[Libreoffice-commits] core.git: extras/source sc/inc sc/source sc/uiconfig solenv/bin

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Feb 15 19:50:36 UTC 2019


 extras/source/glade/libreoffice-catalog.xml.in |    4 
 sc/inc/scabstdlg.hxx                           |    8 
 sc/source/ui/attrdlg/scdlgfact.cxx             |   21 +
 sc/source/ui/attrdlg/scdlgfact.hxx             |   16 +
 sc/source/ui/dbgui/PivotLayoutTreeListData.cxx |    2 
 sc/source/ui/dbgui/pvfundlg.cxx                |  274 +++++++++++--------------
 sc/source/ui/inc/pvfundlg.hxx                  |   57 +----
 sc/uiconfig/scalc/ui/datafielddialog.ui        |   40 +++
 solenv/bin/native-code.py                      |    1 
 9 files changed, 204 insertions(+), 219 deletions(-)

New commits:
commit 490269200e40ead201cc48b450b5e4b1d8147e24
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Feb 15 16:12:35 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Feb 15 20:50:04 2019 +0100

    weld ScDPFunctionDlg
    
    Change-Id: I49428a9e6cd07a962c55939477f8408822170590
    Reviewed-on: https://gerrit.libreoffice.org/67881
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 3bf825820cd8..1d98ea2862bf 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -469,10 +469,6 @@
                         generic-name="CondFormatList" parent="GtkDrawingArea"
                         icon-name="widget-gtk-drawingarea"/>
 
-    <glade-widget-class title="ScDPFunctionListBox" name="scuilo-ScDPFunctionListBox"
-                        generic-name="DPFunctionListBox" parent="GtkTreeView"
-                        icon-name="widget-gtk-treeview"/>
-
     <glade-widget-class title="OTableTreeListBox" name="dbulo-OTableTreeListBox"
                         generic-name="OTableTreeListBox" parent="GtkTreeView"
                         icon-name="widget-gtk-treeview"/>
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 1d6e00d26c8f..9fc0bdbf32a7 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -471,10 +471,10 @@ public:
     virtual VclPtr<AbstractScPivotFilterDlg> CreateScPivotFilterDlg(vcl::Window* pParent,
         const SfxItemSet& rArgSet, sal_uInt16 nSourceTab) = 0;
 
-    virtual VclPtr<AbstractScDPFunctionDlg> CreateScDPFunctionDlg( vcl::Window* pParent,
-                                                                const ScDPLabelDataVector& rLabelVec,
-                                                                const ScDPLabelData& rLabelData,
-                                                                const ScPivotFuncData& rFuncData ) = 0;
+    virtual VclPtr<AbstractScDPFunctionDlg> CreateScDPFunctionDlg(weld::Window* pParent,
+                                                                  const ScDPLabelDataVector& rLabelVec,
+                                                                  const ScDPLabelData& rLabelData,
+                                                                  const ScPivotFuncData& rFuncData ) = 0;
 
     virtual VclPtr<AbstractScDPSubtotalDlg> CreateScDPSubtotalDlg(weld::Window* pParent,
                                                                   ScDPObject& rDPObj,
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index e3125c60ce06..b99de9b218f8 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -166,7 +166,11 @@ short AbstractScNamePasteDlg_Impl::Execute()
 }
 
 IMPL_ABSTDLG_BASE(AbstractScPivotFilterDlg_Impl);
-IMPL_ABSTDLG_BASE(AbstractScDPFunctionDlg_Impl);
+
+short AbstractScDPFunctionDlg_Impl::Execute()
+{
+    return m_xDlg->run();
+}
 
 short AbstractScDPSubtotalDlg_Impl::Execute()
 {
@@ -609,12 +613,12 @@ const ScQueryItem&   AbstractScPivotFilterDlg_Impl::GetOutputItem()
 
 PivotFunc AbstractScDPFunctionDlg_Impl::GetFuncMask() const
 {
-     return pDlg->GetFuncMask();
+     return m_xDlg->GetFuncMask();
 }
 
 css::sheet::DataPilotFieldReference AbstractScDPFunctionDlg_Impl::GetFieldRef() const
 {
-    return pDlg->GetFieldRef();
+    return m_xDlg->GetFieldRef();
 }
 
 PivotFunc AbstractScDPSubtotalDlg_Impl::GetFuncMask() const
@@ -910,13 +914,12 @@ VclPtr<AbstractScPivotFilterDlg> ScAbstractDialogFactory_Impl::CreateScPivotFilt
     return VclPtr<AbstractScPivotFilterDlg_Impl>::Create(pDlg);
 }
 
-VclPtr<AbstractScDPFunctionDlg> ScAbstractDialogFactory_Impl::CreateScDPFunctionDlg ( vcl::Window* pParent,
-                                                                const ScDPLabelDataVector& rLabelVec,
-                                                                const ScDPLabelData& rLabelData,
-                                                                const ScPivotFuncData& rFuncData )
+VclPtr<AbstractScDPFunctionDlg> ScAbstractDialogFactory_Impl::CreateScDPFunctionDlg(weld::Window* pParent,
+                                                                                    const ScDPLabelDataVector& rLabelVec,
+                                                                                    const ScDPLabelData& rLabelData,
+                                                                                    const ScPivotFuncData& rFuncData)
 {
-    VclPtr<ScDPFunctionDlg> pDlg = VclPtr<ScDPFunctionDlg>::Create( pParent, rLabelVec, rLabelData, rFuncData );
-    return VclPtr<AbstractScDPFunctionDlg_Impl>::Create( pDlg );
+    return VclPtr<AbstractScDPFunctionDlg_Impl>::Create(std::make_unique<ScDPFunctionDlg>(pParent, rLabelVec, rLabelData, rFuncData));
 }
 
 VclPtr<AbstractScDPSubtotalDlg> ScAbstractDialogFactory_Impl::CreateScDPSubtotalDlg(weld::Window* pParent,
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 1341de4450aa..ce82fa0bf333 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -392,7 +392,13 @@ class AbstractScPivotFilterDlg_Impl : public AbstractScPivotFilterDlg
 
 class AbstractScDPFunctionDlg_Impl : public AbstractScDPFunctionDlg
 {
-    DECL_ABSTDLG_BASE( AbstractScDPFunctionDlg_Impl, ScDPFunctionDlg)
+    std::unique_ptr<ScDPFunctionDlg> m_xDlg;
+public:
+    explicit AbstractScDPFunctionDlg_Impl(std::unique_ptr<ScDPFunctionDlg> p)
+        : m_xDlg(std::move(p))
+    {
+    }
+    virtual short           Execute() override;
     virtual PivotFunc GetFuncMask() const override;
     virtual css::sheet::DataPilotFieldReference GetFieldRef() const override;
 };
@@ -665,10 +671,10 @@ public:
     virtual VclPtr<AbstractScPivotFilterDlg> CreateScPivotFilterDlg(vcl::Window* pParent,
         const SfxItemSet& rArgSet, sal_uInt16 nSourceTab) override;
 
-    virtual VclPtr<AbstractScDPFunctionDlg> CreateScDPFunctionDlg( vcl::Window* pParent,
-                                                                const ScDPLabelDataVector& rLabelVec,
-                                                                const ScDPLabelData& rLabelData,
-                                                                const ScPivotFuncData& rFuncData ) override;
+    virtual VclPtr<AbstractScDPFunctionDlg> CreateScDPFunctionDlg(weld::Window* pParent,
+                                                                  const ScDPLabelDataVector& rLabelVec,
+                                                                  const ScDPLabelData& rLabelData,
+                                                                  const ScPivotFuncData& rFuncData ) override;
 
     virtual VclPtr<AbstractScDPSubtotalDlg> CreateScDPSubtotalDlg(weld::Window* pParent,
                                                                   ScDPObject& rDPObj,
diff --git a/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx b/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
index 10fc31d77efc..187965ba78d0 100644
--- a/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
+++ b/sc/source/ui/dbgui/PivotLayoutTreeListData.cxx
@@ -85,7 +85,7 @@ bool ScPivotLayoutTreeListData::DoubleClickHdl()
     ScAbstractDialogFactory* pFactory = ScAbstractDialogFactory::Create();
 
     ScopedVclPtr<AbstractScDPFunctionDlg> pDialog(
-        pFactory->CreateScDPFunctionDlg(this, mpParent->GetLabelDataVector(), rCurrentLabelData, rCurrentFunctionData));
+        pFactory->CreateScDPFunctionDlg(GetFrameWeld(), mpParent->GetLabelDataVector(), rCurrentLabelData, rCurrentFunctionData));
 
     if (pDialog->Execute() == RET_OK)
     {
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
index e75b890a8fb4..9b77bbe28472 100644
--- a/sc/source/ui/dbgui/pvfundlg.cxx
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -55,22 +55,6 @@ namespace {
 
     @return  true = The passed string list contains an empty string entry.
  */
-template< typename ListBoxType >
-bool lclFillListBox( ListBoxType& rLBox, const Sequence< OUString >& rStrings, sal_Int32 nEmptyPos = LISTBOX_APPEND )
-{
-    bool bEmpty = false;
-    for (const OUString& str : rStrings)
-    {
-        if (!str.isEmpty())
-            rLBox.InsertEntry(str);
-        else
-        {
-            rLBox.InsertEntry(ScResId(STR_EMPTYDATA), nEmptyPos);
-            bEmpty = true;
-        }
-    }
-    return bEmpty;
-}
 
 bool lclFillListBox(weld::ComboBox& rLBox, const Sequence< OUString >& rStrings)
 {
@@ -88,18 +72,18 @@ bool lclFillListBox(weld::ComboBox& rLBox, const Sequence< OUString >& rStrings)
     return bEmpty;
 }
 
-template< typename ListBoxType >
-bool lclFillListBox( ListBoxType& rLBox, const vector<ScDPLabelData::Member>& rMembers, sal_Int32 nEmptyPos = LISTBOX_APPEND )
+bool lclFillListBox(weld::ComboBox& rLBox, const vector<ScDPLabelData::Member>& rMembers, int nEmptyPos)
 {
     bool bEmpty = false;
-    for (const auto& rMember : rMembers)
+    vector<ScDPLabelData::Member>::const_iterator itr = rMembers.begin(), itrEnd = rMembers.end();
+    for (; itr != itrEnd; ++itr)
     {
-        OUString aName = rMember.getDisplayName();
+        OUString aName = itr->getDisplayName();
         if (!aName.isEmpty())
-            rLBox.InsertEntry(aName);
+            rLBox.append_text(aName);
         else
         {
-            rLBox.InsertEntry(ScResId(STR_EMPTYDATA), nEmptyPos);
+            rLBox.insert_text(nEmptyPos, ScResId(STR_EMPTYDATA));
             bEmpty = true;
         }
     }
@@ -153,63 +137,15 @@ const sal_uInt16 SC_SORTDATA_POS = 1;
 
 const long SC_SHOW_DEFAULT = 10;
 
-static const ScDPListBoxWrapper::MapEntryType spRefTypeMap[] =
-{
-    { 0,                        DataPilotFieldReferenceType::NONE                       },
-    { 1,                        DataPilotFieldReferenceType::ITEM_DIFFERENCE            },
-    { 2,                        DataPilotFieldReferenceType::ITEM_PERCENTAGE            },
-    { 3,                        DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE },
-    { 4,                        DataPilotFieldReferenceType::RUNNING_TOTAL              },
-    { 5,                        DataPilotFieldReferenceType::ROW_PERCENTAGE             },
-    { 6,                        DataPilotFieldReferenceType::COLUMN_PERCENTAGE          },
-    { 7,                        DataPilotFieldReferenceType::TOTAL_PERCENTAGE           },
-    { 8,                        DataPilotFieldReferenceType::INDEX                      },
-    { WRAPPER_LISTBOX_ENTRY_NOTFOUND,   DataPilotFieldReferenceType::NONE               }
-};
-
 } // namespace
 
-ScDPFunctionListBox::ScDPFunctionListBox(vcl::Window* pParent, WinBits nStyle)
-    : ListBox(pParent, nStyle)
-{
-    FillFunctionNames();
-}
-
-VCL_BUILDER_FACTORY_CONSTRUCTOR(ScDPFunctionListBox, WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE)
-
-void ScDPFunctionListBox::SetSelection( PivotFunc nFuncMask )
-{
-    if( (nFuncMask == PivotFunc::NONE) || (nFuncMask == PivotFunc::Auto) )
-        SetNoSelection();
-    else
-        for( sal_Int32 nEntry = 0, nCount = GetEntryCount(); nEntry < nCount; ++nEntry )
-            SelectEntryPos( nEntry, bool(nFuncMask & spnFunctions[ nEntry ]) );
-}
-
-PivotFunc ScDPFunctionListBox::GetSelection() const
-{
-    PivotFunc nFuncMask = PivotFunc::NONE;
-    for( sal_Int32 nSel = 0, nCount = GetSelectedEntryCount(); nSel < nCount; ++nSel )
-        nFuncMask |= spnFunctions[ GetSelectedEntryPos( nSel ) ];
-    return nFuncMask;
-}
-
-void ScDPFunctionListBox::FillFunctionNames()
-{
-    OSL_ENSURE( !GetEntryCount(), "ScDPMultiFuncListBox::FillFunctionNames - do not add texts to resource" );
-    Clear();
-    for (size_t nIndex = 0; nIndex < SAL_N_ELEMENTS(SCSTR_DPFUNCLISTBOX); ++nIndex)
-        InsertEntry(ScResId(SCSTR_DPFUNCLISTBOX[nIndex]));
-    assert(GetEntryCount() == SAL_N_ELEMENTS(spnFunctions));
-}
-
-DPFunctionListBox::DPFunctionListBox(std::unique_ptr<weld::TreeView> xControl)
+ScDPFunctionListBox::ScDPFunctionListBox(std::unique_ptr<weld::TreeView> xControl)
     : m_xControl(std::move(xControl))
 {
     FillFunctionNames();
 }
 
-void DPFunctionListBox::SetSelection( PivotFunc nFuncMask )
+void ScDPFunctionListBox::SetSelection( PivotFunc nFuncMask )
 {
     if( (nFuncMask == PivotFunc::NONE) || (nFuncMask == PivotFunc::Auto) )
         m_xControl->unselect_all();
@@ -225,7 +161,7 @@ void DPFunctionListBox::SetSelection( PivotFunc nFuncMask )
     }
 }
 
-PivotFunc DPFunctionListBox::GetSelection() const
+PivotFunc ScDPFunctionListBox::GetSelection() const
 {
     PivotFunc nFuncMask = PivotFunc::NONE;
     std::vector<int> aRows = m_xControl->get_selected_rows();
@@ -234,7 +170,7 @@ PivotFunc DPFunctionListBox::GetSelection() const
     return nFuncMask;
 }
 
-void DPFunctionListBox::FillFunctionNames()
+void ScDPFunctionListBox::FillFunctionNames()
 {
     OSL_ENSURE( !m_xControl->n_children(), "ScDPMultiFuncListBox::FillFunctionNames - do not add texts to resource" );
     m_xControl->clear();
@@ -245,60 +181,99 @@ void DPFunctionListBox::FillFunctionNames()
     assert(m_xControl->n_children() == SAL_N_ELEMENTS(spnFunctions));
 }
 
+namespace
+{
+    int FromDataPilotFieldReferenceType(int eMode)
+    {
+        switch (eMode)
+        {
+            case DataPilotFieldReferenceType::NONE:
+                return 0;
+            case DataPilotFieldReferenceType::ITEM_DIFFERENCE:
+                return 1;
+            case DataPilotFieldReferenceType::ITEM_PERCENTAGE:
+                return 2;
+            case DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE:
+                return 3;
+            case DataPilotFieldReferenceType::RUNNING_TOTAL:
+                return 4;
+            case DataPilotFieldReferenceType::ROW_PERCENTAGE:
+                return 5;
+            case DataPilotFieldReferenceType::COLUMN_PERCENTAGE:
+                return 6;
+            case DataPilotFieldReferenceType::TOTAL_PERCENTAGE:
+                return 7;
+            case DataPilotFieldReferenceType::INDEX:
+                return 8;
+        }
+        return -1;
+    }
+
+    int ToDataPilotFieldReferenceType(int nPos)
+    {
+        switch (nPos)
+        {
+            case 0:
+                return DataPilotFieldReferenceType::NONE;
+            case 1:
+                return DataPilotFieldReferenceType::ITEM_DIFFERENCE;
+            case 2:
+                return DataPilotFieldReferenceType::ITEM_PERCENTAGE;
+            case 3:
+                return DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE;
+            case 4:
+                return DataPilotFieldReferenceType::RUNNING_TOTAL;
+            case 5:
+                return DataPilotFieldReferenceType::ROW_PERCENTAGE;
+            case 6:
+                return DataPilotFieldReferenceType::COLUMN_PERCENTAGE;
+            case 7:
+                return DataPilotFieldReferenceType::TOTAL_PERCENTAGE;
+            case 8:
+                return DataPilotFieldReferenceType::INDEX;
+        }
+        return DataPilotFieldReferenceType::NONE;
+
+    }
+}
+
 ScDPFunctionDlg::ScDPFunctionDlg(
-        vcl::Window* pParent, const ScDPLabelDataVector& rLabelVec,
+        weld::Window* pParent, const ScDPLabelDataVector& rLabelVec,
         const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData)
-    : ModalDialog(pParent, "DataFieldDialog",
-        "modules/scalc/ui/datafielddialog.ui")
+    : GenericDialogController(pParent, "modules/scalc/ui/datafielddialog.ui", "DataFieldDialog")
+    , mxLbFunc(new ScDPFunctionListBox(m_xBuilder->weld_tree_view("functions")))
+    , mxFtName(m_xBuilder->weld_label("name"))
+    , mxLbType(m_xBuilder->weld_combo_box("type"))
+    , mxFtBaseField(m_xBuilder->weld_label("basefieldft"))
+    , mxLbBaseField(m_xBuilder->weld_combo_box("basefield"))
+    , mxFtBaseItem(m_xBuilder->weld_label("baseitemft"))
+    , mxLbBaseItem(m_xBuilder->weld_combo_box("baseitem"))
+    , mxBtnOk(m_xBuilder->weld_button("ok"))
     , mrLabelVec(rLabelVec)
     , mbEmptyItem(false)
 {
-    get(mpFtName, "name");
-    get(mpLbType, "type");
-    mxLbTypeWrp.reset(new ScDPListBoxWrapper(*mpLbType, spRefTypeMap));
-    get(mpLbFunc, "functions");
-    mpLbFunc->set_height_request(mpLbFunc->GetTextHeight() * 8);
-    get(mpFtBaseField, "basefieldft");
-    get(mpLbBaseField, "basefield");
-    get(mpFtBaseItem, "baseitemft");
-    get(mpLbBaseItem, "baseitem");
-    get(mpBtnOk, "ok");
+    mxLbFunc->set_size_request(-1, mxLbFunc->get_height_rows(8));
 
-    Init( rLabelData, rFuncData );
+    Init(rLabelData, rFuncData);
 }
 
 ScDPFunctionDlg::~ScDPFunctionDlg()
 {
-    disposeOnce();
-}
-
-void ScDPFunctionDlg::dispose()
-{
-    mpLbFunc.clear();
-    mpFtName.clear();
-    mpLbType.clear();
-    mpFtBaseField.clear();
-    mpLbBaseField.clear();
-    mpFtBaseItem.clear();
-    mpLbBaseItem.clear();
-    mpBtnOk.clear();
-    ModalDialog::dispose();
 }
 
-
 PivotFunc ScDPFunctionDlg::GetFuncMask() const
 {
-    return mpLbFunc->GetSelection();
+    return mxLbFunc->GetSelection();
 }
 
 DataPilotFieldReference ScDPFunctionDlg::GetFieldRef() const
 {
     DataPilotFieldReference aRef;
 
-    aRef.ReferenceType = mxLbTypeWrp->GetControlValue();
-    aRef.ReferenceField = GetBaseFieldName(mpLbBaseField->GetSelectedEntry());
+    aRef.ReferenceType = ToDataPilotFieldReferenceType(mxLbType->get_active());
+    aRef.ReferenceField = GetBaseFieldName(mxLbBaseField->get_active_text());
 
-    sal_Int32 nBaseItemPos = mpLbBaseItem->GetSelectedEntryPos();
+    sal_Int32 nBaseItemPos = mxLbBaseItem->get_active();
     switch( nBaseItemPos )
     {
         case SC_BASEITEM_PREV_POS:
@@ -311,7 +286,7 @@ DataPilotFieldReference ScDPFunctionDlg::GetFieldRef() const
         {
             aRef.ReferenceItemType = DataPilotFieldReferenceItemType::NAMED;
             if( !mbEmptyItem || (nBaseItemPos > SC_BASEITEM_USER_POS) )
-                aRef.ReferenceItemName = GetBaseItemName(mpLbBaseItem->GetSelectedEntry());
+                aRef.ReferenceItemName = GetBaseItemName(mxLbBaseItem->get_active_text());
         }
     }
 
@@ -322,62 +297,59 @@ void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScPivotFuncDa
 {
     // list box
     PivotFunc nFuncMask = (rFuncData.mnFuncMask == PivotFunc::NONE) ? PivotFunc::Sum : rFuncData.mnFuncMask;
-    mpLbFunc->SetSelection( nFuncMask );
+    mxLbFunc->SetSelection( nFuncMask );
 
     // field name
-    mpFtName->SetText(rLabelData.getDisplayName());
+    mxFtName->set_label(rLabelData.getDisplayName());
 
     // handlers
-    mpLbFunc->SetDoubleClickHdl( LINK( this, ScDPFunctionDlg, DblClickHdl ) );
-    mpLbType->SetSelectHdl( LINK( this, ScDPFunctionDlg, SelectHdl ) );
-    mpLbBaseField->SetSelectHdl( LINK( this, ScDPFunctionDlg, SelectHdl ) );
+    mxLbFunc->connect_row_activated( LINK( this, ScDPFunctionDlg, DblClickHdl ) );
+    mxLbType->connect_changed( LINK( this, ScDPFunctionDlg, SelectHdl ) );
+    mxLbBaseField->connect_changed( LINK( this, ScDPFunctionDlg, SelectHdl ) );
 
     // base field list box
     OUString aSelectedEntry;
     for( const auto& rxLabel : mrLabelVec )
     {
-        mpLbBaseField->InsertEntry(rxLabel->getDisplayName());
+        mxLbBaseField->append_text(rxLabel->getDisplayName());
         maBaseFieldNameMap.emplace(rxLabel->getDisplayName(), rxLabel->maName);
         if (rxLabel->maName == rFuncData.maFieldRef.ReferenceField)
             aSelectedEntry = rxLabel->getDisplayName();
     }
 
-    // base item list box
-    mpLbBaseItem->SetSeparatorPos( SC_BASEITEM_USER_POS - 1 );
-
     // select field reference type
-    mxLbTypeWrp->SetControlValue( rFuncData.maFieldRef.ReferenceType );
-    SelectHdl( *mpLbType );         // enables base field/item list boxes
+    mxLbType->set_active(FromDataPilotFieldReferenceType(rFuncData.maFieldRef.ReferenceType));
+    SelectHdl( *mxLbType );         // enables base field/item list boxes
 
     // select base field
-    mpLbBaseField->SelectEntry(aSelectedEntry);
-    if( mpLbBaseField->GetSelectedEntryPos() >= mpLbBaseField->GetEntryCount() )
-        mpLbBaseField->SelectEntryPos( 0 );
-    SelectHdl( *mpLbBaseField );    // fills base item list, selects base item
+    mxLbBaseField->set_active_text(aSelectedEntry);
+    if (mxLbBaseField->get_active() == -1)
+        mxLbBaseField->set_active(0);
+    SelectHdl( *mxLbBaseField );    // fills base item list, selects base item
 
     // select base item
     switch( rFuncData.maFieldRef.ReferenceItemType )
     {
         case DataPilotFieldReferenceItemType::PREVIOUS:
-            mpLbBaseItem->SelectEntryPos( SC_BASEITEM_PREV_POS );
+            mxLbBaseItem->set_active( SC_BASEITEM_PREV_POS );
         break;
         case DataPilotFieldReferenceItemType::NEXT:
-            mpLbBaseItem->SelectEntryPos( SC_BASEITEM_NEXT_POS );
+            mxLbBaseItem->set_active( SC_BASEITEM_NEXT_POS );
         break;
         default:
         {
             if( mbEmptyItem && rFuncData.maFieldRef.ReferenceItemName.isEmpty() )
             {
                 // select special "(empty)" entry added before other items
-                mpLbBaseItem->SelectEntryPos( SC_BASEITEM_USER_POS );
+                mxLbBaseItem->set_active( SC_BASEITEM_USER_POS );
             }
             else
             {
                 sal_Int32 nStartPos = mbEmptyItem ? (SC_BASEITEM_USER_POS + 1) : SC_BASEITEM_USER_POS;
                 sal_Int32 nPos = FindBaseItemPos( rFuncData.maFieldRef.ReferenceItemName, nStartPos );
-                if( nPos >= mpLbBaseItem->GetEntryCount() )
-                    nPos = (mpLbBaseItem->GetEntryCount() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
-                mpLbBaseItem->SelectEntryPos( nPos );
+                if( nPos == -1)
+                    nPos = (mxLbBaseItem->get_count() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
+                mxLbBaseItem->set_active( nPos );
             }
         }
     }
@@ -399,10 +371,10 @@ sal_Int32 ScDPFunctionDlg::FindBaseItemPos( const OUString& rEntry, sal_Int32 nS
 {
     sal_Int32 nPos = nStartPos;
     bool bFound = false;
-    while (nPos < mpLbBaseItem->GetEntryCount())
+    while (nPos < mxLbBaseItem->get_count())
     {
         // translate the displayed field name back to its original field name.
-        const OUString& rInName = mpLbBaseItem->GetEntry(nPos);
+        const OUString& rInName = mxLbBaseItem->get_text(nPos);
         const OUString& rName = GetBaseItemName(rInName);
         if (rName == rEntry)
         {
@@ -411,15 +383,15 @@ sal_Int32 ScDPFunctionDlg::FindBaseItemPos( const OUString& rEntry, sal_Int32 nS
         }
         ++nPos;
     }
-    return bFound ? nPos : LISTBOX_ENTRY_NOTFOUND;
+    return bFound ? nPos : -1;
 }
 
-IMPL_LINK( ScDPFunctionDlg, SelectHdl, ListBox&, rLBox, void )
+IMPL_LINK( ScDPFunctionDlg, SelectHdl, weld::ComboBox&, rLBox, void )
 {
-    if( &rLBox == mpLbType )
+    if (&rLBox == mxLbType.get())
     {
         bool bEnableField, bEnableItem;
-        switch( mxLbTypeWrp->GetControlValue() )
+        switch (ToDataPilotFieldReferenceType(mxLbType->get_active()))
         {
             case DataPilotFieldReferenceType::ITEM_DIFFERENCE:
             case DataPilotFieldReferenceType::ITEM_PERCENTAGE:
@@ -436,27 +408,27 @@ IMPL_LINK( ScDPFunctionDlg, SelectHdl, ListBox&, rLBox, void )
                 bEnableField = bEnableItem = false;
         }
 
-        bEnableField &= mpLbBaseField->GetEntryCount() > 0;
-        mpFtBaseField->Enable( bEnableField );
-        mpLbBaseField->Enable( bEnableField );
+        bEnableField &= (mxLbBaseField->get_count() > 0);
+        mxFtBaseField->set_sensitive( bEnableField );
+        mxLbBaseField->set_sensitive( bEnableField );
 
         bEnableItem &= bEnableField;
-        mpFtBaseItem->Enable( bEnableItem );
-        mpLbBaseItem->Enable( bEnableItem );
+        mxFtBaseItem->set_sensitive( bEnableItem );
+        mxLbBaseItem->set_sensitive( bEnableItem );
     }
-    else if( &rLBox == mpLbBaseField )
+    else if (&rLBox == mxLbBaseField.get())
     {
         // keep "previous" and "next" entries
-        while( mpLbBaseItem->GetEntryCount() > SC_BASEITEM_USER_POS )
-            mpLbBaseItem->RemoveEntry( SC_BASEITEM_USER_POS );
+        while (mxLbBaseItem->get_count() > SC_BASEITEM_USER_POS)
+             mxLbBaseItem->remove(SC_BASEITEM_USER_POS);
 
         // update item list for current base field
         mbEmptyItem = false;
-        size_t nBasePos = mpLbBaseField->GetSelectedEntryPos();
-        if( nBasePos < mrLabelVec.size() )
+        size_t nBasePos = mxLbBaseField->get_active();
+        if (nBasePos < mrLabelVec.size())
         {
             const vector<ScDPLabelData::Member>& rMembers = mrLabelVec[nBasePos]->maMembers;
-            mbEmptyItem = lclFillListBox(*mpLbBaseItem, rMembers, SC_BASEITEM_USER_POS);
+            mbEmptyItem = lclFillListBox(*mxLbBaseItem, rMembers, SC_BASEITEM_USER_POS);
             // build cache for base names.
             NameMapType aMap;
             for (const auto& rMember : rMembers)
@@ -465,14 +437,14 @@ IMPL_LINK( ScDPFunctionDlg, SelectHdl, ListBox&, rLBox, void )
         }
 
         // select base item
-        sal_uInt16 nItemPos = (mpLbBaseItem->GetEntryCount() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
-        mpLbBaseItem->SelectEntryPos( nItemPos );
+        sal_uInt16 nItemPos = (mxLbBaseItem->get_count() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
+        mxLbBaseItem->set_active( nItemPos );
     }
 }
 
-IMPL_LINK_NOARG(ScDPFunctionDlg, DblClickHdl, ListBox&, void)
+IMPL_LINK_NOARG(ScDPFunctionDlg, DblClickHdl, weld::TreeView&, void)
 {
-    mpBtnOk->Click();
+    m_xDialog->response(RET_OK);
 }
 
 ScDPSubtotalDlg::ScDPSubtotalDlg(weld::Window* pParent, ScDPObject& rDPObj,
@@ -486,7 +458,7 @@ ScDPSubtotalDlg::ScDPSubtotalDlg(weld::Window* pParent, ScDPObject& rDPObj,
     , mxRbNone(m_xBuilder->weld_radio_button("none"))
     , mxRbAuto(m_xBuilder->weld_radio_button("auto"))
     , mxRbUser(m_xBuilder->weld_radio_button("user"))
-    , mxLbFunc(new DPFunctionListBox(m_xBuilder->weld_tree_view("functions")))
+    , mxLbFunc(new ScDPFunctionListBox(m_xBuilder->weld_tree_view("functions")))
     , mxFtName(m_xBuilder->weld_label("name"))
     , mxCbShowAll(m_xBuilder->weld_check_button("showall"))
     , mxBtnOk(m_xBuilder->weld_button("ok"))
diff --git a/sc/source/ui/inc/pvfundlg.hxx b/sc/source/ui/inc/pvfundlg.hxx
index 258bf0a5349b..2193043e0cd1 100644
--- a/sc/source/ui/inc/pvfundlg.hxx
+++ b/sc/source/ui/inc/pvfundlg.hxx
@@ -23,40 +23,18 @@
 #include <com/sun/star/sheet/DataPilotFieldReference.hpp>
 #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
 
-#include <vcl/fixed.hxx>
-#include <vcl/layout.hxx>
-#include <vcl/lstbox.hxx>
-#include <vcl/dialog.hxx>
-#include <vcl/button.hxx>
-#include <vcl/field.hxx>
 #include <vcl/weld.hxx>
-#include <svx/checklbx.hxx>
-#include <sfx2/controlwrapper.hxx>
 #include <pivot.hxx>
 
 #include <memory>
 #include <unordered_map>
 
-typedef sfx::ListBoxWrapper< sal_Int32 > ScDPListBoxWrapper;
-
 class ScDPObject;
 
-class ScDPFunctionListBox : public ListBox
+class ScDPFunctionListBox
 {
 public:
-    ScDPFunctionListBox(vcl::Window* pParent, WinBits nStyle);
-
-    void                SetSelection( PivotFunc nFuncMask );
-    PivotFunc           GetSelection() const;
-
-private:
-    void                FillFunctionNames();
-};
-
-class DPFunctionListBox
-{
-public:
-    DPFunctionListBox(std::unique_ptr<weld::TreeView> xControl);
+    ScDPFunctionListBox(std::unique_ptr<weld::TreeView> xControl);
 
     void                SetSelection( PivotFunc nFuncMask );
     PivotFunc           GetSelection() const;
@@ -72,14 +50,13 @@ private:
     void                FillFunctionNames();
 };
 
-class ScDPFunctionDlg : public ModalDialog
+class ScDPFunctionDlg : public weld::GenericDialogController
 {
     typedef std::unordered_map< OUString, OUString > NameMapType;
 public:
-    explicit            ScDPFunctionDlg( vcl::Window* pParent, const ScDPLabelDataVector& rLabelVec,
-                            const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData );
+    explicit ScDPFunctionDlg(weld::Window* pParent, const ScDPLabelDataVector& rLabelVec,
+                             const ScDPLabelData& rLabelData, const ScPivotFuncData& rFuncData );
     virtual ~ScDPFunctionDlg() override;
-    virtual void            dispose() override;
     PivotFunc               GetFuncMask() const;
     css::sheet::DataPilotFieldReference GetFieldRef() const;
 
@@ -92,24 +69,22 @@ private:
     /** Searches for a listbox entry, starts search at specified position. */
     sal_Int32 FindBaseItemPos( const OUString& rEntry, sal_Int32 nStartPos ) const;
 
-    DECL_LINK( SelectHdl, ListBox&, void );
-    DECL_LINK( DblClickHdl, ListBox&, void );
+    DECL_LINK(SelectHdl, weld::ComboBox&, void);
+    DECL_LINK(DblClickHdl, weld::TreeView&, void);
 
 private:
-    VclPtr<ScDPFunctionListBox> mpLbFunc;
-    VclPtr<FixedText>           mpFtName;
-    VclPtr<ListBox>             mpLbType;
-    VclPtr<FixedText>           mpFtBaseField;
-    VclPtr<ListBox>             mpLbBaseField;
-    VclPtr<FixedText>           mpFtBaseItem;
-    VclPtr<ListBox>             mpLbBaseItem;
-    VclPtr<OKButton>            mpBtnOk;
+    std::unique_ptr<ScDPFunctionListBox> mxLbFunc;
+    std::unique_ptr<weld::Label>         mxFtName;
+    std::unique_ptr<weld::ComboBox>      mxLbType;
+    std::unique_ptr<weld::Label>         mxFtBaseField;
+    std::unique_ptr<weld::ComboBox>      mxLbBaseField;
+    std::unique_ptr<weld::Label>         mxFtBaseItem;
+    std::unique_ptr<weld::ComboBox>      mxLbBaseItem;
+    std::unique_ptr<weld::Button>        mxBtnOk;
 
     NameMapType          maBaseFieldNameMap; // cache for base field display -> original name.
     NameMapType          maBaseItemNameMap;  // cache for base item display -> original name.
 
-    std::unique_ptr<ScDPListBoxWrapper>  mxLbTypeWrp;        /// Wrapper for direct usage of API constants.
-
     const ScDPLabelDataVector& mrLabelVec;  /// Data of all labels.
     bool                 mbEmptyItem;        /// true = Empty base item in listbox.
 };
@@ -142,7 +117,7 @@ private:
     std::unique_ptr<weld::RadioButton>   mxRbNone;
     std::unique_ptr<weld::RadioButton>   mxRbAuto;
     std::unique_ptr<weld::RadioButton>   mxRbUser;
-    std::unique_ptr<DPFunctionListBox>   mxLbFunc;
+    std::unique_ptr<ScDPFunctionListBox>   mxLbFunc;
     std::unique_ptr<weld::Label>         mxFtName;
     std::unique_ptr<weld::CheckButton>   mxCbShowAll;
     std::unique_ptr<weld::Button>        mxBtnOk;
diff --git a/sc/uiconfig/scalc/ui/datafielddialog.ui b/sc/uiconfig/scalc/ui/datafielddialog.ui
index f35fb6ef510b..ca5c24f0949d 100644
--- a/sc/uiconfig/scalc/ui/datafielddialog.ui
+++ b/sc/uiconfig/scalc/ui/datafielddialog.ui
@@ -2,6 +2,14 @@
 <!-- Generated with glade 3.18.3 -->
 <interface domain="sc">
   <requires lib="gtk+" version="3.18"/>
+  <object class="GtkTreeStore" id="liststore2">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkDialog" id="DataFieldDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
@@ -105,13 +113,39 @@
                         <property name="vexpand">True</property>
                         <property name="row_spacing">6</property>
                         <child>
-                          <object class="scuilo-ScDPFunctionListBox" id="functions:border">
+                          <object class="GtkScrolledWindow">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="hexpand">True</property>
                             <property name="vexpand">True</property>
-                            <child internal-child="selection">
-                              <object class="GtkTreeSelection" id="treeview-selection1"/>
+                            <property name="shadow_type">in</property>
+                            <child>
+                              <object class="GtkTreeView" id="functions">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="hexpand">True</property>
+                                <property name="vexpand">True</property>
+                                <property name="model">liststore2</property>
+                                <property name="headers_visible">False</property>
+                                <property name="search_column">1</property>
+                                <property name="show_expanders">False</property>
+                                <child internal-child="selection">
+                                  <object class="GtkTreeSelection" id="Macro Library List-selection2"/>
+                                </child>
+                                <child>
+                                  <object class="GtkTreeViewColumn" id="treeviewcolumn5">
+                                    <property name="resizable">True</property>
+                                    <property name="spacing">6</property>
+                                    <child>
+                                      <object class="GtkCellRendererText" id="cellrenderer4"/>
+                                      <attributes>
+                                        <attribute name="text">0</attribute>
+                                      </attributes>
+                                    </child>
+                                  </object>
+                                </child>
+                              </object>
                             </child>
                           </object>
                           <packing>
diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index a84945d15c1e..c95a0a48d51a 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -478,7 +478,6 @@ custom_widgets = [
     'ScCondFormatList',
     'ScCsvTableBox',
     'ScCursorRefEdit',
-    'ScDPFunctionListBox',
     'ScDataTableView',
     'ScDoubleField',
     'ScEditWindow',


More information about the Libreoffice-commits mailing list