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