[Libreoffice-commits] core.git: include/svtools svx/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 22 20:00:11 UTC 2021


 include/svtools/editbrowsebox.hxx |   26 +++++++++++++++++++-------
 svx/source/fmcomp/gridcell.cxx    |   26 ++++++++++++++++++--------
 svx/source/inc/gridcell.hxx       |    4 ++--
 3 files changed, 39 insertions(+), 17 deletions(-)

New commits:
commit 8df14a82cee4fe0c4ca6f994c7c3f92373b411a3
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Jan 22 16:29:34 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Jan 22 20:59:28 2021 +0100

    tdf#135550 ListBox should triger an event when changed non-interactively
    
    not just when changed by the user
    
    Change-Id: If2238341ff8465fee6375dad1ea9b4d7ec0110e6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109827
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx
index 46a35c203e96..34696522bd78 100644
--- a/include/svtools/editbrowsebox.hxx
+++ b/include/svtools/editbrowsebox.hxx
@@ -566,7 +566,7 @@ namespace svt
     private:
         std::unique_ptr<weld::ComboBox> m_xWidget;
         Link<LinkParamNone*,void> m_aModify1Hdl;
-        Link<LinkParamNone*,void> m_aModify2Hdl;
+        Link<bool,void> m_aModify2Hdl;
 
         friend class ComboBoxCellController;
 
@@ -587,11 +587,17 @@ namespace svt
         }
 
         // sets an additional link to call when the selection is changed by the user
-        void SetAuxModifyHdl(const Link<LinkParamNone*,void>& rLink)
+        // bool arg is true when triggered interactively by the user
+        void SetAuxModifyHdl(const Link<bool,void>& rLink)
         {
             m_aModify2Hdl = rLink;
         }
 
+        void TriggerAuxModify()
+        {
+            m_aModify2Hdl.Call(false);
+        }
+
         virtual void dispose() override;
 
     private:
@@ -600,7 +606,7 @@ namespace svt
         void CallModifyHdls()
         {
             m_aModify1Hdl.Call(nullptr);
-            m_aModify2Hdl.Call(nullptr);
+            m_aModify2Hdl.Call(true);
         }
     };
 
@@ -627,7 +633,7 @@ namespace svt
     private:
         std::unique_ptr<weld::ComboBox> m_xWidget;
         Link<LinkParamNone*,void> m_aModify1Hdl;
-        Link<LinkParamNone*,void> m_aModify2Hdl;
+        Link<bool,void> m_aModify2Hdl;
 
         friend class ListBoxCellController;
 
@@ -642,12 +648,18 @@ namespace svt
             m_aModify1Hdl = rHdl;
         }
 
-        // sets an additional link to call when the selection is changed by the user
-        void SetAuxModifyHdl(const Link<LinkParamNone*,void>& rLink)
+        // sets an additional link to call when the selection is changed,
+        // bool arg is true when triggered interactively by the user
+        void SetAuxModifyHdl(const Link<bool,void>& rLink)
         {
             m_aModify2Hdl = rLink;
         }
 
+        void TriggerAuxModify()
+        {
+            m_aModify2Hdl.Call(false);
+        }
+
         virtual void dispose() override;
     private:
         DECL_LINK(SelectHdl, weld::ComboBox&, void);
@@ -655,7 +667,7 @@ namespace svt
         void CallModifyHdls()
         {
             m_aModify1Hdl.Call(nullptr);
-            m_aModify2Hdl.Call(nullptr);
+            m_aModify2Hdl.Call(true);
         }
     };
 
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 299c5926df4e..ed5d851bf7ad 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -2445,8 +2445,13 @@ void DbComboBox::updateFromModel( Reference< XPropertySet > _rxModel )
 
     ComboBoxControl* pControl = static_cast<ComboBoxControl*>(m_pWindow.get());
     weld::ComboBox& rComboBox = pControl->get_widget();
+
+    OUString sOldActive = rComboBox.get_active_text();
     rComboBox.set_entry_text(sText);
     rComboBox.select_entry_region(0, -1);
+
+    if (sOldActive != rComboBox.get_active_text())
+        pControl->TriggerAuxModify();
 }
 
 bool DbComboBox::commitControl()
@@ -2577,12 +2582,17 @@ void DbListBox::updateFromModel( Reference< XPropertySet > _rxModel )
     if ( aSelection.hasElements() )
         nSelection = aSelection[ 0 ];
 
-    weld::ComboBox& rComboBox = static_cast<ListBoxControl*>(m_pWindow.get())->get_widget();
+    ListBoxControl* pControl = static_cast<ListBoxControl*>(m_pWindow.get());
+    weld::ComboBox& rComboBox = pControl->get_widget();
 
+    int nOldActive = rComboBox.get_active();
     if (nSelection >= 0 && nSelection < rComboBox.get_count())
         rComboBox.set_active(nSelection);
     else
         rComboBox.set_active(-1);
+
+    if (nOldActive != rComboBox.get_active())
+        pControl->TriggerAuxModify();
 }
 
 bool DbListBox::commitControl()
@@ -2784,7 +2794,7 @@ void DbFilterField::updateFromModel( Reference< XPropertySet > _rxModel )
 {
     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbFilterField::updateFromModel: invalid call!" );
 
-    OSL_FAIL( "DbListBox::updateFromModel: not implemented yet (how the hell did you reach this?)!" );
+    OSL_FAIL( "DbFilterField::updateFromModel: not implemented yet (how the hell did you reach this?)!" );
     // TODO: implement this.
     // remember: updateFromModel should be some kind of opposite of commitControl
 }
@@ -3916,7 +3926,7 @@ void FmXListBoxCell::disposing()
     m_aItemListeners.disposeAndClear(aEvt);
     m_aActionListeners.disposeAndClear(aEvt);
 
-    m_pBox->SetAuxModifyHdl(Link<LinkParamNone*,void>());
+    m_pBox->SetAuxModifyHdl(Link<bool,void>());
     m_pBox = nullptr;
 
     FmXTextCell::disposing();
@@ -4184,14 +4194,14 @@ void SAL_CALL FmXListBoxCell::makeVisible(sal_Int16 /*nEntry*/)
 {
 }
 
-IMPL_LINK_NOARG(FmXListBoxCell, ChangedHdl, LinkParamNone*, void)
+IMPL_LINK(FmXListBoxCell, ChangedHdl, bool, bInteractive, void)
 {
     if (!m_pBox)
         return;
 
     weld::ComboBox& rBox = m_pBox->get_widget();
 
-    if (!rBox.changed_by_direct_pick())
+    if (bInteractive && !rBox.changed_by_direct_pick())
         return;
 
     OnDoubleClick();
@@ -4246,7 +4256,7 @@ void FmXComboBoxCell::disposing()
     m_aItemListeners.disposeAndClear(aEvt);
     m_aActionListeners.disposeAndClear(aEvt);
 
-    m_pComboBox->SetAuxModifyHdl(Link<LinkParamNone*,void>());
+    m_pComboBox->SetAuxModifyHdl(Link<bool,void>());
     m_pComboBox = nullptr;
 
     FmXTextCell::disposing();
@@ -4374,14 +4384,14 @@ void SAL_CALL FmXComboBoxCell::setDropDownLineCount(sal_Int16 nLines)
     m_nLines = nLines; // just store it to return it
 }
 
-IMPL_LINK_NOARG(FmXComboBoxCell, ChangedHdl, LinkParamNone*, void)
+IMPL_LINK(FmXComboBoxCell, ChangedHdl, bool, bInteractive, void)
 {
     if (!m_pComboBox)
         return;
 
     weld::ComboBox& rComboBox = m_pComboBox->get_widget();
 
-    if (!rComboBox.changed_by_direct_pick())
+    if (bInteractive && !rComboBox.changed_by_direct_pick())
         return;
 
     awt::ItemEvent aEvent;
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
index 4e510e59d5e7..3966a4954a15 100644
--- a/svx/source/inc/gridcell.hxx
+++ b/svx/source/inc/gridcell.hxx
@@ -983,7 +983,7 @@ public:
 private:
     virtual ~FmXListBoxCell() override;
 
-    DECL_LINK(ChangedHdl, LinkParamNone*, void);
+    DECL_LINK(ChangedHdl, bool, void);
 
     void OnDoubleClick();
 
@@ -1006,7 +1006,7 @@ private:
     VclPtr<::svt::ComboBoxControl> m_pComboBox;
     sal_uInt16 m_nLines;
 
-    DECL_LINK(ChangedHdl, LinkParamNone*, void);
+    DECL_LINK(ChangedHdl, bool, void);
 
     virtual ~FmXComboBoxCell() override;
 


More information about the Libreoffice-commits mailing list