Resolves: tdf#113889 no date particle reordering when exporting to Excel
Change-Id: I45667a67c6c69106d86755ed41438f23e019dfea
diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx
index 9c809bf..3e59064 100644
--- a/include/svl/zforlist.hxx
+++ b/include/svl/zforlist.hxx
@@ -402,7 +402,8 @@ public:
language/country eNewLnge */
bool PutandConvertEntry( OUString& rString, sal_Int32& nCheckPos,
short& nType, sal_uInt32& nKey,
LanguageType eLnge, LanguageType eNewLnge );
LanguageType eLnge, LanguageType eNewLnge,
bool bForExcelExport = false );
/** 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/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 97f846e..dcca285 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -623,14 +623,15 @@ bool SvNumberFormatter::PutandConvertEntry(OUString& rString,
short& nType,
sal_uInt32& nKey,
LanguageType eLnge,
LanguageType eNewLnge)
LanguageType eNewLnge,
bool bForExcelExport )
{
bool bRes;
if (eNewLnge == LANGUAGE_DONTKNOW)
{
eNewLnge = IniLnge;
}
pFormatScanner->SetConvertMode(eLnge, eNewLnge);
pFormatScanner->SetConvertMode(eLnge, eNewLnge, false, bForExcelExport);
bRes = PutEntry(rString, nCheckPos, nType, nKey, eLnge);
pFormatScanner->SetConvertMode(false);
return bRes;
@@ -808,7 +809,7 @@ OUString SvNumberFormatter::GetFormatStringForExcel( sal_uInt32 nKey, const NfKe
short nType = css::util::NumberFormat::DEFINED;
sal_uInt32 nTempKey;
OUString aTemp( pEntry->GetFormatstring());
rTempFormatter.PutandConvertEntry( aTemp, nCheckPos, nType, nTempKey, nLang, LANGUAGE_ENGLISH_US);
rTempFormatter.PutandConvertEntry( aTemp, nCheckPos, nType, nTempKey, nLang, LANGUAGE_ENGLISH_US, true);
SAL_WARN_IF( nCheckPos != 0, "svl.numbers",
"SvNumberFormatter::GetFormatStringForExcel - format code not convertible");
if (nTempKey != NUMBERFORMAT_ENTRY_NOT_FOUND)
diff --git a/svl/source/numbers/zforscan.cxx b/svl/source/numbers/zforscan.cxx
index f845b5f..a48063f 100644
--- a/svl/source/numbers/zforscan.cxx
+++ b/svl/source/numbers/zforscan.cxx
@@ -115,6 +115,7 @@ ImpSvNumberformatScan::ImpSvNumberformatScan( SvNumberFormatter* pFormatterP )
pFormatter = pFormatterP;
xNFC = css::i18n::NumberFormatMapper::create( pFormatter->GetComponentContext() );
bConvertMode = false;
mbConvertForExcelExport = false;
bConvertSystemToSystem = false;
sKeyword[NF_KEY_E] = sEnglishKeyword[NF_KEY_E]; // Exponent
@@ -1725,7 +1726,10 @@ sal_Int32 ImpSvNumberformatScan::FinalScan( OUString& rString )
pLoc = pFormatter->GetLocaleData();
//! init new keywords
InitKeywords();
bNewDateOrder = (eOldDateOrder != pLoc->getDateOrder());
// 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());
}
const CharClass* pChrCls = pFormatter->GetCharClass();
diff --git a/svl/source/numbers/zforscan.hxx b/svl/source/numbers/zforscan.hxx
index fe08984..54c5932 100644
--- a/svl/source/numbers/zforscan.hxx
+++ b/svl/source/numbers/zforscan.hxx
@@ -136,12 +136,13 @@ public:
}
void SetConvertMode(LanguageType eTmpLge, LanguageType eNewLge,
bool bSystemToSystem = false )
bool bSystemToSystem = false, bool bForExcelExport = false)
{
bConvertMode = true;
eNewLnge = eNewLge;
eTmpLnge = eTmpLge;
bConvertSystemToSystem = bSystemToSystem;
mbConvertForExcelExport = bForExcelExport;
}
// Only changes the bool variable, in order to temporarily pause the convert mode
void SetConvertMode(bool bMode) { bConvertMode = bMode; }
@@ -197,6 +198,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
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)