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
diff --git a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
index 0db9f29..debc3fa 100644
--- a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
+++ b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
@@ -55,59 +55,9 @@
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 8b6904a..32588dd 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -1182,7 +1182,7 @@
{
pEntryData->eType = etQueryContainer;
}
implAppendEntry(xObject.get(), sPath, pEntryData, pEntryData->eType);
implAppendEntry(xObject.get(), sPath, pEntryData);
}
}
}
@@ -2106,7 +2106,7 @@
if ( xChild.is() )
pEntryData->eType = etQueryContainer;
}
implAppendEntry(&rParent, rName, pEntryData, pEntryData->eType);
implAppendEntry(&rParent, rName, pEntryData);
}
}
}
@@ -2118,8 +2118,10 @@
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));
@@ -2775,7 +2777,7 @@
}
pNewData->eType = etQuery;
}
implAppendEntry(xEntry.get(), ::comphelper::getString(rEvent.Accessor), pNewData, pNewData->eType);
implAppendEntry(xEntry.get(), ::comphelper::getString(rEvent.Accessor), pNewData);
rTreeView.make_sorted();
}
@@ -2877,7 +2879,7 @@
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 e147b44..229e0c3 100644
--- a/dbaccess/source/ui/inc/unodatbr.hxx
+++ b/dbaccess/source/ui/inc/unodatbr.hxx
@@ -46,6 +46,7 @@
namespace dbaui
{
struct DBTreeEditedEntry;
struct DBTreeListUserData;
class ImageProvider;
typedef ::cppu::ImplHelper5 < css::frame::XStatusListener
@@ -354,9 +355,7 @@
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,