Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
4efd4196
Kaydet (Commit)
4efd4196
authored
Nis 24, 2012
tarafından
Caolán McNamara
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
after nine years, time to give up on the REGEXP_SUPPORT dream
üst
7d8cc784
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
92 deletions
+1
-92
fmtfield.hxx
svtools/inc/svtools/fmtfield.hxx
+1
-23
fmtfield.cxx
svtools/source/control/fmtfield.cxx
+0
-69
No files found.
svtools/inc/svtools/fmtfield.hxx
Dosyayı görüntüle @
4efd4196
...
...
@@ -33,17 +33,7 @@
#include <vcl/spinfld.hxx>
#include <svl/zforlist.hxx>
//#define REGEXP_SUPPORT
#ifdef REGEXP_SUPPORT
#ifndef _UNOTOOLS_TEXTSEARCH_HXX
#include <unotools/textsearch.hxx>
#endif
#else
// use a hand-made regular expression parsing for the small expression we're interested in
// as soon as OOo does have regular expression support, we can switch on the REGEXP_SUPPORT define
namespace
validation
{
class
NumberValidator
;
}
#endif
namespace
validation
{
class
NumberValidator
;
}
typedef
sal_uInt16
FORMAT_CHANGE_TYPE
;
#define FCT_KEYONLY 0x00 // only a new key was set
...
...
@@ -282,31 +272,19 @@ protected:
class
SVT_DLLPUBLIC
DoubleNumericField
:
public
FormattedField
{
protected
:
#ifdef REGEXP_SUPPORT
::
utl
::
TextSearch
*
m_pConformanceTester
;
#else
validation
::
NumberValidator
*
m_pNumberValidator
;
#endif
public
:
DoubleNumericField
(
Window
*
pParent
,
WinBits
nStyle
=
0
)
:
FormattedField
(
pParent
,
nStyle
)
#ifdef REGEXP_SUPPORT
,
m_pConformanceTester
(
NULL
)
#else
,
m_pNumberValidator
(
NULL
)
#endif
{
ResetConformanceTester
();
}
DoubleNumericField
(
Window
*
pParent
,
const
ResId
&
rResId
)
:
FormattedField
(
pParent
,
rResId
)
#ifdef REGEXP_SUPPORT
,
m_pConformanceTester
(
NULL
)
#else
,
m_pNumberValidator
(
NULL
)
#endif
{
ResetConformanceTester
();
}
...
...
svtools/source/control/fmtfield.cxx
Dosyayı görüntüle @
4efd4196
...
...
@@ -42,30 +42,12 @@
#include <com/sun/star/util/SearchResult.hpp>
#include <com/sun/star/util/SearchFlags.hpp>
#include <unotools/syslocale.hxx>
#ifndef REGEXP_SUPPORT
#include <map>
#endif
#if !defined INCLUDED_RTL_MATH_HXX
#include <rtl/math.hxx>
#endif
using
namespace
::
com
::
sun
::
star
::
lang
;
using
namespace
::
com
::
sun
::
star
::
util
;
#ifdef REGEXP_SUPPORT
//==============================================================================
// regular expression to validate complete numbers, plus every fragment which can occur during the input
// of a complete number
// [+/-][{digit}*.]*{digit}*[,{digit}*][e[+/-]{digit}*]
const
char
szNumericInput
[]
=
"_[-+]?([0-9]*
\\
,)*[0-9]*(
\\
.[0-9]*)?(e[-+]?[0-9]*)?_"
;
// (the two _ are for normalizing it: With this, we can ensure that a to-be-checked text is always
// matched as a _whole_)
#else
// hmm. No support for regular expression. Well, I always (not really :) wanted to write a finite automat
// so here comes a finite automat ...
...
...
@@ -300,8 +282,6 @@ namespace validation
}
}
#endif
//==============================================================================
SvNumberFormatter
*
FormattedField
::
StaticFormatter
::
s_cFormatter
=
NULL
;
sal_uLong
FormattedField
::
StaticFormatter
::
s_nReferences
=
0
;
...
...
@@ -1135,11 +1115,7 @@ bool FormattedField::IsUsingInputStringForFormatting() const
//------------------------------------------------------------------------------
DoubleNumericField
::~
DoubleNumericField
()
{
#ifdef REGEXP_SUPPORT
delete
m_pConformanceTester
;
#else
delete
m_pNumberValidator
;
#endif
}
//------------------------------------------------------------------------------
...
...
@@ -1155,25 +1131,7 @@ sal_Bool DoubleNumericField::CheckText(const XubString& sText) const
// We'd like to implement this using the NumberFormatter::IsNumberFormat, but unfortunately, this doesn't
// recognize fragments of numbers (like, for instance "1e", which happens during entering e.g. "1e10")
// Thus, the roundabout way via a regular expression
#ifdef REGEXP_SUPPORT
if
(
!
sText
.
Len
())
return
sal_True
;
String
sForceComplete
=
'_'
;
sForceComplete
+=
sText
;
sForceComplete
+=
'_'
;
sal_uInt16
nStart
=
0
,
nEnd
=
sForceComplete
.
Len
();
sal_Bool
bFound
=
m_pConformanceTester
->
SearchFrwrd
(
sForceComplete
,
&
nStart
,
&
nEnd
);
if
(
bFound
&&
(
nStart
==
0
)
&&
(
nEnd
==
sForceComplete
.
Len
()))
return
sal_True
;
return
sal_False
;
#else
return
m_pNumberValidator
->
isValidNumericFragment
(
sText
);
#endif
}
//------------------------------------------------------------------------------
...
...
@@ -1199,35 +1157,8 @@ void DoubleNumericField::ResetConformanceTester()
cSeparatorDecimal
=
sSeparator
.
GetBuffer
()[
0
];
}
#ifdef REGEXP_SUPPORT
String
sDescription
=
String
::
CreateFromAscii
(
szNumericInput
);
String
sReplaceWith
((
sal_Unicode
)
'\\'
);
sReplaceWith
+=
cSeparatorThousand
;
sDescription
.
SearchAndReplaceAscii
(
"
\\
,"
,
sReplaceWith
);
sReplaceWith
=
(
sal_Unicode
)
'\\'
;
sReplaceWith
+=
cSeparatorDecimal
;
sDescription
.
SearchAndReplaceAscii
(
"
\\
."
,
sReplaceWith
);
delete
m_pConformanceTester
;
SearchOptions
aParam
;
aParam
.
algorithmType
=
SearchAlgorithms_REGEXP
;
aParam
.
searchFlag
=
SearchFlags
::
ALL_IGNORE_CASE
;
aParam
.
searchString
=
sDescription
;
aParam
.
transliterateFlags
=
0
;
String
sLanguage
,
sCountry
;
ConvertLanguageToIsoNames
(
pFormatEntry
?
pFormatEntry
->
GetLanguage
()
:
LANGUAGE_ENGLISH_US
,
sLanguage
,
sCountry
);
aParam
.
Locale
.
Language
=
sLanguage
;
aParam
.
Locale
.
Country
=
sCountry
;
m_pConformanceTester
=
new
::
utl
::
TextSearch
(
aParam
);
#else
delete
m_pNumberValidator
;
m_pNumberValidator
=
new
validation
::
NumberValidator
(
cSeparatorThousand
,
cSeparatorDecimal
);
#endif
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment