diff options
author | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-12-22 16:44:08 +0100 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2021-12-24 01:51:15 +0100 |
commit | 69bdf09dea60fe590032ed18d59b7dab806a6b0c (patch) | |
tree | 901e19fca236b64f8805512571f7689d7ce2b12e | |
parent | tdf#135061: sw_uiwriter3: Add unittest (diff) | |
download | core-69bdf09dea60fe590032ed18d59b7dab806a6b0c.tar.gz core-69bdf09dea60fe590032ed18d59b7dab806a6b0c.zip |
tdf#145057 Fix saving color filter when multiple data ranges in sheet
When mutliple data ranges existed in one sheet, only the first one was
considered when exporting color filters.
Consider all of them, as any could hold a color filter.
Change-Id: I13ae2018057eef7ef24fc8298c814a93df24f74b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127337
Tested-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
-rw-r--r-- | sc/inc/dbdata.hxx | 1 | ||||
-rw-r--r-- | sc/qa/unit/data/xlsx/tdf145057.xlsx | bin | 0 -> 10417 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 13 | ||||
-rw-r--r-- | sc/source/core/tool/dbdata.cxx | 14 | ||||
-rw-r--r-- | sc/source/filter/excel/xestyle.cxx | 4 |
5 files changed, 30 insertions, 2 deletions
diff --git a/sc/inc/dbdata.hxx b/sc/inc/dbdata.hxx index 24eaa3be7d18..b000af812045 100644 --- a/sc/inc/dbdata.hxx +++ b/sc/inc/dbdata.hxx @@ -323,6 +323,7 @@ public: const ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const; ScDBData* GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2); ScDBData* GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab ); + std::vector<ScDBData*> GetAllDBsFromTab(SCTAB nTab); void RefreshDirtyTableColumnNames(); diff --git a/sc/qa/unit/data/xlsx/tdf145057.xlsx b/sc/qa/unit/data/xlsx/tdf145057.xlsx Binary files differnew file mode 100644 index 000000000000..4a2e259c119d --- /dev/null +++ b/sc/qa/unit/data/xlsx/tdf145057.xlsx diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 382e2b9d02dc..f54cb966bacc 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -144,6 +144,7 @@ public: void testFormulaReferenceXLS(); void testSheetProtectionXLSX(); + void testTdf145057(); void testSheetProtectionXLSB(); void testCellBordersXLS(); @@ -296,6 +297,7 @@ public: CPPUNIT_TEST(testFormulaReferenceXLS); CPPUNIT_TEST(testSheetProtectionXLSX); + CPPUNIT_TEST(testTdf145057); CPPUNIT_TEST(testSheetProtectionXLSB); CPPUNIT_TEST(testCellBordersXLS); CPPUNIT_TEST(testCellBordersXLSX); @@ -2261,6 +2263,17 @@ void ScExportTest::testSheetProtectionXLSX() xDocSh->DoClose(); } +void ScExportTest::testTdf145057() +{ + ScDocShellRef xDocSh = loadDoc(u"tdf145057.", FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh.is()); + xDocSh = saveAndReload(xDocSh.get(), FORMAT_XLSX); + xmlDocPtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, + "xl/tables/table1.xml", FORMAT_XLSX); + CPPUNIT_ASSERT(pDoc); + assertXPath(pDoc, "//x:colorFilter", "dxfId", "1"); +} + void ScExportTest::testSheetProtectionXLSB() { ScDocShellRef xShell = loadDoc("tdf108017_calcProtection.", FORMAT_XLSB); diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index 8e77f5410dc4..e56e7fecf516 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -1491,6 +1491,20 @@ ScDBData* ScDBCollection::GetDBNearCursor(SCCOL nCol, SCROW nRow, SCTAB nTab ) return pDoc->GetAnonymousDBData(nTab); // "unbenannt"/"unnamed" only if nothing else } +std::vector<ScDBData*> ScDBCollection::GetAllDBsFromTab(SCTAB nTab) +{ + std::vector<ScDBData*> pTabData; + for (const auto& rxNamedDB : maNamedDBs) + { + if (rxNamedDB->GetTab() == nTab) + pTabData.emplace_back(rxNamedDB.get()); + } + auto pAnonDBData = pDoc->GetAnonymousDBData(nTab); + if (pAnonDBData) + pTabData.emplace_back(pAnonDBData); + return pTabData; +} + bool ScDBCollection::empty() const { return maNamedDBs.empty() && maAnonDBs.empty(); diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 552f6f66a87d..77a73ee19f57 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -3045,8 +3045,8 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot ) for(SCTAB nTab = 0; nTab < nTables; ++nTab) { // Color filters - const ScDBData* pData = rRoot.GetDoc().GetDBCollection()->GetDBNearCursor(0, 0, 0); - if (pData) + std::vector<ScDBData*> pDBData = rRoot.GetDoc().GetDBCollection()->GetAllDBsFromTab(nTab); + for (auto& pData : pDBData) { ScRange aRange; pData->GetArea(aRange); |