diff options
author | Eike Rathke <erack@redhat.com> | 2018-08-16 15:50:02 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-08-17 17:17:52 +0200 |
commit | 04e12e17cd7a9b7e740299560e8e3e0ba2822ca3 (patch) | |
tree | 181053326518f09be2b26d5e4eb11c182defde9b /svl | |
parent | 2b52e332b7d6cd18cb024295c1218517cf6d27d9 (diff) |
Resolves: tdf#119013 do not over-aggressively reorder date particles
In particular not when reading documents as we don't know what the
original (default/system) locale was when the date format was
created and stored and whether the format's date order actually
matched the locale's ordering.
Regression from
commit 51478cefaa4e265b42e3f67eda0a64767ff3efba
CommitDate: Tue Apr 18 17:01:27 2017 +0200
Resolves: tdf#107012 follow date order of the target locale
Change-Id: I9d3bdbd512d95ed81ff6459e368a2d7497ec8a2d
Reviewed-on: https://gerrit.libreoffice.org/59182
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
(cherry picked from commit 5b8007afdb97d416ee7c22bf9226e927d61e9bd3)
Reviewed-on: https://gerrit.libreoffice.org/59215
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/qa/unit/svl.cxx | 2 | ||||
-rw-r--r-- | svl/source/numbers/numfmuno.cxx | 4 | ||||
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 12 | ||||
-rw-r--r-- | svl/source/numbers/zformat.cxx | 2 | ||||
-rw-r--r-- | svl/source/numbers/zforscan.cxx | 4 | ||||
-rw-r--r-- | svl/source/numbers/zforscan.hxx | 6 |
6 files changed, 16 insertions, 14 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 205af97f1bc3..9d453b14ef5f 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -1637,7 +1637,7 @@ void Test::testColorNamesConversion() for (size_t i = NF_KEY_BLACK; i <= NF_KEY_WHITE; ++i) { aFormatCode = "[" + aGermanKeywords[i] + "]0"; - aFormatter.PutandConvertEntry( aFormatCode, nCheckPos, nType, nKey, LANGUAGE_GERMAN, LANGUAGE_ENGLISH_US); + aFormatter.PutandConvertEntry( aFormatCode, nCheckPos, nType, nKey, LANGUAGE_GERMAN, LANGUAGE_ENGLISH_US, false); CPPUNIT_ASSERT_EQUAL_MESSAGE("CheckPos should be 0.", sal_Int32(0), nCheckPos); CPPUNIT_ASSERT_EQUAL_MESSAGE("Type should be NUMBER.", SvNumFormatType::NUMBER, nType); CPPUNIT_ASSERT_EQUAL( OUString("[" + rEnglishKeywords[i] + "]0"), aFormatCode); diff --git a/svl/source/numbers/numfmuno.cxx b/svl/source/numbers/numfmuno.cxx index 3d465ed17183..52ca8e18d696 100644 --- a/svl/source/numbers/numfmuno.cxx +++ b/svl/source/numbers/numfmuno.cxx @@ -458,7 +458,9 @@ sal_Int32 SAL_CALL SvNumberFormatsObj::addNewConverted( const OUString& aFormat, sal_uInt32 nKey = 0; sal_Int32 nCheckPos = 0; SvNumFormatType nType = SvNumFormatType::ALL; - bool bOk = pFormatter->PutandConvertEntry( aFormStr, nCheckPos, nType, nKey, eLang, eNewLang ); + // This is used also when reading OOXML documents, there's no indicator + // whether to convert date particle order as well, so don't. See tdf#119013 + bool bOk = pFormatter->PutandConvertEntry( aFormStr, nCheckPos, nType, nKey, eLang, eNewLang, false); if (bOk || nKey > 0) nRet = nKey; else if (nCheckPos) diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 266adfd48048..f3af3ac13418 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -462,7 +462,7 @@ void SvNumberFormatter::ReplaceSystemCL( LanguageType eOldLanguage ) // convert additional and user defined from old system to new system SvNumberformat* pStdFormat = GetFormatEntry( nCLOffset + ZF_STANDARD ); sal_uInt32 nLastKey = nMaxBuiltin; - pFormatScanner->SetConvertMode( eOldLanguage, LANGUAGE_SYSTEM, true ); + pFormatScanner->SetConvertMode( eOldLanguage, LANGUAGE_SYSTEM, true , true); while ( !aOldTable.empty() ) { nKey = aOldTable.begin()->first; @@ -628,7 +628,7 @@ bool SvNumberFormatter::PutandConvertEntry(OUString& rString, sal_uInt32& nKey, LanguageType eLnge, LanguageType eNewLnge, - bool bForExcelExport ) + bool bConvertDateOrder ) { ::osl::MutexGuard aGuard( GetInstanceMutex() ); bool bRes; @@ -636,7 +636,7 @@ bool SvNumberFormatter::PutandConvertEntry(OUString& rString, { eNewLnge = IniLnge; } - pFormatScanner->SetConvertMode(eLnge, eNewLnge, false, bForExcelExport); + pFormatScanner->SetConvertMode(eLnge, eNewLnge, false, bConvertDateOrder); bRes = PutEntry(rString, nCheckPos, nType, nKey, eLnge); pFormatScanner->SetConvertMode(false); return bRes; @@ -655,7 +655,7 @@ bool SvNumberFormatter::PutandConvertEntrySystem(OUString& rString, { eNewLnge = IniLnge; } - pFormatScanner->SetConvertMode(eLnge, eNewLnge, true); + pFormatScanner->SetConvertMode(eLnge, eNewLnge, true, true); bRes = PutEntry(rString, nCheckPos, nType, nKey, eLnge); pFormatScanner->SetConvertMode(false); return bRes; @@ -1718,7 +1718,7 @@ bool SvNumberFormatter::GetPreviewStringGuess( const OUString& sFormatString, // Try English -> other or convert english to other LanguageType eFormatLang = LANGUAGE_ENGLISH_US; - pFormatScanner->SetConvertMode( LANGUAGE_ENGLISH_US, eLnge ); + pFormatScanner->SetConvertMode( LANGUAGE_ENGLISH_US, eLnge, false, false); sTmpString = sFormatString; pEntry.reset(new SvNumberformat( sTmpString, pFormatScanner.get(), pStringScanner.get(), nCheckPos, eFormatLang )); @@ -1743,7 +1743,7 @@ bool SvNumberFormatter::GetPreviewStringGuess( const OUString& sFormatString, sal_Int32 nCheckPos2 = -1; // try other --> english eFormatLang = eLnge; - pFormatScanner->SetConvertMode( eLnge, LANGUAGE_ENGLISH_US ); + pFormatScanner->SetConvertMode( eLnge, LANGUAGE_ENGLISH_US, false, false); sTmpString = sFormatString; std::unique_ptr<SvNumberformat> pEntry2(new SvNumberformat( sTmpString, pFormatScanner.get(), pStringScanner.get(), nCheckPos2, eFormatLang )); diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 66f54867cf5c..afbab5087e54 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -1883,7 +1883,7 @@ void SvNumberformat::ConvertLanguage( SvNumberFormatter& rConverter, SvNumFormatType nType = eType; OUString aFormatString( sFormatstring ); rConverter.PutandConvertEntry( aFormatString, nCheckPos, nType, - nKey, eConvertFrom, eConvertTo ); + nKey, eConvertFrom, eConvertTo, false); const SvNumberformat* pFormat = rConverter.GetEntry( nKey ); DBG_ASSERT( pFormat, "SvNumberformat::ConvertLanguage: Conversion without format" ); if ( pFormat ) diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx index ea9e24236b4c..e6285cf3bb3a 100644 --- a/svl/source/numbers/zforscan.cxx +++ b/svl/source/numbers/zforscan.cxx @@ -121,7 +121,7 @@ ImpSvNumberformatScan::ImpSvNumberformatScan( SvNumberFormatter* pFormatterP ) pFormatter = pFormatterP; xNFC = css::i18n::NumberFormatMapper::create( pFormatter->GetComponentContext() ); bConvertMode = false; - mbConvertForExcelExport = false; + mbConvertDateOrder = false; bConvertSystemToSystem = false; bKeywordsNeedInit = true; // locale dependent and not locale dependent keywords bCompatCurNeedInit = true; // locale dependent compatibility currency strings @@ -1783,7 +1783,7 @@ sal_Int32 ImpSvNumberformatScan::FinalScan( OUString& rString ) // Adapt date order to target locale, but Excel does not handle date // particle re-ordering for the target locale when loading documents, // though it does exchange separators, tdf#113889 - bNewDateOrder = (!mbConvertForExcelExport && eOldDateOrder != pLoc->getDateOrder()); + bNewDateOrder = (mbConvertDateOrder && eOldDateOrder != pLoc->getDateOrder()); } const CharClass* pChrCls = pFormatter->GetCharClass(); diff --git a/svl/source/numbers/zforscan.hxx b/svl/source/numbers/zforscan.hxx index b7ee25d2ce52..0080d1dfeef3 100644 --- a/svl/source/numbers/zforscan.hxx +++ b/svl/source/numbers/zforscan.hxx @@ -148,13 +148,13 @@ public: void ReplaceBooleanEquivalent( OUString& rString ); void SetConvertMode(LanguageType eTmpLge, LanguageType eNewLge, - bool bSystemToSystem = false, bool bForExcelExport = false) + bool bSystemToSystem, bool bConvertDateOrder) { bConvertMode = true; eNewLnge = eNewLge; eTmpLnge = eTmpLge; bConvertSystemToSystem = bSystemToSystem; - mbConvertForExcelExport = bForExcelExport; + mbConvertDateOrder = bConvertDateOrder; } // Only changes the bool variable, in order to temporarily pause the convert mode void SetConvertMode(bool bMode) { bConvertMode = bMode; } @@ -213,7 +213,7 @@ private: // Private section static const OUString sErrStr; // String for error output bool bConvertMode; // Set in the convert mode - bool mbConvertForExcelExport; // Set in the convert mode whether to convert for Excel export + bool mbConvertDateOrder; // Set in the convert mode whether to convert date particles order LanguageType eNewLnge; // Language/country which the scanned string is converted to (for Excel filter) LanguageType eTmpLnge; // Language/country which the scanned string is converted from (for Excel filter) |