summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2018-08-16 15:50:02 +0200
committerEike Rathke <erack@redhat.com>2018-08-16 18:54:31 +0200
commit5b8007afdb97d416ee7c22bf9226e927d61e9bd3 (patch)
treed7299707f0a418bfa62fd0104adbe19ec0ce70d0
parent6e03d7ee5734c94d245aea5900c0924fbef2a246 (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
-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 04f597846b7c..107124d98224 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 2b229082f665..156a398a7bcf 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -720,7 +720,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 );
}
@@ -737,7 +737,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;
@@ -747,7 +747,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 );
}
}
@@ -783,7 +783,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 3365761cd1d6..09100d98f021 100644
--- a/editeng/source/items/flditem.cxx
+++ b/editeng/source/items/flditem.cxx
@@ -659,7 +659,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 ef3b3f5668c9..c058977842f0 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -702,7 +702,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 2fef2685f18e..9128a93f0195 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 40095fdbb7fb..2b70371f35e1 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 ec65d2962ccf..68c4f15444a8 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -1656,7 +1656,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 38b8f243f22d..7667e200fb31 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 debfc1e70370..8ececca57bba 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
@@ -1784,7 +1784,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 b18efb264b27..8a718876eb7b 100644
--- a/svtools/source/control/fmtfield.cxx
+++ b/svtools/source/control/fmtfield.cxx
@@ -575,7 +575,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 01e43cdc992c..2c51bbab11c4 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -502,7 +502,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;
@@ -610,7 +610,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
@@ -660,7 +660,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 951601fb2196..f0ab52c3b900 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -477,7 +477,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 5a26312d6a49..9598ee88b6c0 100644
--- a/xmloff/source/style/xmlnumfe.cxx
+++ b/xmloff/source/style/xmlnumfe.cxx
@@ -1975,7 +1975,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 )