diff options
author | Noel Grandin <noel@peralex.com> | 2012-12-03 16:33:30 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2012-12-10 08:05:53 +0200 |
commit | 24f0aa76c005d1506a6d13945c39dafc6e9b8d91 (patch) | |
tree | de84b05444d3436ed107bc4fb7d3522284e69529 /dbaccess | |
parent | b9a4a0b9658015a0d55c42de1f5e56941e20d268 (diff) |
fdo#46808, use service constructor for embed::StorageFactory
Change-Id: I26cd1cf86118122f392f16801a646df753a7df26
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/core/dataaccess/ModelImpl.cxx | 58 | ||||
-rw-r--r-- | dbaccess/source/core/dataaccess/databasedocument.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/filter/xml/dbloader2.cxx | 4 |
3 files changed, 31 insertions, 33 deletions
diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index de74b4fc9648..01546faa25e6 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/frame/GlobalEventBroadcaster.hpp> #include <com/sun/star/embed/XTransactedObject.hpp> #include <com/sun/star/embed/XTransactionBroadcaster.hpp> +#include <com/sun/star/embed/StorageFactory.hpp> #include <com/sun/star/sdb/BooleanComparisonMode.hpp> #include <com/sun/star/script/DocumentScriptLibraryContainer.hpp> #include <com/sun/star/script/DocumentDialogLibraryContainer.hpp> @@ -816,7 +817,7 @@ void ODatabaseModelImpl::disposeStorages() SAL_THROW(()) Reference< XSingleServiceFactory > ODatabaseModelImpl::createStorageFactory() const { - return Reference< XSingleServiceFactory >( m_aContext.createComponent( "com.sun.star.embed.StorageFactory" ), UNO_QUERY_THROW ); + return StorageFactory::create( m_aContext.getUNOContext() ); } void ODatabaseModelImpl::commitRootStorage() @@ -834,46 +835,43 @@ Reference< XStorage > ODatabaseModelImpl::getOrCreateRootStorage() { if ( !m_xDocumentStorage.is() ) { - Reference< XSingleServiceFactory> xStorageFactory = createStorageFactory(); - if ( xStorageFactory.is() ) + Reference< XSingleServiceFactory> xStorageFactory = StorageFactory::create( m_aContext.getUNOContext() ); + Any aSource; + aSource = m_aMediaDescriptor.get( "Stream" ); + if ( !aSource.hasValue() ) + aSource = m_aMediaDescriptor.get( "InputStream" ); + if ( !aSource.hasValue() && !m_sDocFileLocation.isEmpty() ) + aSource <<= m_sDocFileLocation; + // TODO: shouldn't we also check URL? + + OSL_ENSURE( aSource.hasValue(), "ODatabaseModelImpl::getOrCreateRootStorage: no source to create the storage from!" ); + + if ( aSource.hasValue() ) { - Any aSource; - aSource = m_aMediaDescriptor.get( "Stream" ); - if ( !aSource.hasValue() ) - aSource = m_aMediaDescriptor.get( "InputStream" ); - if ( !aSource.hasValue() && !m_sDocFileLocation.isEmpty() ) - aSource <<= m_sDocFileLocation; - // TODO: shouldn't we also check URL? + Sequence< Any > aStorageCreationArgs(2); + aStorageCreationArgs[0] = aSource; + aStorageCreationArgs[1] <<= ElementModes::READWRITE; - OSL_ENSURE( aSource.hasValue(), "ODatabaseModelImpl::getOrCreateRootStorage: no source to create the storage from!" ); - - if ( aSource.hasValue() ) + Reference< XStorage > xDocumentStorage; + try { - Sequence< Any > aStorageCreationArgs(2); - aStorageCreationArgs[0] = aSource; - aStorageCreationArgs[1] <<= ElementModes::READWRITE; - - Reference< XStorage > xDocumentStorage; + xDocumentStorage.set( xStorageFactory->createInstanceWithArguments( aStorageCreationArgs ), UNO_QUERY_THROW ); + } + catch( const Exception& ) + { + m_bDocumentReadOnly = sal_True; + aStorageCreationArgs[1] <<= ElementModes::READ; try { xDocumentStorage.set( xStorageFactory->createInstanceWithArguments( aStorageCreationArgs ), UNO_QUERY_THROW ); } catch( const Exception& ) { - m_bDocumentReadOnly = sal_True; - aStorageCreationArgs[1] <<= ElementModes::READ; - try - { - xDocumentStorage.set( xStorageFactory->createInstanceWithArguments( aStorageCreationArgs ), UNO_QUERY_THROW ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } + DBG_UNHANDLED_EXCEPTION(); } - - impl_switchToStorage_throw( xDocumentStorage ); } + + impl_switchToStorage_throw( xDocumentStorage ); } } return m_xDocumentStorage.getTyped(); diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index d17291a7f222..ece5bc465e82 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -538,7 +538,7 @@ void SAL_CALL ODatabaseDocument::initNew( ) throw (DoubleInitializationExceptio // create a temporary storage Reference< XStorage > xTempStor( ::comphelper::OStorageHelper::GetTemporaryStorage( - m_pImpl->m_aContext.getLegacyServiceFactory() ) ); + m_pImpl->m_aContext.getUNOContext() ) ); // store therein impl_storeToStorage_throw( xTempStor, Sequence< PropertyValue >(), aGuard ); diff --git a/dbaccess/source/filter/xml/dbloader2.cxx b/dbaccess/source/filter/xml/dbloader2.cxx index 5d6db822038b..e75835cc66bb 100644 --- a/dbaccess/source/filter/xml/dbloader2.cxx +++ b/dbaccess/source/filter/xml/dbloader2.cxx @@ -136,7 +136,7 @@ DBTypeDetection::DBTypeDetection(const Reference< XMultiServiceFactory >& _rxFac { bStreamFromDescr = sal_True; xStorageProperties.set( ::comphelper::OStorageHelper::GetStorageFromInputStream( - xInStream, m_aContext.getLegacyServiceFactory() ), UNO_QUERY ); + xInStream, m_aContext.getUNOContext() ), UNO_QUERY ); } else { @@ -146,7 +146,7 @@ DBTypeDetection::DBTypeDetection(const Reference< XMultiServiceFactory >& _rxFac if ( !sFileLocation.isEmpty() ) { xStorageProperties.set( ::comphelper::OStorageHelper::GetStorageFromURL( - sFileLocation, ElementModes::READ, m_aContext.getLegacyServiceFactory() ), UNO_QUERY ); + sFileLocation, ElementModes::READ, m_aContext.getUNOContext() ), UNO_QUERY ); } } |