sc/qa/uitest/calc_tests8/tdf144940.py                |   59 +++++++++++++++++++
 sc/source/filter/xml/XMLTableHeaderFooterContext.cxx |   11 +--
 2 files changed, 65 insertions(+), 5 deletions(-)

New commits:
commit 5db9b33dadda67c7f97d8c23df17211fae380919
Author:     Attila Bakos (NISZ) <bakos.attilakar...@nisz.hu>
AuthorDate: Wed Nov 17 09:15:23 2021 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Fri Nov 26 11:52:13 2021 +0100

    tdf#144940 sc: fix disabled header/footer regression
    
    Setting "Same content on first page" in the Page Style
    dialog on either the Header or Footer tab resulted
    disabled header/footer after reload. This was due to
    flawed logic when assigning SC_UNO_PAGE_HDRON/FTRON
    value: "leftness" was checked for but not "first pageness".
    
    Regression from commit b9993369b4011cd8f367e439f5248096827f1efc
    "tdf#121715 XLSX: support custom first page header/footer".
    
    Co-authored-by: Daniel Arato (NISZ)
    
    Change-Id: I8ee4c9f8145913d9dc5f4b66cdbc2352f2e405f0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125367
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sc/qa/uitest/calc_tests8/tdf144940.py 
b/sc/qa/uitest/calc_tests8/tdf144940.py
new file mode 100644
index 000000000000..6b118c7602c2
--- /dev/null
+++ b/sc/qa/uitest/calc_tests8/tdf144940.py
@@ -0,0 +1,59 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict
+from uitest.uihelper.common import select_pos
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from tempfile import TemporaryDirectory
+from org.libreoffice.unotest import systemPathToFileUrl
+import os.path
+
+class tdf144940(UITestCase):
+
+    def test_tdf144940(self):
+
+        with TemporaryDirectory() as tempdir:
+            xFilePath = os.path.join(tempdir, "tdf144940-tmp.ods")
+
+            with self.ui_test.create_doc_in_start_center("calc"):
+
+                with 
self.ui_test.execute_dialog_through_command(".uno:PageFormatDialog") as xDialog:
+                    xTabs = xDialog.getChild("tabcontrol")
+                    select_pos(xTabs, "4")
+
+                    xCheckHeaderOn = xDialog.getChild("checkHeaderOn")
+                    xCheckSameFP = xDialog.getChild("checkSameFP")
+                    xCheckSameLR = xDialog.getChild("checkSameLR")
+
+                    self.assertEqual("true", 
get_state_as_dict(xCheckHeaderOn)["Selected"])
+                    self.assertEqual("true", 
get_state_as_dict(xCheckSameLR)["Selected"])
+                    self.assertEqual("false", 
get_state_as_dict(xCheckSameFP)["Selected"])
+
+                    xCheckSameFP.executeAction("CLICK", tuple())
+
+                    self.assertEqual("true", 
get_state_as_dict(xCheckSameFP)["Selected"])
+
+                with self.ui_test.execute_dialog_through_command(".uno:Save", 
close_button="open") as xSaveDialog:
+                    xFileName = xSaveDialog.getChild("file_name")
+                    xFileName.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"CTRL+A"}))
+                    xFileName.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+                    xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": 
xFilePath}))
+
+            with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as 
document:
+
+                xPageStyles = document.StyleFamilies.getByIndex(1)
+                xDefaultPageStyle = xPageStyles.getByIndex(0)
+
+                # Without the fix in place, this test would have failed with
+                # AssertionError: False is not true
+                self.assertTrue(xDefaultPageStyle.HeaderOn)
+                self.assertTrue(xDefaultPageStyle.FooterOn)
+                self.assertTrue(xDefaultPageStyle.FirstPageHeaderIsShared)
+                self.assertTrue(xDefaultPageStyle.FirstPageFooterIsShared)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx 
b/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
index c0b5c6eb6cc1..773eb12da88b 100644
--- a/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
+++ b/sc/source/filter/xml/XMLTableHeaderFooterContext.cxx
@@ -63,19 +63,20 @@ XMLTableHeaderFooterContext::XMLTableHeaderFooterContext( 
SvXMLImport& rImport,
             XMLOFF_WARN_UNKNOWN("sc", aIter);
     }
     bool bOn(::cppu::any2bool(xPropSet->getPropertyValue( sOn )));
-    if( bLeft )
+    if( bLeft || bFirst )
     {
+        const OUString sShare = bLeft ? sShareContent : sShareFirstContent;
         if( bOn && bDisplay )
         {
-            if( ::cppu::any2bool(xPropSet->getPropertyValue( sShareContent )) )
+            if( ::cppu::any2bool(xPropSet->getPropertyValue( sShare )) )
                 // Don't share headers any longer
-                xPropSet->setPropertyValue( sShareContent, uno::makeAny(false) 
);
+                xPropSet->setPropertyValue( sShare, uno::makeAny(false) );
         }
         else
         {
-            if( !::cppu::any2bool(xPropSet->getPropertyValue( sShareContent )) 
)
+            if( !::cppu::any2bool(xPropSet->getPropertyValue( sShare )) )
                 // share headers
-                xPropSet->setPropertyValue( sShareContent, uno::makeAny(true) 
);
+                xPropSet->setPropertyValue( sShare, uno::makeAny(true) );
         }
     }
     else

Reply via email to