summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--svl/qa/unit/svl.cxx16
-rw-r--r--svl/source/numbers/zformat.cxx9
2 files changed, 23 insertions, 2 deletions
diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index d30a7b6279ec..2e4f21099d0d 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -34,6 +34,7 @@
#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>
@@ -90,7 +91,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 +1729,19 @@ 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 23c0919aecf2..acbea945cd88 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -5291,7 +5291,14 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords,
aStr.append( "-" );
break;
case NF_SYMBOLTYPE_DATESEP :
- aStr.append( rLocWrp.getDateSep() );
+ if (nOriginalLang == LANGUAGE_DONTKNOW)
+ { // prefer whatever the existing separator is
+ aStr.append(rStrArray[j]);
+ }
+ else
+ {
+ aStr.append( rLocWrp.getDateSep() );
+ }
break;
case NF_SYMBOLTYPE_TIMESEP :
aStr.append( rLocWrp.getTimeSep() );