diff options
author | Daniel Arato (NISZ) <arato.daniel@nisz.hu> | 2021-02-22 16:59:38 +0100 |
---|---|---|
committer | Balazs Varga <varga.balazs3@nisz.hu> | 2021-03-17 13:10:27 +0100 |
commit | 8d8486f43c1a8a51157bfc3e0b87090b05a9229e (patch) | |
tree | 1321f23e4480341338f979f08fce6cdf46030f85 /sw/qa | |
parent | 262c07d2b733543dd895b92325b36ce093226f26 (diff) |
tdf#46561 sw: fix lost undo stack setting header/footer
Changing 'shared' setting of left vs right or
first vs non-first page headers or footers removed
the whole undo stack.
Note: style changes before a 'shared' change
can still not be undone.
Co-authored-by: Attila Bakos (NISZ)
Change-Id: I6875bd0581869ffeb853911347dbc9f8c666214b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111635
Reviewed-by: László Németh <nemeth@numbertext.org>
Reviewed-by: Balazs Varga <varga.balazs3@nisz.hu>
Tested-by: Balazs Varga <varga.balazs3@nisz.hu>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 4 | ||||
-rw-r--r-- | sw/qa/uitest/data/tdf46561.odt | bin | 0 -> 8798 bytes | |||
-rw-r--r-- | sw/qa/uitest/writer_tests7/tdf46561.py | 105 |
3 files changed, 108 insertions, 1 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index c39659fa9bab..dae657a35088 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -2225,7 +2225,9 @@ void SwUiWriterTest::testTextCursorInvalidation() // this does not actually delete the header: xPageStyle->setPropertyValue("HeaderIsOn", uno::makeAny(false)); pWrtShell->ChangeHeaderOrFooter(u"Default Page Style", true, false, false); // must be disposed after deleting header - CPPUNIT_ASSERT_THROW(xCursor->goRight(1, false), uno::RuntimeException); + // cursor ends up in body + // UPDATE: this behaviour has been corrected as a side effect of the fix to tdf#46561: + //CPPUNIT_ASSERT_THROW(xCursor->goRight(1, false), uno::RuntimeException); } void SwUiWriterTest::testTdf68183() diff --git a/sw/qa/uitest/data/tdf46561.odt b/sw/qa/uitest/data/tdf46561.odt Binary files differnew file mode 100644 index 000000000000..c9f9942521d0 --- /dev/null +++ b/sw/qa/uitest/data/tdf46561.odt diff --git a/sw/qa/uitest/writer_tests7/tdf46561.py b/sw/qa/uitest/writer_tests7/tdf46561.py new file mode 100644 index 000000000000..235136524903 --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf46561.py @@ -0,0 +1,105 @@ +# -*- 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 libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import type_text +import importlib +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf46561(UITestCase): + def check_header_texts(self, master="", first="", left="", right=""): + # Get the current header style and its text contents + xPageStyle = self.document.getStyleFamilies().getByIndex(2) + xHeaderText = xPageStyle.getByIndex(0).HeaderText.String + xHeaderTextFirst = xPageStyle.getByIndex(0).HeaderTextFirst.String + xHeaderTextLeft = xPageStyle.getByIndex(0).HeaderTextLeft.String + xHeaderTextRight = xPageStyle.getByIndex(0).HeaderTextRight.String + + # Check the current values + self.assertEqual(master, xHeaderText) + self.assertEqual(first, xHeaderTextFirst) + self.assertEqual(left, xHeaderTextLeft) + self.assertEqual(right, xHeaderTextRight) + + def test_tdf46561(self): + self.ui_test.load_file(get_url_for_data_file("tdf46561.odt")) + self.document = self.ui_test.get_component() + self.check_header_texts(master="right", first="1st", left="left", right="right") + + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "2"})) + self.xUITest.executeCommand(".uno:JumpToHeader") + + # Switch "same left and right page headers" on and off a few times + for _ in range(4): + self.ui_test.execute_dialog_through_command(".uno:PageDialog") + PageDialog = self.xUITest.getTopFocusWindow(); + + xTabs = PageDialog.getChild("tabcontrol") + select_pos(xTabs, "4") + + Button = xTabs.getChild('checkSameLR') + Button.executeAction("CLICK",tuple()) + ok = PageDialog.getChild("ok") + self.ui_test.close_dialog_through_button(ok) + + # We should be back to the starting state after 2*k on/off changes + self.check_header_texts(master="right", first="1st", left="left", right="right") + + # Enter some additional text in the left page header + type_text(xWriterEdit, "XXXX") + self.check_header_texts(master="right", first="1st", left="XXXXleft", right="right") + + # Now go back one change (before entering "XXXX") + self.xUITest.executeCommand(".uno:Undo") + self.check_header_texts(master="right", first="1st", left="left", right="right") + + # Undo the fourth change + self.xUITest.executeCommand(".uno:Undo") + self.check_header_texts(master="right", first="1st", left="right", right="right") + + # Undo the third change + self.xUITest.executeCommand(".uno:Undo") + self.check_header_texts(master="right", first="1st", left="left", right="right") + + # Undo the second change + self.xUITest.executeCommand(".uno:Undo") + self.check_header_texts(master="right", first="1st", left="right", right="right") + + # Undo the first change + self.xUITest.executeCommand(".uno:Undo") + self.check_header_texts(master="right", first="1st", left="left", right="right") + + # Redo the first change + self.xUITest.executeCommand(".uno:Redo") + self.check_header_texts(master="right", first="1st", left="right", right="right") + + # Redo the second change + self.xUITest.executeCommand(".uno:Redo") + self.check_header_texts(master="right", first="1st", left="left", right="right") + + # Redo the third change + self.xUITest.executeCommand(".uno:Redo") + self.check_header_texts(master="right", first="1st", left="right", right="right") + + # Redo the fourth change + self.xUITest.executeCommand(".uno:Redo") + self.check_header_texts(master="right", first="1st", left="left", right="right") + + # Redo the final change + self.xUITest.executeCommand(".uno:Redo") + self.check_header_texts(master="right", first="1st", left="XXXXleft", right="right") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |