sc/qa/unit/data/xlsx/tdf139167.xlsx |binary sc/qa/unit/subsequent_export-test.cxx | 21 +++++++++++++++++++++ sc/source/filter/excel/xestyle.cxx | 9 ++++++--- sc/source/filter/excel/xltools.cxx | 4 ++++ 4 files changed, 31 insertions(+), 3 deletions(-)
New commits: commit 6f61e7fd2c5c43c7ecbeccfed6e6e4d8365924f2 Author: Tibor Nagy <nagy.tib...@nisz.hu> AuthorDate: Wed Jan 20 09:53:46 2021 +0100 Commit: Gabor Kelemen <kelemen.gab...@nisz.hu> CommitDate: Thu Mar 4 09:08:23 2021 +0100 tdf#139167 XLSX export: fix proliferation of conditional styles Run-time created styles “ExtConditionalStyle_N N” for extended conditional styles were written back to the XLSX file, growing the cell style list by each save-reload with unused styles. Co-authored-by: Attila Szűcs (NISZ) Change-Id: Icccb9f5333311556132b760efd4e8c8c2db00858 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109667 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 807a63d66010b1969cfbb61d3609b91909872399) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109887 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit 20ce9f5de3c9d3081d197b0a0138d51d75ae3950) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111918 Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu> Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu> diff --git a/sc/qa/unit/data/xlsx/tdf139167.xlsx b/sc/qa/unit/data/xlsx/tdf139167.xlsx new file mode 100644 index 000000000000..b1c7aa201713 Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf139167.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 7b4a69846d3f..c13695c111d1 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -93,6 +93,7 @@ public: ScDocShellRef saveAndReloadPassword( ScDocShell*, const OUString&, const OUString&, const OUString&, SfxFilterFlags ); void test(); + void testTdf139167(); void testTdf139394(); void testExtCondFormatXLSX(); void testTdf90104(); @@ -281,6 +282,7 @@ public: CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); + CPPUNIT_TEST(testTdf139167); CPPUNIT_TEST(testTdf139394); CPPUNIT_TEST(testExtCondFormatXLSX); CPPUNIT_TEST(testTdf90104); @@ -552,6 +554,25 @@ void ScExportTest::test() xDocSh->DoClose(); } +void ScExportTest::testTdf139167() +{ + ScDocShellRef xShell = loadDoc(u"tdf139167.", FORMAT_XLSX); + CPPUNIT_ASSERT(xShell.is()); + + ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh.is()); + + std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX); + xmlDocUniquePtr pDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/styles.xml"); + CPPUNIT_ASSERT(pDoc); + + assertXPath(pDoc, "/x:styleSheet/x:cellStyles", "count", "6"); + assertXPath(pDoc, "/x:styleSheet/x:dxfs/x:dxf/x:fill/x:patternFill/x:bgColor", "rgb", + "FFFFFF00"); + + xDocSh->DoClose(); +} + void ScExportTest::testTdf139394() { ScDocShellRef xShell = loadDoc(u"tdf139394.", FORMAT_XLSX); diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 5a0354701b64..74cdfc58deae 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -3026,12 +3026,15 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot ) for (size_t nFormatEntry = 0; nFormatEntry < nEntryCount; ++nFormatEntry) { const ScFormatEntry* pFormatEntry = rxItem->GetEntry(nFormatEntry); - if (!pFormatEntry || (pFormatEntry->GetType() != ScFormatEntry::Type::Condition && - pFormatEntry->GetType() != ScFormatEntry::Type::Date)) + if (!pFormatEntry + || (pFormatEntry->GetType() != ScFormatEntry::Type::Condition + && pFormatEntry->GetType() != ScFormatEntry::Type::Date + && pFormatEntry->GetType() != ScFormatEntry::Type::ExtCondition)) continue; OUString aStyleName; - if(pFormatEntry->GetType() == ScFormatEntry::Type::Condition) + if (pFormatEntry->GetType() == ScFormatEntry::Type::Condition + || pFormatEntry->GetType() == ScFormatEntry::Type::ExtCondition) { const ScCondFormatEntry* pEntry = static_cast<const ScCondFormatEntry*>(pFormatEntry); aStyleName= pEntry->GetStyle(); diff --git a/sc/source/filter/excel/xltools.cxx b/sc/source/filter/excel/xltools.cxx index e6fce7474725..b2a42f18542e 100644 --- a/sc/source/filter/excel/xltools.cxx +++ b/sc/source/filter/excel/xltools.cxx @@ -656,6 +656,7 @@ bool XclTools::GetBuiltInStyleId( sal_uInt8& rnStyleId, sal_uInt8& rnLevel, cons static const char maCFStyleNamePrefix1[] = "Excel_CondFormat_"; /// Prefix for cond. formatting style names. static const char maCFStyleNamePrefix2[] = "ConditionalStyle_"; /// Prefix for cond. formatting style names from OOX filter. +static const char maCFStyleNamePrefix3[] = "ExtConditionalStyle_"; OUString XclTools::GetCondFormatStyleName( SCTAB nScTab, sal_Int32 nFormat, sal_uInt16 nCondition ) { @@ -675,6 +676,9 @@ bool XclTools::IsCondFormatStyleName( const OUString& rStyleName ) if( rStyleName.startsWithIgnoreAsciiCase( maCFStyleNamePrefix2 ) ) return true; + if (rStyleName.startsWithIgnoreAsciiCase(maCFStyleNamePrefix3)) + return true; + return false; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits