1*96de5490SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96de5490SAndrew Rist * distributed with this work for additional information 6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance 9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at 10*96de5490SAndrew Rist * 11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*96de5490SAndrew Rist * 13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96de5490SAndrew Rist * software distributed under the License is distributed on an 15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the 17*96de5490SAndrew Rist * specific language governing permissions and limitations 18*96de5490SAndrew Rist * under the License. 19*96de5490SAndrew Rist * 20*96de5490SAndrew Rist *************************************************************/ 21*96de5490SAndrew Rist 22*96de5490SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _DBAUI_TABLETREE_HXX_ 28cdf0e10cSrcweir #include "tabletree.hxx" 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #ifndef _DBAUI_TABLETREE_HRC_ 31cdf0e10cSrcweir #include "tabletree.hrc" 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #ifndef DBACCESS_IMAGEPROVIDER_HXX 34cdf0e10cSrcweir #include "imageprovider.hxx" 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #ifndef _DBAUI_MODULE_DBU_HXX_ 37cdf0e10cSrcweir #include "moduledbu.hxx" 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #ifndef _DBU_CONTROL_HRC_ 40cdf0e10cSrcweir #include "dbu_control.hrc" 41cdf0e10cSrcweir #endif 42cdf0e10cSrcweir #ifndef _SV_MENU_HXX 43cdf0e10cSrcweir #include <vcl/menu.hxx> 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir #ifndef _CONNECTIVITY_DBTOOLS_HXX_ 46cdf0e10cSrcweir #include <connectivity/dbtools.hxx> 47cdf0e10cSrcweir #endif 48cdf0e10cSrcweir #ifndef _COMPHELPER_TYPES_HXX_ 49cdf0e10cSrcweir #include <comphelper/types.hxx> 50cdf0e10cSrcweir #endif 51cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC 52cdf0e10cSrcweir #include "dbustrings.hrc" 53cdf0e10cSrcweir #endif 54cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_APPLICATION_DATABASEOBJECT_HPP_ 55cdf0e10cSrcweir #include <com/sun/star/sdb/application/DatabaseObject.hpp> 56cdf0e10cSrcweir #endif 57cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_APPLICATION_DATABASEOBJECTFOLDER_HPP_ 58cdf0e10cSrcweir #include <com/sun/star/sdb/application/DatabaseObjectContainer.hpp> 59cdf0e10cSrcweir #endif 60cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XDRIVERACCESS_HPP_ 61cdf0e10cSrcweir #include <com/sun/star/sdbc/XDriverAccess.hpp> 62cdf0e10cSrcweir #endif 63cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XDATADEFINITIONSUPPLIER_HPP_ 64cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> 65cdf0e10cSrcweir #endif 66cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XVIEWSSUPPLIER_HPP_ 67cdf0e10cSrcweir #include <com/sun/star/sdbcx/XViewsSupplier.hpp> 68cdf0e10cSrcweir #endif 69cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_ 70cdf0e10cSrcweir #include <com/sun/star/sdbcx/XTablesSupplier.hpp> 71cdf0e10cSrcweir #endif 72cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ 73cdf0e10cSrcweir #include <com/sun/star/sdb/SQLContext.hpp> 74cdf0e10cSrcweir #endif 75cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ 76cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 77cdf0e10cSrcweir #endif 78cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ 79cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 80cdf0e10cSrcweir #endif 81cdf0e10cSrcweir #ifndef _DBAUI_COMMON_TYPES_HXX_ 82cdf0e10cSrcweir #include "commontypes.hxx" 83cdf0e10cSrcweir #endif 84cdf0e10cSrcweir #ifndef _DBAUI_LISTVIEWITEMS_HXX_ 85cdf0e10cSrcweir #include "listviewitems.hxx" 86cdf0e10cSrcweir #endif 87cdf0e10cSrcweir #ifndef TOOLS_DIAGNOSE_EX_H 88cdf0e10cSrcweir #include <tools/diagnose_ex.h> 89cdf0e10cSrcweir #endif 90cdf0e10cSrcweir #ifndef _RTL_USTRBUF_HXX_ 91cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 92cdf0e10cSrcweir #endif 93cdf0e10cSrcweir #include <connectivity/dbmetadata.hxx> 94cdf0e10cSrcweir 95cdf0e10cSrcweir #include <algorithm> 96cdf0e10cSrcweir 97cdf0e10cSrcweir //......................................................................... 98cdf0e10cSrcweir namespace dbaui 99cdf0e10cSrcweir { 100cdf0e10cSrcweir //......................................................................... 101cdf0e10cSrcweir 102cdf0e10cSrcweir using namespace ::com::sun::star::uno; 103cdf0e10cSrcweir using namespace ::com::sun::star::sdb; 104cdf0e10cSrcweir using namespace ::com::sun::star::lang; 105cdf0e10cSrcweir using namespace ::com::sun::star::sdbc; 106cdf0e10cSrcweir using namespace ::com::sun::star::sdbcx; 107cdf0e10cSrcweir using namespace ::com::sun::star::beans; 108cdf0e10cSrcweir using namespace ::com::sun::star::container; 109cdf0e10cSrcweir using namespace ::com::sun::star::sdb::application; 110cdf0e10cSrcweir 111cdf0e10cSrcweir using namespace ::dbtools; 112cdf0e10cSrcweir using namespace ::comphelper; 113cdf0e10cSrcweir 114cdf0e10cSrcweir namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject; 115cdf0e10cSrcweir namespace DatabaseObjectContainer = ::com::sun::star::sdb::application::DatabaseObjectContainer; 116cdf0e10cSrcweir 117cdf0e10cSrcweir //======================================================================== 118cdf0e10cSrcweir //= OTableTreeListBox 119cdf0e10cSrcweir //======================================================================== 120cdf0e10cSrcweir OTableTreeListBox::OTableTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, WinBits nWinStyle,sal_Bool _bVirtualRoot ) 121cdf0e10cSrcweir :OMarkableTreeListBox(pParent,_rxORB,nWinStyle) 122cdf0e10cSrcweir ,m_pImageProvider( new ImageProvider ) 123cdf0e10cSrcweir ,m_bVirtualRoot(_bVirtualRoot) 124cdf0e10cSrcweir ,m_bNoEmptyFolders( false ) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir implSetDefaultImages(); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir //------------------------------------------------------------------------ 129cdf0e10cSrcweir OTableTreeListBox::OTableTreeListBox( Window* pParent, const Reference< XMultiServiceFactory >& _rxORB, const ResId& rResId ,sal_Bool _bVirtualRoot) 130cdf0e10cSrcweir :OMarkableTreeListBox(pParent,_rxORB,rResId) 131cdf0e10cSrcweir ,m_pImageProvider( new ImageProvider ) 132cdf0e10cSrcweir ,m_bVirtualRoot(_bVirtualRoot) 133cdf0e10cSrcweir ,m_bNoEmptyFolders( false ) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir implSetDefaultImages(); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir 138cdf0e10cSrcweir // ----------------------------------------------------------------------------- 139cdf0e10cSrcweir OTableTreeListBox::~OTableTreeListBox() 140cdf0e10cSrcweir { 141cdf0e10cSrcweir } 142cdf0e10cSrcweir 143cdf0e10cSrcweir // ----------------------------------------------------------------------------- 144cdf0e10cSrcweir void OTableTreeListBox::implSetDefaultImages() 145cdf0e10cSrcweir { 146cdf0e10cSrcweir ImageProvider aImageProvider; 147cdf0e10cSrcweir SetDefaultExpandedEntryBmp( aImageProvider.getFolderImage( DatabaseObject::TABLE, false ), BMP_COLOR_NORMAL ); 148cdf0e10cSrcweir SetDefaultExpandedEntryBmp( aImageProvider.getFolderImage( DatabaseObject::TABLE, true ), BMP_COLOR_HIGHCONTRAST ); 149cdf0e10cSrcweir SetDefaultCollapsedEntryBmp( aImageProvider.getFolderImage( DatabaseObject::TABLE, false ), BMP_COLOR_NORMAL ); 150cdf0e10cSrcweir SetDefaultCollapsedEntryBmp( aImageProvider.getFolderImage( DatabaseObject::TABLE, true ), BMP_COLOR_HIGHCONTRAST ); 151cdf0e10cSrcweir } 152cdf0e10cSrcweir 153cdf0e10cSrcweir // ----------------------------------------------------------------------------- 154cdf0e10cSrcweir bool OTableTreeListBox::isFolderEntry( const SvLBoxEntry* _pEntry ) const 155cdf0e10cSrcweir { 156cdf0e10cSrcweir sal_Int32 nEntryType = reinterpret_cast< sal_IntPtr >( _pEntry->GetUserData() ); 157cdf0e10cSrcweir if ( ( nEntryType == DatabaseObjectContainer::TABLES ) 158cdf0e10cSrcweir || ( nEntryType == DatabaseObjectContainer::CATALOG ) 159cdf0e10cSrcweir || ( nEntryType == DatabaseObjectContainer::SCHEMA ) 160cdf0e10cSrcweir ) 161cdf0e10cSrcweir return true; 162cdf0e10cSrcweir return false; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir 165cdf0e10cSrcweir // ----------------------------------------------------------------------------- 166cdf0e10cSrcweir void OTableTreeListBox::notifyHiContrastChanged() 167cdf0e10cSrcweir { 168cdf0e10cSrcweir implSetDefaultImages(); 169cdf0e10cSrcweir 170cdf0e10cSrcweir SvLBoxEntry* pEntryLoop = First(); 171cdf0e10cSrcweir while (pEntryLoop) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir sal_uInt16 nCount = pEntryLoop->ItemCount(); 174cdf0e10cSrcweir for (sal_uInt16 i=0;i<nCount;++i) 175cdf0e10cSrcweir { 176cdf0e10cSrcweir SvLBoxItem* pItem = pEntryLoop->GetItem(i); 177cdf0e10cSrcweir if ( pItem && pItem->IsA() == SV_ITEM_ID_LBOXCONTEXTBMP) 178cdf0e10cSrcweir { 179cdf0e10cSrcweir SvLBoxContextBmp* pContextBitmapItem = static_cast< SvLBoxContextBmp* >( pItem ); 180cdf0e10cSrcweir 181cdf0e10cSrcweir Image aImage, aImageHC; 182cdf0e10cSrcweir if ( isFolderEntry( pEntryLoop ) ) 183cdf0e10cSrcweir { 184cdf0e10cSrcweir aImage = m_pImageProvider->getFolderImage( DatabaseObject::TABLE, false ); 185cdf0e10cSrcweir aImageHC = m_pImageProvider->getFolderImage( DatabaseObject::TABLE, true ); 186cdf0e10cSrcweir } 187cdf0e10cSrcweir else 188cdf0e10cSrcweir { 189cdf0e10cSrcweir String sCompleteName( getQualifiedTableName( pEntryLoop ) ); 190cdf0e10cSrcweir m_pImageProvider->getImages( sCompleteName, DatabaseObject::TABLE, aImage, aImageHC ); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir pContextBitmapItem->SetBitmap1( aImage, BMP_COLOR_NORMAL ); 194cdf0e10cSrcweir pContextBitmapItem->SetBitmap2( aImage, BMP_COLOR_NORMAL ); 195cdf0e10cSrcweir pContextBitmapItem->SetBitmap1( aImageHC, BMP_COLOR_HIGHCONTRAST ); 196cdf0e10cSrcweir pContextBitmapItem->SetBitmap2( aImageHC, BMP_COLOR_HIGHCONTRAST ); 197cdf0e10cSrcweir // TODO: Now that we give both images to the entry item, it is not necessary anymore 198cdf0e10cSrcweir // to do this anytime HC changes - the tree control will do this itself now. 199cdf0e10cSrcweir // We would only need to properly initialize newly inserted entries. 200cdf0e10cSrcweir break; 201cdf0e10cSrcweir } 202cdf0e10cSrcweir } 203cdf0e10cSrcweir pEntryLoop = Next(pEntryLoop); 204cdf0e10cSrcweir } 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir //------------------------------------------------------------------------ 208cdf0e10cSrcweir void OTableTreeListBox::implOnNewConnection( const Reference< XConnection >& _rxConnection ) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir m_xConnection = _rxConnection; 211cdf0e10cSrcweir m_pImageProvider.reset( new ImageProvider( m_xConnection ) ); 212cdf0e10cSrcweir } 213cdf0e10cSrcweir 214cdf0e10cSrcweir //------------------------------------------------------------------------ 215cdf0e10cSrcweir void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConnection ) throw(SQLException) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir Sequence< ::rtl::OUString > sTables, sViews; 218cdf0e10cSrcweir 219cdf0e10cSrcweir String sCurrentActionError; 220cdf0e10cSrcweir try 221cdf0e10cSrcweir { 222cdf0e10cSrcweir Reference< XTablesSupplier > xTableSupp( _rxConnection, UNO_QUERY_THROW ); 223cdf0e10cSrcweir sCurrentActionError = String(ModuleRes(STR_NOTABLEINFO)); 224cdf0e10cSrcweir 225cdf0e10cSrcweir Reference< XNameAccess > xTables,xViews; 226cdf0e10cSrcweir 227cdf0e10cSrcweir Reference< XViewsSupplier > xViewSupp( _rxConnection, UNO_QUERY ); 228cdf0e10cSrcweir if ( xViewSupp.is() ) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir xViews = xViewSupp->getViews(); 231cdf0e10cSrcweir if (xViews.is()) 232cdf0e10cSrcweir sViews = xViews->getElementNames(); 233cdf0e10cSrcweir } 234cdf0e10cSrcweir 235cdf0e10cSrcweir xTables = xTableSupp->getTables(); 236cdf0e10cSrcweir if (xTables.is()) 237cdf0e10cSrcweir sTables = xTables->getElementNames(); 238cdf0e10cSrcweir } 239cdf0e10cSrcweir catch(RuntimeException&) 240cdf0e10cSrcweir { 241cdf0e10cSrcweir DBG_ERROR("OTableTreeListBox::UpdateTableList : caught an RuntimeException!"); 242cdf0e10cSrcweir } 243cdf0e10cSrcweir catch ( const SQLException& ) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir throw; 246cdf0e10cSrcweir } 247cdf0e10cSrcweir catch(Exception&) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir // a non-SQLException exception occured ... simply throw an SQLException 250cdf0e10cSrcweir SQLException aInfo; 251cdf0e10cSrcweir aInfo.Message = sCurrentActionError; 252cdf0e10cSrcweir throw aInfo; 253cdf0e10cSrcweir } 254cdf0e10cSrcweir 255cdf0e10cSrcweir UpdateTableList( _rxConnection, sTables, sViews ); 256cdf0e10cSrcweir } 257cdf0e10cSrcweir // ----------------------------------------------------------------------------- 258cdf0e10cSrcweir namespace 259cdf0e10cSrcweir { 260cdf0e10cSrcweir struct OViewSetter : public ::std::unary_function< OTableTreeListBox::TNames::value_type, bool> 261cdf0e10cSrcweir { 262cdf0e10cSrcweir const Sequence< ::rtl::OUString> m_aViews; 263cdf0e10cSrcweir ::comphelper::TStringMixEqualFunctor m_aEqualFunctor; 264cdf0e10cSrcweir 265cdf0e10cSrcweir OViewSetter(const Sequence< ::rtl::OUString>& _rViews,sal_Bool _bCase) : m_aViews(_rViews),m_aEqualFunctor(_bCase){} 266cdf0e10cSrcweir OTableTreeListBox::TNames::value_type operator() (const ::rtl::OUString& lhs) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir OTableTreeListBox::TNames::value_type aRet; 269cdf0e10cSrcweir aRet.first = lhs; 270cdf0e10cSrcweir const ::rtl::OUString* pIter = m_aViews.getConstArray(); 271cdf0e10cSrcweir const ::rtl::OUString* pEnd = m_aViews.getConstArray() + m_aViews.getLength(); 272cdf0e10cSrcweir aRet.second = (::std::find_if(pIter,pEnd,::std::bind2nd(m_aEqualFunctor,lhs)) != pEnd); 273cdf0e10cSrcweir 274cdf0e10cSrcweir return aRet; 275cdf0e10cSrcweir } 276cdf0e10cSrcweir }; 277cdf0e10cSrcweir 278cdf0e10cSrcweir } 279cdf0e10cSrcweir // ----------------------------------------------------------------------------- 280cdf0e10cSrcweir void OTableTreeListBox::UpdateTableList( 281cdf0e10cSrcweir const Reference< XConnection >& _rxConnection, 282cdf0e10cSrcweir const Sequence< ::rtl::OUString>& _rTables, 283cdf0e10cSrcweir const Sequence< ::rtl::OUString>& _rViews 284cdf0e10cSrcweir ) 285cdf0e10cSrcweir { 286cdf0e10cSrcweir TNames aTables; 287cdf0e10cSrcweir aTables.resize(_rTables.getLength()); 288cdf0e10cSrcweir const ::rtl::OUString* pIter = _rTables.getConstArray(); 289cdf0e10cSrcweir const ::rtl::OUString* pEnd = _rTables.getConstArray() + _rTables.getLength(); 290cdf0e10cSrcweir try 291cdf0e10cSrcweir { 292cdf0e10cSrcweir Reference< XDatabaseMetaData > xMeta( _rxConnection->getMetaData(), UNO_QUERY_THROW ); 293cdf0e10cSrcweir ::std::transform( pIter, pEnd, 294cdf0e10cSrcweir aTables.begin(), OViewSetter( _rViews, xMeta->supportsMixedCaseQuotedIdentifiers() ) ); 295cdf0e10cSrcweir } 296cdf0e10cSrcweir catch(Exception&) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 299cdf0e10cSrcweir } 300cdf0e10cSrcweir UpdateTableList( _rxConnection, aTables ); 301cdf0e10cSrcweir } 302cdf0e10cSrcweir 303cdf0e10cSrcweir //------------------------------------------------------------------------ 304cdf0e10cSrcweir namespace 305cdf0e10cSrcweir { 306cdf0e10cSrcweir ::std::vector< ::rtl::OUString > lcl_getMetaDataStrings_throw( const Reference< XResultSet >& _rxMetaDataResult, sal_Int32 _nColumnIndex ) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir ::std::vector< ::rtl::OUString > aStrings; 309cdf0e10cSrcweir Reference< XRow > xRow( _rxMetaDataResult, UNO_QUERY_THROW ); 310cdf0e10cSrcweir while ( _rxMetaDataResult->next() ) 311cdf0e10cSrcweir aStrings.push_back( xRow->getString( _nColumnIndex ) ); 312cdf0e10cSrcweir return aStrings; 313cdf0e10cSrcweir } 314cdf0e10cSrcweir 315cdf0e10cSrcweir bool lcl_shouldDisplayEmptySchemasAndCatalogs( const Reference< XConnection >& _rxConnection ) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir ::dbtools::DatabaseMetaData aMetaData( _rxConnection ); 318cdf0e10cSrcweir return aMetaData.displayEmptyTableFolders(); 319cdf0e10cSrcweir } 320cdf0e10cSrcweir } 321cdf0e10cSrcweir 322cdf0e10cSrcweir //------------------------------------------------------------------------ 323cdf0e10cSrcweir void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConnection, const TNames& _rTables ) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir implOnNewConnection( _rxConnection ); 326cdf0e10cSrcweir 327cdf0e10cSrcweir // throw away all the old stuff 328cdf0e10cSrcweir Clear(); 329cdf0e10cSrcweir 330cdf0e10cSrcweir try 331cdf0e10cSrcweir { 332cdf0e10cSrcweir // the root entry saying "all objects" 333cdf0e10cSrcweir SvLBoxEntry* pAllObjects = NULL; 334cdf0e10cSrcweir if (haveVirtualRoot()) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir String sRootEntryText; 337cdf0e10cSrcweir TNames::const_iterator aViews = ::std::find_if(_rTables.begin(),_rTables.end(), 338cdf0e10cSrcweir ::std::compose1(::std::bind2nd(::std::equal_to<sal_Bool>(),sal_False),::std::select2nd<TNames::value_type>())); 339cdf0e10cSrcweir TNames::const_iterator aTables = ::std::find_if(_rTables.begin(),_rTables.end(), 340cdf0e10cSrcweir ::std::compose1(::std::bind2nd(::std::equal_to<sal_Bool>(),sal_True),::std::select2nd<TNames::value_type>())); 341cdf0e10cSrcweir 342cdf0e10cSrcweir if ( aViews == _rTables.end() ) 343cdf0e10cSrcweir sRootEntryText = String(ModuleRes(STR_ALL_TABLES)); 344cdf0e10cSrcweir else if ( aTables == _rTables.end() ) 345cdf0e10cSrcweir sRootEntryText = String(ModuleRes(STR_ALL_VIEWS)); 346cdf0e10cSrcweir else 347cdf0e10cSrcweir sRootEntryText = String(ModuleRes(STR_ALL_TABLES_AND_VIEWS)); 348cdf0e10cSrcweir pAllObjects = InsertEntry( sRootEntryText, NULL, sal_False, LIST_APPEND, reinterpret_cast< void* >( DatabaseObjectContainer::TABLES ) ); 349cdf0e10cSrcweir } 350cdf0e10cSrcweir 351cdf0e10cSrcweir if ( _rTables.empty() ) 352cdf0e10cSrcweir // nothing to do (besides inserting the root entry) 353cdf0e10cSrcweir return; 354cdf0e10cSrcweir 355cdf0e10cSrcweir // get the table/view names 356cdf0e10cSrcweir TNames::const_iterator aIter = _rTables.begin(); 357cdf0e10cSrcweir TNames::const_iterator aEnd = _rTables.end(); 358cdf0e10cSrcweir 359cdf0e10cSrcweir Reference< XDatabaseMetaData > xMeta( _rxConnection->getMetaData(), UNO_QUERY_THROW ); 360cdf0e10cSrcweir for ( ; aIter != aEnd; ++aIter ) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir // add the entry 363cdf0e10cSrcweir implAddEntry( 364cdf0e10cSrcweir xMeta, 365cdf0e10cSrcweir aIter->first, 366cdf0e10cSrcweir sal_False 367cdf0e10cSrcweir ); 368cdf0e10cSrcweir } 369cdf0e10cSrcweir 370cdf0e10cSrcweir if ( !m_bNoEmptyFolders && lcl_shouldDisplayEmptySchemasAndCatalogs( _rxConnection ) ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir sal_Bool bSupportsCatalogs = xMeta->supportsCatalogsInDataManipulation(); 373cdf0e10cSrcweir sal_Bool bSupportsSchemas = xMeta->supportsSchemasInDataManipulation(); 374cdf0e10cSrcweir 375cdf0e10cSrcweir if ( bSupportsCatalogs || bSupportsSchemas ) 376cdf0e10cSrcweir { 377cdf0e10cSrcweir // we display empty catalogs if the DB supports catalogs, and they're noted at the beginning of a 378cdf0e10cSrcweir // composed name. Otherwise, we display empty schematas. (also see the tree structure explained in 379cdf0e10cSrcweir // implAddEntry) 380cdf0e10cSrcweir bool bCatalogs = bSupportsCatalogs && xMeta->isCatalogAtStart(); 381cdf0e10cSrcweir 382cdf0e10cSrcweir ::std::vector< ::rtl::OUString > aFolderNames( lcl_getMetaDataStrings_throw( 383cdf0e10cSrcweir bCatalogs ? xMeta->getCatalogs() : xMeta->getSchemas(), 1 ) ); 384cdf0e10cSrcweir sal_Int32 nFolderType = bCatalogs ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA; 385cdf0e10cSrcweir 386cdf0e10cSrcweir SvLBoxEntry* pRootEntry = getAllObjectsEntry(); 387cdf0e10cSrcweir for ( ::std::vector< ::rtl::OUString >::const_iterator folder = aFolderNames.begin(); 388cdf0e10cSrcweir folder != aFolderNames.end(); 389cdf0e10cSrcweir ++folder 390cdf0e10cSrcweir ) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir SvLBoxEntry* pFolder = GetEntryPosByName( *folder, pRootEntry ); 393cdf0e10cSrcweir if ( !pFolder ) 394cdf0e10cSrcweir pFolder = InsertEntry( *folder, pRootEntry, sal_False, LIST_APPEND, reinterpret_cast< void* >( nFolderType ) ); 395cdf0e10cSrcweir } 396cdf0e10cSrcweir } 397cdf0e10cSrcweir } 398cdf0e10cSrcweir } 399cdf0e10cSrcweir catch ( const Exception& ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 402cdf0e10cSrcweir } 403cdf0e10cSrcweir } 404cdf0e10cSrcweir //------------------------------------------------------------------------ 405cdf0e10cSrcweir sal_Bool OTableTreeListBox::isWildcardChecked(SvLBoxEntry* _pEntry) const 406cdf0e10cSrcweir { 407cdf0e10cSrcweir if (_pEntry) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir OBoldListboxString* pTextItem = static_cast<OBoldListboxString*>(_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING)); 410cdf0e10cSrcweir if (pTextItem) 411cdf0e10cSrcweir return pTextItem->isEmphasized(); 412cdf0e10cSrcweir } 413cdf0e10cSrcweir return sal_False; 414cdf0e10cSrcweir } 415cdf0e10cSrcweir 416cdf0e10cSrcweir //------------------------------------------------------------------------ 417cdf0e10cSrcweir void OTableTreeListBox::checkWildcard(SvLBoxEntry* _pEntry) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir SetCheckButtonState(_pEntry, SV_BUTTON_CHECKED); 420cdf0e10cSrcweir checkedButton_noBroadcast(_pEntry); 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir //------------------------------------------------------------------------ 424cdf0e10cSrcweir SvLBoxEntry* OTableTreeListBox::getAllObjectsEntry() const 425cdf0e10cSrcweir { 426cdf0e10cSrcweir return haveVirtualRoot() ? First() : NULL; 427cdf0e10cSrcweir } 428cdf0e10cSrcweir 429cdf0e10cSrcweir //------------------------------------------------------------------------ 430cdf0e10cSrcweir void OTableTreeListBox::checkedButton_noBroadcast(SvLBoxEntry* _pEntry) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir OMarkableTreeListBox::checkedButton_noBroadcast(_pEntry); 433cdf0e10cSrcweir 434cdf0e10cSrcweir // if an entry has children, it makes a difference if the entry is checked because alls children are checked 435cdf0e10cSrcweir // or if the user checked it explicitly. 436cdf0e10cSrcweir // So we track explicit (un)checking 437cdf0e10cSrcweir 438cdf0e10cSrcweir SvButtonState eState = GetCheckButtonState(_pEntry); 439cdf0e10cSrcweir DBG_ASSERT(SV_BUTTON_TRISTATE != eState, "OTableTreeListBox::CheckButtonHdl: user action which lead to TRISTATE?"); 440cdf0e10cSrcweir implEmphasize(_pEntry, SV_BUTTON_CHECKED == eState); 441cdf0e10cSrcweir } 442cdf0e10cSrcweir 443cdf0e10cSrcweir //------------------------------------------------------------------------ 444cdf0e10cSrcweir void OTableTreeListBox::implEmphasize(SvLBoxEntry* _pEntry, sal_Bool _bChecked, sal_Bool _bUpdateDescendants, sal_Bool _bUpdateAncestors) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir DBG_ASSERT(_pEntry, "OTableTreeListBox::implEmphasize: invalid entry (NULL)!"); 447cdf0e10cSrcweir 448cdf0e10cSrcweir // special emphasizing handling for the "all objects" entry 449cdf0e10cSrcweir // 89709 - 16.07.2001 - frank.schoenheit@sun.com 450cdf0e10cSrcweir sal_Bool bAllObjectsEntryAffected = haveVirtualRoot() && (getAllObjectsEntry() == _pEntry); 451cdf0e10cSrcweir if ( GetModel()->HasChilds(_pEntry) // the entry has children 452cdf0e10cSrcweir || bAllObjectsEntryAffected // or it is the "all objects" entry 453cdf0e10cSrcweir ) 454cdf0e10cSrcweir { 455cdf0e10cSrcweir OBoldListboxString* pTextItem = static_cast<OBoldListboxString*>(_pEntry->GetFirstItem(SV_ITEM_ID_BOLDLBSTRING)); 456cdf0e10cSrcweir if (pTextItem) 457cdf0e10cSrcweir pTextItem->emphasize(_bChecked); 458cdf0e10cSrcweir 459cdf0e10cSrcweir if (bAllObjectsEntryAffected) 460cdf0e10cSrcweir InvalidateEntry(_pEntry); 461cdf0e10cSrcweir } 462cdf0e10cSrcweir 463cdf0e10cSrcweir if (_bUpdateDescendants) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir // remove the mark for all children of the checked entry 466cdf0e10cSrcweir SvLBoxEntry* pChildLoop = FirstChild(_pEntry); 467cdf0e10cSrcweir while (pChildLoop) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir if (GetModel()->HasChilds(pChildLoop)) 470cdf0e10cSrcweir implEmphasize(pChildLoop, sal_False, sal_True, sal_False); 471cdf0e10cSrcweir pChildLoop = NextSibling(pChildLoop); 472cdf0e10cSrcweir } 473cdf0e10cSrcweir } 474cdf0e10cSrcweir 475cdf0e10cSrcweir if (_bUpdateAncestors) 476cdf0e10cSrcweir { 477cdf0e10cSrcweir // remove the mark for all ancestors of the entry 478cdf0e10cSrcweir if (GetModel()->HasParent(_pEntry)) 479cdf0e10cSrcweir implEmphasize(GetParent(_pEntry), sal_False, sal_False, sal_True); 480cdf0e10cSrcweir } 481cdf0e10cSrcweir } 482cdf0e10cSrcweir 483cdf0e10cSrcweir //------------------------------------------------------------------------ 484cdf0e10cSrcweir void OTableTreeListBox::InitEntry(SvLBoxEntry* _pEntry, const XubString& _rString, const Image& _rCollapsedBitmap, const Image& _rExpandedBitmap, SvLBoxButtonKind _eButtonKind) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir OMarkableTreeListBox::InitEntry(_pEntry, _rString, _rCollapsedBitmap, _rExpandedBitmap, _eButtonKind); 487cdf0e10cSrcweir 488cdf0e10cSrcweir // replace the text item with our own one 489cdf0e10cSrcweir SvLBoxItem* pTextItem = _pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING); 490cdf0e10cSrcweir DBG_ASSERT(pTextItem, "OTableTreeListBox::InitEntry: no text item!?"); 491cdf0e10cSrcweir sal_uInt16 nTextPos = _pEntry->GetPos(pTextItem); 492cdf0e10cSrcweir DBG_ASSERT(((sal_uInt16)-1) != nTextPos, "OTableTreeListBox::InitEntry: no text item pos!"); 493cdf0e10cSrcweir 494cdf0e10cSrcweir _pEntry->ReplaceItem(new OBoldListboxString(_pEntry, 0, _rString), nTextPos); 495cdf0e10cSrcweir } 496cdf0e10cSrcweir 497cdf0e10cSrcweir //------------------------------------------------------------------------ 498cdf0e10cSrcweir SvLBoxEntry* OTableTreeListBox::implAddEntry( 499cdf0e10cSrcweir const Reference< XDatabaseMetaData >& _rxMeta, 500cdf0e10cSrcweir const ::rtl::OUString& _rTableName, 501cdf0e10cSrcweir sal_Bool _bCheckName 502cdf0e10cSrcweir ) 503cdf0e10cSrcweir { 504cdf0e10cSrcweir OSL_PRECOND( _rxMeta.is(), "OTableTreeListBox::implAddEntry: invalid meta data!" ); 505cdf0e10cSrcweir if ( !_rxMeta.is() ) 506cdf0e10cSrcweir return NULL; 507cdf0e10cSrcweir 508cdf0e10cSrcweir // split the complete name into it's components 509cdf0e10cSrcweir ::rtl::OUString sCatalog, sSchema, sName; 510cdf0e10cSrcweir qualifiedNameComponents( _rxMeta, _rTableName, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation ); 511cdf0e10cSrcweir 512cdf0e10cSrcweir SvLBoxEntry* pParentEntry = getAllObjectsEntry(); 513cdf0e10cSrcweir 514cdf0e10cSrcweir // if the DB uses catalog at the start of identifiers, then our hierarchy is 515cdf0e10cSrcweir // catalog 516cdf0e10cSrcweir // +- schema 517cdf0e10cSrcweir // +- table 518cdf0e10cSrcweir // else it is 519cdf0e10cSrcweir // schema 520cdf0e10cSrcweir // +- catalog 521cdf0e10cSrcweir // +- table 522cdf0e10cSrcweir sal_Bool bCatalogAtStart = _rxMeta->isCatalogAtStart(); 523cdf0e10cSrcweir const ::rtl::OUString& rFirstName = bCatalogAtStart ? sCatalog : sSchema; 524cdf0e10cSrcweir const sal_Int32 nFirstFolderType = bCatalogAtStart ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA; 525cdf0e10cSrcweir const ::rtl::OUString& rSecondName = bCatalogAtStart ? sSchema : sCatalog; 526cdf0e10cSrcweir const sal_Int32 nSecondFolderType = bCatalogAtStart ? DatabaseObjectContainer::SCHEMA : DatabaseObjectContainer::CATALOG; 527cdf0e10cSrcweir 528cdf0e10cSrcweir if ( rFirstName.getLength() ) 529cdf0e10cSrcweir { 530cdf0e10cSrcweir SvLBoxEntry* pFolder = GetEntryPosByName( rFirstName, pParentEntry ); 531cdf0e10cSrcweir if ( !pFolder ) 532cdf0e10cSrcweir pFolder = InsertEntry( rFirstName, pParentEntry, sal_False, LIST_APPEND, reinterpret_cast< void* >( nFirstFolderType ) ); 533cdf0e10cSrcweir pParentEntry = pFolder; 534cdf0e10cSrcweir } 535cdf0e10cSrcweir 536cdf0e10cSrcweir if ( rSecondName.getLength() ) 537cdf0e10cSrcweir { 538cdf0e10cSrcweir SvLBoxEntry* pFolder = GetEntryPosByName( rSecondName, pParentEntry ); 539cdf0e10cSrcweir if ( !pFolder ) 540cdf0e10cSrcweir pFolder = InsertEntry( rSecondName, pParentEntry, sal_False, LIST_APPEND, reinterpret_cast< void* >( nSecondFolderType ) ); 541cdf0e10cSrcweir pParentEntry = pFolder; 542cdf0e10cSrcweir } 543cdf0e10cSrcweir 544cdf0e10cSrcweir SvLBoxEntry* pRet = NULL; 545cdf0e10cSrcweir if ( !_bCheckName || !GetEntryPosByName( sName, pParentEntry ) ) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir pRet = InsertEntry( sName, pParentEntry, sal_False, LIST_APPEND ); 548cdf0e10cSrcweir 549cdf0e10cSrcweir Image aImage, aImageHC; 550cdf0e10cSrcweir m_pImageProvider->getImages( _rTableName, DatabaseObject::TABLE, aImage, aImageHC ); 551cdf0e10cSrcweir 552cdf0e10cSrcweir SetExpandedEntryBmp( pRet, aImage, BMP_COLOR_NORMAL ); 553cdf0e10cSrcweir SetCollapsedEntryBmp( pRet, aImage, BMP_COLOR_NORMAL ); 554cdf0e10cSrcweir SetExpandedEntryBmp( pRet, aImageHC, BMP_COLOR_HIGHCONTRAST ); 555cdf0e10cSrcweir SetCollapsedEntryBmp( pRet, aImageHC, BMP_COLOR_HIGHCONTRAST ); 556cdf0e10cSrcweir } 557cdf0e10cSrcweir return pRet; 558cdf0e10cSrcweir } 559cdf0e10cSrcweir 560cdf0e10cSrcweir //------------------------------------------------------------------------ 561cdf0e10cSrcweir NamedDatabaseObject OTableTreeListBox::describeObject( SvLBoxEntry* _pEntry ) 562cdf0e10cSrcweir { 563cdf0e10cSrcweir NamedDatabaseObject aObject; 564cdf0e10cSrcweir 565cdf0e10cSrcweir sal_Int32 nEntryType = reinterpret_cast< sal_IntPtr >( _pEntry->GetUserData() ); 566cdf0e10cSrcweir 567cdf0e10cSrcweir if ( nEntryType == DatabaseObjectContainer::TABLES ) 568cdf0e10cSrcweir { 569cdf0e10cSrcweir aObject.Type = DatabaseObjectContainer::TABLES; 570cdf0e10cSrcweir } 571cdf0e10cSrcweir else if ( ( nEntryType == DatabaseObjectContainer::CATALOG ) 572cdf0e10cSrcweir || ( nEntryType == DatabaseObjectContainer::SCHEMA ) 573cdf0e10cSrcweir ) 574cdf0e10cSrcweir { 575cdf0e10cSrcweir SvLBoxEntry* pParent = GetParent( _pEntry ); 576cdf0e10cSrcweir sal_Int32 nParentEntryType = pParent ? reinterpret_cast< sal_IntPtr >( pParent->GetUserData() ) : -1; 577cdf0e10cSrcweir 578cdf0e10cSrcweir ::rtl::OUStringBuffer buffer; 579cdf0e10cSrcweir if ( nEntryType == DatabaseObjectContainer::CATALOG ) 580cdf0e10cSrcweir { 581cdf0e10cSrcweir if ( nParentEntryType == DatabaseObjectContainer::SCHEMA ) 582cdf0e10cSrcweir { 583cdf0e10cSrcweir buffer.append( GetEntryText( pParent ) ); 584cdf0e10cSrcweir buffer.append( sal_Unicode( '.' ) ); 585cdf0e10cSrcweir } 586cdf0e10cSrcweir buffer.append( GetEntryText( _pEntry ) ); 587cdf0e10cSrcweir } 588cdf0e10cSrcweir else if ( nEntryType == DatabaseObjectContainer::SCHEMA ) 589cdf0e10cSrcweir { 590cdf0e10cSrcweir if ( nParentEntryType == DatabaseObjectContainer::CATALOG ) 591cdf0e10cSrcweir { 592cdf0e10cSrcweir buffer.append( GetEntryText( pParent ) ); 593cdf0e10cSrcweir buffer.append( sal_Unicode( '.' ) ); 594cdf0e10cSrcweir } 595cdf0e10cSrcweir buffer.append( GetEntryText( _pEntry ) ); 596cdf0e10cSrcweir } 597cdf0e10cSrcweir } 598cdf0e10cSrcweir else 599cdf0e10cSrcweir { 600cdf0e10cSrcweir aObject.Type = DatabaseObject::TABLE; 601cdf0e10cSrcweir aObject.Name = getQualifiedTableName( _pEntry ); 602cdf0e10cSrcweir } 603cdf0e10cSrcweir 604cdf0e10cSrcweir return aObject; 605cdf0e10cSrcweir } 606cdf0e10cSrcweir 607cdf0e10cSrcweir //------------------------------------------------------------------------ 608cdf0e10cSrcweir SvLBoxEntry* OTableTreeListBox::addedTable( const ::rtl::OUString& _rName ) 609cdf0e10cSrcweir { 610cdf0e10cSrcweir try 611cdf0e10cSrcweir { 612cdf0e10cSrcweir Reference< XDatabaseMetaData > xMeta; 613cdf0e10cSrcweir if ( impl_getAndAssertMetaData( xMeta ) ) 614cdf0e10cSrcweir return implAddEntry( xMeta, _rName ); 615cdf0e10cSrcweir } 616cdf0e10cSrcweir catch( const Exception& ) 617cdf0e10cSrcweir { 618cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 619cdf0e10cSrcweir } 620cdf0e10cSrcweir return NULL; 621cdf0e10cSrcweir } 622cdf0e10cSrcweir 623cdf0e10cSrcweir //------------------------------------------------------------------------ 624cdf0e10cSrcweir bool OTableTreeListBox::impl_getAndAssertMetaData( Reference< XDatabaseMetaData >& _out_rMetaData ) const 625cdf0e10cSrcweir { 626cdf0e10cSrcweir if ( m_xConnection.is() ) 627cdf0e10cSrcweir _out_rMetaData = m_xConnection->getMetaData(); 628cdf0e10cSrcweir OSL_PRECOND( _out_rMetaData.is(), "OTableTreeListBox::impl_getAndAssertMetaData: invalid current connection!" ); 629cdf0e10cSrcweir return _out_rMetaData.is(); 630cdf0e10cSrcweir } 631cdf0e10cSrcweir 632cdf0e10cSrcweir //------------------------------------------------------------------------ 633cdf0e10cSrcweir String OTableTreeListBox::getQualifiedTableName( SvLBoxEntry* _pEntry ) const 634cdf0e10cSrcweir { 635cdf0e10cSrcweir OSL_PRECOND( !isFolderEntry( _pEntry ), "OTableTreeListBox::getQualifiedTableName: folder entries not allowed here!" ); 636cdf0e10cSrcweir 637cdf0e10cSrcweir try 638cdf0e10cSrcweir { 639cdf0e10cSrcweir Reference< XDatabaseMetaData > xMeta; 640cdf0e10cSrcweir if ( !impl_getAndAssertMetaData( xMeta ) ) 641cdf0e10cSrcweir return String(); 642cdf0e10cSrcweir 643cdf0e10cSrcweir ::rtl::OUString sCatalog; 644cdf0e10cSrcweir ::rtl::OUString sSchema; 645cdf0e10cSrcweir ::rtl::OUString sTable; 646cdf0e10cSrcweir 647cdf0e10cSrcweir SvLBoxEntry* pSchema = GetParent( _pEntry ); 648cdf0e10cSrcweir if ( pSchema ) 649cdf0e10cSrcweir { 650cdf0e10cSrcweir SvLBoxEntry* pCatalog = GetParent( pSchema ); 651cdf0e10cSrcweir if ( pCatalog 652cdf0e10cSrcweir || ( xMeta->supportsCatalogsInDataManipulation() 653cdf0e10cSrcweir && !xMeta->supportsSchemasInDataManipulation() 654cdf0e10cSrcweir ) // here we support catalog but no schema 655cdf0e10cSrcweir ) 656cdf0e10cSrcweir { 657cdf0e10cSrcweir if ( pCatalog == NULL ) 658cdf0e10cSrcweir { 659cdf0e10cSrcweir pCatalog = pSchema; 660cdf0e10cSrcweir pSchema = NULL; 661cdf0e10cSrcweir } 662cdf0e10cSrcweir sCatalog = GetEntryText( pCatalog ); 663cdf0e10cSrcweir } 664cdf0e10cSrcweir if ( pSchema ) 665cdf0e10cSrcweir sSchema = GetEntryText(pSchema); 666cdf0e10cSrcweir } 667cdf0e10cSrcweir sTable = GetEntryText( _pEntry ); 668cdf0e10cSrcweir 669cdf0e10cSrcweir return ::dbtools::composeTableName( xMeta, sCatalog, sSchema, sTable, sal_False, ::dbtools::eInDataManipulation ); 670cdf0e10cSrcweir } 671cdf0e10cSrcweir catch( const Exception& ) 672cdf0e10cSrcweir { 673cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 674cdf0e10cSrcweir } 675cdf0e10cSrcweir return String(); 676cdf0e10cSrcweir } 677cdf0e10cSrcweir 678cdf0e10cSrcweir //------------------------------------------------------------------------ 679cdf0e10cSrcweir SvLBoxEntry* OTableTreeListBox::getEntryByQualifiedName( const ::rtl::OUString& _rName ) 680cdf0e10cSrcweir { 681cdf0e10cSrcweir try 682cdf0e10cSrcweir { 683cdf0e10cSrcweir Reference< XDatabaseMetaData > xMeta; 684cdf0e10cSrcweir if ( !impl_getAndAssertMetaData( xMeta ) ) 685cdf0e10cSrcweir return NULL; 686cdf0e10cSrcweir 687cdf0e10cSrcweir // split the complete name into it's components 688cdf0e10cSrcweir ::rtl::OUString sCatalog, sSchema, sName; 689cdf0e10cSrcweir qualifiedNameComponents(xMeta, _rName, sCatalog, sSchema, sName,::dbtools::eInDataManipulation); 690cdf0e10cSrcweir 691cdf0e10cSrcweir SvLBoxEntry* pParent = getAllObjectsEntry(); 692cdf0e10cSrcweir SvLBoxEntry* pCat = NULL; 693cdf0e10cSrcweir SvLBoxEntry* pSchema = NULL; 694cdf0e10cSrcweir if ( sCatalog.getLength() ) 695cdf0e10cSrcweir { 696cdf0e10cSrcweir pCat = GetEntryPosByName(sCatalog, pParent); 697cdf0e10cSrcweir if ( pCat ) 698cdf0e10cSrcweir pParent = pCat; 699cdf0e10cSrcweir } 700cdf0e10cSrcweir 701cdf0e10cSrcweir if ( sSchema.getLength() ) 702cdf0e10cSrcweir { 703cdf0e10cSrcweir pSchema = GetEntryPosByName(sSchema, pParent); 704cdf0e10cSrcweir if ( pSchema ) 705cdf0e10cSrcweir pParent = pSchema; 706cdf0e10cSrcweir } 707cdf0e10cSrcweir 708cdf0e10cSrcweir return GetEntryPosByName(sName, pParent); 709cdf0e10cSrcweir } 710cdf0e10cSrcweir catch( const Exception& ) 711cdf0e10cSrcweir { 712cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 713cdf0e10cSrcweir } 714cdf0e10cSrcweir return NULL; 715cdf0e10cSrcweir } 716cdf0e10cSrcweir //------------------------------------------------------------------------ 717cdf0e10cSrcweir void OTableTreeListBox::removedTable( const ::rtl::OUString& _rName ) 718cdf0e10cSrcweir { 719cdf0e10cSrcweir try 720cdf0e10cSrcweir { 721cdf0e10cSrcweir SvLBoxEntry* pEntry = getEntryByQualifiedName( _rName ); 722cdf0e10cSrcweir if ( pEntry ) 723cdf0e10cSrcweir GetModel()->Remove( pEntry ); 724cdf0e10cSrcweir } 725cdf0e10cSrcweir catch( const Exception& ) 726cdf0e10cSrcweir { 727cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 728cdf0e10cSrcweir } 729cdf0e10cSrcweir } 730cdf0e10cSrcweir 731cdf0e10cSrcweir //......................................................................... 732cdf0e10cSrcweir } // namespace dbaui 733cdf0e10cSrcweir //......................................................................... 734cdf0e10cSrcweir 735