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 227ebe934127c64fc0b8089d426b44462c7eb739 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Jan 22 16:29:34 2021 +0000 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Jan 26 10:43:15 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/+/109800 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> 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 67a17de94699..5d508a0fdedf 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -2446,8 +2446,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() @@ -2578,12 +2583,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() @@ -2785,7 +2795,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 } @@ -3917,7 +3927,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(); @@ -4185,14 +4195,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(); @@ -4247,7 +4257,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(); @@ -4375,14 +4385,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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits