sc/source/ui/miscdlgs/mergecellsdialog.cxx |   28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

New commits:
commit 913854864096605bcea23a6174834fb5750ddad0
Author:     anonymotter <kste...@csumb.edu>
AuthorDate: Wed Nov 27 20:29:04 2024 -0800
Commit:     Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org>
CommitDate: Wed Dec 4 11:08:05 2024 +0100

    tdf#158979 Add static variable for last used merge option
    
    A static variable has been added so that, when merging cells in Calc
    where multiple cells have content in them, it will remember which of the 
three
    merge options was last used in a given session and automatically select that
    option the next time the merge cells dialog pops up. The default for the 
first
    merge in a session remains the option to keep the content of hidden cells.
    
    Change-Id: I35f6c01ffe9dff2756e3b9f5d530725e5d939db8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177455
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>

diff --git a/sc/source/ui/miscdlgs/mergecellsdialog.cxx 
b/sc/source/ui/miscdlgs/mergecellsdialog.cxx
index cedcf6777b46..0c365f9bb773 100644
--- a/sc/source/ui/miscdlgs/mergecellsdialog.cxx
+++ b/sc/source/ui/miscdlgs/mergecellsdialog.cxx
@@ -10,6 +10,8 @@
 
 #include <mergecellsdialog.hxx>
 
+static ScMergeCellsOption lastUsedMergeCellsOption = KeepContentHiddenCells;
+
 ScMergeCellsDialog::ScMergeCellsDialog(weld::Window* pParent)
     : GenericDialogController(pParent, 
u"modules/scalc/ui/mergecellsdialog.ui"_ustr,
                               u"MergeCellsDialog"_ustr)
@@ -17,7 +19,18 @@ ScMergeCellsDialog::ScMergeCellsDialog(weld::Window* pParent)
     , 
m_xRBKeepContent(m_xBuilder->weld_radio_button(u"keep-content-radio"_ustr))
     , 
m_xRBEmptyContent(m_xBuilder->weld_radio_button(u"empty-cells-radio"_ustr))
 {
-    m_xRBKeepContent->set_active(true);
+    if (lastUsedMergeCellsOption == MoveContentHiddenCells)
+    {
+        m_xRBMoveContent->set_active(true);
+    }
+    else if (lastUsedMergeCellsOption == KeepContentHiddenCells)
+    {
+        m_xRBKeepContent->set_active(true);
+    }
+    else if (lastUsedMergeCellsOption == EmptyContentHiddenCells)
+    {
+        m_xRBEmptyContent->set_active(true);
+    }
 }
 
 ScMergeCellsDialog::~ScMergeCellsDialog() {}
@@ -25,11 +38,20 @@ ScMergeCellsDialog::~ScMergeCellsDialog() {}
 ScMergeCellsOption ScMergeCellsDialog::GetMergeCellsOption() const
 {
     if (m_xRBMoveContent->get_active())
+    {
+        lastUsedMergeCellsOption = MoveContentHiddenCells;
         return MoveContentHiddenCells;
-    if (m_xRBKeepContent->get_active())
+    }
+    else if (m_xRBKeepContent->get_active())
+    {
+        lastUsedMergeCellsOption = KeepContentHiddenCells;
         return KeepContentHiddenCells;
-    if (m_xRBEmptyContent->get_active())
+    }
+    else if (m_xRBEmptyContent->get_active())
+    {
+        lastUsedMergeCellsOption = EmptyContentHiddenCells;
         return EmptyContentHiddenCells;
+    }
     assert(!"Unknown selection for merge cells.");
     return KeepContentHiddenCells; // default value
 }

Reply via email to