weld ComboBoxControl

Change-Id: Ie862bb782b4c3e203af88d45c850ce0cab60f2e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94123
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/dbaccess/source/ui/inc/QueryDesignView.hxx b/dbaccess/source/ui/inc/QueryDesignView.hxx
index feb1266..4f05717 100644
--- a/dbaccess/source/ui/inc/QueryDesignView.hxx
+++ b/dbaccess/source/ui/inc/QueryDesignView.hxx
@@ -28,8 +28,10 @@ namespace connectivity
{
    class OSQLParseNode;
}

class ComboBox;
namespace weld
{
    class ComboBox;
}
namespace dbaui
{
    enum SqlParseError
@@ -109,7 +111,7 @@ namespace dbaui
        void TableDeleted(const OUString& rAliasName);

        sal_Int32 getColWidth( sal_uInt16 _nColPos) const;
        void fillValidFields(const OUString& strTableName, ComboBox* pFieldList);
        void fillValidFields(const OUString& strTableName, weld::ComboBox& rFieldList);

        void SaveUIConfig();
        void stopTimer();
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index 59494bc..30afb75 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -27,7 +27,6 @@
#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <vcl/svapp.hxx>
#include <vcl/combobox.hxx>
#include <vcl/weld.hxx>
#include <browserids.hxx>
#include "SelectionBrowseBox.hxx"
@@ -2647,10 +2646,9 @@ sal_Int32 OQueryDesignView::getColWidth(sal_uInt16 _nColPos) const
    return nWidth;
}

void OQueryDesignView::fillValidFields(const OUString& sAliasName, ComboBox* pFieldList)
void OQueryDesignView::fillValidFields(const OUString& sAliasName, weld::ComboBox& rFieldList)
{
    OSL_ENSURE(pFieldList != nullptr, "OQueryDesignView::FillValidFields : What the hell do you think I can do with a NULL-ptr ? This will crash !");
    pFieldList->Clear();
    rFieldList.clear();

    bool bAllTables = sAliasName.isEmpty();

@@ -2669,9 +2667,9 @@ void OQueryDesignView::fillValidFields(const OUString& sAliasName, ComboBox* pFi
            for (auto const& field : aFields)
            {
                if (bAllTables || field.toChar() == '*')
                    pFieldList->InsertEntry(strCurrentPrefix + field);
                    rFieldList.append_text(strCurrentPrefix + field);
                else
                    pFieldList->InsertEntry(field);
                    rFieldList.append_text(field);
            }

            if (!bAllTables)
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
index a288e47..c2b4cd9 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -122,7 +122,7 @@ OSelectionBrowseBox::OSelectionBrowseBox( vcl::Window* pParent )
    m_pTextCell     = VclPtr<Edit>::Create(&GetDataWindow(), 0);
    m_pVisibleCell  = VclPtr<CheckBoxControl>::Create(&GetDataWindow());
    m_pTableCell    = VclPtr<ListBoxControl>::Create(&GetDataWindow());     m_pTableCell->SetDropDownLineCount( 20 );
    m_pFieldCell    = VclPtr<ComboBoxControl>::Create(&GetDataWindow());    m_pFieldCell->SetDropDownLineCount( 20 );
    m_pFieldCell    = VclPtr<ComboBoxControl>::Create(&GetDataWindow());
    m_pOrderCell    = VclPtr<ListBoxControl>::Create(&GetDataWindow());
    m_pFunctionCell = VclPtr<ListBoxControl>::Create(&GetDataWindow());     m_pFunctionCell->SetDropDownLineCount( 20 );

@@ -475,20 +475,21 @@ void OSelectionBrowseBox::InitController(CellControllerRef& /*rController*/, lon
    {
        case BROW_FIELD_ROW:
        {
            m_pFieldCell->Clear();
            m_pFieldCell->SetText(OUString());
            weld::ComboBox& rComboBox = m_pFieldCell->get_widget();
            rComboBox.clear();
            rComboBox.set_entry_text(OUString());

            OUString aField(pEntry->GetField());
            OUString aTable(pEntry->GetAlias());

            getDesignView()->fillValidFields(aTable, m_pFieldCell);
            getDesignView()->fillValidFields(aTable, rComboBox);

            // replace with alias.*
            if (aField.trim() == "*")
            {
                aField = aTable + ".*";
            }
            m_pFieldCell->SetText(aField);
            rComboBox.set_entry_text(aField);
        }   break;
        case BROW_TABLE_ROW:
        {
@@ -924,7 +925,8 @@ bool OSelectionBrowseBox::SaveModified()

            case BROW_FIELD_ROW:
            {
                OUString aFieldName(m_pFieldCell->GetText());
                weld::ComboBox& rComboBox = m_pFieldCell->get_widget();
                OUString aFieldName(rComboBox.get_active_text());
                try
                {
                    if (aFieldName.isEmpty())
@@ -943,9 +945,9 @@ bool OSelectionBrowseBox::SaveModified()
                        if ( !m_bInUndoMode )
                            rController.GetUndoManager().EnterListAction(OUString(),OUString(),0,ViewShellId(-1));

                        sal_Int32 nPos = m_pFieldCell->GetEntryPos(aFieldName);
                        sal_Int32 nPos = rComboBox.find_text(aFieldName);
                        OUString aAliasName = pEntry->GetAlias();
                        if ( nPos != COMBOBOX_ENTRY_NOTFOUND && aAliasName.isEmpty() && aFieldName.indexOf('.') >= 0 )
                        if ( nPos != -1 && aAliasName.isEmpty() && aFieldName.indexOf('.') >= 0 )
                        { // special case, we have a table field so we must cut the table name
                            OUString sTableAlias = aFieldName.getToken(0,'.');
                            pEntry->SetAlias(sTableAlias);
@@ -2346,8 +2348,12 @@ bool OSelectionBrowseBox::isCutAllowed() const
        case BROW_FUNCTION_ROW:
            break;
        case BROW_FIELD_ROW:
            bCutAllowed = !m_pFieldCell->GetSelected().isEmpty();
        {
            weld::ComboBox& rComboBox = m_pFieldCell->get_widget();
            int nStartPos, nEndPos;
            bCutAllowed = rComboBox.get_entry_selection_bounds(nStartPos, nEndPos);
            break;
        }
        default:
            bCutAllowed = !m_pTextCell->GetSelected().isEmpty();
            break;
@@ -2361,9 +2367,11 @@ void OSelectionBrowseBox::cut()
    switch (nRow)
    {
        case BROW_FIELD_ROW:
            m_pFieldCell->Cut();
            m_pFieldCell->SetModifyFlag();
        {
            weld::ComboBox& rComboBox = m_pFieldCell->get_widget();
            rComboBox.cut_entry_clipboard();
            break;
        }
        default:
            m_pTextCell->Cut();
            m_pTextCell->SetModifyFlag();
@@ -2380,9 +2388,11 @@ void OSelectionBrowseBox::paste()
    switch (nRow)
    {
        case BROW_FIELD_ROW:
            m_pFieldCell->Paste();
            m_pFieldCell->SetModifyFlag();
        {
            weld::ComboBox& rComboBox = m_pFieldCell->get_widget();
            rComboBox.paste_entry_clipboard();
            break;
        }
        default:
            m_pTextCell->Paste();
            m_pTextCell->SetModifyFlag();
@@ -2418,8 +2428,11 @@ void OSelectionBrowseBox::copy()
    switch (nRow)
    {
        case BROW_FIELD_ROW:
            m_pFieldCell->Copy();
        {
            weld::ComboBox& rComboBox = m_pFieldCell->get_widget();
            rComboBox.copy_entry_clipboard();
            break;
        }
        default:
            m_pTextCell->Copy();
    }
@@ -2616,7 +2629,7 @@ void OSelectionBrowseBox::setFunctionCell(OTableFieldDescRef const & _pEntry)
            OSL_ENSURE(!_pEntry->isNumeric(),"Not allowed to combine group by and numeric values!");
            m_pFunctionCell->SelectEntry(m_pFunctionCell->GetEntry(m_pFunctionCell->GetEntryCount() - 1));
        }
        else if ( m_pFunctionCell->GetEntryPos(_pEntry->GetFunction()) != COMBOBOX_ENTRY_NOTFOUND )
        else if ( m_pFunctionCell->GetEntryPos(_pEntry->GetFunction()) != LISTBOX_ENTRY_NOTFOUND )
            m_pFunctionCell->SelectEntry(_pEntry->GetFunction());
        else
            m_pFunctionCell->SelectEntryPos(0);
@@ -2633,7 +2646,7 @@ void OSelectionBrowseBox::setFunctionCell(OTableFieldDescRef const & _pEntry)
        if ( !bCountRemoved && m_pFunctionCell->GetEntryCount() < 2)
            m_pFunctionCell->InsertEntry(m_aFunctionStrings.getToken(2, ';')); // 2 -> COUNT

        if(m_pFunctionCell->GetEntryPos(_pEntry->GetFunction()) != COMBOBOX_ENTRY_NOTFOUND)
        if(m_pFunctionCell->GetEntryPos(_pEntry->GetFunction()) != LISTBOX_ENTRY_NOTFOUND)
            m_pFunctionCell->SelectEntry(_pEntry->GetFunction());
        else
            m_pFunctionCell->SelectEntryPos(0);
diff --git a/include/svtools/editbrowsebox.hxx b/include/svtools/editbrowsebox.hxx
index 71f8260f..228edb7 100644
--- a/include/svtools/editbrowsebox.hxx
+++ b/include/svtools/editbrowsebox.hxx
@@ -26,11 +26,11 @@
#include <svtools/svtdllapi.h>
#include <tools/ref.hxx>
#include <vcl/window.hxx>
#include <vcl/combobox.hxx>
#include <vcl/lstbox.hxx>

#include <svtools/brwbox.hxx>
#include <svtools/brwhead.hxx>
#include <svtools/InterimItemWindow.hxx>
#include <vcl/vclmedit.hxx>
#include <o3tl/typed_flags_set.hxx>

@@ -301,9 +301,7 @@ namespace svt
        DECL_LINK( OnClick, Button*, void );
    };


    //= CheckBoxCellController

    class SVT_DLLPUBLIC CheckBoxCellController final : public CellController
    {
    public:
@@ -319,29 +317,27 @@ namespace svt
        DECL_LINK(ModifyHdl, LinkParamNone*, void);
    };


    //= ComboBoxControl

    class SVT_DLLPUBLIC ComboBoxControl final : public ComboBox
    class SVT_DLLPUBLIC ComboBoxControl final : public InterimItemWindow
    {
        friend class ComboBoxCellController;

    public:
        ComboBoxControl(vcl::Window* pParent);

        weld::ComboBox& get_widget() { return *m_xWidget; }

    private:
        virtual bool PreNotify( NotifyEvent& rNEvt ) override;
        std::unique_ptr<weld::ComboBox> m_xWidget;
    };


    //= ComboBoxCellController

    class SVT_DLLPUBLIC ComboBoxCellController : public CellController
    {
    public:

        ComboBoxCellController(ComboBoxControl* pParent);
        ComboBoxControl& GetComboBox() const { return static_cast<ComboBoxControl &>(GetWindow()); }
        weld::ComboBox& GetComboBox() const { return static_cast<ComboBoxControl&>(GetWindow()).get_widget(); }

        virtual bool IsModified() const override;
        virtual void ClearModified() override;
@@ -349,7 +345,7 @@ namespace svt
    protected:
        virtual bool MoveAllowed(const KeyEvent& rEvt) const override;
    private:
        DECL_LINK(ModifyHdl, Edit&, void);
        DECL_LINK(ModifyHdl, weld::ComboBox&, void);
    };


diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx
index 69ff978..8cb3a65 100644
--- a/reportdesign/source/ui/dlg/GroupsSorting.cxx
+++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx
@@ -52,7 +52,7 @@ using namespace ::com::sun::star;
using namespace svt;
using namespace ::comphelper;

    static void lcl_addToList_throw( ComboBoxControl& _rListBox, ::std::vector<ColumnInfo>& o_aColumnList,const uno::Reference< container::XNameAccess>& i_xColumns )
    static void lcl_addToList_throw( weld::ComboBox& _rListBox, ::std::vector<ColumnInfo>& o_aColumnList,const uno::Reference< container::XNameAccess>& i_xColumns )
    {
        const uno::Sequence< OUString > aEntries = i_xColumns->getElementNames();
        for ( const OUString& rEntry : aEntries )
@@ -63,9 +63,9 @@ using namespace ::comphelper;
                xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel;
            o_aColumnList.emplace_back(rEntry,sLabel );
            if ( !sLabel.isEmpty() )
                _rListBox.InsertEntry( sLabel );
                _rListBox.append_text( sLabel );
            else
                _rListBox.InsertEntry( rEntry );
                _rListBox.append_text( rEntry );
        }
    }

@@ -159,7 +159,7 @@ protected:

private:

    DECL_LINK( CBChangeHdl, ComboBox&, void);
    DECL_LINK( CBChangeHdl, weld::ComboBox&, void);

public:
    DECL_LINK( DelayedDelete, void*, void );
@@ -266,8 +266,9 @@ sal_Int8 OFieldExpressionControl::AcceptDrop( const BrowserAcceptDropEvent& rEvt
    sal_Int8 nAction = DND_ACTION_NONE;
    if ( IsEditing() )
    {
        sal_Int32 nPos = m_pComboCell->GetSelectedEntryPos();
        if ( COMBOBOX_ENTRY_NOTFOUND != nPos || !m_pComboCell->GetText().isEmpty() )
        weld::ComboBox& rComboBox = m_pComboCell->get_widget();
        sal_Int32 nPos = rComboBox.get_active();
        if (nPos != -1 || !rComboBox.get_active_text().isEmpty())
            SaveModified();
        DeactivateCell();
    }
@@ -339,9 +340,10 @@ void OFieldExpressionControl::moveGroups(const uno::Sequence<uno::Any>& _aGroups

void OFieldExpressionControl::fillColumns(const uno::Reference< container::XNameAccess>& _xColumns)
{
    m_pComboCell->Clear();
    weld::ComboBox& rComboBox = m_pComboCell->get_widget();
    rComboBox.clear();
    if ( _xColumns.is() )
        lcl_addToList_throw(*m_pComboCell,m_aColumnInfo,_xColumns);
        lcl_addToList_throw(rComboBox, m_aColumnInfo, _xColumns);
}

void OFieldExpressionControl::lateInit()
@@ -368,10 +370,11 @@ void OFieldExpressionControl::lateInit()
        InsertDataColumn( FIELD_EXPRESSION, RptResId(STR_RPT_EXPRESSION), 100);

        m_pComboCell = VclPtr<ComboBoxControl>::Create( &GetDataWindow() );
        m_pComboCell->SetSelectHdl(LINK(this,OFieldExpressionControl,CBChangeHdl));
        weld::ComboBox& rComboBox = m_pComboCell->get_widget();
        rComboBox.connect_changed(LINK(this,OFieldExpressionControl,CBChangeHdl));
        m_pComboCell->SetHelpId(HID_RPT_FIELDEXPRESSION);

        m_pComboCell->SetGetFocusHdl(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusGot));
        rComboBox.connect_focus_in(LINK(m_pParent, OGroupsSortingDialog, OnControlFocusGot));


        // set browse mode
@@ -389,20 +392,16 @@ void OFieldExpressionControl::lateInit()
    RowInserted(0, m_aGroupPositions.size());
}


IMPL_LINK_NOARG( OFieldExpressionControl, CBChangeHdl, ComboBox&, void )
IMPL_LINK_NOARG( OFieldExpressionControl, CBChangeHdl, weld::ComboBox&, void )
{

    SaveModified();
}


bool OFieldExpressionControl::IsTabAllowed(bool /*bForward*/) const
{
    return false;
}


bool OFieldExpressionControl::SaveModified()
{
    sal_Int32 nRow = GetCurRow();
@@ -447,10 +446,11 @@ bool OFieldExpressionControl::SaveModified()
                xGroup = m_pParent->getGroup(m_aGroupPositions[nRow]);
            if ( xGroup.is() )
            {
                sal_Int32 nPos = m_pComboCell->GetSelectedEntryPos();
                weld::ComboBox& rComboBox = m_pComboCell->get_widget();
                sal_Int32 nPos = rComboBox.get_active();
                OUString sExpression;
                if ( COMBOBOX_ENTRY_NOTFOUND == nPos )
                    sExpression = m_pComboCell->GetText();
                if (nPos == -1)
                    sExpression = rComboBox.get_active_text();
                else
                {
                    sExpression = m_aColumnInfo[nPos].sColumnName;
@@ -507,11 +507,10 @@ OUString OFieldExpressionControl::GetCellText( long nRow, sal_uInt16 /*nColId*/ 
    return sText;
}


void OFieldExpressionControl::InitController( CellControllerRef& /*rController*/, long nRow, sal_uInt16 nColumnId )
{

    m_pComboCell->SetText( GetCellText( nRow, nColumnId ) );
    weld::ComboBox& rComboBox = m_pComboCell->get_widget();
    rComboBox.set_entry_text(GetCellText(nRow, nColumnId));
}

bool OFieldExpressionControl::CursorMoving(long nNewRow, sal_uInt16 nNewCol)
@@ -532,11 +531,10 @@ bool OFieldExpressionControl::CursorMoving(long nNewRow, sal_uInt16 nNewCol)
CellController* OFieldExpressionControl::GetController( long /*nRow*/, sal_uInt16 /*nColumnId*/ )
{
    ComboBoxCellController* pCellController = new ComboBoxCellController( m_pComboCell );
    pCellController->GetComboBox().SetReadOnly(!m_pParent->m_pController->isEditable());
    pCellController->GetComboBox().set_entry_editable(m_pParent->m_pController->isEditable());
    return pCellController;
}


bool OFieldExpressionControl::SeekRow( long _nRow )
{
    // the basis class needs the call, because that's how the class knows which line will be painted
@@ -545,7 +543,6 @@ bool OFieldExpressionControl::SeekRow( long _nRow )
    return true;
}


void OFieldExpressionControl::PaintCell( OutputDevice& rDev, const tools::Rectangle& rRect, sal_uInt16 nColumnId ) const
{
    OUString aText  =GetCellText( m_nCurrentPos, nColumnId );
@@ -930,7 +927,7 @@ sal_Int32 OGroupsSortingDialog::getColumnDataType(const OUString& _sColumnName)
    return nDataType;
}

IMPL_LINK_NOARG(OGroupsSortingDialog, OnControlFocusGot, Control&, void )
IMPL_LINK_NOARG(OGroupsSortingDialog, OnControlFocusGot, weld::Widget&, void )
{
    m_xHelpWindow->set_label(RptResId(STR_RPT_HELP_FIELD));
}
diff --git a/reportdesign/source/ui/inc/GroupsSorting.hxx b/reportdesign/source/ui/inc/GroupsSorting.hxx
index 270484a..cd038e6 100644
--- a/reportdesign/source/ui/inc/GroupsSorting.hxx
+++ b/reportdesign/source/ui/inc/GroupsSorting.hxx
@@ -74,7 +74,7 @@ private:
    DECL_LINK( OnWidgetFocusLost, weld::Widget&, void );
    DECL_LINK( OnWidgetFocusGot, weld::Widget&, void );

    DECL_LINK( OnControlFocusGot, Control&, void );
    DECL_LINK( OnControlFocusGot, weld::Widget&, void );

    DECL_LINK( LBChangeHdl, weld::ComboBox&, void );
    DECL_LINK( OnFormatAction, const OString&, void );
diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index c90561c6..65f333d 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -26,75 +26,47 @@
namespace svt
{


    //= ComboBoxControl

    ComboBoxControl::ComboBoxControl(vcl::Window* pParent)
                   :ComboBox(pParent, WB_DROPDOWN|WB_NOBORDER)
        : InterimItemWindow(pParent, "svt/ui/combocontrol.ui", "ComboControl")
        , m_xWidget(m_xBuilder->weld_combo_box("combobox"))
    {
        EnableAutoSize(false);
        EnableAutocomplete(true);
        SetDropDownLineCount(5);
    }


    bool ComboBoxControl::PreNotify( NotifyEvent& rNEvt )
    {
        if (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT && !IsInDropDown())
        {
            const KeyEvent *pEvt = rNEvt.GetKeyEvent();
            const vcl::KeyCode rKey = pEvt->GetKeyCode();

            if ((rKey.GetCode() == KEY_UP || rKey.GetCode() == KEY_DOWN) &&
                (!pEvt->GetKeyCode().IsShift() && pEvt->GetKeyCode().IsMod1()))
            {
                // select next resp. previous entry
                sal_Int32 nPos = GetEntryPos(GetText());
                int nDir = (rKey.GetCode() == KEY_DOWN ? 1 : -1);
                if (!((nPos == 0 && nDir == -1) || (nPos >= GetEntryCount() && nDir == 1)))
                {
                    nPos += nDir;
                    SetText(GetEntry(nPos));
                }
                return true;
            }
        }
        return ComboBox::PreNotify(rNEvt);
    }

    //= ComboBoxCellController
    ComboBoxCellController::ComboBoxCellController(ComboBoxControl* pWin)
                             :CellController(pWin)
    {
        GetComboBox().SetModifyHdl( LINK(this, ComboBoxCellController, ModifyHdl) );
        GetComboBox().connect_changed(LINK(this, ComboBoxCellController, ModifyHdl));
    }

    IMPL_LINK_NOARG(ComboBoxCellController, ModifyHdl, Edit&, void)
    IMPL_LINK_NOARG(ComboBoxCellController, ModifyHdl, weld::ComboBox&, void)
    {
        callModifyHdl();
    }


    bool ComboBoxCellController::MoveAllowed(const KeyEvent& rEvt) const
    {
        ComboBoxControl& rBox = GetComboBox();
        weld::ComboBox& rBox = GetComboBox();
        switch (rEvt.GetKeyCode().GetCode())
        {
            case KEY_END:
            case KEY_RIGHT:
            {
                Selection aSel = rBox.GetSelection();
                return !aSel && aSel.Max() == rBox.GetText().getLength();
                int nStartPos, nEndPos;
                bool bNoSelection = rBox.get_entry_selection_bounds(nStartPos, nEndPos);
                return bNoSelection && nEndPos == rBox.get_active_text().getLength();
            }
            case KEY_HOME:
            case KEY_LEFT:
            {
                Selection aSel = rBox.GetSelection();
                return !aSel && aSel.Min() == 0;
                int nStartPos, nEndPos;
                bool bNoSelection = rBox.get_entry_selection_bounds(nStartPos, nEndPos);
                return bNoSelection && nStartPos == 0;
            }
            case KEY_UP:
            case KEY_DOWN:
                if (rBox.IsInDropDown())
                if (rBox.get_popup_shown())
                    return false;
                if (!rEvt.GetKeyCode().IsShift() &&
                     rEvt.GetKeyCode().IsMod1())
@@ -106,7 +78,7 @@ namespace svt
            case KEY_PAGEUP:
            case KEY_PAGEDOWN:
            case KEY_RETURN:
                if (rBox.IsInDropDown())
                if (rBox.get_popup_shown())
                    return false;
                [[fallthrough]];
            default:
@@ -114,15 +86,14 @@ namespace svt
        }
    }


    bool ComboBoxCellController::IsModified() const
    {
        return GetComboBox().IsValueChangedFromSaved();
        return GetComboBox().get_value_changed_from_saved();
    }

    void ComboBoxCellController::ClearModified()
    {
        GetComboBox().SaveValue();
        GetComboBox().save_value();
    }

    //= ListBoxControl
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx
index 24eebf6..82b3b41 100644
--- a/svx/source/fmcomp/gridcell.cxx
+++ b/svx/source/fmcomp/gridcell.cxx
@@ -2392,7 +2392,6 @@ DbComboBox::DbComboBox(DbGridColumn& _rColumn)
    doPropertyListening( FM_PROP_LINECOUNT );
}


void DbComboBox::_propertyChanged( const PropertyChangeEvent& _rEvent )
{
    if ( _rEvent.PropertyName == FM_PROP_STRINGITEMLIST )
@@ -2405,36 +2404,28 @@ void DbComboBox::_propertyChanged( const PropertyChangeEvent& _rEvent )
    }
}


void DbComboBox::SetList(const Any& rItems)
{
    ComboBoxControl* pField = static_cast<ComboBoxControl*>(m_pWindow.get());
    pField->Clear();
    weld::ComboBox& rComboBox = pField->get_widget();
    rComboBox.clear();

    css::uno::Sequence<OUString> aTest;
    if (rItems >>= aTest)
    {
        for (const OUString& rString : std::as_const(aTest))
             pField->InsertEntry(rString);
             rComboBox.append_text(rString);

        // tell the grid control that this controller is invalid and has to be re-initialized
        invalidatedController();
    }
}


void DbComboBox::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
void DbComboBox::implAdjustGenericFieldSetting(const Reference<XPropertySet>&)
{
    DBG_ASSERT( m_pWindow, "DbComboBox::implAdjustGenericFieldSetting: not to be called without window!" );
    DBG_ASSERT( _rxModel.is(), "DbComboBox::implAdjustGenericFieldSetting: invalid model!" );
    if ( m_pWindow && _rxModel.is() )
    {
        sal_Int16  nLines = getINT16( _rxModel->getPropertyValue( FM_PROP_LINECOUNT ) );
        static_cast< ComboBoxControl* >( m_pWindow.get() )->SetDropDownLineCount( nLines );
    }
    // we no longer pay attention to FM_PROP_LINECOUNT
}


void DbComboBox::Init( vcl::Window& rParent, const Reference< XRowSet >& xCursor )
{
    m_rColumn.SetAlignmentFromModel(css::awt::TextAlign::LEFT);
@@ -2472,13 +2463,12 @@ OUString DbComboBox::GetFormatText(const Reference< css::sdb::XColumn >& _rxFiel
    return fmter.getFormattedValue();
}


void DbComboBox::UpdateFromField(const Reference< css::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter)
{
    m_pWindow->SetText(GetFormatText(_rxField, xFormatter));
    ComboBoxControl* pControl = static_cast<ComboBoxControl*>(m_pWindow.get());
    pControl->get_widget().set_entry_text(GetFormatText(_rxField, xFormatter));
}


void DbComboBox::updateFromModel( Reference< XPropertySet > _rxModel )
{
    OSL_ENSURE( _rxModel.is() && m_pWindow, "DbComboBox::updateFromModel: invalid call!" );
@@ -2486,14 +2476,17 @@ void DbComboBox::updateFromModel( Reference< XPropertySet > _rxModel )
    OUString sText;
    _rxModel->getPropertyValue( FM_PROP_TEXT ) >>= sText;

    static_cast< ComboBox* >( m_pWindow.get() )->SetText( sText );
    static_cast< ComboBox* >( m_pWindow.get() )->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
    ComboBoxControl* pControl = static_cast<ComboBoxControl*>(m_pWindow.get());
    weld::ComboBox& rComboBox = pControl->get_widget();
    rComboBox.set_entry_text(sText);
    rComboBox.select_entry_region(0, -1);
}


bool DbComboBox::commitControl()
{
    OUString aText( m_pWindow->GetText());
    ComboBoxControl* pControl = static_cast<ComboBoxControl*>(m_pWindow.get());
    weld::ComboBox& rComboBox = pControl->get_widget();
    OUString aText(rComboBox.get_active_text());
    m_rColumn.getModel()->setPropertyValue(FM_PROP_TEXT, makeAny(aText));
    return true;
}
@@ -2696,9 +2689,10 @@ void DbFilterField::SetList(const Any& rItems, bool bComboBox)
    {
        if (bComboBox)
        {
            ComboBox* pField = static_cast<ComboBox*>(m_pWindow.get());
            ComboBoxControl* pField = static_cast<ComboBoxControl*>(m_pWindow.get());
            weld::ComboBox& rComboBox = pField->get_widget();
            for (const OUString& rString : std::as_const(aTest))
                pField->InsertEntry(rString);
                rComboBox.append_text(rString);
        }
        else
        {
@@ -2746,13 +2740,9 @@ void DbFilterField::CreateControl(vcl::Window* pParent, const Reference< css::be

            if (!m_bFilterList)
            {
                sal_Int16  nLines       = ::comphelper::getINT16(xModel->getPropertyValue(FM_PROP_LINECOUNT));
                Any  aItems      = xModel->getPropertyValue(FM_PROP_STRINGITEMLIST);
                Any aItems = xModel->getPropertyValue(FM_PROP_STRINGITEMLIST);
                SetList(aItems, true);
                static_cast<ComboBox*>(m_pWindow.get())->SetDropDownLineCount(nLines);
            }
            else
                static_cast<ComboBox*>(m_pWindow.get())->SetDropDownLineCount(5);

        }   break;
        default:
@@ -2807,7 +2797,6 @@ void DbFilterField::Init( vcl::Window& rParent, const Reference< XRowSet >& xCur
        pAsEdit->SetReadOnly( false );
}


CellControllerRef DbFilterField::CreateController() const
{
    CellControllerRef xController;
@@ -2831,7 +2820,6 @@ CellControllerRef DbFilterField::CreateController() const
    return xController;
}


void DbFilterField::updateFromModel( Reference< XPropertySet > _rxModel )
{
    OSL_ENSURE( _rxModel.is() && m_pWindow, "DbFilterField::updateFromModel: invalid call!" );
@@ -2841,7 +2829,6 @@ void DbFilterField::updateFromModel( Reference< XPropertySet > _rxModel )
    // remember: updateFromModel should be some kind of opposite of commitControl
}


bool DbFilterField::commitControl()
{
    OUString aText(m_aText);
@@ -3066,12 +3053,13 @@ void DbFilterField::Update()
        (void)xListCursor->next();
    }

    ComboBoxControl* pField = static_cast<ComboBoxControl*>(m_pWindow.get());
    weld::ComboBox& rComboBox = pField->get_widget();
    // filling the entries for the combobox
    for (const auto& rString : aStringList)
        static_cast<ComboBox*>(m_pWindow.get())->InsertEntry(rString);
        rComboBox.append_text(rString);
}


OUString DbFilterField::GetFormatText(const Reference< XColumn >& /*_rxField*/, const Reference< XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/)
{
    return OUString();
@@ -4327,11 +4315,12 @@ 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< ComboBox& >( m_pCellControl->GetWindow() ) )
    ,m_rComboBox(static_cast<ComboBoxControl&>(m_pCellControl->GetWindow()).get_widget())
    ,m_nLines(Application::GetSettings().GetStyleSettings().GetListBoxMaximumLineCount())
{
    m_rComboBox.connect_changed(LINK(this, FmXComboBoxCell, ChangedHdl));
}


FmXComboBoxCell::~FmXComboBoxCell()
{
    if ( !OComponentHelper::rBHelper.bDisposed )
@@ -4342,7 +4331,6 @@ FmXComboBoxCell::~FmXComboBoxCell()

}


void FmXComboBoxCell::disposing()
{
    css::lang::EventObject aEvt(*this);
@@ -4352,7 +4340,6 @@ void FmXComboBoxCell::disposing()
    FmXTextCell::disposing();
}


Any SAL_CALL FmXComboBoxCell::queryAggregation( const css::uno::Type& _rType )
{
    Any aReturn = FmXTextCell::queryAggregation(_rType);
@@ -4363,7 +4350,6 @@ Any SAL_CALL FmXComboBoxCell::queryAggregation( const css::uno::Type& _rType )
    return aReturn;
}


Sequence< Type > SAL_CALL FmXComboBoxCell::getTypes(  )
{
    return ::comphelper::concatSequences(
@@ -4372,22 +4358,18 @@ Sequence< Type > SAL_CALL FmXComboBoxCell::getTypes(  )
    );
}


IMPLEMENT_GET_IMPLEMENTATION_ID( FmXComboBoxCell )


void SAL_CALL FmXComboBoxCell::addItemListener(const Reference< awt::XItemListener >& l)
{
    m_aItemListeners.addInterface( l );
}


void SAL_CALL FmXComboBoxCell::removeItemListener(const Reference< awt::XItemListener >& l)
{
    m_aItemListeners.removeInterface( l );
}


void SAL_CALL FmXComboBoxCell::addActionListener(const Reference< awt::XActionListener >& l)
{
    m_aActionListeners.addInterface( l );
@@ -4399,53 +4381,41 @@ void SAL_CALL FmXComboBoxCell::removeActionListener(const Reference< awt::XActio
    m_aActionListeners.removeInterface( l );
}


void SAL_CALL FmXComboBoxCell::addItem( const OUString& Item, sal_Int16 Pos )
{
    ::osl::MutexGuard aGuard( m_aMutex );
    if ( m_pComboBox )
        m_pComboBox->InsertEntry( Item, Pos );
    m_rComboBox.insert_text(Pos, Item);
}


void SAL_CALL FmXComboBoxCell::addItems( const Sequence< OUString >& Items, sal_Int16 Pos )
{
    ::osl::MutexGuard aGuard( m_aMutex );
    if ( m_pComboBox )
    sal_uInt16 nP = Pos;
    for ( const auto& rItem : Items )
    {
        sal_uInt16 nP = Pos;
        for ( const auto& rItem : Items )
        {
            m_pComboBox->InsertEntry( rItem, nP );
            if ( Pos != -1 )
                nP++;
        }
        m_rComboBox.insert_text(nP, rItem);
        if ( Pos != -1 )
            nP++;
    }
}


void SAL_CALL FmXComboBoxCell::removeItems( sal_Int16 Pos, sal_Int16 Count )
{
    ::osl::MutexGuard aGuard( m_aMutex );
    if ( m_pComboBox )
    {
        for ( sal_uInt16 n = Count; n; )
            m_pComboBox->RemoveEntryAt( Pos + (--n) );
    }
    for ( sal_uInt16 n = Count; n; )
        m_rComboBox.remove( Pos + (--n) );
}


sal_Int16 SAL_CALL FmXComboBoxCell::getItemCount()
{
    ::osl::MutexGuard aGuard( m_aMutex );
    return m_pComboBox ? m_pComboBox->GetEntryCount() : 0;
    return m_rComboBox.get_count();
}


OUString SAL_CALL FmXComboBoxCell::getItem( sal_Int16 Pos )
{
    ::osl::MutexGuard aGuard( m_aMutex );
    return m_pComboBox ? m_pComboBox->GetEntry(Pos) : OUString();
    return m_rComboBox.get_text(Pos);
}

Sequence< OUString > SAL_CALL FmXComboBoxCell::getItems()
@@ -4453,64 +4423,43 @@ Sequence< OUString > SAL_CALL FmXComboBoxCell::getItems()
    ::osl::MutexGuard aGuard( m_aMutex );

    Sequence< OUString > aItems;
    if ( m_pComboBox )
    {
        const sal_Int32 nEntries = m_pComboBox->GetEntryCount();
        aItems.realloc( nEntries );
        OUString* pItem = aItems.getArray();
        for ( sal_Int32 n=0; n<nEntries; ++n, ++pItem )
            *pItem = m_pComboBox->GetEntry( n );
    }
    const sal_Int32 nEntries = m_rComboBox.get_count();
    aItems.realloc( nEntries );
    OUString* pItem = aItems.getArray();
    for ( sal_Int32 n=0; n<nEntries; ++n, ++pItem )
        *pItem = m_rComboBox.get_text(n);
    return aItems;
}


sal_Int16 SAL_CALL FmXComboBoxCell::getDropDownLineCount()
{
    ::osl::MutexGuard aGuard( m_aMutex );

    sal_Int16 nLines = 0;
    if ( m_pComboBox )
        nLines = m_pComboBox->GetDropDownLineCount();

    return nLines;
    return m_nLines;
}


void SAL_CALL FmXComboBoxCell::setDropDownLineCount(sal_Int16 nLines)
{
    ::osl::MutexGuard aGuard( m_aMutex );
    if ( m_pComboBox )
        m_pComboBox->SetDropDownLineCount( nLines );
    // just store it to return it
    m_nLines = nLines;
}


void FmXComboBoxCell::onWindowEvent( const VclEventId _nEventId, const vcl::Window& _rWindow, const void* _pEventData )
IMPL_LINK_NOARG(FmXComboBoxCell, ChangedHdl, weld::ComboBox&, void)
{
    if (!m_rComboBox.changed_by_direct_pick())
        return;

    switch ( _nEventId )
    {
    case VclEventId::ComboboxSelect:
    {
        awt::ItemEvent aEvent;
        aEvent.Source = *this;
        aEvent.Highlighted = 0;
    awt::ItemEvent aEvent;
    aEvent.Source = *this;
    aEvent.Highlighted = 0;

        // with multiple selection 0xFFFF, otherwise the ID
        aEvent.Selected =   ( m_pComboBox->GetSelectedEntryCount() == 1 )
                        ?   m_pComboBox->GetSelectedEntryPos()
                        :   0xFFFF;
        m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
    }
    break;

    default:
        FmXTextCell::onWindowEvent( _nEventId, _rWindow, _pEventData );
        break;
    }
    // with invalid selection 0xFFFF, otherwise the position
    aEvent.Selected =   ( m_rComboBox.get_active() != -1 )
                    ?   m_rComboBox.get_active()
                    :   0xFFFF;
    m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
}


FmXFilterCell::FmXFilterCell(DbGridColumn* pColumn, std::unique_ptr<DbFilterField> pControl )
              :FmXGridCell( pColumn, std::move(pControl) )
              ,m_aTextListeners(m_aMutex)
@@ -4518,7 +4467,6 @@ FmXFilterCell::FmXFilterCell(DbGridColumn* pColumn, std::unique_ptr<DbFilterFiel
    static_cast<DbFilterField*>(m_pCellControl.get())->SetCommitHdl( LINK( this, FmXFilterCell, OnCommit ) );
}


FmXFilterCell::~FmXFilterCell()
{
    if (!OComponentHelper::rBHelper.bDisposed)
@@ -4530,7 +4478,6 @@ FmXFilterCell::~FmXFilterCell()
}

// XUnoTunnel

sal_Int64 SAL_CALL FmXFilterCell::getSomething( const Sequence< sal_Int8 >& _rIdentifier )
{
    sal_Int64 nReturn(0);
diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx
index b46582e..f30d96c8 100644
--- a/svx/source/inc/gridcell.hxx
+++ b/svx/source/inc/gridcell.hxx
@@ -1012,7 +1012,10 @@ class FmXComboBoxCell   :public FmXTextCell
private:
    ::comphelper::OInterfaceContainerHelper2   m_aItemListeners,
                                        m_aActionListeners;
    VclPtr<ComboBox>                    m_pComboBox;
    weld::ComboBox& m_rComboBox;
    sal_uInt16 m_nLines;

    DECL_LINK(ChangedHdl, weld::ComboBox&, void);

protected:
    virtual ~FmXComboBoxCell() override;
@@ -1041,12 +1044,8 @@ public:
    virtual css::uno::Sequence< OUString > SAL_CALL getItems(  ) override;
    virtual ::sal_Int16 SAL_CALL getDropDownLineCount(  ) override;
    virtual void SAL_CALL setDropDownLineCount( ::sal_Int16 Lines ) override;

protected:
    virtual void onWindowEvent( const VclEventId _nEventId, const vcl::Window& _rWindow, const void* _pEventData ) override;
};


typedef ::cppu::ImplHelper2 <   css::awt::XTextComponent
                            ,   css::lang::XUnoTunnel
                            >   FmXFilterCell_Base;