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.heinisch@yahoo.de>
(cherry picked from commit 8085a68be7604e7bd00004e0d9445be5e266ffbb)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149735
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx
index ce7ac0c..f97dc4b 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -23,6 +23,8 @@
#include <dpcache.hxx>
#include <dpobject.hxx>
#include <clipparam.hxx>
#include <scresid.hxx>
#include <globstr.hrc>
#include <editeng/wghtitem.hxx>
#include <editeng/postitem.hxx>
@@ -147,6 +149,7 @@ public:
void testTdf121718_UseFirstPageNumberXLSX();
void testHeaderFontStyleXLSX();
void testTdf135828_Shape_Rect();
void testTdf154445_unused_pagestyles();
void testTdf123139XLSX();
void testTdf123353();
void testTdf140098();
@@ -276,6 +279,7 @@ public:
CPPUNIT_TEST(testTdf121718_UseFirstPageNumberXLSX);
CPPUNIT_TEST(testHeaderFontStyleXLSX);
CPPUNIT_TEST(testTdf135828_Shape_Rect);
CPPUNIT_TEST(testTdf154445_unused_pagestyles);
CPPUNIT_TEST(testTdf123139XLSX);
CPPUNIT_TEST(testTdf123353);
CPPUNIT_TEST(testTdf140098);
@@ -1889,6 +1893,27 @@ void ScExportTest2::testTdf135828_Shape_Rect()
CPPUNIT_ASSERT_DOUBLES_EQUAL(1988280, nHeight, 10000);
}
void ScExportTest2::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));
}
void ScExportTest2::testTdf123139XLSX()
{
createScDoc("xlsx/tdf123139_applyAlignment.xlsx");
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 051c0ac..9fba6fd 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2611,7 +2611,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;
}
@@ -2673,7 +2674,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 )