From 689b5a4862ead541e54e83cb14067cfaa691e2ab Mon Sep 17 00:00:00 2001 From: Balazs Santha Date: Tue, 20 Jul 2021 15:54:01 +0200 Subject: tdf#143244 sw: fix redo of adding table rows breaks table style This fixes a bug, which caused the break of table style when redo of inserting table rows, Normally, upon inserting a row, the formatting of the table is updated by the UpdateTableStyleFormatting() function. In certain situations (e.g in the description of the bug) this update wasn't successful. This was beacuse, the update function didn't know which tableNode needs to be updated. As the proper tableNode we need is already calculated in the SwTable::InsertRow function, we simply had to pass this argument too. Change-Id: I81ebd7bb37eebc9be8974f3f7a1adc5ad4ba1e7d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119249 Tested-by: Jenkins Reviewed-by: Michael Stahl --- sw/qa/uitest/data/tdf143244.odt | Bin 0 -> 9831 bytes sw/qa/uitest/writer_tests7/tdf143244.py | 44 ++++++++++++++++++++++++++++++++ sw/source/core/doc/tblrwcl.cxx | 2 +- 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 sw/qa/uitest/data/tdf143244.odt create mode 100644 sw/qa/uitest/writer_tests7/tdf143244.py diff --git a/sw/qa/uitest/data/tdf143244.odt b/sw/qa/uitest/data/tdf143244.odt new file mode 100644 index 000000000000..0fd3ff915a8a Binary files /dev/null and b/sw/qa/uitest/data/tdf143244.odt differ diff --git a/sw/qa/uitest/writer_tests7/tdf143244.py b/sw/qa/uitest/writer_tests7/tdf143244.py new file mode 100644 index 000000000000..a47074396334 --- /dev/null +++ b/sw/qa/uitest/writer_tests7/tdf143244.py @@ -0,0 +1,44 @@ +# -*- 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, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +# Bug 143244 - Redo of adding table rows breaks table style after cut/paste action + + +class tdf143244(UITestCase): + def test_tdf143244(self): + with self.ui_test.load_file(get_url_for_data_file("tdf143244.odt")) as writer_doc: + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Cut") + self.xUITest.executeCommand(".uno:Paste") + self.xUITest.executeCommand(".uno:GoUp") + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + for i in range(0,6): + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + for i in range(0,4): + self.xUITest.executeCommand(".uno:Undo") + for i in range(0,4): + self.xUITest.executeCommand(".uno:Redo") + for i in range (0,3): + self.xUITest.executeCommand(".uno:GoUp") + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "4") #tab Background + btncolor = xDialog.getChild("btncolor") + btncolor.executeAction("CLICK", tuple()) + hex_custom = xDialog.getChild("hex_custom") + if i == 0: + self.assertEqual(get_state_as_dict(hex_custom)["Text"], "bee3d3") + if i == 1: + self.assertEqual(get_state_as_dict(hex_custom)["Text"], "ffffff") + if i == 2: + self.assertEqual(get_state_as_dict(hex_custom)["Text"], "dddddd") +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 6d8d86ce8f12..48ac3ea7fbc5 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -607,7 +607,7 @@ bool SwTable::InsertRow_( SwDoc* pDoc, const SwSelBoxes& rBoxes, pPCD->AddRowCols( *this, rBoxes, nCnt, bBehind ); pDoc->UpdateCharts( GetFrameFormat()->GetName() ); - pDoc->GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(); + pDoc->GetDocShell()->GetFEShell()->UpdateTableStyleFormatting(pTableNd); return true; } -- cgit