[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - sc/qa sc/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Fri Oct 1 12:01:40 UTC 2021


 sc/qa/unit/subsequent_export-test.cxx |    2 -
 sc/source/filter/excel/excrecds.cxx   |    1 
 sc/source/filter/excel/xestyle.cxx    |   42 +++++++++++++++++-----------------
 3 files changed, 24 insertions(+), 21 deletions(-)

New commits:
commit 077a2c6d909f827824af4be59d07226db5e59a5f
Author:     Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
AuthorDate: Fri Sep 24 15:13:44 2021 +0200
Commit:     Thorsten Behrens <thorsten.behrens at allotropia.de>
CommitDate: Fri Oct 1 14:01:05 2021 +0200

    tdf#76258 Fix xlsx export of color filter colors
    
    Change-Id: I08bd46fe10a8fc35a9c2a87745ee3e8cb4c676d5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116648
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
    (cherry picked from commit d148ed642f2aef2c2cc8615296cc648249a4878d)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122604
    Tested-by: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
    Reviewed-by: Thorsten Behrens <thorsten.behrens at allotropia.de>

diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 475dee2fc742..bbfbbbf6e3e1 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -4108,7 +4108,7 @@ void ScExportTest::testAutofilterColorsOOXML()
                                                      "xl/tables/table1.xml", FORMAT_XLSX);
     CPPUNIT_ASSERT(pDoc);
 
-    assertXPath(pDoc, "/x:table/x:autoFilter/x:filterColumn/x:colorFilter", "dxfId", "4");
+    assertXPath(pDoc, "/x:table/x:autoFilter/x:filterColumn/x:colorFilter", "dxfId", "5");
 }
 
 void ScExportTest::testAutofilterColorsStyleOOXML()
diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx
index 23c106524704..95bfeff9ef05 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -844,6 +844,7 @@ void XclExpAutofilter::SaveXml( XclExpXmlStream& rStrm )
                     nDxfId = GetDxfs().GetDxfByBackColor(color);
                 else
                     nDxfId = GetDxfs().GetDxfByForeColor(color);
+                nDxfId++; // Count is 1-based
                 rWorksheet->singleElement(XML_colorFilter, XML_dxfId, OString::number(nDxfId));
             }
         }
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx
index 65f73bb6b1f5..017d8ad43dd1 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -3041,8 +3041,7 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot )
     xFormatter->FillKeywordTableForExcel( *mpKeywordTable );
 
     SCTAB nTables = rRoot.GetDoc().GetTableCount();
-    sal_Int32 nForeColorIndex = 0;
-    sal_Int32 nBackColorIndex = 0;
+    sal_Int32 nColorIndex = 0;
     sal_Int32 nCondFormattingIndex = 0;
     for(SCTAB nTab = 0; nTab < nTables; ++nTab)
     {
@@ -3052,27 +3051,30 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot )
         {
             ScRange aRange;
             pData->GetArea(aRange);
-            ScFilterEntries aFilterEntries;
-            rRoot.GetDoc().GetFilterEntriesArea(aRange.aStart.Col(), aRange.aStart.Row(),
-                                                aRange.aEnd.Row(), nTab, true, aFilterEntries);
-
-            for (auto& rColor : aFilterEntries.getBackgroundColors())
+            for (auto nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); nCol++)
             {
-                if (!maBackColorToDxfId.emplace(rColor, nBackColorIndex).second)
-                    continue;
+                ScFilterEntries aFilterEntries;
+                rRoot.GetDoc().GetFilterEntriesArea(nCol, aRange.aStart.Row(),
+                                                    aRange.aEnd.Row(), nTab, true, aFilterEntries);
 
-                std::unique_ptr<XclExpCellArea> pExpCellArea(new XclExpCellArea(0, rColor));
-                maDxf.push_back(std::make_unique<XclExpDxf>(rRoot, std::move(pExpCellArea)));
-                nBackColorIndex++;
-            }
-            for (auto& rColor : aFilterEntries.getTextColors())
-            {
-                if (!maForeColorToDxfId.emplace(rColor, nForeColorIndex).second)
-                    continue;
+                for (auto& rColor : aFilterEntries.getBackgroundColors())
+                {
+                    if (!maBackColorToDxfId.emplace(rColor, nColorIndex).second)
+                        continue;
 
-                std::unique_ptr<XclExpCellArea> pExpCellArea(new XclExpCellArea(rColor, 0));
-                maDxf.push_back(std::make_unique<XclExpDxf>(rRoot, std::move(pExpCellArea)));
-                nForeColorIndex++;
+                    std::unique_ptr<XclExpCellArea> pExpCellArea(new XclExpCellArea(0, rColor));
+                    maDxf.push_back(std::make_unique<XclExpDxf>(rRoot, std::move(pExpCellArea)));
+                    nColorIndex++;
+                }
+                for (auto& rColor : aFilterEntries.getTextColors())
+                {
+                    if (!maForeColorToDxfId.emplace(rColor, nColorIndex).second)
+                        continue;
+
+                    std::unique_ptr<XclExpCellArea> pExpCellArea(new XclExpCellArea(rColor, 0));
+                    maDxf.push_back(std::make_unique<XclExpDxf>(rRoot, std::move(pExpCellArea)));
+                    nColorIndex++;
+                }
             }
         }
 


More information about the Libreoffice-commits mailing list