Tag: cws_dev300_dba30d User: fs Date: 2008-06-01 20:55:26+0000 Modified: dba/dbaccess/source/ui/browser/unodatbr.cxx
Log: #i80943# +IContextMenuProvider File Changes: Directory: /dba/dbaccess/source/ui/browser/ =========================================== File [changed]: unodatbr.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/browser/unodatbr.cxx?r1=1.200.8.2&r2=1.200.8.3 Delta lines: +149 -119 ----------------------- --- unodatbr.cxx 2008-05-29 11:30:59+0000 1.200.8.2 +++ unodatbr.cxx 2008-06-01 20:55:23+0000 1.200.8.3 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: unodatbr.cxx,v $ - * $Revision: 1.200.8.2 $ + * $Revision: 1.200.8.3 $ * * This file is part of OpenOffice.org. * @@ -98,6 +98,7 @@ #include <com/sun/star/sdb/XDocumentDataSource.hpp> #include <com/sun/star/document/MacroExecMode.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/ui/XContextMenuInterceptor.hpp> /** === end UNO includes === **/ #include <comphelper/extract.hxx> @@ -151,13 +152,11 @@ using namespace ::com::sun::star::view; using namespace ::com::sun::star::datatransfer; using namespace ::com::sun::star::document; +using namespace ::com::sun::star::ui; using namespace ::dbtools; using namespace ::comphelper; using namespace ::svx; -using ::com::sun::star::frame::XLayoutManager; // obsolete of interface is moved outside drafts -using ::com::sun::star::ui::XUIElement; // dito - // ......................................................................... namespace dbaui { @@ -220,6 +219,7 @@ SbaTableQueryBrowser::SbaTableQueryBrowser(const Reference< XMultiServiceFactory >& _rM) :SbaXDataBrowserController(_rM) ,m_aSelectionListeners(m_aMutex) + ,m_aContextMenuInterceptors(m_aMutex) ,m_aTableCopyHelper(this) ,m_pTreeView(NULL) ,m_pSplitter(NULL) @@ -313,6 +313,7 @@ // kiss our listeners goodbye EventObject aEvt(*this); m_aSelectionListeners.disposeAndClear(aEvt); + m_aContextMenuInterceptors.disposeAndClear(aEvt); // reset the content's tree view: it holds a reference to our model which is to be deleted immediately, // and it will live longer than we do. @@ -322,7 +323,7 @@ clearTreeModel(); // clear the tree model { - ::std::auto_ptr<DBTreeListModel> aTemp(m_pTreeModel); + ::std::auto_ptr<SvLBoxTreeList> aTemp(m_pTreeModel); m_pTreeModel = NULL; } @@ -381,8 +382,8 @@ m_pTreeView->setCopyHandler(LINK(this, SbaTableQueryBrowser, OnCopyEntry)); - m_pTreeView->getListBox()->setContextMenuProvider( this ); - m_pTreeView->getListBox()->setControlActionListener( this ); + m_pTreeView->getListBox().setContextMenuProvider( this ); + m_pTreeView->getListBox().setControlActionListener( this ); m_pTreeView->SetHelpId(HID_CTL_TREEVIEW); // a default pos for the splitter, so that the listbox is about 80 (logical) pixels wide @@ -392,7 +393,7 @@ getBrowserView()->setTreeView(m_pTreeView); // fill view with data - m_pTreeModel = new DBTreeListModel; + m_pTreeModel = new SvLBoxTreeList; m_pTreeModel->SetSortMode(SortAscending); m_pTreeModel->SetCompareHdl(LINK(this, SbaTableQueryBrowser, OnTreeEntryCompare)); m_pTreeView->setModel(m_pTreeModel); @@ -423,7 +424,7 @@ Sequence< ::rtl::OUString> aProperties(3); Sequence< Any> aValues(3); - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData()); OSL_ENSURE( pData, "SbaTableQueryBrowser::InitializeForm: No user data set at the currently displayed entry!" ); OSL_ENSURE( pData->xObjectProperties.is(), "SbaTableQueryBrowser::InitializeForm: No table available!" ); @@ -504,7 +505,7 @@ Sequence< ::rtl::OUString> aProperties(6 + ( m_bPreview ? 5 : 0 )); Sequence< Any> aValues(7 + ( m_bPreview ? 5 : 0 )); - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData()); OSL_ENSURE( pData->xObjectProperties.is(), "SbaTableQueryBrowser::InitializeGridModel: No table available!" ); ::rtl::OUString* pStringIter = aProperties.getArray(); @@ -693,7 +694,7 @@ Reference<XPropertySet> xRet; if(_pCurrentlyDisplayed) { - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pCurrentlyDisplayed->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pCurrentlyDisplayed->GetUserData()); Reference<XColumnsSupplier> xColumnsSup(pData->xObjectProperties,UNO_QUERY); Reference<XNameAccess> xNames = xColumnsSup->getColumns(); ::rtl::OUString aName; @@ -709,7 +710,7 @@ { if(m_pCurrentlyDisplayed) { - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData()); Reference< XPropertySet > xObjectProps(pData->xObjectProperties, UNO_QUERY); OSL_ENSURE(xObjectProps.is(),"SbaTableQueryBrowser::transferChangedControlProperty: no table/query object!"); if (xObjectProps.is()) @@ -794,7 +795,7 @@ { if(m_pCurrentlyDisplayed) { - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(m_pCurrentlyDisplayed->GetUserData()); OSL_ENSURE( pData->xObjectProperties.is(), "No table available!" ); sal_Bool bDefault = !evt.NewValue.hasValue(); @@ -984,7 +985,7 @@ bool FilterByEntryDataId::includeEntry( SvLBoxEntry* _pEntry ) const { - DBTreeListModel::DBTreeListUserData* pData = static_cast< DBTreeListModel::DBTreeListUserData* >( _pEntry->GetUserData() ); + DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( _pEntry->GetUserData() ); return ( !pData || ( pData->sAccessor == sId ) ); } } @@ -994,7 +995,7 @@ { DBG_ASSERT( _pDataSourceEntry, "SbaTableQueryBrowser::getDataSourceAcessor: invalid entry!" ); - DBTreeListModel::DBTreeListUserData* pData = static_cast< DBTreeListModel::DBTreeListUserData* >( _pDataSourceEntry->GetUserData() ); + DBTreeListUserData* pData = static_cast< DBTreeListUserData* >( _pDataSourceEntry->GetUserData() ); DBG_ASSERT( pData, "SbaTableQueryBrowser::getDataSourceAcessor: invalid entry data!" ); DBG_ASSERT( pData->eType == etDatasource, "SbaTableQueryBrowser::getDataSourceAcessor: entry does not denote a data source!" ); return pData->sAccessor.Len() ? pData->sAccessor : GetEntryText( _pDataSourceEntry ); @@ -1011,7 +1012,7 @@ *_ppContainerEntry = NULL; SvLBoxEntry* pObject = NULL; - if (m_pTreeView && m_pTreeView->getListBox()) + if ( m_pTreeView ) { // look for the data source entry String sDisplayName, sDataSourceId; @@ -1020,7 +1021,7 @@ // #i33699# - 2004-09-24 - [EMAIL PROTECTED] FilterByEntryDataId aFilter( sDataSourceId ); - SvLBoxEntry* pDataSource = m_pTreeView->getListBox()->GetEntryPosByName( sDisplayName, NULL, &aFilter ); + SvLBoxEntry* pDataSource = m_pTreeView->getListBox().GetEntryPosByName( sDisplayName, NULL, &aFilter ); if ( !pDataSource ) // check if the data source name is a file location { if ( bIsDataSourceURL ) @@ -1030,7 +1031,7 @@ Image a, b, c; // not interested in reusing them String e, f; implAddDatasource( _rDataSource, a, e, b, f, c, _rxConnection ); - pDataSource = m_pTreeView->getListBox()->GetEntryPosByName( sDisplayName, NULL, &aFilter ); + pDataSource = m_pTreeView->getListBox().GetEntryPosByName( sDisplayName, NULL, &aFilter ); DBG_ASSERT( pDataSource, "SbaTableQueryBrowser::getObjectEntry: hmm - did not find it again!" ); } } @@ -1042,18 +1043,18 @@ { // expand if required so if (_bExpandAncestors) - m_pTreeView->getListBox()->Expand(pDataSource); + m_pTreeView->getListBox().Expand(pDataSource); // look for the object container SvLBoxEntry* pCommandType = NULL; switch (_nCommandType) { case CommandType::TABLE: - pCommandType = m_pTreeView->getListBox()->GetModel()->GetEntry(pDataSource, CONTAINER_TABLES); + pCommandType = m_pTreeView->getListBox().GetModel()->GetEntry(pDataSource, CONTAINER_TABLES); break; case CommandType::QUERY: - pCommandType = m_pTreeView->getListBox()->GetModel()->GetEntry(pDataSource, CONTAINER_QUERIES); + pCommandType = m_pTreeView->getListBox().GetModel()->GetEntry(pDataSource, CONTAINER_QUERIES); break; } @@ -1064,10 +1065,10 @@ { // expand if required so if (_bExpandAncestors) - m_pTreeView->getListBox()->Expand(pCommandType); + m_pTreeView->getListBox().Expand(pCommandType); // look for the object - pObject = m_pTreeView->getListBox()->GetEntryPosByName(_rCommand, pCommandType); + pObject = m_pTreeView->getListBox().GetEntryPosByName(_rCommand, pCommandType); } } } @@ -1214,14 +1215,14 @@ else { Reference<XConnection> xCon(_rSource.Source, UNO_QUERY); - if ( xCon.is() && m_pTreeView && m_pTreeView->getListBox() ) + if ( xCon.is() && m_pTreeView ) { // 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 - SvLBoxEntry* pDSLoop = m_pTreeView->getListBox()->FirstChild(NULL); + SvLBoxEntry* pDSLoop = m_pTreeView->getListBox().FirstChild(NULL); while (pDSLoop) { - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pDSLoop->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pDSLoop->GetUserData()); if ( pData && pData->xConnection == xCon ) { // we set the conenction to null to avoid a second disposing of the connection @@ -1230,7 +1231,7 @@ break; } - pDSLoop = m_pTreeView->getListBox()->NextSibling(pDSLoop); + pDSLoop = m_pTreeView->getListBox().NextSibling(pDSLoop); } } else @@ -1537,15 +1538,15 @@ case ID_TREE_EDIT_DATABASE: case ID_BROWSER_COPY: { - SvLBoxEntry* pCurrentEntry( m_pTreeView->getListBox()->GetCurEntry() ); + SvLBoxEntry* pCurrentEntry( m_pTreeView->getListBox().GetCurEntry() ); EntryType eType = getEntryType( pCurrentEntry ); if ( eType == etUnknown ) return aReturn; - SvLBoxEntry* pDataSourceEntry = m_pTreeView->getListBox()->GetRootLevelParent( pCurrentEntry ); - DBTreeListModel::DBTreeListUserData* pDSData + SvLBoxEntry* pDataSourceEntry = m_pTreeView->getListBox().GetRootLevelParent( pCurrentEntry ); + DBTreeListUserData* pDSData = pDataSourceEntry - ? static_cast< DBTreeListModel::DBTreeListUserData* >( pDataSourceEntry->GetUserData() ) + ? static_cast< DBTreeListUserData* >( pDataSourceEntry->GetUserData() ) : NULL; if ( nId == ID_TREE_CLOSE_CONN ) @@ -1702,13 +1703,17 @@ { switch (nId) { + default: + SbaXDataBrowserController::Execute(nId,aArgs); + break; + case ID_TREE_EDIT_DATABASE: - implAdministrate( m_pTreeView->getListBox()->GetCurEntry() ); + implAdministrate( m_pTreeView->getListBox().GetCurEntry() ); break; case ID_TREE_CLOSE_CONN: openHelpAgent( HID_DSBROWSER_DISCONNECTING ); - closeConnection( m_pTreeView->getListBox()->GetRootLevelParent( m_pTreeView->getListBox()->GetCurEntry() ) ); + closeConnection( m_pTreeView->getListBox().GetRootLevelParent( m_pTreeView->getListBox().GetCurEntry() ) ); break; case ID_TREE_ADMINISTRATE: @@ -1867,7 +1872,7 @@ case ID_BROWSER_COPY: if(m_pTreeView->HasChildPathFocus()) { - copyEntry(m_pTreeView->getListBox()->GetCurEntry()); + copyEntry(m_pTreeView->getListBox().GetCurEntry()); } else if (getBrowserView() && getBrowserView()->getVclControl() && !getBrowserView()->getVclControl()->IsEditing()) { @@ -1877,9 +1882,6 @@ else SbaXDataBrowserController::Execute(nId,aArgs); break; - default: - SbaXDataBrowserController::Execute(nId,aArgs); - break; } } // ------------------------------------------------------------------------- @@ -1909,8 +1911,8 @@ String sDSDisplayName, sDataSourceId; getDataSourceDisplayName_isURL( _rDbName, sDSDisplayName, sDataSourceId ); - SvLBoxEntry* pDatasourceEntry = m_pTreeView->getListBox()->InsertEntry( sDSDisplayName, _rDbImage, _rDbImage, NULL, sal_False ); - DBTreeListModel::DBTreeListUserData* pDSData = new DBTreeListModel::DBTreeListUserData; + SvLBoxEntry* pDatasourceEntry = m_pTreeView->getListBox().InsertEntry( sDSDisplayName, _rDbImage, _rDbImage, NULL, sal_False ); + DBTreeListUserData* pDSData = new DBTreeListUserData; pDSData->eType = etDatasource; pDSData->sAccessor = sDataSourceId; pDSData->xConnection = _rxConnection; @@ -1918,16 +1920,16 @@ // the child for the queries container { - SvLBoxEntry* pQueries = m_pTreeView->getListBox()->InsertEntry(_rQueryName, _rQueryImage, _rQueryImage, pDatasourceEntry, sal_True); - DBTreeListModel::DBTreeListUserData* pQueriesData = new DBTreeListModel::DBTreeListUserData; + SvLBoxEntry* pQueries = m_pTreeView->getListBox().InsertEntry(_rQueryName, _rQueryImage, _rQueryImage, pDatasourceEntry, sal_True); + DBTreeListUserData* pQueriesData = new DBTreeListUserData; pQueriesData->eType = etQueryContainer; pQueries->SetUserData(pQueriesData); } // the child for the tables container { - SvLBoxEntry* pTables = m_pTreeView->getListBox()->InsertEntry(_rTableName, _rTableImage, _rTableImage, pDatasourceEntry, sal_True); - DBTreeListModel::DBTreeListUserData* pTablesData = new DBTreeListModel::DBTreeListUserData; + SvLBoxEntry* pTables = m_pTreeView->getListBox().InsertEntry(_rTableName, _rTableImage, _rTableImage, pDatasourceEntry, sal_True); + DBTreeListUserData* pTablesData = new DBTreeListUserData; pTablesData->eType = etTableContainer; pTables->SetUserData(pTablesData); } @@ -1954,7 +1956,7 @@ SvLBoxEntry* _pParent, EntryType _eEntryType) { - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pParent->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pParent->GetUserData()); if(pData) // don't ask if the nameaccess is already set see OnExpandEntry views and tables pData->xContainer = _xNameAccess; @@ -1965,9 +1967,9 @@ const ::rtl::OUString* pEnd = pIter + aNames.getLength(); for (; pIter != pEnd; ++pIter) { - if(!m_pTreeView->getListBox()->GetEntryPosByName(*pIter,_pParent)) + if(!m_pTreeView->getListBox().GetEntryPosByName(*pIter,_pParent)) { - DBTreeListModel::DBTreeListUserData* pEntryData = new DBTreeListModel::DBTreeListUserData; + DBTreeListUserData* pEntryData = new DBTreeListUserData; pEntryData->eType = _eEntryType; implAppendEntry( _pParent, *pIter, pEntryData, _eEntryType ); } @@ -1989,12 +1991,12 @@ Image aImage, aImageHC; pImageProvider->getImages( _rName, getDatabaseObjectType( _eEntryType ), aImage, aImageHC ); - SvLBoxEntry* pNewEntry = m_pTreeView->getListBox()->InsertEntry( _rName, _pParent, sal_False, LIST_APPEND, _pUserData ); + SvLBoxEntry* pNewEntry = m_pTreeView->getListBox().InsertEntry( _rName, _pParent, sal_False, LIST_APPEND, _pUserData ); - m_pTreeView->getListBox()->SetExpandedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL ); - m_pTreeView->getListBox()->SetCollapsedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL ); - m_pTreeView->getListBox()->SetExpandedEntryBmp( pNewEntry, aImageHC, BMP_COLOR_HIGHCONTRAST ); - m_pTreeView->getListBox()->SetCollapsedEntryBmp( pNewEntry, aImageHC, BMP_COLOR_HIGHCONTRAST ); + m_pTreeView->getListBox().SetExpandedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL ); + m_pTreeView->getListBox().SetCollapsedEntryBmp( pNewEntry, aImage, BMP_COLOR_NORMAL ); + m_pTreeView->getListBox().SetExpandedEntryBmp( pNewEntry, aImageHC, BMP_COLOR_HIGHCONTRAST ); + m_pTreeView->getListBox().SetCollapsedEntryBmp( pNewEntry, aImageHC, BMP_COLOR_HIGHCONTRAST ); } //------------------------------------------------------------------------------ @@ -2006,10 +2008,10 @@ ::osl::MutexGuard aGuard(m_aEntryMutex); - SvLBoxEntry* pFirstParent = m_pTreeView->getListBox()->GetRootLevelParent(_pParent); + SvLBoxEntry* pFirstParent = m_pTreeView->getListBox().GetRootLevelParent(_pParent); OSL_ENSURE(pFirstParent,"SbaTableQueryBrowser::OnExpandEntry: No rootlevelparent!"); - DBTreeListModel::DBTreeListUserData* pData = static_cast< DBTreeListModel::DBTreeListUserData* >(_pParent->GetUserData()); + DBTreeListUserData* pData = static_cast< DBTreeListUserData* >(_pParent->GetUserData()); OSL_ENSURE(pData,"SbaTableQueryBrowser::OnExpandEntry: No user data!"); #if OSL_DEBUG_LEVEL > 0 SvLBoxString* pString = static_cast<SvLBoxString*>(pFirstParent->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING)); @@ -2093,7 +2095,7 @@ { // we have to expand the queries or bookmarks if (ensureEntryObject(_pParent)) { - DBTreeListModel::DBTreeListUserData* pParentData = static_cast< DBTreeListModel::DBTreeListUserData* >( _pParent->GetUserData() ); + DBTreeListUserData* pParentData = static_cast< DBTreeListUserData* >( _pParent->GetUserData() ); Reference< XNameAccess > xCollection( pParentData->xContainer, UNO_QUERY ); populateTree( xCollection, _pParent, etQuery ); } @@ -2111,10 +2113,10 @@ EntryType eType = getEntryType( _pEntry ); // the user data of the entry - DBTreeListModel::DBTreeListUserData* pEntryData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pEntry->GetUserData()); + DBTreeListUserData* pEntryData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData()); OSL_ENSURE(pEntryData,"ensureEntryObject: user data should already be set!"); - SvLBoxEntry* pDataSourceEntry = m_pTreeView->getListBox()->GetRootLevelParent(_pEntry); + SvLBoxEntry* pDataSourceEntry = m_pTreeView->getListBox().GetRootLevelParent(_pEntry); sal_Bool bSuccess = sal_False; switch (eType) @@ -2274,7 +2276,7 @@ OnSelectEntry(pCommand); } else - m_pTreeView->getListBox()->Select(pCommand); + m_pTreeView->getListBox().Select(pCommand); } else if (!pCommandType) { @@ -2297,7 +2299,7 @@ { ::osl::MutexGuard aGuard(m_aEntryMutex); - DBTreeListModel::DBTreeListUserData* pEntryData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pEntry->GetUserData()); + DBTreeListUserData* pEntryData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData()); switch (pEntryData->eType) { case etTableOrView: @@ -2313,11 +2315,11 @@ // get the entry for the tables or queries SvLBoxEntry* pContainer = m_pTreeModel->GetParent(_pEntry); - DBTreeListModel::DBTreeListUserData* pContainerData = static_cast<DBTreeListModel::DBTreeListUserData*>(pContainer->GetUserData()); + DBTreeListUserData* pContainerData = static_cast<DBTreeListUserData*>(pContainer->GetUserData()); // get the entry for the datasource SvLBoxEntry* pConnection = m_pTreeModel->GetParent(pContainer); - DBTreeListModel::DBTreeListUserData* pConData = static_cast<DBTreeListModel::DBTreeListUserData*>(pConnection->GetUserData()); + DBTreeListUserData* pConData = static_cast<DBTreeListUserData*>(pConnection->GetUserData()); // reinitialize the rowset // but first check if it is necessary @@ -2401,7 +2403,7 @@ if(xNameAccess.is() && xNameAccess->hasByName(aName)) { - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(_pEntry->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(_pEntry->GetUserData()); if ( !pData->xObjectProperties.is() ) { Reference<XInterface> xObject; @@ -2487,27 +2489,24 @@ // ----------------------------------------------------------------------------- SvLBoxEntry* SbaTableQueryBrowser::getEntryFromContainer(const Reference<XNameAccess>& _rxNameAccess) { - DBTreeListBox* pListBox = m_pTreeView->getListBox(); + DBTreeListBox& rListBox = m_pTreeView->getListBox(); SvLBoxEntry* pContainer = NULL; - if ( pListBox ) - { - SvLBoxEntry* pDSLoop = pListBox->FirstChild(NULL); + SvLBoxEntry* pDSLoop = rListBox.FirstChild(NULL); while (pDSLoop) { - pContainer = pListBox->GetEntry(pDSLoop, CONTAINER_QUERIES); - DBTreeListModel::DBTreeListUserData* pQueriesData = static_cast<DBTreeListModel::DBTreeListUserData*>(pContainer->GetUserData()); + pContainer = rListBox.GetEntry(pDSLoop, CONTAINER_QUERIES); + DBTreeListUserData* pQueriesData = static_cast<DBTreeListUserData*>(pContainer->GetUserData()); if ( pQueriesData && pQueriesData->xContainer == _rxNameAccess ) break; - pContainer = pListBox->GetEntry(pDSLoop, CONTAINER_TABLES); - DBTreeListModel::DBTreeListUserData* pTablesData = static_cast<DBTreeListModel::DBTreeListUserData*>(pContainer->GetUserData()); + pContainer = rListBox.GetEntry(pDSLoop, CONTAINER_TABLES); + DBTreeListUserData* pTablesData = static_cast<DBTreeListUserData*>(pContainer->GetUserData()); if ( pTablesData && pTablesData->xContainer == _rxNameAccess ) break; - pDSLoop = pListBox->NextSibling(pDSLoop); + pDSLoop = rListBox.NextSibling(pDSLoop); pContainer = NULL; } - } return pContainer; } @@ -2524,10 +2523,10 @@ if(pEntry) // found one { // insert the new entry into the tree - DBTreeListModel::DBTreeListUserData* pContainerData = static_cast<DBTreeListModel::DBTreeListUserData*>(pEntry->GetUserData()); + DBTreeListUserData* pContainerData = static_cast<DBTreeListUserData*>(pEntry->GetUserData()); OSL_ENSURE(pContainerData, "elementInserted: There must be user data for this type!"); - DBTreeListModel::DBTreeListUserData* pNewData = new DBTreeListModel::DBTreeListUserData; + DBTreeListUserData* pNewData = new DBTreeListUserData; sal_Bool bIsTable = etTableContainer == pContainerData->eType; if ( bIsTable ) { @@ -2536,7 +2535,7 @@ } else { - if ((sal_Int32)m_pTreeView->getListBox()->GetChildCount(pEntry) < ( xNames->getElementNames().getLength() - 1 ) ) + if ((sal_Int32)m_pTreeView->getListBox().GetChildCount(pEntry) < ( 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 @@ -2565,8 +2564,8 @@ { return m_pCurrentlyDisplayed && getEntryType(m_pCurrentlyDisplayed) == getChildType(_pContainer) - && m_pTreeView->getListBox()->GetParent(m_pCurrentlyDisplayed) == _pContainer - && m_pTreeView->getListBox()->GetEntryText(m_pCurrentlyDisplayed) == _sName; + && m_pTreeView->getListBox().GetParent(m_pCurrentlyDisplayed) == _pContainer + && m_pTreeView->getListBox().GetEntryText(m_pCurrentlyDisplayed) == _sName; } // ------------------------------------------------------------------------- void SAL_CALL SbaTableQueryBrowser::elementRemoved( const ContainerEvent& _rEvent ) throw(RuntimeException) @@ -2592,7 +2591,7 @@ // unload unloadAndCleanup( sal_False ); // don't dispose the connection - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pTemp->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pTemp->GetUserData()); pTemp->SetUserData(NULL); delete pData; // the data could be null because we have a table which isn't correct @@ -2604,9 +2603,9 @@ SvLBoxEntry* pChild = m_pTreeModel->FirstChild(pContainer); while(pChild) { - if (m_pTreeView->getListBox()->GetEntryText(pChild) == aName) + if (m_pTreeView->getListBox().GetEntryText(pChild) == aName) { - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pChild->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pChild->GetUserData()); pChild->SetUserData(NULL); delete pData; m_pTreeModel->Remove(pChild); @@ -2628,26 +2627,26 @@ String sNewDatasource = sNewDS; // get the top-level representing the removed data source - SvLBoxEntry* pDSLoop = m_pTreeView->getListBox()->FirstChild(NULL); + SvLBoxEntry* pDSLoop = m_pTreeView->getListBox().FirstChild(NULL); while (pDSLoop) { - if (m_pTreeView->getListBox()->GetEntryText(pDSLoop) == sNewDatasource) + if (m_pTreeView->getListBox().GetEntryText(pDSLoop) == sNewDatasource) break; - pDSLoop = m_pTreeView->getListBox()->NextSibling(pDSLoop); + pDSLoop = m_pTreeView->getListBox().NextSibling(pDSLoop); } if (pDSLoop) { if (isSelected(pDSLoop)) { // a table or query belonging to the deleted data source is currently beeing displayed. - OSL_ENSURE(m_pTreeView->getListBox()->GetRootLevelParent(m_pCurrentlyDisplayed) == pDSLoop, "SbaTableQueryBrowser::elementRemoved: inconsistence (1)!"); + OSL_ENSURE(m_pTreeView->getListBox().GetRootLevelParent(m_pCurrentlyDisplayed) == pDSLoop, "SbaTableQueryBrowser::elementRemoved: inconsistence (1)!"); unloadAndCleanup( sal_True ); } else OSL_ENSURE( (NULL == m_pCurrentlyDisplayed) - || (m_pTreeView->getListBox()->GetRootLevelParent(m_pCurrentlyDisplayed) != pDSLoop), "SbaTableQueryBrowser::elementRemoved: inconsistence (2)!"); + || (m_pTreeView->getListBox().GetRootLevelParent(m_pCurrentlyDisplayed) != pDSLoop), "SbaTableQueryBrowser::elementRemoved: inconsistence (2)!"); // look for user data to delete SvTreeEntryList* pList = m_pTreeModel->GetChildList(pDSLoop); @@ -2656,14 +2655,14 @@ SvLBoxEntry* pEntryLoop = static_cast<SvLBoxEntry*>(pList->First()); while (pEntryLoop) { - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pEntryLoop->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pEntryLoop->GetUserData()); pEntryLoop->SetUserData(NULL); delete pData; pEntryLoop = static_cast<SvLBoxEntry*>(pList->Next()); } } // remove the entry. This should remove all children, too. - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pDSLoop->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pDSLoop->GetUserData()); pDSLoop->SetUserData(NULL); delete pData; m_pTreeModel->Remove(pDSLoop); @@ -2697,7 +2696,7 @@ SvLBoxEntry* pTemp = m_pCurrentlyDisplayed; unloadAndCleanup( sal_False ); // don't dispose the connection - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pTemp->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pTemp->GetUserData()); if (pData) { if ( etTableOrView == pData->eType ) @@ -2717,9 +2716,9 @@ SvLBoxEntry* pChild = m_pTreeModel->FirstChild(pContainer); while(pChild) { - if (m_pTreeView->getListBox()->GetEntryText(pChild) == aName) + if (m_pTreeView->getListBox().GetEntryText(pChild) == aName) { - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pChild->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pChild->GetUserData()); if (pData) { if ( etTableOrView == pData->eType ) @@ -2787,7 +2786,7 @@ if ( _pDSEntry ) { - DBTreeListModel::DBTreeListUserData* pTreeListData = static_cast< DBTreeListModel::DBTreeListUserData* >( _pDSEntry->GetUserData() ); + DBTreeListUserData* pTreeListData = static_cast< DBTreeListUserData* >( _pDSEntry->GetUserData() ); if ( pTreeListData ) impl_releaseConnection( pTreeListData->xConnection ); } @@ -2800,7 +2799,7 @@ DBG_ASSERT( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::closeConnection: invalid entry (not top-level)!"); // 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)) + if (m_pCurrentlyDisplayed && (m_pTreeView->getListBox().GetRootLevelParent(m_pCurrentlyDisplayed) == _pDSEntry)) unloadAndCleanup(_bDisposeConnection); // collapse the query/table container @@ -2808,21 +2807,21 @@ { SvLBoxEntry* pElements = m_pTreeModel->FirstChild(pContainers); if ( pElements ) - m_pTreeView->getListBox()->Collapse(pContainers); - m_pTreeView->getListBox()->EnableExpandHandler(pContainers); + m_pTreeView->getListBox().Collapse(pContainers); + m_pTreeView->getListBox().EnableExpandHandler(pContainers); // and delete their children (they are connection-relative) for (; pElements; ) { SvLBoxEntry* pRemove = pElements; pElements= m_pTreeModel->NextSibling(pElements); - DBTreeListModel::DBTreeListUserData* pData = static_cast<DBTreeListModel::DBTreeListUserData*>(pRemove->GetUserData()); + DBTreeListUserData* pData = static_cast<DBTreeListUserData*>(pRemove->GetUserData()); pRemove->SetUserData(NULL); delete pData; m_pTreeModel->Remove(pRemove); } } // collapse the entry itself - m_pTreeView->getListBox()->Collapse(_pDSEntry); + m_pTreeView->getListBox().Collapse(_pDSEntry); // dispose/reset the connection if ( _bDisposeConnection ) @@ -2836,7 +2835,7 @@ // nothing to do return; - SvLBoxEntry* pDSEntry = m_pTreeView->getListBox()->GetRootLevelParent(m_pCurrentlyDisplayed); + SvLBoxEntry* pDSEntry = m_pTreeView->getListBox().GetRootLevelParent(m_pCurrentlyDisplayed); // de-select the path for the currently displayed table/query if (m_pCurrentlyDisplayed) @@ -3058,7 +3057,7 @@ implAddDatasource( sInitialDataSourceName, aDBImage, sQueriesName, aQueriesImage, sTablesName, aTablesImage, xConnection ); - m_pTreeView->getListBox()->Expand( m_pTreeView->getListBox()->First() ); + m_pTreeView->getListBox().Expand( m_pTreeView->getListBox().First() ); } else initializeTreeModel(); @@ -3140,10 +3139,10 @@ // ----------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::ensureConnection(SvLBoxEntry* _pAnyEntry, SharedConnection& _rConnection) { - SvLBoxEntry* pDSEntry = m_pTreeView->getListBox()->GetRootLevelParent(_pAnyEntry); - DBTreeListModel::DBTreeListUserData* pDSData = + SvLBoxEntry* pDSEntry = m_pTreeView->getListBox().GetRootLevelParent(_pAnyEntry); + DBTreeListUserData* pDSData = pDSEntry - ? static_cast<DBTreeListModel::DBTreeListUserData*>(pDSEntry->GetUserData()) + ? static_cast<DBTreeListUserData*>(pDSEntry->GetUserData()) : NULL; return ensureConnection( pDSEntry, pDSData, _rConnection ); @@ -3162,10 +3161,10 @@ // ----------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::getExistentConnectionFor( SvLBoxEntry* _pAnyEntry, SharedConnection& _rConnection ) { - SvLBoxEntry* pDSEntry = m_pTreeView->getListBox()->GetRootLevelParent( _pAnyEntry ); - DBTreeListModel::DBTreeListUserData* pDSData = + SvLBoxEntry* pDSEntry = m_pTreeView->getListBox().GetRootLevelParent( _pAnyEntry ); + DBTreeListUserData* pDSData = pDSEntry - ? static_cast< DBTreeListModel::DBTreeListUserData* >( pDSEntry->GetUserData() ) + ? static_cast< DBTreeListUserData* >( pDSEntry->GetUserData() ) : NULL; if ( pDSData ) _rConnection = pDSData->xConnection; @@ -3186,7 +3185,7 @@ DBG_ASSERT( impl_isDataSourceEntry( _pDSEntry ), "SbaTableQueryBrowser::ensureConnection: this entry does not denote a data source!" ); if(_pDSEntry) { - DBTreeListModel::DBTreeListUserData* pTreeListData = static_cast<DBTreeListModel::DBTreeListUserData*>(pDSData); + DBTreeListUserData* pTreeListData = static_cast<DBTreeListUserData*>(pDSData); ::rtl::OUString aDSName = GetEntryText(_pDSEntry); if ( pTreeListData ) @@ -3235,7 +3234,7 @@ // every other container should be placed _before_ the bookmark container return -1; - const String sLeft = m_pTreeView->getListBox()->GetEntryText(pLHS); + const String sLeft = m_pTreeView->getListBox().GetEntryText(pLHS); EntryType eLeft = etTableContainer; if (String(ModuleRes(RID_STR_TABLES_CONTAINER)) == sLeft) @@ -3293,8 +3292,8 @@ { // the initial selection SvLBoxEntry* pTopLevelSelected = _pApplyTo; - while (pTopLevelSelected && m_pTreeView->getListBox()->GetParent(pTopLevelSelected)) - pTopLevelSelected = m_pTreeView->getListBox()->GetParent(pTopLevelSelected); + while (pTopLevelSelected && m_pTreeView->getListBox().GetParent(pTopLevelSelected)) + pTopLevelSelected = m_pTreeView->getListBox().GetParent(pTopLevelSelected); ::rtl::OUString sInitialSelection; if (pTopLevelSelected) sInitialSelection = getDataSourceAcessor( pTopLevelSelected ); @@ -3336,7 +3335,7 @@ // ----------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::requestQuickHelp( const SvLBoxEntry* _pEntry, String& _rText ) const { - const DBTreeListModel::DBTreeListUserData* pData = static_cast< const DBTreeListModel::DBTreeListUserData* >( _pEntry->GetUserData() ); + const DBTreeListUserData* pData = static_cast< const DBTreeListUserData* >( _pEntry->GetUserData() ); if ( ( pData->eType == etDatasource ) && pData->sAccessor.Len() ) { _rText = ::svt::OFileNotation( pData->sAccessor ).get( ::svt::OFileNotation::N_SYSTEM ); @@ -3346,11 +3345,11 @@ } // ----------------------------------------------------------------------------- -PopupMenu* SbaTableQueryBrowser::getContextMenu( Control& _rControl ) +PopupMenu* SbaTableQueryBrowser::getContextMenu( Control& _rControl ) const { - OSL_PRECOND( m_pTreeView->getListBox() == &_rControl, + OSL_PRECOND( &m_pTreeView->getListBox() == &_rControl, "SbaTableQueryBrowser::getContextMenu: where does this come from?" ); - if ( m_pTreeView->getListBox() != &_rControl ) + if ( &m_pTreeView->getListBox() != &_rControl ) return NULL; return new PopupMenu( ModuleRes( MENU_BROWSER_DEFAULTCONTEXT ) ); @@ -3363,6 +3362,24 @@ } // ----------------------------------------------------------------------------- +::cppu::OInterfaceContainerHelper* SbaTableQueryBrowser::getContextMenuInterceptors() +{ + return &m_aContextMenuInterceptors; +} + +// ----------------------------------------------------------------------------- +Any SbaTableQueryBrowser::getCurrentSelection( Control& _rControl ) const +{ + OSL_PRECOND( &m_pTreeView->getListBox() == &_rControl, + "SbaTableQueryBrowser::getCurrentSelection: where does this come from?" ); + if ( &m_pTreeView->getListBox() != &_rControl ) + return Any(); + + // TODO + return Any(); +} + +// ----------------------------------------------------------------------------- sal_Bool SbaTableQueryBrowser::implGetQuerySignature( ::rtl::OUString& _rCommand, sal_Bool& _bEscapeProcessing ) { _rCommand = ::rtl::OUString(); @@ -3444,7 +3461,7 @@ { sal_Bool bRet = sal_False; if ( m_pTreeView ) - bRet = m_pTreeView->getListBox()->GetBackground().GetColor().IsDark(); + bRet = m_pTreeView->getListBox().GetBackground().GetColor().IsDark(); return bRet; } // ----------------------------------------------------------------------------- @@ -3477,7 +3494,7 @@ SvLBoxEntry* pContainer = m_pTreeModel->GetParent(m_pCurrentlyDisplayed); // get the entry for the datasource SvLBoxEntry* pConnection = m_pTreeModel->GetParent(pContainer); - ::rtl::OUString sName = m_pTreeView->getListBox()->GetEntryText(m_pCurrentlyDisplayed); + ::rtl::OUString sName = m_pTreeView->getListBox().GetEntryText(m_pCurrentlyDisplayed); sTitle = GetEntryText( pConnection ); INetURLObject aURL(sTitle); if ( aURL.GetProtocol() != INET_PROT_NOT_VALID ) @@ -3537,6 +3554,19 @@ return xScripts; } +//------------------------------------------------------------------------------ +void SAL_CALL SbaTableQueryBrowser::registerContextMenuInterceptor( const Reference< XContextMenuInterceptor >& _Interceptor ) throw (RuntimeException) +{ + if ( _Interceptor.is() ) + m_aContextMenuInterceptors.addInterface( _Interceptor ); +} + +//------------------------------------------------------------------------------ +void SAL_CALL SbaTableQueryBrowser::releaseContextMenuInterceptor( const Reference< XContextMenuInterceptor >& _Interceptor ) throw (RuntimeException) +{ + m_aContextMenuInterceptors.removeInterface( _Interceptor ); +} + // ......................................................................... } // namespace dbaui // ......................................................................... --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
