summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-05-19 13:23:33 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2022-05-25 21:10:12 +0200
commit7dc49d024c23ef2b4a41484427a4dd18e6690756 (patch)
treeaf8d1897523eb6bd0d31efed69881c0bb045704c
parentRevert "svl: SvNumberformat::GetMappedFormatstring() vs. LANGUAGE_DONTKNOW" (diff)
downloadcore-feature/cib_contract3753.tar.gz
core-feature/cib_contract3753.zip
sw: language fallback in MSWordExportBase::GetNumberFormat() feature/cib_contract3753
There is this number format: <number:date-style style:name="N36" number:automatic-order="true"> <number:day number:style="long"/> <number:text>.</number:text> <number:month number:style="long"/> <number:text>.</number:text> <number:year number:style="long"/> </number:date-style> in a paragraph which has fo:language="zxx", so the field has LANGUAGE_NONE. MSWordExportBase::GetNumberFormat() exports as: DATE \@"dd/MM/yyyy" But should be: DATE \@"dd.MM.yyyy" Follow Eike's suggestion to use the number format's language in case the field doesn't have one. Change-Id: I596bea5daa75c717931b3c5d5506103b87b8ee08
-rw-r--r--svl/qa/unit/svl.cxx15
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx5
2 files changed, 19 insertions, 1 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index d30a7b6279ec..4304875b8088 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -90,7 +90,7 @@ public:
CPPUNIT_TEST(testExcelExportFormats);
CPPUNIT_TEST_SUITE_END();
-private:
+protected:
uno::Reference< uno::XComponentContext > m_xContext;
void checkPreviewString(SvNumberFormatter& aFormatter,
const OUString& sCode,
@@ -1728,6 +1728,19 @@ void Test::testExcelExportFormats()
CPPUNIT_ASSERT_EQUAL( OUString("[$R-1C09]\\ #,##0.0;[$R-1C09]\\-#,##0.0"), aCode);
}
+CPPUNIT_TEST_FIXTURE(Test, testLanguageNone)
+{
+ SvNumberFormatter aFormatter(m_xContext, LANGUAGE_ENGLISH_US);
+ NfKeywordTable keywords;
+ aFormatter.FillKeywordTableForExcel(keywords);
+ OUString code("TT.MM.JJJJ");
+ sal_uInt32 nKey = aFormatter.GetEntryKey(code, LANGUAGE_GERMAN);
+ CPPUNIT_ASSERT(nKey != NUMBERFORMAT_ENTRY_NOT_FOUND);
+ SvNumberformat const*const pFormat = aFormatter.GetEntry(nKey);
+ LocaleDataWrapper ldw(m_xContext, LanguageTag(pFormat->GetLanguage()));
+ CPPUNIT_ASSERT_EQUAL(OUString("dd.mm.yyyy"), pFormat->GetMappedFormatstring(keywords, ldw));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index b2c3b35d7ae1..1327f78d645a 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -2581,6 +2581,11 @@ bool MSWordExportBase::GetNumberFormat(const SwField& rField, OUString& rStr)
if( pNumFormat )
{
LanguageType nLng = rField.GetLanguage();
+ SAL_WARN_IF(nLng == LANGUAGE_DONTKNOW, "sw.ww8", "unexpected LANGUAGE_DONTKNOW");
+ if (nLng == LANGUAGE_NONE || nLng == LANGUAGE_DONTKNOW)
+ {
+ nLng = pNumFormat->GetLanguage();
+ }
LocaleDataWrapper aLocDat(pNFormatr->GetComponentContext(),
LanguageTag(nLng));