sc/qa/unit/subsequent_export_test4.cxx | 23 +++++++++++++++++++++++ sc/source/filter/xml/xmlexprt.cxx | 6 ++++-- 2 files changed, 27 insertions(+), 2 deletions(-)
New commits: commit 8085a68be7604e7bd00004e0d9445be5e266ffbb Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Wed Mar 29 16:53:48 2023 +0200 Commit: Andreas Heinisch <andreas.heini...@yahoo.de> CommitDate: Wed Mar 29 17:22:55 2023 +0000 tdf#154445 - Export all page styles even if they are not in use Change-Id: If0ca5ea97ad545058c6a70d223158a87bf9207ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149729 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de> diff --git a/sc/qa/unit/subsequent_export_test4.cxx b/sc/qa/unit/subsequent_export_test4.cxx index 3033ff4fef85..275493f61387 100644 --- a/sc/qa/unit/subsequent_export_test4.cxx +++ b/sc/qa/unit/subsequent_export_test4.cxx @@ -18,6 +18,8 @@ #include <stlpool.hxx> #include <formulacell.hxx> #include <validat.hxx> +#include <scresid.hxx> +#include <globstr.hrc> #include <editeng/wghtitem.hxx> #include <editeng/postitem.hxx> @@ -418,6 +420,27 @@ CPPUNIT_TEST_FIXTURE(ScExportTest4, testHeaderFontStyleXLSX) CPPUNIT_ASSERT_MESSAGE("Second line should be italic.", bHasItalic); } +CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf154445_unused_pagestyles) +{ + createScDoc("ods/tdf108188_pagestyle.ods"); + + // Check if the user defined page style is present + const OUString aTestPageStyle = "TestPageStyle"; + ScDocument* pDoc = getScDoc(); + CPPUNIT_ASSERT_EQUAL(aTestPageStyle, pDoc->GetPageStyle(0)); + + // Change page style to default so the user defined one is not used anymore + pDoc->SetPageStyle(0, ScResId(STR_STYLENAME_STANDARD)); + + // Save and reload the document to check if the unused page styles are still present + saveAndReload("calc8"); + pDoc = getScDoc(); + + // Without the accompanying fix in place, the unused page styles don't exist anymore + ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool(); + CPPUNIT_ASSERT(pStylePool->Find(aTestPageStyle, SfxStyleFamily::Page)); +} + CPPUNIT_TEST_FIXTURE(ScExportTest4, testTdf135828_Shape_Rect) { if (!IsDefaultDPI()) diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index cbf8dcf11a0a..4c306de2c907 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2609,7 +2609,8 @@ void ScXMLExport::collectAutoStyles() } if (getExportFlags() & SvXMLExportFlags::MASTERSTYLES) - GetPageExport()->collectAutoStyles(true); + // tdf#154445 - export all page styles even if they are not in use + GetPageExport()->collectAutoStyles(false); mbAutoStylesCollected = true; } @@ -2671,7 +2672,8 @@ void ScXMLExport::ExportAutoStyles_() void ScXMLExport::ExportMasterStyles_() { - GetPageExport()->exportMasterStyles( true ); + // tdf#154445 - export all page styles even if they are not in use + GetPageExport()->exportMasterStyles( false ); } void ScXMLExport::CollectInternalShape( uno::Reference< drawing::XShape > const & xShape )