diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2022-05-19 13:23:33 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-05-27 10:59:52 +0200 |
commit | 5c7f4b83c207b909312ed5a28282015fdcdd12da (patch) | |
tree | ffdd681af812cac33c0d959330a9663d5f47bcdb | |
parent | a8df5c815c8b002b7083b8777e3dd8beac573bf3 (diff) |
sw: language fallback in MSWordExportBase::GetNumberFormat()
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
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134638
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | svl/qa/unit/svl.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 5 |
2 files changed, 19 insertions, 1 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 523e998c60c1..f125305783c5 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -93,7 +93,7 @@ public: CPPUNIT_TEST(testExcelExportFormats); CPPUNIT_TEST_SUITE_END(); -private: +protected: uno::Reference< uno::XComponentContext > m_xContext; void checkPreviewString(SvNumberFormatter& aFormatter, const OUString& sCode, @@ -1920,6 +1920,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 b5f354e46d84..78bbb5219e57 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2601,6 +2601,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)); |