summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2011-11-22 14:52:13 +0100
committerEike Rathke <erack@redhat.com>2011-11-22 14:52:41 +0100
commitd66a2c452575f7a1b960e9ec6512b9d32eff4f61 (patch)
tree10be9f3291329cabc1fe6832d217b96b18ef6e78 /svl
parent3b5ee26d2c27b9fb8d3836c470832fc81cda721f (diff)
scan genitive and partitive month names only if they differ
Diffstat (limited to 'svl')
-rw-r--r--svl/source/numbers/zforfind.cxx21
-rw-r--r--svl/source/numbers/zforfind.hxx2
2 files changed, 19 insertions, 4 deletions
diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx
index cfad6e2b7483..18a2fe96b97c 100644
--- a/svl/source/numbers/zforfind.cxx
+++ b/svl/source/numbers/zforfind.cxx
@@ -91,6 +91,9 @@ ImpSvNumberInputScan::ImpSvNumberInputScan( SvNumberFormatter* pFormatterP )
pUpperPartitiveAbbrevMonthText( NULL ),
pUpperDayText( NULL ),
pUpperAbbrevDayText( NULL ),
+ bTextInitialized( false ),
+ bScanGenitiveMonths( false ),
+ bScanPartitiveMonths( false ),
eScannedType( NUMBERFORMAT_UNDEFINED ),
eSetType( NUMBERFORMAT_UNDEFINED )
{
@@ -565,25 +568,25 @@ short ImpSvNumberInputScan::GetMonth( const String& rString, xub_StrLen& nPos )
sal_Int16 nMonths = pFormatter->GetCalendar()->getNumberOfMonthsInYear();
for ( sal_Int16 i = 0; i < nMonths; i++ )
{
- if ( StringContains( pUpperGenitiveMonthText[i], rString, nPos ) )
+ if ( bScanGenitiveMonths && StringContains( pUpperGenitiveMonthText[i], rString, nPos ) )
{ // genitive full names first
nPos = nPos + pUpperGenitiveMonthText[i].Len();
res = i+1;
break; // for
}
- else if ( StringContains( pUpperGenitiveAbbrevMonthText[i], rString, nPos ) )
+ else if ( bScanGenitiveMonths && StringContains( pUpperGenitiveAbbrevMonthText[i], rString, nPos ) )
{ // genitive abbreviated
nPos = nPos + pUpperGenitiveAbbrevMonthText[i].Len();
res = sal::static_int_cast< short >(-(i+1)); // negative
break; // for
}
- else if ( StringContains( pUpperPartitiveMonthText[i], rString, nPos ) )
+ else if ( bScanPartitiveMonths && StringContains( pUpperPartitiveMonthText[i], rString, nPos ) )
{ // partitive full names
nPos = nPos + pUpperPartitiveMonthText[i].Len();
res = i+1;
break; // for
}
- else if ( StringContains( pUpperPartitiveAbbrevMonthText[i], rString, nPos ) )
+ else if ( bScanPartitiveMonths && StringContains( pUpperPartitiveAbbrevMonthText[i], rString, nPos ) )
{ // partitive abbreviated
nPos = nPos + pUpperPartitiveAbbrevMonthText[i].Len();
res = sal::static_int_cast< short >(-(i+1)); // negative
@@ -2462,6 +2465,7 @@ void ImpSvNumberInputScan::InitText()
delete [] pUpperGenitiveMonthText;
delete [] pUpperGenitiveAbbrevMonthText;
xElems = pCal->getGenitiveMonths();
+ bScanGenitiveMonths = (nElems != xElems.getLength());
nElems = xElems.getLength();
pUpperGenitiveMonthText = new String[nElems];
pUpperGenitiveAbbrevMonthText = new String[nElems];
@@ -2469,11 +2473,16 @@ void ImpSvNumberInputScan::InitText()
{
pUpperGenitiveMonthText[j] = pChrCls->upper( xElems[j].FullName );
pUpperGenitiveAbbrevMonthText[j] = pChrCls->upper( xElems[j].AbbrevName );
+ if (!bScanGenitiveMonths &&
+ (pUpperGenitiveMonthText[j] != pUpperMonthText[j] ||
+ pUpperGenitiveAbbrevMonthText[j] != pUpperAbbrevMonthText[j]))
+ bScanGenitiveMonths = true;
}
delete [] pUpperPartitiveMonthText;
delete [] pUpperPartitiveAbbrevMonthText;
xElems = pCal->getPartitiveMonths();
+ bScanPartitiveMonths = (nElems != xElems.getLength());
nElems = xElems.getLength();
pUpperPartitiveMonthText = new String[nElems];
pUpperPartitiveAbbrevMonthText = new String[nElems];
@@ -2481,6 +2490,10 @@ void ImpSvNumberInputScan::InitText()
{
pUpperPartitiveMonthText[j] = pChrCls->upper( xElems[j].FullName );
pUpperPartitiveAbbrevMonthText[j] = pChrCls->upper( xElems[j].AbbrevName );
+ if (!bScanPartitiveMonths &&
+ (pUpperPartitiveMonthText[j] != pUpperGenitiveMonthText[j] ||
+ pUpperPartitiveAbbrevMonthText[j] != pUpperGenitiveAbbrevMonthText[j]))
+ bScanPartitiveMonths = true;
}
delete [] pUpperDayText;
diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx
index c8a6d29ba5f5..d949217cf828 100644
--- a/svl/source/numbers/zforfind.hxx
+++ b/svl/source/numbers/zforfind.hxx
@@ -81,6 +81,8 @@ private:
String* pUpperAbbrevDayText; // Array of day of week names, abbreviated, uppercase
String aUpperCurrSymbol; // Currency symbol, uppercase
bool bTextInitialized; // Whether days and months are initialized
+ bool bScanGenitiveMonths; // Whether to scan an input for genitive months
+ bool bScanPartitiveMonths; // Whether to scan an input for partitive months
Date* pNullDate; // 30Dec1899
// Variables for provisional results:
String sStrArray[SV_MAX_ANZ_INPUT_STRINGS]; // Array of scanned substrings