summaryrefslogtreecommitdiff
path: root/dbaccess/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-08-10 19:49:25 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-08-12 20:22:23 +0200
commit5f7cf9ccba25a94c275ec67936dc29f0adb4129a (patch)
tree2d2063dd0cfd2b1e2946b66db0c70b05fb6f7903 /dbaccess/source
parentf88c85b09b0e4557c2ce9216941244cce0750169 (diff)
use InterimDBTreeListBox
Change-Id: I2f345f1a4fd6c7a4dc7be831f85a9f728ee477ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100496 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'dbaccess/source')
-rw-r--r--dbaccess/source/ui/browser/dataview.cxx19
-rw-r--r--dbaccess/source/ui/browser/dbexchange.cxx41
-rw-r--r--dbaccess/source/ui/browser/dbtreeview.cxx18
-rw-r--r--dbaccess/source/ui/browser/dbtreeview.hxx20
-rw-r--r--dbaccess/source/ui/browser/dsEntriesNoExp.cxx171
-rw-r--r--dbaccess/source/ui/browser/dsbrowserDnD.cxx153
-rw-r--r--dbaccess/source/ui/browser/genericcontroller.cxx4
-rw-r--r--dbaccess/source/ui/browser/unodatbr.cxx1002
-rw-r--r--dbaccess/source/ui/control/dbtreelistbox.cxx16
-rw-r--r--dbaccess/source/ui/control/listviewitems.cxx68
-rw-r--r--dbaccess/source/ui/control/tabletree.cxx1
-rw-r--r--dbaccess/source/ui/inc/TableCopyHelper.hxx4
-rw-r--r--dbaccess/source/ui/inc/dbexchange.hxx19
-rw-r--r--dbaccess/source/ui/inc/dbtreelistbox.hxx8
-rw-r--r--dbaccess/source/ui/inc/imageprovider.hxx2
-rw-r--r--dbaccess/source/ui/inc/listviewitems.hxx54
-rw-r--r--dbaccess/source/ui/inc/unodatbr.hxx115
-rw-r--r--dbaccess/source/ui/misc/imageprovider.cxx4
18 files changed, 845 insertions, 874 deletions
diff --git a/dbaccess/source/ui/browser/dataview.cxx b/dbaccess/source/ui/browser/dataview.cxx
index 099199bc2ae4..b293fadd3cc4 100644
--- a/dbaccess/source/ui/browser/dataview.cxx
+++ b/dbaccess/source/ui/browser/dataview.cxx
@@ -131,12 +131,6 @@ namespace dbaui
{
Window::StateChanged( nType );
- if ( nType == StateChangedType::ControlBackground )
- {
- // Check if we need to get new images for normal/high contrast mode
- m_xController->notifyHiContrastChanged();
- }
-
if ( nType != StateChangedType::InitShow )
return;
@@ -158,20 +152,7 @@ namespace dbaui
DBG_UNHANDLED_EXCEPTION("dbaccess");
}
}
- void ODataView::DataChanged( const DataChangedEvent& rDCEvt )
- {
- Window::DataChanged( rDCEvt );
- if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
- (rDCEvt.GetType() == DataChangedEventType::DISPLAY) ||
- (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
- ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
- (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
- {
- // Check if we need to get new images for normal/high contrast mode
- m_xController->notifyHiContrastChanged();
- }
- }
void ODataView::attachFrame(const Reference< XFrame >& _xFrame)
{
m_pAccel->init(m_xContext, _xFrame);
diff --git a/dbaccess/source/ui/browser/dbexchange.cxx b/dbaccess/source/ui/browser/dbexchange.cxx
index 2fe0a3b21ed5..a6d649674f07 100644
--- a/dbaccess/source/ui/browser/dbexchange.cxx
+++ b/dbaccess/source/ui/browser/dbexchange.cxx
@@ -58,6 +58,10 @@ namespace dbaui
}
}
+ ODataClipboard::ODataClipboard()
+ {
+ }
+
ODataClipboard::ODataClipboard(
const OUString& _rDatasource,
const sal_Int32 _nCommandType,
@@ -88,6 +92,43 @@ namespace dbaui
m_pRtf.set( new ORTFImportExport( getDescriptor(),_rxORB, _rxFormatter ) );
}
+ void ODataClipboard::Update(
+ const OUString& rDatasource,
+ const sal_Int32 nCommandType,
+ const OUString& rCommand,
+ const Reference< XConnection >& rxConnection,
+ const Reference< XNumberFormatter >& rxFormatter,
+ const Reference< XComponentContext >& rxORB)
+ {
+ ClearFormats();
+
+ ODataAccessObjectTransferable::Update(rDatasource, nCommandType, rCommand, rxConnection);
+
+ lcl_setListener(rxConnection, this, true);
+
+ m_pHtml.set(new OHTMLImportExport(getDescriptor(), rxORB, rxFormatter));
+ m_pRtf.set(new ORTFImportExport(getDescriptor(), rxORB, rxFormatter));
+
+ AddSupportedFormats();
+ }
+
+ void ODataClipboard::Update(
+ const OUString& rDatasource,
+ const sal_Int32 nCommandType,
+ const OUString& rCommand,
+ const Reference< XNumberFormatter >& rxFormatter,
+ const Reference< XComponentContext >& rxORB)
+ {
+ ClearFormats();
+
+ ODataAccessObjectTransferable::Update(rDatasource, nCommandType, rCommand);
+
+ m_pHtml.set(new OHTMLImportExport(getDescriptor(), rxORB, rxFormatter));
+ m_pRtf.set(new ORTFImportExport(getDescriptor(), rxORB, rxFormatter));
+
+ AddSupportedFormats();
+ }
+
ODataClipboard::ODataClipboard( const Reference< XPropertySet >& i_rAliveForm,
const Sequence< Any >& i_rSelectedRows,
const bool i_bBookmarkSelection,
diff --git a/dbaccess/source/ui/browser/dbtreeview.cxx b/dbaccess/source/ui/browser/dbtreeview.cxx
index 38464068bbb7..f5d1d023c869 100644
--- a/dbaccess/source/ui/browser/dbtreeview.cxx
+++ b/dbaccess/source/ui/browser/dbtreeview.cxx
@@ -29,14 +29,13 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
DBTreeView::DBTreeView( vcl::Window* pParent, WinBits nBits)
- : Window( pParent, nBits )
- , m_pTreeListBox(nullptr)
+ : Window(pParent, nBits)
+ , m_pTreeListBox(VclPtr<InterimDBTreeListBox>::Create(this))
{
-
- m_pTreeListBox = VclPtr<DBTreeListBox>::Create(this, WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONS | WB_HSCROLL |WB_HASBUTTONSATROOT);
- m_pTreeListBox->EnableCheckButton(nullptr);
+#if 0
m_pTreeListBox->SetDragDropMode( DragDropMode::NONE );
m_pTreeListBox->EnableInplaceEditing( true );
+#endif
m_pTreeListBox->SetHelpId(HID_TLB_TREELISTBOX);
m_pTreeListBox->Show();
}
@@ -52,14 +51,9 @@ void DBTreeView::dispose()
vcl::Window::dispose();
}
-SvTreeList* DBTreeView::GetTreeModel()
-{
- return m_pTreeListBox->GetModel();
-}
-
-void DBTreeView::SetPreExpandHandler(const Link<SvTreeListEntry*,bool>& _rHdl)
+void DBTreeView::SetPreExpandHandler(const Link<const weld::TreeIter&,bool>& rHdl)
{
- m_pTreeListBox->SetPreExpandHandler(_rHdl);
+ m_pTreeListBox->GetWidget().connect_expanding(rHdl);
}
void DBTreeView::setCopyHandler(const Link<LinkParamNone*,void>& _rHdl)
diff --git a/dbaccess/source/ui/browser/dbtreeview.hxx b/dbaccess/source/ui/browser/dbtreeview.hxx
index 892a6beab394..0070b50f3ee8 100644
--- a/dbaccess/source/ui/browser/dbtreeview.hxx
+++ b/dbaccess/source/ui/browser/dbtreeview.hxx
@@ -20,20 +20,17 @@
#ifndef INCLUDED_DBACCESS_SOURCE_UI_BROWSER_DBTREEVIEW_HXX
#define INCLUDED_DBACCESS_SOURCE_UI_BROWSER_DBTREEVIEW_HXX
+#include <vcl/weld.hxx>
#include <vcl/window.hxx>
-class SvTreeList;
-class SvTreeListEntry;
-
namespace dbaui
{
- class DBTreeListBox;
- // - DBTreeView -
+ class InterimDBTreeListBox;
class DBTreeView : public vcl::Window
{
private:
- VclPtr<DBTreeListBox> m_pTreeListBox;
+ VclPtr<InterimDBTreeListBox> m_pTreeListBox;
protected:
// window overridables
virtual void Resize() override;
@@ -45,17 +42,16 @@ namespace dbaui
virtual void dispose() override;
/** sets a handler which is called when a list box entry is to be expanded.
- <p>When calling the link, the parameter is an SvTreeListEntry marking the entry to be expanded.
+ <p>When calling the link, the parameter is a TreeIter marking the entry to be expanded.
</p>
*/
- void SetPreExpandHandler(const Link<SvTreeListEntry*,bool>& _rHdl);
+ void SetPreExpandHandler(const Link<const weld::TreeIter&,bool>& rHdl);
- void setCopyHandler(const Link<LinkParamNone*,void>& _rHdl);
+ void setCopyHandler(const Link<LinkParamNone*,void>& rHdl);
- SvTreeList* GetTreeModel();
- void setSelChangeHdl(const Link<LinkParamNone*,void>& _rHdl);
+ void setSelChangeHdl(const Link<LinkParamNone*,void>& rHdl);
- DBTreeListBox& getListBox() const { return *m_pTreeListBox; }
+ InterimDBTreeListBox& getListBox() const { return *m_pTreeListBox; }
virtual void GetFocus() override;
};
diff --git a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
index 7e9bfc851360..c6b160c09b23 100644
--- a/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
+++ b/dbaccess/source/ui/browser/dsEntriesNoExp.cxx
@@ -23,7 +23,6 @@
#include <unodatbr.hxx>
#include <browserids.hxx>
-#include <listviewitems.hxx>
#include <imageprovider.hxx>
#include <osl/diagnose.h>
#include "dbtreeview.hxx"
@@ -37,10 +36,10 @@ using namespace ::svx;
namespace dbaui
{
-SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getChildType( SvTreeListEntry const * _pEntry ) const
+SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getChildType(const weld::TreeIter& rEntry) const
{
- OSL_ENSURE(isContainer(_pEntry), "SbaTableQueryBrowser::getChildType: invalid entry!");
- switch (getEntryType(_pEntry))
+ OSL_ENSURE(isContainer(rEntry), "SbaTableQueryBrowser::getChildType: invalid entry!");
+ switch (getEntryType(rEntry))
{
case etTableContainer:
return etTableOrView;
@@ -52,88 +51,98 @@ SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getChildType( SvTreeListEn
return etUnknown;
}
-OUString SbaTableQueryBrowser::GetEntryText( SvTreeListEntry* _pEntry ) const
+OUString SbaTableQueryBrowser::GetEntryText(const weld::TreeIter& rEntry) const
{
- return m_pTreeView->getListBox().GetEntryText(_pEntry);
+ return m_pTreeView->getListBox().GetWidget().get_text(rEntry);
}
-SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getEntryType( const SvTreeListEntry* _pEntry ) const
+SbaTableQueryBrowser::EntryType SbaTableQueryBrowser::getEntryType(const weld::TreeIter& rEntry) const
{
- if (!_pEntry)
- return etUnknown;
+ std::unique_ptr<weld::TreeIter> xRootEntry = m_pTreeView->getListBox().GetRootLevelParent(&rEntry);
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
- SvTreeListEntry* pRootEntry = m_pTreeView->getListBox().GetRootLevelParent(const_cast<SvTreeListEntry*>(_pEntry));
- SvTreeListEntry* pEntryParent = m_pTreeView->getListBox().GetParent(const_cast<SvTreeListEntry*>(_pEntry));
- SvTreeListEntry* pTables = m_pTreeView->getListBox().GetEntry(pRootEntry, CONTAINER_TABLES);
- SvTreeListEntry* pQueries = m_pTreeView->getListBox().GetEntry(pRootEntry, CONTAINER_QUERIES);
+ if (rTreeView.iter_compare(*xRootEntry, rEntry) == 0)
+ return etDatasource;
-#ifdef DBG_UTIL
- OUString sTest;
- if (pTables) sTest = m_pTreeView->getListBox().GetEntryText(pTables);
- if (pQueries) sTest = m_pTreeView->getListBox().GetEntryText(pQueries);
-#endif
+ std::unique_ptr<weld::TreeIter> xEntryParent(rTreeView.make_iterator(&rEntry));
+ if (!rTreeView.iter_parent(*xEntryParent))
+ xEntryParent.reset();
- if (pRootEntry == _pEntry)
- return etDatasource;
+ 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 (pTables == _pEntry)
+ if (xTables && rTreeView.iter_compare(*xTables, rEntry) == 0)
return etTableContainer;
- if (pQueries == _pEntry)
+ if (xQueries && rTreeView.iter_compare(*xQueries, rEntry) == 0)
return etQueryContainer;
- if (pTables == pEntryParent)
+ if (xTables && xEntryParent && rTreeView.iter_compare(*xTables, *xEntryParent) == 0)
return etTableOrView;
- if (pQueries == pEntryParent)
+ if (xQueries && xEntryParent)
{
- DBTreeListUserData* pEntryData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData());
- if ( pEntryData )
- return pEntryData->eType;
+ if (rTreeView.iter_compare(*xQueries, *xEntryParent) == 0)
+ {
+ DBTreeListUserData* pEntryData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rEntry).toUInt64());
+ if (pEntryData)
+ return pEntryData->eType;
+ return etQuery;
+ }
- return etQuery;
- }
- while( pEntryParent != pQueries )
- {
- pEntryParent = m_pTreeView->getListBox().GetParent(pEntryParent);
- if ( !pEntryParent )
- return etUnknown;
+ while (rTreeView.iter_compare(*xEntryParent, *xQueries) != 0)
+ {
+ if (!rTreeView.iter_parent(*xEntryParent))
+ return etUnknown;
+ }
}
return etQueryContainer;
}
-void SbaTableQueryBrowser::select(SvTreeListEntry* _pEntry, bool _bSelect)
+void SbaTableQueryBrowser::select(weld::TreeIter* pEntry, bool bSelect)
{
- SvLBoxItem* pTextItem = _pEntry ? _pEntry->GetFirstItem(SvLBoxItemType::String) : nullptr;
- if (pTextItem)
+ if (pEntry)
{
- static_cast<OBoldListboxString*>(pTextItem)->emphasize(_bSelect);
- m_pTreeView->GetTreeModel()->InvalidateEntry(_pEntry);
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ rTreeView.set_text_emphasis(*pEntry, bSelect, 0);
}
- else {
+ else
+ {
OSL_FAIL("SbaTableQueryBrowser::select: invalid entry!");
}
}
-void SbaTableQueryBrowser::selectPath(SvTreeListEntry* _pEntry, bool _bSelect)
+void SbaTableQueryBrowser::selectPath(weld::TreeIter* pEntry, bool bSelect)
{
- while (_pEntry)
+ if (!pEntry)
+ return;
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xEntry(rTreeView.make_iterator(pEntry));
+ do
{
- select(_pEntry, _bSelect);
- _pEntry = m_pTreeView->GetTreeModel()->GetParent(_pEntry);
+ select(xEntry.get(), bSelect);
}
+ while (rTreeView.iter_parent(*xEntry));
}
-bool SbaTableQueryBrowser::isSelected(SvTreeListEntry* _pEntry)
+bool SbaTableQueryBrowser::isSelected(const weld::TreeIter& rEntry) const
{
- SvLBoxItem* pTextItem = _pEntry ? _pEntry->GetFirstItem(SvLBoxItemType::String) : nullptr;
- if (pTextItem)
- return static_cast<OBoldListboxString*>(pTextItem)->isEmphasized();
- else {
- OSL_FAIL("SbaTableQueryBrowser::isSelected: invalid entry!");
- }
- return false;
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ return rTreeView.get_text_emphasis(rEntry, 0);
}
void SbaTableQueryBrowser::SelectionChanged()
@@ -193,64 +202,6 @@ sal_Int32 SbaTableQueryBrowser::getDatabaseObjectType( EntryType _eType )
return css::sdb::application::DatabaseObject::TABLE;
}
-void SbaTableQueryBrowser::notifyHiContrastChanged()
-{
- if ( !m_pTreeView )
- return;
-
- auto pTreeModel = m_pTreeView->GetTreeModel();
- // change all bitmap entries
- SvTreeListEntry* pEntryLoop = pTreeModel->First();
- while ( pEntryLoop )
- {
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pEntryLoop->GetUserData());
- if ( !pData )
- {
- pEntryLoop = pTreeModel->Next(pEntryLoop);
- continue;
- }
-
- // the connection to which this entry belongs, if any
- std::unique_ptr< ImageProvider > pImageProvider( getImageProviderFor( pEntryLoop ) );
-
- // the images for this entry
- Image aImage;
- if ( pData->eType == etDatasource )
- aImage = ImageProvider::getDatabaseImage();
- else
- {
- bool bIsFolder = !isObject( pData->eType );
- if ( bIsFolder )
- {
- sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) );
- aImage = ImageProvider::getFolderImage( nObjectType );
- }
- else
- {
- sal_Int32 nObjectType( getDatabaseObjectType( pData->eType ) );
- pImageProvider->getImages( GetEntryText( pEntryLoop ), nObjectType, aImage );
- }
- }
-
- // find the proper item, and set its icons
- sal_uInt16 nCount = pEntryLoop->ItemCount();
- for (sal_uInt16 i=0;i<nCount;++i)
- {
- SvLBoxItem& rItem = pEntryLoop->GetItem(i);
- if (rItem.GetType() != SvLBoxItemType::ContextBmp)
- continue;
-
- SvLBoxContextBmp& rContextBitmapItem = static_cast< SvLBoxContextBmp& >( rItem );
-
- rContextBitmapItem.SetBitmap1( aImage );
- rContextBitmapItem.SetBitmap2( aImage );
- break;
- }
-
- pEntryLoop = pTreeModel->Next(pEntryLoop);
- }
-}
-
} // namespace dbaui
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/browser/dsbrowserDnD.cxx b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
index 0b9888f3f34e..e8425436df37 100644
--- a/dbaccess/source/ui/browser/dsbrowserDnD.cxx
+++ b/dbaccess/source/ui/browser/dsbrowserDnD.cxx
@@ -59,26 +59,26 @@ namespace dbaui
using namespace ::dbtools;
using namespace ::svx;
- TransferableHelper* SbaTableQueryBrowser::implCopyObject( SvTreeListEntry* _pApplyTo, sal_Int32 _nCommandType )
+ bool SbaTableQueryBrowser::implCopyObject(ODataClipboard& rExchange, const weld::TreeIter& rApplyTo, sal_Int32 nCommandType)
{
try
{
- OUString aName = GetEntryText( _pApplyTo );
- OUString aDSName = getDataSourceAccessor( m_pTreeView->getListBox().GetRootLevelParent( _pApplyTo ) );
+ OUString aName = GetEntryText(rApplyTo);
+ std::unique_ptr<weld::TreeIter> xRootEntry(m_pTreeView->getListBox().GetRootLevelParent(&rApplyTo));
+ OUString aDSName = getDataSourceAccessor(*xRootEntry);
- ODataClipboard* pData = nullptr;
SharedConnection xConnection;
- if ( CommandType::QUERY != _nCommandType )
+ if ( CommandType::QUERY != nCommandType )
{
- if ( !ensureConnection( _pApplyTo, xConnection) )
- return nullptr;
- pData = new ODataClipboard(aDSName, _nCommandType, aName, xConnection, getNumberFormatter(), getORB());
+ if (!ensureConnection(&rApplyTo, xConnection))
+ return false;
+ rExchange.Update(aDSName, nCommandType, aName, xConnection, getNumberFormatter(), getORB());
}
else
- pData = new ODataClipboard(aDSName, _nCommandType, aName, getNumberFormatter(), getORB());
+ rExchange.Update(aDSName, nCommandType, aName, getNumberFormatter(), getORB());
// the ownership goes to ODataClipboards
- return pData;
+ return true;
}
catch(const SQLException& )
{
@@ -88,19 +88,21 @@ namespace dbaui
{
DBG_UNHANDLED_EXCEPTION("dbaccess");
}
- return nullptr;
+ return false;
}
+
sal_Int8 SbaTableQueryBrowser::queryDrop( const AcceptDropEvent& _rEvt, const DataFlavorExVector& _rFlavors )
{
// check if we're a table or query container
- SvTreeListEntry* pHitEntry = m_pTreeView->getListBox().GetEntry( _rEvt.maPosPixel );
-
- if ( pHitEntry ) // no drop if no entry was hit...
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xHitEntry(rTreeView.make_iterator());
+ // get_dest_row_at_pos with false cause no drop if no entry was hit exactly
+ if (rTreeView.get_dest_row_at_pos(_rEvt.maPosPixel, xHitEntry.get(), false))
{
// it must be a container
- EntryType eEntryType = getEntryType( pHitEntry );
+ EntryType eEntryType = getEntryType(*xHitEntry);
SharedConnection xConnection;
- if ( eEntryType == etTableContainer && ensureConnection( pHitEntry, xConnection ) && xConnection.is() )
+ if ( eEntryType == etTableContainer && ensureConnection(xHitEntry.get(), xConnection ) && xConnection.is())
{
Reference<XChild> xChild(xConnection,UNO_QUERY);
Reference<XStorable> xStore;
@@ -116,8 +118,12 @@ namespace dbaui
}
sal_Int8 SbaTableQueryBrowser::executeDrop( const ExecuteDropEvent& _rEvt )
{
- SvTreeListEntry* pHitEntry = m_pTreeView->getListBox().GetEntry( _rEvt.maPosPixel );
- EntryType eEntryType = getEntryType( pHitEntry );
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xHitEntry(rTreeView.make_iterator());
+ // get_dest_row_at_pos with false cause no drop if no entry was hit exactly
+ if (!rTreeView.get_dest_row_at_pos(_rEvt.maPosPixel, xHitEntry.get(), false))
+ return DND_ACTION_NONE;
+ EntryType eEntryType = getEntryType(*xHitEntry);
if (!isContainer(eEntryType))
{
OSL_FAIL("SbaTableQueryBrowser::executeDrop: what the hell did queryDrop do?");
@@ -137,7 +143,7 @@ namespace dbaui
m_aAsyncDrop.nAction = _rEvt.mnAction;
m_aAsyncDrop.bError = false;
m_aAsyncDrop.bHtml = false;
- m_aAsyncDrop.pDroppedAt = nullptr;
+ m_aAsyncDrop.xDroppedAt.reset();
m_aAsyncDrop.aUrl.clear();
// loop through the available formats and see what we can do ...
@@ -145,7 +151,7 @@ namespace dbaui
if ( ODataAccessObjectTransferable::canExtractObjectDescriptor(aDroppedData.GetDataFlavorExVector()) )
{
m_aAsyncDrop.aDroppedData = ODataAccessObjectTransferable::extractObjectDescriptor(aDroppedData);
- m_aAsyncDrop.pDroppedAt = pHitEntry;
+ m_aAsyncDrop.xDroppedAt = std::move(xHitEntry);
// asynchron because we some dialogs and we aren't allowed to show them while in D&D
m_nAsyncDrop = Application::PostUserEvent(LINK(this, SbaTableQueryBrowser, OnAsyncDrop));
@@ -154,12 +160,12 @@ namespace dbaui
else
{
SharedConnection xDestConnection;
- if ( ensureConnection( pHitEntry, xDestConnection )
+ if ( ensureConnection( xHitEntry.get(), xDestConnection )
&& xDestConnection.is()
&& m_aTableCopyHelper.copyTagTable( aDroppedData, m_aAsyncDrop, xDestConnection )
)
{
- m_aAsyncDrop.pDroppedAt = pHitEntry;
+ m_aAsyncDrop.xDroppedAt = std::move(xHitEntry);
// asynchron because we some dialogs and we aren't allowed to show them while in D&D
m_nAsyncDrop = Application::PostUserEvent(LINK(this, SbaTableQueryBrowser, OnAsyncDrop));
@@ -170,54 +176,44 @@ namespace dbaui
return DND_ACTION_NONE;
}
- bool SbaTableQueryBrowser::requestDrag( const Point& _rPosPixel )
+ bool SbaTableQueryBrowser::requestDrag( const Point& /*rPosPixel*/ )
{
- // get the affected list entry
- // ensure that the entry which the user clicked at is selected
- SvTreeListEntry* pHitEntry = m_pTreeView->getListBox().GetEntry( _rPosPixel );
- if (!pHitEntry)
- // no drag of no entry was hit...
- return false;
+ return false;
+ }
+ bool SbaTableQueryBrowser::requestDrag(const weld::TreeIter& rEntry)
+ {
// it must be a query/table
- EntryType eEntryType = getEntryType( pHitEntry );
+ EntryType eEntryType = getEntryType(rEntry);
if (!isObject(eEntryType))
return false;
- rtl::Reference<TransferableHelper> pTransfer = implCopyObject( pHitEntry, ( etTableOrView == eEntryType ) ? CommandType::TABLE : CommandType::QUERY);
-
- if (pTransfer)
- pTransfer->StartDrag( &m_pTreeView->getListBox(), DND_ACTION_COPY );
-
- return pTransfer.is();
- }
-
- bool SbaTableQueryBrowser::requestDrag(const weld::TreeIter& /*rEntry*/)
- {
- return false;
+ ODataClipboard& rExchange = m_pTreeView->getListBox().GetDataTransfer();
+ return implCopyObject(rExchange, rEntry, (etTableOrView == eEntryType) ? CommandType::TABLE : CommandType::QUERY);
}
IMPL_LINK_NOARG(SbaTableQueryBrowser, OnCopyEntry, LinkParamNone*, void)
{
- SvTreeListEntry* pSelected = m_pTreeView->getListBox().FirstSelected();
- if( isEntryCopyAllowed( pSelected ) )
- copyEntry( pSelected );
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xSelected = rTreeView.make_iterator();
+ if (rTreeView.get_selected(xSelected.get()) && isEntryCopyAllowed(*xSelected))
+ copyEntry(*xSelected);
}
- bool SbaTableQueryBrowser::isEntryCopyAllowed(SvTreeListEntry const * _pEntry) const
+
+ bool SbaTableQueryBrowser::isEntryCopyAllowed(const weld::TreeIter& rEntry) const
{
- EntryType eType = getEntryType(_pEntry);
+ EntryType eType = getEntryType(rEntry);
return ( eType == etTableOrView || eType == etQuery );
}
- void SbaTableQueryBrowser::copyEntry(SvTreeListEntry* _pEntry)
+
+ void SbaTableQueryBrowser::copyEntry(weld::TreeIter& rEntry)
{
- TransferableHelper* pTransfer = nullptr;
- Reference< XTransferable> aEnsureDelete;
- EntryType eType = getEntryType(_pEntry);
- pTransfer = implCopyObject( _pEntry, eType == etQuery ? CommandType::QUERY : CommandType::TABLE);
- aEnsureDelete = pTransfer;
- if (pTransfer)
- pTransfer->CopyToClipboard(getView());
+ EntryType eType = getEntryType(rEntry);
+ rtl::Reference<ODataClipboard> xTransfer(new ODataClipboard);
+ if (implCopyObject(*xTransfer, rEntry, eType == etQuery ? CommandType::QUERY : CommandType::TABLE))
+ xTransfer->CopyToClipboard(getView());
}
+
IMPL_LINK_NOARG( SbaTableQueryBrowser, OnAsyncDrop, void*, void )
{
m_nAsyncDrop = nullptr;
@@ -227,45 +223,42 @@ namespace dbaui
if ( m_aAsyncDrop.nType == E_TABLE )
{
SharedConnection xDestConnection;
- if ( ensureConnection( m_aAsyncDrop.pDroppedAt, xDestConnection ) && xDestConnection.is() )
+ if ( ensureConnection(m_aAsyncDrop.xDroppedAt.get(), xDestConnection) && xDestConnection.is())
{
- SvTreeListEntry* pDataSourceEntry = m_pTreeView->getListBox().GetRootLevelParent(m_aAsyncDrop.pDroppedAt);
- m_aTableCopyHelper.asyncCopyTagTable( m_aAsyncDrop, getDataSourceAccessor( pDataSourceEntry ), xDestConnection );
+ std::unique_ptr<weld::TreeIter> xDataSourceEntry =
+ m_pTreeView->getListBox().GetRootLevelParent(m_aAsyncDrop.xDroppedAt.get());
+ m_aTableCopyHelper.asyncCopyTagTable(m_aAsyncDrop, getDataSourceAccessor(*xDataSourceEntry), xDestConnection);
}
}
m_aAsyncDrop.aDroppedData.clear();
}
+
void SbaTableQueryBrowser::clearTreeModel()
{
- if (m_pTreeView)
- {
- auto pTreeModel = m_pTreeView->GetTreeModel();
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ rTreeView.all_foreach([this, &rTreeView](weld::TreeIter& rEntryLoop){
// clear the user data of the tree model
- SvTreeListEntry* pEntryLoop = pTreeModel->First();
- while (pEntryLoop)
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rEntryLoop).toUInt64());
+ if (pData)
{
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pEntryLoop->GetUserData());
- if(pData)
- {
- pEntryLoop->SetUserData(nullptr);
- Reference< XContainer > xContainer(pData->xContainer, UNO_QUERY);
- if (xContainer.is())
- xContainer->removeContainerListener(this);
+ rTreeView.set_id(rEntryLoop, OUString());
+ Reference<XContainer> xContainer(pData->xContainer, UNO_QUERY);
+ if (xContainer.is())
+ xContainer->removeContainerListener(this);
- if ( pData->xConnection.is() )
- {
- OSL_ENSURE( impl_isDataSourceEntry( pEntryLoop ), "SbaTableQueryBrowser::clearTreeModel: no data source entry, but a connection?" );
- // connections are to be stored *only* at the data source entries
- impl_releaseConnection( pData->xConnection );
- }
-
- delete pData;
+ if (pData->xConnection.is())
+ {
+ // connections are to be stored *only* at the data source entries
+ impl_releaseConnection(pData->xConnection);
}
- pEntryLoop = pTreeModel->Next(pEntryLoop);
+
+ delete pData;
}
- }
- m_pCurrentlyDisplayed = nullptr;
+ return false;
+ });
+
+ m_xCurrentlyDisplayed.reset();
}
} // namespace dbaui
diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx
index 58f5b55ea940..a53ade551795 100644
--- a/dbaccess/source/ui/browser/genericcontroller.cxx
+++ b/dbaccess/source/ui/browser/genericcontroller.cxx
@@ -1146,10 +1146,6 @@ bool OGenericUnoController::isCommandEnabled(sal_uInt16 _nCommandId) const
return GetState( _nCommandId ).bEnabled;
}
-void OGenericUnoController::notifyHiContrastChanged()
-{
-}
-
bool OGenericUnoController::isDataSourceReadOnly() const
{
return false;
diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx
index 4caa3f4cc31f..928764bb00fe 100644
--- a/dbaccess/source/ui/browser/unodatbr.cxx
+++ b/dbaccess/source/ui/browser/unodatbr.cxx
@@ -81,7 +81,6 @@
#include <cppuhelper/exc_hlp.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <svl/filenotation.hxx>
-#include <vcl/svlbitm.hxx>
#include <vcl/treelistbox.hxx>
#include <vcl/treelistentry.hxx>
#include <svx/dataaccessdescriptor.hxx>
@@ -171,7 +170,6 @@ SbaTableQueryBrowser::SbaTableQueryBrowser(const Reference< XComponentContext >&
,m_aTableCopyHelper(this)
,m_pTreeView(nullptr)
,m_pSplitter(nullptr)
- ,m_pCurrentlyDisplayed(nullptr)
,m_nAsyncDrop(nullptr)
,m_bQueryEscapeProcessing( false )
,m_bShowMenu(false)
@@ -317,9 +315,12 @@ bool SbaTableQueryBrowser::Construct(vcl::Window* pParent)
getBrowserView()->setTreeView(m_pTreeView);
// fill view with data
- auto pTreeModel = m_pTreeView->GetTreeModel();
- pTreeModel->SetSortMode(SortAscending);
- pTreeModel->SetCompareHdl(LINK(this, SbaTableQueryBrowser, OnTreeEntryCompare));
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ rTreeView.set_sort_order(true);
+ rTreeView.set_sort_func([this](const weld::TreeIter& rLeft, const weld::TreeIter& rRight){
+ return OnTreeEntryCompare(rLeft, rRight);
+ });
+ rTreeView.make_sorted();
m_pTreeView->setSelChangeHdl( LINK( this, SbaTableQueryBrowser, OnSelectionChange ) );
// TODO
@@ -461,13 +462,14 @@ void SbaTableQueryBrowser::impl_sanitizeRowSetClauses_nothrow()
bool SbaTableQueryBrowser::InitializeForm( const Reference< XPropertySet > & i_formProperties )
{
- if(!m_pCurrentlyDisplayed)
+ if (!m_xCurrentlyDisplayed)
return true;
// this method set all format settings from the original table or query
try
{
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*m_xCurrentlyDisplayed).toUInt64());
ENSURE_OR_RETURN_FALSE( pData, "SbaTableQueryBrowser::InitializeForm: No user data set at the currently displayed entry!" );
ENSURE_OR_RETURN_FALSE( pData->xObjectProperties.is(), "SbaTableQueryBrowser::InitializeForm: No table available!" );
@@ -541,12 +543,13 @@ void SbaTableQueryBrowser::InitializeGridModel(const Reference< css::form::XForm
if (xFormAsLoadable.is() && xFormAsLoadable->isLoaded())
{
// set the formats from the table
- if(m_pCurrentlyDisplayed)
+ if (m_xCurrentlyDisplayed)
{
Sequence< OUString> aProperties(6 + ( m_bPreview ? 5 : 0 ));
Sequence< Any> aValues(7 + ( m_bPreview ? 5 : 0 ));
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*m_xCurrentlyDisplayed).toUInt64());
OSL_ENSURE( pData->xObjectProperties.is(), "SbaTableQueryBrowser::InitializeGridModel: No table available!" );
if ( !pData->xObjectProperties.is() )
return;
@@ -751,16 +754,18 @@ void SbaTableQueryBrowser::InitializeGridModel(const Reference< css::form::XForm
}
}
-static Reference<XPropertySet> getColumnHelper(SvTreeListEntry const * _pCurrentlyDisplayed, const Reference<XPropertySet>& _rxSource)
+static Reference<XPropertySet> getColumnHelper(const weld::TreeView& rTreeView,
+ const weld::TreeIter* pCurrentlyDisplayed,
+ const Reference<XPropertySet>& rxSource)
{
Reference<XPropertySet> xRet;
- if(_pCurrentlyDisplayed)
+ if (pCurrentlyDisplayed)
{
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pCurrentlyDisplayed->GetUserData());
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*pCurrentlyDisplayed).toUInt64());
Reference<XColumnsSupplier> xColumnsSup(pData->xObjectProperties,UNO_QUERY);
Reference<XNameAccess> xNames = xColumnsSup->getColumns();
OUString aName;
- _rxSource->getPropertyValue(PROPERTY_NAME) >>= aName;
+ rxSource->getPropertyValue(PROPERTY_NAME) >>= aName;
if(xNames.is() && xNames->hasByName(aName))
xRet.set(xNames->getByName(aName),UNO_QUERY);
}
@@ -769,9 +774,10 @@ static Reference<XPropertySet> getColumnHelper(SvTreeListEntry const * _pCurrent
void SbaTableQueryBrowser::transferChangedControlProperty(const OUString& _rProperty, const Any& _rNewValue)
{
- if(m_pCurrentlyDisplayed)
+ if (m_xCurrentlyDisplayed)
{
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*m_xCurrentlyDisplayed).toUInt64());
Reference< XPropertySet > xObjectProps = pData->xObjectProperties;
OSL_ENSURE(xObjectProps.is(),"SbaTableQueryBrowser::transferChangedControlProperty: no table/query object!");
if (xObjectProps.is())
@@ -783,18 +789,19 @@ void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt)
{
SbaXDataBrowserController::propertyChange(evt);
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+
try
{
Reference< XPropertySet > xSource(evt.Source, UNO_QUERY);
if (!xSource.is())
return;
-
// one of the many properties which require us to update the definition ?
// a column's width ?
else if (evt.PropertyName == PROPERTY_WIDTH)
{ // a column width has changed -> update the model
// (the update of the view is done elsewhere)
- Reference<XPropertySet> xProp = getColumnHelper(m_pCurrentlyDisplayed,xSource);
+ Reference<XPropertySet> xProp = getColumnHelper(rTreeView, m_xCurrentlyDisplayed.get(), xSource);
if(xProp.is())
{
if(!evt.NewValue.hasValue())
@@ -807,7 +814,7 @@ void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt)
// a column's 'visible' state ?
else if (evt.PropertyName == PROPERTY_HIDDEN)
{
- Reference<XPropertySet> xProp = getColumnHelper(m_pCurrentlyDisplayed,xSource);
+ Reference<XPropertySet> xProp = getColumnHelper(rTreeView, m_xCurrentlyDisplayed.get(), xSource);
if(xProp.is())
xProp->setPropertyValue(PROPERTY_HIDDEN,evt.NewValue);
}
@@ -815,7 +822,7 @@ void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt)
// a columns alignment ?
else if (evt.PropertyName == PROPERTY_ALIGN)
{
- Reference<XPropertySet> xProp = getColumnHelper(m_pCurrentlyDisplayed,xSource);
+ Reference<XPropertySet> xProp = getColumnHelper(rTreeView, m_xCurrentlyDisplayed.get(), xSource);
try
{
if(xProp.is())
@@ -844,7 +851,7 @@ void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt)
)
{
// update the model (means the definition object)
- Reference<XPropertySet> xProp = getColumnHelper(m_pCurrentlyDisplayed,xSource);
+ Reference<XPropertySet> xProp = getColumnHelper(rTreeView, m_xCurrentlyDisplayed.get(), xSource);
if(xProp.is())
xProp->setPropertyValue(PROPERTY_FORMATKEY,evt.NewValue);
}
@@ -853,9 +860,9 @@ void SbaTableQueryBrowser::propertyChange(const PropertyChangeEvent& evt)
// the height of the rows in the grid ?
else if (evt.PropertyName == PROPERTY_ROW_HEIGHT)
{
- if(m_pCurrentlyDisplayed)
+ if (m_xCurrentlyDisplayed)
{
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData());
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*m_xCurrentlyDisplayed).toUInt64());
OSL_ENSURE( pData->xObjectProperties.is(), "No table available!" );
bool bDefault = !evt.NewValue.hasValue();
@@ -959,17 +966,20 @@ void SAL_CALL SbaTableQueryBrowser::statusChanged( const FeatureStateEvent& _rEv
void SbaTableQueryBrowser::checkDocumentDataSource()
{
- SvTreeListEntry* pDataSourceEntry = nullptr;
- SvTreeListEntry* pContainerEntry = nullptr;
- SvTreeListEntry* pObjectEntry = getObjectEntry( m_aDocumentDataSource, &pDataSourceEntry, &pContainerEntry );
- bool bKnownDocDataSource = (nullptr != pObjectEntry);
+ std::unique_ptr<weld::TreeIter> xDataSourceEntry;
+ std::unique_ptr<weld::TreeIter> xContainerEntry;
+ std::unique_ptr<weld::TreeIter> xObjectEntry = getObjectEntry(m_aDocumentDataSource, &xDataSourceEntry, &xContainerEntry);
+ bool bKnownDocDataSource = static_cast<bool>(xObjectEntry);
if (!bKnownDocDataSource)
{
- if (nullptr != pDataSourceEntry)
- { // at least the data source is known
- if (nullptr != pContainerEntry)
+ if (xDataSourceEntry)
+ {
+ // at least the data source is known
+ if (xContainerEntry)
+ {
bKnownDocDataSource = true; // assume we know it.
// TODO: should we expand the object container? This may be too expensive just for checking...
+ }
else
{
if (m_aDocumentDataSource.has(DataAccessDescriptorProperty::CommandType)
@@ -1041,26 +1051,25 @@ namespace
}
}
-OUString SbaTableQueryBrowser::getDataSourceAccessor( SvTreeListEntry* _pDataSourceEntry ) const
+OUString SbaTableQueryBrowser::getDataSourceAccessor(const weld::TreeIter& rDataSourceEntry) const
{
- OSL_ENSURE( _pDataSourceEntry, "SbaTableQueryBrowser::getDataSourceAccessor: invalid entry!" );
-
- DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( _pDataSourceEntry->GetUserData() );
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rDataSourceEntry).toUInt64());
OSL_ENSURE( pData, "SbaTableQueryBrowser::getDataSourceAccessor: invalid entry data!" );
OSL_ENSURE( pData->eType == etDatasource, "SbaTableQueryBrowser::getDataSourceAccessor: entry does not denote a data source!" );
- return !pData->sAccessor.isEmpty() ? pData->sAccessor : GetEntryText( _pDataSourceEntry );
+ return !pData->sAccessor.isEmpty() ? pData->sAccessor : GetEntryText(rDataSourceEntry);
}
-SvTreeListEntry* SbaTableQueryBrowser::getObjectEntry(const OUString& _rDataSource, const OUString& _rCommand, sal_Int32 _nCommandType,
- SvTreeListEntry** _ppDataSourceEntry, SvTreeListEntry** _ppContainerEntry, bool _bExpandAncestors,
+std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::getObjectEntry(const OUString& _rDataSource, const OUString& _rCommand, sal_Int32 nCommandType,
+ std::unique_ptr<weld::TreeIter>* ppDataSourceEntry, std::unique_ptr<weld::TreeIter>* ppContainerEntry, bool bExpandAncestors,
const SharedConnection& _rxConnection )
{
- if (_ppDataSourceEntry)
- *_ppDataSourceEntry = nullptr;
- if (_ppContainerEntry)
- *_ppContainerEntry = nullptr;
+ if (ppDataSourceEntry)
+ ppDataSourceEntry->reset();
+ if (ppContainerEntry)
+ ppContainerEntry->reset();
- SvTreeListEntry* pObject = nullptr;
+ std::unique_ptr<weld::TreeIter> xObject;
if ( m_pTreeView )
{
// look for the data source entry
@@ -1070,50 +1079,64 @@ SvTreeListEntry* SbaTableQueryBrowser::getObjectEntry(const OUString& _rDataSour
// #i33699#
FilterByEntryDataId aFilter( sDataSourceId );
- SvTreeListEntry* pDataSource = m_pTreeView->getListBox().GetEntryPosByName( sDisplayName, nullptr, &aFilter );
- if ( !pDataSource ) // check if the data source name is a file location
+ std::unique_ptr<weld::TreeIter> xDataSource = m_pTreeView->getListBox().GetEntryPosByName( sDisplayName, nullptr, &aFilter );
+ if (!xDataSource) // check if the data source name is a file location
{
if ( bIsDataSourceURL )
{
// special case, the data source is a URL
// add new entries to the list box model
implAddDatasource( _rDataSource, _rxConnection );
- pDataSource = m_pTreeView->getListBox().GetEntryPosByName( sDisplayName, nullptr, &aFilter );
- OSL_ENSURE( pDataSource, "SbaTableQueryBrowser::getObjectEntry: hmm - did not find it again!" );
+ xDataSource = m_pTreeView->getListBox().GetEntryPosByName( sDisplayName, nullptr, &aFilter );
+ OSL_ENSURE( xDataSource, "SbaTableQueryBrowser::getObjectEntry: hmm - did not find it again!" );
}
}
- if (_ppDataSourceEntry)
+
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+
+ if (ppDataSourceEntry)
+ {
// (caller wants to have it...)
- *_ppDataSourceEntry = pDataSource;
+ *ppDataSourceEntry = rTreeView.make_iterator(xDataSource.get());
+ }
- if (pDataSource)
+ if (xDataSource)
{
// expand if required so
- if (_bExpandAncestors)
- m_pTreeView->getListBox().Expand(pDataSource);
+ if (bExpandAncestors)
+ rTreeView.expand_row(*xDataSource);
// look for the object container
- SvTreeListEntry* pCommandType = nullptr;
- switch (_nCommandType)
+ std::unique_ptr<weld::TreeIter> xCommandType;
+ if (nCommandType == CommandType::QUERY || nCommandType == CommandType::TABLE)
{
- case CommandType::TABLE:
- pCommandType = m_pTreeView->getListBox().GetModel()->GetEntry(pDataSource, CONTAINER_TABLES);
- break;
+ xCommandType = rTreeView.make_iterator(xDataSource.get());
+ if (!rTreeView.iter_children(*xCommandType))
+ xCommandType.reset();
+ else
+ {
+ // 1st child is queries, so we're already done if looking for CommandType::QUERY
- case CommandType::QUERY:
- pCommandType = m_pTreeView->getListBox().GetModel()->GetEntry(pDataSource, CONTAINER_QUERIES);
- break;
+ // 2nd child is tables
+ if (nCommandType == CommandType::TABLE && !rTreeView.iter_next_sibling(*xCommandType))
+ xCommandType.reset();
+ }
}
- if (_ppContainerEntry)
- *_ppContainerEntry = pCommandType;
+ if (ppContainerEntry)
+ {
+ // (caller wants to have it...)
+ *ppContainerEntry = rTreeView.make_iterator(xCommandType.get());
+ }
- if (pCommandType)
+ if (xCommandType)
{
+ rTreeView.make_unsorted();
+
// expand if required so
- if (_bExpandAncestors)
+ if (bExpandAncestors)
{
- m_pTreeView->getListBox().Expand(pCommandType);
+ rTreeView.expand_row(*xCommandType);
}
// look for the object
@@ -1121,7 +1144,7 @@ SvTreeListEntry* SbaTableQueryBrowser::getObjectEntry(const OUString& _rDataSour
do
{
OUString sPath;
- switch (_nCommandType)
+ switch (nCommandType)
{
case CommandType::TABLE:
sPath = _rCommand;
@@ -1135,13 +1158,13 @@ SvTreeListEntry* SbaTableQueryBrowser::getObjectEntry(const OUString& _rDataSour
default:
assert(false);
}
- pObject = m_pTreeView->getListBox().GetEntryPosByName(sPath, pCommandType);
- pCommandType = pObject;
+ xObject = m_pTreeView->getListBox().GetEntryPosByName(sPath, xCommandType.get());
+ rTreeView.copy_iterator(*xObject, *xCommandType);
if ( nIndex >= 0 )
{
- if (ensureEntryObject(pObject))
+ if (ensureEntryObject(*xObject))
{
- DBTreeListUserData* pParentData = static_cast< DBTreeListUserData* >( pObject->GetUserData() );
+ DBTreeListUserData* pParentData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xObject).toUInt64());
Reference< XNameAccess > xCollection( pParentData->xContainer, UNO_QUERY );
sal_Int32 nIndex2 = nIndex;
sPath = _rCommand.getToken( 0, '/', nIndex2 );
@@ -1149,7 +1172,7 @@ SvTreeListEntry* SbaTableQueryBrowser::getObjectEntry(const OUString& _rDataSour
{
if ( xCollection->hasByName(sPath) )
{
- if(!m_pTreeView->getListBox().GetEntryPosByName(sPath,pObject))
+ if(!m_pTreeView->getListBox().GetEntryPosByName(sPath, xObject.get()))
{
Reference<XNameAccess> xChild(xCollection->getByName(sPath),UNO_QUERY);
DBTreeListUserData* pEntryData = new DBTreeListUserData;
@@ -1158,7 +1181,7 @@ SvTreeListEntry* SbaTableQueryBrowser::getObjectEntry(const OUString& _rDataSour
{
pEntryData->eType = etQueryContainer;
}
- implAppendEntry( pObject, sPath, pEntryData, pEntryData->eType );
+ implAppendEntry(xObject.get(), sPath, pEntryData, pEntryData->eType);
}
}
}
@@ -1170,23 +1193,25 @@ SvTreeListEntry* SbaTableQueryBrowser::getObjectEntry(const OUString& _rDataSour
}
}
while ( nIndex >= 0 );
+
+ rTreeView.make_sorted();
}
}
}
- return pObject;
+ return xObject;
}
-SvTreeListEntry* SbaTableQueryBrowser::getObjectEntry(const svx::ODataAccessDescriptor& _rDescriptor,
- SvTreeListEntry** _ppDataSourceEntry, SvTreeListEntry** _ppContainerEntry)
+std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::getObjectEntry(const svx::ODataAccessDescriptor& rDescriptor,
+ std::unique_ptr<weld::TreeIter>* ppDataSourceEntry, std::unique_ptr<weld::TreeIter>* ppContainerEntry)
{
// extract the props from the descriptor
OUString sDataSource;
OUString sCommand;
sal_Int32 nCommandType = CommandType::COMMAND;
bool bEscapeProcessing = true;
- extractDescriptorProps(_rDescriptor, sDataSource, sCommand, nCommandType, bEscapeProcessing);
+ extractDescriptorProps(rDescriptor, sDataSource, sCommand, nCommandType, bEscapeProcessing);
- return getObjectEntry( sDataSource, sCommand, nCommandType, _ppDataSourceEntry, _ppContainerEntry, false/*_bExpandAncestors*/ );
+ return getObjectEntry(sDataSource, sCommand, nCommandType, ppDataSourceEntry, ppContainerEntry, false /*bExpandAncestors*/);
}
void SbaTableQueryBrowser::connectExternalDispatches()
@@ -1307,22 +1332,26 @@ void SAL_CALL SbaTableQueryBrowser::disposing( const css::lang::EventObject& _rS
{
Reference<XConnection> xCon(_rSource.Source, UNO_QUERY);
if ( xCon.is() && m_pTreeView )
- { // our connection is in dispose so we have to find the entry equal with this connection
+ {
+ // our connection is in dispose so we have to find the entry equal with this connection
// and close it what means to collapse the entry
// get the top-level representing the removed data source
- SvTreeListEntry* pDSLoop = m_pTreeView->getListBox().FirstChild(nullptr);
- while (pDSLoop)
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xDSLoop(rTreeView.make_iterator());
+ if (rTreeView.get_iter_first(*xDSLoop))
{
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pDSLoop->GetUserData());
- if ( pData && pData->xConnection == xCon )
+ do
{
- // we set the connection to null to avoid a second disposing of the connection
- pData->xConnection.clear();
- closeConnection(pDSLoop,false);
- break;
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xDSLoop).toUInt64());
+ if ( pData && pData->xConnection == xCon )
+ {
+ // we set the connection to null to avoid a second disposing of the connection
+ pData->xConnection.clear();
+ closeConnection(*xDSLoop, false);
+ break;
+ }
}
-
- pDSLoop = pDSLoop->NextSibling();
+ while (rTreeView.iter_next_sibling(*xDSLoop));
}
}
else
@@ -1601,15 +1630,19 @@ FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) const
case ID_TREE_CLOSE_CONN:
case ID_TREE_EDIT_DATABASE:
{
- SvTreeListEntry* pCurrentEntry( m_pTreeView->getListBox().GetCurEntry() );
- EntryType eType = getEntryType( pCurrentEntry );
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xCurrentEntry(rTreeView.make_iterator());
+ if (!rTreeView.get_cursor(xCurrentEntry.get()))
+ return aReturn;
+
+ EntryType eType = getEntryType(*xCurrentEntry);
if ( eType == etUnknown )
return aReturn;
- SvTreeListEntry* pDataSourceEntry = m_pTreeView->getListBox().GetRootLevelParent( pCurrentEntry );
+ std::unique_ptr<weld::TreeIter> xDataSourceEntry = m_pTreeView->getListBox().GetRootLevelParent(xCurrentEntry.get());
DBTreeListUserData* pDSData
- = pDataSourceEntry
- ? static_cast< DBTreeListUserData* >( pDataSourceEntry->GetUserData() )
+ = xDataSourceEntry
+ ? reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xDataSourceEntry).toUInt64())
: nullptr;
if ( nId == ID_TREE_CLOSE_CONN )
@@ -1622,11 +1655,11 @@ FeatureState SbaTableQueryBrowser::GetState(sal_uInt16 nId) const
"/org.openoffice.Office.DataAccess/Policies/Features/Common" ) );
bool bHaveEditDatabase( true );
OSL_VERIFY( aConfig.getNodeValue( "EditDatabaseFromDataSourceView" ) >>= bHaveEditDatabase );
- aReturn.bEnabled = getORB().is() && ( pDataSourceEntry != nullptr ) && bHaveEditDatabase;
+ aReturn.bEnabled = getORB().is() && xDataSourceEntry && bHaveEditDatabase;
}
else if ( nId == ID_BROWSER_COPY )
{
- aReturn.bEnabled = isEntryCopyAllowed( pCurrentEntry );
+ aReturn.bEnabled = isEntryCopyAllowed(*xCurrentEntry);
}
return aReturn;
@@ -1769,13 +1802,24 @@ void SbaTableQueryBrowser::Execute(sal_uInt16 nId, const Sequence< PropertyValue
break;
case ID_TREE_EDIT_DATABASE:
- implAdministrate( m_pTreeView->getListBox().GetCurEntry() );
+ {
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xIter(rTreeView.make_iterator());
+ if (rTreeView.get_cursor(xIter.get()))
+ implAdministrate(*xIter);
break;
-
+ }
case ID_TREE_CLOSE_CONN:
- closeConnection( m_pTreeView->getListBox().GetRootLevelParent( m_pTreeView->getListBox().GetCurEntry() ) );
+ {
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xIter(rTreeView.make_iterator());
+ if (rTreeView.get_cursor(xIter.get()))
+ {
+ xIter = m_pTreeView->getListBox().GetRootLevelParent(xIter.get());
+ closeConnection(*xIter);
+ }
break;
-
+ }
case ID_TREE_ADMINISTRATE:
svx::administrateDatabaseRegistration( getFrameWeld() );
break;
@@ -1814,14 +1858,17 @@ void SbaTableQueryBrowser::Execute(sal_uInt16 nId, const Sequence< PropertyValue
// nothing to do
break;
- SvTreeListEntry* pSelected = m_pCurrentlyDisplayed;
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xSelected = m_xCurrentlyDisplayed ?
+ rTreeView.make_iterator(m_xCurrentlyDisplayed.get()) : nullptr;
+
// unload
unloadAndCleanup( false );
// reselect the entry
- if ( pSelected )
+ if ( xSelected )
{
- implSelect( pSelected );
+ implSelect(xSelected.get());
}
else
{
@@ -1932,7 +1979,10 @@ void SbaTableQueryBrowser::Execute(sal_uInt16 nId, const Sequence< PropertyValue
case ID_BROWSER_COPY:
if(m_pTreeView->HasChildPathFocus())
{
- copyEntry(m_pTreeView->getListBox().GetCurEntry());
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xCursor(rTreeView.make_iterator());
+ if (rTreeView.get_cursor(xCursor.get()))
+ copyEntry(*xCursor);
}
else if (getBrowserView() && getBrowserView()->getVclControl() && !getBrowserView()->getVclControl()->IsEditing() && getBrowserView()->getVclControl()->GetSelectRowCount() < 1)
{
@@ -1947,13 +1997,12 @@ void SbaTableQueryBrowser::Execute(sal_uInt16 nId, const Sequence< PropertyValue
void SbaTableQueryBrowser::implAddDatasource( const OUString& _rDataSourceName, const SharedConnection& _rxConnection )
{
- Image a, b, c;
- OUString d, e;
+ OUString a, b, c, d, e;
implAddDatasource( _rDataSourceName, a, d, b, e, c, _rxConnection );
}
-void SbaTableQueryBrowser::implAddDatasource(const OUString& _rDbName, Image& _rDbImage,
- OUString& _rQueryName, Image& _rQueryImage, OUString& _rTableName, Image& _rTableImage,
+void SbaTableQueryBrowser::implAddDatasource(const OUString& _rDbName, OUString& _rDbImage,
+ OUString& _rQueryName, OUString& _rQueryImage, OUString& _rTableName, OUString& _rTableImage,
const SharedConnection& _rxConnection)
{
SolarMutexGuard aGuard;
@@ -1963,12 +2012,12 @@ void SbaTableQueryBrowser::implAddDatasource(const OUString& _rDbName, Image& _r
if (_rTableName.isEmpty())
_rTableName = DBA_RES(RID_STR_TABLES_CONTAINER);
- if (!_rQueryImage)
- _rQueryImage = ImageProvider::getFolderImage( DatabaseObject::QUERY );
- if (!_rTableImage)
- _rTableImage = ImageProvider::getFolderImage( DatabaseObject::TABLE );
+ if (_rQueryImage.isEmpty())
+ _rQueryImage = ImageProvider::getFolderImageId(DatabaseObject::QUERY);
+ if (_rTableImage.isEmpty())
+ _rTableImage = ImageProvider::getFolderImageId(DatabaseObject::TABLE);
- if (!_rDbImage)
+ if (_rDbImage.isEmpty())
_rDbImage = ImageProvider::getDatabaseImage();
// add the entry for the data source
@@ -1977,40 +2026,50 @@ void SbaTableQueryBrowser::implAddDatasource(const OUString& _rDbName, Image& _r
OUString sDSDisplayName, sDataSourceId;
getDataSourceDisplayName_isURL( _rDbName, sDSDisplayName, sDataSourceId );
- SvTreeListEntry* pDatasourceEntry = m_pTreeView->getListBox().InsertEntry( sDSDisplayName, _rDbImage, _rDbImage );
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
DBTreeListUserData* pDSData = new DBTreeListUserData;
pDSData->eType = etDatasource;
pDSData->sAccessor = sDataSourceId;
pDSData->xConnection = _rxConnection;
- pDatasourceEntry->SetUserData(pDSData);
+ OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(pDSData)));
+
+ std::unique_ptr<weld::TreeIter> xDatasourceEntry(rTreeView.make_iterator());
+ rTreeView.insert(nullptr, -1, &sDSDisplayName, &sId, nullptr, nullptr, false, xDatasourceEntry.get());
+ rTreeView.set_image(*xDatasourceEntry, _rDbImage);
+ rTreeView.set_text_emphasis(*xDatasourceEntry, false, 0);
// the child for the queries container
{
DBTreeListUserData* pQueriesData = new DBTreeListUserData;
pQueriesData->eType = etQueryContainer;
+ sId = OUString::number(reinterpret_cast<sal_uInt64>(pQueriesData));
- m_pTreeView->getListBox().InsertEntry(
- _rQueryName, _rQueryImage, _rQueryImage, pDatasourceEntry,
- true /*ChildrenOnDemand*/, TREELIST_APPEND, pQueriesData );
+ std::unique_ptr<weld::TreeIter> xRet(rTreeView.make_iterator());
+ rTreeView.insert(xDatasourceEntry.get(), -1, &_rQueryName, &sId,
+ nullptr, nullptr, true /*ChildrenOnDemand*/, xRet.get());
+ rTreeView.set_image(*xRet, _rQueryImage);
+ rTreeView.set_text_emphasis(*xRet, false, 0);
}
// the child for the tables container
{
DBTreeListUserData* pTablesData = new DBTreeListUserData;
pTablesData->eType = etTableContainer;
+ sId = OUString::number(reinterpret_cast<sal_uInt64>(pTablesData));
- m_pTreeView->getListBox().InsertEntry(
- _rTableName, _rTableImage, _rTableImage, pDatasourceEntry,
- true /*ChildrenOnDemand*/, TREELIST_APPEND, pTablesData );
+ std::unique_ptr<weld::TreeIter> xRet(rTreeView.make_iterator());
+ rTreeView.insert(xDatasourceEntry.get(), -1, &_rTableName, &sId,
+ nullptr, nullptr, true /*ChildrenOnDemand*/, xRet.get());
+ rTreeView.set_image(*xRet, _rTableImage);
+ rTreeView.set_text_emphasis(*xRet, false, 0);
}
-
}
void SbaTableQueryBrowser::initializeTreeModel()
{
if (m_xDatabaseContext.is())
{
- Image aDBImage, aQueriesImage, aTablesImage;
+ OUString aDBImage, aQueriesImage, aTablesImage;
OUString sQueriesName, sTablesName;
// fill the model with the names of the registered datasources
@@ -2021,11 +2080,14 @@ void SbaTableQueryBrowser::initializeTreeModel()
}
void SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAccess,
- SvTreeListEntry* _pParent,
- EntryType _eEntryType)
+ const weld::TreeIter& rParent,
+ EntryType eEntryType)
{
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pParent->GetUserData());
- if(pData) // don't ask if the nameaccess is already set see OnExpandEntry views and tables
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ rTreeView.make_unsorted();
+
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rParent).toUInt64());
+ if (pData) // don't ask if the nameaccess is already set see OnExpandEntry views and tables
pData->xContainer = _xNameAccess;
try
@@ -2033,17 +2095,17 @@ void SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAcce
const Sequence<OUString> aNames = _xNameAccess->getElementNames();
for (const OUString& rName : aNames)
{
- if( !m_pTreeView->getListBox().GetEntryPosByName(rName,_pParent))
+ if( !m_pTreeView->getListBox().GetEntryPosByName(rName, &rParent))
{
DBTreeListUserData* pEntryData = new DBTreeListUserData;
- pEntryData->eType = _eEntryType;
- if ( _eEntryType == etQuery )
+ pEntryData->eType = eEntryType;
+ if ( eEntryType == etQuery )
{
Reference<XNameAccess> xChild(_xNameAccess->getByName(rName),UNO_QUERY);
if ( xChild.is() )
pEntryData->eType = etQueryContainer;
}
- implAppendEntry( _pParent, rName, pEntryData, pEntryData->eType );
+ implAppendEntry(&rParent, rName, pEntryData, pEntryData->eType);
}
}
}
@@ -2051,38 +2113,40 @@ void SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAcce
{
SAL_WARN("dbaccess.ui", "SbaTableQueryBrowser::populateTree: could not fill the tree");
}
+
+ rTreeView.make_sorted();
}
-SvTreeListEntry* SbaTableQueryBrowser::implAppendEntry( SvTreeListEntry* _pParent, const OUString& _rName, void* _pUserData, EntryType _eEntryType )
+std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::implAppendEntry(const weld::TreeIter* pParent, const OUString& rName, void* pUserData, EntryType eEntryType)
{
- std::unique_ptr< ImageProvider > pImageProvider( getImageProviderFor( _pParent ) );
+ std::unique_ptr<ImageProvider> xImageProvider(getImageProviderFor(pParent));
- Image aImage;
- pImageProvider->getImages( _rName, getDatabaseObjectType( _eEntryType ), aImage );
+ OUString aImage = xImageProvider->getImageId(rName, getDatabaseObjectType(eEntryType));
- SvTreeListEntry* pNewEntry = m_pTreeView->getListBox().InsertEntry( _rName, _pParent, _eEntryType == etQueryContainer , TREELIST_APPEND, _pUserData );
+ OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(pUserData)));
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xNewEntry(rTreeView.make_iterator());
+ rTreeView.insert(pParent, -1, &rName, &sId, nullptr, nullptr, eEntryType == etQueryContainer, xNewEntry.get());
+ rTreeView.set_image(*xNewEntry, aImage);
+ rTreeView.set_text_emphasis(*xNewEntry, false, 0);
- m_pTreeView->getListBox().SetExpandedEntryBmp( pNewEntry, aImage );
- m_pTreeView->getListBox().SetCollapsedEntryBmp( pNewEntry, aImage );
-
- return pNewEntry;
+ return xNewEntry;
}
-IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvTreeListEntry*, _pParent, bool)
+IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, const weld::TreeIter&, rParent, bool)
{
- if (_pParent->HasChildren())
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ if (rTreeView.iter_has_child(rParent))
+ {
// nothing to do...
return true;
+ }
- SvTreeListEntry* pFirstParent = m_pTreeView->getListBox().GetRootLevelParent(_pParent);
- OSL_ENSURE(pFirstParent,"SbaTableQueryBrowser::OnExpandEntry: No rootlevelparent!");
+ std::unique_ptr<weld::TreeIter> xFirstParent = m_pTreeView->getListBox().GetRootLevelParent(&rParent);
+ OSL_ENSURE(xFirstParent,"SbaTableQueryBrowser::OnExpandEntry: No rootlevelparent!");
- DBTreeListUserData* pData = static_cast< DBTreeListUserData* >(_pParent->GetUserData());
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rParent).toInt64());
assert(pData && "SbaTableQueryBrowser::OnExpandEntry: No user data!");
-#if OSL_DEBUG_LEVEL > 0
- SvLBoxString* pString = static_cast<SvLBoxString*>(pFirstParent->GetFirstItem(SvLBoxItemType::String));
- OSL_ENSURE(pString,"SbaTableQueryBrowser::OnExpandEntry: No string item!");
-#endif
if (etTableContainer == pData->eType)
{
@@ -2090,7 +2154,7 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvTreeListEntry*, _pParent, bool)
// it could be that we already have a connection
SharedConnection xConnection;
- ensureConnection( pFirstParent, xConnection );
+ ensureConnection(xFirstParent.get(), xConnection);
if ( xConnection.is() )
{
@@ -2106,12 +2170,12 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvTreeListEntry*, _pParent, bool)
// the nameaccess will be overwritten in populateTree
Reference<XViewsSupplier> xViewSup(xConnection,UNO_QUERY);
if(xViewSup.is())
- populateTree( xViewSup->getViews(), _pParent, etTableOrView );
+ populateTree( xViewSup->getViews(), rParent, etTableOrView );
Reference<XTablesSupplier> xTabSup(xConnection,UNO_QUERY);
if(xTabSup.is())
{
- populateTree( xTabSup->getTables(), _pParent, etTableOrView );
+ populateTree( xTabSup->getTables(), rParent, etTableOrView );
Reference<XContainer> xCont(xTabSup->getTables(),UNO_QUERY);
if(xCont.is())
// add as listener to know when elements are inserted or removed
@@ -2165,35 +2229,34 @@ IMPL_LINK(SbaTableQueryBrowser, OnExpandEntry, SvTreeListEntry*, _pParent, bool)
// 0 indicates that an error occurred
}
else
- { // we have to expand the queries or bookmarks
- if (ensureEntryObject(_pParent))
+ {
+ // we have to expand the queries or bookmarks
+ if (ensureEntryObject(rParent))
{
- DBTreeListUserData* pParentData = static_cast< DBTreeListUserData* >( _pParent->GetUserData() );
+ DBTreeListUserData* pParentData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rParent).toUInt64());
Reference< XNameAccess > xCollection( pParentData->xContainer, UNO_QUERY );
- populateTree( xCollection, _pParent, etQuery );
+ populateTree(xCollection, rParent, etQuery);
}
}
return true;
}
-bool SbaTableQueryBrowser::ensureEntryObject( SvTreeListEntry* _pEntry )
+bool SbaTableQueryBrowser::ensureEntryObject(const weld::TreeIter& rEntry)
{
- OSL_ENSURE(_pEntry, "SbaTableQueryBrowser::ensureEntryObject: invalid argument!");
- if (!_pEntry)
- return false;
-
- EntryType eType = getEntryType( _pEntry );
+ EntryType eType = getEntryType(rEntry);
// the user data of the entry
- DBTreeListUserData* pEntryData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData());
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ DBTreeListUserData* pEntryData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(rEntry).toUInt64());
OSL_ENSURE(pEntryData,"ensureEntryObject: user data should already be set!");
- SvTreeListEntry* pDataSourceEntry = m_pTreeView->getListBox().GetRootLevelParent(_pEntry);
+ std::unique_ptr<weld::TreeIter> xDataSourceEntry = m_pTreeView->getListBox().GetRootLevelParent(&rEntry);
bool bSuccess = false;
switch (eType)
{
case etQueryContainer:
+ {
if ( pEntryData->xContainer.is() )
{
// nothing to do
@@ -2201,14 +2264,13 @@ bool SbaTableQueryBrowser::ensureEntryObject( SvTreeListEntry* _pEntry )
break;
}
+ std::unique_ptr<weld::TreeIter> xParent(rTreeView.make_iterator(&rEntry));
+ if (rTreeView.iter_parent(*xParent))
{
- SvTreeListEntry* pParent = m_pTreeView->getListBox().GetParent(_pEntry);
- if ( pParent != pDataSourceEntry )
+ if (rTreeView.iter_compare(*xParent, *xDataSourceEntry) != 0)
{
- SvLBoxString* pString = static_cast<SvLBoxString*>(_pEntry->GetFirstItem(SvLBoxItemType::String));
- OSL_ENSURE(pString,"There must be a string item!");
- OUString aName(pString->GetText());
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pParent->GetUserData());
+ OUString aName(rTreeView.get_text(rEntry));
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xParent).toUInt64());
try
{
Reference< XNameAccess > xNameAccess(pData->xContainer,UNO_QUERY);
@@ -2227,7 +2289,7 @@ bool SbaTableQueryBrowser::ensureEntryObject( SvTreeListEntry* _pEntry )
try
{
Reference< XQueryDefinitionsSupplier > xQuerySup;
- m_xDatabaseContext->getByName( getDataSourceAccessor( pDataSourceEntry ) ) >>= xQuerySup;
+ m_xDatabaseContext->getByName(getDataSourceAccessor(*xDataSourceEntry)) >>= xQuerySup;
if (xQuerySup.is())
{
Reference< XNameAccess > xQueryDefs = xQuerySup->getQueryDefinitions();
@@ -2250,13 +2312,12 @@ bool SbaTableQueryBrowser::ensureEntryObject( SvTreeListEntry* _pEntry )
}
}
break;
-
+ }
default:
SAL_WARN("dbaccess.ui", "SbaTableQueryBrowser::ensureEntryObject: ooops ... missing some implementation here!");
// TODO ...
break;
}
-
return bSuccess;
}
@@ -2274,7 +2335,7 @@ bool SbaTableQueryBrowser::implSelect(const svx::ODataAccessDescriptor& _rDescri
}
bool SbaTableQueryBrowser::implLoadAnything(const OUString& _rDataSourceName, const OUString& _rCommand,
- const sal_Int32 _nCommandType, const bool _bEscapeProcessing, const SharedConnection& _rxConnection)
+ const sal_Int32 nCommandType, const bool _bEscapeProcessing, const SharedConnection& _rxConnection)
{
try
{
@@ -2286,7 +2347,7 @@ bool SbaTableQueryBrowser::implLoadAnything(const OUString& _rDataSourceName, co
xProp->setPropertyValue( PROPERTY_ACTIVE_CONNECTION, makeAny( _rxConnection.getTyped() ) );
// set this _before_ setting the connection, else the rowset would rebuild it ...
- xProp->setPropertyValue(PROPERTY_COMMAND_TYPE, makeAny(_nCommandType));
+ xProp->setPropertyValue(PROPERTY_COMMAND_TYPE, makeAny(nCommandType));
xProp->setPropertyValue(PROPERTY_COMMAND, makeAny(_rCommand));
xProp->setPropertyValue(PROPERTY_ESCAPE_PROCESSING, css::uno::makeAny(_bEscapeProcessing));
if ( m_bPreview )
@@ -2357,44 +2418,47 @@ bool SbaTableQueryBrowser::implLoadAnything(const OUString& _rDataSourceName, co
}
bool SbaTableQueryBrowser::implSelect(const OUString& _rDataSourceName, const OUString& _rCommand,
- const sal_Int32 _nCommandType, const bool _bEscapeProcessing,
+ const sal_Int32 nCommandType, const bool _bEscapeProcessing,
const SharedConnection& _rxConnection,
bool _bSelectDirect)
{
- if (_rDataSourceName.getLength() && _rCommand.getLength() && (-1 != _nCommandType))
+ if (_rDataSourceName.getLength() && _rCommand.getLength() && (-1 != nCommandType))
{
- SvTreeListEntry* pDataSource = nullptr;
- SvTreeListEntry* pCommandType = nullptr;
- SvTreeListEntry* pCommand = getObjectEntry( _rDataSourceName, _rCommand, _nCommandType, &pDataSource, &pCommandType, true, _rxConnection );
+ std::unique_ptr<weld::TreeIter> xDataSource;
+ std::unique_ptr<weld::TreeIter> xCommandType;
+ std::unique_ptr<weld::TreeIter> xCommand = getObjectEntry( _rDataSourceName, _rCommand, nCommandType, &xDataSource, &xCommandType, true, _rxConnection );
- if (pCommand)
+ if (xCommand)
{
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+
bool bSuccess = true;
if ( _bSelectDirect )
{
- bSuccess = implSelect( pCommand );
+ bSuccess = implSelect(xCommand.get());
}
else
{
- m_pTreeView->getListBox().Select( pCommand );
+ rTreeView.select(*xCommand);
}
if ( bSuccess )
{
- m_pTreeView->getListBox().MakeVisible(pCommand);
- m_pTreeView->getListBox().SetCursor(pCommand);
+ rTreeView.scroll_to_row(*xCommand);
+ rTreeView.set_cursor(*xCommand);
}
}
- else if (!pCommandType)
+ else if (!xCommandType)
{
- if ( m_pCurrentlyDisplayed )
- { // tell the old entry (if any) it has been deselected
- selectPath(m_pCurrentlyDisplayed, false);
- m_pCurrentlyDisplayed = nullptr;
+ if (m_xCurrentlyDisplayed)
+ {
+ // tell the old entry (if any) it has been deselected
+ selectPath(m_xCurrentlyDisplayed.get(), false);
+ m_xCurrentlyDisplayed.reset();
}
// we have a command and need to display this in the rowset
- return implLoadAnything(_rDataSourceName, _rCommand, _nCommandType, _bEscapeProcessing, _rxConnection);
+ return implLoadAnything(_rDataSourceName, _rCommand, nCommandType, _bEscapeProcessing, _rxConnection);
}
}
return false;
@@ -2402,27 +2466,33 @@ bool SbaTableQueryBrowser::implSelect(const OUString& _rDataSourceName, const OU
IMPL_LINK_NOARG(SbaTableQueryBrowser, OnSelectionChange, LinkParamNone*, void)
{
- implSelect( m_pTreeView->getListBox().FirstSelected() );
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xSelection(rTreeView.make_iterator());
+ if (!rTreeView.get_selected(xSelection.get()))
+ xSelection.reset();
+ implSelect(xSelection.get());
}
-SvTreeListEntry* SbaTableQueryBrowser::implGetConnectionEntry(SvTreeListEntry* _pEntry) const
+std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::implGetConnectionEntry(weld::TreeIter& rEntry) const
{
- SvTreeListEntry* pCurrentEntry = _pEntry;
- DBTreeListUserData* pEntryData = static_cast< DBTreeListUserData* >( pCurrentEntry->GetUserData() );
- while(pEntryData->eType != etDatasource )
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xCurrentEntry(rTreeView.make_iterator(&rEntry));
+ DBTreeListUserData* pEntryData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xCurrentEntry).toInt64());
+ while (pEntryData->eType != etDatasource)
{
- pCurrentEntry = m_pTreeView->GetTreeModel()->GetParent(pCurrentEntry);
- pEntryData = static_cast< DBTreeListUserData* >( pCurrentEntry->GetUserData() );
+ rTreeView.iter_parent(*xCurrentEntry);
+ pEntryData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xCurrentEntry).toInt64());
}
- return pCurrentEntry;
+ return xCurrentEntry;
}
-bool SbaTableQueryBrowser::implSelect( SvTreeListEntry* _pEntry )
+bool SbaTableQueryBrowser::implSelect(weld::TreeIter* pEntry)
{
- if ( !_pEntry )
+ if ( !pEntry )
return false;
- DBTreeListUserData* pEntryData = static_cast< DBTreeListUserData* >( _pEntry->GetUserData() );
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ DBTreeListUserData* pEntryData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*pEntry).toUInt64());
switch (pEntryData->eType)
{
case etTableOrView:
@@ -2433,16 +2503,16 @@ bool SbaTableQueryBrowser::implSelect( SvTreeListEntry* _pEntry )
return false;
}
- OSL_ENSURE(m_pTreeView->GetTreeModel()->HasParent(_pEntry), "SbaTableQueryBrowser::implSelect: invalid entry (1)!");
- OSL_ENSURE(m_pTreeView->GetTreeModel()->HasParent(m_pTreeView->GetTreeModel()->GetParent(_pEntry)), "SbaTableQueryBrowser::implSelect: invalid entry (2)!");
+ OSL_ENSURE(rTreeView.get_iter_depth(*pEntry) >= 2, "SbaTableQueryBrowser::implSelect: invalid entry!");
// get the entry for the tables or queries
- SvTreeListEntry* pContainer = m_pTreeView->GetTreeModel()->GetParent(_pEntry);
- DBTreeListUserData* pContainerData = static_cast<DBTreeListUserData*>(pContainer->GetUserData());
+ std::unique_ptr<weld::TreeIter> xContainer = rTreeView.make_iterator(pEntry);
+ rTreeView.iter_parent(*xContainer);
+ DBTreeListUserData* pContainerData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xContainer).toUInt64());
// get the entry for the datasource
- SvTreeListEntry* pConnection = implGetConnectionEntry(pContainer);
- DBTreeListUserData* pConData = static_cast<DBTreeListUserData*>(pConnection->GetUserData());
+ std::unique_ptr<weld::TreeIter> xConnection = implGetConnectionEntry(*xContainer);
+ DBTreeListUserData* pConData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xConnection).toUInt64());
// reinitialize the rowset
// but first check if it is necessary
@@ -2455,20 +2525,22 @@ bool SbaTableQueryBrowser::implSelect( SvTreeListEntry* _pEntry )
Reference<XConnection> xOldConnection(xRowSetProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
// the name of the table or query
- SvLBoxString* pString = static_cast<SvLBoxString*>(_pEntry->GetFirstItem(SvLBoxItemType::String));
- OSL_ENSURE(pString,"There must be a string item!");
- const OUString sSimpleName = pString->GetText();
+ const OUString sSimpleName = rTreeView.get_text(*pEntry);
OUStringBuffer sNameBuffer(sSimpleName);
if ( etQueryContainer == pContainerData->eType )
{
- SvTreeListEntry* pTemp = pContainer;
- while( m_pTreeView->GetTreeModel()->GetParent(pTemp) != pConnection )
+ std::unique_ptr<weld::TreeIter> xTemp = rTreeView.make_iterator(xContainer.get());
+ std::unique_ptr<weld::TreeIter> xNextTemp = rTreeView.make_iterator(xTemp.get());
+ if (rTreeView.iter_parent(*xNextTemp))
{
- sNameBuffer.insert(0,'/');
- pString = static_cast<SvLBoxString*>(pTemp->GetFirstItem(SvLBoxItemType::String));
- OSL_ENSURE(pString,"There must be a string item!");
- sNameBuffer.insert(0,pString->GetText());
- pTemp = m_pTreeView->GetTreeModel()->GetParent(pTemp);
+ while (rTreeView.iter_compare(*xNextTemp, *xConnection) != 0)
+ {
+ sNameBuffer.insert(0,'/');
+ sNameBuffer.insert(0, rTreeView.get_text(*xTemp));
+ rTreeView.copy_iterator(*xNextTemp, *xTemp);
+ if (!rTreeView.iter_parent(*xNextTemp))
+ break;
+ }
}
}
OUString aName = sNameBuffer.makeStringAndClear();
@@ -2492,16 +2564,16 @@ bool SbaTableQueryBrowser::implSelect( SvTreeListEntry* _pEntry )
weld::WaitObject aWaitCursor(getFrameWeld());
// tell the old entry it has been deselected
- selectPath(m_pCurrentlyDisplayed, false);
- m_pCurrentlyDisplayed = nullptr;
+ selectPath(m_xCurrentlyDisplayed.get(), false);
+ m_xCurrentlyDisplayed.reset();
// not really loaded
- m_pCurrentlyDisplayed = _pEntry;
+ m_xCurrentlyDisplayed = rTreeView.make_iterator(pEntry);
// tell the new entry it has been selected
- selectPath(m_pCurrentlyDisplayed);
+ selectPath(m_xCurrentlyDisplayed.get());
// get the name of the data source currently selected
- ensureConnection( m_pCurrentlyDisplayed, pConData->xConnection );
+ ensureConnection(m_xCurrentlyDisplayed.get(), pConData->xConnection);
if ( !pConData->xConnection.is() )
{
@@ -2547,7 +2619,7 @@ bool SbaTableQueryBrowser::implSelect( SvTreeListEntry* _pEntry )
bool bEscapeProcessing = true;
if(xNameAccess.is() && xNameAccess->hasByName(sSimpleName))
{
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData());
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*pEntry).toUInt64());
if ( !pData->xObjectProperties.is() )
{
Reference<XInterface> xObject;
@@ -2596,7 +2668,7 @@ bool SbaTableQueryBrowser::implSelect( SvTreeListEntry* _pEntry )
}
}
- OUString sDataSourceName( getDataSourceAccessor( pConnection ) );
+ OUString sDataSourceName(getDataSourceAccessor(*xConnection));
bSuccess = implLoadAnything( sDataSourceName, aName, nCommandType, bEscapeProcessing, pConData->xConnection );
if ( !bSuccess )
{ // clean up
@@ -2634,72 +2706,93 @@ bool SbaTableQueryBrowser::implSelect( SvTreeListEntry* _pEntry )
return bSuccess;
}
-SvTreeListEntry* SbaTableQueryBrowser::getEntryFromContainer(const Reference<XNameAccess>& _rxNameAccess)
+std::unique_ptr<weld::TreeIter> SbaTableQueryBrowser::getEntryFromContainer(const Reference<XNameAccess>& rxNameAccess)
{
- DBTreeListBox& rListBox = m_pTreeView->getListBox();
- SvTreeListEntry* pContainer = nullptr;
- SvTreeListEntry* pDSLoop = rListBox.FirstChild(nullptr);
- while (pDSLoop)
- {
- pContainer = rListBox.GetEntry(pDSLoop, CONTAINER_QUERIES);
- DBTreeListUserData* pQueriesData = static_cast<DBTreeListUserData*>(pContainer->GetUserData());
- if ( pQueriesData && pQueriesData->xContainer == _rxNameAccess )
- break;
+ std::unique_ptr<weld::TreeIter> xContainer;
- pContainer = rListBox.GetEntry(pDSLoop, CONTAINER_TABLES);
- DBTreeListUserData* pTablesData = static_cast<DBTreeListUserData*>(pContainer->GetUserData());
- if ( pTablesData && pTablesData->xContainer == _rxNameAccess )
- break;
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xDSLoop(rTreeView.make_iterator(xContainer.get()));
+ if (rTreeView.get_iter_first(*xDSLoop))
+ {
+ do
+ {
+ xContainer = rTreeView.make_iterator(xDSLoop.get());
+ if (rTreeView.iter_children(*xContainer))
+ {
+ // 1st child is queries
+ DBTreeListUserData* pQueriesData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xContainer).toUInt64());
+ if (pQueriesData && pQueriesData->xContainer == rxNameAccess)
+ break;
- pDSLoop = pDSLoop->NextSibling();
- pContainer = nullptr;
+ if (rTreeView.iter_next_sibling(*xContainer))
+ {
+ // 2nd child is tables
+ DBTreeListUserData* pTablesData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xContainer).toUInt64());
+ if (pTablesData && pTablesData->xContainer == rxNameAccess)
+ break;
+ }
+ }
+ xContainer.reset();
+ }
+ while (rTreeView.iter_next_sibling(*xDSLoop));
}
- return pContainer;
+
+ return xContainer;
}
-void SAL_CALL SbaTableQueryBrowser::elementInserted( const ContainerEvent& _rEvent )
+void SAL_CALL SbaTableQueryBrowser::elementInserted(const ContainerEvent& rEvent)
{
SolarMutexGuard aSolarGuard;
- Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
+ Reference< XNameAccess > xNames(rEvent.Source, UNO_QUERY);
// first search for a definition container where we can insert this element
- SvTreeListEntry* pEntry = getEntryFromContainer(xNames);
- if(pEntry) // found one
+ std::unique_ptr<weld::TreeIter> xEntry = getEntryFromContainer(xNames);
+ if (xEntry) // found one
{
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ rTreeView.make_unsorted();
+
// insert the new entry into the tree
- DBTreeListUserData* pContainerData = static_cast<DBTreeListUserData*>(pEntry->GetUserData());
+ DBTreeListUserData* pContainerData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xEntry).toUInt64());
OSL_ENSURE(pContainerData, "elementInserted: There must be user data for this type!");
DBTreeListUserData* pNewData = new DBTreeListUserData;
bool bIsTable = etTableContainer == pContainerData->eType;
if ( bIsTable )
{
- _rEvent.Element >>= pNewData->xObjectProperties;// remember the new element
+ rEvent.Element >>= pNewData->xObjectProperties;// remember the new element
pNewData->eType = etTableOrView;
}
else
{
- if (static_cast<sal_Int32>(m_pTreeView->getListBox().GetChildCount(pEntry)) < ( xNames->getElementNames().getLength() - 1 ) )
+ if (rTreeView.iter_n_children(*xEntry) < xNames->getElementNames().getLength() - 1)
{
// the item inserts its children on demand, but it has not been expanded yet. So ensure here and
// now that it has all items
- populateTree(xNames, pEntry, etQuery );
+ populateTree(xNames, *xEntry, etQuery);
}
pNewData->eType = etQuery;
}
- implAppendEntry( pEntry, ::comphelper::getString( _rEvent.Accessor ), pNewData, pNewData->eType );
+ implAppendEntry(xEntry.get(), ::comphelper::getString(rEvent.Accessor), pNewData, pNewData->eType);
+
+ rTreeView.make_sorted();
}
else
- SbaXDataBrowserController::elementInserted(_rEvent);
+ SbaXDataBrowserController::elementInserted(rEvent);
}
-bool SbaTableQueryBrowser::isCurrentlyDisplayedChanged(const OUString& _sName, SvTreeListEntry const * _pContainer)
+bool SbaTableQueryBrowser::isCurrentlyDisplayedChanged(const OUString& rName, const weld::TreeIter& rContainer)
{
- return m_pCurrentlyDisplayed
- && getEntryType(m_pCurrentlyDisplayed) == getChildType(_pContainer)
- && m_pTreeView->getListBox().GetParent(m_pCurrentlyDisplayed) == _pContainer
- && m_pTreeView->getListBox().GetEntryText(m_pCurrentlyDisplayed) == _sName;
+ if (!m_xCurrentlyDisplayed)
+ return false;
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ if (getEntryType(*m_xCurrentlyDisplayed) != getChildType(rContainer))
+ return false;
+ if (rTreeView.get_text(*m_xCurrentlyDisplayed) != rName)
+ return false;
+ std::unique_ptr<weld::TreeIter> xParent = rTreeView.make_iterator(m_xCurrentlyDisplayed.get());
+ return rTreeView.iter_parent(*xParent) && rTreeView.iter_compare(*xParent, rContainer) == 0;
}
void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEvent )
@@ -2709,41 +2802,45 @@ void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEven
Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
// get the top-level representing the removed data source
// and search for the queries and tables
- SvTreeListEntry* pContainer = getEntryFromContainer(xNames);
- if ( pContainer )
- { // a query or table has been removed
+ std::unique_ptr<weld::TreeIter> xContainer = getEntryFromContainer(xNames);
+ if (xContainer)
+ {
+ // a query or table has been removed
OUString aName = ::comphelper::getString(_rEvent.Accessor);
- if ( isCurrentlyDisplayedChanged( aName, pContainer) )
- { // the element displayed currently has been replaced
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ if (isCurrentlyDisplayedChanged(aName, *xContainer))
+ {
+ // the element displayed currently has been replaced
// we need to remember the old value
- SvTreeListEntry* pTemp = m_pCurrentlyDisplayed;
+ std::unique_ptr<weld::TreeIter> xTemp = rTreeView.make_iterator(m_xCurrentlyDisplayed.get());
// unload
unloadAndCleanup( false ); // don't dispose the connection
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pTemp->GetUserData());
- pTemp->SetUserData(nullptr);
- delete pData;
- // the data could be null because we have a table which isn't correct
- m_pTreeView->GetTreeModel()->Remove(pTemp);
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xTemp).toUInt64());
+ rTreeView.set_id(*xTemp, OUString());
+ delete pData; // the data could be null because we have a table which isn't correct
+ rTreeView.remove(*xTemp);
}
else
{
// remove the entry from the model
- SvTreeListEntry* pChild = m_pTreeView->GetTreeModel()->FirstChild(pContainer);
- while(pChild)
+ std::unique_ptr<weld::TreeIter> xChild(rTreeView.make_iterator(xContainer.get()));
+ if (rTreeView.get_iter_first(*xChild))
{
- if (m_pTreeView->getListBox().GetEntryText(pChild) == aName)
+ do
{
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pChild->GetUserData());
- pChild->SetUserData(nullptr);
- delete pData;
- m_pTreeView->GetTreeModel()->Remove(pChild);
- break;
- }
- pChild = pChild->NextSibling();
+ if (rTreeView.get_text(*xChild) == aName)
+ {
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xChild).toUInt64());
+ rTreeView.set_id(*xChild, OUString());
+ delete pData;
+ rTreeView.remove(*xChild);
+ break;
+ }
+ } while (rTreeView.iter_next_sibling(*xChild));
}
}
@@ -2759,28 +2856,31 @@ void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEve
SolarMutexGuard aSolarGuard;
Reference< XNameAccess > xNames(_rEvent.Source, UNO_QUERY);
- SvTreeListEntry* pContainer = getEntryFromContainer(xNames);
- if ( pContainer )
- { // a table or query as been replaced
+ std::unique_ptr<weld::TreeIter> xContainer = getEntryFromContainer(xNames);
+ if (xContainer)
+ {
+ // a table or query as been replaced
OUString aName = ::comphelper::getString(_rEvent.Accessor);
- if ( isCurrentlyDisplayedChanged( aName, pContainer) )
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ if (isCurrentlyDisplayedChanged(aName, *xContainer))
{ // the element displayed currently has been replaced
// we need to remember the old value
- SvTreeListEntry* pTemp = m_pCurrentlyDisplayed;
+ std::unique_ptr<weld::TreeIter> xTemp = rTreeView.make_iterator(m_xCurrentlyDisplayed.get());
unloadAndCleanup( false ); // don't dispose the connection
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pTemp->GetUserData());
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xTemp).toUInt64());
if (pData)
{
if ( etTableOrView == pData->eType )
- { // only insert userdata when we have a table because the query is only a commanddefinition object and not a query
+ {
+ // 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
}
else
{
- pTemp->SetUserData(nullptr);
+ rTreeView.set_id(*xTemp, OUString());
delete pData;
}
}
@@ -2788,27 +2888,30 @@ void SAL_CALL SbaTableQueryBrowser::elementReplaced( const ContainerEvent& _rEve
else
{
// find the entry for this name
- SvTreeListEntry* pChild = m_pTreeView->GetTreeModel()->FirstChild(pContainer);
- while(pChild)
+ std::unique_ptr<weld::TreeIter> xChild(rTreeView.make_iterator(xContainer.get()));
+ if (rTreeView.get_iter_first(*xChild))
{
- if (m_pTreeView->getListBox().GetEntryText(pChild) == aName)
+ do
{
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pChild->GetUserData());
- if (pData)
+ if (rTreeView.get_text(*xChild) == aName)
{
- 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
- }
- else
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xChild).toUInt64());
+ if (pData)
{
- pChild->SetUserData(nullptr);
- delete pData;
+ 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
+ }
+ else
+ {
+ rTreeView.set_id(*xChild, OUString());
+ delete pData;
+ }
}
+ break;
}
- break;
- }
- pChild = pChild->NextSibling();
+ } while (rTreeView.iter_next_sibling(*xChild));
}
}
@@ -2852,68 +2955,79 @@ void SbaTableQueryBrowser::impl_releaseConnection( SharedConnection& _rxConnecti
// will implicitly dispose if we have the ownership, since xConnection is a SharedConnection
}
-void SbaTableQueryBrowser::disposeConnection( SvTreeListEntry* _pDSEntry )
+void SbaTableQueryBrowser::disposeConnection(weld::TreeIter* pDSEntry)
{
- OSL_ENSURE( _pDSEntry, "SbaTableQueryBrowser::disposeConnection: invalid entry (NULL)!" );
- OSL_ENSURE( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::disposeConnection: invalid entry (not top-level)!" );
+ OSL_ENSURE( pDSEntry, "SbaTableQueryBrowser::disposeConnection: invalid entry (NULL)!" );
+ OSL_ENSURE( impl_isDataSourceEntry( pDSEntry ), "SbaTableQueryBrowser::disposeConnection: invalid entry (not top-level)!" );
- if ( _pDSEntry )
+ if (pDSEntry)
{
- DBTreeListUserData* pTreeListData = static_cast< DBTreeListUserData* >( _pDSEntry->GetUserData() );
- if ( pTreeListData )
- impl_releaseConnection( pTreeListData->xConnection );
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ DBTreeListUserData* pTreeListData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*pDSEntry).toUInt64());
+ if (pTreeListData)
+ impl_releaseConnection(pTreeListData->xConnection);
}
}
-void SbaTableQueryBrowser::closeConnection(SvTreeListEntry* _pDSEntry, bool _bDisposeConnection)
+void SbaTableQueryBrowser::closeConnection(weld::TreeIter& rDSEntry, bool _bDisposeConnection)
{
- OSL_ENSURE(_pDSEntry, "SbaTableQueryBrowser::closeConnection: invalid entry (NULL)!");
- OSL_ENSURE( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::closeConnection: invalid entry (not top-level)!");
+ OSL_ENSURE(impl_isDataSourceEntry(&rDSEntry), "SbaTableQueryBrowser::closeConnection: invalid entry (not top-level)!");
+
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
// if one of the entries of the given DS is displayed currently, unload the form
- if (m_pCurrentlyDisplayed && (m_pTreeView->getListBox().GetRootLevelParent(m_pCurrentlyDisplayed) == _pDSEntry))
- unloadAndCleanup(_bDisposeConnection);
+ if (m_xCurrentlyDisplayed)
+ {
+ std::unique_ptr<weld::TreeIter> xRoot = m_pTreeView->getListBox().GetRootLevelParent(m_xCurrentlyDisplayed.get());
+ if (rTreeView.iter_compare(*xRoot, rDSEntry) == 0)
+ unloadAndCleanup(_bDisposeConnection);
+ }
// collapse the query/table container
- for (SvTreeListEntry* pContainers = m_pTreeView->GetTreeModel()->FirstChild(_pDSEntry); pContainers; pContainers = pContainers->NextSibling())
- {
- SvTreeListEntry* pElements = m_pTreeView->GetTreeModel()->FirstChild(pContainers);
- if ( pElements )
- m_pTreeView->getListBox().Collapse(pContainers);
- m_pTreeView->getListBox().EnableExpandHandler(pContainers);
- // and delete their children (they are connection-relative)
- for (; pElements; )
- {
- SvTreeListEntry* pRemove = pElements;
- pElements = pElements->NextSibling();
- DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pRemove->GetUserData());
- pRemove->SetUserData(nullptr);
- delete pData;
- m_pTreeView->GetTreeModel()->Remove(pRemove);
+ std::unique_ptr<weld::TreeIter> xContainers(rTreeView.make_iterator());
+ if (rTreeView.get_iter_first(*xContainers))
+ {
+ do
+ {
+ std::unique_ptr<weld::TreeIter> xElements(rTreeView.make_iterator(xContainers.get()));
+ if (rTreeView.get_iter_first(*xElements))
+ {
+ rTreeView.collapse_row(*xContainers);
+ // and delete their children (they are connection-relative)
+ bool bElements = true;
+ while (bElements)
+ {
+ std::unique_ptr<weld::TreeIter> xRemove(rTreeView.make_iterator(xElements.get()));
+ bElements = rTreeView.iter_next_sibling(*xElements);
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xRemove).toUInt64());
+ rTreeView.set_id(*xRemove, OUString());
+ delete pData;
+ rTreeView.remove(*xRemove);
+ }
+ }
}
+ while (rTreeView.iter_next_sibling(*xContainers));
}
+
// collapse the entry itself
- m_pTreeView->getListBox().Collapse(_pDSEntry);
+ rTreeView.collapse_row(rDSEntry);
// dispose/reset the connection
if ( _bDisposeConnection )
- disposeConnection( _pDSEntry );
+ disposeConnection(&rDSEntry);
}
void SbaTableQueryBrowser::unloadAndCleanup( bool _bDisposeConnection )
{
- if (!m_pCurrentlyDisplayed)
+ if (!m_xCurrentlyDisplayed)
// nothing to do
return;
- SvTreeListEntry* pDSEntry = m_pTreeView->getListBox().GetRootLevelParent(m_pCurrentlyDisplayed);
+ std::unique_ptr<weld::TreeIter> xDSEntry = m_pTreeView->getListBox().GetRootLevelParent(m_xCurrentlyDisplayed.get());
// de-select the path for the currently displayed table/query
- if (m_pCurrentlyDisplayed)
- {
- selectPath(m_pCurrentlyDisplayed, false);
- }
- m_pCurrentlyDisplayed = nullptr;
+ selectPath(m_xCurrentlyDisplayed.get(), false);
+ m_xCurrentlyDisplayed.reset();
try
{
@@ -2930,7 +3044,7 @@ void SbaTableQueryBrowser::unloadAndCleanup( bool _bDisposeConnection )
// dispose the connection
if(_bDisposeConnection)
- disposeConnection( pDSEntry );
+ disposeConnection(xDSEntry.get());
}
catch(SQLException& e)
{
@@ -3084,6 +3198,9 @@ void SbaTableQueryBrowser::impl_initialize()
// which was given as initial selection
bLimitedTreeEntries |= !m_bEnableBrowser;
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ rTreeView.make_unsorted();
+
if ( bLimitedTreeEntries )
{
if ( xConnection.is() )
@@ -3112,11 +3229,16 @@ void SbaTableQueryBrowser::impl_initialize()
}
implAddDatasource( sInitialDataSourceName, xConnection );
- m_pTreeView->getListBox().Expand( m_pTreeView->getListBox().First() );
+
+ std::unique_ptr<weld::TreeIter> xFirst(rTreeView.make_iterator());
+ if (rTreeView.get_iter_first(*xFirst))
+ rTreeView.expand_row(*xFirst);
}
else
initializeTreeModel();
+ rTreeView.make_sorted();
+
if ( m_bEnableBrowser )
{
m_aDocScriptSupport = ::std::optional< bool >( false );
@@ -3183,55 +3305,62 @@ void SbaTableQueryBrowser::showExplorer()
InvalidateFeature(ID_BROWSER_EXPLORER);
}
-bool SbaTableQueryBrowser::ensureConnection(SvTreeListEntry* _pAnyEntry, SharedConnection& _rConnection)
+bool SbaTableQueryBrowser::ensureConnection(const weld::TreeIter* pAnyEntry, SharedConnection& rConnection)
{
- SvTreeListEntry* pDSEntry = m_pTreeView->getListBox().GetRootLevelParent(_pAnyEntry);
+ std::unique_ptr<weld::TreeIter> xDSEntry = m_pTreeView->getListBox().GetRootLevelParent(pAnyEntry);
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
DBTreeListUserData* pDSData =
- pDSEntry
- ? static_cast<DBTreeListUserData*>(pDSEntry->GetUserData())
+ xDSEntry
+ ? reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xDSEntry).toUInt64())
: nullptr;
- return ensureConnection( pDSEntry, pDSData, _rConnection );
+ return ensureConnection(xDSEntry.get(), pDSData, rConnection);
}
-std::unique_ptr< ImageProvider > SbaTableQueryBrowser::getImageProviderFor( SvTreeListEntry* _pAnyEntry )
+std::unique_ptr< ImageProvider > SbaTableQueryBrowser::getImageProviderFor(const weld::TreeIter* pAnyEntry)
{
- std::unique_ptr< ImageProvider > pImageProvider( new ImageProvider );
+ std::unique_ptr<ImageProvider> xImageProvider(new ImageProvider);
SharedConnection xConnection;
- if ( getExistentConnectionFor( _pAnyEntry, xConnection ) )
- pImageProvider.reset( new ImageProvider( xConnection ) );
- return pImageProvider;
+ if (getExistentConnectionFor(pAnyEntry, xConnection))
+ xImageProvider.reset(new ImageProvider(xConnection));
+ return xImageProvider;
}
-bool SbaTableQueryBrowser::getExistentConnectionFor( SvTreeListEntry* _pAnyEntry, SharedConnection& _rConnection )
+bool SbaTableQueryBrowser::getExistentConnectionFor(const weld::TreeIter* pAnyEntry, SharedConnection& rConnection)
{
- SvTreeListEntry* pDSEntry = m_pTreeView->getListBox().GetRootLevelParent( _pAnyEntry );
+ std::unique_ptr<weld::TreeIter> xDSEntry = m_pTreeView->getListBox().GetRootLevelParent(pAnyEntry);
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
DBTreeListUserData* pDSData =
- pDSEntry
- ? static_cast< DBTreeListUserData* >( pDSEntry->GetUserData() )
+ xDSEntry
+ ? reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xDSEntry).toUInt64())
: nullptr;
- if ( pDSData )
- _rConnection = pDSData->xConnection;
- return _rConnection.is();
+ if (pDSData)
+ rConnection = pDSData->xConnection;
+ return rConnection.is();
}
-bool SbaTableQueryBrowser::impl_isDataSourceEntry( SvTreeListEntry* _pEntry ) const
+bool SbaTableQueryBrowser::impl_isDataSourceEntry(const weld::TreeIter* pEntry) const
{
- return m_pTreeView->GetTreeModel()->GetRootLevelParent( _pEntry ) == _pEntry;
+ if (!pEntry)
+ return false;
+ std::unique_ptr<weld::TreeIter> xRoot(m_pTreeView->getListBox().GetRootLevelParent(pEntry));
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ return rTreeView.iter_compare(*xRoot, *pEntry) == 0;
}
-bool SbaTableQueryBrowser::ensureConnection( SvTreeListEntry* _pDSEntry, void* pDSData, SharedConnection& _rConnection )
+bool SbaTableQueryBrowser::ensureConnection(const weld::TreeIter* pDSEntry, void* pDSData, SharedConnection& rConnection)
{
- OSL_ENSURE( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::ensureConnection: this entry does not denote a data source!" );
- if(_pDSEntry)
+ OSL_ENSURE( impl_isDataSourceEntry( pDSEntry ), "SbaTableQueryBrowser::ensureConnection: this entry does not denote a data source!" );
+ if (pDSEntry)
{
- DBTreeListUserData* pTreeListData = static_cast<DBTreeListUserData*>(pDSData);
- OUString aDSName = GetEntryText(_pDSEntry);
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ OUString aDSName = rTreeView.get_text(*pDSEntry);
+ DBTreeListUserData* pTreeListData = static_cast<DBTreeListUserData*>(pDSData);
if ( pTreeListData )
- _rConnection = pTreeListData->xConnection;
+ rConnection = pTreeListData->xConnection;
- if ( !_rConnection.is() && pTreeListData )
+ if ( !rConnection.is() && pTreeListData )
{
// show the "connecting to ..." status
OUString sConnecting(DBA_RES(STR_CONNECTING_DATASOURCE));
@@ -3243,37 +3372,33 @@ bool SbaTableQueryBrowser::ensureConnection( SvTreeListEntry* _pDSEntry, void* p
sConnectingContext = sConnectingContext.replaceFirst("$name$", aDSName);
// connect
- _rConnection.reset(
- connect( getDataSourceAccessor( _pDSEntry ), sConnectingContext, nullptr ),
- SharedConnection::TakeOwnership
- );
+ rConnection.reset(
+ connect(getDataSourceAccessor(*pDSEntry), sConnectingContext, nullptr),
+ SharedConnection::TakeOwnership);
// remember the connection
- pTreeListData->xConnection = _rConnection;
+ pTreeListData->xConnection = rConnection;
}
}
-
- return _rConnection.is();
+ return rConnection.is();
}
-IMPL_LINK( SbaTableQueryBrowser, OnTreeEntryCompare, const SvSortData&, _rSortData, sal_Int32 )
+int SbaTableQueryBrowser::OnTreeEntryCompare(const weld::TreeIter& rLHS, const weld::TreeIter& rRHS)
{
- const SvTreeListEntry* pLHS = _rSortData.pLeft;
- const SvTreeListEntry* pRHS = _rSortData.pRight;
- OSL_ENSURE(pLHS && pRHS, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid tree entries!");
- // we want the table entry and the end so we have to do a check
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
- if (isContainer(pRHS))
+ // we want the table entry and the end so we have to do a check
+ if (isContainer(rRHS))
{
// don't use getEntryType (directly or indirecly) for the LHS:
// LHS is currently being inserted, so it is not "completely valid" at the moment
- const EntryType eRight = getEntryType(pRHS);
+ const EntryType eRight = getEntryType(rRHS);
if (etTableContainer == eRight)
// every other container should be placed _before_ the bookmark container
return -1;
- const OUString sLeft = m_pTreeView->getListBox().GetEntryText(const_cast<SvTreeListEntry*>(pLHS));
+ const OUString sLeft = rTreeView.get_text(rLHS);
EntryType eLeft = etTableContainer;
if (DBA_RES(RID_STR_TABLES_CONTAINER) == sLeft)
@@ -3294,12 +3419,8 @@ IMPL_LINK( SbaTableQueryBrowser, OnTreeEntryCompare, const SvSortData&, _rSortDa
return 0;
}
- const SvLBoxString* pLeftTextItem = static_cast<const SvLBoxString*>(pLHS->GetFirstItem(SvLBoxItemType::String));
- const SvLBoxString* pRightTextItem = static_cast<const SvLBoxString*>(pRHS->GetFirstItem(SvLBoxItemType::String));
- OSL_ENSURE(pLeftTextItem && pRightTextItem, "SbaTableQueryBrowser::OnTreeEntryCompare: invalid text items!");
-
- OUString sLeftText = pLeftTextItem->GetText();
- OUString sRightText = pRightTextItem->GetText();
+ OUString sLeftText = rTreeView.get_text(rLHS);
+ OUString sRightText = rTreeView.get_text(rRHS);
sal_Int32 nCompareResult = 0; // equal by default
@@ -3320,24 +3441,21 @@ IMPL_LINK( SbaTableQueryBrowser, OnTreeEntryCompare, const SvSortData&, _rSortDa
return nCompareResult;
}
-void SbaTableQueryBrowser::implAdministrate( SvTreeListEntry* _pApplyTo )
+void SbaTableQueryBrowser::implAdministrate(weld::TreeIter& rApplyTo)
{
- OSL_PRECOND( _pApplyTo, "SbaTableQueryBrowser::implAdministrate: illegal entry!" );
- if ( !_pApplyTo )
- return;
-
try
{
// get the desktop object
Reference< XDesktop2 > xFrameLoader = Desktop::create( getORB() );
// the initial selection
- SvTreeListEntry* pTopLevelSelected = _pApplyTo;
- while (pTopLevelSelected && m_pTreeView->getListBox().GetParent(pTopLevelSelected))
- pTopLevelSelected = m_pTreeView->getListBox().GetParent(pTopLevelSelected);
- OUString sInitialSelection;
- if (pTopLevelSelected)
- sInitialSelection = getDataSourceAccessor( pTopLevelSelected );
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xTopLevelSelected(rTreeView.make_iterator(&rApplyTo));
+
+ while (rTreeView.get_iter_depth(*xTopLevelSelected))
+ rTreeView.iter_parent(*xTopLevelSelected);
+
+ OUString sInitialSelection = getDataSourceAccessor(*xTopLevelSelected);
Reference< XDataSource > xDataSource( getDataSourceByName( sInitialSelection, getFrameWeld(), getORB(), nullptr ) );
Reference< XModel > xDocumentModel( getDataSourceOrModel( xDataSource ), UNO_QUERY );
@@ -3369,14 +3487,8 @@ void SbaTableQueryBrowser::implAdministrate( SvTreeListEntry* _pApplyTo )
}
}
-bool SbaTableQueryBrowser::requestQuickHelp( const SvTreeListEntry* _pEntry, OUString& _rText ) const
+bool SbaTableQueryBrowser::requestQuickHelp( const SvTreeListEntry* , OUString& ) const
{
- const DBTreeListUserData* pData = static_cast< const DBTreeListUserData* >( _pEntry->GetUserData() );
- if ( ( pData->eType == etDatasource ) && !pData->sAccessor.isEmpty() )
- {
- _rText = ::svt::OFileNotation( pData->sAccessor ).get( ::svt::OFileNotation::N_SYSTEM );
- return true;
- }
return false;
}
@@ -3414,28 +3526,26 @@ Any SbaTableQueryBrowser::getCurrentSelection( Control& _rControl ) const
if ( &m_pTreeView->getListBox() != &_rControl )
return Any();
- SvTreeListEntry* pSelected = m_pTreeView->getListBox().FirstSelected();
- if ( !pSelected )
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xSelected(rTreeView.make_iterator());
+ if (!rTreeView.get_selected(xSelected.get()))
return Any();
- OSL_ENSURE( m_pTreeView->getListBox().NextSelected( pSelected ) == nullptr,
- "SbaTableQueryBrowser::getCurrentSelection: single-selection is expected here!" );
-
NamedDatabaseObject aSelectedObject;
- DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( pSelected->GetUserData() );
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xSelected).toUInt64());
aSelectedObject.Type = static_cast< sal_Int32 >( pData->eType );
switch ( aSelectedObject.Type )
{
case DatabaseObject::QUERY:
case DatabaseObject::TABLE:
- aSelectedObject.Name = m_pTreeView->getListBox().GetEntryText( pSelected );
+ aSelectedObject.Name = rTreeView.get_text(*xSelected);
break;
case DatabaseObjectContainer::DATA_SOURCE:
case DatabaseObjectContainer::QUERIES:
case DatabaseObjectContainer::TABLES:
- aSelectedObject.Name = getDataSourceAccessor( pSelected );
+ aSelectedObject.Name = getDataSourceAccessor(*xSelected);
break;
default:
@@ -3545,13 +3655,16 @@ void SbaTableQueryBrowser::loadMenu(const Reference< XFrame >& _xFrame)
OUString SbaTableQueryBrowser::getPrivateTitle() const
{
OUString sTitle;
- if ( m_pCurrentlyDisplayed )
+ if (m_xCurrentlyDisplayed)
{
- SvTreeListEntry* pContainer = m_pTreeView->GetTreeModel()->GetParent(m_pCurrentlyDisplayed);
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xContainer = rTreeView.make_iterator(m_xCurrentlyDisplayed.get());
+ if (!rTreeView.iter_parent(*xContainer))
+ return OUString();
// get the entry for the datasource
- SvTreeListEntry* pConnection = implGetConnectionEntry(pContainer);
- OUString sName = m_pTreeView->getListBox().GetEntryText(m_pCurrentlyDisplayed);
- sTitle = GetEntryText( pConnection );
+ std::unique_ptr<weld::TreeIter> xConnection = implGetConnectionEntry(*xContainer);
+ OUString sName = rTreeView.get_text(*m_xCurrentlyDisplayed);
+ sTitle = GetEntryText(*xConnection);
INetURLObject aURL(sTitle);
if ( aURL.GetProtocol() != INetProtocol::NotValid )
sTitle = aURL.getBase(INetURLObject::LAST_SEGMENT,true,INetURLObject::DecodeMechanism::WithCharset);
@@ -3568,7 +3681,7 @@ OUString SbaTableQueryBrowser::getPrivateTitle() const
bool SbaTableQueryBrowser::preReloadForm()
{
bool bIni = false;
- if ( !m_pCurrentlyDisplayed )
+ if (!m_xCurrentlyDisplayed)
{
// switch the grid to design mode while loading
getBrowserView()->getGridControl()->setDesignMode(true);
@@ -3583,9 +3696,7 @@ bool SbaTableQueryBrowser::preReloadForm()
extractDescriptorProps(aDesc, sDataSource, sCommand, nCommandType, bEscapeProcessing);
if ( !sDataSource.isEmpty() && !sCommand.isEmpty() && (-1 != nCommandType) )
{
- SvTreeListEntry* pDataSource = nullptr;
- SvTreeListEntry* pCommandType = nullptr;
- m_pCurrentlyDisplayed = getObjectEntry( sDataSource, sCommand, nCommandType, &pDataSource, &pCommandType );
+ m_xCurrentlyDisplayed = getObjectEntry(sDataSource, sCommand, nCommandType, nullptr, nullptr);
bIni = true;
}
}
@@ -3641,53 +3752,46 @@ void SAL_CALL SbaTableQueryBrowser::registeredDatabaseLocation( const DatabaseRe
implAddDatasource( Event.Name, SharedConnection() );
}
-void SbaTableQueryBrowser::impl_cleanupDataSourceEntry( const OUString& _rDataSourceName )
+void SbaTableQueryBrowser::impl_cleanupDataSourceEntry(const OUString& rDataSourceName)
{
// get the top-level representing the removed data source
- SvTreeListEntry* pDataSourceEntry = m_pTreeView->getListBox().FirstChild( nullptr );
- while ( pDataSourceEntry )
+ weld::TreeView& rTreeView = m_pTreeView->getListBox().GetWidget();
+ std::unique_ptr<weld::TreeIter> xDataSourceEntry(rTreeView.make_iterator());
+ bool bDataSourceEntry = rTreeView.get_iter_first(*xDataSourceEntry);
+ while (bDataSourceEntry)
{
- if ( m_pTreeView->getListBox().GetEntryText( pDataSourceEntry ) == _rDataSourceName )
+ if (rTreeView.get_text(*xDataSourceEntry) == rDataSourceName)
break;
-
- pDataSourceEntry = pDataSourceEntry->NextSibling();
+ bDataSourceEntry = rTreeView.iter_next_sibling(*xDataSourceEntry);
}
- OSL_ENSURE( pDataSourceEntry, "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: do not know this data source!" );
- if ( !pDataSourceEntry )
+ OSL_ENSURE( bDataSourceEntry, "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: do not know this data source!" );
+ if (!bDataSourceEntry)
return;
- if ( isSelected( pDataSourceEntry ) )
- { // a table or query belonging to the deleted data source is currently being displayed.
- OSL_ENSURE( m_pTreeView->getListBox().GetRootLevelParent( m_pCurrentlyDisplayed ) == pDataSourceEntry,
- "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: inconsistence (1)!" );
+ if (isSelected(*xDataSourceEntry))
+ {
+ // a table or query belonging to the deleted data source is currently being displayed.
unloadAndCleanup();
}
- else
- OSL_ENSURE(
- ( nullptr == m_pCurrentlyDisplayed )
- || ( m_pTreeView->getListBox().GetRootLevelParent( m_pCurrentlyDisplayed ) != pDataSourceEntry ),
- "SbaTableQueryBrowser::impl_cleanupDataSourceEntry: inconsistence (2)!");
- // delete any user data of the child entries of the to-be-removed entry
- std::pair<SvTreeListEntries::const_iterator, SvTreeListEntries::const_iterator> aIters =
- m_pTreeView->GetTreeModel()->GetChildIterators(pDataSourceEntry);
-
- SvTreeListEntries::const_iterator it = aIters.first, itEnd = aIters.second;
-
- for (; it != itEnd; ++it)
+ std::unique_ptr<weld::TreeIter> xChild(rTreeView.make_iterator(xDataSourceEntry.get()));
+ if (rTreeView.iter_children(*xChild))
{
- SvTreeListEntry* pEntry = (*it).get();
- const DBTreeListUserData* pData = static_cast<const DBTreeListUserData*>(pEntry->GetUserData());
- pEntry->SetUserData(nullptr);
- delete pData;
+ do
+ {
+ // delete any user data of the child entries of the to-be-removed entry
+ const DBTreeListUserData* pData = reinterpret_cast<const DBTreeListUserData*>(rTreeView.get_id(*xChild).toUInt64());
+ rTreeView.set_id(*xChild, OUString());
+ delete pData;
+ } while (rTreeView.iter_next_sibling(*xChild));
}
// remove the entry
- DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( pDataSourceEntry->GetUserData() );
- pDataSourceEntry->SetUserData( nullptr );
+ DBTreeListUserData* pData = reinterpret_cast<DBTreeListUserData*>(rTreeView.get_id(*xDataSourceEntry).toUInt64());
+ rTreeView.set_id(*xDataSourceEntry, OUString());
delete pData;
- m_pTreeView->GetTreeModel()->Remove( pDataSourceEntry );
+ rTreeView.remove(*xDataSourceEntry);
}
void SAL_CALL SbaTableQueryBrowser::revokedDatabaseLocation( const DatabaseRegistrationEvent& Event )
diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx
index 1b7afcc7198d..540700041322 100644
--- a/dbaccess/source/ui/control/dbtreelistbox.cxx
+++ b/dbaccess/source/ui/control/dbtreelistbox.cxx
@@ -18,7 +18,6 @@
*/
#include <dbtreelistbox.hxx>
-#include <listviewitems.hxx>
#include <callbacks.hxx>
#include <com/sun/star/ui/XContextMenuInterceptor.hpp>
@@ -37,6 +36,7 @@
#include <vcl/event.hxx>
#include <vcl/help.hxx>
#include <vcl/treelistentry.hxx>
+#include <vcl/menu.hxx>
#include <memory>
@@ -121,6 +121,10 @@ TreeListBox::TreeListBox(std::unique_ptr<weld::TreeView> xTreeView)
m_xTreeView->connect_changed(LINK(this, TreeListBox, SelectHdl));
m_xTreeView->connect_query_tooltip(LINK(this, TreeListBox, QueryTooltipHdl));
m_xTreeView->connect_popup_menu(LINK(this, TreeListBox, CommandHdl));
+
+ m_xHelper.set(new ODataClipboard);
+ rtl::Reference<TransferDataContainer> xHelper(m_xHelper.get());
+ m_xTreeView->enable_drag_source(xHelper, DND_ACTION_COPY);
m_xTreeView->connect_drag_begin(LINK(this, TreeListBox, DragBeginHdl));
m_aTimer.SetTimeout(900);
@@ -939,6 +943,16 @@ void DBTreeListBox::StateChanged( StateChangedType nStateChange )
implStopSelectionTimer();
}
+std::unique_ptr<weld::TreeIter> TreeListBox::GetRootLevelParent(const weld::TreeIter* pEntry) const
+{
+ if (!pEntry)
+ return nullptr;
+ std::unique_ptr<weld::TreeIter> xEntry(m_xTreeView->make_iterator(pEntry));
+ while (m_xTreeView->get_iter_depth(*xEntry))
+ m_xTreeView->iter_parent(*xEntry);
+ return xEntry;
+}
+
} // namespace dbaui
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/listviewitems.cxx b/dbaccess/source/ui/control/listviewitems.cxx
deleted file mode 100644
index 1036ed3b36df..000000000000
--- a/dbaccess/source/ui/control/listviewitems.cxx
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <listviewitems.hxx>
-#include <vcl/viewdataentry.hxx>
-
-namespace dbaui
-{
-
- void OBoldListboxString::InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry, SvViewDataItem* _pViewData)
- {
- SvLBoxString::InitViewData( pView, pEntry, _pViewData );
- if ( !m_bEmphasized )
- return;
- if (!_pViewData)
- _pViewData = pView->GetViewDataItem( pEntry, this );
- pView->Push();
- vcl::Font aFont( pView->GetFont());
- aFont.SetWeight(WEIGHT_BOLD);
- pView->Control::SetFont( aFont );
- _pViewData->mnWidth = pView->GetTextWidth(GetText());
- _pViewData->mnHeight = pView->GetTextHeight();
- pView->Pop();
- }
-
- SvLBoxItemType OBoldListboxString::GetType() const
- {
- return SvLBoxItemType::String;
- }
-
- void OBoldListboxString::Paint(const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext,
- const SvViewDataEntry* pView, const SvTreeListEntry& rEntry)
- {
- if (m_bEmphasized)
- {
- rRenderContext.Push();
- vcl::Font aFont(rRenderContext.GetFont());
- aFont.SetWeight(WEIGHT_BOLD);
- rRenderContext.SetFont(aFont);
- Point aPos(rPos);
- rRenderContext.DrawText(aPos, GetText());
- rRenderContext.Pop();
- }
- else
- {
- SvLBoxString::Paint(rPos, rDev, rRenderContext, pView, rEntry);
- }
- }
-
-} // namespace dbaui
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/control/tabletree.cxx b/dbaccess/source/ui/control/tabletree.cxx
index 99bcfad77a71..a4de1dc9a4f4 100644
--- a/dbaccess/source/ui/control/tabletree.cxx
+++ b/dbaccess/source/ui/control/tabletree.cxx
@@ -29,7 +29,6 @@
#include <com/sun/star/sdbc/SQLException.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
-#include <listviewitems.hxx>
#include <tools/diagnose_ex.h>
#include <osl/diagnose.h>
#include <connectivity/dbmetadata.hxx>
diff --git a/dbaccess/source/ui/inc/TableCopyHelper.hxx b/dbaccess/source/ui/inc/TableCopyHelper.hxx
index 670920028ece..5049c47cd756 100644
--- a/dbaccess/source/ui/inc/TableCopyHelper.hxx
+++ b/dbaccess/source/ui/inc/TableCopyHelper.hxx
@@ -24,6 +24,7 @@
#include <svx/dataaccessdescriptor.hxx>
#include <sot/storage.hxx>
#include <vcl/transfer.hxx>
+#include <vcl/weld.hxx>
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
@@ -75,14 +76,13 @@ namespace dbaui
OUString aUrl;
tools::SvRef<SotStorageStream> aHtmlRtfStorage;
ElementType nType;
- SvTreeListEntry* pDroppedAt;
+ std::unique_ptr<weld::TreeIter> xDroppedAt;
sal_Int8 nAction;
bool bHtml;
bool bError;
DropDescriptor()
: nType(E_TABLE)
- , pDroppedAt(nullptr)
, nAction(DND_ACTION_NONE)
, bHtml(false)
, bError(false)
diff --git a/dbaccess/source/ui/inc/dbexchange.hxx b/dbaccess/source/ui/inc/dbexchange.hxx
index 7ee0f5ca2cf2..13b3e18503bb 100644
--- a/dbaccess/source/ui/inc/dbexchange.hxx
+++ b/dbaccess/source/ui/inc/dbexchange.hxx
@@ -43,6 +43,8 @@ namespace dbaui
::rtl::Reference< ORTFImportExport > m_pRtf;
public:
+ ODataClipboard();
+
ODataClipboard(
const OUString& _rDatasource,
const sal_Int32 _nCommandType,
@@ -67,6 +69,23 @@ namespace dbaui
const css::uno::Reference< css::uno::XComponentContext >& i_rORB
);
+ void Update(
+ const OUString& _rDatasource,
+ const sal_Int32 _nCommandType,
+ const OUString& _rCommand,
+ const css::uno::Reference< css::sdbc::XConnection >& _rxConnection,
+ const css::uno::Reference< css::util::XNumberFormatter >& _rxFormatter,
+ const css::uno::Reference< css::uno::XComponentContext >& _rxORB
+ );
+
+ void Update(
+ const OUString& _rDatasource,
+ const sal_Int32 _nCommandType,
+ const OUString& _rCommand,
+ const css::uno::Reference< css::util::XNumberFormatter >& _rxFormatter,
+ const css::uno::Reference< css::uno::XComponentContext >& _rxORB
+ );
+
// XEventListener
virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
diff --git a/dbaccess/source/ui/inc/dbtreelistbox.hxx b/dbaccess/source/ui/inc/dbtreelistbox.hxx
index 70b891f0ef56..732d20cf68c2 100644
--- a/dbaccess/source/ui/inc/dbtreelistbox.hxx
+++ b/dbaccess/source/ui/inc/dbtreelistbox.hxx
@@ -25,12 +25,15 @@
#include <vcl/InterimItemWindow.hxx>
#include <vcl/treelistbox.hxx>
+#include <vcl/transfer.hxx>
#include <vcl/timer.hxx>
#include <vcl/weld.hxx>
#include <memory>
#include <set>
+#include "dbexchange.hxx"
+
namespace dbaui
{
struct DBTreeEditedEntry
@@ -168,6 +171,7 @@ namespace dbaui
private:
Timer m_aTimer; // is needed for table updates
+ rtl::Reference<ODataClipboard> m_xHelper;
Link<LinkParamNone*,void> m_aSelChangeHdl; // handler to be called (asynchronously) when the selection changes in any way
Link<LinkParamNone*,void> m_aCopyHandler; // called when someone press CTRL+C
@@ -191,12 +195,16 @@ namespace dbaui
const weld::TreeIter* pStart = nullptr,
const IEntryFilter* pFilter = nullptr) const;
+ std::unique_ptr<weld::TreeIter> GetRootLevelParent(const weld::TreeIter* pEntry) const;
+
void setControlActionListener(IControlActionListener* pListener) { m_pActionListener = pListener; }
void setContextMenuProvider(IContextMenuProvider* pContextMenuProvider) { m_pContextMenuProvider = pContextMenuProvider; }
weld::TreeView& GetWidget() { return *m_xTreeView; }
const weld::TreeView& GetWidget() const { return *m_xTreeView; }
+ ODataClipboard& GetDataTransfer() { return *m_xHelper; }
+
sal_Int8 AcceptDrop(const AcceptDropEvent& rEvt);
sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt);
diff --git a/dbaccess/source/ui/inc/imageprovider.hxx b/dbaccess/source/ui/inc/imageprovider.hxx
index 1f267818a592..a85c7df7d50c 100644
--- a/dbaccess/source/ui/inc/imageprovider.hxx
+++ b/dbaccess/source/ui/inc/imageprovider.hxx
@@ -136,7 +136,7 @@ namespace dbaui
@return
the image to be used for folders of this type
*/
- static Image getDatabaseImage();
+ static OUString getDatabaseImage();
};
} // namespace dbaui
diff --git a/dbaccess/source/ui/inc/listviewitems.hxx b/dbaccess/source/ui/inc/listviewitems.hxx
deleted file mode 100644
index 47b231272804..000000000000
--- a/dbaccess/source/ui/inc/listviewitems.hxx
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_DBACCESS_SOURCE_UI_INC_LISTVIEWITEMS_HXX
-#define INCLUDED_DBACCESS_SOURCE_UI_INC_LISTVIEWITEMS_HXX
-
-#include <vcl/svlbitm.hxx>
-
-namespace dbaui
-{
-
- // OBoldListboxString
- class OBoldListboxString : public SvLBoxString
- {
- bool m_bEmphasized;
-
- public:
- OBoldListboxString(const OUString& _rStr)
- :SvLBoxString(_rStr)
- ,m_bEmphasized(false)
- {
- }
-
- virtual SvLBoxItemType GetType() const override;
-
- virtual void Paint(const Point& rPos, SvTreeListBox& rOutDev, vcl::RenderContext& rRenderContext,
- const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) override;
- virtual void InitViewData( SvTreeListBox* pView,SvTreeListEntry* pEntry, SvViewDataItem* _pViewData = nullptr) override;
-
- bool isEmphasized() const { return m_bEmphasized; }
- void emphasize(bool _bEmphasize) { m_bEmphasized = _bEmphasize; }
- };
-
-} // namespace dbaui
-
-#endif // INCLUDED_DBACCESS_SOURCE_UI_INC_LISTVIEWITEMS_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dbaccess/source/ui/inc/unodatbr.hxx b/dbaccess/source/ui/inc/unodatbr.hxx
index 810586a2d70c..f1891596f16d 100644
--- a/dbaccess/source/ui/inc/unodatbr.hxx
+++ b/dbaccess/source/ui/inc/unodatbr.hxx
@@ -42,6 +42,7 @@
class SvTreeListEntry;
class Splitter;
struct SvSortData;
+class ODataClipboard;
namespace com::sun::star::container { class XNameContainer; }
@@ -97,7 +98,7 @@ namespace dbaui
VclPtr<DBTreeView> m_pTreeView; // contains the datasources of the registry
VclPtr<Splitter> m_pSplitter;
- SvTreeListEntry* m_pCurrentlyDisplayed;
+ std::unique_ptr<weld::TreeIter> m_xCurrentlyDisplayed;
ImplSVEvent * m_nAsyncDrop;
bool m_bQueryEscapeProcessing : 1; // the escape processing flag of the query currently loaded (if any)
@@ -174,9 +175,6 @@ namespace dbaui
// css::frame::XFrameActionListener
virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent& aEvent) override;
- //IController
- virtual void notifyHiContrastChanged() override;
-
// XScriptInvocationContext
virtual css::uno::Reference< css::document::XEmbeddedScripts > SAL_CALL getScriptContainer() override;
@@ -242,11 +240,11 @@ namespace dbaui
// methods for handling the 'selection' (painting them bold) of SvLBoxEntries
// returns <TRUE/> if the entry is selected (which means it's part of the selected path)
- static bool isSelected(SvTreeListEntry* _pEntry);
+ bool isSelected(const weld::TreeIter& rEntry) const;
// select the entry (and only the entry, not the whole path)
- void select(SvTreeListEntry* _pEntry, bool _bSelect);
+ void select(weld::TreeIter* pEntry, bool bSelect);
// select the path of the entry (which must be an entry without children)
- void selectPath(SvTreeListEntry* _pEntry, bool _bSelect = true);
+ void selectPath(weld::TreeIter* pEntry, bool bSelect = true);
virtual void loadMenu(const css::uno::Reference< css::frame::XFrame >& _xFrame) override;
@@ -267,9 +265,9 @@ namespace dbaui
<p>The given names and images may be empty, in this case they're filled with the correct
values. This way they may be reused for the next call, which saves some resource manager calls.</p>
*/
- void implAddDatasource(const OUString& _rDbName, Image& _rDbImage,
- OUString& _rQueryName, Image& _rQueryImage,
- OUString& _rTableName, Image& _rTableImage,
+ void implAddDatasource(const OUString& _rDbName, OUString& _rDbImage,
+ OUString& _rQueryName, OUString& _rQueryImage,
+ OUString& _rTableName, OUString& _rTableImage,
const SharedConnection& _rxConnection
);
@@ -290,63 +288,62 @@ namespace dbaui
void unloadAndCleanup( bool _bDisposeConnection = true );
// disposes the connection associated with the given entry (which must represent a data source)
- void disposeConnection( SvTreeListEntry* _pDSEntry );
+ void disposeConnection(weld::TreeIter* xpDSEntry);
/// flushes and disposes the given connection, and de-registers as listener
void impl_releaseConnection( SharedConnection& _rxConnection );
/** close the connection (and collapse the list entries) of the given list entries
*/
- void closeConnection(SvTreeListEntry* _pEntry, bool _bDisposeConnection = true);
+ void closeConnection(weld::TreeIter& rEntry, bool bDisposeConnection = true);
- void populateTree(const css::uno::Reference< css::container::XNameAccess>& _xNameAccess, SvTreeListEntry* _pParent, EntryType _eEntryType);
+ void populateTree(const css::uno::Reference< css::container::XNameAccess>& xNameAccess, const weld::TreeIter& rParent, EntryType eEntryType);
void initializeTreeModel();
/** search in the tree for query- or tablecontainer equal to this interface and return
this container entry
*/
- SvTreeListEntry* getEntryFromContainer(const css::uno::Reference< css::container::XNameAccess>& _rxNameAccess);
+ std::unique_ptr<weld::TreeIter> getEntryFromContainer(const css::uno::Reference<css::container::XNameAccess>& rxNameAccess);
+
// return true when there is connection available
- bool ensureConnection(SvTreeListEntry* _pDSEntry, void * pDSData, SharedConnection& _rConnection );
- bool ensureConnection(SvTreeListEntry* _pAnyEntry, SharedConnection& _rConnection );
+ bool ensureConnection(const weld::TreeIter* pDSEntry, void * pDSData, SharedConnection& rConnection);
+ bool ensureConnection(const weld::TreeIter* pAnyEntry, SharedConnection& rConnection);
- bool getExistentConnectionFor( SvTreeListEntry* _pDSEntry, SharedConnection& _rConnection );
+ bool getExistentConnectionFor(const weld::TreeIter* pDSEntry, SharedConnection& rConnection);
/** returns an image provider which works with the connection belonging to the given entry
*/
- std::unique_ptr< ImageProvider >
- getImageProviderFor( SvTreeListEntry* _pAnyEntry );
+ std::unique_ptr<ImageProvider> getImageProviderFor(const weld::TreeIter* pAnyEntry);
- void implAdministrate( SvTreeListEntry* _pApplyTo );
+ void implAdministrate(weld::TreeIter& rApplyTo);
- TransferableHelper*
- implCopyObject( SvTreeListEntry* _pApplyTo, sal_Int32 _nCommandType );
+ bool implCopyObject(ODataClipboard& rExchange, const weld::TreeIter& rApplyTo, sal_Int32 nCommandType);
- EntryType getEntryType( const SvTreeListEntry* _pEntry ) const;
- EntryType getChildType( SvTreeListEntry const * _pEntry ) const;
+ EntryType getEntryType(const weld::TreeIter& rEntry) const;
+ EntryType getChildType(const weld::TreeIter& rEntry) const;
static bool isObject( EntryType _eType ) { return ( etTableOrView== _eType ) || ( etQuery == _eType ); }
static bool isContainer( EntryType _eType ) { return (etTableContainer == _eType) || (etQueryContainer == _eType); }
- bool isContainer( const SvTreeListEntry* _pEntry ) const { return isContainer( getEntryType( _pEntry ) ); }
+ bool isContainer(const weld::TreeIter& rEntry) const { return isContainer(getEntryType(rEntry)); }
// ensure that the xObject for the given entry is set on the user data
- bool ensureEntryObject( SvTreeListEntry* _pEntry );
+ bool ensureEntryObject(const weld::TreeIter& rEntry);
// get the display text of the entry given
- OUString GetEntryText( SvTreeListEntry* _pEntry ) const;
+ OUString GetEntryText(const weld::TreeIter& rEntry) const;
// is called when a table or a query was selected
DECL_LINK( OnSelectionChange, LinkParamNone*, void );
- DECL_LINK( OnExpandEntry, SvTreeListEntry*, bool );
+ DECL_LINK( OnExpandEntry, const weld::TreeIter&, bool );
DECL_LINK( OnCopyEntry, LinkParamNone*, void );
- DECL_LINK( OnTreeEntryCompare, const SvSortData&, sal_Int32 );
+ int OnTreeEntryCompare(const weld::TreeIter& rLHS, const weld::TreeIter& rRHS);
DECL_LINK( OnAsyncDrop, void*, void );
void implRemoveStatusListeners();
bool implSelect(const svx::ODataAccessDescriptor& _rDescriptor, bool _bSelectDirect = false);
- bool implSelect( SvTreeListEntry* _pEntry );
+ bool implSelect(weld::TreeIter* pEntry);
/// selects the entry given and loads the grid control with the object's data
bool implSelect(
@@ -358,13 +355,13 @@ namespace dbaui
bool _bSelectDirect
);
- SvTreeListEntry* implGetConnectionEntry(SvTreeListEntry* _pEntry) const;
+ std::unique_ptr<weld::TreeIter> implGetConnectionEntry(weld::TreeIter& rEntry) const;
/// inserts an entry into the tree
- SvTreeListEntry* implAppendEntry(
- SvTreeListEntry* _pParent,
- const OUString& _rName,
- void* _pUserData,
- EntryType _eEntryType
+ std::unique_ptr<weld::TreeIter> implAppendEntry(
+ const weld::TreeIter* pParent,
+ const OUString& rName,
+ void* pUserData,
+ EntryType eEntryType
);
/// loads the grid control with the data object specified (which may be a table, a query or a command)
@@ -372,37 +369,37 @@ namespace dbaui
const sal_Int32 _nCommandType, const bool _bEscapeProcessing, const SharedConnection& _rxConnection );
/** retrieves the tree entry for the object described by <arg>_rDescriptor</arg>
- @param _rDescriptor
+ @param rDescriptor
the object descriptor
- @param _ppDataSourceEntry
+ @param ppDataSourceEntry
If not <NULL/>, the data source tree entry will be returned here
- @param _ppContainerEntry
+ @param ppContainerEntry
If not <NULL/>, the object container tree entry will be returned here
*/
- SvTreeListEntry* getObjectEntry(const svx::ODataAccessDescriptor& _rDescriptor,
- SvTreeListEntry** _ppDataSourceEntry, SvTreeListEntry** _ppContainerEntry
+ std::unique_ptr<weld::TreeIter> getObjectEntry(const svx::ODataAccessDescriptor& rDescriptor,
+ std::unique_ptr<weld::TreeIter>* ppDataSourceEntry, std::unique_ptr<weld::TreeIter>* ppContainerEntry
);
/** retrieves the tree entry for the object described by data source name, command and command type
- @param _rDataSource
+ @param rDataSource
the data source name
- @param _rCommand
+ @param rCommand
the command
- @param _nCommandType
+ @param nCommandType
the command type
- @param _rDescriptor
+ @param rDescriptor
the object descriptor
- @param _ppDataSourceEntry
+ @param ppDataSourceEntry
If not <NULL/>, the data source tree entry will be returned here
- @param _ppContainerEntry
+ @param ppContainerEntry
If not <NULL/>, the object container tree entry will be returned here
- @param _bExpandAncestors
+ @param bExpandAncestors
If <TRUE/>, all ancestor on the way to the entry will be expanded
*/
- SvTreeListEntry* getObjectEntry(
- const OUString& _rDataSource, const OUString& _rCommand, sal_Int32 _nCommandType,
- SvTreeListEntry** _ppDataSourceEntry, SvTreeListEntry** _ppContainerEntry,
+ std::unique_ptr<weld::TreeIter> getObjectEntry(
+ const OUString& rDataSource, const OUString& rCommand, sal_Int32 nCommandType,
+ std::unique_ptr<weld::TreeIter>* ppDataSourceEntry, std::unique_ptr<weld::TreeIter>* ppContainerEntry,
bool _bExpandAncestors = true,
- const SharedConnection& _rxConnection = SharedConnection()
+ const SharedConnection& rxConnection = SharedConnection()
);
/// checks if m_aDocumentDataSource describes a known object
@@ -414,32 +411,32 @@ namespace dbaui
void transferChangedControlProperty(const OUString& _rProperty, const css::uno::Any& _rNewValue);
// checks whether the given tree entry denotes a data source
- bool impl_isDataSourceEntry( SvTreeListEntry* _pEntry ) const;
+ bool impl_isDataSourceEntry(const weld::TreeIter* pEntry) const;
/// retrieves the data source URL/name for the given entry representing a data source
- OUString getDataSourceAccessor( SvTreeListEntry* _pDataSourceEntry ) const;
+ OUString getDataSourceAccessor(const weld::TreeIter& rDataSourceEntry) const;
/** get the signature (command/escape processing) of the query the form is based on
<p>If the for is not based on a query or not even loaded, nothing happens and <FALSE/> is returned.</p>
*/
bool implGetQuerySignature( OUString& _rCommand, bool& _bEscapeProcessing );
- bool isEntryCopyAllowed(SvTreeListEntry const * _pEntry) const;
+ bool isEntryCopyAllowed(const weld::TreeIter& rEntry) const;
- void copyEntry(SvTreeListEntry* _pEntry);
+ void copyEntry(weld::TreeIter& rEntry);
// remove all grid columns and dispose them
static void clearGridColumns(const css::uno::Reference< css::container::XNameContainer >& _xColContainer);
/** checks if the currently displayed entry changed
- @param _sName
+ @param rName
Name of the changed entry
- @param _pContainer
+ @param rContainer
The container of the displayed entry
@return
<TRUE/> if it is the currently displayed otherwise <FALSE/>
*/
- bool isCurrentlyDisplayedChanged(const OUString& _sName, SvTreeListEntry const * _pContainer);
+ bool isCurrentlyDisplayedChanged(const OUString& rName, const weld::TreeIter& rContainer);
/** called whenever the content of the browser is used for preview, as the very last action
of the load process
diff --git a/dbaccess/source/ui/misc/imageprovider.cxx b/dbaccess/source/ui/misc/imageprovider.cxx
index 8cd3b397e12c..f3d9a7372092 100644
--- a/dbaccess/source/ui/misc/imageprovider.cxx
+++ b/dbaccess/source/ui/misc/imageprovider.cxx
@@ -256,9 +256,9 @@ namespace dbaui
return sImageResourceID;
}
- Image ImageProvider::getDatabaseImage()
+ OUString ImageProvider::getDatabaseImage()
{
- return Image(StockImage::Yes, DATABASE_TREE_ICON);
+ return DATABASE_TREE_ICON;
}
} // namespace dbaui