[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sc/qa sc/source

Vasily Melenchuk (via logerrit) logerrit at kemper.freedesktop.org
Mon Oct 4 12:09:27 UTC 2021


 sc/qa/unit/data/ods/tdf142578.ods      |binary
 sc/qa/unit/subsequent_export-test2.cxx |   41 +++++++++++++++++++++++++++++++++
 sc/source/filter/excel/xestyle.cxx     |   15 +++++-------
 3 files changed, 48 insertions(+), 8 deletions(-)

New commits:
commit c1e156e16d3f2a0c1393332b3ad3a20a267ab936
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Thu Sep 30 17:50:16 2021 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Mon Oct 4 14:08:51 2021 +0200

    tdf#142578: xlsx export: use continuous numbering for dfx nodes
    
    Since all dxf records are stored in one place it is required
    from color filter and conditional formatting to use continuous
    numbering for dxf structures to avoid id collision.
    
    Change-Id: I91146e34d462d812b480db137cda522f6db7ef8b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122915
    Tested-by: Jenkins
    Reviewed-by: Vasily Melenchuk <vasily.melenchuk at cib.de>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123038
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sc/qa/unit/data/ods/tdf142578.ods b/sc/qa/unit/data/ods/tdf142578.ods
new file mode 100644
index 000000000000..0fb6e07d5e4b
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf142578.ods differ
diff --git a/sc/qa/unit/subsequent_export-test2.cxx b/sc/qa/unit/subsequent_export-test2.cxx
index 0518cd11c154..cc266e5a2bc0 100644
--- a/sc/qa/unit/subsequent_export-test2.cxx
+++ b/sc/qa/unit/subsequent_export-test2.cxx
@@ -201,6 +201,7 @@ public:
     void testTdf143220XLSX();
     void testTdf142264ManyChartsToXLSX();
     void testTdf143929MultiColumnToODS();
+    void testTdf142578();
 
     CPPUNIT_TEST_SUITE(ScExportTest2);
 
@@ -303,6 +304,7 @@ public:
     CPPUNIT_TEST(testTdf143220XLSX);
     CPPUNIT_TEST(testTdf142264ManyChartsToXLSX);
     CPPUNIT_TEST(testTdf143929MultiColumnToODS);
+    CPPUNIT_TEST(testTdf142578);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -2625,6 +2627,45 @@ void ScExportTest2::testTdf143929MultiColumnToODS()
         "column-gap");
 }
 
+void ScExportTest2::testTdf142578()
+{
+    ScDocShellRef xDocSh = loadDoc(u"tdf142578.", FORMAT_ODS);
+    CPPUNIT_ASSERT(xDocSh);
+
+    std::shared_ptr<utl::TempFile> pXPathFile
+        = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX);
+    xmlDocUniquePtr pSheet
+        = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/sheet1.xml");
+    CPPUNIT_ASSERT(pSheet);
+
+    // Get DxfId for color filter
+    sal_Int32 nDxfIdColorFilter
+        = getXPath(pSheet, "/x:worksheet/x:autoFilter/x:filterColumn/x:colorFilter", "dxfId")
+              .toInt32()
+          + 1;
+
+    // Get DxfId for conditional formatting
+    sal_Int32 nDxfIdCondFormat
+        = getXPath(pSheet, "/x:worksheet/x:conditionalFormatting/x:cfRule", "dxfId").toInt32() + 1;
+
+    // Ensure they are using different dxfs
+    CPPUNIT_ASSERT_MESSAGE("dxfID's should be different!", nDxfIdColorFilter != nDxfIdCondFormat);
+
+    // Check colors used by these dxfs
+    xmlDocUniquePtr pStyles = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/styles.xml");
+    CPPUNIT_ASSERT(pStyles);
+
+    OString sDxfColorFilterXPath("/x:styleSheet/x:dxfs/x:dxf[" + OString::number(nDxfIdColorFilter)
+                                 + "]/x:fill/x:patternFill/x:fgColor");
+    assertXPath(pStyles, sDxfColorFilterXPath, "rgb", "FF81D41A");
+
+    OString sDxfCondFormatXPath("/x:styleSheet/x:dxfs/x:dxf[" + OString::number(nDxfIdCondFormat)
+                                + "]/x:fill/x:patternFill/x:bgColor");
+    assertXPath(pStyles, sDxfCondFormatXPath, "rgb", "FFFFCCCC");
+
+    xDocSh->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 627cc93b7a6c..243560cf494b 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -3053,8 +3053,7 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot )
     xFormatter->FillKeywordTableForExcel( *mpKeywordTable );
 
     SCTAB nTables = rRoot.GetDoc().GetTableCount();
-    sal_Int32 nColorIndex = 0;
-    sal_Int32 nCondFormattingIndex = 0;
+    sal_Int32 nDxfId = 0;
     for(SCTAB nTab = 0; nTab < nTables; ++nTab)
     {
         // Color filters
@@ -3073,21 +3072,21 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot )
                 // Does not matter it is text color or cell background color
                 for (auto& rColor : aFilterEntries.getBackgroundColors())
                 {
-                    if (!maColorToDxfId.emplace(rColor, nColorIndex).second)
+                    if (!maColorToDxfId.emplace(rColor, nDxfId).second)
                         continue;
 
                     std::unique_ptr<XclExpCellArea> pExpCellArea(new XclExpCellArea(rColor, 0));
                     maDxf.push_back(std::make_unique<XclExpDxf>(rRoot, std::move(pExpCellArea)));
-                    nColorIndex++;
+                    nDxfId++;
                 }
                 for (auto& rColor : aFilterEntries.getTextColors())
                 {
-                    if (!maColorToDxfId.emplace(rColor, nColorIndex).second)
+                    if (!maColorToDxfId.emplace(rColor, nDxfId).second)
                         continue;
 
                     std::unique_ptr<XclExpCellArea> pExpCellArea(new XclExpCellArea(rColor, 0));
                     maDxf.push_back(std::make_unique<XclExpDxf>(rRoot, std::move(pExpCellArea)));
-                    nColorIndex++;
+                    nDxfId++;
                 }
             }
         }
@@ -3121,7 +3120,7 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot )
                         aStyleName = pEntry->GetStyleName();
                     }
 
-                    if (maStyleNameToDxfId.emplace(aStyleName, nCondFormattingIndex).second)
+                    if (maStyleNameToDxfId.emplace(aStyleName, nDxfId).second)
                     {
                         SfxStyleSheetBase* pStyle = rRoot.GetDoc().GetStyleSheetPool()->Find(aStyleName, SfxStyleFamily::Para);
                         if(!pStyle)
@@ -3166,7 +3165,7 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot )
 
                         maDxf.push_back(std::make_unique<XclExpDxf>( rRoot, std::move(pAlign), std::move(pBorder),
                                 std::move(pFont), std::move(pNumFormat), std::move(pCellProt), std::move(pColor) ));
-                        ++nCondFormattingIndex;
+                        ++nDxfId;
                     }
 
                 }


More information about the Libreoffice-commits mailing list