[Libreoffice-commits] core.git: 2 commits - svl/qa svl/source

Eike Rathke (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 8 08:40:07 UTC 2019


 svl/qa/unit/svl.cxx            |   41 +++++++++++++++++++++++++++++++++++++++++
 svl/source/numbers/zformat.cxx |   34 ++++++++++++++++++++++------------
 2 files changed, 63 insertions(+), 12 deletions(-)

New commits:
commit 3e71ec4dd593d4c7d904a8617be5808a0c0f02b1
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Fri Nov 8 01:52:44 2019 +0100
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Fri Nov 8 09:39:20 2019 +0100

    Unit test for fixed locale Excel export formats, tdf#128649
    
    Change-Id: I7ec63659c39acb612de4df502e364afdc2cc7189
    Reviewed-on: https://gerrit.libreoffice.org/82257
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins

diff --git a/svl/qa/unit/svl.cxx b/svl/qa/unit/svl.cxx
index 17035f29dc86..d30a7b6279ec 100644
--- a/svl/qa/unit/svl.cxx
+++ b/svl/qa/unit/svl.cxx
@@ -70,6 +70,7 @@ public:
     void testNfEnglishKeywordsIntegrity();
     void testStandardColorIntegrity();
     void testColorNamesConversion();
+    void testExcelExportFormats();
 
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(testNumberFormat);
@@ -86,6 +87,7 @@ public:
     CPPUNIT_TEST(testNfEnglishKeywordsIntegrity);
     CPPUNIT_TEST(testStandardColorIntegrity);
     CPPUNIT_TEST(testColorNamesConversion);
+    CPPUNIT_TEST(testExcelExportFormats);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1687,6 +1689,45 @@ void Test::testColorNamesConversion()
     }
 }
 
+void Test::testExcelExportFormats()
+{
+    // Create a formatter with "system" locale other than the specific formats'
+    // locale, and different from the en-US export locale.
+    SvNumberFormatter aFormatter( m_xContext, LANGUAGE_ENGLISH_UK);
+
+    OUString aCode;
+    sal_Int32 nCheckPos;
+    SvNumFormatType eType;
+    sal_uInt32 nKey1, nKey2;
+
+    aCode = "00.00";
+    aFormatter.PutandConvertEntry( aCode, nCheckPos, eType, nKey1,
+            LANGUAGE_ENGLISH_US, LANGUAGE_ENGLISH_SAFRICA, false);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("CheckPos should be 0.", sal_Int32(0), nCheckPos);
+    CPPUNIT_ASSERT_MESSAGE("Key should be greater than system locale's keys.",
+            nKey1 > SV_COUNTRY_LANGUAGE_OFFSET);
+
+    aCode = "[$R-1C09] #,##0.0;[$R-1C09]-#,##0.0";
+    aFormatter.PutandConvertEntry( aCode, nCheckPos, eType, nKey2,
+            LANGUAGE_ENGLISH_US, LANGUAGE_ENGLISH_SAFRICA, false);
+    CPPUNIT_ASSERT_EQUAL_MESSAGE("CheckPos should be 0.", sal_Int32(0), nCheckPos);
+    CPPUNIT_ASSERT_MESSAGE("Key should be greater than system locale's keys.",
+            nKey2 > SV_COUNTRY_LANGUAGE_OFFSET);
+
+    // The export formatter.
+    SvNumberFormatter aTempFormatter( m_xContext, LANGUAGE_ENGLISH_US);
+    NfKeywordTable aKeywords;
+    aTempFormatter.FillKeywordTableForExcel( aKeywords);
+
+    aCode = aFormatter.GetFormatStringForExcel( nKey1, aKeywords, aTempFormatter);
+    // Test that LCID is prepended.
+    CPPUNIT_ASSERT_EQUAL( OUString("[$-1C09]00.00"), aCode);
+
+    aCode = aFormatter.GetFormatStringForExcel( nKey2, aKeywords, aTempFormatter);
+    // Test that LCID is not prepended. Note that literal characters are escaped.
+    CPPUNIT_ASSERT_EQUAL( OUString("[$R-1C09]\\ #,##0.0;[$R-1C09]\\-#,##0.0"), aCode);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
commit 3b49477c31692730f15dc571c823515889ccaec9
Author:     Eike Rathke <erack at redhat.com>
AuthorDate: Thu Nov 7 21:24:04 2019 +0100
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Fri Nov 8 09:39:09 2019 +0100

    Resolves: tdf#128649 Do not insert duplicate LCID for currency
    
    Fallout from
    
        commit d0f8daa0980ba8e403b32006831657c5a0a4ea17
        CommitDate: Wed Aug 22 19:03:27 2018 +0200
    
            Resolves: tdf#73063 preserve and roundtrip LCID from/to Excel number formats
    
    Change-Id: I356f37624786d753370a272b0f1b54b17b5d206c
    Reviewed-on: https://gerrit.libreoffice.org/82249
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Jenkins
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index eb2b47dc80af..ce04f095c68f 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -5239,6 +5239,7 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords,
         {
             aStr.append( aPrefix );
         }
+        sal_Int32 nPosHaveLCID = -1;
         sal_Int32 nPosInsertLCID = aStr.getLength();
         sal_uInt32 nCalendarID = 0x0000000; // Excel ID of calendar used in sub-format see tdf#36038
         if ( nCnt )
@@ -5318,6 +5319,10 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords,
                         if ( nCalendarID > 0 )
                             j = j+2;
                         break;
+                    case NF_SYMBOLTYPE_CURREXT :
+                        nPosHaveLCID = aStr.getLength();
+                        aStr.append( rStrArray[j] );
+                        break;
                     default:
                         aStr.append( rStrArray[j] );
                     }
@@ -5428,19 +5433,24 @@ OUString SvNumberformat::GetMappedFormatstring( const NfKeywordTable& rKeywords,
             if ( aNatNum.GetDBNum() > 0 && nLanguageID == LANGUAGE_SYSTEM )
                 nLanguageID = MsLangId::getRealLanguage( aNatNum.GetLang());
         }
-        else if (!bSystemLanguage && nOriginalLang != LANGUAGE_DONTKNOW)
+        else if (nPosHaveLCID < 0)
         {
-            // Explicit locale, write only to the first subformat.
-            if (n == 0)
-                nLanguageID = MsLangId::getRealLanguage( nOriginalLang);
-        }
-        else if (bSystemLanguage && maLocale.meLanguageWithoutLocaleData != LANGUAGE_DONTKNOW)
-        {
-            // Explicit locale but no locale data thus assigned to system
-            // locale, preserve for roundtrip, write only to the first
-            // subformat.
-            if (n == 0)
-                nLanguageID = maLocale.meLanguageWithoutLocaleData;
+            // Do not insert a duplicated LCID that was already given with a
+            // currency format as [$R-1C09]
+            if (!bSystemLanguage && nOriginalLang != LANGUAGE_DONTKNOW)
+            {
+                // Explicit locale, write only to the first subformat.
+                if (n == 0)
+                    nLanguageID = MsLangId::getRealLanguage( nOriginalLang);
+            }
+            else if (bSystemLanguage && maLocale.meLanguageWithoutLocaleData != LANGUAGE_DONTKNOW)
+            {
+                // Explicit locale but no locale data thus assigned to system
+                // locale, preserve for roundtrip, write only to the first
+                // subformat.
+                if (n == 0)
+                    nLanguageID = maLocale.meLanguageWithoutLocaleData;
+            }
         }
         if ( nCalendarID > 0 )
         {   // Add alphabet and language to calendar


More information about the Libreoffice-commits mailing list