summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-08-14 16:26:52 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-08-16 18:04:37 +0200
commit704297ed099e1732db360669abe2443d24f6c252 (patch)
treeea71f7fd8fb203ef65dd15c6cf4eb5dfb2a2fece
parent737343cbe43cd7010d12cf7aba4a2042798aeb70 (diff)
tdf#135550 make XComboBox Item status changed event work again
Change-Id: I323a114d3b71a74267ee7a89c5fb29821611e57e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100751 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.cxx39
-rw-r--r--svx/source/inc/gridcell.hxx9
4 files changed, 62 insertions, 23 deletions
diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx
index 9e851acf9a3f..a4a4ee182ee0 100644
--- a/include/svtools/editbrowsebox.hxx
+++ b/include/svtools/editbrowsebox.hxx
@@ -563,6 +563,11 @@ namespace svt
//= ComboBoxControl
class SVT_DLLPUBLIC ComboBoxControl final : public ControlBase
{
+ private:
+ std::unique_ptr<weld::ComboBox> m_xWidget;
+ Link<LinkParamNone*,void> m_aModify1Hdl;
+ Link<LinkParamNone*,void> m_aModify2Hdl;
+
friend class ComboBoxCellController;
public:
@@ -575,10 +580,28 @@ 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);
+ }
};
//= ComboBoxCellController
@@ -595,7 +618,7 @@ namespace svt
protected:
virtual bool MoveAllowed(const KeyEvent& rEvt) const override;
private:
- DECL_LINK(ModifyHdl, weld::ComboBox&, void);
+ DECL_LINK(ModifyHdl, LinkParamNone*, void);
};
//= ListBoxControl
diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index d08b83fef214..ccc74f84e659 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -29,6 +29,7 @@ namespace svt
{
InitControlBase(m_xWidget.get());
m_xWidget->set_entry_width_chars(1); // so a smaller than default width can be used
+ m_xWidget->connect_changed(LINK(this, ComboBoxControl, SelectHdl));
}
void ComboBoxControl::dispose()
@@ -37,14 +38,19 @@ namespace svt
ControlBase::dispose();
}
+ IMPL_LINK_NOARG(ComboBoxControl, SelectHdl, weld::ComboBox&, void)
+ {
+ CallModifyHdls();
+ }
+
//= ComboBoxCellController
ComboBoxCellController::ComboBoxCellController(ComboBoxControl* pWin)
:CellController(pWin)
{
- GetComboBox().connect_changed(LINK(this, ComboBoxCellController, ModifyHdl));
+ static_cast<ComboBoxControl&>(GetWindow()).SetModifyHdl(LINK(this, ComboBoxCellController, ModifyHdl));
}
- IMPL_LINK_NOARG(ComboBoxCellController, ModifyHdl, weld::ComboBox&, void)
+ IMPL_LINK_NOARG(ComboBoxCellController, ModifyHdl, LinkParamNone*, void)
{
callModifyHdl();
}
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 58c46c9a6f27..d08bd5a79d72 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -4225,10 +4225,10 @@ FmXComboBoxCell::FmXComboBoxCell( DbGridColumn* pColumn, std::unique_ptr<DbCellC
:FmXTextCell( pColumn, std::move(pControl) )
,m_aItemListeners( m_aMutex )
,m_aActionListeners( m_aMutex )
- ,m_pComboBox(&static_cast<ComboBoxControl&>(m_pCellControl->GetWindow()).get_widget())
+ ,m_pComboBox(&static_cast<ComboBoxControl&>(m_pCellControl->GetWindow()))
,m_nLines(Application::GetSettings().GetStyleSettings().GetListBoxMaximumLineCount())
{
- m_pComboBox->connect_changed(LINK(this, FmXComboBoxCell, ChangedHdl));
+ m_pComboBox->SetAuxModifyHdl(LINK(this, FmXComboBoxCell, ChangedHdl));
}
FmXComboBoxCell::~FmXComboBoxCell()
@@ -4247,7 +4247,7 @@ void FmXComboBoxCell::disposing()
m_aItemListeners.disposeAndClear(aEvt);
m_aActionListeners.disposeAndClear(aEvt);
- m_pComboBox->connect_changed( Link<weld::ComboBox&,void>() );
+ m_pComboBox->SetAuxModifyHdl(Link<LinkParamNone*,void>());
m_pComboBox = nullptr;
FmXTextCell::disposing();
@@ -4299,7 +4299,8 @@ void SAL_CALL FmXComboBoxCell::addItem( const OUString& Item, sal_Int16 Pos )
::osl::MutexGuard aGuard( m_aMutex );
if (!m_pComboBox)
return;
- m_pComboBox->insert_text(Pos, Item);
+ weld::ComboBox& rBox = m_pComboBox->get_widget();
+ rBox.insert_text(Pos, Item);
}
void SAL_CALL FmXComboBoxCell::addItems( const Sequence< OUString >& Items, sal_Int16 Pos )
@@ -4307,10 +4308,11 @@ void SAL_CALL FmXComboBoxCell::addItems( const Sequence< OUString >& Items, sal_
::osl::MutexGuard aGuard( m_aMutex );
if (!m_pComboBox)
return;
+ weld::ComboBox& rBox = m_pComboBox->get_widget();
sal_uInt16 nP = Pos;
for ( const auto& rItem : Items )
{
- m_pComboBox->insert_text(nP, rItem);
+ rBox.insert_text(nP, rItem);
if ( Pos != -1 )
nP++;
}
@@ -4321,8 +4323,9 @@ void SAL_CALL FmXComboBoxCell::removeItems( sal_Int16 Pos, sal_Int16 Count )
::osl::MutexGuard aGuard( m_aMutex );
if (!m_pComboBox)
return;
+ weld::ComboBox& rBox = m_pComboBox->get_widget();
for ( sal_uInt16 n = Count; n; )
- m_pComboBox->remove( Pos + (--n) );
+ rBox.remove( Pos + (--n) );
}
sal_Int16 SAL_CALL FmXComboBoxCell::getItemCount()
@@ -4330,7 +4333,8 @@ sal_Int16 SAL_CALL FmXComboBoxCell::getItemCount()
::osl::MutexGuard aGuard( m_aMutex );
if (!m_pComboBox)
return 0;
- return m_pComboBox->get_count();
+ weld::ComboBox& rBox = m_pComboBox->get_widget();
+ return rBox.get_count();
}
OUString SAL_CALL FmXComboBoxCell::getItem( sal_Int16 Pos )
@@ -4338,7 +4342,8 @@ OUString SAL_CALL FmXComboBoxCell::getItem( sal_Int16 Pos )
::osl::MutexGuard aGuard( m_aMutex );
if (!m_pComboBox)
return OUString();
- return m_pComboBox->get_text(Pos);
+ weld::ComboBox& rBox = m_pComboBox->get_widget();
+ return rBox.get_text(Pos);
}
Sequence< OUString > SAL_CALL FmXComboBoxCell::getItems()
@@ -4348,11 +4353,12 @@ Sequence< OUString > SAL_CALL FmXComboBoxCell::getItems()
Sequence< OUString > aItems;
if (m_pComboBox)
{
- const sal_Int32 nEntries = m_pComboBox->get_count();
+ weld::ComboBox& rBox = m_pComboBox->get_widget();
+ const sal_Int32 nEntries = rBox.get_count();
aItems.realloc( nEntries );
OUString* pItem = aItems.getArray();
for ( sal_Int32 n=0; n<nEntries; ++n, ++pItem )
- *pItem = m_pComboBox->get_text(n);
+ *pItem = rBox.get_text(n);
}
return aItems;
}
@@ -4369,9 +4375,14 @@ void SAL_CALL FmXComboBoxCell::setDropDownLineCount(sal_Int16 nLines)
m_nLines = nLines; // just store it to return it
}
-IMPL_LINK_NOARG(FmXComboBoxCell, ChangedHdl, weld::ComboBox&, void)
+IMPL_LINK_NOARG(FmXComboBoxCell, ChangedHdl, LinkParamNone*, void)
{
- if (!m_pComboBox || !m_pComboBox->changed_by_direct_pick())
+ if (!m_pComboBox)
+ return;
+
+ weld::ComboBox& rComboBox = m_pComboBox->get_widget();
+
+ if (!rComboBox.changed_by_direct_pick())
return;
awt::ItemEvent aEvent;
@@ -4379,8 +4390,8 @@ IMPL_LINK_NOARG(FmXComboBoxCell, ChangedHdl, weld::ComboBox&, void)
aEvent.Highlighted = 0;
// with invalid selection 0xFFFF, otherwise the position
- aEvent.Selected = ( m_pComboBox->get_active() != -1 )
- ? m_pComboBox->get_active()
+ aEvent.Selected = ( rComboBox.get_active() != -1 )
+ ? rComboBox.get_active()
: 0xFFFF;
m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
}
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
index 48b005c199e3..931bd28e2640 100644
--- a/svx/source/inc/gridcell.hxx
+++ b/svx/source/inc/gridcell.hxx
@@ -997,18 +997,17 @@ private:
typedef ::cppu::ImplHelper1 < css::awt::XComboBox
> FmXComboBoxCell_Base;
-class FmXComboBoxCell :public FmXTextCell
- ,public FmXComboBoxCell_Base
+class FmXComboBoxCell final : public FmXTextCell
+ , public FmXComboBoxCell_Base
{
private:
::comphelper::OInterfaceContainerHelper2 m_aItemListeners,
m_aActionListeners;
- weld::ComboBox* m_pComboBox;
+ VclPtr<::svt::ComboBoxControl> m_pComboBox;
sal_uInt16 m_nLines;
- DECL_LINK(ChangedHdl, weld::ComboBox&, void);
+ DECL_LINK(ChangedHdl, LinkParamNone*, void);
-protected:
virtual ~FmXComboBoxCell() override;
public: