diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2012-11-06 13:58:20 -0600 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2012-11-18 19:57:23 -0600 |
commit | 1599fc9e54a7c4855bee1c30d92dd1f5be05f530 (patch) | |
tree | d3952cdcb599c86d92bfcb2268c612af6c7b8789 | |
parent | 6dbf5f7ea0187aa6c4e1c45fc2d2cd03b2b67b0a (diff) |
svl: OUString conversion of most of zforscan
Change-Id: I02ca7f7770e2d53371e7c597c087c4a370ce8d3f
-rw-r--r-- | svl/inc/svl/zforlist.hxx | 2 | ||||
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 4 | ||||
-rw-r--r-- | svl/source/numbers/zformat.cxx | 34 | ||||
-rw-r--r-- | svl/source/numbers/zforscan.cxx | 3020 | ||||
-rw-r--r-- | svl/source/numbers/zforscan.hxx | 56 | ||||
-rw-r--r-- | xmloff/source/style/xmlnumfe.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/style/xmlnumfi.cxx | 2 |
7 files changed, 1628 insertions, 1496 deletions
diff --git a/svl/inc/svl/zforlist.hxx b/svl/inc/svl/zforlist.hxx index d5b2992fe83c..ea40a506523d 100644 --- a/svl/inc/svl/zforlist.hxx +++ b/svl/inc/svl/zforlist.hxx @@ -777,7 +777,7 @@ public: LanguageType eFormatLanguage, bool bOnlyStringLanguage = false ); /// Get compatibility ("automatic" old style) currency from I18N locale data - void GetCompatibilityCurrency( String& rSymbol, String& rAbbrev ) const; + void GetCompatibilityCurrency( OUString& rSymbol, OUString& rAbbrev ) const; /// Fill rList with the language/country codes that have been allocated void GetUsedLanguages( std::vector<sal_uInt16>& rList ); diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 9e0d93bc35dc..60726af504da 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -2783,7 +2783,7 @@ OUString SvNumberFormatter::GenerateFormat(sal_uInt32 nIndex, } else { // "automatic" old style - String aSymbol, aAbbrev; + OUString aSymbol, aAbbrev; GetCompatibilityCurrency( aSymbol, aAbbrev ); ImpGetPosCurrFormat( sString, aSymbol ); ImpGetNegCurrFormat( sNegStr, aSymbol ); @@ -3449,7 +3449,7 @@ const NfCurrencyEntry* SvNumberFormatter::GetCurrencyEntry( bool & bFoundBank, } -void SvNumberFormatter::GetCompatibilityCurrency( String& rSymbol, String& rAbbrev ) const +void SvNumberFormatter::GetCompatibilityCurrency( OUString& rSymbol, OUString& rAbbrev ) const { ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Currency2 > xCurrencies( xLocaleData->getAllCurrencies() ); diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 3272a10fc376..408bd6a4fe29 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -937,10 +937,14 @@ SvNumberformat::SvNumberformat(String& rString, if (sInsertCalendar.Len()) sStr.Insert( sInsertCalendar, 0); - xub_StrLen nStrPos = pSc->ScanFormat( sStr ); + OUString aStr(sStr); + sal_Int32 nStrPos = pSc->ScanFormat( aStr); + sStr = aStr; sal_uInt16 nAnz = pSc->GetAnzResStrings(); if (nAnz == 0) // error + { nStrPos = 1; + } if (nStrPos == 0) // ok { // e.g. Thai T speciality @@ -1019,34 +1023,42 @@ SvNumberformat::SvNumberformat(String& rString, } } if ( bCancel && !nCheckPos ) + { nCheckPos = 1; // nCheckPos is used as an error condition + } if ( !bCancel ) { if ( NumFor[nIndex].GetNatNum().IsSet() && - NumFor[nIndex].GetNatNum().GetLang() == LANGUAGE_DONTKNOW ) + NumFor[nIndex].GetNatNum().GetLang() == LANGUAGE_DONTKNOW ) + { NumFor[nIndex].SetNatNumLang( eLan ); + } } if (rString.Len() == nPos) { if ( nIndex == 2 && eSymbolType == BRACKET_SYMBOLTYPE_FORMAT && rString.GetChar(nPos-1) == ';' ) - { // #83510# A 4th subformat explicitly specified to be empty + { + // #83510# A 4th subformat explicitly specified to be empty // hides any text. Need the type here for HasTextFormat() NumFor[3].Info().eScannedType = NUMBERFORMAT_TEXT; } bCancel = true; } if ( NumFor[nIndex].GetNatNum().IsSet() ) + { NumFor[nIndex].SetNatNumDate( (NumFor[nIndex].Info().eScannedType & NUMBERFORMAT_DATE) != 0 ); + } } if ( bCondition && !nCheckPos ) { if ( nIndex == 1 && NumFor[0].GetCount() == 0 && - rString.GetChar(rString.Len()-1) != ';' ) - { // No format code => GENERAL but not if specified empty - String aAdd( pSc->GetStandardName() ); + rString.GetChar(rString.Len()-1) != ';' ) + { + // No format code => GENERAL but not if specified empty + OUString aAdd( pSc->GetStandardName() ); if ( !pSc->ScanFormat( aAdd ) ) { sal_uInt16 nAnz = pSc->GetAnzResStrings(); @@ -1062,9 +1074,10 @@ SvNumberformat::SvNumberformat(String& rString, rString.GetChar(rString.Len()-1) != ';' && (NumFor[0].GetCount() > 1 || (NumFor[0].GetCount() == 1 && NumFor[0].Info().nTypeArray[0] != NF_KEY_GENERAL)) ) - { // No trailing second subformat => GENERAL but not if specified empty + { + // No trailing second subformat => GENERAL but not if specified empty // and not if first subformat is GENERAL - String aAdd( pSc->GetStandardName() ); + OUString aAdd( pSc->GetStandardName() ); if ( !pSc->ScanFormat( aAdd ) ) { sal_uInt16 nAnz = pSc->GetAnzResStrings(); @@ -1080,8 +1093,9 @@ SvNumberformat::SvNumberformat(String& rString, else if ( nIndex == 2 && NumFor[nIndex].GetCount() == 0 && rString.GetChar(rString.Len()-1) != ';' && eOp2 != NUMBERFORMAT_OP_NO ) - { // No trailing third subformat => GENERAL but not if specified empty - String aAdd( pSc->GetStandardName() ); + { + // No trailing third subformat => GENERAL but not if specified empty + OUString aAdd( pSc->GetStandardName() ); if ( !pSc->ScanFormat( aAdd ) ) { sal_uInt16 nAnz = pSc->GetAnzResStrings(); diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx index c81ac8b0897c..afb132d54098 100644 --- a/svl/source/numbers/zforscan.cxx +++ b/svl/source/numbers/zforscan.cxx @@ -103,7 +103,7 @@ ImpSvNumberformatScan::ImpSvNumberformatScan( SvNumberFormatter* pFormatterP ) pNullDate = new Date(30,12,1899); nStandardPrec = 2; - sErrStr.AssignAscii( RTL_CONSTASCII_STRINGPARAM( "###")); + sErrStr = "###"; Reset(); } @@ -526,9 +526,9 @@ Color* ImpSvNumberformatScan::GetColor(OUString& sStr) return pResult; } -short ImpSvNumberformatScan::GetKeyWord( const String& sSymbol, xub_StrLen nPos ) +short ImpSvNumberformatScan::GetKeyWord( const OUString& sSymbol, sal_Int32 nPos ) { - OUString sString = pFormatter->GetCharClass()->uppercase( sSymbol, nPos, sSymbol.Len() - nPos ); + OUString sString = pFormatter->GetCharClass()->uppercase( sSymbol, nPos, sSymbol.getLength() - nPos ); const NfKeywordTable & rKeyword = GetKeywords(); // #77026# for the Xcl perverts: the GENERAL keyword is recognized anywhere if ( sString.startsWith( rKeyword[NF_KEY_GENERAL] )) @@ -632,269 +632,260 @@ enum ScanState SsGetBlank = 6 }; -short ImpSvNumberformatScan::Next_Symbol( const String& rStr, - xub_StrLen& nPos, String& sSymbol ) +short ImpSvNumberformatScan::Next_Symbol( const OUString& rStr, + sal_Int32& nPos, + OUString& sSymbol ) { if ( bKeywordsNeedInit ) + { InitKeywords(); + } const CharClass* pChrCls = pFormatter->GetCharClass(); const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData(); - const xub_StrLen nStart = nPos; + const sal_Int32 nStart = nPos; short eType = 0; ScanState eState = SsStart; - sSymbol.Erase(); - while ( nPos < rStr.Len() && eState != SsStop ) + sSymbol = ""; + while ( nPos < rStr.getLength() && eState != SsStop ) { - sal_Unicode cToken = rStr.GetChar( nPos++ ); + sal_Unicode cToken = rStr[nPos++]; switch (eState) { - case SsStart: + case SsStart: + // Fetch any currency longer than one character and don't get + // confused later on by "E/" or other combinations of letters + // and meaningful symbols. Necessary for old automatic currency. + // #96158# But don't do it if we're starting a "[...]" section, + // for example a "[$...]" new currency symbol to not parse away + // "$U" (symbol) of "[$UYU]" (abbreviation). + if ( nCurrPos >= 0 && sCurString.getLength() > 1 && + nPos-1 + sCurString.getLength() <= rStr.getLength() && + !(nPos > 1 && rStr[nPos-2] == '[') ) { - // Fetch any currency longer than one character and don't get - // confused later on by "E/" or other combinations of letters - // and meaningful symbols. Necessary for old automatic currency. - // #96158# But don't do it if we're starting a "[...]" section, - // for example a "[$...]" new currency symbol to not parse away - // "$U" (symbol) of "[$UYU]" (abbreviation). - if ( nCurrPos != STRING_NOTFOUND && sCurString.Len() > 1 && - nPos-1 + sCurString.Len() <= rStr.Len() && - !(nPos > 1 && rStr.GetChar( nPos-2 ) == '[') ) + OUString aTest = pChrCls->uppercase( rStr.copy( nPos-1, sCurString.getLength() ) ); + if ( aTest == sCurString ) { - String aTest = pChrCls->uppercase( rStr.Copy( nPos-1, sCurString.Len() ) ); - if ( aTest == sCurString ) - { - sSymbol = rStr.Copy( --nPos, sCurString.Len() ); - nPos = nPos + sSymbol.Len(); - eState = SsStop; - eType = NF_SYMBOLTYPE_STRING; - return eType; - } + sSymbol = rStr.copy( --nPos, sCurString.getLength() ); + nPos = nPos + sSymbol.getLength(); + eState = SsStop; + eType = NF_SYMBOLTYPE_STRING; + return eType; } - switch (cToken) + } + switch (cToken) + { + case '#': + case '0': + case '?': + case '%': + case '@': + case '[': + case ']': + case ',': + case '.': + case '/': + case '\'': + case ' ': + case ':': + case '-': + eType = NF_SYMBOLTYPE_DEL; + sSymbol += OUString(cToken); + eState = SsStop; + break; + case '*': + eType = NF_SYMBOLTYPE_STAR; + sSymbol += OUString(cToken); + eState = SsGetStar; + break; + case '_': + eType = NF_SYMBOLTYPE_BLANK; + sSymbol += OUString(cToken); + eState = SsGetBlank; + break; + case '"': + eType = NF_SYMBOLTYPE_STRING; + eState = SsGetString; + sSymbol += OUString(cToken); + break; + case '\\': + eType = NF_SYMBOLTYPE_STRING; + eState = SsGetChar; + sSymbol += OUString(cToken); + break; + case '$': + case '+': + case '(': + case ')': + eType = NF_SYMBOLTYPE_STRING; + eState = SsStop; + sSymbol += OUString(cToken); + break; + default : + if (StringEqualsChar( pFormatter->GetNumDecimalSep(), cToken) || + StringEqualsChar( pFormatter->GetNumThousandSep(), cToken) || + StringEqualsChar( pFormatter->GetDateSep(), cToken) || + StringEqualsChar( pLoc->getTimeSep(), cToken) || + StringEqualsChar( pLoc->getTime100SecSep(), cToken)) { - case '#': - case '0': - case '?': - case '%': - case '@': - case '[': - case ']': - case ',': - case '.': - case '/': - case '\'': - case ' ': - case ':': - case '-': - { - eType = NF_SYMBOLTYPE_DEL; - sSymbol += cToken; - eState = SsStop; - } - break; - case '*': - { - eType = NF_SYMBOLTYPE_STAR; - sSymbol += cToken; - eState = SsGetStar; - } - break; - case '_': - { - eType = NF_SYMBOLTYPE_BLANK; - sSymbol += cToken; - eState = SsGetBlank; - } - break; - case '"': - eType = NF_SYMBOLTYPE_STRING; - eState = SsGetString; - sSymbol += cToken; - break; - case '\\': - eType = NF_SYMBOLTYPE_STRING; - eState = SsGetChar; - sSymbol += cToken; - break; - case '$': - case '+': - case '(': - case ')': - eType = NF_SYMBOLTYPE_STRING; - eState = SsStop; - sSymbol += cToken; - break; - default : + // Another separator than pre-known ASCII + eType = NF_SYMBOLTYPE_DEL; + sSymbol += OUString(cToken); + eState = SsStop; + } + else if ( pChrCls->isLetter( rStr, nPos-1 ) ) + { + short nTmpType = GetKeyWord( rStr, nPos-1 ); + if ( nTmpType ) { - if (StringEqualsChar( pFormatter->GetNumDecimalSep(), cToken) || - StringEqualsChar( pFormatter->GetNumThousandSep(), cToken) || - StringEqualsChar( pFormatter->GetDateSep(), cToken) || - StringEqualsChar( pLoc->getTimeSep(), cToken) || - StringEqualsChar( pLoc->getTime100SecSep(), cToken)) + bool bCurrency = false; + // "Automatic" currency may start with keyword, + // like "R" (Rand) and 'R' (era) + if ( nCurrPos != STRING_NOTFOUND && + nPos-1 + sCurString.getLength() <= rStr.getLength() && + sCurString.indexOf( sKeyword[nTmpType] ) == 0 ) { - // Another separator than pre-known ASCII - eType = NF_SYMBOLTYPE_DEL; - sSymbol += cToken; - eState = SsStop; + OUString aTest = pChrCls->uppercase( rStr.copy( nPos-1, sCurString.getLength() ) ); + if ( aTest == sCurString ) + { + bCurrency = true; + } } - else if ( pChrCls->isLetter( rStr, nPos-1 ) ) + if ( bCurrency ) { - short nTmpType = GetKeyWord( rStr, nPos-1 ); - if ( nTmpType ) + eState = SsGetWord; + sSymbol += OUString(cToken); + } + else + { + eType = nTmpType; + sal_Int32 nLen = sKeyword[eType].getLength(); + sSymbol = rStr.copy( nPos-1, nLen ); + if ( eType == NF_KEY_E || IsAmbiguousE( eType ) ) { - bool bCurrency = false; - // "Automatic" currency may start with keyword, - // like "R" (Rand) and 'R' (era) - if ( nCurrPos != STRING_NOTFOUND && - nPos-1 + sCurString.Len() <= rStr.Len() && - sCurString.Search( String(sKeyword[nTmpType]) ) == 0 ) - { - String aTest = pChrCls->uppercase( rStr.Copy( nPos-1, sCurString.Len() ) ); - if ( aTest == sCurString ) - bCurrency = true; - } - if ( bCurrency ) - { - eState = SsGetWord; - sSymbol += cToken; - } - else + sal_Unicode cNext = rStr[nPos]; + switch ( cNext ) { - eType = nTmpType; - sal_Int32 nLen = sKeyword[eType].getLength(); - sSymbol = rStr.Copy( nPos-1, (sal_uInt16)nLen ); - if ( eType == NF_KEY_E || IsAmbiguousE( eType ) ) - { - sal_Unicode cNext = rStr.GetChar(nPos); - switch ( cNext ) - { - case '+' : - case '-' : // E+ E- combine to one symbol - sSymbol += cNext; - eType = NF_KEY_E; - nPos++; - break; - case '0' : - case '#' : // scientific E without sign - eType = NF_KEY_E; - break; - } - } - nPos--; - nPos = nPos + nLen; - eState = SsStop; + case '+' : + case '-' : // E+ E- combine to one symbol + sSymbol += OUString(cNext); + eType = NF_KEY_E; + nPos++; + break; + case '0' : + case '#' : // scientific E without sign + eType = NF_KEY_E; + break; } } - else - { - eState = SsGetWord; - sSymbol += cToken; - } - } - else - { - eType = NF_SYMBOLTYPE_STRING; + nPos--; + nPos = nPos + nLen; eState = SsStop; - sSymbol += cToken; } } - break; + else + { + eState = SsGetWord; + sSymbol += OUString(cToken); + } } + else + { + eType = NF_SYMBOLTYPE_STRING; + eState = SsStop; + sSymbol += OUString(cToken); + } + break; } break; - case SsGetChar: - { - sSymbol += cToken; - eState = SsStop; - } + case SsGetChar: + sSymbol += OUString(cToken); + eState = SsStop; break; - case SsGetString: + case SsGetString: + if (cToken == '"') { - if (cToken == '"') - eState = SsStop; - sSymbol += cToken; + eState = SsStop; } + sSymbol += OUString(cToken); break; - case SsGetWord: + case SsGetWord: + if ( pChrCls->isLetter( rStr, nPos-1 ) ) { - if ( pChrCls->isLetter( rStr, nPos-1 ) ) + short nTmpType = GetKeyWord( rStr, nPos-1 ); + if ( nTmpType ) { - short nTmpType = GetKeyWord( rStr, nPos-1 ); - if ( nTmpType ) - { // beginning of keyword, stop scan and put back - eType = NF_SYMBOLTYPE_STRING; - eState = SsStop; - nPos--; - } - else - sSymbol += cToken; + // beginning of keyword, stop scan and put back + eType = NF_SYMBOLTYPE_STRING; + eState = SsStop; + nPos--; } else { - bool bDontStop = false; - switch (cToken) + sSymbol += OUString(cToken); + } + } + else + { + bool bDontStop = false; + sal_Unicode cNext; + switch (cToken) + { + case '/': // AM/PM, A/P + cNext = rStr[nPos]; + if ( cNext == 'P' || cNext == 'p' ) { - case '/': // AM/PM, A/P + sal_Int32 nLen = sSymbol.getLength(); + if ( 1 <= nLen && + (sSymbol[0] == 'A' || sSymbol[0] == 'a') && + (nLen == 1 || + (nLen == 2 && (sSymbol[1] == 'M' || sSymbol[1] == 'm') + && (rStr[nPos + 1] == 'M' || rStr[nPos + 1] == 'm')))) { - sal_Unicode cNext = rStr.GetChar(nPos); - if ( cNext == 'P' || cNext == 'p' ) - { - xub_StrLen nLen = sSymbol.Len(); - if ( 1 <= nLen - && (sSymbol.GetChar(0) == 'A' || sSymbol.GetChar(0) == 'a') - && (nLen == 1 || (nLen == 2 - && (sSymbol.GetChar(1) == 'M' || sSymbol.GetChar(1) == 'm') - && (rStr.GetChar(nPos+1) == 'M' || rStr.GetChar(nPos+1) == 'm'))) ) - { - sSymbol += cToken; - bDontStop = true; - } - } + sSymbol += OUString(cToken); + bDontStop = true; } - break; - } - // anything not recognized will stop the scan - if ( eState != SsStop && !bDontStop ) - { - eState = SsStop; - nPos--; - eType = NF_SYMBOLTYPE_STRING; } + break; + } + // anything not recognized will stop the scan + if ( eState != SsStop && !bDontStop ) + { + eState = SsStop; + nPos--; + eType = NF_SYMBOLTYPE_STRING; } } break; - case SsGetStar: - { - eState = SsStop; - sSymbol += cToken; - nRepPos = (nPos - nStart) - 1; // everytime > 0!! - } + case SsGetStar: + eState = SsStop; + sSymbol += OUString(cToken); + nRepPos = (nPos - nStart) - 1; // everytime > 0!! break; - case SsGetBlank: - { - eState = SsStop; - sSymbol += cToken; - } + case SsGetBlank: + eState = SsStop; + sSymbol += OUString(cToken); break; - default: + default: break; } // of switch } // of while if (eState == SsGetWord) + { eType = NF_SYMBOLTYPE_STRING; + } return eType; } -xub_StrLen ImpSvNumberformatScan::Symbol_Division(const String& rString) +sal_Int32 ImpSvNumberformatScan::Symbol_Division(const OUString& rString) { - nCurrPos = STRING_NOTFOUND; + nCurrPos = -1; // Ist Waehrung im Spiel? - String sString = pFormatter->GetCharClass()->uppercase(rString); - xub_StrLen nCPos = 0; - while (nCPos != STRING_NOTFOUND) + OUString sString = pFormatter->GetCharClass()->uppercase(rString); + sal_Int32 nCPos = 0; + while (nCPos >= 0) { - nCPos = sString.Search(GetCurString(),nCPos); - if (nCPos != STRING_NOTFOUND) + nCPos = sString.indexOf(GetCurString(),nCPos); + if (nCPos >= 0) { // in Quotes? sal_Int32 nQ = SvNumberformat::GetQuoteEnd( sString, nCPos ); @@ -902,14 +893,16 @@ xub_StrLen ImpSvNumberformatScan::Symbol_Division(const String& rString) { sal_Unicode c; if ( nCPos == 0 || - ((c = sString.GetChar(xub_StrLen(nCPos-1))) != '"' + ((c = sString[nCPos-1]) != '"' && c != '\\') ) // dm kann durch "dm { // \d geschuetzt werden nCurrPos = nCPos; - nCPos = STRING_NOTFOUND; // Abbruch + nCPos = -1; } else + { nCPos++; // weitersuchen + } } else { @@ -921,17 +914,21 @@ xub_StrLen ImpSvNumberformatScan::Symbol_Division(const String& rString) bool bStar = false; // wird bei '*'Detektion gesetzt Reset(); - xub_StrLen nPos = 0; - const xub_StrLen nLen = rString.Len(); + sal_Int32 nPos = 0; + const sal_Int32 nLen = rString.getLength(); while (nPos < nLen && nAnzStrings < NF_MAX_FORMAT_SYMBOLS) { nTypeArray[nAnzStrings] = Next_Symbol(rString, nPos, sStrArray[nAnzStrings]); if (nTypeArray[nAnzStrings] == NF_SYMBOLTYPE_STAR) { // Ueberwachung des '*' if (bStar) + { return nPos; // Fehler: doppelter '*' + } else + { bStar = true; + } } nAnzStrings++; } @@ -939,13 +936,13 @@ xub_StrLen ImpSvNumberformatScan::Symbol_Division(const String& rString) return 0; // 0 => ok } -void ImpSvNumberformatScan::SkipStrings(sal_uInt16& i, xub_StrLen& nPos) +void ImpSvNumberformatScan::SkipStrings(sal_uInt16& i, sal_Int32& nPos) { while (i < nAnzStrings && ( nTypeArray[i] == NF_SYMBOLTYPE_STRING || nTypeArray[i] == NF_SYMBOLTYPE_BLANK || nTypeArray[i] == NF_SYMBOLTYPE_STAR) ) { - nPos = nPos + sStrArray[i].Len(); + nPos = nPos + sStrArray[i].getLength(); i++; } } @@ -957,9 +954,13 @@ sal_uInt16 ImpSvNumberformatScan::PreviousKeyword(sal_uInt16 i) { i--; while (i > 0 && nTypeArray[i] <= 0) + { i--; + } if (nTypeArray[i] > 0) + { res = nTypeArray[i]; + } } return res; } @@ -971,9 +972,13 @@ sal_uInt16 ImpSvNumberformatScan::NextKeyword(sal_uInt16 i) { i++; while (i < nAnzStrings-1 && nTypeArray[i] <= 0) + { i++; + } if (nTypeArray[i] > 0) + { res = nTypeArray[i]; + } } return res; } @@ -985,7 +990,8 @@ short ImpSvNumberformatScan::PreviousType( sal_uInt16 i ) do { i--; - } while ( i > 0 && nTypeArray[i] == NF_SYMBOLTYPE_EMPTY ); + } + while ( i > 0 && nTypeArray[i] == NF_SYMBOLTYPE_EMPTY ); return nTypeArray[i]; } return 0; @@ -997,13 +1003,18 @@ sal_Unicode ImpSvNumberformatScan::PreviousChar(sal_uInt16 i) if (i > 0 && i < nAnzStrings) { i--; - while (i > 0 && ( nTypeArray[i] == NF_SYMBOLTYPE_EMPTY - || nTypeArray[i] == NF_SYMBOLTYPE_STRING - || nTypeArray[i] == NF_SYMBOLTYPE_STAR - || nTypeArray[i] == NF_SYMBOLTYPE_BLANK ) ) + while (i > 0 && + ( nTypeArray[i] == NF_SYMBOLTYPE_EMPTY || + nTypeArray[i] == NF_SYMBOLTYPE_STRING || + nTypeArray[i] == NF_SYMBOLTYPE_STAR || + nTypeArray[i] == NF_SYMBOLTYPE_BLANK )) + { i--; - if (sStrArray[i].Len() > 0) - res = sStrArray[i].GetChar(xub_StrLen(sStrArray[i].Len()-1)); + } + if (sStrArray[i].getLength() > 0) + { + res = sStrArray[i][sStrArray[i].getLength()-1]; + } } return res; } @@ -1015,13 +1026,17 @@ sal_Unicode ImpSvNumberformatScan::NextChar(sal_uInt16 i) { i++; while (i < nAnzStrings-1 && - ( nTypeArray[i] == NF_SYMBOLTYPE_EMPTY - || nTypeArray[i] == NF_SYMBOLTYPE_STRING - || nTypeArray[i] == NF_SYMBOLTYPE_STAR - || nTypeArray[i] == NF_SYMBOLTYPE_BLANK)) + ( nTypeArray[i] == NF_SYMBOLTYPE_EMPTY || + nTypeArray[i] == NF_SYMBOLTYPE_STRING || + nTypeArray[i] == NF_SYMBOLTYPE_STAR || + nTypeArray[i] == NF_SYMBOLTYPE_BLANK)) + { i++; - if (sStrArray[i].Len() > 0) - res = sStrArray[i].GetChar(0); + } + if (sStrArray[i].getLength() > 0) + { + res = sStrArray[i][0]; + } } return res; } @@ -1037,18 +1052,25 @@ bool ImpSvNumberformatScan::IsLastBlankBeforeFrac(sal_uInt16 i) { i++; if ( nTypeArray[i] == NF_SYMBOLTYPE_DEL && - sStrArray[i].GetChar(0) == '/') + sStrArray[i][0] == '/') + { bStop = true; + } else if ( nTypeArray[i] == NF_SYMBOLTYPE_DEL && - sStrArray[i].GetChar(0) == ' ') + sStrArray[i][0] == ' ') + { res = false; + } } - if (!bStop) // kein '/' + if (!bStop) // kein '/'{ + { res = false; + } } else + { res = false; // kein '/' mehr - + } return res; } @@ -1070,9 +1092,9 @@ void ImpSvNumberformatScan::Reset() bThousand = false; nThousand = 0; bDecSep = false; - nDecPos = -1; - nExpPos = (sal_uInt16) -1; - nBlankPos = (sal_uInt16) -1; + nDecPos = (sal_uInt16)-1; + nExpPos = (sal_uInt16)-1; + nBlankPos = (sal_uInt16)-1; nCntPre = 0; nCntPost = 0; nCntExp = 0; @@ -1084,17 +1106,17 @@ void ImpSvNumberformatScan::Reset() bool ImpSvNumberformatScan::Is100SecZero( sal_uInt16 i, bool bHadDecSep ) { sal_uInt16 nIndexPre = PreviousKeyword( i ); - return (nIndexPre == NF_KEY_S || nIndexPre == NF_KEY_SS) - && (bHadDecSep // S, SS ',' - || (i>0 && nTypeArray[i-1] == NF_SYMBOLTYPE_STRING)); + return (nIndexPre == NF_KEY_S || nIndexPre == NF_KEY_SS) && + (bHadDecSep || + ( i > 0 && nTypeArray[i-1] == NF_SYMBOLTYPE_STRING)); // SS"any"00 take "any" as a valid decimal separator } -xub_StrLen ImpSvNumberformatScan::ScanType() +sal_Int32 ImpSvNumberformatScan::ScanType() { const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData(); - xub_StrLen nPos = 0; + sal_Int32 nPos = 0; sal_uInt16 i = 0; short eNewType; bool bMatchBracket = false; @@ -1105,151 +1127,164 @@ xub_StrLen ImpSvNumberformatScan::ScanType() { if (nTypeArray[i] > 0) { // keyword + sal_uInt16 nIndexPre; + sal_uInt16 nIndexNex; + sal_Unicode cChar; + switch (nTypeArray[i]) { - case NF_KEY_E: // E - eNewType = NUMBERFORMAT_SCIENTIFIC; + case NF_KEY_E: // E + eNewType = NUMBERFORMAT_SCIENTIFIC; break; - case NF_KEY_AMPM: // AM,A,PM,P - case NF_KEY_AP: - case NF_KEY_H: // H - case NF_KEY_HH: // HH - case NF_KEY_S: // S - case NF_KEY_SS: // SS - eNewType = NUMBERFORMAT_TIME; + case NF_KEY_AMPM: // AM,A,PM,P + case NF_KEY_AP: + case NF_KEY_H: // H + case NF_KEY_HH: // HH + case NF_KEY_S: // S + case NF_KEY_SS: // SS + eNewType = NUMBERFORMAT_TIME; break; - case NF_KEY_M: // M - case NF_KEY_MM: // MM - { // minute or month - sal_uInt16 nIndexPre = PreviousKeyword(i); - sal_uInt16 nIndexNex = NextKeyword(i); - sal_Unicode cChar = PreviousChar(i); - if (nIndexPre == NF_KEY_H || // H - nIndexPre == NF_KEY_HH || // HH - nIndexNex == NF_KEY_S || // S - nIndexNex == NF_KEY_SS || // SS - cChar == '[' ) // [M - { - eNewType = NUMBERFORMAT_TIME; - nTypeArray[i] -= 2; // 6 -> 4, 7 -> 5 - } - else - eNewType = NUMBERFORMAT_DATE; + case NF_KEY_M: // M + case NF_KEY_MM: // MM + // minute or month + nIndexPre = PreviousKeyword(i); + nIndexNex = NextKeyword(i); + cChar = PreviousChar(i); + if (nIndexPre == NF_KEY_H || // H + nIndexPre == NF_KEY_HH || // HH + nIndexNex == NF_KEY_S || // S + nIndexNex == NF_KEY_SS || // SS + cChar == '[' ) // [M + { + eNewType = NUMBERFORMAT_TIME; + nTypeArray[i] -= 2; // 6 -> 4, 7 -> 5 } - break; - case NF_KEY_MMM: // MMM - case NF_KEY_MMMM: // MMMM - case NF_KEY_MMMMM: // MMMMM - case NF_KEY_Q: // Q - case NF_KEY_QQ: // QQ - case NF_KEY_D: // D - case NF_KEY_DD: // DD - case NF_KEY_DDD: // DDD - case NF_KEY_DDDD: // DDDD - case NF_KEY_YY: // YY - case NF_KEY_YYYY: // YYYY - case NF_KEY_NN: // NN - case NF_KEY_NNN: // NNN - case NF_KEY_NNNN: // NNNN - case NF_KEY_WW : // WW - case NF_KEY_AAA : // AAA - case NF_KEY_AAAA : // AAAA - case NF_KEY_EC : // E - case NF_KEY_EEC : // EE - case NF_KEY_G : // G - case NF_KEY_GG : // GG - case NF_KEY_GGG : // GGG - case NF_KEY_R : // R - case NF_KEY_RR : // RR + else + { eNewType = NUMBERFORMAT_DATE; + } break; - case NF_KEY_CCC: // CCC - eNewType = NUMBERFORMAT_CURRENCY; + case NF_KEY_MMM: // MMM + case NF_KEY_MMMM: // MMMM + case NF_KEY_MMMMM: // MMMMM + case NF_KEY_Q: // Q + case NF_KEY_QQ: // QQ + case NF_KEY_D: // D + case NF_KEY_DD: // DD + case NF_KEY_DDD: // DDD + case NF_KEY_DDDD: // DDDD + case NF_KEY_YY: // YY + case NF_KEY_YYYY: // YYYY + case NF_KEY_NN: // NN + case NF_KEY_NNN: // NNN + case NF_KEY_NNNN: // NNNN + case NF_KEY_WW : // WW + case NF_KEY_AAA : // AAA + case NF_KEY_AAAA : // AAAA + case NF_KEY_EC : // E + case NF_KEY_EEC : // EE + case NF_KEY_G : // G + case NF_KEY_GG : // GG + case NF_KEY_GGG : // GGG + case NF_KEY_R : // R + case NF_KEY_RR : // RR + eNewType = NUMBERFORMAT_DATE; break; - case NF_KEY_GENERAL: // Standard - eNewType = NUMBERFORMAT_NUMBER; - bHaveGeneral = true; + case NF_KEY_CCC: // CCC + eNewType = NUMBERFORMAT_CURRENCY; break; - default: - eNewType = NUMBERFORMAT_UNDEFINED; + case NF_KEY_GENERAL: // Standard + eNewType = NUMBERFORMAT_NUMBER; + bHaveGeneral = true; + break; + default: + eNewType = NUMBERFORMAT_UNDEFINED; break; } } else { // control character - switch ( sStrArray[i].GetChar(0) ) + switch ( sStrArray[i][0] ) { - case '#': - case '?': - eNewType = NUMBERFORMAT_NUMBER; + case '#': + case '?': + eNewType = NUMBERFORMAT_NUMBER; break; - case '0': + case '0': + if ( (eScannedType & NUMBERFORMAT_TIME) == NUMBERFORMAT_TIME ) { - if ( (eScannedType & NUMBERFORMAT_TIME) == NUMBERFORMAT_TIME ) + if ( Is100SecZero( i, bDecSep ) ) { - if ( Is100SecZero( i, bDecSep ) ) - { - bDecSep = true; // subsequent 0's - eNewType = NUMBERFORMAT_TIME; - } - else - return nPos; // Error + bDecSep = true; // subsequent 0's + eNewType = NUMBERFORMAT_TIME; } else - eNewType = NUMBERFORMAT_NUMBER; + { + return nPos; // Error + } + } + else + { + eNewType = NUMBERFORMAT_NUMBER; } break; - case '%': - eNewType = NUMBERFORMAT_PERCENT; + case '%': + eNewType = NUMBERFORMAT_PERCENT; break; - case '/': - eNewType = NUMBERFORMAT_FRACTION; + case '/': + eNewType = NUMBERFORMAT_FRACTION; break; - case '[': + case '[': + if ( i < nAnzStrings-1 && + nTypeArray[i+1] == NF_SYMBOLTYPE_STRING && + sStrArray[i+1][0] == '$' ) + { // as of SV_NUMBERFORMATTER_VERSION_NEW_CURR + eNewType = NUMBERFORMAT_CURRENCY; + bMatchBracket = true; + } + else if ( i < nAnzStrings-1 && + nTypeArray[i+1] == NF_SYMBOLTYPE_STRING && + sStrArray[i+1][0] == '~' ) + { // as of SV_NUMBERFORMATTER_VERSION_CALENDAR + eNewType = NUMBERFORMAT_DATE; + bMatchBracket = true; + } + else { - if ( i < nAnzStrings-1 && - nTypeArray[i+1] == NF_SYMBOLTYPE_STRING && - sStrArray[i+1].GetChar(0) == '$' ) - { // as of SV_NUMBERFORMATTER_VERSION_NEW_CURR - eNewType = NUMBERFORMAT_CURRENCY; - bMatchBracket = true; - } - else if ( i < nAnzStrings-1 && - nTypeArray[i+1] == NF_SYMBOLTYPE_STRING && - sStrArray[i+1].GetChar(0) == '~' ) - { // as of SV_NUMBERFORMATTER_VERSION_CALENDAR - eNewType = NUMBERFORMAT_DATE; - bMatchBracket = true; - } + sal_uInt16 nIndexNex = NextKeyword(i); + if (nIndexNex == NF_KEY_H || // H + nIndexNex == NF_KEY_HH || // HH + nIndexNex == NF_KEY_M || // M + nIndexNex == NF_KEY_MM || // MM + nIndexNex == NF_KEY_S || // S + nIndexNex == NF_KEY_SS ) // SS + eNewType = NUMBERFORMAT_TIME; else { - sal_uInt16 nIndexNex = NextKeyword(i); - if (nIndexNex == NF_KEY_H || // H - nIndexNex == NF_KEY_HH || // HH - nIndexNex == NF_KEY_M || // M - nIndexNex == NF_KEY_MM || // MM - nIndexNex == NF_KEY_S || // S - nIndexNex == NF_KEY_SS ) // SS - eNewType = NUMBERFORMAT_TIME; - else - return nPos; // Error + return nPos; // Error } } break; - case '@': - eNewType = NUMBERFORMAT_TEXT; + case '@': + eNewType = NUMBERFORMAT_TEXT; break; - default: - if (pLoc->getTime100SecSep().equals(sStrArray[i])) - bDecSep = true; // for SS,0 - eNewType = NUMBERFORMAT_UNDEFINED; + default: + if (pLoc->getTime100SecSep().equals(sStrArray[i])) + { + bDecSep = true; // for SS,0 + } + eNewType = NUMBERFORMAT_UNDEFINED; break; } } if (eScannedType == NUMBERFORMAT_UNDEFINED) + { eScannedType = eNewType; + } else if (eScannedType == NUMBERFORMAT_TEXT || eNewType == NUMBERFORMAT_TEXT) + { eScannedType = NUMBERFORMAT_TEXT; // Text bleibt immer Text + } else if (eNewType == NUMBERFORMAT_UNDEFINED) { // bleibt wie bisher } @@ -1257,157 +1292,171 @@ xub_StrLen ImpSvNumberformatScan::ScanType() { switch (eScannedType) { - case NUMBERFORMAT_DATE: + case NUMBERFORMAT_DATE: + switch (eNewType) { - switch (eNewType) + case NUMBERFORMAT_TIME: + eScannedType = NUMBERFORMAT_DATETIME; + break; + case NUMBERFORMAT_FRACTION: // DD/MM + break; + default: + if (nCurrPos >= 0) { - case NUMBERFORMAT_TIME: - eScannedType = NUMBERFORMAT_DATETIME; - break; - case NUMBERFORMAT_FRACTION: // DD/MM - break; - default: - { - if (nCurrPos != STRING_NOTFOUND) - eScannedType = NUMBERFORMAT_UNDEFINED; - else if ( sStrArray[i] != pFormatter->GetDateSep() ) - return nPos; - } + eScannedType = NUMBERFORMAT_UNDEFINED; } - } - break; - case NUMBERFORMAT_TIME: - { - switch (eNewType) + else if ( sStrArray[i] != OUString(pFormatter->GetDateSep()) ) { - case NUMBERFORMAT_DATE: - eScannedType = NUMBERFORMAT_DATETIME; - break; - case NUMBERFORMAT_FRACTION: // MM/SS - break; - default: - { - if (nCurrPos != STRING_NOTFOUND) - eScannedType = NUMBERFORMAT_UNDEFINED; - else if (!pLoc->getTimeSep().equals(sStrArray[i])) - return nPos; - } + return nPos; } } break; - case NUMBERFORMAT_DATETIME: + case NUMBERFORMAT_TIME: + switch (eNewType) { - switch (eNewType) + case NUMBERFORMAT_DATE: + eScannedType = NUMBERFORMAT_DATETIME; + break; + case NUMBERFORMAT_FRACTION: // MM/SS + break; + default: + if (nCurrPos != STRING_NOTFOUND) { - case NUMBERFORMAT_TIME: - case NUMBERFORMAT_DATE: - break; - case NUMBERFORMAT_FRACTION: // DD/MM - break; - default: - { - if (nCurrPos != STRING_NOTFOUND) - eScannedType = NUMBERFORMAT_UNDEFINED; - else if ( pFormatter->GetDateSep() != sStrArray[i] - && !pLoc->getTimeSep().equals(sStrArray[i]) ) - return nPos; - } + eScannedType = NUMBERFORMAT_UNDEFINED; + } + else if (!pLoc->getTimeSep().equals(sStrArray[i])) + { + return nPos; } + break; } break; - case NUMBERFORMAT_PERCENT: + case NUMBERFORMAT_DATETIME: + switch (eNewType) { - switch (eNewType) + case NUMBERFORMAT_TIME: + case NUMBERFORMAT_DATE: + break; + case NUMBERFORMAT_FRACTION: // DD/MM + break; + default: + if (nCurrPos >= 0) { - case NUMBERFORMAT_NUMBER: // nur Zahl nach Prozent - break; - default: - return nPos; + eScannedType = NUMBERFORMAT_UNDEFINED; + } + else if ( OUString(pFormatter->GetDateSep()) != sStrArray[i] && + !pLoc->getTimeSep().equals(sStrArray[i]) ) + { + return nPos; } } break; - case NUMBERFORMAT_SCIENTIFIC: + case NUMBERFORMAT_PERCENT: + switch (eNewType) { - switch (eNewType) - { - case NUMBERFORMAT_NUMBER: // nur Zahl nach E - break; - default: - return nPos; - } + case NUMBERFORMAT_NUMBER: // nur Zahl nach Prozent + break; + default: + return nPos; } break; - case NUMBERFORMAT_NUMBER: + case NUMBERFORMAT_SCIENTIFIC: + switch (eNewType) { - switch (eNewType) - { - case NUMBERFORMAT_SCIENTIFIC: - case NUMBERFORMAT_PERCENT: - case NUMBERFORMAT_FRACTION: - case NUMBERFORMAT_CURRENCY: - eScannedType = eNewType; - break; - default: - if (nCurrPos != STRING_NOTFOUND) - eScannedType = NUMBERFORMAT_UNDEFINED; - else - return nPos; - } + case NUMBERFORMAT_NUMBER: // nur Zahl nach E + break; + default: + return nPos; } break; - case NUMBERFORMAT_FRACTION: + case NUMBERFORMAT_NUMBER: + switch (eNewType) { - switch (eNewType) + case NUMBERFORMAT_SCIENTIFIC: + case NUMBERFORMAT_PERCENT: + case NUMBERFORMAT_FRACTION: + case NUMBERFORMAT_CURRENCY: + eScannedType = eNewType; + break; + default: + if (nCurrPos != STRING_NOTFOUND) { - case NUMBERFORMAT_NUMBER: // nur Zahl nach Bruch - break; - default: - return nPos; + eScannedType = NUMBERFORMAT_UNDEFINED; + } + else + { + return nPos; } } break; + case NUMBERFORMAT_FRACTION: + switch (eNewType) + { + case NUMBERFORMAT_NUMBER: // nur Zahl nach Bruch + break; default: + return nPos; + } + break; + default: break; } } - nPos = nPos + sStrArray[i].Len(); // Korrekturposition + nPos = nPos + sStrArray[i].getLength(); // Korrekturposition i++; if ( bMatchBracket ) { // no type detection inside of matching brackets if [$...], [~...] while ( bMatchBracket && i < nAnzStrings ) { if ( nTypeArray[i] == NF_SYMBOLTYPE_DEL - && sStrArray[i].GetChar(0) == ']' ) + && sStrArray[i][0] == ']' ) + { bMatchBracket = false; + } else + { nTypeArray[i] = NF_SYMBOLTYPE_STRING; - nPos = nPos + sStrArray[i].Len(); + } + nPos = nPos + sStrArray[i].getLength(); i++; } if ( bMatchBracket ) + { return nPos; // missing closing bracket at end of code + } } SkipStrings(i, nPos); } - if ((eScannedType == NUMBERFORMAT_NUMBER || eScannedType == NUMBERFORMAT_UNDEFINED) - && nCurrPos != STRING_NOTFOUND && !bHaveGeneral) + if ((eScannedType == NUMBERFORMAT_NUMBER || + eScannedType == NUMBERFORMAT_UNDEFINED) && + nCurrPos >= 0 && !bHaveGeneral) + { eScannedType = NUMBERFORMAT_CURRENCY; // old "automatic" currency + } if (eScannedType == NUMBERFORMAT_UNDEFINED) + { eScannedType = NUMBERFORMAT_DEFINED; + } return 0; // Alles ok } -bool ImpSvNumberformatScan::InsertSymbol( sal_uInt16 & nPos, svt::NfSymbolType eType, const String& rStr ) +bool ImpSvNumberformatScan::InsertSymbol( sal_uInt16 & nPos, svt::NfSymbolType eType, const OUString& rStr ) { if (nAnzStrings >= NF_MAX_FORMAT_SYMBOLS || nPos > nAnzStrings) + { return false; + } if (nPos > 0 && nTypeArray[nPos-1] == NF_SYMBOLTYPE_EMPTY) + { --nPos; // reuse position + } else { if ((size_t) (nAnzStrings + 1) >= NF_MAX_FORMAT_SYMBOLS) + { return false; + } ++nAnzStrings; for (size_t i = nAnzStrings; i > nPos; --i) { @@ -1421,62 +1470,67 @@ bool ImpSvNumberformatScan::InsertSymbol( sal_uInt16 & nPos, svt::NfSymbolType e return true; } -int ImpSvNumberformatScan::FinalScanGetCalendar( xub_StrLen& nPos, sal_uInt16& i, - sal_uInt16& rAnzResStrings ) +int ImpSvNumberformatScan::FinalScanGetCalendar( sal_Int32& nPos, sal_uInt16& i, + sal_uInt16& rAnzResStrings ) { - if ( sStrArray[i].GetChar(0) == '[' && - i < nAnzStrings-1 && - nTypeArray[i+1] == NF_SYMBOLTYPE_STRING && - sStrArray[i+1].GetChar(0) == '~' ) - { // [~calendarID] + if ( sStrArray[i][0] == '[' && + i < nAnzStrings-1 && + nTypeArray[i+1] == NF_SYMBOLTYPE_STRING && + sStrArray[i+1][0] == '~' ) + { + // [~calendarID] // as of SV_NUMBERFORMATTER_VERSION_CALENDAR - nPos = nPos + sStrArray[i].Len(); // [ + nPos = nPos + sStrArray[i].getLength(); // [ nTypeArray[i] = NF_SYMBOLTYPE_CALDEL; - nPos = nPos + sStrArray[++i].Len(); // ~ + nPos = nPos + sStrArray[++i].getLength(); // ~ sStrArray[i-1] += sStrArray[i]; // [~ nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; rAnzResStrings--; if ( ++i >= nAnzStrings ) + { return -1; // error - nPos = nPos + sStrArray[i].Len(); // calendarID - String& rStr = sStrArray[i]; + } + nPos = nPos + sStrArray[i].getLength(); // calendarID + OUString& rStr = sStrArray[i]; nTypeArray[i] = NF_SYMBOLTYPE_CALENDAR; // convert i++; while ( i < nAnzStrings && - sStrArray[i].GetChar(0) != ']' ) + sStrArray[i][0] != ']' ) { - nPos = nPos + sStrArray[i].Len(); + nPos = nPos + sStrArray[i].getLength(); rStr += sStrArray[i]; nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; rAnzResStrings--; i++; } - if ( rStr.Len() && i < nAnzStrings && - sStrArray[i].GetChar(0) == ']' ) + if ( rStr.getLength() && i < nAnzStrings && + sStrArray[i][0] == ']' ) { nTypeArray[i] = NF_SYMBOLTYPE_CALDEL; - nPos = nPos + sStrArray[i].Len(); + nPos = nPos + sStrArray[i].getLength(); i++; } else + { return -1; // error + } return 1; } return 0; } -xub_StrLen ImpSvNumberformatScan::FinalScan( String& rString ) +sal_Int32 ImpSvNumberformatScan::FinalScan( OUString& rString ) { const LocaleDataWrapper* pLoc = pFormatter->GetLocaleData(); // save values for convert mode - String sOldDecSep = pFormatter->GetNumDecimalSep(); - String sOldThousandSep = pFormatter->GetNumThousandSep(); - String sOldDateSep = pFormatter->GetDateSep(); - String sOldTimeSep = pLoc->getTimeSep(); - String sOldTime100SecSep= pLoc->getTime100SecSep(); - String sOldCurSymbol = GetCurSymbol(); - rtl::OUString sOldCurString = GetCurString(); + OUString sOldDecSep = pFormatter->GetNumDecimalSep(); + OUString sOldThousandSep = pFormatter->GetNumThousandSep(); + OUString sOldDateSep = pFormatter->GetDateSep(); + OUString sOldTimeSep = pLoc->getTimeSep(); + OUString sOldTime100SecSep= pLoc->getTime100SecSep(); + OUString sOldCurSymbol = GetCurSymbol(); + OUString sOldCurString = GetCurString(); sal_Unicode cOldKeyH = sKeyword[NF_KEY_H][0]; sal_Unicode cOldKeyMI = sKeyword[NF_KEY_MI][0]; sal_Unicode cOldKeyS = sKeyword[NF_KEY_S][0]; @@ -1485,9 +1539,10 @@ xub_StrLen ImpSvNumberformatScan::FinalScan( String& rString ) // normal space instead so queries on space work correctly. // The format string is adjusted to allow both. // For output of the format code string the LocaleData characters are used. - if ( sOldThousandSep.GetChar(0) == cNonBreakingSpace && sOldThousandSep.Len() == 1 ) - sOldThousandSep = ' '; - + if ( sOldThousandSep[0] == cNonBreakingSpace && sOldThousandSep.getLength() == 1 ) + { + sOldThousandSep = " "; + } // change locale data et al if (bConvertMode) { @@ -1499,1038 +1554,1079 @@ xub_StrLen ImpSvNumberformatScan::FinalScan( String& rString ) } const CharClass* pChrCls = pFormatter->GetCharClass(); - xub_StrLen nPos = 0; // error correction position - sal_uInt16 i = 0; // symbol loop counter - sal_uInt16 nCounter = 0; // counts digits - nAnzResStrings = nAnzStrings; // counts remaining symbols - bDecSep = false; // reset in case already used in TypeCheck - bool bThaiT = false; // Thai T NatNum modifier present + sal_Int32 nPos = 0; // error correction position + sal_uInt16 i = 0; // symbol loop counter + sal_uInt16 nCounter = 0; // counts digits + nAnzResStrings = nAnzStrings; // counts remaining symbols + bDecSep = false; // reset in case already used in TypeCheck + bool bThaiT = false; // Thai T NatNum modifier present + bool bTimePart = false; switch (eScannedType) { - case NUMBERFORMAT_TEXT: - case NUMBERFORMAT_DEFINED: + case NUMBERFORMAT_TEXT: + case NUMBERFORMAT_DEFINED: + while (i < nAnzStrings) { - while (i < nAnzStrings) + switch (nTypeArray[i]) { - switch (nTypeArray[i]) + case NF_SYMBOLTYPE_BLANK: + case NF_SYMBOLTYPE_STAR: + break; + case NF_KEY_GENERAL : // #77026# "General" is the same as "@" + break; + default: + if ( nTypeArray[i] != NF_SYMBOLTYPE_DEL || + sStrArray[i][0] != '@' ) { - case NF_SYMBOLTYPE_BLANK: - case NF_SYMBOLTYPE_STAR: - break; - case NF_KEY_GENERAL : // #77026# "General" is the same as "@" - break; - default: + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + } + break; + } + nPos = nPos + sStrArray[i].getLength(); + i++; + } // of while + break; + + case NUMBERFORMAT_NUMBER: + case NUMBERFORMAT_PERCENT: + case NUMBERFORMAT_CURRENCY: + case NUMBERFORMAT_SCIENTIFIC: + case NUMBERFORMAT_FRACTION: + while (i < nAnzStrings) + { + // TODO: rechecking eScannedType is unnecessary. + // This switch-case is for eScannedType == NUMBERFORMAT_FRACTION anyway + if (eScannedType == NUMBERFORMAT_FRACTION && // special case + nTypeArray[i] == NF_SYMBOLTYPE_DEL && // # ### #/# + StringEqualsChar( sOldThousandSep, ' ' ) && // e.g. France or Sweden + StringEqualsChar( sStrArray[i], ' ' ) && + !bFrac && + IsLastBlankBeforeFrac(i) ) + { + nTypeArray[i] = NF_SYMBOLTYPE_STRING; // del->string + } // kein Taus.p. + + if (nTypeArray[i] == NF_SYMBOLTYPE_BLANK || + nTypeArray[i] == NF_SYMBOLTYPE_STAR || + nTypeArray[i] == NF_KEY_CCC || // CCC + nTypeArray[i] == NF_KEY_GENERAL ) // Standard + { + if (nTypeArray[i] == NF_KEY_GENERAL) + { + nThousand = FLAG_STANDARD_IN_FORMAT; + if ( bConvertMode ) { - if ( nTypeArray[i] != NF_SYMBOLTYPE_DEL || - sStrArray[i].GetChar(0) != '@' ) - nTypeArray[i] = NF_SYMBOLTYPE_STRING; + sStrArray[i] = sNameStandardFormat; } - break; } - nPos = nPos + sStrArray[i].Len(); + nPos = nPos + sStrArray[i].getLength(); i++; - } // of while - } - break; - case NUMBERFORMAT_NUMBER: - case NUMBERFORMAT_PERCENT: - case NUMBERFORMAT_CURRENCY: - case NUMBERFORMAT_SCIENTIFIC: - case NUMBERFORMAT_FRACTION: - { - while (i < nAnzStrings) + } + else if (nTypeArray[i] == NF_SYMBOLTYPE_STRING || // Strings oder + nTypeArray[i] > 0) // Keywords { - // TODO: rechecking eScannedType is unnecessary. - // This switch-case is for eScannedType == NUMBERFORMAT_FRACTION anyway - if (eScannedType == NUMBERFORMAT_FRACTION && // special case - nTypeArray[i] == NF_SYMBOLTYPE_DEL && // # ### #/# - StringEqualsChar( sOldThousandSep, ' ' ) && // e.g. France or Sweden - StringEqualsChar( sStrArray[i], ' ' ) && - !bFrac && - IsLastBlankBeforeFrac(i) ) + if (eScannedType == NUMBERFORMAT_SCIENTIFIC && + nTypeArray[i] == NF_KEY_E) // E+ { - nTypeArray[i] = NF_SYMBOLTYPE_STRING; // del->string - } // kein Taus.p. - - if (nTypeArray[i] == NF_SYMBOLTYPE_BLANK || - nTypeArray[i] == NF_SYMBOLTYPE_STAR || - nTypeArray[i] == NF_KEY_CCC || // CCC - nTypeArray[i] == NF_KEY_GENERAL ) // Standard + if (bExp) // doppelt + { + return nPos; + } + bExp = true; + nExpPos = i; + if (bDecSep) + { + nCntPost = nCounter; + } + else + { + nCntPre = nCounter; + } + nCounter = 0; + nTypeArray[i] = NF_SYMBOLTYPE_EXP; + } + else if (eScannedType == NUMBERFORMAT_FRACTION && + sStrArray[i][0] == ' ') { - if (nTypeArray[i] == NF_KEY_GENERAL) + if (!bBlank && !bFrac) // nicht doppelt oder hinter / { - nThousand = FLAG_STANDARD_IN_FORMAT; - if ( bConvertMode ) + if (bDecSep && nCounter > 0) // Nachkommastellen { - sStrArray[i] = sNameStandardFormat; + return nPos; // Fehler } + bBlank = true; + nBlankPos = i; + nCntPre = nCounter; + nCounter = 0; } - nPos = nPos + sStrArray[i].Len(); - i++; + nTypeArray[i] = NF_SYMBOLTYPE_FRACBLANK; + } + else if (nTypeArray[i] == NF_KEY_THAI_T) + { + bThaiT = true; + sStrArray[i] = sKeyword[nTypeArray[i]]; } - else if (nTypeArray[i] == NF_SYMBOLTYPE_STRING || // Strings oder - nTypeArray[i] > 0) // Keywords + else if (sStrArray[i][0] >= '0' && + sStrArray[i][0] <= '9') { - if (eScannedType == NUMBERFORMAT_SCIENTIFIC && - nTypeArray[i] == NF_KEY_E) // E+ + OUString sDiv; + sal_uInt16 j = i; + while(j < nAnzStrings) { - if (bExp) // doppelt - return nPos; - bExp = true; - nExpPos = i; - if (bDecSep) - nCntPost = nCounter; - else - nCntPre = nCounter; - nCounter = 0; - nTypeArray[i] = NF_SYMBOLTYPE_EXP; + sDiv += sStrArray[j++]; } - else if (eScannedType == NUMBERFORMAT_FRACTION && - sStrArray[i].GetChar(0) == ' ') + if (OUString::valueOf(sDiv.toInt32()) == sDiv) { - if (!bBlank && !bFrac) // nicht doppelt oder hinter / + /* Found a Divisor */ + while (i < j) { - if (bDecSep && nCounter > 0) // Nachkommastellen - return nPos; // Fehler - bBlank = true; - nBlankPos = i; - nCntPre = nCounter; - nCounter = 0; + nTypeArray[i++] = NF_SYMBOLTYPE_FRAC_FDIV; } - nTypeArray[i] = NF_SYMBOLTYPE_FRACBLANK; + i = j - 1; // Stop the loop + if (nCntPost) + { + nCounter = nCntPost; + } + else if (nCntPre) + { + nCounter = nCntPre; + } + // don't artificially increment nCntPre + // for forced denominator + if ( ( eScannedType != NUMBERFORMAT_FRACTION ) && (!nCntPre) ) + { + nCntPre++; + } + } + } + else + { + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + } + nPos = nPos + sStrArray[i].getLength(); + i++; + } + else if (nTypeArray[i] == NF_SYMBOLTYPE_DEL) + { + sal_Unicode cHere = sStrArray[i][0]; + sal_Unicode cSaved = cHere; + // Handle not pre-known separators in switch. + sal_Unicode cSimplified; + if (StringEqualsChar( pFormatter->GetNumThousandSep(), cHere)) + { + cSimplified = ','; + } + else if (StringEqualsChar( pFormatter->GetNumDecimalSep(), cHere)) + { + cSimplified = '.'; + } + else + { + cSimplified = cHere; + } + + OUString& rStr = sStrArray[i]; + + switch ( cSimplified ) + { + case '#': + case '0': + case '?': + if (nThousand > 0) // #... # + { + return nPos; // Fehler } - else if (nTypeArray[i] == NF_KEY_THAI_T) + else if (bFrac && cHere == '0') { - bThaiT = true; - sStrArray[i] = String(sKeyword[nTypeArray[i]]); + return nPos; // 0 im Nenner } - else if (sStrArray[i].GetChar(0) >= '0' && - sStrArray[i].GetChar(0) <= '9') + nTypeArray[i] = NF_SYMBOLTYPE_DIGIT; + nPos = nPos + rStr.getLength(); + i++; + nCounter++; + while (i < nAnzStrings && + (sStrArray[i][0] == '#' || + sStrArray[i][0] == '0' || + sStrArray[i][0] == '?') + ) { - rtl::OUString sDiv; - sal_uInt16 j = i; - while(j < nAnzStrings) - sDiv += sStrArray[j++]; - if (rtl::OUString::valueOf(sDiv.toInt32()) == sDiv) + nTypeArray[i] = NF_SYMBOLTYPE_DIGIT; + nPos = nPos + sStrArray[i].getLength(); + nCounter++; + i++; + } + break; + case '-': + if ( bDecSep && nDecPos+1 == i && + nTypeArray[nDecPos] == NF_SYMBOLTYPE_DECSEP ) + { // "0.--" + nTypeArray[i] = NF_SYMBOLTYPE_DIGIT; + nPos = nPos + rStr.getLength(); + i++; + nCounter++; + while (i < nAnzStrings && + (sStrArray[i][0] == '-') ) { - /* Found a Divisor */ - while (i < j) - nTypeArray[i++] = NF_SYMBOLTYPE_FRAC_FDIV; - i = j - 1; // Stop the loop - if (nCntPost) - nCounter = nCntPost; - else if (nCntPre) - nCounter = nCntPre; - // don't artificially increment nCntPre - // for forced denominator - if ( ( eScannedType != NUMBERFORMAT_FRACTION ) && (!nCntPre) ) - nCntPre++; + // If more than two dashes are present in + // currency formats the last dash will be + // interpreted literally as a minus sign. + // Has to be this ugly. Period. + if ( eScannedType == NUMBERFORMAT_CURRENCY + && rStr.getLength() >= 2 && + (i == nAnzStrings-1 || + sStrArray[i+1][0] != '-') ) + break; + rStr += sStrArray[i]; + nPos = nPos + sStrArray[i].getLength(); + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; + nCounter++; + i++; } } else + { nTypeArray[i] = NF_SYMBOLTYPE_STRING; - nPos = nPos + sStrArray[i].Len(); - i++; - } - else if (nTypeArray[i] == NF_SYMBOLTYPE_DEL) - { - sal_Unicode cHere = sStrArray[i].GetChar(0); - // Handle not pre-known separators in switch. - sal_Unicode cSimplified; - if (StringEqualsChar( pFormatter->GetNumThousandSep(), cHere)) - cSimplified = ','; - else if (StringEqualsChar( pFormatter->GetNumDecimalSep(), cHere)) - cSimplified = '.'; - else - cSimplified = cHere; - switch ( cSimplified ) + nPos = nPos + sStrArray[i].getLength(); + i++; + } + break; + case '.': + case ',': + case '\'': + case ' ': + if ( StringEqualsChar( sOldThousandSep, cSaved ) ) { - case '#': - case '0': - case '?': - { - if (nThousand > 0) // #... # - return nPos; // Fehler - else if (bFrac && cHere == '0') - return nPos; // 0 im Nenner - nTypeArray[i] = NF_SYMBOLTYPE_DIGIT; - String& rStr = sStrArray[i]; - nPos = nPos + rStr.Len(); - i++; - nCounter++; - while (i < nAnzStrings && - (sStrArray[i].GetChar(0) == '#' || - sStrArray[i].GetChar(0) == '0' || - sStrArray[i].GetChar(0) == '?') - ) + // previous char with skip empty + sal_Unicode cPre = PreviousChar(i); + sal_Unicode cNext; + if (bExp || bBlank || bFrac) + { // after E, / or ' ' + if ( !StringEqualsChar( sOldThousandSep, ' ' ) ) { - nTypeArray[i] = NF_SYMBOLTYPE_DIGIT; - nPos = nPos + sStrArray[i].Len(); - nCounter++; - i++; - } - } - break; - case '-': - { - if ( bDecSep && nDecPos+1 == i && - nTypeArray[nDecPos] == NF_SYMBOLTYPE_DECSEP ) - { // "0.--" - nTypeArray[i] = NF_SYMBOLTYPE_DIGIT; - String& rStr = sStrArray[i]; - nPos = nPos + rStr.Len(); - i++; - nCounter++; - while (i < nAnzStrings && - (sStrArray[i].GetChar(0) == '-') ) - { - // If more than two dashes are present in - // currency formats the last dash will be - // interpreted literally as a minus sign. - // Has to be this ugly. Period. - if ( eScannedType == NUMBERFORMAT_CURRENCY - && rStr.Len() >= 2 && - (i == nAnzStrings-1 || - sStrArray[i+1].GetChar(0) != '-') ) - break; - rStr += sStrArray[i]; - nPos = nPos + sStrArray[i].Len(); - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - nCounter++; - i++; - } + nPos = nPos + sStrArray[i].getLength(); + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; + i++; // eat it } else { nTypeArray[i] = NF_SYMBOLTYPE_STRING; - nPos = nPos + sStrArray[i].Len(); - i++; } } - break; - case '.': - case ',': - case '\'': - case ' ': + else if (i > 0 && i < nAnzStrings-1 && + (cPre == '#' || cPre == '0') && + ((cNext = NextChar(i)) == '#' || cNext == '0')) // #,# { - sal_Unicode cSep = cHere; // remember - if ( StringEqualsChar( sOldThousandSep, cSep ) ) + nPos = nPos + sStrArray[i].getLength(); + if (!bThousand) // only once + { + bThousand = true; + } + // Eat it, will be reinserted at proper + // grouping positions further down. + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; + i++; + } + else if (i > 0 && (cPre == '#' || cPre == '0') + && PreviousType(i) == NF_SYMBOLTYPE_DIGIT + && nThousand < FLAG_STANDARD_IN_FORMAT ) + { // #,,,, + if ( StringEqualsChar( sOldThousandSep, ' ' ) ) { - // previous char with skip empty - sal_Unicode cPre = PreviousChar(i); - sal_Unicode cNext; - if (bExp || bBlank || bFrac) - { // after E, / or ' ' - if ( !StringEqualsChar( sOldThousandSep, ' ' ) ) + // strange, those French.. + bool bFirst = true; + // set a hard Non-Breaking Space or ConvertMode + const OUString& rSepF = pFormatter->GetNumThousandSep(); + while ( i < nAnzStrings && + sStrArray[i] == sOldThousandSep && + StringEqualsChar( sOldThousandSep, NextChar(i) ) ) + { // last was a space or another space + // is following => separator + nPos = nPos + sStrArray[i].getLength(); + if ( bFirst ) + { + bFirst = false; + rStr = rSepF; + nTypeArray[i] = NF_SYMBOLTYPE_THSEP; + } + else { - nPos = nPos + sStrArray[i].Len(); + rStr += rSepF; nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; nAnzResStrings--; - i++; // eat it } - else - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - } - else if (i > 0 && i < nAnzStrings-1 && - (cPre == '#' || cPre == '0') && - ((cNext = NextChar(i)) == '#' || cNext == '0') - ) // #,# - { - nPos = nPos + sStrArray[i].Len(); - if (!bThousand) // only once - bThousand = true; - // Eat it, will be reinserted at proper - // grouping positions further down. - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; + nThousand++; i++; } - else if (i > 0 && (cPre == '#' || cPre == '0') - && PreviousType(i) == NF_SYMBOLTYPE_DIGIT - && nThousand < FLAG_STANDARD_IN_FORMAT ) - { // #,,,, - if ( StringEqualsChar( sOldThousandSep, ' ' ) ) - { // strange, those French.. - bool bFirst = true; - String& rStr = sStrArray[i]; - // set a hard Non-Breaking Space or ConvertMode - const String& rSepF = pFormatter->GetNumThousandSep(); - while ( i < nAnzStrings - && sStrArray[i] == sOldThousandSep - && StringEqualsChar( sOldThousandSep, NextChar(i) ) ) - { // last was a space or another space - // is following => separator - nPos = nPos + sStrArray[i].Len(); - if ( bFirst ) - { - bFirst = false; - rStr = rSepF; - nTypeArray[i] = NF_SYMBOLTYPE_THSEP; - } - else - { - rStr += rSepF; - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - } - nThousand++; - i++; - } - if ( i < nAnzStrings-1 - && sStrArray[i] == sOldThousandSep ) - { // something following last space - // => space if currency contained, - // else separator - nPos = nPos + sStrArray[i].Len(); - if ( (nPos <= nCurrPos && - nCurrPos < nPos + sStrArray[i+1].Len()) - || nTypeArray[i+1] == NF_KEY_CCC - || (i < nAnzStrings-2 && - sStrArray[i+1].GetChar(0) == '[' && - sStrArray[i+2].GetChar(0) == '$') ) - { - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - } - else - { - if ( bFirst ) - { - bFirst = false; - rStr = rSepF; - nTypeArray[i] = NF_SYMBOLTYPE_THSEP; - } - else - { - rStr += rSepF; - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - } - nThousand++; - } - i++; - } + if ( i < nAnzStrings-1 && + sStrArray[i] == sOldThousandSep ) + { + // something following last space + // => space if currency contained, + // else separator + nPos = nPos + sStrArray[i].getLength(); + if ( (nPos <= nCurrPos && + nCurrPos < nPos + sStrArray[i+1].getLength()) || + nTypeArray[i+1] == NF_KEY_CCC || + (i < nAnzStrings-2 && + sStrArray[i+1][0] == '[' && + sStrArray[i+2][0] == '$') ) + { + nTypeArray[i] = NF_SYMBOLTYPE_STRING; } else { - do + if ( bFirst ) { - nThousand++; + bFirst = false; + rStr = rSepF; nTypeArray[i] = NF_SYMBOLTYPE_THSEP; - nPos = nPos + sStrArray[i].Len(); - sStrArray[i] = pFormatter->GetNumThousandSep(); - i++; - } while (i < nAnzStrings && - sStrArray[i] == sOldThousandSep); + } + else + { + rStr += rSepF; + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; + } + nThousand++; } - } - else // any grsep - { - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - String& rStr = sStrArray[i]; - nPos = nPos + rStr.Len(); i++; - while ( i < nAnzStrings && - sStrArray[i] == sOldThousandSep ) - { - rStr += sStrArray[i]; - nPos = nPos + sStrArray[i].Len(); - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - i++; - } } } - else if ( StringEqualsChar( sOldDecSep, cSep ) ) + else { - if (bBlank || bFrac) // . behind / or ' ' - return nPos; // error - else if (bExp) // behind E - { - nPos = nPos + sStrArray[i].Len(); - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - i++; // eat it - } - else if (bDecSep) // any . - { - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - String& rStr = sStrArray[i]; - nPos = nPos + rStr.Len(); - i++; - while ( i < nAnzStrings && - sStrArray[i] == sOldDecSep ) - { - rStr += sStrArray[i]; - nPos = nPos + sStrArray[i].Len(); - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - i++; - } - } - else + do { - nPos = nPos + sStrArray[i].Len(); - nTypeArray[i] = NF_SYMBOLTYPE_DECSEP; - sStrArray[i] = pFormatter->GetNumDecimalSep(); - bDecSep = true; - nDecPos = i; - nCntPre = nCounter; - nCounter = 0; - + nThousand++; + nTypeArray[i] = NF_SYMBOLTYPE_THSEP; + nPos = nPos + sStrArray[i].getLength(); + sStrArray[i] = pFormatter->GetNumThousandSep(); i++; } - } // of else = DecSep - else // . without meaning + while (i < nAnzStrings && sStrArray[i] == sOldThousandSep); + } + } + else // any grsep + { + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + nPos = nPos + rStr.getLength(); + i++; + while ( i < nAnzStrings && sStrArray[i] == sOldThousandSep ) { - if (cSep == ' ' && - eScannedType == NUMBERFORMAT_FRACTION && - StringEqualsChar( sStrArray[i], ' ' ) ) - { - if (!bBlank && !bFrac) // no dups - { // or behind / - if (bDecSep && nCounter > 0)// dec. - return nPos; // error - bBlank = true; - nBlankPos = i; - nCntPre = nCounter; - nCounter = 0; - } - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - nPos = nPos + sStrArray[i].Len(); - } - else - { - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - String& rStr = sStrArray[i]; - nPos = nPos + rStr.Len(); - i++; - while (i < nAnzStrings && - StringEqualsChar( sStrArray[i], cSep ) ) - { - rStr += sStrArray[i]; - nPos = nPos + sStrArray[i].Len(); - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - i++; - } - } + rStr += sStrArray[i]; + nPos = nPos + sStrArray[i].getLength(); + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; + i++; } } - break; - case '/': + } + else if ( StringEqualsChar( sOldDecSep, cSaved ) ) + { + if (bBlank || bFrac) // . behind / or ' ' + { + return nPos; // error + } + else if (bExp) // behind E + { + nPos = nPos + sStrArray[i].getLength(); + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; + i++; // eat it + } + else if (bDecSep) // any . { - if (eScannedType == NUMBERFORMAT_FRACTION) + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + nPos = nPos + rStr.getLength(); + i++; + while ( i < nAnzStrings && sStrArray[i] == sOldDecSep ) { - if ( i == 0 || - (nTypeArray[i-1] != NF_SYMBOLTYPE_DIGIT && - nTypeArray[i-1] != NF_SYMBOLTYPE_EMPTY) ) - return nPos ? nPos : 1; // /? not allowed - else if (!bFrac || (bDecSep && nCounter > 0)) + rStr += sStrArray[i]; + nPos = nPos + sStrArray[i].getLength(); + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; + i++; + } + } + else + { + nPos = nPos + sStrArray[i].getLength(); + nTypeArray[i] = NF_SYMBOLTYPE_DECSEP; + sStrArray[i] = pFormatter->GetNumDecimalSep(); + bDecSep = true; + nDecPos = i; + nCntPre = nCounter; + nCounter = 0; + + i++; + } + } // of else = DecSep + else // . without meaning + { + if (cSaved == ' ' && + eScannedType == NUMBERFORMAT_FRACTION && + StringEqualsChar( sStrArray[i], ' ' ) ) + { + if (!bBlank && !bFrac) // no dups + { // or behind / + if (bDecSep && nCounter > 0)// dec. { - bFrac = true; - nCntPost = nCounter; - nCounter = 0; - nTypeArray[i] = NF_SYMBOLTYPE_FRAC; - nPos = nPos + sStrArray[i].Len(); - i++; + return nPos; // error } - else // / doppelt od. , imZaehl - return nPos; // Fehler + bBlank = true; + nBlankPos = i; + nCntPre = nCounter; + nCounter = 0; } - else + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + nPos = nPos + sStrArray[i].getLength(); + } + else + { + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + nPos = nPos + rStr.getLength(); + i++; + while (i < nAnzStrings && StringEqualsChar( sStrArray[i], cSaved ) ) { - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - nPos = nPos + sStrArray[i].Len(); + rStr += sStrArray[i]; + nPos = nPos + sStrArray[i].getLength(); + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; i++; } } - break; - case '[' : + } + break; + case '/': + if (eScannedType == NUMBERFORMAT_FRACTION) + { + if ( i == 0 || + (nTypeArray[i-1] != NF_SYMBOLTYPE_DIGIT && + nTypeArray[i-1] != NF_SYMBOLTYPE_EMPTY) ) + { + return nPos ? nPos : 1; // /? not allowed + } + else if (!bFrac || (bDecSep && nCounter > 0)) + { + bFrac = true; + nCntPost = nCounter; + nCounter = 0; + nTypeArray[i] = NF_SYMBOLTYPE_FRAC; + nPos = nPos + sStrArray[i].getLength(); + i++; + } + else // / doppelt od. , imZaehl + { + return nPos; // Fehler + } + } + else + { + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + nPos = nPos + sStrArray[i].getLength(); + i++; + } + break; + case '[' : + if ( eScannedType == NUMBERFORMAT_CURRENCY && + i < nAnzStrings-1 && + nTypeArray[i+1] == NF_SYMBOLTYPE_STRING && + sStrArray[i+1][0] == '$' ) + { + // [$DM-xxx] + // ab SV_NUMBERFORMATTER_VERSION_NEW_CURR + nPos = nPos + sStrArray[i].getLength(); // [ + nTypeArray[i] = NF_SYMBOLTYPE_CURRDEL; + nPos = nPos + sStrArray[++i].getLength(); // $ + sStrArray[i-1] += sStrArray[i]; // [$ + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; + if ( ++i >= nAnzStrings ) + { + return nPos; // Fehler + } + nPos = nPos + sStrArray[i].getLength(); // DM + OUString* pStr = &sStrArray[i]; + nTypeArray[i] = NF_SYMBOLTYPE_CURRENCY; // wandeln + bool bHadDash = false; + i++; + while ( i < nAnzStrings && sStrArray[i][0] != ']' ) { - if ( eScannedType == NUMBERFORMAT_CURRENCY && - i < nAnzStrings-1 && - nTypeArray[i+1] == NF_SYMBOLTYPE_STRING && - sStrArray[i+1].GetChar(0) == '$' ) - { // [$DM-xxx] - // ab SV_NUMBERFORMATTER_VERSION_NEW_CURR - nPos = nPos + sStrArray[i].Len(); // [ - nTypeArray[i] = NF_SYMBOLTYPE_CURRDEL; - nPos = nPos + sStrArray[++i].Len(); // $ - sStrArray[i-1] += sStrArray[i]; // [$ + nPos = nPos + sStrArray[i].getLength(); + if ( bHadDash ) + { + *pStr += sStrArray[i]; nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; nAnzResStrings--; - if ( ++i >= nAnzStrings ) - return nPos; // Fehler - nPos = nPos + sStrArray[i].Len(); // DM - String& rStr = sStrArray[i]; - String* pStr = &sStrArray[i]; - nTypeArray[i] = NF_SYMBOLTYPE_CURRENCY; // wandeln - bool bHadDash = false; - i++; - while ( i < nAnzStrings && - sStrArray[i].GetChar(0) != ']' ) + } + else + { + if ( sStrArray[i][0] == '-' ) { - nPos = nPos + sStrArray[i].Len(); - if ( bHadDash ) - { - *pStr += sStrArray[i]; - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - } - else - { - if ( sStrArray[i].GetChar(0) == '-' ) - { - bHadDash = true; - pStr = &sStrArray[i]; - nTypeArray[i] = NF_SYMBOLTYPE_CURREXT; - } - else - { - *pStr += sStrArray[i]; - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - } - } - i++; + bHadDash = true; + pStr = &sStrArray[i]; + nTypeArray[i] = NF_SYMBOLTYPE_CURREXT; } - if ( rStr.Len() && i < nAnzStrings && - sStrArray[i].GetChar(0) == ']' ) + else { - nTypeArray[i] = NF_SYMBOLTYPE_CURRDEL; - nPos = nPos + sStrArray[i].Len(); - i++; + *pStr += sStrArray[i]; + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; } - else - return nPos; // Fehler - } - else - { - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - nPos = nPos + sStrArray[i].Len(); - i++; } + i++; } - break; - default: // andere Dels + if ( rStr.getLength() && i < nAnzStrings && sStrArray[i][0] == ']' ) { - if (eScannedType == NUMBERFORMAT_PERCENT && - cHere == '%') - nTypeArray[i] = NF_SYMBOLTYPE_PERCENT; - else - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - nPos = nPos + sStrArray[i].Len(); + nTypeArray[i] = NF_SYMBOLTYPE_CURRDEL; + nPos = nPos + sStrArray[i].getLength(); i++; } - break; - } // of switch (Del) - } // of else Del - else - { - SAL_WARN( "svl.numbers", "unknown NF_SYMBOLTYPE_..." ); - nPos = nPos + sStrArray[i].Len(); + else + { + return nPos; // Fehler + } + } + else + { + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + nPos = nPos + sStrArray[i].getLength(); + i++; + } + break; + default: // andere Dels + if (eScannedType == NUMBERFORMAT_PERCENT && cHere == '%') + { + nTypeArray[i] = NF_SYMBOLTYPE_PERCENT; + } + else + { + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + } + nPos = nPos + sStrArray[i].getLength(); i++; - } - } // of while - if (eScannedType == NUMBERFORMAT_FRACTION) + break; + } // of switch (Del) + } // of else Del + else { - if (bFrac) - nCntExp = nCounter; - else if (bBlank) - nCntPost = nCounter; - else - nCntPre = nCounter; + SAL_WARN( "svl.numbers", "unknown NF_SYMBOLTYPE_..." ); + nPos = nPos + sStrArray[i].getLength(); + i++; + } + } // of while + if (eScannedType == NUMBERFORMAT_FRACTION) + { + if (bFrac) + { + nCntExp = nCounter; + } + else if (bBlank) + { + nCntPost = nCounter; } else { - if (bExp) - nCntExp = nCounter; - else if (bDecSep) - nCntPost = nCounter; - else - nCntPre = nCounter; + nCntPre = nCounter; } - if (bThousand) // Expansion of grouping separators + } + else + { + if (bExp) { - sal_uInt16 nMaxPos; - if (bFrac) + nCntExp = nCounter; + } + else if (bDecSep) + { + nCntPost = nCounter; + } + else + { + nCntPre = nCounter; + } + } + if (bThousand) // Expansion of grouping separators + { + sal_uInt16 nMaxPos; + if (bFrac) + { + if (bBlank) { - if (bBlank) - nMaxPos = nBlankPos; - else - nMaxPos = 0; // no grouping + nMaxPos = nBlankPos; } - else if (bDecSep) // decimal separator present - nMaxPos = nDecPos; - else if (bExp) // 'E' exponent present - nMaxPos = nExpPos; - else // up to end - nMaxPos = i; - // Insert separators at proper positions. - xub_StrLen nCount = 0; - utl::DigitGroupingIterator aGrouping( pLoc->getDigitGrouping()); - size_t nFirstDigitSymbol = nMaxPos; - size_t nFirstGroupingSymbol = nMaxPos; - i = nMaxPos; - while (i-- > 0) + else + { + nMaxPos = 0; // no grouping + } + } + else if (bDecSep) // decimal separator present + { + nMaxPos = nDecPos; + } + else if (bExp) // 'E' exponent present + { + nMaxPos = nExpPos; + } + else // up to end + { + nMaxPos = i; + } + // Insert separators at proper positions. + sal_Int32 nCount = 0; + utl::DigitGroupingIterator aGrouping( pLoc->getDigitGrouping()); + size_t nFirstDigitSymbol = nMaxPos; + size_t nFirstGroupingSymbol = nMaxPos; + i = nMaxPos; + while (i-- > 0) + { + if (nTypeArray[i] == NF_SYMBOLTYPE_DIGIT) { - if (nTypeArray[i] == NF_SYMBOLTYPE_DIGIT) + nFirstDigitSymbol = i; + nCount = nCount + sStrArray[i].getLength(); // MSC converts += to int and then warns, so ... + // Insert separator only if not leftmost symbol. + if (i > 0 && nCount >= aGrouping.getPos()) { - nFirstDigitSymbol = i; - nCount = nCount + sStrArray[i].Len(); // MSC converts += to int and then warns, so ... - // Insert separator only if not leftmost symbol. - if (i > 0 && nCount >= aGrouping.getPos()) - { - DBG_ASSERT( sStrArray[i].Len() == 1, + DBG_ASSERT( sStrArray[i].getLength() == 1, "ImpSvNumberformatScan::FinalScan: combined digits in group separator insertion"); - if (!InsertSymbol( i, NF_SYMBOLTYPE_THSEP, - pFormatter->GetNumThousandSep())) - // nPos isn't correct here, but signals error - return nPos; - // i may have been decremented by 1 - nFirstDigitSymbol = i + 1; - nFirstGroupingSymbol = i; - aGrouping.advance(); + if (!InsertSymbol( i, NF_SYMBOLTYPE_THSEP, pFormatter->GetNumThousandSep())) + { + // nPos isn't correct here, but signals error + return nPos; } + // i may have been decremented by 1 + nFirstDigitSymbol = i + 1; + nFirstGroupingSymbol = i; + aGrouping.advance(); } } - // Generated something like "string",000; remove separator again. - if (nFirstGroupingSymbol < nFirstDigitSymbol) - { - nTypeArray[nFirstGroupingSymbol] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - } } - // Combine digits into groups to save memory (Info will be copied - // later, taking only non-empty symbols). - for (i = 0; i < nAnzStrings; ++i) + // Generated something like "string",000; remove separator again. + if (nFirstGroupingSymbol < nFirstDigitSymbol) { - if (nTypeArray[i] == NF_SYMBOLTYPE_DIGIT) + nTypeArray[nFirstGroupingSymbol] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; + } + } + // Combine digits into groups to save memory (Info will be copied + // later, taking only non-empty symbols). + for (i = 0; i < nAnzStrings; ++i) + { + if (nTypeArray[i] == NF_SYMBOLTYPE_DIGIT) + { + OUString& rStr = sStrArray[i]; + while (++i < nAnzStrings && nTypeArray[i] == NF_SYMBOLTYPE_DIGIT) { - String& rStr = sStrArray[i]; - while (++i < nAnzStrings && - nTypeArray[i] == NF_SYMBOLTYPE_DIGIT) - { - rStr += sStrArray[i]; - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - } + rStr += sStrArray[i]; + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; } } } break; // of NUMBERFORMAT_NUMBER - case NUMBERFORMAT_DATE: + case NUMBERFORMAT_DATE: + while (i < nAnzStrings) { - while (i < nAnzStrings) + int nCalRet; + switch (nTypeArray[i]) { - switch (nTypeArray[i]) + case NF_SYMBOLTYPE_BLANK: + case NF_SYMBOLTYPE_STAR: + case NF_SYMBOLTYPE_STRING: + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + case NF_SYMBOLTYPE_DEL: + if (sStrArray[i] == sOldDateSep) { - case NF_SYMBOLTYPE_BLANK: - case NF_SYMBOLTYPE_STAR: - case NF_SYMBOLTYPE_STRING: - nPos = nPos + sStrArray[i].Len(); - i++; - break; - case NF_SYMBOLTYPE_DEL: + nTypeArray[i] = NF_SYMBOLTYPE_DATESEP; + nPos = nPos + sStrArray[i].getLength(); + if (bConvertMode) { - int nCalRet; - if (sStrArray[i] == sOldDateSep) - { - nTypeArray[i] = NF_SYMBOLTYPE_DATESEP; - nPos = nPos + sStrArray[i].Len(); - if (bConvertMode) - sStrArray[i] = pFormatter->GetDateSep(); - i++; - } - else if ( (nCalRet = FinalScanGetCalendar( nPos, i, nAnzResStrings )) != 0 ) - { - if ( nCalRet < 0 ) - return nPos; // error - } - else - { - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - nPos = nPos + sStrArray[i].Len(); - i++; - } + sStrArray[i] = pFormatter->GetDateSep(); } - break; - case NF_KEY_THAI_T : - bThaiT = true; - // fall thru - case NF_KEY_M: // M - case NF_KEY_MM: // MM - case NF_KEY_MMM: // MMM - case NF_KEY_MMMM: // MMMM - case NF_KEY_MMMMM: // MMMMM - case NF_KEY_Q: // Q - case NF_KEY_QQ: // QQ - case NF_KEY_D: // D - case NF_KEY_DD: // DD - case NF_KEY_DDD: // DDD - case NF_KEY_DDDD: // DDDD - case NF_KEY_YY: // YY - case NF_KEY_YYYY: // YYYY - case NF_KEY_NN: // NN - case NF_KEY_NNN: // NNN - case NF_KEY_NNNN: // NNNN - case NF_KEY_WW : // WW - case NF_KEY_AAA : // AAA - case NF_KEY_AAAA : // AAAA - case NF_KEY_EC : // E - case NF_KEY_EEC : // EE - case NF_KEY_G : // G - case NF_KEY_GG : // GG - case NF_KEY_GGG : // GGG - case NF_KEY_R : // R - case NF_KEY_RR : // RR - sStrArray[i] = String(sKeyword[nTypeArray[i]]); // tTtT -> TTTT - nPos = nPos + sStrArray[i].Len(); - i++; - break; - default: // andere Keywords - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - nPos = nPos + sStrArray[i].Len(); - i++; - break; + i++; } - } // of while - } + else if ( (nCalRet = FinalScanGetCalendar( nPos, i, nAnzResStrings )) != 0 ) + { + if ( nCalRet < 0 ) + { + return nPos; // error + } + } + else + { + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + nPos = nPos + sStrArray[i].getLength(); + i++; + } + break; + case NF_KEY_THAI_T : + bThaiT = true; + // fall thru + case NF_KEY_M: // M + case NF_KEY_MM: // MM + case NF_KEY_MMM: // MMM + case NF_KEY_MMMM: // MMMM + case NF_KEY_MMMMM: // MMMMM + case NF_KEY_Q: // Q + case NF_KEY_QQ: // QQ + case NF_KEY_D: // D + case NF_KEY_DD: // DD + case NF_KEY_DDD: // DDD + case NF_KEY_DDDD: // DDDD + case NF_KEY_YY: // YY + case NF_KEY_YYYY: // YYYY + case NF_KEY_NN: // NN + case NF_KEY_NNN: // NNN + case NF_KEY_NNNN: // NNNN + case NF_KEY_WW : // WW + case NF_KEY_AAA : // AAA + case NF_KEY_AAAA : // AAAA + case NF_KEY_EC : // E + case NF_KEY_EEC : // EE + case NF_KEY_G : // G + case NF_KEY_GG : // GG + case NF_KEY_GGG : // GGG + case NF_KEY_R : // R + case NF_KEY_RR : // RR + sStrArray[i] = OUString(sKeyword[nTypeArray[i]]); // tTtT -> TTTT + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + default: // andere Keywords + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + } + } // of while break; // of NUMBERFORMAT_DATE - case NUMBERFORMAT_TIME: + case NUMBERFORMAT_TIME: + while (i < nAnzStrings) { - while (i < nAnzStrings) + switch (nTypeArray[i]) { - switch (nTypeArray[i]) + case NF_SYMBOLTYPE_BLANK: + case NF_SYMBOLTYPE_STAR: + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + case NF_SYMBOLTYPE_DEL: + switch( sStrArray[i][0] ) + { + case '0': { - case NF_SYMBOLTYPE_BLANK: - case NF_SYMBOLTYPE_STAR: + if ( Is100SecZero( i, bDecSep ) ) { - nPos = nPos + sStrArray[i].Len(); + bDecSep = true; + nTypeArray[i] = NF_SYMBOLTYPE_DIGIT; + OUString& rStr = sStrArray[i]; i++; - } - break; - case NF_SYMBOLTYPE_DEL: - { - switch( sStrArray[i].GetChar(0) ) + nPos = nPos + sStrArray[i].getLength(); + nCounter++; + while (i < nAnzStrings && + sStrArray[i][0] == '0') { - case '0': - { - if ( Is100SecZero( i, bDecSep ) ) - { - bDecSep = true; - nTypeArray[i] = NF_SYMBOLTYPE_DIGIT; - String& rStr = sStrArray[i]; - i++; - nPos = nPos + sStrArray[i].Len(); - nCounter++; - while (i < nAnzStrings && - sStrArray[i].GetChar(0) == '0') - { - rStr += sStrArray[i]; - nPos = nPos + sStrArray[i].Len(); - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - nCounter++; - i++; - } - } - else - return nPos; - } - break; - case '#': - case '?': - return nPos; - case '[': - { - if (bThousand) // doppelt - return nPos; - bThousand = true; // bei Time frei - sal_Unicode cChar = pChrCls->uppercase(rtl::OUString(NextChar(i)))[0]; - if ( cChar == cOldKeyH ) - nThousand = 1; // H - else if ( cChar == cOldKeyMI ) - nThousand = 2; // M - else if ( cChar == cOldKeyS ) - nThousand = 3; // S - else - return nPos; - nPos = nPos + sStrArray[i].Len(); - i++; - } - break; - case ']': - { - if (!bThousand) // kein [ vorher - return nPos; - nPos = nPos + sStrArray[i].Len(); - i++; - } - break; - default: - { - nPos = nPos + sStrArray[i].Len(); - if ( sStrArray[i] == sOldTimeSep ) - { - nTypeArray[i] = NF_SYMBOLTYPE_TIMESEP; - if ( bConvertMode ) - sStrArray[i] = pLoc->getTimeSep(); - } - else if ( sStrArray[i] == sOldTime100SecSep ) - { - bDecSep = true; - nTypeArray[i] = NF_SYMBOLTYPE_TIME100SECSEP; - if ( bConvertMode ) - sStrArray[i] = pLoc->getTime100SecSep(); - } - else - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - i++; - } - break; + rStr += sStrArray[i]; + nPos = nPos + sStrArray[i].getLength(); + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; + nCounter++; + i++; } } - break; - case NF_SYMBOLTYPE_STRING: + else { - nPos = nPos + sStrArray[i].Len(); - i++; + return nPos; } - break; - case NF_KEY_AMPM: // AM/PM - case NF_KEY_AP: // A/P + } + break; + case '#': + case '?': + return nPos; + case '[': + { + if (bThousand) // doppelt + return nPos; + bThousand = true; // bei Time frei + sal_Unicode cChar = pChrCls->uppercase(rtl::OUString(NextChar(i)))[0]; + if ( cChar == cOldKeyH ) + nThousand = 1; // H + else if ( cChar == cOldKeyMI ) + nThousand = 2; // M + else if ( cChar == cOldKeyS ) + nThousand = 3; // S + else + return nPos; + nPos = nPos + sStrArray[i].getLength(); + i++; + } + break; + case ']': + { + if (!bThousand) // kein [ vorher + return nPos; + nPos = nPos + sStrArray[i].getLength(); + i++; + } + break; + default: + { + nPos = nPos + sStrArray[i].getLength(); + if ( sStrArray[i] == sOldTimeSep ) { - bExp = true; // missbraucht fuer A/P - sStrArray[i] = String(sKeyword[nTypeArray[i]]); // tTtT -> TTTT - nPos = nPos + sStrArray[i].Len(); - i++; + nTypeArray[i] = NF_SYMBOLTYPE_TIMESEP; + if ( bConvertMode ) + sStrArray[i] = pLoc->getTimeSep(); } - break; - case NF_KEY_THAI_T : - bThaiT = true; - // fall thru - case NF_KEY_MI: // M - case NF_KEY_MMI: // MM - case NF_KEY_H: // H - case NF_KEY_HH: // HH - case NF_KEY_S: // S - case NF_KEY_SS: // SS + else if ( sStrArray[i] == sOldTime100SecSep ) { - sStrArray[i] = String(sKeyword[nTypeArray[i]]); // tTtT -> TTTT - nPos = nPos + sStrArray[i].Len(); - i++; + bDecSep = true; + nTypeArray[i] = NF_SYMBOLTYPE_TIME100SECSEP; + if ( bConvertMode ) + sStrArray[i] = pLoc->getTime100SecSep(); } - break; - default: // andere Keywords - { + else nTypeArray[i] = NF_SYMBOLTYPE_STRING; - nPos = nPos + sStrArray[i].Len(); - i++; - } - break; + i++; } - } // of while - nCntPost = nCounter; // Zaehler der Nullen - if (bExp) - nCntExp = 1; // merkt AM/PM + break; + } + break; + case NF_SYMBOLTYPE_STRING: + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + case NF_KEY_AMPM: // AM/PM + case NF_KEY_AP: // A/P + bExp = true; // missbraucht fuer A/P + sStrArray[i] = sKeyword[nTypeArray[i]]; // tTtT -> TTTT + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + case NF_KEY_THAI_T : + bThaiT = true; + // fall thru + case NF_KEY_MI: // M + case NF_KEY_MMI: // MM + case NF_KEY_H: // H + case NF_KEY_HH: // HH + case NF_KEY_S: // S + case NF_KEY_SS: // SS + sStrArray[i] = sKeyword[nTypeArray[i]]; // tTtT -> TTTT + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + default: // andere Keywords + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + } + } // of while + nCntPost = nCounter; // Zaehler der Nullen + if (bExp) + { + nCntExp = 1; // merkt AM/PM } break; // of NUMBERFORMAT_TIME - case NUMBERFORMAT_DATETIME: + case NUMBERFORMAT_DATETIME: + while (i < nAnzStrings) { - bool bTimePart = false; - while (i < nAnzStrings) + int nCalRet; + switch (nTypeArray[i]) { - switch (nTypeArray[i]) + case NF_SYMBOLTYPE_BLANK: + case NF_SYMBOLTYPE_STAR: + case NF_SYMBOLTYPE_STRING: + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + case NF_SYMBOLTYPE_DEL: + if ( (nCalRet = FinalScanGetCalendar( nPos, i, nAnzResStrings )) != 0 ) { - case NF_SYMBOLTYPE_BLANK: - case NF_SYMBOLTYPE_STAR: - case NF_SYMBOLTYPE_STRING: - nPos = nPos + sStrArray[i].Len(); - i++; - break; - case NF_SYMBOLTYPE_DEL: + if ( nCalRet < 0 ) + return nPos; // error + } + else + { + switch( sStrArray[i][0] ) { - int nCalRet; - if ( (nCalRet = FinalScanGetCalendar( nPos, i, nAnzResStrings )) != 0 ) + case '0': + if ( bTimePart && Is100SecZero( i, bDecSep ) ) { - if ( nCalRet < 0 ) - return nPos; // error + bDecSep = true; + nTypeArray[i] = NF_SYMBOLTYPE_DIGIT; + OUString& rStr = sStrArray[i]; + i++; + nPos = nPos + sStrArray[i].getLength(); + nCounter++; + while (i < nAnzStrings && + sStrArray[i][0] == '0') + { + rStr += sStrArray[i]; + nPos = nPos + sStrArray[i].getLength(); + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; + nCounter++; + i++; + } } else { - switch( sStrArray[i].GetChar(0) ) + return nPos; + } + break; + case '#': + case '?': + return nPos; + default: + nPos = nPos + sStrArray[i].getLength(); + if (bTimePart) + { + if ( sStrArray[i] == sOldTimeSep ) { - case '0': - { - if ( bTimePart && Is100SecZero( i, bDecSep ) ) - { - bDecSep = true; - nTypeArray[i] = NF_SYMBOLTYPE_DIGIT; - String& rStr = sStrArray[i]; - i++; - nPos = nPos + sStrArray[i].Len(); - nCounter++; - while (i < nAnzStrings && - sStrArray[i].GetChar(0) == '0') - { - rStr += sStrArray[i]; - nPos = nPos + sStrArray[i].Len(); - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - nCounter++; - i++; - } - } - else - return nPos; - } - break; - case '#': - case '?': - return nPos; - default: - { - nPos = nPos + sStrArray[i].Len(); - if (bTimePart) - { - if ( sStrArray[i] == sOldTimeSep ) - { - nTypeArray[i] = NF_SYMBOLTYPE_TIMESEP; - if ( bConvertMode ) - sStrArray[i] = pLoc->getTimeSep(); - } - else if ( sStrArray[i] == sOldTime100SecSep ) - { - bDecSep = true; - nTypeArray[i] = NF_SYMBOLTYPE_TIME100SECSEP; - if ( bConvertMode ) - sStrArray[i] = pLoc->getTime100SecSep(); - } - else - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - } - else - { - if ( sStrArray[i] == sOldDateSep ) - { - nTypeArray[i] = NF_SYMBOLTYPE_DATESEP; - if (bConvertMode) - sStrArray[i] = pFormatter->GetDateSep(); - } - else - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - } - i++; - } + nTypeArray[i] = NF_SYMBOLTYPE_TIMESEP; + if ( bConvertMode ) + sStrArray[i] = pLoc->getTimeSep(); } + else if ( sStrArray[i] == sOldTime100SecSep ) + { + bDecSep = true; + nTypeArray[i] = NF_SYMBOLTYPE_TIME100SECSEP; + if ( bConvertMode ) + sStrArray[i] = pLoc->getTime100SecSep(); + } + else + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + } + else + { + if ( sStrArray[i] == sOldDateSep ) + { + nTypeArray[i] = NF_SYMBOLTYPE_DATESEP; + if (bConvertMode) + sStrArray[i] = pFormatter->GetDateSep(); + } + else + nTypeArray[i] = NF_SYMBOLTYPE_STRING; } - } - break; - case NF_KEY_AMPM: // AM/PM - case NF_KEY_AP: // A/P - { - bTimePart = true; - bExp = true; // missbraucht fuer A/P - sStrArray[i] = String(sKeyword[nTypeArray[i]]); // tTtT -> TTTT - nPos = nPos + sStrArray[i].Len(); i++; + break; } - break; - case NF_KEY_MI: // M - case NF_KEY_MMI: // MM - case NF_KEY_H: // H - case NF_KEY_HH: // HH - case NF_KEY_S: // S - case NF_KEY_SS: // SS - bTimePart = true; - sStrArray[i] = String(sKeyword[nTypeArray[i]]); // tTtT -> TTTT - nPos = nPos + sStrArray[i].Len(); - i++; - break; - case NF_KEY_M: // M - case NF_KEY_MM: // MM - case NF_KEY_MMM: // MMM - case NF_KEY_MMMM: // MMMM - case NF_KEY_MMMMM: // MMMMM - case NF_KEY_Q: // Q - case NF_KEY_QQ: // QQ - case NF_KEY_D: // D - case NF_KEY_DD: // DD - case NF_KEY_DDD: // DDD - case NF_KEY_DDDD: // DDDD - case NF_KEY_YY: // YY - case NF_KEY_YYYY: // YYYY - case NF_KEY_NN: // NN - case NF_KEY_NNN: // NNN - case NF_KEY_NNNN: // NNNN - case NF_KEY_WW : // WW - case NF_KEY_AAA : // AAA - case NF_KEY_AAAA : // AAAA - case NF_KEY_EC : // E - case NF_KEY_EEC : // EE - case NF_KEY_G : // G - case NF_KEY_GG : // GG - case NF_KEY_GGG : // GGG - case NF_KEY_R : // R - case NF_KEY_RR : // RR - bTimePart = false; - sStrArray[i] = String(sKeyword[nTypeArray[i]]); // tTtT -> TTTT - nPos = nPos + sStrArray[i].Len(); - i++; - break; - case NF_KEY_THAI_T : - bThaiT = true; - sStrArray[i] = String(sKeyword[nTypeArray[i]]); - nPos = nPos + sStrArray[i].Len(); - i++; - break; - default: // andere Keywords - nTypeArray[i] = NF_SYMBOLTYPE_STRING; - nPos = nPos + sStrArray[i].Len(); - i++; - break; } - } // of while - nCntPost = nCounter; // decimals (100th seconds) - if (bExp) - nCntExp = 1; // merkt AM/PM + break; + case NF_KEY_AMPM: // AM/PM + case NF_KEY_AP: // A/P + bTimePart = true; + bExp = true; // missbraucht fuer A/P + sStrArray[i] = sKeyword[nTypeArray[i]]; // tTtT -> TTTT + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + case NF_KEY_MI: // M + case NF_KEY_MMI: // MM + case NF_KEY_H: // H + case NF_KEY_HH: // HH + case NF_KEY_S: // S + case NF_KEY_SS: // SS + bTimePart = true; + sStrArray[i] = sKeyword[nTypeArray[i]]; // tTtT -> TTTT + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + case NF_KEY_M: // M + case NF_KEY_MM: // MM + case NF_KEY_MMM: // MMM + case NF_KEY_MMMM: // MMMM + case NF_KEY_MMMMM: // MMMMM + case NF_KEY_Q: // Q + case NF_KEY_QQ: // QQ + case NF_KEY_D: // D + case NF_KEY_DD: // DD + case NF_KEY_DDD: // DDD + case NF_KEY_DDDD: // DDDD + case NF_KEY_YY: // YY + case NF_KEY_YYYY: // YYYY + case NF_KEY_NN: // NN + case NF_KEY_NNN: // NNN + case NF_KEY_NNNN: // NNNN + case NF_KEY_WW : // WW + case NF_KEY_AAA : // AAA + case NF_KEY_AAAA : // AAAA + case NF_KEY_EC : // E + case NF_KEY_EEC : // EE + case NF_KEY_G : // G + case NF_KEY_GG : // GG + case NF_KEY_GGG : // GGG + case NF_KEY_R : // R + case NF_KEY_RR : // RR + bTimePart = false; + sStrArray[i] = sKeyword[nTypeArray[i]]; // tTtT -> TTTT + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + case NF_KEY_THAI_T : + bThaiT = true; + sStrArray[i] = sKeyword[nTypeArray[i]]; + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + default: // andere Keywords + nTypeArray[i] = NF_SYMBOLTYPE_STRING; + nPos = nPos + sStrArray[i].getLength(); + i++; + break; + } + } // of while + nCntPost = nCounter; // decimals (100th seconds) + if (bExp) + { + nCntExp = 1; // merkt AM/PM } break; // of NUMBERFORMAT_DATETIME - default: + default: break; } if (eScannedType == NUMBERFORMAT_SCIENTIFIC && (nCntPre + nCntPost == 0 || nCntExp == 0)) + { return nPos; + } else if (eScannedType == NUMBERFORMAT_FRACTION && (nCntExp > 8 || nCntExp == 0)) + { return nPos; - + } if (bThaiT && !GetNatNumModifier()) + { SetNatNumModifier(1); - + } if ( bConvertMode ) { // strings containing keywords of the target locale must be quoted, so // the user sees the difference and is able to edit the format string for ( i=0; i < nAnzStrings; i++ ) { if ( nTypeArray[i] == NF_SYMBOLTYPE_STRING && - sStrArray[i].GetChar(0) != '\"' ) + sStrArray[i][0] != '\"' ) { if ( bConvertSystemToSystem && eScannedType == NUMBERFORMAT_CURRENCY ) - { // don't stringize automatic currency, will be converted + { + // don't stringize automatic currency, will be converted if ( sStrArray[i] == sOldCurSymbol ) + { continue; // for + } // DM might be splitted into D and M - if ( sStrArray[i].Len() < sOldCurSymbol.Len() && - pChrCls->uppercase( sStrArray[i], 0, 1 )[0] == - sOldCurString[0] ) + if ( sStrArray[i].getLength() < sOldCurSymbol.getLength() && + pChrCls->uppercase( sStrArray[i], 0, 1 )[0] == + sOldCurString[0] ) { - String aTmp( sStrArray[i] ); + OUString aTmp( sStrArray[i] ); sal_uInt16 j = i + 1; - while ( aTmp.Len() < sOldCurSymbol.Len() && + while ( aTmp.getLength() < sOldCurSymbol.getLength() && j < nAnzStrings && nTypeArray[j] == NF_SYMBOLTYPE_STRING ) { @@ -2549,14 +2645,13 @@ xub_StrLen ImpSvNumberformatScan::FinalScan( String& rString ) } } } - String& rStr = sStrArray[i]; - xub_StrLen nLen = rStr.Len(); - for ( xub_StrLen j=0; j<nLen; j++ ) + OUString& rStr = sStrArray[i]; + sal_Int32 nLen = rStr.getLength(); + for ( sal_Int32 j = 0; j < nLen; j++ ) { - if ( (j == 0 || rStr.GetChar(j-1) != '\\') && GetKeyWord( rStr, j ) ) + if ( (j == 0 || rStr[j - 1] != '\\') && GetKeyWord( rStr, j ) ) { - rStr.Insert( '\"', 0 ); - rStr += '\"'; + rStr = "\"" + rStr + "\""; break; // for } } @@ -2564,178 +2659,195 @@ xub_StrLen ImpSvNumberformatScan::FinalScan( String& rString ) } } // concatenate strings, remove quotes for output, and rebuild the format string - rString.Erase(); + rString = ""; i = 0; while (i < nAnzStrings) { + sal_Int32 nStringPos; + sal_Int32 nArrPos = 0; + sal_uInt16 iPos = i; switch ( nTypeArray[i] ) { - case NF_SYMBOLTYPE_STRING : + case NF_SYMBOLTYPE_STRING : + nStringPos = rString.getLength(); + do { - xub_StrLen nStringPos = rString.Len(); - xub_StrLen nArrPos = 0; - sal_uInt16 iPos = i; - do + if (sStrArray[i].getLength() == 2 && + sStrArray[i][0] == '\\') { - if (sStrArray[i].Len() == 2 && - sStrArray[i].GetChar(0) == '\\') + // Unescape some simple forms of symbols even in the UI + // visible string to prevent duplicates that differ + // only in notation, originating from import. + // e.g. YYYY-MM-DD and YYYY\-MM\-DD are identical, + // but 0\ 000 0 and 0 000 0 in a French locale are not. + sal_Unicode c = sStrArray[i][1]; + switch (c) { - // Unescape some simple forms of symbols even in the UI - // visible string to prevent duplicates that differ - // only in notation, originating from import. - // e.g. YYYY-MM-DD and YYYY\-MM\-DD are identical, - // but 0\ 000 0 and 0 000 0 in a French locale are not. - sal_Unicode c = sStrArray[i].GetChar(1); - switch (c) + case '+': + case '-': + rString += OUString(c); + break; + case ' ': + case '.': + case '/': + if (((eScannedType & NUMBERFORMAT_DATE) == 0) && + (StringEqualsChar( pFormatter->GetNumThousandSep(), c) || + StringEqualsChar( pFormatter->GetNumDecimalSep(), c) || + (c == ' ' && StringEqualsChar( pFormatter->GetNumThousandSep(), cNonBreakingSpace)))) { - case '+': - case '-': - rString += c; - break; - case ' ': - case '.': - case '/': - if (((eScannedType & NUMBERFORMAT_DATE) == 0) - && (StringEqualsChar( - pFormatter->GetNumThousandSep(), - c) || StringEqualsChar( - pFormatter->GetNumDecimalSep(), - c) || (c == ' ' && - StringEqualsChar( - pFormatter->GetNumThousandSep(), - cNonBreakingSpace)))) - rString += sStrArray[i]; - else if ((eScannedType & NUMBERFORMAT_DATE) && - StringEqualsChar( - pFormatter->GetDateSep(), c)) - rString += sStrArray[i]; - else if ((eScannedType & NUMBERFORMAT_TIME) && - (StringEqualsChar( pLoc->getTimeSep(), - c) || - StringEqualsChar( - pLoc->getTime100SecSep(), c))) - rString += sStrArray[i]; - else if (eScannedType & NUMBERFORMAT_FRACTION) - rString += sStrArray[i]; - else - rString += c; - break; - default: - rString += sStrArray[i]; + rString += sStrArray[i]; } - } - else - rString += sStrArray[i]; - if ( RemoveQuotes( sStrArray[i] ) > 0 ) - { // update currency up to quoted string - if ( eScannedType == NUMBERFORMAT_CURRENCY ) - { // dM -> DM or DM -> $ in old automatic - // currency formats, oh my ..., why did we ever - // introduce them? - String aTmp( pChrCls->uppercase( - sStrArray[iPos], nArrPos, - sStrArray[iPos].Len()-nArrPos ) ); - xub_StrLen nCPos = aTmp.Search( sOldCurString ); - if ( nCPos != STRING_NOTFOUND ) - { - const String& rCur = - bConvertMode && bConvertSystemToSystem ? - GetCurSymbol() : sOldCurSymbol; - sStrArray[iPos].Replace( nArrPos+nCPos, - sOldCurString.getLength(), rCur ); - rString.Replace( nStringPos+nCPos, - sOldCurString.getLength(), rCur ); - } - nStringPos = rString.Len(); - if ( iPos == i ) - nArrPos = sStrArray[iPos].Len(); - else - nArrPos = sStrArray[iPos].Len() + sStrArray[i].Len(); + else if ((eScannedType & NUMBERFORMAT_DATE) && + StringEqualsChar( pFormatter->GetDateSep(), c)) + { + rString += sStrArray[i]; } + else if ((eScannedType & NUMBERFORMAT_TIME) && + (StringEqualsChar( pLoc->getTimeSep(), c) || + StringEqualsChar( pLoc->getTime100SecSep(), c))) + { + rString += sStrArray[i]; + } + else if (eScannedType & NUMBERFORMAT_FRACTION) + { + rString += sStrArray[i]; + } + else + { + rString += OUString(c); + } + break; + default: + rString += sStrArray[i]; } - if ( iPos != i ) - { - sStrArray[iPos] += sStrArray[i]; - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; - } - i++; - } while ( i < nAnzStrings && nTypeArray[i] == NF_SYMBOLTYPE_STRING ); - if ( i < nAnzStrings ) - i--; // enter switch on next symbol again - if ( eScannedType == NUMBERFORMAT_CURRENCY && nStringPos < rString.Len() ) - { // same as above, since last RemoveQuotes - String aTmp( pChrCls->uppercase( - sStrArray[iPos], nArrPos, - sStrArray[iPos].Len()-nArrPos ) ); - xub_StrLen nCPos = aTmp.Search( sOldCurString ); - if ( nCPos != STRING_NOTFOUND ) + } + else + { + rString += sStrArray[i]; + } + if ( RemoveQuotes( sStrArray[i] ) > 0 ) + { + // update currency up to quoted string + if ( eScannedType == NUMBERFORMAT_CURRENCY ) { - const String& rCur = - bConvertMode && bConvertSystemToSystem ? - GetCurSymbol() : sOldCurSymbol; - sStrArray[iPos].Replace( nArrPos+nCPos, - sOldCurString.getLength(), rCur ); - rString.Replace( nStringPos+nCPos, - sOldCurString.getLength(), rCur ); + // dM -> DM or DM -> $ in old automatic + // currency formats, oh my ..., why did we ever + // introduce them? + OUString aTmp( pChrCls->uppercase( sStrArray[iPos], nArrPos, + sStrArray[iPos].getLength()-nArrPos ) ); + sal_Int32 nCPos = aTmp.indexOf( sOldCurString ); + if ( nCPos >= 0 ) + { + const OUString& rCur = bConvertMode && bConvertSystemToSystem ? + GetCurSymbol() : sOldCurSymbol; + sStrArray[iPos] = sStrArray[iPos].replaceAt( nArrPos + nCPos, + sOldCurString.getLength(), + rCur ); + rString = rString.replaceAt( nStringPos + nCPos, + sOldCurString.getLength(), + rCur ); + } + nStringPos = rString.getLength(); + if ( iPos == i ) + { + nArrPos = sStrArray[iPos].getLength(); + } + else + { + nArrPos = sStrArray[iPos].getLength() + sStrArray[i].getLength(); + } } } + if ( iPos != i ) + { + sStrArray[iPos] += sStrArray[i]; + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; + } + i++; } - break; - case NF_SYMBOLTYPE_CURRENCY : + while ( i < nAnzStrings && nTypeArray[i] == NF_SYMBOLTYPE_STRING ); + + if ( i < nAnzStrings ) { - rString += sStrArray[i]; - RemoveQuotes( sStrArray[i] ); + i--; // enter switch on next symbol again } - break; - case NF_KEY_THAI_T: - if (bThaiT && GetNatNumModifier() == 1) - { // Remove T from format code, will be replaced with a [NatNum1] prefix. - nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; - nAnzResStrings--; + if ( eScannedType == NUMBERFORMAT_CURRENCY && nStringPos < rString.getLength() ) + { + // same as above, since last RemoveQuotes + OUString aTmp( pChrCls->uppercase( sStrArray[iPos], nArrPos, + sStrArray[iPos].getLength()-nArrPos ) ); + sal_Int32 nCPos = aTmp.indexOf( sOldCurString ); + if ( nCPos >= 0 ) + { + const OUString& rCur = bConvertMode && bConvertSystemToSystem ? + GetCurSymbol() : sOldCurSymbol; + sStrArray[iPos] = sStrArray[iPos].replaceAt( nArrPos + nCPos, + sOldCurString.getLength(), + rCur ); + rString = rString.replaceAt( nStringPos + nCPos, + sOldCurString.getLength(), rCur ); } - else - rString += sStrArray[i]; + } break; - case NF_SYMBOLTYPE_EMPTY : - // nothing + case NF_SYMBOLTYPE_CURRENCY : + rString += sStrArray[i]; + RemoveQuotes( sStrArray[i] ); break; - default: + case NF_KEY_THAI_T: + if (bThaiT && GetNatNumModifier() == 1) + { + // Remove T from format code, will be replaced with a [NatNum1] prefix. + nTypeArray[i] = NF_SYMBOLTYPE_EMPTY; + nAnzResStrings--; + } + else + { rString += sStrArray[i]; + } + break; + case NF_SYMBOLTYPE_EMPTY : + // nothing + break; + default: + rString += sStrArray[i]; } i++; } return 0; } -xub_StrLen ImpSvNumberformatScan::RemoveQuotes( String& rStr ) +sal_Int32 ImpSvNumberformatScan::RemoveQuotes( OUString& rStr ) { - if ( rStr.Len() > 1 ) + if ( rStr.getLength() > 1 ) { - sal_Unicode c = rStr.GetChar(0); - xub_StrLen n; - if ( c == '"' && rStr.GetChar( (n = xub_StrLen(rStr.Len()-1)) ) == '"' ) + sal_Unicode c = rStr[0]; + sal_Int32 n = rStr.getLength() - 1; + if ( c == '"' && rStr[n] == '"' ) { - rStr.Erase(n,1); - rStr.Erase(0,1); + rStr = rStr.copy(1,n); return 2; } else if ( c == '\\' ) { - rStr.Erase(0,1); + rStr = rStr.copy(1); return 1; } } return 0; } -xub_StrLen ImpSvNumberformatScan::ScanFormat( String& rString ) +sal_Int32 ImpSvNumberformatScan::ScanFormat( OUString& rString ) { - xub_StrLen res = Symbol_Division(rString); //lexikalische Analyse + sal_Int32 res = Symbol_Division(rString); //lexikalische Analyse if (!res) + { res = ScanType(); // Erkennung des Formattyps + } if (!res) + { res = FinalScan( rString ); // Typabhaengige Endanalyse + } return res; // res = Kontrollposition // res = 0 => Format ok } diff --git a/svl/source/numbers/zforscan.hxx b/svl/source/numbers/zforscan.hxx index 7773c8a2b9b7..0ce11eb56996 100644 --- a/svl/source/numbers/zforscan.hxx +++ b/svl/source/numbers/zforscan.hxx @@ -48,7 +48,7 @@ public: // tauscht Referenzdatum aus void ChangeStandardPrec(sal_uInt16 nPrec); // tauscht Standardprecision aus - xub_StrLen ScanFormat( String& rString ); // Aufruf der Scan-Analyse + sal_Int32 ScanFormat( OUString& rString ); // Aufruf der Scan-Analyse void CopyInfo(ImpSvNumberformatInfo* pInfo, sal_uInt16 nAnz); // Kopiert die FormatInfo @@ -80,7 +80,7 @@ public: const OUString& GetColorString() const { return GetKeywords()[NF_KEY_COLOR]; } const OUString& GetRedString() const { return GetKeywords()[NF_KEY_RED]; } const OUString& GetBooleanString() const { return GetKeywords()[NF_KEY_BOOLEAN]; } - const String& GetErrorString() const { return sErrStr; } + const OUString& GetErrorString() const { return sErrStr; } Date* GetNullDate() const { return pNullDate; } const OUString& GetStandardName() const @@ -97,26 +97,32 @@ public: // definierte Farben // the compatibility currency symbol for old automatic currency formats - const String& GetCurSymbol() const + const OUString& GetCurSymbol() const { if ( bCompatCurNeedInit ) + { InitCompatCur(); + } return sCurSymbol; } // the compatibility currency abbreviation for CCC format code - const String& GetCurAbbrev() const + const OUString& GetCurAbbrev() const { if ( bCompatCurNeedInit ) + { InitCompatCur(); + } return sCurAbbrev; } // the compatibility currency symbol upper case for old automatic currency formats - const String& GetCurString() const + const OUString& GetCurString() const { if ( bCompatCurNeedInit ) + { InitCompatCur(); + } return sCurString; } @@ -159,7 +165,7 @@ private: // ---- privater Teil sal_uInt16 nStandardPrec; // default Precision for Standardformat SvNumberFormatter* pFormatter; // Pointer auf die Formatliste - String sStrArray[NF_MAX_FORMAT_SYMBOLS]; // Array der Symbole + OUString sStrArray[NF_MAX_FORMAT_SYMBOLS]; // Array der Symbole short nTypeArray[NF_MAX_FORMAT_SYMBOLS]; // Array der Infos // externe Infos: sal_uInt16 nAnzResStrings; // Anzahl der Ergebnissymbole @@ -185,10 +191,10 @@ private: // ---- privater Teil bool bDecSep; // Wird beim ersten , gesetzt mutable bool bKeywordsNeedInit; // Locale dependent keywords need to be initialized mutable bool bCompatCurNeedInit; // Locale dependent compatibility currency need to be initialized - String sCurSymbol; // Currency symbol for compatibility format codes - String sCurString; // Currency symbol in upper case - String sCurAbbrev; // Currency abbreviation - String sErrStr; // String fuer Fehlerausgaben + OUString sCurSymbol; // Currency symbol for compatibility format codes + OUString sCurString; // Currency symbol in upper case + OUString sCurAbbrev; // Currency abbreviation + OUString sErrStr; // String fuer Fehlerausgaben bool bConvertMode; // Wird im Convert-Mode gesetzt // Land/Sprache, in die der @@ -204,7 +210,7 @@ private: // ---- privater Teil // currency symbol is converted // too). - xub_StrLen nCurrPos; // Position des Waehrungssymbols + sal_Int32 nCurrPos; // Position des Waehrungssymbols sal_uInt8 nNatNumModifier; // Thai T speciality @@ -215,7 +221,7 @@ private: // ---- privater Teil #ifdef _ZFORSCAN_CXX // ----- private Methoden ----- void SetDependentKeywords(); // Setzt die Sprachabh. Keyw. - void SkipStrings(sal_uInt16& i,xub_StrLen& nPos);// Ueberspringt StringSymbole + void SkipStrings(sal_uInt16& i, sal_Int32& nPos);// Ueberspringt StringSymbole sal_uInt16 PreviousKeyword(sal_uInt16 i); // Gibt Index des vorangeh. // Schluesselworts oder 0 sal_uInt16 NextKeyword(sal_uInt16 i); // Gibt Index des naechsten @@ -230,8 +236,8 @@ private: // ---- privater Teil // mehr bis zum '/' void Reset(); // Reset aller Variablen // vor Analysestart - short GetKeyWord( const String& sSymbol, // determine keyword at nPos - xub_StrLen nPos ); // return 0 <=> not found + short GetKeyWord( const OUString& sSymbol, // determine keyword at nPos + sal_Int32 nPos ); // return 0 <=> not found inline bool IsAmbiguousE( short nKey ) // whether nKey is ambiguous E of NF_KEY_E/NF_KEY_EC { @@ -242,28 +248,28 @@ private: // ---- privater Teil // if 0 at strArray[i] is of S,00 or SS,00 or SS"any"00 in ScanType() or FinalScan() bool Is100SecZero( sal_uInt16 i, bool bHadDecSep ); - short Next_Symbol(const String& rStr, - xub_StrLen& nPos, - String& sSymbol); // Naechstes Symbol - xub_StrLen Symbol_Division(const String& rString);// lexikalische Voranalyse - xub_StrLen ScanType(); // Analyse des Formattyps - xub_StrLen FinalScan( String& rString ); // Endanalyse mit Vorgabe des Typs + short Next_Symbol(const OUString& rStr, + sal_Int32& nPos, + OUString& sSymbol); // Naechstes Symbol + sal_Int32 Symbol_Division(const OUString& rString);// lexikalische Voranalyse + sal_Int32 ScanType(); // Analyse des Formattyps + sal_Int32 FinalScan( OUString& rString ); // Endanalyse mit Vorgabe des Typs // -1:= error, return nPos in FinalScan; 0:= no calendar, 1:= calendar found - int FinalScanGetCalendar( xub_StrLen& nPos, sal_uInt16& i, sal_uInt16& nAnzResStrings ); + int FinalScanGetCalendar( sal_Int32& nPos, sal_uInt16& i, sal_uInt16& nAnzResStrings ); /** Insert symbol into nTypeArray and sStrArray, e.g. grouping separator. If at nPos-1 a symbol type NF_SYMBOLTYPE_EMPTY is present, that is reused instead of shifting all one up and nPos is decremented! */ - bool InsertSymbol( sal_uInt16 & nPos, svt::NfSymbolType eType, const String& rStr ); + bool InsertSymbol( sal_uInt16 & nPos, svt::NfSymbolType eType, const OUString& rStr ); - static inline bool StringEqualsChar( const String& rStr, sal_Unicode ch ) - { return rStr.GetChar(0) == ch && rStr.Len() == 1; } + static inline bool StringEqualsChar( const OUString& rStr, sal_Unicode ch ) + { return rStr[0] == ch && rStr.getLength() == 1; } // Yes, for efficiency get the character first and then compare length // because in most places where this is used the string is one char. // remove "..." and \... quotes from rStr, return how many chars removed - static xub_StrLen RemoveQuotes( String& rStr ); + static sal_Int32 RemoveQuotes( OUString& rStr ); #endif //_ZFORSCAN_CXX }; diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx index a770d207b15b..2d06b91b9c81 100644 --- a/xmloff/source/style/xmlnumfe.cxx +++ b/xmloff/source/style/xmlnumfe.cxx @@ -805,16 +805,16 @@ sal_Bool SvXMLNumFmtExport::WriteTextWithCurrency_Impl( const OUString& rString, LanguageType nLang = LanguageTag( rLocale ).getLanguageType( false); pFormatter->ChangeIntl( nLang ); - String sCurString, sDummy; + OUString sCurString, sDummy; pFormatter->GetCompatibilityCurrency( sCurString, sDummy ); pCharClass->setLocale( rLocale ); OUString sUpperStr = pCharClass->uppercase(rString); - sal_Int32 nPos = lcl_FindSymbol( sUpperStr, OUString(sCurString) ); + sal_Int32 nPos = lcl_FindSymbol( sUpperStr, sCurString ); if ( nPos >= 0 ) { sal_Int32 nLength = rString.getLength(); - sal_Int32 nCurLen = sCurString.Len(); + sal_Int32 nCurLen = sCurString.getLength(); sal_Int32 nCont = nPos + nCurLen; // text before currency symbol diff --git a/xmloff/source/style/xmlnumfi.cxx b/xmloff/source/style/xmlnumfi.cxx index f142ce936e5b..de3d238d2013 100644 --- a/xmloff/source/style/xmlnumfi.cxx +++ b/xmloff/source/style/xmlnumfi.cxx @@ -1875,7 +1875,7 @@ void SvXMLNumFormatContext::AddCurrency( const rtl::OUString& rContent, Language if ( pFormatter ) { pFormatter->ChangeIntl( nFormatLang ); - String sCurString, sDummy; + OUString sCurString, sDummy; pFormatter->GetCompatibilityCurrency( sCurString, sDummy ); aSymbol = sCurString; |