include/svtools/editbrowsebox.hxx     |   27 +++++++++++++++++++++--
 svtools/source/brwbox/ebbcontrols.cxx |   10 ++++++--
 svx/source/fmcomp/gridcell.cxx        |   39 +++++++++++++++++++++-------------
 svx/source/inc/gridcell.hxx           |    9 +++----
 4 files changed, 62 insertions(+), 23 deletions(-)

New commits:
commit 23c965a299315398c0931ecefbca49824cc21261
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Aug 14 16:26:52 2020 +0100
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Thu Aug 20 13:07:27 2020 +0200

    tdf#135550 make XComboBox Item status changed event work again
    
    Change-Id: I323a114d3b71a74267ee7a89c5fb29821611e57e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100704
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@cib.de>

diff --git a/include/svtools/editbrowsebox.hxx 
b/include/svtools/editbrowsebox.hxx
index 2e9c7cb891cb..61deadfdd4fa 100644
--- a/include/svtools/editbrowsebox.hxx
+++ b/include/svtools/editbrowsebox.hxx
@@ -319,6 +319,11 @@ namespace svt
     //= ComboBoxControl
     class SVT_DLLPUBLIC ComboBoxControl final : public InterimItemWindow
     {
+    private:
+        std::unique_ptr<weld::ComboBox> m_xWidget;
+        Link<LinkParamNone*,void> m_aModify1Hdl;
+        Link<LinkParamNone*,void> m_aModify2Hdl;
+
         friend class ComboBoxCellController;
 
     public:
@@ -326,10 +331,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
@@ -346,7 +369,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 2c6291fd3f7e..4d4fc8ea72cf 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -32,6 +32,7 @@ namespace svt
         , m_xWidget(m_xBuilder->weld_combo_box("combobox"))
     {
         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()
@@ -40,14 +41,19 @@ namespace svt
         InterimItemWindow::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 fcbb633fb003..8811f7ce29e1 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -4031,10 +4031,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()
@@ -4053,7 +4053,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();
@@ -4105,7 +4105,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 )
@@ -4113,10 +4114,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++;
     }
@@ -4127,8 +4129,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()
@@ -4136,7 +4139,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 )
@@ -4144,7 +4148,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()
@@ -4154,11 +4159,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;
 }
@@ -4175,9 +4181,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;
@@ -4185,8 +4196,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 2e43144fcb1d..eebfbab4cc6f 100644
--- a/svx/source/inc/gridcell.hxx
+++ b/svx/source/inc/gridcell.hxx
@@ -977,18 +977,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:
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to