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