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

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Thu May 2 06:28:18 UTC 2019


 sc/qa/unit/data/xlsx/tdf112567.xlsx   |binary
 sc/qa/unit/subsequent_export-test.cxx |   30 ++++++++++++++++++++++++++++++
 sc/source/filter/excel/xename.cxx     |    8 +++++++-
 3 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit 19976f079800ec4c1d0d5d7e226986cb41f834c2
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Mon Apr 29 17:31:16 2019 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Thu May 2 08:27:33 2019 +0200

    tdf#112567 XLSX export: fix broken built-in names
    
    Localized range separators resulted broken XLSX export
    with duplicated built-in names. For example, XLSX export
    of a Format->Print range using Hungarian locale in LibO
    raised an error message in MSO, because the export
    contained the same range also with a bad semicolon:
    
    <definedName>Sheet1!$A:$A;Sheet1!$1:$1</definedName>
    <definedName>Sheet1!$A:$A,Sheet1!$1:$1</definedName>
    
    Change-Id: Iee6ff7c5f5952fc1e736cebfc290c64a851786ab
    Reviewed-on: https://gerrit.libreoffice.org/71538
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sc/qa/unit/data/xlsx/tdf112567.xlsx b/sc/qa/unit/data/xlsx/tdf112567.xlsx
new file mode 100644
index 000000000000..287c0cc1aa0e
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf112567.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 23727d5b17c7..2db10074d785 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -60,6 +60,8 @@
 #include <editeng/colritem.hxx>
 #include <formula/grammar.hxx>
 #include <unotools/useroptions.hxx>
+#include <comphelper/scopeguard.hxx>
+#include <unotools/syslocaleoptions.hxx>
 #include <tools/datetime.hxx>
 #include <svl/zformat.hxx>
 
@@ -214,6 +216,7 @@ public:
     void testTdf115192XLSX();
     void testTdf91634XLSX();
     void testTdf115159();
+    void testTdf112567();
     void testTdf123645XLSX();
 
     void testXltxExport();
@@ -336,6 +339,7 @@ public:
     CPPUNIT_TEST(testTdf115192XLSX);
     CPPUNIT_TEST(testTdf91634XLSX);
     CPPUNIT_TEST(testTdf115159);
+    CPPUNIT_TEST(testTdf112567);
     CPPUNIT_TEST(testTdf123645XLSX);
 
     CPPUNIT_TEST(testXltxExport);
@@ -4199,6 +4203,32 @@ void ScExportTest::testTdf115159()
     xDocSh->DoClose();
 }
 
+void ScExportTest::testTdf112567()
+{
+    // Set the system locale to Hungarian (a language with different range separator)
+    SvtSysLocaleOptions aOptions;
+    aOptions.SetLocaleConfigString("hu-HU");
+    aOptions.Commit();
+    comphelper::ScopeGuard g([&aOptions] {
+        aOptions.SetLocaleConfigString(OUString());
+        aOptions.Commit();
+    });
+
+    ScDocShellRef xShell = loadDoc("tdf112567.", FORMAT_XLSX);
+    CPPUNIT_ASSERT(xShell.is());
+    ScDocShellRef xDocSh = saveAndReload(xShell.get(), FORMAT_XLSX);
+    CPPUNIT_ASSERT(xDocSh.is());
+    xShell->DoClose();
+
+    xmlDocPtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, "xl/workbook.xml", FORMAT_XLSX);
+    CPPUNIT_ASSERT(pDoc);
+
+    //assert the existing OOXML built-in name is not duplicated
+    assertXPath(pDoc, "/x:workbook/x:definedNames/x:definedName", 1);
+
+    xDocSh->DoClose();
+}
+
 void ScExportTest::testTdf123645XLSX()
 {
     ScDocShellRef xDocSh = loadDoc("chart_hyperlink.", FORMAT_XLSX);
diff --git a/sc/source/filter/excel/xename.cxx b/sc/source/filter/excel/xename.cxx
index ee3bfa2c10f3..ee418fb80d5c 100644
--- a/sc/source/filter/excel/xename.cxx
+++ b/sc/source/filter/excel/xename.cxx
@@ -537,8 +537,14 @@ sal_uInt16 XclExpNameManagerImpl::FindBuiltInNameIdx(
         for( size_t nPos = 0; nPos < mnFirstUserIdx; ++nPos )
         {
             XclExpNameRef xName = maNameList.GetRecord( nPos );
-            if( xName->GetBuiltInName() == cBuiltIn && xName->GetSymbol() == sSymbol )
+            if( xName->GetBuiltInName() == cBuiltIn && xName->GetSymbol().replace(';', ',') == sSymbol.replace(';', ',') )
             {
+                // tdf#112567 restore the original built-in names with non-localized separators
+                // TODO: support more localizations, if needed
+                if ( xName->GetSymbol() != sSymbol )
+                {
+                    xName->SetSymbol(xName->GetSymbol().replace(';', ','));
+                }
                 return static_cast< sal_uInt16 >( nPos + 1 );
             }
         }


More information about the Libreoffice-commits mailing list