summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-08-14 14:41:35 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-08-14 17:27:37 +0200
commit937f800cdb644b22b4c7bd18b35a8940bcede7ce (patch)
treec69f7de9436d4c72718e063ba7607332fa9aa2ab
parent7bb20ab2e84cf4d84d24bfcd8103946e92f2ae06 (diff)
tdf#135550 make XListBox Item status changed event work again
Change-Id: I9a5fe6a097c5d06e3ac3ab6c4c77cbe082d1a17d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100745 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/svtools/editbrowsebox.hxx27
-rw-r--r--svtools/source/brwbox/ebbcontrols.cxx10
-rw-r--r--svx/source/fmcomp/gridcell.cxx23
-rw-r--r--svx/source/inc/gridcell.hxx6
4 files changed, 50 insertions, 16 deletions
diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx
index 725cc081d044..9e851acf9a3f 100644
--- a/include/svtools/editbrowsebox.hxx
+++ b/include/svtools/editbrowsebox.hxx
@@ -601,6 +601,11 @@ namespace svt
//= ListBoxControl
class SVT_DLLPUBLIC ListBoxControl final : public ControlBase
{
+ private:
+ std::unique_ptr<weld::ComboBox> m_xWidget;
+ Link<LinkParamNone*,void> m_aModify1Hdl;
+ Link<LinkParamNone*,void> m_aModify2Hdl;
+
friend class ListBoxCellController;
public:
@@ -608,9 +613,27 @@ namespace svt
weld::ComboBox& get_widget() { return *m_xWidget; }
+ // sets a link to call when the selection is changed by the user
+ void SetModifyHdl(const Link<LinkParamNone*,void>& rHdl)
+ {
+ m_aModify1Hdl = rHdl;
+ }
+
+ // sets an additional link to call when the selection is changed by the user
+ void SetAuxModifyHdl(const Link<LinkParamNone*,void>& rLink)
+ {
+ m_aModify2Hdl = rLink;
+ }
+
virtual void dispose() override;
private:
- std::unique_ptr<weld::ComboBox> m_xWidget;
+ DECL_LINK(SelectHdl, weld::ComboBox&, void);
+
+ void CallModifyHdls()
+ {
+ m_aModify1Hdl.Call(nullptr);
+ m_aModify2Hdl.Call(nullptr);
+ }
};
//= ListBoxCellController
@@ -627,7 +650,7 @@ namespace svt
protected:
virtual bool MoveAllowed(const KeyEvent& rEvt) const override;
private:
- DECL_LINK(ListBoxSelectHdl, weld::ComboBox&, void);
+ DECL_LINK(ListBoxSelectHdl, LinkParamNone*, void);
};
class SVT_DLLPUBLIC FormattedControlBase : public EditControlBase
diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index 1ac4605a3096..d08b83fef214 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -107,6 +107,7 @@ namespace svt
{
InitControlBase(m_xWidget.get());
m_xWidget->set_size_request(42, -1); // so a later narrow size request can stick
+ m_xWidget->connect_changed(LINK(this, ListBoxControl, SelectHdl));
}
void ListBoxControl::dispose()
@@ -115,11 +116,16 @@ namespace svt
ControlBase::dispose();
}
+ IMPL_LINK_NOARG(ListBoxControl, SelectHdl, weld::ComboBox&, void)
+ {
+ CallModifyHdls();
+ }
+
//= ListBoxCellController
ListBoxCellController::ListBoxCellController(ListBoxControl* pWin)
:CellController(pWin)
{
- GetListBox().connect_changed(LINK(this, ListBoxCellController, ListBoxSelectHdl));
+ static_cast<ListBoxControl&>(GetWindow()).SetModifyHdl(LINK(this, ListBoxCellController, ListBoxSelectHdl));
}
bool ListBoxCellController::MoveAllowed(const KeyEvent& rEvt) const
@@ -157,7 +163,7 @@ namespace svt
GetListBox().save_value();
}
- IMPL_LINK_NOARG(ListBoxCellController, ListBoxSelectHdl, weld::ComboBox&, void)
+ IMPL_LINK_NOARG(ListBoxCellController, ListBoxSelectHdl, LinkParamNone*, void)
{
callModifyHdl();
}
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index ee688865530a..4bc0b5179ee9 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -3894,9 +3894,9 @@ FmXListBoxCell::FmXListBoxCell(DbGridColumn* pColumn, std::unique_ptr<DbCellCont
: FmXTextCell(pColumn, std::move(pControl))
, m_aItemListeners(m_aMutex)
, m_aActionListeners(m_aMutex)
- , m_pBox(&static_cast<svt::ListBoxControl&>(m_pCellControl->GetWindow()).get_widget())
+ , m_pBox(&static_cast<svt::ListBoxControl&>(m_pCellControl->GetWindow()))
{
- m_pBox->connect_changed(LINK(this, FmXListBoxCell, ChangedHdl));
+ m_pBox->SetAuxModifyHdl(LINK(this, FmXListBoxCell, ChangedHdl));
}
FmXListBoxCell::~FmXListBoxCell()
@@ -3915,7 +3915,7 @@ void FmXListBoxCell::disposing()
m_aItemListeners.disposeAndClear(aEvt);
m_aActionListeners.disposeAndClear(aEvt);
- m_pBox->connect_changed( Link<weld::ComboBox&,void>() );
+ m_pBox->SetAuxModifyHdl(Link<LinkParamNone*,void>());
m_pBox = nullptr;
FmXTextCell::disposing();
@@ -3923,9 +3923,14 @@ void FmXListBoxCell::disposing()
IMPLEMENT_GET_IMPLEMENTATION_ID( FmXListBoxCell )
-IMPL_LINK_NOARG(FmXListBoxCell, ChangedHdl, weld::ComboBox&, void)
+IMPL_LINK_NOARG(FmXListBoxCell, ChangedHdl, LinkParamNone*, void)
{
- if (!m_pBox || !m_pBox->changed_by_direct_pick())
+ if (!m_pBox)
+ return;
+
+ weld::ComboBox& rBox = m_pBox->get_widget();
+
+ if (!rBox.changed_by_direct_pick())
return;
OnDoubleClick();
@@ -3935,11 +3940,10 @@ IMPL_LINK_NOARG(FmXListBoxCell, ChangedHdl, weld::ComboBox&, void)
aEvent.Highlighted = 0;
// with multiple selection 0xFFFF, otherwise the ID
- aEvent.Selected = (m_pBox->get_active() != -1 )
- ? m_pBox->get_active() : 0xFFFF;
+ aEvent.Selected = (rBox.get_active() != -1 )
+ ? rBox.get_active() : 0xFFFF;
m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
- return;
}
void FmXListBoxCell::OnDoubleClick()
@@ -3948,7 +3952,8 @@ void FmXListBoxCell::OnDoubleClick()
css::awt::ActionEvent aEvent;
aEvent.Source = *this;
- aEvent.ActionCommand = m_pBox->get_active_text();
+ weld::ComboBox& rBox = m_pBox->get_widget();
+ aEvent.ActionCommand = rBox.get_active_text();
while( aIt.hasMoreElements() )
static_cast< css::awt::XActionListener *>(aIt.next())->actionPerformed( aEvent );
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
index ee40a8520549..db8883a1e997 100644
--- a/svx/source/inc/gridcell.hxx
+++ b/svx/source/inc/gridcell.hxx
@@ -940,7 +940,7 @@ public:
virtual void SAL_CALL setActionCommand( const OUString& Command ) override;
};
-class FmXListBoxCell final :public FmXTextCell
+class FmXListBoxCell final : public FmXTextCell
{
public:
FmXListBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl );
@@ -953,13 +953,13 @@ public:
private:
virtual ~FmXListBoxCell() override;
- DECL_LINK(ChangedHdl, weld::ComboBox&, void);
+ DECL_LINK(ChangedHdl, LinkParamNone*, void);
void OnDoubleClick();
::comphelper::OInterfaceContainerHelper2 m_aItemListeners,
m_aActionListeners;
- weld::ComboBox* m_pBox;
+ VclPtr<::svt::ListBoxControl> m_pBox;
};