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