summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-08-16 15:50:02 +0200
committerCaolán McNamara <caolanm@redhat.com>2018-08-17 17:17:52 +0200
commit04e12e17cd7a9b7e740299560e8e3e0ba2822ca3 (patch)
tree181053326518f09be2b26d5e4eb11c182defde9b
parent2b52e332b7d6cd18cb024295c1218517cf6d27d9 (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>
-rw-r--r--basic/source/runtime/runtime.cxx4
-rw-r--r--basic/source/sbx/sbxdate.cxx4
-rw-r--r--basic/source/sbx/sbxscan.cxx8
-rw-r--r--editeng/source/items/flditem.cxx2
-rw-r--r--include/svl/zforlist.hxx2
-rw-r--r--sc/source/filter/excel/xistyle.cxx2
-rw-r--r--sc/source/ui/docshell/impex.cxx2
-rw-r--r--sfx2/source/bastyp/sfxhtml.cxx2
-rw-r--r--svl/qa/unit/svl.cxx2
-rw-r--r--svl/source/numbers/numfmuno.cxx4
-rw-r--r--svl/source/numbers/zforlist.cxx12
-rw-r--r--svl/source/numbers/zformat.cxx2
-rw-r--r--svl/source/numbers/zforscan.cxx4
-rw-r--r--svl/source/numbers/zforscan.hxx6
-rw-r--r--svtools/source/control/fmtfield.cxx2
-rw-r--r--sw/source/core/fields/fldbas.cxx6
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx2
-rw-r--r--xmloff/source/style/xmlnumfe.cxx2
18 files changed, 35 insertions, 33 deletions
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 9f242dab4ba8..42e97c704a26 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -438,12 +438,12 @@ std::shared_ptr<SvNumberFormatter> SbiInstance::PrepareNumberFormatter( sal_uInt
}
OUString aStr( aDateStr ); // PutandConvertEntry() modifies string!
pNumberFormatter->PutandConvertEntry( aStr, nCheckPos, nType,
- rnStdDateIdx, LANGUAGE_ENGLISH_US, eLangType );
+ rnStdDateIdx, LANGUAGE_ENGLISH_US, eLangType, true);
nCheckPos = 0;
aDateStr += " HH:MM:SS";
aStr = aDateStr;
pNumberFormatter->PutandConvertEntry( aStr, nCheckPos, nType,
- rnStdDateTimeIdx, LANGUAGE_ENGLISH_US, eLangType );
+ rnStdDateTimeIdx, LANGUAGE_ENGLISH_US, eLangType, true);
return pNumberFormatter;
}
diff --git a/basic/source/sbx/sbxdate.cxx b/basic/source/sbx/sbxdate.cxx
index abf30c202e7d..1880ba40df78 100644
--- a/basic/source/sbx/sbxdate.cxx
+++ b/basic/source/sbx/sbxdate.cxx
@@ -142,7 +142,7 @@ double ImpGetDate( const SbxValues* p )
OUString aStr = aDateStr + " HH:MM:SS";
pFormatter->PutandConvertEntry( aStr, nCheckPos, nType,
- nIndex, LANGUAGE_ENGLISH_US, eLangType );
+ nIndex, LANGUAGE_ENGLISH_US, eLangType, true);
bool bSuccess = pFormatter->IsNumberFormat( *p->pOUString, nIndex, nRes );
if ( bSuccess )
{
@@ -337,7 +337,7 @@ start:
nType,
nIndex,
LANGUAGE_ENGLISH_US,
- eLangType );
+ eLangType, true);
pFormatter->GetOutputString( n, nIndex, *p->pOUString, &pColor );
#endif
break;
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index 7f9b4931ea48..49f632ff1a57 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -719,7 +719,7 @@ void SbxValue::Format( OUString& rRes, const OUString* pFmt ) const
else
{
aFmtStr = OUString::createFromAscii(pInfo->mpOOoFormat);
- pFormatter->PutandConvertEntry( aFmtStr, nCheckPos, nType, nIndex, LANGUAGE_ENGLISH, eLangType );
+ pFormatter->PutandConvertEntry( aFmtStr, nCheckPos, nType, nIndex, LANGUAGE_ENGLISH, eLangType, true);
}
pFormatter->GetOutputString( nNumber, nIndex, rRes, &pCol );
}
@@ -736,7 +736,7 @@ void SbxValue::Format( OUString& rRes, const OUString* pFmt ) const
if( floor( nNumber ) != nNumber )
{
aFmtStr = "H:MM:SS AM/PM";
- pFormatter->PutandConvertEntry( aFmtStr, nCheckPos, nType, nIndex, LANGUAGE_ENGLISH, eLangType );
+ pFormatter->PutandConvertEntry( aFmtStr, nCheckPos, nType, nIndex, LANGUAGE_ENGLISH, eLangType, true);
OUString aTime;
pFormatter->GetOutputString( nNumber, nIndex, aTime, &pCol );
rRes += " " + aTime;
@@ -746,7 +746,7 @@ void SbxValue::Format( OUString& rRes, const OUString* pFmt ) const
{
// long time only
aFmtStr = "H:MM:SS AM/PM";
- pFormatter->PutandConvertEntry( aFmtStr, nCheckPos, nType, nIndex, LANGUAGE_ENGLISH, eLangType );
+ pFormatter->PutandConvertEntry( aFmtStr, nCheckPos, nType, nIndex, LANGUAGE_ENGLISH, eLangType, true);
pFormatter->GetOutputString( nNumber, nIndex, rRes, &pCol );
}
}
@@ -782,7 +782,7 @@ void SbxValue::Format( OUString& rRes, const OUString* pFmt ) const
}
else
{
- pFormatter->PutandConvertEntry( aFmtStr, nCheckPos, nType, nIndex, LANGUAGE_ENGLISH, eLangType );
+ pFormatter->PutandConvertEntry( aFmtStr, nCheckPos, nType, nIndex, LANGUAGE_ENGLISH, eLangType, true);
pFormatter->GetOutputString( nNumber, nIndex, rRes, &pCol );
}
diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx
index d90fbc522688..1add8f85be8f 100644
--- a/editeng/source/items/flditem.cxx
+++ b/editeng/source/items/flditem.cxx
@@ -677,7 +677,7 @@ OUString SvxExtTimeField::GetFormatted( tools::Time const & aTime, SvxTimeFormat
sal_Int32 nCheckPos;
SvNumFormatType nType;
rFormatter.PutandConvertEntry( aFormatCode, nCheckPos, nType,
- nFormatKey, LANGUAGE_ENGLISH_US, eLang );
+ nFormatKey, LANGUAGE_ENGLISH_US, eLang, true);
DBG_ASSERT( nCheckPos == 0, "SvxTimeFormat::HH12_MM_SS_00: could not insert format code" );
if ( nCheckPos )
{
diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx
index 14aaf6a40940..8b1574cf8a08 100644
--- a/include/svl/zforlist.hxx
+++ b/include/svl/zforlist.hxx
@@ -461,7 +461,7 @@ public:
bool PutandConvertEntry( OUString& rString, sal_Int32& nCheckPos,
SvNumFormatType& nType, sal_uInt32& nKey,
LanguageType eLnge, LanguageType eNewLnge,
- bool bForExcelExport = false );
+ bool bConvertDateOrder );
/** Same as <method>PutandConvertEntry</method> but the format code string
is considered to be of the System language/country eLnge and is
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index 07216a81db1f..16d53e111dae 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -700,7 +700,7 @@ void XclImpNumFmtBuffer::CreateScFormats()
{
OUString aFormat( rNumFmt.maFormat );
rFormatter.PutandConvertEntry( aFormat, nCheckPos,
- nType, nKey, LANGUAGE_ENGLISH_US, rNumFmt.meLanguage );
+ nType, nKey, LANGUAGE_ENGLISH_US, rNumFmt.meLanguage, false);
}
else
nKey = rFormatter.GetFormatIndex( rNumFmt.meOffset, rNumFmt.meLanguage );
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 854bc92b9635..9af724054c25 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -2035,7 +2035,7 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
SvNumFormatType nType;
sal_uInt32 nKey;
pDoc->GetFormatTable()->PutandConvertEntry( aCode, nCheckPos, nType, nKey,
- LANGUAGE_ENGLISH_US, ScGlobal::eLnge );
+ LANGUAGE_ENGLISH_US, ScGlobal::eLnge, false);
if ( nCheckPos )
nKey = 0;
aFormats.push_back( nKey );
diff --git a/sfx2/source/bastyp/sfxhtml.cxx b/sfx2/source/bastyp/sfxhtml.cxx
index e64dd7ed714e..1e05cf434347 100644
--- a/sfx2/source/bastyp/sfxhtml.cxx
+++ b/sfx2/source/bastyp/sfxhtml.cxx
@@ -337,7 +337,7 @@ double SfxHTMLParser::GetTableDataOptionsValNum( sal_uInt32& nNumForm,
rFormatter.PutEntry( aFormat, nCheckPos, nType, nNumForm, eNumLang );
else
rFormatter.PutandConvertEntry( aFormat, nCheckPos, nType, nNumForm,
- eParseLang, eNumLang );
+ eParseLang, eNumLang, true);
}
else
{
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)
diff --git a/svtools/source/control/fmtfield.cxx b/svtools/source/control/fmtfield.cxx
index 4d81dff3ea36..d3b8e591749d 100644
--- a/svtools/source/control/fmtfield.cxx
+++ b/svtools/source/control/fmtfield.cxx
@@ -574,7 +574,7 @@ void FormattedField::SetFormatter(SvNumberFormatter* pFormatter, bool bResetForm
// convert the old format string into the new language
sal_Int32 nCheckPos;
SvNumFormatType nType;
- pFormatter->PutandConvertEntry(sOldFormat, nCheckPos, nType, nDestKey, aOldLang, aNewLang);
+ pFormatter->PutandConvertEntry(sOldFormat, nCheckPos, nType, nDestKey, aOldLang, aNewLang, true);
m_nFormatKey = nDestKey;
}
m_pFormatter = pFormatter;
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index 3087bc382eb8..cd80d853632d 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -495,7 +495,7 @@ OUString SwValueFieldType::ExpandValue( const double& rVal,
OUString sFormat(pEntry->GetFormatstring());
pFormatter->PutandConvertEntry(sFormat, nDummy, nType, nFormat,
- pEntry->GetLanguage(), nFormatLng );
+ pEntry->GetLanguage(), nFormatLng, false);
}
else
nFormat = nNewFormat;
@@ -603,7 +603,7 @@ sal_uInt32 SwValueField::GetSystemFormat(SvNumberFormatter* pFormatter, sal_uInt
sal_uInt32 nTempFormat = nFormat;
pFormatter->PutandConvertEntry(sFormat, nDummy, nType,
- nTempFormat, pEntry->GetLanguage(), nLng);
+ nTempFormat, pEntry->GetLanguage(), nLng, true);
nFormat = nTempFormat;
}
else
@@ -645,7 +645,7 @@ void SwValueField::SetLanguage( LanguageType nLng )
pFormatter->PutandConvertEntry( sFormat, nDummy, nType,
nNewFormat,
pEntry->GetLanguage(),
- nFormatLng );
+ nFormatLng, false);
}
SetFormat( nNewFormat );
}
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index efd87ee64a05..4d1f84a9ad76 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -478,7 +478,7 @@ SvNumFormatType SwWW8ImplReader::GetTimeDatePara(OUString const & rStr, sal_uInt
OUString sTemp(sParams);
pFormatter->PutandConvertEntry(sTemp, nCheckPos, nType, rFormat,
- LANGUAGE_ENGLISH_US, rLang);
+ LANGUAGE_ENGLISH_US, rLang, false);
sParams = sTemp;
return bHasTime ? SvNumFormatType::DATETIME : SvNumFormatType::DATE;
diff --git a/xmloff/source/style/xmlnumfe.cxx b/xmloff/source/style/xmlnumfe.cxx
index 7001328ab196..ebfd65d3cb54 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -1973,7 +1973,7 @@ sal_uInt32 SvXMLNumFmtExport::ForceSystemLanguage( sal_uInt32 nKey )
pFormatter->PutandConvertEntry(
aFormatString,
nErrorPos, nType, nNewKey,
- pFormat->GetLanguage(), LANGUAGE_SYSTEM );
+ pFormat->GetLanguage(), LANGUAGE_SYSTEM, true);
// success? Then use new key.
if( nErrorPos == 0 )