svl/qa/unit/svl.cxx | 5 ++--- svl/source/numbers/zformat.cxx | 9 +-------- sw/source/filter/ww8/ww8atr.cxx | 5 +++++ 3 files changed, 8 insertions(+), 11 deletions(-)
New commits: commit 7dc49d024c23ef2b4a41484427a4dd18e6690756 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu May 19 13:23:33 2022 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed May 25 21:10:12 2022 +0200 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 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)); commit 7483d54d45b9931064dc20adc6fdb28597667859 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed May 25 21:09:43 2022 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed May 25 21:09:43 2022 +0200 Revert "svl: SvNumberformat::GetMappedFormatstring() vs. LANGUAGE_DONTKNOW" This reverts commit 712b7e578292e521c64e6de117dbf7d11e38ba7a. diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx index 2e4f21099d0d..d30a7b6279ec 100644 --- a/svl/qa/unit/svl.cxx +++ b/svl/qa/unit/svl.cxx @@ -34,7 +34,6 @@ #include <svl/sharedstring.hxx> #include <tools/color.hxx> #include <unotools/syslocale.hxx> -#include <unotest/bootstrapfixturebase.hxx> // for CPPUNIT_TEST_FIXTURE #include <memory> #include <unicode/timezone.h> @@ -91,7 +90,7 @@ public: CPPUNIT_TEST(testExcelExportFormats); CPPUNIT_TEST_SUITE_END(); -protected: +private: uno::Reference< uno::XComponentContext > m_xContext; void checkPreviewString(SvNumberFormatter& aFormatter, const OUString& sCode, @@ -1729,19 +1728,6 @@ void Test::testExcelExportFormats() CPPUNIT_ASSERT_EQUAL( OUString("[$R-1C09]\\ #,##0.0;[$R-1C09]\\-#,##0.0"), aCode); } -CPPUNIT_TEST_FIXTURE(Test, testLanguageDontknow) -{ - 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(LANGUAGE_DONTKNOW)); - CPPUNIT_ASSERT_EQUAL(OUString("dd.mm.yyyy"), pFormat->GetMappedFormatstring(keywords, ldw)); -} - CPPUNIT_TEST_SUITE_REGISTRATION(Test); } diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index acbea945cd88..23c0919aecf2 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -5291,14 +5291,7 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords, aStr.append( "-" ); break; case NF_SYMBOLTYPE_DATESEP : - if (nOriginalLang == LANGUAGE_DONTKNOW) - { // prefer whatever the existing separator is - aStr.append(rStrArray[j]); - } - else - { - aStr.append( rLocWrp.getDateSep() ); - } + aStr.append( rLocWrp.getDateSep() ); break; case NF_SYMBOLTYPE_TIMESEP : aStr.append( rLocWrp.getTimeSep() );