scan genitive and partitive month names only if they differ
This commit is contained in:
@@ -91,6 +91,9 @@ ImpSvNumberInputScan::ImpSvNumberInputScan( SvNumberFormatter* pFormatterP )
|
|||||||
pUpperPartitiveAbbrevMonthText( NULL ),
|
pUpperPartitiveAbbrevMonthText( NULL ),
|
||||||
pUpperDayText( NULL ),
|
pUpperDayText( NULL ),
|
||||||
pUpperAbbrevDayText( NULL ),
|
pUpperAbbrevDayText( NULL ),
|
||||||
|
bTextInitialized( false ),
|
||||||
|
bScanGenitiveMonths( false ),
|
||||||
|
bScanPartitiveMonths( false ),
|
||||||
eScannedType( NUMBERFORMAT_UNDEFINED ),
|
eScannedType( NUMBERFORMAT_UNDEFINED ),
|
||||||
eSetType( NUMBERFORMAT_UNDEFINED )
|
eSetType( NUMBERFORMAT_UNDEFINED )
|
||||||
{
|
{
|
||||||
@@ -565,25 +568,25 @@ short ImpSvNumberInputScan::GetMonth( const String& rString, xub_StrLen& nPos )
|
|||||||
sal_Int16 nMonths = pFormatter->GetCalendar()->getNumberOfMonthsInYear();
|
sal_Int16 nMonths = pFormatter->GetCalendar()->getNumberOfMonthsInYear();
|
||||||
for ( sal_Int16 i = 0; i < nMonths; i++ )
|
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
|
{ // genitive full names first
|
||||||
nPos = nPos + pUpperGenitiveMonthText[i].Len();
|
nPos = nPos + pUpperGenitiveMonthText[i].Len();
|
||||||
res = i+1;
|
res = i+1;
|
||||||
break; // for
|
break; // for
|
||||||
}
|
}
|
||||||
else if ( StringContains( pUpperGenitiveAbbrevMonthText[i], rString, nPos ) )
|
else if ( bScanGenitiveMonths && StringContains( pUpperGenitiveAbbrevMonthText[i], rString, nPos ) )
|
||||||
{ // genitive abbreviated
|
{ // genitive abbreviated
|
||||||
nPos = nPos + pUpperGenitiveAbbrevMonthText[i].Len();
|
nPos = nPos + pUpperGenitiveAbbrevMonthText[i].Len();
|
||||||
res = sal::static_int_cast< short >(-(i+1)); // negative
|
res = sal::static_int_cast< short >(-(i+1)); // negative
|
||||||
break; // for
|
break; // for
|
||||||
}
|
}
|
||||||
else if ( StringContains( pUpperPartitiveMonthText[i], rString, nPos ) )
|
else if ( bScanPartitiveMonths && StringContains( pUpperPartitiveMonthText[i], rString, nPos ) )
|
||||||
{ // partitive full names
|
{ // partitive full names
|
||||||
nPos = nPos + pUpperPartitiveMonthText[i].Len();
|
nPos = nPos + pUpperPartitiveMonthText[i].Len();
|
||||||
res = i+1;
|
res = i+1;
|
||||||
break; // for
|
break; // for
|
||||||
}
|
}
|
||||||
else if ( StringContains( pUpperPartitiveAbbrevMonthText[i], rString, nPos ) )
|
else if ( bScanPartitiveMonths && StringContains( pUpperPartitiveAbbrevMonthText[i], rString, nPos ) )
|
||||||
{ // partitive abbreviated
|
{ // partitive abbreviated
|
||||||
nPos = nPos + pUpperPartitiveAbbrevMonthText[i].Len();
|
nPos = nPos + pUpperPartitiveAbbrevMonthText[i].Len();
|
||||||
res = sal::static_int_cast< short >(-(i+1)); // negative
|
res = sal::static_int_cast< short >(-(i+1)); // negative
|
||||||
@@ -2462,6 +2465,7 @@ void ImpSvNumberInputScan::InitText()
|
|||||||
delete [] pUpperGenitiveMonthText;
|
delete [] pUpperGenitiveMonthText;
|
||||||
delete [] pUpperGenitiveAbbrevMonthText;
|
delete [] pUpperGenitiveAbbrevMonthText;
|
||||||
xElems = pCal->getGenitiveMonths();
|
xElems = pCal->getGenitiveMonths();
|
||||||
|
bScanGenitiveMonths = (nElems != xElems.getLength());
|
||||||
nElems = xElems.getLength();
|
nElems = xElems.getLength();
|
||||||
pUpperGenitiveMonthText = new String[nElems];
|
pUpperGenitiveMonthText = new String[nElems];
|
||||||
pUpperGenitiveAbbrevMonthText = new String[nElems];
|
pUpperGenitiveAbbrevMonthText = new String[nElems];
|
||||||
@@ -2469,11 +2473,16 @@ void ImpSvNumberInputScan::InitText()
|
|||||||
{
|
{
|
||||||
pUpperGenitiveMonthText[j] = pChrCls->upper( xElems[j].FullName );
|
pUpperGenitiveMonthText[j] = pChrCls->upper( xElems[j].FullName );
|
||||||
pUpperGenitiveAbbrevMonthText[j] = pChrCls->upper( xElems[j].AbbrevName );
|
pUpperGenitiveAbbrevMonthText[j] = pChrCls->upper( xElems[j].AbbrevName );
|
||||||
|
if (!bScanGenitiveMonths &&
|
||||||
|
(pUpperGenitiveMonthText[j] != pUpperMonthText[j] ||
|
||||||
|
pUpperGenitiveAbbrevMonthText[j] != pUpperAbbrevMonthText[j]))
|
||||||
|
bScanGenitiveMonths = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] pUpperPartitiveMonthText;
|
delete [] pUpperPartitiveMonthText;
|
||||||
delete [] pUpperPartitiveAbbrevMonthText;
|
delete [] pUpperPartitiveAbbrevMonthText;
|
||||||
xElems = pCal->getPartitiveMonths();
|
xElems = pCal->getPartitiveMonths();
|
||||||
|
bScanPartitiveMonths = (nElems != xElems.getLength());
|
||||||
nElems = xElems.getLength();
|
nElems = xElems.getLength();
|
||||||
pUpperPartitiveMonthText = new String[nElems];
|
pUpperPartitiveMonthText = new String[nElems];
|
||||||
pUpperPartitiveAbbrevMonthText = new String[nElems];
|
pUpperPartitiveAbbrevMonthText = new String[nElems];
|
||||||
@@ -2481,6 +2490,10 @@ void ImpSvNumberInputScan::InitText()
|
|||||||
{
|
{
|
||||||
pUpperPartitiveMonthText[j] = pChrCls->upper( xElems[j].FullName );
|
pUpperPartitiveMonthText[j] = pChrCls->upper( xElems[j].FullName );
|
||||||
pUpperPartitiveAbbrevMonthText[j] = pChrCls->upper( xElems[j].AbbrevName );
|
pUpperPartitiveAbbrevMonthText[j] = pChrCls->upper( xElems[j].AbbrevName );
|
||||||
|
if (!bScanPartitiveMonths &&
|
||||||
|
(pUpperPartitiveMonthText[j] != pUpperGenitiveMonthText[j] ||
|
||||||
|
pUpperPartitiveAbbrevMonthText[j] != pUpperGenitiveAbbrevMonthText[j]))
|
||||||
|
bScanPartitiveMonths = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] pUpperDayText;
|
delete [] pUpperDayText;
|
||||||
|
@@ -81,6 +81,8 @@ private:
|
|||||||
String* pUpperAbbrevDayText; // Array of day of week names, abbreviated, uppercase
|
String* pUpperAbbrevDayText; // Array of day of week names, abbreviated, uppercase
|
||||||
String aUpperCurrSymbol; // Currency symbol, uppercase
|
String aUpperCurrSymbol; // Currency symbol, uppercase
|
||||||
bool bTextInitialized; // Whether days and months are initialized
|
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
|
Date* pNullDate; // 30Dec1899
|
||||||
// Variables for provisional results:
|
// Variables for provisional results:
|
||||||
String sStrArray[SV_MAX_ANZ_INPUT_STRINGS]; // Array of scanned substrings
|
String sStrArray[SV_MAX_ANZ_INPUT_STRINGS]; // Array of scanned substrings
|
||||||
|
Reference in New Issue
Block a user