[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - dbaccess/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 21 09:20:22 UTC 2021


 dbaccess/source/ui/browser/dsEntriesNoExp.cxx |   56 +-------------------------
 dbaccess/source/ui/browser/unodatbr.cxx       |   12 +++--
 dbaccess/source/ui/inc/unodatbr.hxx           |    5 --
 3 files changed, 12 insertions(+), 61 deletions(-)

New commits:
commit 7d5a4c031221d8099c554a84684ce42b0390be1f
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Sep 20 11:44:50 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Sep 21 11:19:49 2021 +0200

    Resolves: tdf#144564 don't query siblings and parent to determine type
    
    because this is used during sorting of the tree elements so its position
    isn't necessarily meaningful during the sort. DBTreeListUserData is
    supposed to exist for elements not staged for removal and that already
    has the type as a member
    
    Change-Id: Ie1004dbcdca2fae8711941d98a084103a0b15815
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122355
    Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>
    Tested-by: Jenkins

diff --git a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
index 0db9f29f5236..debc3fa51a67 100644
--- a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
+++ b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
@@ -55,59 +55,9 @@ OUString SbaTableQueryBrowser::GetEntryText(const weld::TreeIter& rEntry) const
 
 SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getEntryType(const weld::TreeIter& rEntry) const
 {
-    std::unique_ptr<weld::TreeIter> xRootEntry = m_pTreeView->GetRootLevelParent(&rEntry);
-    weld::TreeView& rTreeView = m_pTreeView->GetWidget();
-
-    if (rTreeView.iter_compare(*xRootEntry, rEntry) == 0)
-        return etDatasource;
-
-    std::unique_ptr<weld::TreeIter> xEntryParent(rTreeView.make_iterator(&rEntry));
-    if (!rTreeView.iter_parent(*xEntryParent))
-        xEntryParent.reset();
-
-    std::unique_ptr<weld::TreeIter> xTables;
-    std::unique_ptr<weld::TreeIter> xQueries;
-
-    std::unique_ptr<weld::TreeIter> xContainer = rTreeView.make_iterator(xRootEntry.get());
-    if (rTreeView.iter_children(*xContainer))
-    {
-        // 1st child is queries
-        xQueries = rTreeView.make_iterator(xContainer.get());
-
-        if (rTreeView.iter_next_sibling(*xContainer))
-        {
-            // 2nd child is tables
-            xTables = rTreeView.make_iterator(xContainer.get());
-        }
-    }
-
-    if (xTables && rTreeView.iter_compare(*xTables, rEntry) == 0)
-        return etTableContainer;
-
-    if (xQueries && rTreeView.iter_compare(*xQueries, rEntry) == 0)
-        return etQueryContainer;
-
-    if (xTables && xEntryParent && rTreeView.iter_compare(*xTables, *xEntryParent) == 0)
-        return etTableOrView;
-
-    if (xQueries && xEntryParent)
-    {
-        if (rTreeView.iter_compare(*xQueries, *xEntryParent) == 0)
-        {
-            DBTreeListUserData* pEntryData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rEntry).toUInt64());
-            if (pEntryData)
-                return pEntryData->eType;
-            return etQuery;
-        }
-
-        while (rTreeView.iter_compare(*xEntryParent, *xQueries) != 0)
-        {
-            if (!rTreeView.iter_parent(*xEntryParent))
-                return etUnknown;
-        }
-    }
-
-    return etQueryContainer;
+    const weld::TreeView& rTreeView = m_pTreeView->GetWidget();
+    DBTreeListUserData* pEntryData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rEntry).toUInt64());
+    return pEntryData ? pEntryData->eType : etUnknown;
 }
 
 void SbaTableQueryBrowser::select(const weld::TreeIter* pEntry, bool bSelect)
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index 685db87d432e..3d0fd95acc43 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -1183,7 +1183,7 @@ std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::getObjectEntry(const OUStr
                                         {
                                             pEntryData->eType = etQueryContainer;
                                         }
-                                        implAppendEntry(xObject.get(), sPath, pEntryData, pEntryData->eType);
+                                        implAppendEntry(xObject.get(), sPath, pEntryData);
                                     }
                                 }
                             }
@@ -2107,7 +2107,7 @@ void SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAcce
                     if ( xChild.is() )
                         pEntryData->eType = etQueryContainer;
                 }
-                implAppendEntry(&rParent, rName, pEntryData, pEntryData->eType);
+                implAppendEntry(&rParent, rName, pEntryData);
             }
         }
     }
@@ -2119,8 +2119,10 @@ void SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAcce
     rTreeView.make_sorted();
 }
 
-std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::implAppendEntry(const weld::TreeIter* pParent, const OUString& rName, void* pUserData, EntryType eEntryType)
+std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::implAppendEntry(const weld::TreeIter* pParent, const OUString& rName, DBTreeListUserData* pUserData)
 {
+    EntryType eEntryType = pUserData->eType;
+
     std::unique_ptr<ImageProvider> xImageProvider(getImageProviderFor(pParent));
 
     OUString aImage = xImageProvider->getImageId(rName, getDatabaseObjectType(eEntryType));
@@ -2776,7 +2778,7 @@ void SAL_CALL SbaTableQueryBrowser::elementInserted(const ContainerEvent& rEvent
             }
             pNewData->eType = etQuery;
         }
-        implAppendEntry(xEntry.get(), ::comphelper::getString(rEvent.Accessor), pNewData, pNewData->eType);
+        implAppendEntry(xEntry.get(), ::comphelper::getString(rEvent.Accessor), pNewData);
 
         rTreeView.make_sorted();
     }
@@ -2878,7 +2880,7 @@ void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEve
                 if ( etTableOrView == pData->eType )
                 {
                     // only insert userdata when we have a table because the query is only a commanddefinition object and not a query
-                     _rEvent.Element >>= pData->xObjectProperties;  // remember the new element
+                    _rEvent.Element >>= pData->xObjectProperties;  // remember the new element
                 }
                 else
                 {
diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx
index 637f173da20e..7899fed5fec6 100644
--- a/dbaccess/source/ui/inc/unodatbr.hxx
+++ b/dbaccess/source/ui/inc/unodatbr.hxx
@@ -46,6 +46,7 @@ namespace com::sun::star::container { class XNameContainer; }
 namespace dbaui
 {
     struct DBTreeEditedEntry;
+    struct DBTreeListUserData;
     class ImageProvider;
 
     typedef ::cppu::ImplHelper5 <   css::frame::XStatusListener
@@ -354,9 +355,7 @@ namespace dbaui
         std::unique_ptr<weld::TreeIter> implAppendEntry(
             const weld::TreeIter* pParent,
             const OUString& rName,
-            void* pUserData,
-            EntryType eEntryType
-        );
+            DBTreeListUserData* pUserData);
 
         /// loads the grid control with the data object specified (which may be a table, a query or a command)
         bool implLoadAnything(const OUString& _rDataSourceName, const OUString& _rCommand,


More information about the Libreoffice-commits mailing list