sc/qa/uitest/calc_tests6/moveCopySheet.py | 32 ++++++++++++++++++++++++++---- sc/source/ui/inc/mvtabdlg.hxx | 3 ++ sc/source/ui/miscdlgs/mvtabdlg.cxx | 15 ++++++++++---- 3 files changed, 42 insertions(+), 8 deletions(-)
New commits: commit 6f67eb36d035fa3fe4103e497207452602ff993b Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Fri May 5 19:28:58 2023 +0200 Commit: Andreas Heinisch <andreas.heini...@yahoo.de> CommitDate: Sun May 7 13:39:12 2023 +0200 tdf#96854 - Remember last used option in copy/move sheet dialog Change-Id: Iebfd224091c108bb5068b716c39da0979a7ab3ac Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151437 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de> diff --git a/sc/qa/uitest/calc_tests6/moveCopySheet.py b/sc/qa/uitest/calc_tests6/moveCopySheet.py index 80bd9f830a27..5b21e6e86cb0 100644 --- a/sc/qa/uitest/calc_tests6/moveCopySheet.py +++ b/sc/qa/uitest/calc_tests6/moveCopySheet.py @@ -23,8 +23,10 @@ class moveCopySheet(UITestCase): newName.executeAction("TYPE", mkPropertyValues({"TEXT":"newName"})) #verify, the file has 2 sheets; first one "newName" is selected self.assertEqual(document.Sheets.getCount(), 2) - # dialog move/copy sheet ; Move is selected; select -move to end position - ; New Name = moveName + # dialog move/copy sheet ; Copy is selected; Select move and -move to end position - ; New Name = moveName with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: + xMoveButton = xDialog.getChild("move") + xMoveButton.executeAction("CLICK", tuple()) insertBefore = xDialog.getChild("insertBefore") xTreeEntry = insertBefore.getChild('2') @@ -76,6 +78,29 @@ class moveCopySheet(UITestCase): self.assertEqual(get_state_as_dict(xMoveButton)["Checked"], "false") self.assertEqual(get_state_as_dict(xMoveButton)["Enabled"], "false") + # tdf#96854 - remember last used option for copy/move sheet + def test_tdf96854_remember_copy_move_option(self): + with self.ui_test.create_doc_in_start_center("calc"): + # Add a second sheet to the calc document + with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: + pass + + # Check if the copy option was remembered + with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: + xCopyButton = xDialog.getChild("copy") + self.assertEqual(get_state_as_dict(xCopyButton)["Checked"], "true") + xMoveButton = xDialog.getChild("move") + self.assertEqual(get_state_as_dict(xMoveButton)["Checked"], "false") + # Move selected sheet and check if option was remembered + xMoveButton.executeAction("CLICK", tuple()) + + # Check if move option was remembered + with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: + xCopyButton = xDialog.getChild("copy") + self.assertEqual(get_state_as_dict(xCopyButton)["Checked"], "false") + xMoveButton = xDialog.getChild("move") + self.assertEqual(get_state_as_dict(xMoveButton)["Checked"], "true") + #tdf#139464 Set OK button label to selected action: Move or Copy def test_tdf139464_move_sheet(self): with self.ui_test.create_doc_in_start_center("calc"): @@ -87,11 +112,10 @@ class moveCopySheet(UITestCase): xOkButton = xDialog.getChild("ok") xCopyButton = xDialog.getChild("copy") xMoveButton = xDialog.getChild("move") - self.assertEqual(get_state_as_dict(xMoveButton)['Text'], get_state_as_dict(xOkButton)['Text']) - xCopyButton.executeAction("CLICK", tuple()) self.assertEqual(get_state_as_dict(xCopyButton)['Text'], get_state_as_dict(xOkButton)['Text']) xMoveButton.executeAction("CLICK", tuple()) self.assertEqual(get_state_as_dict(xMoveButton)['Text'], get_state_as_dict(xOkButton)['Text']) - + xCopyButton.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xCopyButton)['Text'], get_state_as_dict(xOkButton)['Text']) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx index c6e89ab9fed0..665d3cd46085 100644 --- a/sc/source/ui/inc/mvtabdlg.hxx +++ b/sc/source/ui/inc/mvtabdlg.hxx @@ -61,6 +61,9 @@ private: bool bRenameTable:1; bool mbEverEdited:1; + // tdf#96854 - remember last used option for copy/move sheet + static bool mbRememeberedCopy; + std::unique_ptr<weld::RadioButton> m_xBtnMove; std::unique_ptr<weld::RadioButton> m_xBtnCopy; std::unique_ptr<weld::Label> m_xFtDoc; diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx index e64a29b6b471..12c4e4d54bcc 100644 --- a/sc/source/ui/miscdlgs/mvtabdlg.cxx +++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx @@ -27,6 +27,9 @@ #include <comphelper/lok.hxx> #include <utility> +// tdf#96854 - remember last used option for copy/move sheet +bool ScMoveTableDlg::mbRememeberedCopy = false; + ScMoveTableDlg::ScMoveTableDlg(weld::Window* pParent, OUString aDefault) : GenericDialogController(pParent, "modules/scalc/ui/movecopysheet.ui", "MoveCopySheetDialog") , maDefaultName(std::move(aDefault)) @@ -188,8 +191,10 @@ void ScMoveTableDlg::Init() m_xBtnCopy->connect_toggled(LINK(this, ScMoveTableDlg, CheckBtnHdl)); m_xBtnMove->connect_toggled(LINK(this, ScMoveTableDlg, CheckBtnHdl)); m_xEdTabName->connect_changed(LINK(this, ScMoveTableDlg, CheckNameHdl)); - m_xBtnMove->set_active(true); - m_xBtnCopy->set_active(false); + + // tdf#96854 - remember last used option for copy/move sheet + m_xBtnMove->set_active(!mbRememeberedCopy); + m_xBtnCopy->set_active(mbRememeberedCopy); m_xEdTabName->set_sensitive(false); m_xFtWarn->hide(); InitDocListBox(); @@ -241,9 +246,11 @@ void ScMoveTableDlg::InitDocListBox() void ScMoveTableDlg::SetOkBtnLabel() { + const bool bIsCopyActive = m_xBtnCopy->get_active(); // tdf#139464 Write "Copy" or "Move" on OK button - m_xBtnOk->set_label(m_xBtnCopy->get_active() ? m_xBtnCopy->get_label() - : m_xBtnMove->get_label()); + m_xBtnOk->set_label(bIsCopyActive ? m_xBtnCopy->get_label() : m_xBtnMove->get_label()); + // tdf#96854 - remember last used option for copy/move sheet + mbRememeberedCopy = bIsCopyActive; } // Handler: