sw/qa/uitest/table/splitTable.py | 22 +++++++++++++++++++++- sw/source/ui/table/splittbl.cxx | 25 +++++++++++++++++++++++++ sw/source/uibase/inc/splittbl.hxx | 8 ++++++++ 3 files changed, 54 insertions(+), 1 deletion(-)
New commits: commit a86cbb0da80e0e05c041a8ddbd8e16df47638c73 Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Fri Apr 28 11:01:34 2023 +0200 Commit: Andreas Heinisch <andreas.heini...@yahoo.de> CommitDate: Fri May 5 15:35:22 2023 +0200 tdf#131759 - Remember last used option in split table dialog Change-Id: Id7aaa300babff988f0244d822860d455d57c86c0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151160 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de> diff --git a/sw/qa/uitest/table/splitTable.py b/sw/qa/uitest/table/splitTable.py index 2bfc4ca476ed..0292c452b187 100644 --- a/sw/qa/uitest/table/splitTable.py +++ b/sw/qa/uitest/table/splitTable.py @@ -7,7 +7,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. # from uitest.framework import UITestCase -from uitest.uihelper.common import get_url_for_data_file +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file #Writer Split Table @@ -64,4 +64,24 @@ class splitTable(UITestCase): self.xUITest.executeCommand(".uno:Undo") self.assertEqual(writer_doc.TextTables.getCount(), 1) + def test_tdf115572_remember_split_table_option(self): + with self.ui_test.load_file(get_url_for_data_file("splitTable.odt")) as writer_doc: + # Go to second row + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + + # Split table using a non default option + with self.ui_test.execute_dialog_through_command(".uno:SplitTable") as xDialog: + xRadioNoHeading = xDialog.getChild("noheading") + xRadioNoHeading.executeAction("CLICK", tuple()) + + # Reopen split table dialog and check preselection + self.xUITest.executeCommand(".uno:GoDown") + with self.ui_test.execute_dialog_through_command(".uno:SplitTable") as xDialog: + xRadioNoHeading = xDialog.getChild("noheading") + # Without the fix in place, this test would have failed with + # AssertionError: 'true' != 'false' + # i.e. the last used option in the split table dialog was not remembered + self.assertEqual("true", get_state_as_dict(xRadioNoHeading)["Checked"]) + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/ui/table/splittbl.cxx b/sw/source/ui/table/splittbl.cxx index bc33390861b1..5a7ef0ae080a 100644 --- a/sw/source/ui/table/splittbl.cxx +++ b/sw/source/ui/table/splittbl.cxx @@ -21,6 +21,9 @@ #include <splittbl.hxx> #include <tblenum.hxx> +SplitTable_HeadlineOption SwSplitTableDlg::m_eRememberedSplitOption + = SplitTable_HeadlineOption::ContentCopy; + SwSplitTableDlg::SwSplitTableDlg(weld::Window* pParent, SwWrtShell& rSh) : GenericDialogController(pParent, "modules/swriter/ui/splittable.ui", "SplitTableDialog") , m_xBoxAttrCopyWithParaRB(m_xBuilder->weld_radio_button("customheadingapplystyle")) @@ -29,6 +32,25 @@ SwSplitTableDlg::SwSplitTableDlg(weld::Window* pParent, SwWrtShell& rSh) , m_rShell(rSh) , m_nSplit(SplitTable_HeadlineOption::ContentCopy) { + // tdf#131759 - remember last used option in split table dialog + m_nSplit = m_eRememberedSplitOption; + switch (m_nSplit) + { + case SplitTable_HeadlineOption::BoxAttrAllCopy: + m_xBoxAttrCopyWithParaRB->set_active(true); + break; + case SplitTable_HeadlineOption::BoxAttrCopy: + m_xBoxAttrCopyNoParaRB->set_active(true); + break; + case SplitTable_HeadlineOption::BorderCopy: + m_xBorderCopyRB->set_active(true); + break; + case SplitTable_HeadlineOption::NONE: + case SplitTable_HeadlineOption::ContentCopy: + default: + // Use the default value in case of an invalid option + m_nSplit = SplitTable_HeadlineOption::ContentCopy; + } } void SwSplitTableDlg::Apply() @@ -41,6 +63,9 @@ void SwSplitTableDlg::Apply() else if (m_xBorderCopyRB->get_active()) m_nSplit = SplitTable_HeadlineOption::BorderCopy; + // tdf#131759 - remember last used option in split table dialog + m_eRememberedSplitOption = m_nSplit; + m_rShell.SplitTable(m_nSplit); } diff --git a/sw/source/uibase/inc/splittbl.hxx b/sw/source/uibase/inc/splittbl.hxx index 9eaef2a02901..c579eea177a9 100644 --- a/sw/source/uibase/inc/splittbl.hxx +++ b/sw/source/uibase/inc/splittbl.hxx @@ -21,6 +21,7 @@ #include <vcl/weld.hxx> #include <tblenum.hxx> +#include <unotools/viewoptions.hxx> class SwWrtShell; @@ -34,6 +35,9 @@ private: SwWrtShell& m_rShell; SplitTable_HeadlineOption m_nSplit; + // tdf#131759 - remember last used option in split table dialog + static SplitTable_HeadlineOption m_eRememberedSplitOption; + void Apply(); public: @@ -56,6 +60,10 @@ public: nSplit = SplitTable_HeadlineOption::BoxAttrCopy; else if (m_xBorderCopyRB->get_active()) nSplit = SplitTable_HeadlineOption::BorderCopy; + + // tdf#131759 - remember last used option in split table dialog + m_eRememberedSplitOption = nSplit; + return nSplit; } };