Tag: cws_dev300_odbmacros3 User: fs Date: 2008-07-23 11:43:10+0000 Modified: dba/dbaccess/source/core/dataaccess/databasecontext.cxx dba/dbaccess/source/core/dataaccess/databasecontext.hxx
Log: #i76128# allow to create un-initialized database documents File Changes: Directory: /dba/dbaccess/source/core/dataaccess/ ================================================ File [changed]: databasecontext.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasecontext.cxx?r1=1.43.4.1&r2=1.43.4.2 Delta lines: +25 -21 --------------------- --- databasecontext.cxx 2008-07-23 10:05:05+0000 1.43.4.1 +++ databasecontext.cxx 2008-07-23 11:43:07+0000 1.43.4.2 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: databasecontext.cxx,v $ - * $Revision: 1.43.4.1 $ + * $Revision: 1.43.4.2 $ * * This file is part of OpenOffice.org. * @@ -190,40 +190,44 @@ } //-------------------------------------------------------------------------- -Reference< XInterface > SAL_CALL ODatabaseContext::createInstance( ) throw (Exception, RuntimeException) +Reference< XInterface > ODatabaseContext::impl_createNewDataSource( bool _bInitialize ) { ::rtl::Reference<ODatabaseModelImpl> pImpl( new ODatabaseModelImpl( m_aContext.getLegacyServiceFactory(), *this ) ); Reference< XDataSource > xDataSource( pImpl->getOrCreateDataSource() ); - // for convenience of the API user, we ensure the document is fully initialized (effectively: XLoadable::initNew - // has been called at the DatabaseDocument). - // We delete this to the ODatabaseModelImpl, which can create and initialize the DatabaseDocument instance + // We delegate the initialization to the ODatabaseModelImpl, which can create and initialize the DatabaseDocument instance // itself. This instance is then immediately closed, since it's not needed anymore. + if ( _bInitialize ) + { ::utl::CloseableComponent aEnsureClose( pImpl->createNewModel_deliverOwnership( true ) ); + (void)aEnsureClose; + } return xDataSource.get(); } //-------------------------------------------------------------------------- +Reference< XInterface > SAL_CALL ODatabaseContext::createInstance( ) throw (Exception, RuntimeException) +{ + // for convenience of the API user, we ensure the document is fully initialized (effectively: XLoadable::initNew + // has been called at the DatabaseDocument). + return impl_createNewDataSource( true ); +} + +//-------------------------------------------------------------------------- Reference< XInterface > SAL_CALL ODatabaseContext::createInstanceWithArguments( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException) { - const Any* pIter = _rArguments.getConstArray(); - const Any* pEnd = pIter + _rArguments.getLength(); - NamedValue aValue; - Reference< XInterface > xExistent; - ::rtl::OUString sURL; - for (; pIter != pEnd; ++pIter) - { - if ( (*pIter >>= aValue) && aValue.Name == INFO_POOLURL && (aValue.Value >>= sURL) ) - { - xExistent = getObject(sURL); - break; - } - } - if ( !xExistent.is() ) - xExistent = createInstance(); + ::comphelper::NamedValueCollection aArgs( _rArguments ); + ::rtl::OUString sURL = aArgs.getOrDefault( (::rtl::OUString)INFO_POOLURL, ::rtl::OUString() ); - return xExistent; + Reference< XInterface > xDataSource; + if ( sURL.getLength() ) + xDataSource = getObject( sURL ); + + if ( !xDataSource.is() ) + xDataSource = impl_createNewDataSource( aArgs.getOrDefault( "InitializeDocument", true )); + + return xDataSource; } // DatabaseAccessContext_Base //------------------------------------------------------------------------------ File [changed]: databasecontext.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/databasecontext.hxx?r1=1.17&r2=1.17.2.1 Delta lines: +7 -2 ------------------- --- databasecontext.hxx 2008-04-10 12:44:21+0000 1.17 +++ databasecontext.hxx 2008-07-23 11:43:07+0000 1.17.2.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: databasecontext.hxx,v $ - * $Revision: 1.17 $ + * $Revision: 1.17.2.1 $ * * This file is part of OpenOffice.org. * @@ -138,6 +138,11 @@ */ void setTransientProperties(const ::rtl::OUString& _sURL, ODatabaseModelImpl& _rDataSourceModel ); + /** creates a new data source + */ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + impl_createNewDataSource( bool _bInitialize ); + protected: ::osl::Mutex m_aMutex; ::comphelper::ComponentContext m_aContext; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
