diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-09-20 11:44:50 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2021-09-30 11:02:04 +0200 |
commit | 973296a9ee257c4dcd5c599cc6333e43ac86754d (patch) | |
tree | bc547d7da3ba0fc3655bf95d2d4e2c5c1028dd83 /dbaccess | |
parent | 92162bc1ac5202d2109d8c5b6ea0162df2bab7fc (diff) |
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@allotropia.de>
Tested-by: Jenkins
(cherry picked from commit 7d5a4c031221d8099c554a84684ce42b0390be1f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122744
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/browser/dsEntriesNoExp.cxx | 56 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/unodatbr.cxx | 12 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/unodatbr.hxx | 5 |
3 files changed, 12 insertions, 61 deletions
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 be1d04927957..3548ca399e96 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 e147b44b9e02..229e0c39e402 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, |