sc/qa/unit/data/ods/header-footer-content.ods     |binary
 sc/qa/unit/subsequent_export_test2.cxx            |   36 ++++++++++++++++++++++
 sc/source/filter/xml/XMLTableMasterPageExport.cxx |    2 -
 3 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit 6f04952e6828cf1419b991e82070514bae24896c
Author:     Daniel Arato (NISZ) <arato.dan...@nisz.hu>
AuthorDate: Wed Sep 22 15:03:48 2021 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Tue Sep 28 11:32:53 2021 +0200

    tdf#144184 sc: fix first page footer export
    
    Due to a typical case of copy-paste oversight LO Calc used to lose
    the first page footer when exporting to ODS. With the typo fixed,
    the export now works again.
    
    Follow-up to commit 19fa853ce12136b5c14e0c5a0aa906c296b75388
    "tdf#121715 XLSX: support custom first page header/footer".
    
    Change-Id: If8f5ab4ff9a9392768789b886218d1d9c56ddbae
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122455
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sc/qa/unit/data/ods/header-footer-content.ods 
b/sc/qa/unit/data/ods/header-footer-content.ods
new file mode 100644
index 000000000000..f365748ddc22
Binary files /dev/null and b/sc/qa/unit/data/ods/header-footer-content.ods 
differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx 
b/sc/qa/unit/subsequent_export_test2.cxx
index 41a25d2c0312..10743521d31c 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -83,6 +83,7 @@
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/graphic/GraphicType.hpp>
 #include <com/sun/star/sheet/GlobalSheetSettings.hpp>
+#include <com/sun/star/sheet/XHeaderFooterContent.hpp>
 #include <com/sun/star/text/XTextColumns.hpp>
 
 using namespace ::com::sun::star;
@@ -126,6 +127,7 @@ public:
     void testRefStringConfigXLSX();
     void testRefStringUnspecified();
     void testHeaderImageODS();
+    void testHeaderFooterContentODS();
 
     void testTdf88657ODS();
     void testTdf41722();
@@ -233,6 +235,7 @@ public:
     CPPUNIT_TEST(testRefStringConfigXLSX);
     CPPUNIT_TEST(testRefStringUnspecified);
     CPPUNIT_TEST(testHeaderImageODS);
+    CPPUNIT_TEST(testHeaderFooterContentODS);
 
     CPPUNIT_TEST(testTdf88657ODS);
     CPPUNIT_TEST(testTdf41722);
@@ -485,6 +488,39 @@ void ScExportTest2::testHeaderImageODS()
     xDocSh->DoClose();
 }
 
+void ScExportTest2::testHeaderFooterContentODS()
+{
+    ScDocShellRef xShell = loadDoc(u"header-footer-content.", FORMAT_ODS);
+    ScDocShellRef xDocSh = saveAndReload(&(*xShell), FORMAT_ODS);
+    uno::Reference<style::XStyleFamiliesSupplier> 
xStyleFamiliesSupplier(xDocSh->GetModel(),
+                                                                         
uno::UNO_QUERY);
+    uno::Reference<container::XNameAccess> xStyleFamilies
+        = xStyleFamiliesSupplier->getStyleFamilies();
+    uno::Reference<container::XNameAccess> 
xPageStyles(xStyleFamilies->getByName("PageStyles"),
+                                                       uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> 
xStyle(xPageStyles->getByName("Default"), uno::UNO_QUERY);
+
+    uno::Reference<css::sheet::XHeaderFooterContent> xContent;
+    xStyle->getPropertyValue("RightPageHeaderContent") >>= xContent;
+    CPPUNIT_ASSERT(xContent.is());
+    CPPUNIT_ASSERT_EQUAL(OUString("header"), 
xContent->getCenterText()->getString());
+
+    xStyle->getPropertyValue("FirstPageHeaderContent") >>= xContent;
+    CPPUNIT_ASSERT(xContent.is());
+    CPPUNIT_ASSERT_EQUAL(OUString("first page header"), 
xContent->getCenterText()->getString());
+
+    xStyle->getPropertyValue("RightPageFooterContent") >>= xContent;
+    CPPUNIT_ASSERT(xContent.is());
+    CPPUNIT_ASSERT_EQUAL(OUString("footer"), 
xContent->getCenterText()->getString());
+
+    xStyle->getPropertyValue("FirstPageFooterContent") >>= xContent;
+    // First page footer content used to be lost upon export.
+    CPPUNIT_ASSERT(xContent.is());
+    CPPUNIT_ASSERT_EQUAL(OUString("first page footer"), 
xContent->getCenterText()->getString());
+
+    xDocSh->DoClose();
+}
+
 void ScExportTest2::testTextDirectionXLSX()
 {
     ScDocShellRef xDocSh = loadDoc(u"writingMode.", FORMAT_XLSX);
diff --git a/sc/source/filter/xml/XMLTableMasterPageExport.cxx 
b/sc/source/filter/xml/XMLTableMasterPageExport.cxx
index bf43b2c29fb2..59b29378ea16 100644
--- a/sc/source/filter/xml/XMLTableMasterPageExport.cxx
+++ b/sc/source/filter/xml/XMLTableMasterPageExport.cxx
@@ -187,7 +187,7 @@ void XMLTableMasterPageExport::exportMasterPageContent(
 
         bool bFirstFooter = (!::cppu::any2bool(rPropSet->getPropertyValue( 
SC_UNO_PAGE_FIRSTFTRSHARED )) && bFooter);
 
-        exportHeaderFooter( xFooterLeft, XML_FOOTER_FIRST, bFirstFooter );
+        exportHeaderFooter( xFooterFirst, XML_FOOTER_FIRST, bFirstFooter );
     }
 }
 

Reply via email to