sc/qa/unit/subsequent_export_test2.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 d148ed642f2aef2c2cc8615296cc648249a4878d Author: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> AuthorDate: Fri Sep 24 15:13:44 2021 +0200 Commit: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de> CommitDate: Sat Sep 25 11:22:02 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.mehrbr...@allotropia.de> diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 12863985d79e..41a25d2c0312 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -764,7 +764,7 @@ void ScExportTest2::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 ScExportTest2::testAutofilterColorsStyleOOXML() diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx index 71c62bd86190..a09312d665de 100644 --- a/sc/source/filter/excel/excrecds.cxx +++ b/sc/source/filter/excel/excrecds.cxx @@ -855,6 +855,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 0b6d5ae95277..e9eccbfabc05 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -3054,8 +3054,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) { @@ -3065,27 +3064,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++; + } } }