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_connectivity.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "hsqldb/HConnection.hxx" 32*cdf0e10cSrcweir #include "hsqldb/HTools.hxx" 33*cdf0e10cSrcweir #include "hsqlui.hrc" 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <connectivity/dbtools.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir /** === begin UNO includes === **/ 38*cdf0e10cSrcweir #include <com/sun/star/beans/NamedValue.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/lang/ServiceNotRegisteredException.hpp> 42*cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 43*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphicProvider.hpp> 44*cdf0e10cSrcweir #include <com/sun/star/graphic/GraphicColorMode.hpp> 45*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 46*cdf0e10cSrcweir #include <com/sun/star/sdbc/XDatabaseMetaData2.hpp> 47*cdf0e10cSrcweir /** === end UNO includes === **/ 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir #include <comphelper/componentcontext.hxx> 50*cdf0e10cSrcweir #include <comphelper/listenernotification.hxx> 51*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 52*cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx> 53*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 54*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir #include "resource/sharedresources.hxx" 57*cdf0e10cSrcweir #include "resource/hsqldb_res.hrc" 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir /** === begin UNO using === **/ 60*cdf0e10cSrcweir using ::com::sun::star::util::XFlushListener; 61*cdf0e10cSrcweir using ::com::sun::star::lang::EventObject; 62*cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 63*cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 64*cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 65*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 66*cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW; 67*cdf0e10cSrcweir using ::com::sun::star::sdbc::XStatement; 68*cdf0e10cSrcweir using ::com::sun::star::sdbc::XConnection; 69*cdf0e10cSrcweir using ::com::sun::star::sdbcx::XDataDefinitionSupplier; 70*cdf0e10cSrcweir using ::com::sun::star::sdbcx::XTablesSupplier; 71*cdf0e10cSrcweir using ::com::sun::star::container::XNameAccess; 72*cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 73*cdf0e10cSrcweir using ::com::sun::star::beans::NamedValue; 74*cdf0e10cSrcweir using ::com::sun::star::lang::WrappedTargetException; 75*cdf0e10cSrcweir using ::com::sun::star::lang::ServiceNotRegisteredException; 76*cdf0e10cSrcweir using ::com::sun::star::sdbc::XDriver; 77*cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory; 78*cdf0e10cSrcweir using ::com::sun::star::graphic::XGraphic; 79*cdf0e10cSrcweir using ::com::sun::star::graphic::XGraphicProvider; 80*cdf0e10cSrcweir using ::com::sun::star::uno::XInterface; 81*cdf0e10cSrcweir using ::com::sun::star::lang::IllegalArgumentException; 82*cdf0e10cSrcweir using ::com::sun::star::ui::dialogs::XExecutableDialog; 83*cdf0e10cSrcweir using ::com::sun::star::uno::Any; 84*cdf0e10cSrcweir using ::com::sun::star::uno::makeAny; 85*cdf0e10cSrcweir using ::com::sun::star::sdbc::XResultSet; 86*cdf0e10cSrcweir using ::com::sun::star::sdbc::XDatabaseMetaData; 87*cdf0e10cSrcweir using ::com::sun::star::sdbc::XDatabaseMetaData2; 88*cdf0e10cSrcweir using ::com::sun::star::sdbc::XRow; 89*cdf0e10cSrcweir using ::com::sun::star::sdb::application::XDatabaseDocumentUI; 90*cdf0e10cSrcweir using ::com::sun::star::beans::PropertyValue; 91*cdf0e10cSrcweir /** === end UNO using === **/ 92*cdf0e10cSrcweir namespace GraphicColorMode = ::com::sun::star::graphic::GraphicColorMode; 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir namespace connectivity { namespace hsqldb 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir // ============================================================================= 97*cdf0e10cSrcweir // = FlushListeners 98*cdf0e10cSrcweir // ============================================================================= 99*cdf0e10cSrcweir typedef ::comphelper::OListenerContainerBase< XFlushListener, EventObject > FlushListeners_Base; 100*cdf0e10cSrcweir class FlushListeners : public FlushListeners_Base 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir public: 103*cdf0e10cSrcweir FlushListeners( ::osl::Mutex& _rMutex ) :FlushListeners_Base( _rMutex ) { } 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir protected: 106*cdf0e10cSrcweir virtual bool implTypedNotify( 107*cdf0e10cSrcweir const Reference< XFlushListener >& _rxListener, 108*cdf0e10cSrcweir const EventObject& _rEvent 109*cdf0e10cSrcweir ) SAL_THROW( ( Exception ) ); 110*cdf0e10cSrcweir }; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 113*cdf0e10cSrcweir bool FlushListeners::implTypedNotify( const Reference< XFlushListener >& _rxListener, const EventObject& _rEvent ) SAL_THROW( ( Exception ) ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir _rxListener->flushed( _rEvent ); 116*cdf0e10cSrcweir return true; // continue notifying the other listeners, if any 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir 119*cdf0e10cSrcweir // ============================================================================= 120*cdf0e10cSrcweir // = OHsqlConnection 121*cdf0e10cSrcweir // ============================================================================= 122*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 123*cdf0e10cSrcweir void SAL_CALL OHsqlConnection::disposing(void) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir m_aFlushListeners.disposeAndClear( EventObject( *this ) ); 126*cdf0e10cSrcweir OHsqlConnection_BASE::disposing(); 127*cdf0e10cSrcweir OConnectionWrapper::disposing(); 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 130*cdf0e10cSrcweir OHsqlConnection::OHsqlConnection( const Reference< XDriver > _rxDriver, 131*cdf0e10cSrcweir const Reference< XConnection >& _xConnection ,const Reference< XMultiServiceFactory>& _xORB ) 132*cdf0e10cSrcweir :OHsqlConnection_BASE( m_aMutex ) 133*cdf0e10cSrcweir ,m_aFlushListeners( m_aMutex ) 134*cdf0e10cSrcweir ,m_xDriver( _rxDriver ) 135*cdf0e10cSrcweir ,m_xORB( _xORB ) 136*cdf0e10cSrcweir ,m_bIni(true) 137*cdf0e10cSrcweir ,m_bReadOnly(false) 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir setDelegation(_xConnection,_xORB,m_refCount); 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 142*cdf0e10cSrcweir OHsqlConnection::~OHsqlConnection() 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir if ( !OHsqlConnection_BASE::rBHelper.bDisposed ) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 147*cdf0e10cSrcweir dispose(); 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 151*cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2(OHsqlConnection,OHsqlConnection_BASE,OConnectionWrapper) 152*cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(OHsqlConnection, "com.sun.star.sdbc.drivers.hsqldb.OHsqlConnection", "com.sun.star.sdbc.Connection") 153*cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2(OHsqlConnection,OHsqlConnection_BASE,OConnectionWrapper) 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir //-------------------------------------------------------------------- 156*cdf0e10cSrcweir ::osl::Mutex& OHsqlConnection::getMutex() const 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir return m_aMutex; 159*cdf0e10cSrcweir } 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir //-------------------------------------------------------------------- 162*cdf0e10cSrcweir void OHsqlConnection::checkDisposed() const 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir ::connectivity::checkDisposed( rBHelper.bDisposed ); 165*cdf0e10cSrcweir } 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir // XFlushable 168*cdf0e10cSrcweir //-------------------------------------------------------------------- 169*cdf0e10cSrcweir void SAL_CALL OHsqlConnection::flush( ) throw (RuntimeException) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir MethodGuard aGuard( *this ); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir try 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir if ( m_xConnection.is() ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir if ( m_bIni ) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir m_bIni = false; 180*cdf0e10cSrcweir Reference< XDatabaseMetaData2 > xMeta2(m_xConnection->getMetaData(),UNO_QUERY_THROW); 181*cdf0e10cSrcweir const Sequence< PropertyValue > aInfo = xMeta2->getConnectionInfo(); 182*cdf0e10cSrcweir const PropertyValue* pIter = aInfo.getConstArray(); 183*cdf0e10cSrcweir const PropertyValue* pEnd = pIter + aInfo.getLength(); 184*cdf0e10cSrcweir for(;pIter != pEnd;++pIter) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir if ( pIter->Name.compareToAscii("readonly") == 0 ) 187*cdf0e10cSrcweir m_bReadOnly = true; 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir if ( !m_bReadOnly ) 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir Reference< XStatement > xStmt( m_xConnection->createStatement(), UNO_QUERY_THROW ); 193*cdf0e10cSrcweir xStmt->execute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CHECKPOINT" ) ) ); 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir EventObject aFlushedEvent( *this ); 198*cdf0e10cSrcweir m_aFlushListeners.notifyEach( &XFlushListener::flushed, aFlushedEvent ); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir catch(const Exception& ) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir //-------------------------------------------------------------------- 207*cdf0e10cSrcweir void SAL_CALL OHsqlConnection::addFlushListener( const Reference< XFlushListener >& l ) throw (RuntimeException) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir MethodGuard aGuard( *this ); 210*cdf0e10cSrcweir m_aFlushListeners.addInterface( l ); 211*cdf0e10cSrcweir } 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir //-------------------------------------------------------------------- 214*cdf0e10cSrcweir void SAL_CALL OHsqlConnection::removeFlushListener( const Reference< XFlushListener >& l ) throw (RuntimeException) 215*cdf0e10cSrcweir { 216*cdf0e10cSrcweir MethodGuard aGuard( *this ); 217*cdf0e10cSrcweir m_aFlushListeners.removeInterface( l ); 218*cdf0e10cSrcweir } 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir // ------------------------------------------------------------------- 221*cdf0e10cSrcweir Reference< XGraphic > SAL_CALL OHsqlConnection::getTableIcon( const ::rtl::OUString& _TableName, ::sal_Int32 _ColorMode ) throw (RuntimeException) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir MethodGuard aGuard( *this ); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir impl_checkExistingTable_throw( _TableName ); 226*cdf0e10cSrcweir if ( !impl_isTextTable_nothrow( _TableName ) ) 227*cdf0e10cSrcweir return NULL; 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir return impl_getTextTableIcon_nothrow( _ColorMode ); 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir 232*cdf0e10cSrcweir // ------------------------------------------------------------------- 233*cdf0e10cSrcweir Reference< XInterface > SAL_CALL OHsqlConnection::getTableEditor( const Reference< XDatabaseDocumentUI >& _DocumentUI, const ::rtl::OUString& _TableName ) throw (IllegalArgumentException, WrappedTargetException, RuntimeException) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir MethodGuard aGuard( *this ); 236*cdf0e10cSrcweir 237*cdf0e10cSrcweir impl_checkExistingTable_throw( _TableName ); 238*cdf0e10cSrcweir if ( !impl_isTextTable_nothrow( _TableName ) ) 239*cdf0e10cSrcweir return NULL; 240*cdf0e10cSrcweir 241*cdf0e10cSrcweir if ( !_DocumentUI.is() ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir ::connectivity::SharedResources aResources; 244*cdf0e10cSrcweir const ::rtl::OUString sError( aResources.getResourceString(STR_NO_DOCUMENTUI)); 245*cdf0e10cSrcweir throw IllegalArgumentException( 246*cdf0e10cSrcweir sError, 247*cdf0e10cSrcweir *this, 248*cdf0e10cSrcweir 0 249*cdf0e10cSrcweir ); 250*cdf0e10cSrcweir } // if ( !_DocumentUI.is() ) 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir // Reference< XExecutableDialog > xEditor = impl_createLinkedTableEditor_throw( _DocumentUI, _TableName ); 254*cdf0e10cSrcweir // return xEditor.get(); 255*cdf0e10cSrcweir return NULL; 256*cdf0e10cSrcweir // editor not yet implemented in this CWS 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir // ------------------------------------------------------------------- 260*cdf0e10cSrcweir Reference< XNameAccess > OHsqlConnection::impl_getTableContainer_throw() 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir Reference< XNameAccess > xTables; 263*cdf0e10cSrcweir try 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir Reference< XConnection > xMe( *this, UNO_QUERY ); 266*cdf0e10cSrcweir Reference< XDataDefinitionSupplier > xDefinitionsSupp( m_xDriver, UNO_QUERY_THROW ); 267*cdf0e10cSrcweir Reference< XTablesSupplier > xTablesSupp( xDefinitionsSupp->getDataDefinitionByConnection( xMe ), UNO_QUERY_THROW ); 268*cdf0e10cSrcweir xTables.set( xTablesSupp->getTables(), UNO_QUERY_THROW ); 269*cdf0e10cSrcweir } 270*cdf0e10cSrcweir catch( const RuntimeException& ) { throw; } 271*cdf0e10cSrcweir catch( const Exception& ) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir ::connectivity::SharedResources aResources; 274*cdf0e10cSrcweir const ::rtl::OUString sError( aResources.getResourceString(STR_NO_TABLE_CONTAINER)); 275*cdf0e10cSrcweir throw WrappedTargetException( sError ,*this, ::cppu::getCaughtException() ); 276*cdf0e10cSrcweir } 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir OSL_POSTCOND( xTables.is(), "OHsqlConnection::impl_getTableContainer_throw: post condition not met!" ); 279*cdf0e10cSrcweir return xTables; 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir 282*cdf0e10cSrcweir //TODO: resource 283*cdf0e10cSrcweir #if 0 284*cdf0e10cSrcweir // ------------------------------------------------------------------- 285*cdf0e10cSrcweir Reference< XExecutableDialog > OHsqlConnection::impl_createLinkedTableEditor_throw( const Reference< XDatabaseDocumentUI >& _rxDocumentUI, const ::rtl::OUString& _rTableName ) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir OSL_PRECOND( _rxDocumentUI.is(), "OHsqlConnection::impl_createLinkedTableEditor_throw: illegal document UI!" ); 288*cdf0e10cSrcweir Reference< XExecutableDialog > xDialog; 289*cdf0e10cSrcweir try 290*cdf0e10cSrcweir { 291*cdf0e10cSrcweir ::comphelper::ComponentContext aContext( m_xORB ); 292*cdf0e10cSrcweir Sequence< Any > aArguments(3); 293*cdf0e10cSrcweir aArguments[0] <<= NamedValue( 294*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TableContainer" ) ), 295*cdf0e10cSrcweir makeAny( impl_getTableContainer_throw() ) 296*cdf0e10cSrcweir ); 297*cdf0e10cSrcweir aArguments[1] <<= NamedValue( 298*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TableName" ) ), 299*cdf0e10cSrcweir makeAny( _rTableName ) 300*cdf0e10cSrcweir ); 301*cdf0e10cSrcweir aArguments[2] <<= NamedValue( 302*cdf0e10cSrcweir ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ) ), 303*cdf0e10cSrcweir makeAny( _rxDocumentUI->getApplicationMainWindow() ) 304*cdf0e10cSrcweir ); 305*cdf0e10cSrcweir 306*cdf0e10cSrcweir aContext.createComponentWithArguments( "com.sun.star.sdb.hsql.LinkedTableEditor", aArguments, xDialog ); 307*cdf0e10cSrcweir if ( !xDialog.is() ) 308*cdf0e10cSrcweir throw ServiceNotRegisteredException( ::rtl::OUString::createFromAscii( "com.sun.star.sdb.hsql.LinkedTableEditor" ), *this ); 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir catch( const RuntimeException& ) { throw; } 311*cdf0e10cSrcweir catch( const Exception& ) 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir ::connectivity::SharedResources aResources; 314*cdf0e10cSrcweir const ::rtl::OUString sError( aResources.getResourceString(STR_NO_TABLE_EDITOR_DIALOG)); 315*cdf0e10cSrcweir throw WrappedTargetException( sError ,*this, ::cppu::getCaughtException() ); 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir return xDialog; 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir #endif 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir // ------------------------------------------------------------------- 322*cdf0e10cSrcweir void OHsqlConnection::impl_checkExistingTable_throw( const ::rtl::OUString& _rTableName ) 323*cdf0e10cSrcweir { 324*cdf0e10cSrcweir bool bDoesExist = false; 325*cdf0e10cSrcweir try 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir Reference< XNameAccess > xTables( impl_getTableContainer_throw(), UNO_QUERY_THROW ); 328*cdf0e10cSrcweir if ( xTables.is() ) 329*cdf0e10cSrcweir bDoesExist = xTables->hasByName( _rTableName ); 330*cdf0e10cSrcweir } 331*cdf0e10cSrcweir catch( const Exception& ) 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir // that's a serious error in impl_getTableContainer_throw, or hasByName, however, we're only 334*cdf0e10cSrcweir // allowed to throw an IllegalArgumentException ourself 335*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir if ( !bDoesExist ) 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir ::connectivity::SharedResources aResources; 341*cdf0e10cSrcweir const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution( 342*cdf0e10cSrcweir STR_NO_TABLENAME, 343*cdf0e10cSrcweir "$tablename$", _rTableName 344*cdf0e10cSrcweir )); 345*cdf0e10cSrcweir throw IllegalArgumentException( sError,*this, 0 ); 346*cdf0e10cSrcweir } // if ( !bDoesExist ) 347*cdf0e10cSrcweir } 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir // ------------------------------------------------------------------- 350*cdf0e10cSrcweir bool OHsqlConnection::impl_isTextTable_nothrow( const ::rtl::OUString& _rTableName ) 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir bool bIsTextTable = false; 353*cdf0e10cSrcweir try 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir Reference< XConnection > xMe( *this, UNO_QUERY_THROW ); 356*cdf0e10cSrcweir 357*cdf0e10cSrcweir // split the fully qualified name 358*cdf0e10cSrcweir Reference< XDatabaseMetaData > xMetaData( xMe->getMetaData(), UNO_QUERY_THROW ); 359*cdf0e10cSrcweir ::rtl::OUString sCatalog, sSchema, sName; 360*cdf0e10cSrcweir ::dbtools::qualifiedNameComponents( xMetaData, _rTableName, sCatalog, sSchema, sName, ::dbtools::eComplete ); 361*cdf0e10cSrcweir 362*cdf0e10cSrcweir // get the table information 363*cdf0e10cSrcweir ::rtl::OUStringBuffer sSQL; 364*cdf0e10cSrcweir sSQL.appendAscii( "SELECT HSQLDB_TYPE FROM INFORMATION_SCHEMA.SYSTEM_TABLES" ); 365*cdf0e10cSrcweir HTools::appendTableFilterCrit( sSQL, sCatalog, sSchema, sName, true ); 366*cdf0e10cSrcweir sSQL.appendAscii( " AND TABLE_TYPE = 'TABLE'" ); 367*cdf0e10cSrcweir 368*cdf0e10cSrcweir Reference< XStatement > xStatement( xMe->createStatement(), UNO_QUERY_THROW ); 369*cdf0e10cSrcweir Reference< XResultSet > xTableHsqlType( xStatement->executeQuery( sSQL.makeStringAndClear() ), UNO_QUERY_THROW ); 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir if ( xTableHsqlType->next() ) // might not succeed in case of VIEWs 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir Reference< XRow > xValueAccess( xTableHsqlType, UNO_QUERY_THROW ); 374*cdf0e10cSrcweir ::rtl::OUString sTableType = xValueAccess->getString( 1 ); 375*cdf0e10cSrcweir bIsTextTable = sTableType.equalsAscii( "TEXT" ); 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir catch( const Exception& ) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir 383*cdf0e10cSrcweir return bIsTextTable; 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir // ------------------------------------------------------------------- 387*cdf0e10cSrcweir Reference< XGraphic > OHsqlConnection::impl_getTextTableIcon_nothrow( ::sal_Int32 _ColorMode ) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir Reference< XGraphic > xGraphic; 390*cdf0e10cSrcweir try 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir // create a graphic provider 393*cdf0e10cSrcweir Reference< XGraphicProvider > xProvider; 394*cdf0e10cSrcweir if ( m_xORB.is() ) 395*cdf0e10cSrcweir xProvider.set( m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) ) ), UNO_QUERY_THROW ); 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir // assemble the image URL 398*cdf0e10cSrcweir ::rtl::OUStringBuffer aImageURL; 399*cdf0e10cSrcweir aImageURL.appendAscii( "private:graphicrepository/" ); // load the graphic from the global graphic repository 400*cdf0e10cSrcweir aImageURL.appendAscii( "database/" ); // the relative path within the images.zip 401*cdf0e10cSrcweir if ( _ColorMode == GraphicColorMode::NORMAL ) 402*cdf0e10cSrcweir aImageURL.appendAscii( LINKED_TEXT_TABLE_IMAGE_RESOURCE ); 403*cdf0e10cSrcweir else 404*cdf0e10cSrcweir aImageURL.appendAscii( LINKED_TEXT_TABLE_IMAGE_RESOURCE_HC ); 405*cdf0e10cSrcweir // the name of the graphic to use 406*cdf0e10cSrcweir ::rtl::OUString sImageURL( aImageURL.makeStringAndClear() ); 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir // ask the provider to obtain a graphic 409*cdf0e10cSrcweir Sequence< PropertyValue > aMediaProperties( 1 ); 410*cdf0e10cSrcweir aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); 411*cdf0e10cSrcweir aMediaProperties[0].Value <<= sImageURL; 412*cdf0e10cSrcweir xGraphic = xProvider->queryGraphic( aMediaProperties ); 413*cdf0e10cSrcweir OSL_ENSURE( xGraphic.is(), "OHsqlConnection::impl_getTextTableIcon_nothrow: the provider did not give us a graphic object!" ); 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir catch( const Exception& ) 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir return xGraphic; 420*cdf0e10cSrcweir } 421*cdf0e10cSrcweir 422*cdf0e10cSrcweir } } // namespace connectivity::hsqldb 423