summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorAttila Bakos (NISZ) <bakos.attilakaroly@nisz.hu>2021-11-17 09:15:23 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2021-11-29 12:35:50 +0100
commit5ece740b3672b4204231c995a31ae97c108e7c80 (patch)
treebd28da18b5424747782d39b25fcfec6d7787ef54 /sc
parent038dcdd6d54c0c0866ddcaeffb19846095f4c554 (diff)
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 <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit 5db9b33dadda67c7f97d8c23df17211fae380919) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125841 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/uitest/calc_tests8/tdf144940.py72
-rw-r--r--sc/source/filter/xml/XMLTableHeaderFooterContext.cxx11
2 files changed, 78 insertions, 5 deletions
diff --git a/sc/qa/uitest/calc_tests8/tdf144940.py b/sc/qa/uitest/calc_tests8/tdf144940.py
new file mode 100644
index 000000000000..1f3d34b51219
--- /dev/null
+++ b/sc/qa/uitest/calc_tests8/tdf144940.py
@@ -0,0 +1,72 @@
+# -*- 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")
+
+ calc_doc = self.ui_test.create_doc_in_start_center("calc")
+
+ self.ui_test.execute_dialog_through_command(".uno:PageFormatDialog")
+ xDialog = self.xUITest.getTopFocusWindow()
+ 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"])
+
+ xOkBtn = xDialog.getChild("ok")
+ self.ui_test.close_dialog_through_button(xOkBtn)
+
+ self.ui_test.execute_dialog_through_command(".uno:Save")
+ xSaveDialog = self.xUITest.getTopFocusWindow()
+ xFileName = xSaveDialog.getChild("file_name")
+ xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+ xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+ xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath}))
+
+ xOkBtn = xSaveDialog.getChild("open")
+ self.ui_test.close_dialog_through_button(xOkBtn)
+
+ self.ui_test.close_doc()
+
+ self.ui_test.load_file(systemPathToFileUrl(xFilePath))
+ document = self.ui_test.get_component()
+
+ 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)
+
+ self.ui_test.close_doc()
+
+# 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