summaryrefslogtreecommitdiff
path: root/svl
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-27 10:59:52 +0200
commit5c7f4b83c207b909312ed5a28282015fdcdd12da (patch)
treeffdd681af812cac33c0d959330a9663d5f47bcdb /svl
parenta8df5c815c8b002b7083b8777e3dd8beac573bf3 (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>
Diffstat (limited to 'svl')
-rw-r--r--svl/qa/unit/svl.cxx15
1 files changed, 14 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);
}