extras/source/glade/libreoffice-catalog.xml.in |    3 
 include/vcl/weld.hxx                           |    4 
 sw/source/ui/fldui/flddb.cxx                   |  320 +++++++++----------
 sw/source/ui/fldui/flddb.hxx                   |   45 +-
 sw/source/uibase/dbui/dbtree.cxx               |  421 ++-----------------------
 sw/source/uibase/inc/dbtree.hxx                |   41 --
 sw/source/uibase/inc/numfmtlb.hxx              |    3 
 sw/uiconfig/swriter/ui/flddbpage.ui            |   97 +++++
 vcl/source/app/salvtables.cxx                  |   12 
 vcl/unx/gtk3/gtk3gtkinst.cxx                   |   40 ++
 10 files changed, 370 insertions(+), 616 deletions(-)

New commits:
commit 7bf4edd62fd0e34a0bd79cc918155ac5043b091b
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Sun Mar 17 21:01:06 2019 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue Mar 19 12:10:13 2019 +0100

    weld SwFieldDBPage
    
    Change-Id: Ic4919fa3caa2106598ed8da3cec5deffa506eee1
    Reviewed-on: https://gerrit.libreoffice.org/69401
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/extras/source/glade/libreoffice-catalog.xml.in 
b/extras/source/glade/libreoffice-catalog.xml.in
index 5af0548a670c..020f29f1b5ca 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -183,9 +183,6 @@
     <glade-widget-class title="Check List Box" name="svxcorelo-SvxCheckListBox"
                         generic-name="Check List Box" parent="GtkTreeView"
                         icon-name="widget-gtk-treeview"/>
-    <glade-widget-class title="SwDBTreeList" name="swlo-SwDBTreeList"
-                        generic-name="SwDBTreeList" parent="GtkTreeView"
-                        icon-name="widget-gtk-treeview"/>
     <glade-widget-class title="Table Preview" name="swuilo-AutoFmtPreview"
                         generic-name="Table Preview Window" 
parent="GtkDrawingArea"
                         icon-name="widget-gtk-drawingarea"/>
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index a88cfe5ea04f..910f977db66c 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -138,6 +138,9 @@ public:
 
     virtual OUString get_accessible_description() const = 0;
 
+    virtual void set_accessible_relation_labeled_by(weld::Widget* pLabel) = 0;
+    virtual void set_accessible_relation_label_for(weld::Widget* pLabeled) = 0;
+
     virtual void set_tooltip_text(const OUString& rTip) = 0;
     virtual OUString get_tooltip_text() const = 0;
 
@@ -954,6 +957,7 @@ public:
     }
 
     void save_value() { m_sSavedValue = get_text(); }
+    OUString const& get_saved_value() const { return m_sSavedValue; }
     bool get_value_changed_from_saved() const { return m_sSavedValue != 
get_text(); }
 };
 
diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx
index 56da644402fd..0f0aab017bf8 100644
--- a/sw/source/ui/fldui/flddb.cxx
+++ b/sw/source/ui/fldui/flddb.cxx
@@ -33,43 +33,39 @@
 #define USER_DATA_VERSION_1     "1"
 #define USER_DATA_VERSION USER_DATA_VERSION_1
 
-SwFieldDBPage::SwFieldDBPage(vcl::Window* pParent, const SfxItemSet *const 
pCoreSet)
-    : SwFieldPage(pParent, "FieldDbPage",
-        "modules/swriter/ui/flddbpage.ui", pCoreSet)
+SwFieldDBPage::SwFieldDBPage(TabPageParent pParent, const SfxItemSet *const 
pCoreSet)
+    : SwFieldPage(pParent, "modules/swriter/ui/flddbpage.ui", "FieldDbPage", 
pCoreSet)
     , m_nOldFormat(0)
     , m_nOldSubType(0)
+    , m_xTypeLB(m_xBuilder->weld_tree_view("type"))
+    , m_xDatabaseTLB(new DBTreeList(m_xBuilder->weld_tree_view("select")))
+    , m_xAddDBPB(m_xBuilder->weld_button("browse"))
+    , m_xCondition(m_xBuilder->weld_widget("condgroup"))
+    , m_xConditionED(new SwConditionEdit(m_xBuilder->weld_entry("condition")))
+    , m_xValue(m_xBuilder->weld_widget("recgroup"))
+    , m_xValueED(m_xBuilder->weld_entry("recnumber"))
+    , m_xDBFormatRB(m_xBuilder->weld_radio_button("fromdatabasecb"))
+    , m_xNewFormatRB(m_xBuilder->weld_radio_button("userdefinedcb"))
+    , m_xNumFormatLB(new 
SwNumFormatListBox(m_xBuilder->weld_combo_box("numformat")))
+    , m_xFormatLB(m_xBuilder->weld_combo_box("format"))
+    , m_xFormat(m_xBuilder->weld_widget("formatframe"))
 {
-    get(m_pTypeLB, "type");
-    m_pTypeLB->SetStyle(m_pTypeLB->GetStyle() | WB_SORT);
-    get(m_pDatabaseTLB, "select");
-    get(m_pCondition, "condgroup");
-    get(m_pConditionED, "condition");
-    get(m_pValue, "recgroup");
-    get(m_pValueED, "recnumber");
-    get(m_pFormat, "formatframe");
-    get(m_pAddDBPB, "browse");
-    get(m_pDBFormatRB, "fromdatabasecb");
-    get(m_pNewFormatRB, "userdefinedcb");
-    get(m_pNumFormatLB, "numformat");
-    get(m_pFormatLB, "format");
-    m_pFormatLB->SetStyle(m_pFormatLB->GetStyle() | WB_SORT);
-
-    long nHeight = m_pTypeLB->GetTextHeight() * 14;
-    m_pTypeLB->set_height_request(nHeight);
-    m_pDatabaseTLB->set_height_request(nHeight);
-
-    long nWidth = m_pTypeLB->LogicToPixel(Size(FIELD_COLUMN_WIDTH, 0), 
MapMode(MapUnit::MapAppFont)).Width();
-    m_pTypeLB->set_width_request(nWidth);
-    m_pDatabaseTLB->set_width_request(nWidth*2);
-
-    m_aOldNumSelectHdl = m_pNumFormatLB->GetSelectHdl();
-
-    m_pNumFormatLB->SetSelectHdl(LINK(this, SwFieldDBPage, NumSelectHdl));
-    m_pDatabaseTLB->SetSelectHdl(LINK(this, SwFieldDBPage, TreeSelectHdl));
-    m_pDatabaseTLB->SetDoubleClickHdl(LINK(this, SwFieldDBPage, 
TreeListBoxInsertHdl));
-
-    m_pValueED->SetModifyHdl(LINK(this, SwFieldDBPage, ModifyHdl));
-    m_pAddDBPB->SetClickHdl(LINK(this, SwFieldDBPage, AddDBHdl));
+    SetTypeSel(-1); //TODO
+
+    m_xTypeLB->make_sorted();
+    m_xFormatLB->make_sorted();
+
+    auto nWidth = LogicToPixel(Size(FIELD_COLUMN_WIDTH, 0), 
MapMode(MapUnit::MapAppFont)).Width();
+    auto nHeight = m_xTypeLB->get_height_rows(14);
+    m_xTypeLB->set_size_request(nWidth, nHeight);
+    m_xDatabaseTLB->set_size_request(nWidth*2, nHeight);
+
+    m_xNumFormatLB->connect_changed(LINK(this, SwFieldDBPage, NumSelectHdl));
+    m_xDatabaseTLB->connect_changed(LINK(this, SwFieldDBPage, TreeSelectHdl));
+    m_xDatabaseTLB->connect_row_activated(LINK(this, SwFieldDBPage, 
TreeViewInsertHdl));
+
+    m_xValueED->connect_changed(LINK(this, SwFieldDBPage, ModifyHdl));
+    m_xAddDBPB->connect_clicked(LINK(this, SwFieldDBPage, AddDBHdl));
 }
 
 SwFieldDBPage::~SwFieldDBPage()
@@ -87,18 +83,6 @@ void SwFieldDBPage::dispose()
     if (pDbManager)
         pDbManager->RevokeLastRegistrations();
 
-    m_pTypeLB.clear();
-    m_pDatabaseTLB.clear();
-    m_pAddDBPB.clear();
-    m_pCondition.clear();
-    m_pConditionED.clear();
-    m_pValue.clear();
-    m_pValueED.clear();
-    m_pDBFormatRB.clear();
-    m_pNewFormatRB.clear();
-    m_pNumFormatLB.clear();
-    m_pFormatLB.clear();
-    m_pFormat.clear();
     SwFieldPage::dispose();
 }
 
@@ -107,11 +91,11 @@ void SwFieldDBPage::Reset(const SfxItemSet*)
 {
     Init(); // general initialization
 
-    m_pTypeLB->SetUpdateMode(false);
-    const sal_Int32 nOldPos = m_pTypeLB->GetSelectedEntryPos();
-    m_sOldDBName = m_pDatabaseTLB->GetDBName(m_sOldTableName, 
m_sOldColumnName);
+    const sal_Int32 nOldPos = m_xTypeLB->get_selected_index();
+    m_xTypeLB->freeze();
+    m_sOldDBName = m_xDatabaseTLB->GetDBName(m_sOldTableName, 
m_sOldColumnName);
 
-    m_pTypeLB->Clear();
+    m_xTypeLB->clear();
 
     if (!IsFieldEdit())
     {
@@ -121,42 +105,42 @@ void SwFieldDBPage::Reset(const SfxItemSet*)
         for(sal_uInt16 i = rRg.nStart; i < rRg.nEnd; ++i)
         {
             const sal_uInt16 nTypeId = SwFieldMgr::GetTypeId(i);
-            const sal_Int32 nPos = 
m_pTypeLB->InsertEntry(SwFieldMgr::GetTypeStr(i));
-            m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
+            m_xTypeLB->append(OUString::number(nTypeId), 
SwFieldMgr::GetTypeStr(i));
         }
     }
     else
     {
         const sal_uInt16 nTypeId = GetCurField()->GetTypeId();
-        const sal_Int32 nPos = m_pTypeLB->InsertEntry(
-            SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId)));
-        m_pTypeLB->SetEntryData(nPos, reinterpret_cast<void*>(nTypeId));
+        m_xTypeLB->append(OUString::number(nTypeId),
+                          SwFieldMgr::GetTypeStr(SwFieldMgr::GetPos(nTypeId)));
     }
 
+    m_xTypeLB->thaw();
+
     // select old Pos
-    if (GetTypeSel() != LISTBOX_ENTRY_NOTFOUND)
-        m_pTypeLB->SelectEntryPos(GetTypeSel());
+    if (GetTypeSel() != -1)
+        m_xTypeLB->select(GetTypeSel());
 
-    m_pFormatLB->Clear();
+    m_xFormatLB->clear();
 
     const sal_uInt16 nSize = GetFieldMgr().GetFormatCount(TYP_DBSETNUMBERFLD, 
IsFieldDlgHtmlMode());
     for( sal_uInt16 i = 0; i < nSize; ++i )
     {
-        const sal_Int32 nEntryPos = 
m_pFormatLB->InsertEntry(GetFieldMgr().GetFormatStr(TYP_DBSETNUMBERFLD, i));
         const sal_uInt16 nFormatId = GetFieldMgr().GetFormatId( 
TYP_DBSETNUMBERFLD, i );
-        m_pFormatLB->SetEntryData( nEntryPos, 
reinterpret_cast<void*>(nFormatId) );
-        if( SVX_NUM_ARABIC == nFormatId )
-            m_pFormatLB->SelectEntryPos( nEntryPos );
+        OUString sId(OUString::number(nFormatId));
+        m_xFormatLB->append(sId, 
GetFieldMgr().GetFormatStr(TYP_DBSETNUMBERFLD, i));
+        if (SVX_NUM_ARABIC == nFormatId)
+            m_xFormatLB->set_active_id(sId);
     }
 
     if (!IsFieldEdit())
     {
-        if (nOldPos != LISTBOX_ENTRY_NOTFOUND)
-            m_pTypeLB->SelectEntryPos(nOldPos);
+        if (nOldPos != -1)
+            m_xTypeLB->select(nOldPos);
 
         if (!m_sOldDBName.isEmpty())
         {
-            m_pDatabaseTLB->Select(m_sOldDBName, m_sOldTableName, 
m_sOldColumnName);
+            m_xDatabaseTLB->Select(m_sOldDBName, m_sOldTableName, 
m_sOldColumnName);
         }
         else
         {
@@ -166,7 +150,7 @@ void SwFieldDBPage::Reset(const SfxItemSet*)
             if(pSh)
             {
                 SwDBData aTmp(pSh->GetDBData());
-                m_pDatabaseTLB->Select(aTmp.sDataSource, aTmp.sCommand, 
OUString());
+                m_xDatabaseTLB->Select(aTmp.sDataSource, aTmp.sCommand, 
OUString());
             }
         }
     }
@@ -178,28 +162,29 @@ void SwFieldDBPage::Reset(const SfxItemSet*)
         if (sUserData.getToken(0, ';', 
nIdx).equalsIgnoreAsciiCase(USER_DATA_VERSION_1))
         {
             const sal_uInt16 nVal = 
static_cast<sal_uInt16>(sUserData.getToken(0, ';', nIdx).toInt32());
-            if(nVal != USHRT_MAX)
+            if (nVal != USHRT_MAX)
             {
-                for (sal_Int32 i = 0; i < m_pTypeLB->GetEntryCount(); ++i)
-                    if(nVal == 
static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(i))))
+                for (sal_Int32 i = 0, nEntryCount = m_xTypeLB->n_children(); i 
< nEntryCount; ++i)
+                {
+                    if (nVal == m_xTypeLB->get_id(i).toUInt32())
                     {
-                        m_pTypeLB->SelectEntryPos(i);
+                        m_xTypeLB->select(i);
                         break;
                     }
+                }
             }
         }
     }
     TypeHdl(nullptr);
 
-    m_pTypeLB->SetUpdateMode(true);
-    m_pTypeLB->SetSelectHdl(LINK(this, SwFieldDBPage, TypeListBoxHdl));
-    m_pTypeLB->SetDoubleClickHdl(LINK(this, SwFieldDBPage, ListBoxInsertHdl));
+    m_xTypeLB->connect_changed(LINK(this, SwFieldDBPage, TypeListBoxHdl));
+    m_xTypeLB->connect_row_activated(LINK(this, SwFieldDBPage, 
TreeViewInsertHdl));
 
     if (IsFieldEdit())
     {
-        m_pConditionED->SaveValue();
-        m_pValueED->SaveValue();
-        m_sOldDBName = m_pDatabaseTLB->GetDBName(m_sOldTableName, 
m_sOldColumnName);
+        m_xConditionED->save_value();
+        m_xValueED->save_value();
+        m_sOldDBName = m_xDatabaseTLB->GetDBName(m_sOldTableName, 
m_sOldColumnName);
         m_nOldFormat = GetCurField()->GetFormat();
         m_nOldSubType = GetCurField()->GetSubType();
     }
@@ -211,7 +196,7 @@ bool SwFieldDBPage::FillItemSet(SfxItemSet* )
     OUString sColumnName;
     SwDBData aData;
     sal_Bool bIsTable;
-    aData.sDataSource = m_pDatabaseTLB->GetDBName(sTableName, sColumnName, 
&bIsTable);
+    aData.sDataSource = m_xDatabaseTLB->GetDBName(sTableName, sColumnName, 
&bIsTable);
     aData.sCommand = sTableName;
     aData.nCommandType = bIsTable ? 0 : 1;
     SwWrtShell *pSh = GetWrtShell();
@@ -227,7 +212,7 @@ bool SwFieldDBPage::FillItemSet(SfxItemSet* )
 
     if(!aData.sDataSource.isEmpty())       // without database no new field 
command
     {
-        const sal_uInt16 nTypeId = 
static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(GetTypeSel())));
+        const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
         sal_uLong nFormat = 0;
         sal_uInt16 nSubType = 0;
 
@@ -241,32 +226,31 @@ bool SwFieldDBPage::FillItemSet(SfxItemSet* )
         {
             sDBName += sColumnName + OUStringLiteral1(DB_DELIM);
         }
-        OUString aName = sDBName + m_pConditionED->GetText();
+        OUString aName = sDBName + m_xConditionED->get_text();
 
         switch (nTypeId)
         {
         case TYP_DBFLD:
-            nFormat = m_pNumFormatLB->GetFormat();
-            if (m_pNewFormatRB->IsEnabled() && m_pNewFormatRB->IsChecked())
+            nFormat = m_xNumFormatLB->GetFormat();
+            if (m_xNewFormatRB->get_sensitive() && 
m_xNewFormatRB->get_active())
                 nSubType = nsSwExtendedSubType::SUB_OWN_FMT;
             aName = sDBName;
             break;
 
         case TYP_DBSETNUMBERFLD:
-            nFormat = reinterpret_cast<sal_uLong>(m_pFormatLB->GetEntryData(
-                                m_pFormatLB->GetSelectedEntryPos() ));
+            nFormat = m_xFormatLB->get_active_id().toUInt32();
             break;
         }
 
-        const OUString aVal(m_pValueED->GetText());
+        const OUString aVal(m_xValueED->get_text());
         OUString sTempTableName;
         OUString sTempColumnName;
-        OUString sTempDBName = m_pDatabaseTLB->GetDBName(sTempTableName, 
sTempColumnName);
+        OUString sTempDBName = m_xDatabaseTLB->GetDBName(sTempTableName, 
sTempColumnName);
         bool bDBListBoxChanged = m_sOldDBName != sTempDBName ||
             m_sOldTableName != sTempTableName || m_sOldColumnName != 
sTempColumnName;
         if (!IsFieldEdit() ||
-            m_pConditionED->IsValueChangedFromSaved() ||
-            m_pValueED->GetSavedValue() != aVal ||
+            m_xConditionED->get_value_changed_from_saved() ||
+            m_xValueED->get_saved_value() != aVal ||
              bDBListBoxChanged ||
              m_nOldFormat != nFormat || m_nOldSubType != nSubType)
         {
@@ -280,7 +264,7 @@ bool SwFieldDBPage::FillItemSet(SfxItemSet* )
 VclPtr<SfxTabPage> SwFieldDBPage::Create( TabPageParent pParent,
                                         const SfxItemSet *const pAttrSet )
 {
-    return VclPtr<SwFieldDBPage>::Create( pParent.pParent, pAttrSet );
+    return VclPtr<SwFieldDBPage>::Create( pParent, pAttrSet );
 }
 
 sal_uInt16 SwFieldDBPage::GetGroup()
@@ -288,23 +272,23 @@ sal_uInt16 SwFieldDBPage::GetGroup()
     return GRP_DB;
 }
 
-IMPL_LINK( SwFieldDBPage, TypeListBoxHdl, ListBox&, rBox, void )
+IMPL_LINK( SwFieldDBPage, TypeListBoxHdl, weld::TreeView&, rBox, void )
 {
     TypeHdl(&rBox);
 }
 
-void SwFieldDBPage::TypeHdl( ListBox const * pBox )
+void SwFieldDBPage::TypeHdl(const weld::TreeView* pBox)
 {
     // save old ListBoxPos
     const sal_Int32 nOld = GetTypeSel();
 
     // current ListBoxPos
-    SetTypeSel(m_pTypeLB->GetSelectedEntryPos());
+    SetTypeSel(m_xTypeLB->get_selected_index());
 
-    if(GetTypeSel() == LISTBOX_ENTRY_NOTFOUND)
+    if (GetTypeSel() == -1)
     {
         SetTypeSel(0);
-        m_pTypeLB->SelectEntryPos(0);
+        m_xTypeLB->select(0);
     }
 
     if (nOld == GetTypeSel())
@@ -314,9 +298,9 @@ void SwFieldDBPage::TypeHdl( ListBox const * pBox )
     if(!pSh)
         pSh = ::GetActiveWrtShell();
     bool bCond = false, bSetNo = false, bFormat = false, bDBFormat = false;
-    const sal_uInt16 nTypeId = 
static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(GetTypeSel())));
+    const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
 
-    m_pDatabaseTLB->ShowColumns(nTypeId == TYP_DBFLD);
+    m_xDatabaseTLB->ShowColumns(nTypeId == TYP_DBFLD);
 
     if (IsFieldEdit())
     {
@@ -331,36 +315,38 @@ void SwFieldDBPage::TypeHdl( ListBox const * pBox )
         {
             aData = 
static_cast<SwDBNameInfField*>(GetCurField())->GetDBData(pSh->GetDoc());
         }
-        m_pDatabaseTLB->Select(aData.sDataSource, aData.sCommand, sColumnName);
+        m_xDatabaseTLB->Select(aData.sDataSource, aData.sCommand, sColumnName);
     }
 
     switch (nTypeId)
     {
         case TYP_DBFLD:
+        {
             bFormat = true;
             bDBFormat = true;
-            m_pNumFormatLB->Show();
-            m_pFormatLB->Hide();
+            m_xNumFormatLB->show();
+            m_xFormatLB->hide();
 
-            m_pNewFormatRB->SetAccessibleRelationLabelFor(m_pNumFormatLB);
-            m_pNumFormatLB->SetAccessibleRelationLabeledBy(m_pNewFormatRB);
-            m_pFormatLB->SetAccessibleRelationLabelFor(nullptr);
+            weld::Widget& rWidget = m_xNumFormatLB->get_widget();
+            m_xNewFormatRB->set_accessible_relation_label_for(&rWidget);
+            rWidget.set_accessible_relation_labeled_by(m_xNewFormatRB.get());
+            m_xFormatLB->set_accessible_relation_label_for(nullptr);
 
             if (pBox)   // type was changed by user
-                m_pDBFormatRB->Check();
+                m_xDBFormatRB->set_active(true);
 
             if (IsFieldEdit())
             {
                 if (GetCurField()->GetFormat() != 0 && 
GetCurField()->GetFormat() != SAL_MAX_UINT32)
-                    m_pNumFormatLB->SetDefFormat(GetCurField()->GetFormat());
+                    m_xNumFormatLB->SetDefFormat(GetCurField()->GetFormat());
 
                 if (GetCurField()->GetSubType() & 
nsSwExtendedSubType::SUB_OWN_FMT)
-                    m_pNewFormatRB->Check();
+                    m_xNewFormatRB->set_active(true);
                 else
-                    m_pDBFormatRB->Check();
+                    m_xDBFormatRB->set_active(true);
             }
             break;
-
+        }
         case TYP_DBNUMSETFLD:
             bSetNo = true;
             [[fallthrough]];
@@ -368,8 +354,8 @@ void SwFieldDBPage::TypeHdl( ListBox const * pBox )
             bCond = true;
             if (IsFieldEdit())
             {
-                m_pConditionED->SetText(GetCurField()->GetPar1());
-                m_pValueED->SetText(GetCurField()->GetPar2());
+                m_xConditionED->set_text(GetCurField()->GetPar1());
+                m_xValueED->set_text(GetCurField()->GetPar2());
             }
             break;
 
@@ -377,80 +363,82 @@ void SwFieldDBPage::TypeHdl( ListBox const * pBox )
             break;
 
         case TYP_DBSETNUMBERFLD:
+        {
             bFormat = true;
-            m_pNewFormatRB->Check();
-            m_pNumFormatLB->Hide();
-            m_pFormatLB->Show();
+            m_xNewFormatRB->set_active(true);
+            m_xNumFormatLB->hide();
+            m_xFormatLB->show();
 
-            m_pNewFormatRB->SetAccessibleRelationLabelFor(m_pFormatLB);
-            m_pFormatLB->SetAccessibleRelationLabeledBy(m_pNewFormatRB);
-            m_pNumFormatLB->SetAccessibleRelationLabelFor(nullptr);
+            
m_xNewFormatRB->set_accessible_relation_label_for(m_xFormatLB.get());
+            
m_xFormatLB->set_accessible_relation_labeled_by(m_xNewFormatRB.get());
+            weld::Widget& rWidget = m_xNumFormatLB->get_widget();
+            rWidget.set_accessible_relation_label_for(nullptr);
 
             if( IsFieldEdit() )
             {
-                for( sal_Int32 nI = m_pFormatLB->GetEntryCount(); nI; )
-                    if( GetCurField()->GetFormat() == 
reinterpret_cast<sal_uLong>(
-                        m_pFormatLB->GetEntryData( --nI )))
+                for (sal_Int32 nI = m_xFormatLB->get_count(); nI;)
+                {
+                    if (GetCurField()->GetFormat() == 
m_xFormatLB->get_id(--nI).toUInt32())
                     {
-                        m_pFormatLB->SelectEntryPos( nI );
+                        m_xFormatLB->set_active( nI );
                         break;
                     }
+                }
             }
             break;
+        }
     }
 
-    m_pCondition->Enable(bCond);
-    m_pValue->Enable(bSetNo);
+    m_xCondition->set_sensitive(bCond);
+    m_xValue->set_sensitive(bSetNo);
     if (nTypeId != TYP_DBFLD)
     {
-        m_pDBFormatRB->Enable(bDBFormat);
-        m_pNewFormatRB->Enable(bDBFormat || bFormat);
-        m_pNumFormatLB->Enable(bDBFormat);
-        m_pFormatLB->Enable(bFormat);
+        m_xDBFormatRB->set_sensitive(bDBFormat);
+        m_xNewFormatRB->set_sensitive(bDBFormat || bFormat);
+        m_xNumFormatLB->set_sensitive(bDBFormat);
+        m_xFormatLB->set_sensitive(bFormat);
     }
-    m_pFormat->Enable(bDBFormat || bFormat);
+    m_xFormat->set_sensitive(bDBFormat || bFormat);
 
     if (!IsFieldEdit())
     {
-        m_pValueED->SetText(OUString());
+        m_xValueED->set_text(OUString());
         if (bCond)
-            m_pConditionED->SetText("TRUE");
+            m_xConditionED->set_text("TRUE");
         else
-            m_pConditionED->SetText(OUString());
+            m_xConditionED->set_text(OUString());
     }
 
     CheckInsert();
-
 }
 
-IMPL_LINK( SwFieldDBPage, NumSelectHdl, ListBox&, rLB, void )
+IMPL_LINK_NOARG(SwFieldDBPage, NumSelectHdl, weld::ComboBox&, void)
 {
-    m_pNewFormatRB->Check();
-    m_aOldNumSelectHdl.Call(rLB);
+    m_xNewFormatRB->set_active(true);
+    m_xNumFormatLB->CallSelectHdl();
 }
 
 void SwFieldDBPage::CheckInsert()
 {
     bool bInsert = true;
-    const sal_uInt16 nTypeId = 
static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(GetTypeSel())));
-
-    SvTreeListEntry* pEntry = m_pDatabaseTLB->GetCurEntry();
+    const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
 
-    if (pEntry)
+    std::unique_ptr<weld::TreeIter> xIter(m_xDatabaseTLB->make_iterator());
+    if (m_xDatabaseTLB->get_selected(xIter.get()))
     {
-        pEntry = m_pDatabaseTLB->GetParent(pEntry);
+        bool bEntry = m_xDatabaseTLB->iter_parent(*xIter);
 
-        if (nTypeId == TYP_DBFLD && pEntry)
-            pEntry = m_pDatabaseTLB->GetParent(pEntry);
+        if (nTypeId == TYP_DBFLD && bEntry)
+            bEntry = m_xDatabaseTLB->iter_parent(*xIter);
 
-        bInsert &= pEntry != nullptr;
+        bInsert &= bEntry;
     }
     else
         bInsert = false;
 
     if (nTypeId == TYP_DBNUMSETFLD)
     {
-        bool bHasValue = !m_pValueED->GetText().isEmpty();
+        bool bHasValue = !m_xValueED->get_text().isEmpty();
 
         bInsert &= bHasValue;
     }
@@ -458,17 +446,17 @@ void SwFieldDBPage::CheckInsert()
     EnableInsert(bInsert);
 }
 
-IMPL_LINK( SwFieldDBPage, TreeSelectHdl, SvTreeListBox *, pBox, void )
+IMPL_LINK(SwFieldDBPage, TreeSelectHdl, weld::TreeView&, rBox, void)
 {
-    SvTreeListEntry* pEntry = pBox->GetCurEntry();
-    if (pEntry)
+    std::unique_ptr<weld::TreeIter> xIter(rBox.make_iterator());
+    if (rBox.get_selected(xIter.get()))
     {
-        const sal_uInt16 nTypeId = 
static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData(GetTypeSel())));
+        const sal_uInt16 nTypeId = m_xTypeLB->get_id(GetTypeSel()).toUInt32();
 
-        pEntry = m_pDatabaseTLB->GetParent(pEntry);
+        bool bEntry = m_xDatabaseTLB->iter_parent(*xIter);
 
-        if (nTypeId == TYP_DBFLD && pEntry)
-            pEntry = m_pDatabaseTLB->GetParent(pEntry);
+        if (nTypeId == TYP_DBFLD && bEntry)
+            bEntry = m_xDatabaseTLB->iter_parent(*xIter);
 
         CheckInsert();
 
@@ -476,67 +464,67 @@ IMPL_LINK( SwFieldDBPage, TreeSelectHdl, SvTreeListBox *, 
pBox, void )
         {
             bool bNumFormat = false;
 
-            if (pEntry != nullptr)
+            if (bEntry)
             {
                 OUString sTableName;
                 OUString sColumnName;
                 sal_Bool bIsTable;
-                OUString sDBName = m_pDatabaseTLB->GetDBName(sTableName, 
sColumnName, &bIsTable);
+                OUString sDBName = m_xDatabaseTLB->GetDBName(sTableName, 
sColumnName, &bIsTable);
                 bNumFormat = GetFieldMgr().IsDBNumeric(sDBName,
                             sTableName,
                             bIsTable,
                             sColumnName);
                 if (!IsFieldEdit())
-                    m_pDBFormatRB->Check();
+                    m_xDBFormatRB->set_active(true);
             }
 
-            m_pDBFormatRB->Enable(bNumFormat);
-            m_pNewFormatRB->Enable(bNumFormat);
-            m_pNumFormatLB->Enable(bNumFormat);
-            m_pFormat->Enable(bNumFormat);
+            m_xDBFormatRB->set_sensitive(bNumFormat);
+            m_xNewFormatRB->set_sensitive(bNumFormat);
+            m_xNumFormatLB->set_sensitive(bNumFormat);
+            m_xFormat->set_sensitive(bNumFormat);
         }
     }
 }
 
-IMPL_LINK_NOARG(SwFieldDBPage, AddDBHdl, Button*, void)
+IMPL_LINK_NOARG(SwFieldDBPage, AddDBHdl, weld::Button&, void)
 {
     SwWrtShell* pSh = GetWrtShell();
     if (!pSh)
         pSh = ::GetActiveWrtShell();
 
     OUString sNewDB
-        = SwDBManager::LoadAndRegisterDataSource(GetFrameWeld(), 
pSh->GetDoc()->GetDocShell());
+        = SwDBManager::LoadAndRegisterDataSource(GetDialogFrameWeld(), 
pSh->GetDoc()->GetDocShell());
     if(!sNewDB.isEmpty())
     {
-        m_pDatabaseTLB->AddDataSource(sNewDB);
+        m_xDatabaseTLB->AddDataSource(sNewDB);
     }
 }
 
 // Modify
-IMPL_LINK_NOARG(SwFieldDBPage, ModifyHdl, Edit&, void)
+IMPL_LINK_NOARG(SwFieldDBPage, ModifyHdl, weld::Entry&, void)
 {
     CheckInsert();
 }
 
 void    SwFieldDBPage::FillUserData()
 {
-    const sal_Int32 nEntryPos = m_pTypeLB->GetSelectedEntryPos();
-    const sal_uInt16 nTypeSel = ( LISTBOX_ENTRY_NOTFOUND == nEntryPos )
-        ? USHRT_MAX : 
static_cast<sal_uInt16>(reinterpret_cast<sal_uLong>(m_pTypeLB->GetEntryData( 
nEntryPos )));
+    const sal_Int32 nEntryPos = m_xTypeLB->get_selected_index();
+    const sal_uInt16 nTypeSel = ( -1 == nEntryPos )
+        ? USHRT_MAX : m_xTypeLB->get_id(nEntryPos).toUInt32();
     SetUserData(USER_DATA_VERSION ";" + OUString::number( nTypeSel ));
 }
 
 void SwFieldDBPage::ActivateMailMergeAddress()
 {
-    m_pTypeLB->SelectEntryPos(m_pTypeLB->GetEntryPos( reinterpret_cast<const 
void*>( TYP_DBFLD ) ));
-    m_pTypeLB->GetSelectHdl().Call(*m_pTypeLB);
+    m_xTypeLB->select_id(OUString::number(TYP_DBFLD));
+    TypeListBoxHdl(*m_xTypeLB);
     const SwDBData& rData = SW_MOD()->GetDBConfig()->GetAddressSource();
-    m_pDatabaseTLB->Select(rData.sDataSource, rData.sCommand, OUString());
+    m_xDatabaseTLB->Select(rData.sDataSource, rData.sCommand, OUString());
 }
 
 void SwFieldDBPage::SetWrtShell(SwWrtShell& rSh)
 {
-    m_pDatabaseTLB->SetWrtShell(rSh);
+    m_xDatabaseTLB->SetWrtShell(rSh);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/fldui/flddb.hxx b/sw/source/ui/fldui/flddb.hxx
index b8121bb2affd..913788cba606 100644
--- a/sw/source/ui/fldui/flddb.hxx
+++ b/sw/source/ui/fldui/flddb.hxx
@@ -31,34 +31,31 @@
 
 class SwFieldDBPage : public SwFieldPage
 {
-    VclPtr<ListBox>            m_pTypeLB;
-    VclPtr<SwDBTreeList>       m_pDatabaseTLB;
-
-    VclPtr<PushButton>         m_pAddDBPB;
-
-    VclPtr<VclContainer>       m_pCondition;
-    VclPtr<ConditionEdit>      m_pConditionED;
-    VclPtr<VclContainer>       m_pValue;
-    VclPtr<Edit>               m_pValueED;
-    VclPtr<RadioButton>        m_pDBFormatRB;
-    VclPtr<RadioButton>        m_pNewFormatRB;
-    VclPtr<NumFormatListBox>   m_pNumFormatLB;
-    VclPtr<ListBox>            m_pFormatLB;
-    VclPtr<VclContainer>       m_pFormat;
-
     OUString            m_sOldDBName;
     OUString            m_sOldTableName;
     OUString            m_sOldColumnName;
     sal_uLong           m_nOldFormat;
     sal_uInt16          m_nOldSubType;
-    Link<ListBox&,void> m_aOldNumSelectHdl;
 
-    DECL_LINK( TypeListBoxHdl, ListBox&, void );
-    DECL_LINK( NumSelectHdl, ListBox&, void );
-    DECL_LINK( TreeSelectHdl, SvTreeListBox*, void );
-    DECL_LINK( ModifyHdl, Edit&, void );
-    DECL_LINK( AddDBHdl, Button*, void );
-    void TypeHdl(ListBox const *);
+    std::unique_ptr<weld::TreeView> m_xTypeLB;
+    std::unique_ptr<DBTreeList> m_xDatabaseTLB;
+    std::unique_ptr<weld::Button> m_xAddDBPB;
+    std::unique_ptr<weld::Widget> m_xCondition;
+    std::unique_ptr<SwConditionEdit> m_xConditionED;
+    std::unique_ptr<weld::Widget> m_xValue;
+    std::unique_ptr<weld::Entry> m_xValueED;
+    std::unique_ptr<weld::RadioButton> m_xDBFormatRB;
+    std::unique_ptr<weld::RadioButton> m_xNewFormatRB;
+    std::unique_ptr<SwNumFormatListBox> m_xNumFormatLB;
+    std::unique_ptr<weld::ComboBox> m_xFormatLB;
+    std::unique_ptr<weld::Widget> m_xFormat;
+
+    DECL_LINK( TypeListBoxHdl, weld::TreeView&, void );
+    DECL_LINK( NumSelectHdl, weld::ComboBox&, void );
+    DECL_LINK( TreeSelectHdl, weld::TreeView&, void );
+    DECL_LINK( ModifyHdl, weld::Entry&, void );
+    DECL_LINK( AddDBHdl, weld::Button&, void );
+    void TypeHdl(const weld::TreeView*);
 
     void                CheckInsert();
 
@@ -68,9 +65,9 @@ protected:
     virtual sal_uInt16      GetGroup() override;
 
 public:
-                        SwFieldDBPage(vcl::Window* pParent, const SfxItemSet* 
rSet);
+    SwFieldDBPage(TabPageParent pParent, const SfxItemSet* rSet);
 
-                        virtual ~SwFieldDBPage() override;
+    virtual ~SwFieldDBPage() override;
     virtual void        dispose() override;
 
     static VclPtr<SfxTabPage>  Create(TabPageParent pParent, const SfxItemSet* 
rAttrSet);
diff --git a/sw/source/uibase/dbui/dbtree.cxx b/sw/source/uibase/dbui/dbtree.cxx
index 3be7b4242f5e..fce39c1b02b4 100644
--- a/sw/source/uibase/dbui/dbtree.cxx
+++ b/sw/source/uibase/dbui/dbtree.cxx
@@ -133,359 +133,6 @@ Reference<XConnection>  
SwDBTreeList_Impl::GetConnection(const OUString& rSource
     return xRet;
 }
 
-SwDBTreeList::SwDBTreeList(vcl::Window *pParent, WinBits nStyle)
-    : SvTreeListBox(pParent, nStyle)
-    , bInitialized(false)
-    , bShowColumns(false)
-    , pImpl(new SwDBTreeList_Impl)
-{
-    if (IsVisible())
-        InitTreeList();
-}
-
-VCL_BUILDER_FACTORY_CONSTRUCTOR(SwDBTreeList, WB_TABSTOP)
-
-Size SwDBTreeList::GetOptimalSize() const
-{
-    return LogicToPixel(Size(100, 62), MapMode(MapUnit::MapAppFont));
-}
-
-SwDBTreeList::~SwDBTreeList()
-{
-    disposeOnce();
-}
-
-void SwDBTreeList::dispose()
-{
-    pImpl = nullptr;
-    SvTreeListBox::dispose();
-}
-
-void SwDBTreeList::InitTreeList()
-{
-    if(!pImpl->HasContext() && pImpl->GetWrtShell())
-        return;
-    SetSelectionMode(SelectionMode::Single);
-    
SetStyle(GetStyle()|WB_HASLINES|WB_CLIPCHILDREN|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
-    // don't set font, so that the Control's font is being applied!
-    SetSpaceBetweenEntries(0);
-    SetNodeBitmaps(Image(StockImage::Yes, RID_BMP_COLLAPSE),
-                   Image(StockImage::Yes, RID_BMP_EXPAND));
-
-    SetDragDropMode(DragDropMode::APP_COPY);
-
-    GetModel()->SetCompareHdl(LINK(this, SwDBTreeList, DBCompare));
-
-    Sequence< OUString > aDBNames = pImpl->GetContext()->getElementNames();
-    auto const sort = comphelper::string::NaturalStringSorter(
-        comphelper::getProcessComponentContext(),
-        Application::GetSettings().GetUILanguageTag().getLocale());
-    std::sort(
-        aDBNames.begin(), aDBNames.end(),
-        [&sort](OUString const & x, OUString const & y)
-        { return sort.compare(x, y) < 0; });
-    const OUString* pDBNames = aDBNames.getConstArray();
-    long nCount = aDBNames.getLength();
-
-    Image aImg(StockImage::Yes, RID_BMP_DB);
-    for(long i = 0; i < nCount; i++)
-    {
-        OUString sDBName(pDBNames[i]);
-        Reference<XConnection> xConnection = pImpl->GetConnection(sDBName);
-        if (xConnection.is())
-        {
-            InsertEntry(sDBName, aImg, aImg, nullptr, true);
-        }
-    }
-    Select(OUString(), OUString(), OUString());
-
-    bInitialized = true;
-}
-
-void SwDBTreeList::AddDataSource(const OUString& rSource)
-{
-    Image aImg(StockImage::Yes, RID_BMP_DB);
-    SvTreeListEntry* pEntry = InsertEntry(rSource, aImg, aImg, nullptr, true);
-    SvTreeListBox::Select(pEntry);
-}
-
-void SwDBTreeList::ShowColumns(bool bShowCol)
-{
-    if (bShowCol != bShowColumns)
-    {
-        bShowColumns = bShowCol;
-        OUString sTableName;
-        OUString sColumnName;
-        const OUString sDBName(GetDBName(sTableName, sColumnName));
-
-        SetUpdateMode(false);
-
-        SvTreeListEntry* pEntry = First();
-
-        while (pEntry)
-        {
-            pEntry = GetRootLevelParent( pEntry );
-            Collapse(pEntry);       // zuklappen
-
-            SvTreeListEntry* pChild;
-            while ((pChild = FirstChild(pEntry)) != nullptr)
-                GetModel()->Remove(pChild);
-
-            pEntry = Next(pEntry);
-        }
-
-        if (!sDBName.isEmpty())
-        {
-            Select(sDBName, sTableName, sColumnName);   // force 
RequestingChildren
-        }
-        SetUpdateMode(true);
-    }
-}
-
-void  SwDBTreeList::RequestingChildren(SvTreeListEntry* pParent)
-{
-    if (!pParent->HasChildren())
-    {
-        if (GetParent(pParent)) // column names
-        {
-            try
-            {
-
-                OUString sSourceName = GetEntryText(GetParent(pParent));
-                OUString sTableName = GetEntryText(pParent);
-
-                if(!pImpl->GetContext()->hasByName(sSourceName))
-                    return;
-                Reference<XConnection> xConnection = 
pImpl->GetConnection(sSourceName);
-                bool bTable = pParent->GetUserData() == nullptr;
-                Reference<XColumnsSupplier> xColsSupplier;
-                if(bTable)
-                {
-                    Reference<XTablesSupplier> xTSupplier(xConnection, 
UNO_QUERY);
-                    if(xTSupplier.is())
-                    {
-                        Reference<XNameAccess> xTables = 
xTSupplier->getTables();
-                        OSL_ENSURE(xTables->hasByName(sTableName), "table not 
available anymore?");
-                        try
-                        {
-                            Any aTable = xTables->getByName(sTableName);
-                            Reference<XPropertySet> xPropSet;
-                            aTable >>= xPropSet;
-                            xColsSupplier.set(xPropSet, UNO_QUERY);
-                        }
-                        catch (const Exception&)
-                        {
-                        }
-                    }
-                }
-                else
-                {
-                    Reference<XQueriesSupplier> xQSupplier(xConnection, 
UNO_QUERY);
-                    if(xQSupplier.is())
-                    {
-                        Reference<XNameAccess> xQueries = 
xQSupplier->getQueries();
-                        OSL_ENSURE(xQueries->hasByName(sTableName), "table not 
available anymore?");
-                        try
-                        {
-                            Any aQuery = xQueries->getByName(sTableName);
-                            Reference<XPropertySet> xPropSet;
-                            aQuery >>= xPropSet;
-                            xColsSupplier.set(xPropSet, UNO_QUERY);
-                        }
-                        catch (const Exception&)
-                        {
-                        }
-                    }
-                }
-
-                if(xColsSupplier.is())
-                {
-                    Reference <XNameAccess> xCols = 
xColsSupplier->getColumns();
-                    Sequence< OUString> aColNames = xCols->getElementNames();
-                    const OUString* pColNames = aColNames.getConstArray();
-                    long nCount = aColNames.getLength();
-                    for (long i = 0; i < nCount; i++)
-                    {
-                        OUString sName = pColNames[i];
-                        InsertEntry(sName, pParent);
-                    }
-                }
-            }
-            catch (const Exception&)
-            {
-            }
-        }
-        else    // table names
-        {
-            try
-            {
-                OUString sSourceName = GetEntryText(pParent);
-                if(!pImpl->GetContext()->hasByName(sSourceName))
-                    return;
-                Reference<XConnection> xConnection = 
pImpl->GetConnection(sSourceName);
-                if (xConnection.is())
-                {
-                    Reference<XTablesSupplier> xTSupplier(xConnection, 
UNO_QUERY);
-                    if(xTSupplier.is())
-                    {
-                        Reference<XNameAccess> xTables = 
xTSupplier->getTables();
-                        Sequence< OUString> aTableNames = 
xTables->getElementNames();
-                        OUString sTableName;
-                        long nCount = aTableNames.getLength();
-                        const OUString* pTableNames = 
aTableNames.getConstArray();
-                        Image aImg(StockImage::Yes, RID_BMP_DBTABLE);
-                        for (long i = 0; i < nCount; i++)
-                        {
-                            sTableName = pTableNames[i];
-                            SvTreeListEntry* pTableEntry = 
InsertEntry(sTableName, aImg, aImg, pParent, bShowColumns);
-                            //to discriminate between queries and tables the 
user data of table entries is set
-                            pTableEntry->SetUserData(nullptr);
-                        }
-                    }
-
-                    Reference<XQueriesSupplier> xQSupplier(xConnection, 
UNO_QUERY);
-                    if(xQSupplier.is())
-                    {
-                        Reference<XNameAccess> xQueries = 
xQSupplier->getQueries();
-                        Sequence< OUString> aQueryNames = 
xQueries->getElementNames();
-                        OUString sQueryName;
-                        long nCount = aQueryNames.getLength();
-                        const OUString* pQueryNames = 
aQueryNames.getConstArray();
-                        Image aImg(StockImage::Yes, RID_BMP_DBQUERY);
-                        for (long i = 0; i < nCount; i++)
-                        {
-                            sQueryName = pQueryNames[i];
-                            SvTreeListEntry* pQueryEntry = 
InsertEntry(sQueryName, aImg, aImg, pParent, bShowColumns);
-                            
pQueryEntry->SetUserData(reinterpret_cast<void*>(1));
-                        }
-                    }
-                }
-            }
-            catch (const Exception&)
-            {
-            }
-        }
-    }
-}
-
-IMPL_LINK( SwDBTreeList, DBCompare, const SvSortData&, rData, sal_Int32 )
-{
-    SvTreeListEntry* pRight = const_cast<SvTreeListEntry*>(rData.pRight);
-
-    if (GetParent(pRight) && GetParent(GetParent(pRight)))
-        return 1; // don't sort column names
-
-    return DefaultCompare(rData);   // otherwise call base class
-}
-
-OUString SwDBTreeList::GetDBName(OUString& rTableName, OUString& rColumnName, 
sal_Bool* pbIsTable)
-{
-    OUString sDBName;
-    SvTreeListEntry* pEntry = FirstSelected();
-
-    if (pEntry && GetParent(pEntry))
-    {
-        if (GetParent(GetParent(pEntry)))
-        {
-            rColumnName = GetEntryText(pEntry);
-            pEntry = GetParent(pEntry); // column name was selected
-        }
-        sDBName = GetEntryText(GetParent(pEntry));
-        if(pbIsTable)
-        {
-            *pbIsTable = pEntry->GetUserData() == nullptr;
-        }
-        rTableName = GetEntryText(pEntry);
-    }
-    return sDBName;
-}
-
-// Format: database.table
-void SwDBTreeList::Select(const OUString& rDBName, const OUString& rTableName, 
const OUString& rColumnName)
-{
-    SvTreeListEntry* pParent;
-    SvTreeListEntry* pChild;
-    sal_uInt16 nParent = 0;
-    sal_uInt16 nChild = 0;
-
-    while ((pParent = GetEntry(nParent++)) != nullptr)
-    {
-        if (rDBName == GetEntryText(pParent))
-        {
-            if (!pParent->HasChildren())
-                RequestingChildren(pParent);
-            while ((pChild = GetEntry(pParent, nChild++)) != nullptr)
-            {
-                if (rTableName == GetEntryText(pChild))
-                {
-                    pParent = pChild;
-
-                    if (bShowColumns && !rColumnName.isEmpty())
-                    {
-                        nChild = 0;
-
-                        if (!pParent->HasChildren())
-                            RequestingChildren(pParent);
-
-                        while ((pChild = GetEntry(pParent, nChild++)) != 
nullptr)
-                            if (rColumnName == GetEntryText(pChild))
-                                break;
-                    }
-                    if (!pChild)
-                        pChild = pParent;
-
-                    MakeVisible(pChild);
-                    SvTreeListBox::Select(pChild);
-                    return;
-                }
-            }
-        }
-    }
-}
-
-void SwDBTreeList::StartDrag( sal_Int8 /*nAction*/, const Point& /*rPosPixel*/ 
)
-{
-    OUString sTableName;
-    OUString sColumnName;
-    OUString sDBName( GetDBName( sTableName, sColumnName ));
-    if (!sDBName.isEmpty())
-    {
-        rtl::Reference<TransferDataContainer> pContainer = new 
TransferDataContainer;
-        if( !sColumnName.isEmpty() )
-        {
-            // drag database field
-            rtl::Reference< svx::OColumnTransferable > xColTransfer( new 
svx::OColumnTransferable(
-                            sDBName,
-                            sTableName,
-                            sColumnName,
-                            
(ColumnTransferFormatFlags::FIELD_DESCRIPTOR|ColumnTransferFormatFlags::COLUMN_DESCRIPTOR)
 ) );
-            xColTransfer->addDataToContainer( pContainer.get() );
-        }
-
-        sDBName += "." + sTableName;
-        if (!sColumnName.isEmpty())
-        {
-            sDBName += "." + sColumnName;
-        }
-
-        pContainer->CopyString( SotClipboardFormatId::STRING, sDBName );
-        pContainer->StartDrag( this, DND_ACTION_COPY | DND_ACTION_LINK,
-                                Link<sal_Int8,void>() );
-    }
-}
-
-sal_Int8 SwDBTreeList::AcceptDrop( const AcceptDropEvent& /*rEvt*/ )
-{
-    return DND_ACTION_NONE;
-}
-
-void SwDBTreeList::SetWrtShell(SwWrtShell& rSh)
-{
-    pImpl->SetWrtShell(rSh);
-    if (IsVisible() && !bInitialized)
-        InitTreeList();
-}
-
 DBTreeList::DBTreeList(std::unique_ptr<weld::TreeView> xTreeView)
     : bInitialized(false)
     , bShowColumns(false)
@@ -493,10 +140,6 @@ DBTreeList::DBTreeList(std::unique_ptr<weld::TreeView> 
xTreeView)
     , m_xTreeView(std::move(xTreeView))
 {
     m_xTreeView->connect_expanding(LINK(this, DBTreeList, 
RequestingChildrenHdl));
-#if 0
-    if (m_xTreeView->get_visible())
-        InitTreeList();
-#endif
 }
 
 DBTreeList::~DBTreeList()
@@ -508,10 +151,6 @@ void DBTreeList::InitTreeList()
     if (!pImpl->HasContext() && pImpl->GetWrtShell())
         return;
 
-//TODO    SetDragDropMode(DragDropMode::APP_COPY);
-
-//TODO    GetModel()->SetCompareHdl(LINK(this, DBTreeList, DBCompare));
-
     Sequence< OUString > aDBNames = pImpl->GetContext()->getElementNames();
     auto const sort = comphelper::string::NaturalStringSorter(
         comphelper::getProcessComponentContext(),
@@ -675,25 +314,13 @@ IMPL_LINK(DBTreeList, RequestingChildrenHdl, const 
weld::TreeIter&, rParent, boo
     return true;
 }
 
-#if 0
-IMPL_LINK( DBTreeList, DBCompare, const SvSortData&, rData, sal_Int32 )
-{
-    SvTreeListEntry* pRight = const_cast<SvTreeListEntry*>(rData.pRight);
-
-    if (GetParent(pRight) && GetParent(GetParent(pRight)))
-        return 1; // don't sort column names
-
-    return DefaultCompare(rData);   // otherwise call base class
-}
-#endif
-
 OUString DBTreeList::GetDBName(OUString& rTableName, OUString& rColumnName, 
sal_Bool* pbIsTable)
 {
     OUString sDBName;
     std::unique_ptr<weld::TreeIter> xIter(m_xTreeView->make_iterator());
     if (m_xTreeView->get_selected(xIter.get()) && 
m_xTreeView->get_iter_depth(*xIter))
     {
-        if (m_xTreeView->get_iter_depth(*xIter) > 2)
+        if (m_xTreeView->get_iter_depth(*xIter) > 1)
         {
             rColumnName = m_xTreeView->get_text(*xIter);
             m_xTreeView->iter_parent(*xIter); // column name was selected
@@ -772,4 +399,50 @@ void DBTreeList::SetWrtShell(SwWrtShell& rSh)
         InitTreeList();
 }
 
+namespace
+{
+    void GotoRootLevelParent(weld::TreeView& rTreeView, weld::TreeIter& rEntry)
+    {
+        while (rTreeView.get_iter_depth(rEntry))
+            rTreeView.iter_parent(rEntry);
+    }
+}
+
+void DBTreeList::ShowColumns(bool bShowCol)
+{
+    if (bShowCol != bShowColumns)
+    {
+        bShowColumns = bShowCol;
+        OUString sTableName;
+        OUString sColumnName;
+        const OUString sDBName(GetDBName(sTableName, sColumnName));
+
+        m_xTreeView->freeze();
+
+        std::unique_ptr<weld::TreeIter> xIter(m_xTreeView->make_iterator());
+        std::unique_ptr<weld::TreeIter> xChild(m_xTreeView->make_iterator());
+        if (m_xTreeView->get_iter_first(*xIter))
+        {
+            do
+            {
+                GotoRootLevelParent(*m_xTreeView, *xIter);
+                m_xTreeView->collapse_row(*xIter);
+                while (m_xTreeView->iter_has_child(*xIter))
+                {
+                    m_xTreeView->copy_iterator(*xIter, *xChild);
+                    m_xTreeView->iter_children(*xChild);
+                    m_xTreeView->remove(*xChild);
+                }
+            } while (m_xTreeView->iter_next(*xIter));
+        }
+
+        m_xTreeView->thaw();
+
+        if (!sDBName.isEmpty())
+        {
+            Select(sDBName, sTableName, sColumnName);   // force 
RequestingChildren
+        }
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/dbtree.hxx b/sw/source/uibase/inc/dbtree.hxx
index 987412684063..bf729c86f597 100644
--- a/sw/source/uibase/inc/dbtree.hxx
+++ b/sw/source/uibase/inc/dbtree.hxx
@@ -29,40 +29,6 @@
 class SwDBTreeList_Impl;
 class SwWrtShell;
 
-class SW_DLLPUBLIC SwDBTreeList : public SvTreeListBox
-{
-    bool            bInitialized;
-    bool            bShowColumns;
-
-    rtl::Reference<SwDBTreeList_Impl> pImpl;
-
-    DECL_DLLPRIVATE_LINK( DBCompare, const SvSortData&, sal_Int32 );
-
-    SAL_DLLPRIVATE void          InitTreeList();
-    SAL_DLLPRIVATE virtual void  RequestingChildren( SvTreeListEntry* pParent 
) override;
-
-    SAL_DLLPRIVATE virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) 
override;
-    SAL_DLLPRIVATE virtual void  StartDrag( sal_Int8 nAction, const Point& 
rPosPixel ) override;
-
-    using SvTreeListBox::Select;
-
-public:
-    SwDBTreeList(vcl::Window* pParent, WinBits nStyle);
-    virtual ~SwDBTreeList() override;
-    virtual void dispose() override;
-    virtual Size GetOptimalSize() const override;
-
-    OUString GetDBName( OUString& rTableName, OUString& rColumnName, sal_Bool* 
pbIsTable = nullptr);
-
-    void    Select( const OUString& rDBName, const OUString& rTableName,
-                    const OUString& rColumnName );
-
-    void    ShowColumns(bool bShowCol);
-    void    SetWrtShell(SwWrtShell& rSh);
-
-    void    AddDataSource(const OUString& rSource);
-};
-
 class SW_DLLPUBLIC DBTreeList
 {
     bool            bInitialized;
@@ -70,10 +36,7 @@ class SW_DLLPUBLIC DBTreeList
 
     rtl::Reference<SwDBTreeList_Impl> pImpl;
     std::unique_ptr<weld::TreeView> m_xTreeView;
-#if 0
 
-    DECL_DLLPRIVATE_LINK( DBCompare, const SvSortData&, sal_Int32 );
-#endif
     DECL_DLLPRIVATE_LINK(RequestingChildrenHdl, const weld::TreeIter&, bool);
     SAL_DLLPRIVATE void          InitTreeList();
 
@@ -86,13 +49,17 @@ public:
     void    Select( const OUString& rDBName, const OUString& rTableName,
                     const OUString& rColumnName );
 
+    void    ShowColumns(bool bShowCol);
+
     void    SetWrtShell(SwWrtShell& rSh);
 
     void    AddDataSource(const OUString& rSource);
 
     void connect_changed(const Link<weld::TreeView&, void>& rLink) { 
m_xTreeView->connect_changed(rLink); }
+    void connect_row_activated(const Link<weld::TreeView&, void>& rLink) { 
m_xTreeView->connect_row_activated(rLink); }
     std::unique_ptr<weld::TreeIter> make_iterator(const weld::TreeIter* pOrig 
= nullptr) const { return m_xTreeView->make_iterator(pOrig); }
     bool get_selected(weld::TreeIter* pIter) const { return 
m_xTreeView->get_selected(pIter); }
+    bool iter_parent(weld::TreeIter& rIter) const { return 
m_xTreeView->iter_parent(rIter); }
     int get_iter_depth(const weld::TreeIter& rIter) const { return 
m_xTreeView->get_iter_depth(rIter); }
     void set_size_request(int nWidth, int nHeight) { 
m_xTreeView->set_size_request(nWidth, nHeight); }
 };
diff --git a/sw/source/uibase/inc/numfmtlb.hxx 
b/sw/source/uibase/inc/numfmtlb.hxx
index 15749c65ec84..6d120242b18c 100644
--- a/sw/source/uibase/inc/numfmtlb.hxx
+++ b/sw/source/uibase/inc/numfmtlb.hxx
@@ -87,6 +87,8 @@ public:
     ~SwNumFormatListBox();
 
     void            clear();
+    void            show() { mxControl->show(); }
+    void            hide() { mxControl->hide(); }
 
     void            SetFormatType(const SvNumFormatType nFormatType);
     void            SetDefFormat(const sal_uInt32 nDefFormat);
@@ -96,6 +98,7 @@ public:
 
     void            set_sensitive(bool bSensitive) { 
mxControl->set_sensitive(bSensitive); }
     void            connect_changed(const Link<weld::ComboBox&, void>& rLink) 
{ mxControl->connect_changed(rLink); }
+    weld::ComboBox& get_widget() const { return *mxControl; }
 };
 
 #endif
diff --git a/sw/uiconfig/swriter/ui/flddbpage.ui 
b/sw/uiconfig/swriter/ui/flddbpage.ui
index 6c0d90835d49..a1d47bce72d3 100644
--- a/sw/uiconfig/swriter/ui/flddbpage.ui
+++ b/sw/uiconfig/swriter/ui/flddbpage.ui
@@ -1,7 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface domain="sw">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
+  <object class="GtkTreeStore" id="liststore1">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
+  <object class="GtkTreeStore" id="liststore2">
+    <columns>
+      <!-- column-name expander -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
   <object class="GtkBox" id="FieldDbPage">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -37,14 +54,38 @@
                     <property name="hexpand">True</property>
                     <property name="top_padding">6</property>
                     <child>
-                      <object class="GtkTreeView" id="type: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>
-                        <property name="search_column">0</property>
-                        <property name="show_expanders">False</property>
-                        <child internal-child="selection">
-                          <object class="GtkTreeSelection" 
id="treeview-selection"/>
+                        <property name="shadow_type">in</property>
+                        <child>
+                          <object class="GtkTreeView" id="type">
+                            <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">liststore1</property>
+                            <property name="headers_visible">False</property>
+                            <property name="search_column">0</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="treeviewcolumn3">
+                                <property name="spacing">6</property>
+                                <child>
+                                  <object class="GtkCellRendererText" 
id="cellrenderer4"/>
+                                  <attributes>
+                                    <attribute name="text">0</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
                         </child>
                       </object>
                     </child>
@@ -96,7 +137,7 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="swlo-ConditionEdit" id="condition">
+                      <object class="GtkEntry" id="condition">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="hexpand">True</property>
@@ -195,13 +236,46 @@
                     <property name="hexpand">True</property>
                     <property name="top_padding">6</property>
                     <child>
-                      <object class="swlo-SwDBTreeList" id="select: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="SwDBTreeList-selection1"/>
+                        <property name="shadow_type">in</property>
+                        <child>
+                          <object class="GtkTreeView" id="select">
+                            <property name="width_request">-1</property>
+                            <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="show_expanders">True</property>
+                            <property name="search_column">1</property>
+                            <property name="enable_tree_lines">True</property>
+                            <child internal-child="selection">
+                              <object class="GtkTreeSelection" id="Macro 
Library List-selection2"/>
+                            </child>
+                            <child>
+                              <object class="GtkTreeViewColumn" 
id="treeviewcolumn8">
+                                <property name="spacing">6</property>
+                                <child>
+                                  <object class="GtkCellRendererPixbuf" 
id="cellrenderertext5"/>
+                                  <attributes>
+                                    <attribute name="pixbuf">0</attribute>
+                                  </attributes>
+                                </child>
+                                <child>
+                                  <object class="GtkCellRendererText" 
id="cellrenderertext6"/>
+                                  <attributes>
+                                    <attribute name="text">1</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
                         </child>
                       </object>
                     </child>
@@ -299,7 +373,6 @@
                             <property name="xalign">0</property>
                             <property name="active">True</property>
                             <property name="draw_indicator">True</property>
-                            <property name="group">userdefinedcb</property>
                           </object>
                           <packing>
                             <property name="left_attach">0</property>
@@ -347,7 +420,7 @@
                               </packing>
                             </child>
                             <child>
-                              <object class="swlo-NumFormatListBox" 
id="numformat">
+                              <object class="GtkComboBoxText" id="numformat">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
                                 <property name="hexpand">True</property>
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 47f2ecda410f..7173f8ad5b03 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -468,6 +468,18 @@ public:
         return m_xWidget->GetAccessibleDescription();
     }
 
+    virtual void set_accessible_relation_labeled_by(weld::Widget* pLabel) 
override
+    {
+        vcl::Window* pAtkLabel = pLabel ? 
dynamic_cast<SalInstanceWidget&>(*pLabel).getWidget() : nullptr;
+        m_xWidget->SetAccessibleRelationLabeledBy(pAtkLabel);
+    }
+
+    virtual void set_accessible_relation_label_for(weld::Widget* pLabeled) 
override
+    {
+        vcl::Window* pAtkLabeled = pLabeled ? 
dynamic_cast<SalInstanceWidget&>(*pLabeled).getWidget() : nullptr;
+        m_xWidget->SetAccessibleRelationLabelFor(pAtkLabeled);
+    }
+
     virtual void set_tooltip_text(const OUString& rTip) override
     {
         m_xWidget->SetQuickHelpText(rTip);
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 2a7551456922..2056ea4068e5 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1718,6 +1718,46 @@ public:
         return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8);
     }
 
+    virtual void set_accessible_relation_labeled_by(weld::Widget* pLabel) 
override
+    {
+        AtkObject* pAtkObject = gtk_widget_get_accessible(m_pWidget);
+        if (!pAtkObject)
+            return;
+        AtkObject *pAtkLabel = pLabel ? 
gtk_widget_get_accessible(dynamic_cast<GtkInstanceWidget&>(*pLabel).getWidget())
 : nullptr;
+        AtkRelationSet *pRelationSet = atk_object_ref_relation_set(pAtkObject);
+        AtkRelation *pRelation = 
atk_relation_set_get_relation_by_type(pRelationSet, ATK_RELATION_LABELLED_BY);
+        if (pRelation)
+            atk_relation_set_remove(pRelationSet, pRelation);
+        if (pAtkLabel)
+        {
+            AtkObject *obj_array[1];
+            obj_array[0] = pAtkLabel;
+            pRelation = atk_relation_new(obj_array, 1, 
ATK_RELATION_LABELLED_BY);
+            atk_relation_set_add(pRelationSet, pRelation);
+        }
+        g_object_unref(pRelationSet);
+    }
+
+    virtual void set_accessible_relation_label_for(weld::Widget* pLabeled) 
override
+    {
+        AtkObject* pAtkObject = gtk_widget_get_accessible(m_pWidget);
+        if (!pAtkObject)
+            return;
+        AtkObject *pAtkLabeled = pLabeled ? 
gtk_widget_get_accessible(dynamic_cast<GtkInstanceWidget&>(*pLabeled).getWidget())
 : nullptr;
+        AtkRelationSet *pRelationSet = atk_object_ref_relation_set(pAtkObject);
+        AtkRelation *pRelation = 
atk_relation_set_get_relation_by_type(pRelationSet, ATK_RELATION_LABEL_FOR);
+        if (pRelation)
+            atk_relation_set_remove(pRelationSet, pRelation);
+        if (pAtkLabeled)
+        {
+            AtkObject *obj_array[1];
+            obj_array[0] = pAtkLabeled;
+            pRelation = atk_relation_new(obj_array, 1, ATK_RELATION_LABEL_FOR);
+            atk_relation_set_add(pRelationSet, pRelation);
+        }
+        g_object_unref(pRelationSet);
+    }
+
     virtual bool get_extents_relative_to(weld::Widget& rRelative, int& x, int 
&y, int& width, int &height) override
     {
         //for toplevel windows this is sadly futile under wayland, so we can't 
tell where a dialog is in order to allow
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to