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 88ecd33f7b5a8f5ea876aef3281a086c753cae7e 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:46:11 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/+/109831 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx index 1b9fd13aa93f..54608e5cbc1f 100644 --- a/include/svtools/editbrowsebox.hxx +++ b/include/svtools/editbrowsebox.hxx @@ -335,7 +335,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; @@ -358,7 +358,8 @@ 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; } @@ -368,6 +369,11 @@ namespace svt return m_xWidget && m_xWidget->has_focus(); } + void TriggerAuxModify() + { + m_aModify2Hdl.Call(false); + } + virtual void dispose() override; private: @@ -376,7 +382,7 @@ namespace svt void CallModifyHdls() { m_aModify1Hdl.Call(nullptr); - m_aModify2Hdl.Call(nullptr); + m_aModify2Hdl.Call(true); } }; @@ -403,7 +409,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; @@ -425,8 +431,9 @@ 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; } @@ -436,6 +443,11 @@ namespace svt return m_xWidget && m_xWidget->has_focus(); } + void TriggerAuxModify() + { + m_aModify2Hdl.Call(false); + } + virtual void dispose() override; private: DECL_LINK(SelectHdl, weld::ComboBox&, void); @@ -443,7 +455,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 cc02e1a3a0a0..c03eb61d9773 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -2479,8 +2479,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() @@ -2611,12 +2616,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() @@ -2810,7 +2820,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 } @@ -3990,7 +4000,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(); @@ -4258,14 +4268,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(); @@ -4320,7 +4330,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(); @@ -4448,14 +4458,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 4fff0ef46689..13144e2f9d54 100644 --- a/svx/source/inc/gridcell.hxx +++ b/svx/source/inc/gridcell.hxx @@ -994,7 +994,7 @@ public: private: virtual ~FmXListBoxCell() override; - DECL_LINK(ChangedHdl, LinkParamNone*, void); + DECL_LINK(ChangedHdl, bool, void); void OnDoubleClick(); @@ -1017,7 +1017,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