Kaydet (Commit) e8b2e916 authored tarafından Eike Rathke's avatar Eike Rathke

Back out change for fdo#78119 now that we have StringContainsWord()

This reverts commit 3b3b690c1f0479cfbebcfa68595f75a4994e7a5f.

With the use of StringContainsWord() it is unnecessary to loop all
available names.
üst 3885b5d4
...@@ -609,7 +609,6 @@ short ImpSvNumberInputScan::GetMonth( const OUString& rString, sal_Int32& nPos ) ...@@ -609,7 +609,6 @@ short ImpSvNumberInputScan::GetMonth( const OUString& rString, sal_Int32& nPos )
static const OUString aSepShortened("SEP"); static const OUString aSepShortened("SEP");
short res = 0; // no month found short res = 0; // no month found
int nMatchLen = 0;
if (rString.getLength() > nPos) // only if needed if (rString.getLength() > nPos) // only if needed
{ {
...@@ -618,80 +617,54 @@ short ImpSvNumberInputScan::GetMonth( const OUString& rString, sal_Int32& nPos ) ...@@ -618,80 +617,54 @@ short ImpSvNumberInputScan::GetMonth( const OUString& rString, sal_Int32& nPos )
InitText(); InitText();
} }
sal_Int16 nMonths = pFormatter->GetCalendar()->getNumberOfMonthsInYear(); sal_Int16 nMonths = pFormatter->GetCalendar()->getNumberOfMonthsInYear();
// Find the longest match. This is needed for, e.g., Czech, as Červen (June)
// is fully contained in Červenec (July), so the latter could never be found
// if we stopped at the first match.
for ( sal_Int16 i = 0; i < nMonths; i++ ) for ( sal_Int16 i = 0; i < nMonths; i++ )
{ {
if ( bScanGenitiveMonths && StringContainsWord( pUpperGenitiveMonthText[i], rString, nPos ) ) if ( bScanGenitiveMonths && StringContainsWord( pUpperGenitiveMonthText[i], rString, nPos ) )
{ // genitive full names first { // genitive full names first
const int nMonthLen = pUpperGenitiveMonthText[i].getLength(); nPos = nPos + pUpperGenitiveMonthText[i].getLength();
if (nMonthLen > nMatchLen)
{
nMatchLen = nMonthLen;
res = i + 1; res = i + 1;
} break; // for
} }
else if ( bScanGenitiveMonths && StringContainsWord( pUpperGenitiveAbbrevMonthText[i], rString, nPos ) ) else if ( bScanGenitiveMonths && StringContainsWord( pUpperGenitiveAbbrevMonthText[i], rString, nPos ) )
{ // genitive abbreviated { // genitive abbreviated
const int nMonthLen = pUpperGenitiveAbbrevMonthText[i].getLength(); nPos = nPos + pUpperGenitiveAbbrevMonthText[i].getLength();
if (nMonthLen > nMatchLen)
{
nMatchLen = nMonthLen;
res = sal::static_int_cast< short >(-(i+1)); // negative res = sal::static_int_cast< short >(-(i+1)); // negative
} break; // for
} }
else if ( bScanPartitiveMonths && StringContainsWord( pUpperPartitiveMonthText[i], rString, nPos ) ) else if ( bScanPartitiveMonths && StringContainsWord( pUpperPartitiveMonthText[i], rString, nPos ) )
{ // partitive full names { // partitive full names
const int nMonthLen = pUpperPartitiveMonthText[i].getLength(); nPos = nPos + pUpperPartitiveMonthText[i].getLength();
if (nMonthLen > nMatchLen)
{
nMatchLen = nMonthLen;
res = i+1; res = i+1;
} break; // for
} }
else if ( bScanPartitiveMonths && StringContainsWord( pUpperPartitiveAbbrevMonthText[i], rString, nPos ) ) else if ( bScanPartitiveMonths && StringContainsWord( pUpperPartitiveAbbrevMonthText[i], rString, nPos ) )
{ // partitive abbreviated { // partitive abbreviated
const int nMonthLen = pUpperPartitiveAbbrevMonthText[i].getLength(); nPos = nPos + pUpperPartitiveAbbrevMonthText[i].getLength();
if (nMonthLen > nMatchLen)
{
nMatchLen = nMonthLen;
res = sal::static_int_cast< short >(-(i+1)); // negative res = sal::static_int_cast< short >(-(i+1)); // negative
} break; // for
} }
else if ( StringContainsWord( pUpperMonthText[i], rString, nPos ) ) else if ( StringContainsWord( pUpperMonthText[i], rString, nPos ) )
{ // noun full names { // noun full names
const int nMonthLen = pUpperMonthText[i].getLength(); nPos = nPos + pUpperMonthText[i].getLength();
if (nMonthLen > nMatchLen)
{
nMatchLen = nMonthLen;
res = i+1; res = i+1;
} break; // for
} }
else if ( StringContainsWord( pUpperAbbrevMonthText[i], rString, nPos ) ) else if ( StringContainsWord( pUpperAbbrevMonthText[i], rString, nPos ) )
{ // noun abbreviated { // noun abbreviated
const int nMonthLen = pUpperAbbrevMonthText[i].getLength(); nPos = nPos + pUpperAbbrevMonthText[i].getLength();
if (nMonthLen > nMatchLen)
{
nMatchLen = nMonthLen;
res = sal::static_int_cast< short >(-(i+1)); // negative res = sal::static_int_cast< short >(-(i+1)); // negative
} break; // for
} }
else if ( i == 8 && pUpperAbbrevMonthText[i] == aSeptCorrect && else if ( i == 8 && pUpperAbbrevMonthText[i] == aSeptCorrect &&
StringContainsWord( aSepShortened, rString, nPos ) ) StringContainsWord( aSepShortened, rString, nPos ) )
{ // #102136# SEPT/SEP { // #102136# SEPT/SEP
const int nMonthLen = aSepShortened.getLength(); nPos = nPos + aSepShortened.getLength();
if (nMonthLen > nMatchLen)
{
nMatchLen = nMonthLen;
res = sal::static_int_cast< short >(-(i+1)); // negative res = sal::static_int_cast< short >(-(i+1)); // negative
break; // for
} }
} }
} }
nPos += nMatchLen;
}
return res; return res;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment