summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-04-25 00:05:58 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-04-25 11:58:26 +0100
commit4efd419679e9a43b47bfe970fc5b1c2d7c680890 (patch)
treedf1484d33029d7e78618cffb894c7b151d04bea8 /svtools
parent7d8cc784403f857f652e4579f28a2c0d478610c2 (diff)
after nine years, time to give up on the REGEXP_SUPPORT dream
Diffstat (limited to 'svtools')
-rw-r--r--svtools/inc/svtools/fmtfield.hxx24
-rw-r--r--svtools/source/control/fmtfield.cxx69
2 files changed, 1 insertions, 92 deletions
diff --git a/svtools/inc/svtools/fmtfield.hxx b/svtools/inc/svtools/fmtfield.hxx
index fdbf2518b69b..d4fd75a23797 100644
--- a/svtools/inc/svtools/fmtfield.hxx
+++ b/svtools/inc/svtools/fmtfield.hxx
@@ -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();
}
diff --git a/svtools/source/control/fmtfield.cxx b/svtools/source/control/fmtfield.cxx
index 237d63c44947..98545612b09b 100644
--- a/svtools/source/control/fmtfield.cxx
+++ b/svtools/source/control/fmtfield.cxx
@@ -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
}