include/vcl/weld.hxx           |    4 ++++
 svx/source/fmcomp/gridcell.cxx |   11 +++++++++--
 vcl/inc/salvtables.hxx         |    2 ++
 vcl/source/app/salvtables.cxx  |    2 ++
 vcl/unx/gtk3/gtkinst.cxx       |   16 +++++++++++++++-
 5 files changed, 32 insertions(+), 3 deletions(-)

New commits:
commit 07e6ed881032d1df3ec96c93f5e6c502e021eeb6
Author:     Caolán McNamara <[email protected]>
AuthorDate: Sat May 18 21:17:01 2024 +0100
Commit:     Adolfo Jayme Barrientos <[email protected]>
CommitDate: Sun May 19 20:33:05 2024 +0200

    Resolves: tdf#157453 support FM_PROP_LINECOUNT for combobox dropdow rows
    
    Change-Id: I3d18ed505c2eea7305903f9a476c332db0148113
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167814
    Tested-by: Jenkins
    Reviewed-by: Adolfo Jayme Barrientos <[email protected]>

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index fc585bdb1071..2a4e1ef084b6 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -889,6 +889,10 @@ public:
     virtual void set_max_mru_count(int nCount) = 0;
     virtual OUString get_mru_entries() const = 0;
     virtual void set_mru_entries(const OUString& rEntries) = 0;
+
+    // Backwards compatibility, should be avoided to allow
+    // UI consistency.
+    virtual void set_max_drop_down_rows(int nRows) = 0;
 };
 
 enum class ColumnToggleType
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index e8c56fb0ac38..2f17f7f3a490 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -2629,9 +2629,16 @@ void DbListBox::Init(BrowserDataWin& rParent, const 
Reference< XRowSet >& xCurso
     DbCellControl::Init( rParent, xCursor );
 }
 
-void DbListBox::implAdjustGenericFieldSetting( const Reference< XPropertySet 
>& /*rxModel*/ )
+void DbListBox::implAdjustGenericFieldSetting(const Reference<XPropertySet>& 
_rxModel)
 {
-    // ignore FM_PROP_LINECOUNT
+    DBG_ASSERT( m_pWindow, "DbListBox::implAdjustGenericFieldSetting: not to 
be called without window!" );
+    DBG_ASSERT( _rxModel.is(), "DbListBox::implAdjustGenericFieldSetting: 
invalid model!" );
+    if ( m_pWindow && _rxModel.is() )
+    {
+        sal_Int16  nLines   = getINT16( _rxModel->getPropertyValue( 
FM_PROP_LINECOUNT ) );
+        weld::ComboBox& rComboBox = 
static_cast<ListBoxControl*>(m_pWindow.get())->get_widget();
+        rComboBox.set_max_drop_down_rows(nLines);
+    }
 }
 
 CellControllerRef DbListBox::CreateController() const
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 4074e097a4f4..d6d3a90ce2e4 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -922,6 +922,8 @@ public:
         return 20 * (pDefault ? pDefault->GetDPIScaleFactor() : 1.0);
     }
 
+    void set_max_drop_down_rows(int nRows) override { 
m_xComboBox->SetDropDownLineCount(nRows); }
+
     void CallHandleEventListener(VclWindowEvent& rEvent)
     {
         if (rEvent.GetId() == VclEventId::DropdownPreOpen
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index faf645fc7943..8dc0edf814fd 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -6927,6 +6927,8 @@ public:
 
     virtual void set_mru_entries(const OUString&) override { assert(false && 
"not implemented"); }
 
+    virtual void set_max_drop_down_rows(int) override { assert(false && "not 
implemented"); }
+
     virtual void set_item_menu(const OUString&, weld::Menu*) override
     {
         assert(false && "not implemented");
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index a899fc16c606..6a06947d4cd2 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -21034,6 +21034,11 @@ public:
 #endif
     }
 
+    virtual void set_max_drop_down_rows(int) override
+    {
+        SAL_WARN( "vcl.gtk", "set_max_drop_down_rows unimplemented");
+    }
+
     virtual ~GtkInstanceComboBox() override
     {
 //        m_xCustomMenuButtonHelper.reset();
@@ -21114,6 +21119,7 @@ private:
     gint m_nPrePopupCursorPos;
     int m_nMRUCount;
     int m_nMaxMRUCount;
+    int m_nMaxDropdownRows;
 
     static gboolean idleAutoComplete(gpointer widget)
     {
@@ -21236,7 +21242,7 @@ private:
     {
         const StyleSettings& rSettings = 
Application::GetSettings().GetStyleSettings();
 
-        int nMaxRows = rSettings.GetListBoxMaximumLineCount();
+        int nMaxRows = m_nMaxDropdownRows == -1 ? 
rSettings.GetListBoxMaximumLineCount() : m_nMaxDropdownRows;
         bool bAddScrollWidth = false;
         int nRows = get_count_including_mru();
         if (nMaxRows < nRows)
@@ -22154,6 +22160,7 @@ public:
         , m_nPrePopupCursorPos(-1)
         , m_nMRUCount(0)
         , m_nMaxMRUCount(0)
+        , m_nMaxDropdownRows(-1)
     {
         int nActive = gtk_combo_box_get_active(m_pComboBox);
 
@@ -22838,6 +22845,11 @@ public:
         return nWidth;
     }
 
+    virtual void set_max_drop_down_rows(int nMaxRows) override
+    {
+        m_nMaxDropdownRows = nMaxRows;
+    }
+
     virtual ~GtkInstanceComboBox() override
     {
         m_xCustomMenuButtonHelper.reset();
@@ -23223,6 +23235,8 @@ public:
         return 0;
     }
 
+    virtual void set_max_drop_down_rows(int) override { assert(false && "not 
implemented"); }
+
     virtual ~GtkInstanceEntryTreeView() override
     {
         if (m_nAutoCompleteIdleId)

Reply via email to