19b5730f6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 39b5730f6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 49b5730f6SAndrew Rist * or more contributor license agreements. See the NOTICE file 59b5730f6SAndrew Rist * distributed with this work for additional information 69b5730f6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 79b5730f6SAndrew Rist * to you under the Apache License, Version 2.0 (the 89b5730f6SAndrew Rist * "License"); you may not use this file except in compliance 99b5730f6SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 119b5730f6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 139b5730f6SAndrew Rist * Unless required by applicable law or agreed to in writing, 149b5730f6SAndrew Rist * software distributed under the License is distributed on an 159b5730f6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169b5730f6SAndrew Rist * KIND, either express or implied. See the License for the 179b5730f6SAndrew Rist * specific language governing permissions and limitations 189b5730f6SAndrew Rist * under the License. 19cdf0e10cSrcweir * 209b5730f6SAndrew Rist *************************************************************/ 219b5730f6SAndrew Rist 229b5730f6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_connectivity.hxx" 26cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 27cdf0e10cSrcweir #include "file/FConnection.hxx" 28cdf0e10cSrcweir #include "file/FDatabaseMetaData.hxx" 29cdf0e10cSrcweir #include "file/FDriver.hxx" 30cdf0e10cSrcweir #include "file/FStatement.hxx" 31cdf0e10cSrcweir #include "file/FPreparedStatement.hxx" 32cdf0e10cSrcweir #include <com/sun/star/sdbc/ColumnValue.hpp> 33cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp> 34cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp> 35cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 36cdf0e10cSrcweir #include <com/sun/star/ucb/XContent.hpp> 37cdf0e10cSrcweir #include <com/sun/star/ucb/XContentIdentifier.hpp> 38cdf0e10cSrcweir #include <tools/urlobj.hxx> 39cdf0e10cSrcweir #include "file/FCatalog.hxx" 40cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 41cdf0e10cSrcweir #include <ucbhelper/content.hxx> 42cdf0e10cSrcweir #include <connectivity/dbcharset.hxx> 43cdf0e10cSrcweir #include <connectivity/dbexception.hxx> 44cdf0e10cSrcweir #include <osl/thread.h> 45cdf0e10cSrcweir #include <osl/nlsupport.h> 46cdf0e10cSrcweir #include "resource/file_res.hrc" 47cdf0e10cSrcweir 48cdf0e10cSrcweir using namespace connectivity::file; 49cdf0e10cSrcweir using namespace dbtools; 50cdf0e10cSrcweir //------------------------------------------------------------------------------ 51cdf0e10cSrcweir using namespace com::sun::star::uno; 52cdf0e10cSrcweir using namespace com::sun::star::lang; 53cdf0e10cSrcweir using namespace com::sun::star::beans; 54cdf0e10cSrcweir using namespace com::sun::star::sdbc; 55cdf0e10cSrcweir using namespace com::sun::star::sdbcx; 56cdf0e10cSrcweir using namespace com::sun::star::container; 57cdf0e10cSrcweir using namespace com::sun::star::ucb; 58cdf0e10cSrcweir using namespace ::ucbhelper; 59cdf0e10cSrcweir using rtl::OUString; 60cdf0e10cSrcweir typedef connectivity::OMetaConnection OConnection_BASE; 61cdf0e10cSrcweir // -------------------------------------------------------------------------------- 62cdf0e10cSrcweir OConnection::OConnection(OFileDriver* _pDriver) 63cdf0e10cSrcweir : OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this) 64cdf0e10cSrcweir ,m_pDriver(_pDriver) 65cdf0e10cSrcweir ,m_bClosed(sal_False) 66cdf0e10cSrcweir ,m_bShowDeleted(sal_False) 67cdf0e10cSrcweir ,m_bCaseSensitiveExtension( sal_True ) 68cdf0e10cSrcweir ,m_bCheckSQL92(sal_False) 69cdf0e10cSrcweir ,m_bDefaultTextEncoding(false) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir m_nTextEncoding = RTL_TEXTENCODING_DONTKNOW; 72cdf0e10cSrcweir } 73cdf0e10cSrcweir //----------------------------------------------------------------------------- 74cdf0e10cSrcweir OConnection::~OConnection() 75cdf0e10cSrcweir { 76cdf0e10cSrcweir if(!isClosed( )) 77cdf0e10cSrcweir close(); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir //----------------------------------------------------------------------------- 80cdf0e10cSrcweir void SAL_CALL OConnection::release() throw() 81cdf0e10cSrcweir { 82cdf0e10cSrcweir relase_ChildImpl(); 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir //----------------------------------------------------------------------------- 86cdf0e10cSrcweir sal_Bool OConnection::matchesExtension( const String& _rExt ) const 87cdf0e10cSrcweir { 88cdf0e10cSrcweir if ( isCaseSensitveExtension() ) 89cdf0e10cSrcweir return ( getExtension() == _rExt ); 90cdf0e10cSrcweir 91cdf0e10cSrcweir String sMyExtension( getExtension() ); 92cdf0e10cSrcweir sMyExtension.ToLowerAscii(); 93cdf0e10cSrcweir String sExt( _rExt ); 94cdf0e10cSrcweir sExt.ToLowerAscii(); 95cdf0e10cSrcweir 96cdf0e10cSrcweir return sMyExtension == sExt; 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 99cdf0e10cSrcweir //----------------------------------------------------------------------------- 100cdf0e10cSrcweir void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir osl_incrementInterlockedCount( &m_refCount ); 103cdf0e10cSrcweir 104cdf0e10cSrcweir ::rtl::OUString aExt; 105cdf0e10cSrcweir const PropertyValue *pIter = info.getConstArray(); 106cdf0e10cSrcweir const PropertyValue *pEnd = pIter + info.getLength(); 107cdf0e10cSrcweir for(;pIter != pEnd;++pIter) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir if(0 == pIter->Name.compareToAscii("Extension")) 110cdf0e10cSrcweir OSL_VERIFY( pIter->Value >>= aExt ); 111cdf0e10cSrcweir else if(0 == pIter->Name.compareToAscii("CharSet")) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir ::rtl::OUString sIanaName; 114cdf0e10cSrcweir OSL_VERIFY( pIter->Value >>= sIanaName ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir ::dbtools::OCharsetMap aLookupIanaName; 117cdf0e10cSrcweir ::dbtools::OCharsetMap::const_iterator aLookup = aLookupIanaName.find(sIanaName, ::dbtools::OCharsetMap::IANA()); 118cdf0e10cSrcweir if (aLookup != aLookupIanaName.end()) 119cdf0e10cSrcweir m_nTextEncoding = (*aLookup).getEncoding(); 120cdf0e10cSrcweir else 121cdf0e10cSrcweir m_nTextEncoding = RTL_TEXTENCODING_DONTKNOW; 122cdf0e10cSrcweir } 123cdf0e10cSrcweir else if (0 == pIter->Name.compareToAscii("ShowDeleted")) 124cdf0e10cSrcweir { 125cdf0e10cSrcweir OSL_VERIFY( pIter->Value >>= m_bShowDeleted ); 126cdf0e10cSrcweir } 127cdf0e10cSrcweir else if (0 == pIter->Name.compareToAscii("EnableSQL92Check")) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir pIter->Value >>= m_bCheckSQL92; 130cdf0e10cSrcweir } 131cdf0e10cSrcweir } // for(;pIter != pEnd;++pIter) 132cdf0e10cSrcweir 133cdf0e10cSrcweir { 134cdf0e10cSrcweir sal_Int32 nLen = url.indexOf(':'); 135cdf0e10cSrcweir nLen = url.indexOf(':',nLen+1); 136cdf0e10cSrcweir ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD; 137cdf0e10cSrcweir 138cdf0e10cSrcweir String aFileName = aDSN; 139cdf0e10cSrcweir INetURLObject aURL; 140cdf0e10cSrcweir aURL.SetSmartProtocol(INET_PROT_FILE); 141cdf0e10cSrcweir { 142cdf0e10cSrcweir SvtPathOptions aPathOptions; 143cdf0e10cSrcweir aFileName = aPathOptions.SubstituteVariable(aFileName); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 146cdf0e10cSrcweir aURL.SetSmartURL(aFileName); 147cdf0e10cSrcweir 148cdf0e10cSrcweir setURL(aURL.GetMainURL(INetURLObject::NO_DECODE)); 149cdf0e10cSrcweir } 150cdf0e10cSrcweir 151cdf0e10cSrcweir if ( m_nTextEncoding == RTL_TEXTENCODING_DONTKNOW ) 152cdf0e10cSrcweir { 153cdf0e10cSrcweir //m_nTextEncoding = osl_getTextEncodingFromLocale(NULL); 154cdf0e10cSrcweir m_nTextEncoding = osl_getThreadTextEncoding(); 155cdf0e10cSrcweir m_bDefaultTextEncoding = true; 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir if ( aExt.getLength() ) 159cdf0e10cSrcweir m_aFilenameExtension = aExt; 160cdf0e10cSrcweir 161cdf0e10cSrcweir try 162cdf0e10cSrcweir { 163cdf0e10cSrcweir ::ucbhelper::Content aFile; 164cdf0e10cSrcweir try 165cdf0e10cSrcweir { 166cdf0e10cSrcweir aFile = ::ucbhelper::Content(getURL(),Reference< XCommandEnvironment >()); 167cdf0e10cSrcweir } 168cdf0e10cSrcweir catch(ContentCreationException& e) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir throwUrlNotValid(getURL(),e.Message); 171cdf0e10cSrcweir } 172cdf0e10cSrcweir 173cdf0e10cSrcweir // set fields to fetch 174cdf0e10cSrcweir Sequence< OUString > aProps(1); 175cdf0e10cSrcweir OUString* pProps = aProps.getArray(); 176cdf0e10cSrcweir pProps[ 0 ] = OUString::createFromAscii( "Title" ); 177cdf0e10cSrcweir 178cdf0e10cSrcweir try 179cdf0e10cSrcweir { 180cdf0e10cSrcweir if (aFile.isFolder()) 181cdf0e10cSrcweir { 182cdf0e10cSrcweir m_xDir = aFile.createDynamicCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ); 183cdf0e10cSrcweir m_xContent = aFile.get(); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir else if (aFile.isDocument()) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir Reference<XContent> xParent(Reference<XChild>(aFile.get(),UNO_QUERY)->getParent(),UNO_QUERY); 188cdf0e10cSrcweir Reference<XContentIdentifier> xIdent = xParent->getIdentifier(); 189cdf0e10cSrcweir m_xContent = xParent; 190cdf0e10cSrcweir 191cdf0e10cSrcweir ::ucbhelper::Content aParent(xIdent->getContentIdentifier(),Reference< XCommandEnvironment >()); 192cdf0e10cSrcweir m_xDir = aParent.createDynamicCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ); 193cdf0e10cSrcweir } 194cdf0e10cSrcweir else 195cdf0e10cSrcweir { 196*2c64eeb8Sdamjan OSL_ENSURE(0,"OConnection::construct: ::ucbhelper::Content is neither a folder nor a document! How's that?!"); 197cdf0e10cSrcweir throw SQLException(); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir } 200*2c64eeb8Sdamjan catch(Exception& e) // an exception is thrown when no file exists 201cdf0e10cSrcweir { 202cdf0e10cSrcweir throwUrlNotValid(getURL(),e.Message); 203cdf0e10cSrcweir } 204cdf0e10cSrcweir if(!m_xDir.is() || !m_xContent.is()) 205cdf0e10cSrcweir throwUrlNotValid(getURL(),::rtl::OUString()); 206cdf0e10cSrcweir 207cdf0e10cSrcweir if (m_aFilenameExtension.Search('*') != STRING_NOTFOUND || m_aFilenameExtension.Search('?') != STRING_NOTFOUND) 208cdf0e10cSrcweir throw SQLException(); 209cdf0e10cSrcweir } 210cdf0e10cSrcweir catch(const Exception&) 211cdf0e10cSrcweir { 212cdf0e10cSrcweir osl_decrementInterlockedCount( &m_refCount ); 213cdf0e10cSrcweir throw; 214cdf0e10cSrcweir } 215cdf0e10cSrcweir 216cdf0e10cSrcweir osl_decrementInterlockedCount( &m_refCount ); 217cdf0e10cSrcweir } 218cdf0e10cSrcweir // XServiceInfo 219cdf0e10cSrcweir // -------------------------------------------------------------------------------- 220cdf0e10cSrcweir IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.file.Connection", "com.sun.star.sdbc.Connection") 221cdf0e10cSrcweir 222cdf0e10cSrcweir // -------------------------------------------------------------------------------- 223cdf0e10cSrcweir Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 226cdf0e10cSrcweir checkDisposed(OConnection_BASE::rBHelper.bDisposed); 227cdf0e10cSrcweir 228cdf0e10cSrcweir 229cdf0e10cSrcweir Reference< XStatement > xReturn = new OStatement(this); 230cdf0e10cSrcweir m_aStatements.push_back(WeakReferenceHelper(xReturn)); 231cdf0e10cSrcweir return xReturn; 232cdf0e10cSrcweir } 233cdf0e10cSrcweir // -------------------------------------------------------------------------------- 234cdf0e10cSrcweir Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) 235cdf0e10cSrcweir { 236cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 237cdf0e10cSrcweir checkDisposed(OConnection_BASE::rBHelper.bDisposed); 238cdf0e10cSrcweir 239cdf0e10cSrcweir 240cdf0e10cSrcweir OPreparedStatement* pStmt = new OPreparedStatement(this); 241cdf0e10cSrcweir Reference< XPreparedStatement > xHoldAlive = pStmt; 242cdf0e10cSrcweir pStmt->construct(sql); 243cdf0e10cSrcweir m_aStatements.push_back(WeakReferenceHelper(*pStmt)); 244cdf0e10cSrcweir return pStmt; 245cdf0e10cSrcweir } 246cdf0e10cSrcweir // -------------------------------------------------------------------------------- 247cdf0e10cSrcweir Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir throwFeatureNotImplementedException( "XConnection::prepareCall", *this ); 250cdf0e10cSrcweir return NULL; 251cdf0e10cSrcweir } 252cdf0e10cSrcweir // -------------------------------------------------------------------------------- 253cdf0e10cSrcweir ::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir return sql; 256cdf0e10cSrcweir } 257cdf0e10cSrcweir // -------------------------------------------------------------------------------- 258cdf0e10cSrcweir void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 261cdf0e10cSrcweir checkDisposed(OConnection_BASE::rBHelper.bDisposed); 262cdf0e10cSrcweir 263cdf0e10cSrcweir m_bAutoCommit = autoCommit; 264cdf0e10cSrcweir } 265cdf0e10cSrcweir // -------------------------------------------------------------------------------- 266cdf0e10cSrcweir sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException) 267cdf0e10cSrcweir { 268cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 269cdf0e10cSrcweir checkDisposed(OConnection_BASE::rBHelper.bDisposed); 270cdf0e10cSrcweir 271cdf0e10cSrcweir return m_bAutoCommit; 272cdf0e10cSrcweir } 273cdf0e10cSrcweir // -------------------------------------------------------------------------------- 274cdf0e10cSrcweir void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException) 275cdf0e10cSrcweir { 276cdf0e10cSrcweir } 277cdf0e10cSrcweir // -------------------------------------------------------------------------------- 278cdf0e10cSrcweir void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir } 281cdf0e10cSrcweir // -------------------------------------------------------------------------------- 282cdf0e10cSrcweir sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 285cdf0e10cSrcweir 286cdf0e10cSrcweir return OConnection_BASE::rBHelper.bDisposed; 287cdf0e10cSrcweir } 288cdf0e10cSrcweir // -------------------------------------------------------------------------------- 289cdf0e10cSrcweir Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 292cdf0e10cSrcweir checkDisposed(OConnection_BASE::rBHelper.bDisposed); 293cdf0e10cSrcweir 294cdf0e10cSrcweir 295cdf0e10cSrcweir Reference< XDatabaseMetaData > xMetaData = m_xMetaData; 296cdf0e10cSrcweir if(!xMetaData.is()) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir xMetaData = new ODatabaseMetaData(this); 299cdf0e10cSrcweir m_xMetaData = xMetaData; 300cdf0e10cSrcweir } 301cdf0e10cSrcweir 302cdf0e10cSrcweir return xMetaData; 303cdf0e10cSrcweir } 304cdf0e10cSrcweir // -------------------------------------------------------------------------------- 305cdf0e10cSrcweir void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 308cdf0e10cSrcweir checkDisposed(OConnection_BASE::rBHelper.bDisposed); 309cdf0e10cSrcweir 310cdf0e10cSrcweir 311cdf0e10cSrcweir m_bReadOnly = readOnly; 312cdf0e10cSrcweir } 313cdf0e10cSrcweir // -------------------------------------------------------------------------------- 314cdf0e10cSrcweir sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 317cdf0e10cSrcweir checkDisposed(OConnection_BASE::rBHelper.bDisposed); 318cdf0e10cSrcweir 319cdf0e10cSrcweir 320cdf0e10cSrcweir return m_bReadOnly; 321cdf0e10cSrcweir } 322cdf0e10cSrcweir // -------------------------------------------------------------------------------- 323cdf0e10cSrcweir void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& /*catalog*/ ) throw(SQLException, RuntimeException) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir throwFeatureNotImplementedException( "XConnection::setCatalog", *this ); 326cdf0e10cSrcweir } 327cdf0e10cSrcweir // -------------------------------------------------------------------------------- 328cdf0e10cSrcweir ::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir return ::rtl::OUString(); 331cdf0e10cSrcweir } 332cdf0e10cSrcweir // -------------------------------------------------------------------------------- 333cdf0e10cSrcweir void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir throwFeatureNotImplementedException( "XConnection::setTransactionIsolation", *this ); 336cdf0e10cSrcweir } 337cdf0e10cSrcweir // -------------------------------------------------------------------------------- 338cdf0e10cSrcweir sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir return 0; 341cdf0e10cSrcweir } 342cdf0e10cSrcweir // -------------------------------------------------------------------------------- 343cdf0e10cSrcweir Reference< XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir return NULL; 346cdf0e10cSrcweir } 347cdf0e10cSrcweir // -------------------------------------------------------------------------------- 348cdf0e10cSrcweir void SAL_CALL OConnection::setTypeMap( const Reference< XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException) 349cdf0e10cSrcweir { 350cdf0e10cSrcweir } 351cdf0e10cSrcweir // -------------------------------------------------------------------------------- 352cdf0e10cSrcweir // XCloseable 353cdf0e10cSrcweir void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException) 354cdf0e10cSrcweir { 355cdf0e10cSrcweir { 356cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 357cdf0e10cSrcweir checkDisposed(OConnection_BASE::rBHelper.bDisposed); 358cdf0e10cSrcweir 359cdf0e10cSrcweir } 360cdf0e10cSrcweir dispose(); 361cdf0e10cSrcweir } 362cdf0e10cSrcweir // -------------------------------------------------------------------------------- 363cdf0e10cSrcweir // XWarningsSupplier 364cdf0e10cSrcweir Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException) 365cdf0e10cSrcweir { 366cdf0e10cSrcweir return Any(); 367cdf0e10cSrcweir } 368cdf0e10cSrcweir // -------------------------------------------------------------------------------- 369cdf0e10cSrcweir void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException) 370cdf0e10cSrcweir { 371cdf0e10cSrcweir } 372cdf0e10cSrcweir //------------------------------------------------------------------------------ 373cdf0e10cSrcweir void OConnection::disposing() 374cdf0e10cSrcweir { 375cdf0e10cSrcweir ::osl::MutexGuard aGuard(m_aMutex); 376cdf0e10cSrcweir OConnection_BASE::disposing(); 377cdf0e10cSrcweir 378cdf0e10cSrcweir m_bClosed = sal_True; 379cdf0e10cSrcweir m_xDir.clear(); 380cdf0e10cSrcweir m_xContent.clear(); 381cdf0e10cSrcweir m_xCatalog = WeakReference< XTablesSupplier>(); 382cdf0e10cSrcweir 383cdf0e10cSrcweir dispose_ChildImpl(); 384cdf0e10cSrcweir } 385cdf0e10cSrcweir //------------------------------------------------------------------------------ 386cdf0e10cSrcweir Reference< XTablesSupplier > OConnection::createCatalog() 387cdf0e10cSrcweir { 388cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 389cdf0e10cSrcweir Reference< XTablesSupplier > xTab = m_xCatalog; 390cdf0e10cSrcweir if(!xTab.is()) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir xTab = new OFileCatalog(this); 393cdf0e10cSrcweir m_xCatalog = xTab; 394cdf0e10cSrcweir } 395cdf0e10cSrcweir return xTab; 396cdf0e10cSrcweir } 397cdf0e10cSrcweir // ----------------------------------------------------------------------------- 398cdf0e10cSrcweir Reference< XDynamicResultSet > OConnection::getDir() const 399cdf0e10cSrcweir { 400cdf0e10cSrcweir Reference<XDynamicResultSet> xContent; 401cdf0e10cSrcweir Sequence< ::rtl::OUString > aProps(1); 402cdf0e10cSrcweir ::rtl::OUString* pProps = aProps.getArray(); 403cdf0e10cSrcweir pProps[ 0 ] = ::rtl::OUString::createFromAscii( "Title" ); 404cdf0e10cSrcweir try 405cdf0e10cSrcweir { 406cdf0e10cSrcweir Reference<XContentIdentifier> xIdent = getContent()->getIdentifier(); 407cdf0e10cSrcweir ::ucbhelper::Content aParent(xIdent->getContentIdentifier(),Reference< XCommandEnvironment >()); 408cdf0e10cSrcweir xContent = aParent.createDynamicCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY ); 409cdf0e10cSrcweir } 410cdf0e10cSrcweir catch(Exception&) 411cdf0e10cSrcweir { 412cdf0e10cSrcweir } 413cdf0e10cSrcweir return xContent; 414cdf0e10cSrcweir } 415cdf0e10cSrcweir // ----------------------------------------------------------------------------- 416cdf0e10cSrcweir sal_Int64 SAL_CALL OConnection::getSomething( const Sequence< sal_Int8 >& rId ) throw (RuntimeException) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) 419cdf0e10cSrcweir ? reinterpret_cast< sal_Int64 >( this ) 420cdf0e10cSrcweir : (sal_Int64)0; 421cdf0e10cSrcweir } 422cdf0e10cSrcweir // ----------------------------------------------------------------------------- 423cdf0e10cSrcweir Sequence< sal_Int8 > OConnection::getUnoTunnelImplementationId() 424cdf0e10cSrcweir { 425cdf0e10cSrcweir static ::cppu::OImplementationId * pId = 0; 426cdf0e10cSrcweir if (! pId) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); 429cdf0e10cSrcweir if (! pId) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir static ::cppu::OImplementationId aId; 432cdf0e10cSrcweir pId = &aId; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir } 435cdf0e10cSrcweir return pId->getImplementationId(); 436cdf0e10cSrcweir } 437cdf0e10cSrcweir // ----------------------------------------------------------------------------- 438cdf0e10cSrcweir void OConnection::throwUrlNotValid(const ::rtl::OUString & _rsUrl,const ::rtl::OUString & _rsMessage) 439cdf0e10cSrcweir { 440cdf0e10cSrcweir SQLException aError; 441cdf0e10cSrcweir aError.Message = getResources().getResourceStringWithSubstitution( 442cdf0e10cSrcweir STR_NO_VALID_FILE_URL, 443cdf0e10cSrcweir "$URL$", _rsUrl 444cdf0e10cSrcweir ); 445cdf0e10cSrcweir 446cdf0e10cSrcweir aError.SQLState = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")); 447cdf0e10cSrcweir aError.ErrorCode = 0; 448cdf0e10cSrcweir aError.Context = static_cast< XConnection* >(this); 449cdf0e10cSrcweir if (_rsMessage.getLength()) 450cdf0e10cSrcweir aError.NextException <<= SQLException(_rsMessage, aError.Context, ::rtl::OUString(), 0, Any()); 451cdf0e10cSrcweir 452cdf0e10cSrcweir throw aError; 453cdf0e10cSrcweir } 454cdf0e10cSrcweir // ----------------------------------------------------------------------------- 455cdf0e10cSrcweir 456cdf0e10cSrcweir 457cdf0e10cSrcweir 458