diff options
26 files changed, 263 insertions, 329 deletions
diff --git a/chart2/source/model/filter/XMLFilter.cxx b/chart2/source/model/filter/XMLFilter.cxx index 10a565a7338e..c832d4a41d6a 100644 --- a/chart2/source/model/filter/XMLFilter.cxx +++ b/chart2/source/model/filter/XMLFilter.cxx @@ -43,6 +43,7 @@ #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/embed/StorageFactory.hpp> #include <com/sun/star/embed/XTransactedObject.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> @@ -101,10 +102,7 @@ uno::Reference< embed::XStorage > lcl_getWriteStorage( } else { - Reference< lang::XSingleServiceFactory > xStorageFact( - xContext->getServiceManager()->createInstanceWithContext( - C2U("com.sun.star.embed.StorageFactory"), - xContext ), uno::UNO_QUERY_THROW ); + Reference< lang::XSingleServiceFactory > xStorageFact( embed::StorageFactory::create( xContext ) ); ::std::vector< beans::PropertyValue > aPropertiesForStorage; @@ -188,11 +186,7 @@ uno::Reference< embed::XStorage > lcl_getReadStorage( return xStorage; // convert XInputStream to XStorage via the storage factory - Reference< lang::XSingleServiceFactory > xStorageFact( - xContext->getServiceManager()->createInstanceWithContext( - C2U("com.sun.star.embed.StorageFactory"), - xContext ), - uno::UNO_QUERY_THROW ); + Reference< lang::XSingleServiceFactory > xStorageFact( embed::StorageFactory::create( xContext ) ); Sequence< uno::Any > aStorageArgs( 3 ); aStorageArgs[0] <<= xStream; aStorageArgs[1] <<= (embed::ElementModes::READ | embed::ElementModes::NOCREATE); diff --git a/chart2/source/model/main/ChartModel_Persistence.cxx b/chart2/source/model/main/ChartModel_Persistence.cxx index 1e4d1f4264f5..0e638ece1c15 100644 --- a/chart2/source/model/main/ChartModel_Persistence.cxx +++ b/chart2/source/model/main/ChartModel_Persistence.cxx @@ -37,6 +37,7 @@ #include <com/sun/star/drawing/ProjectionMode.hpp> #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/embed/StorageFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <com/sun/star/uno/XComponentContext.hpp> @@ -118,11 +119,7 @@ Reference< embed::XStorage > lcl_createStorage( ::ucbhelper::Content( rURL, Reference< ::com::sun::star::ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext()).openStream(), uno::UNO_QUERY ); - Reference< lang::XSingleServiceFactory > xStorageFact( - xContext->getServiceManager()->createInstanceWithContext( - C2U("com.sun.star.embed.StorageFactory"), - xContext ), - uno::UNO_QUERY_THROW ); + Reference< lang::XSingleServiceFactory > xStorageFact( embed::StorageFactory::create( xContext ) ); Sequence< uno::Any > aStorageArgs( 3 ); aStorageArgs[0] <<= xStream; aStorageArgs[1] <<= embed::ElementModes::READWRITE; @@ -311,13 +308,12 @@ void SAL_CALL ChartModel::storeToURL( { if( m_xContext.is() && aMediaDescriptorHelper.ISSET_OutputStream ) { - Reference< lang::XMultiServiceFactory > xFact( m_xContext->getServiceManager(), uno::UNO_QUERY_THROW ); Reference< io::XStream > xStream( io::TempFile::create(m_xContext), uno::UNO_QUERY_THROW ); Reference< io::XInputStream > xInputStream( xStream->getInputStream()); Reference< embed::XStorage > xStorage( - ::comphelper::OStorageHelper::GetStorageFromStream( xStream, embed::ElementModes::READWRITE, xFact )); + ::comphelper::OStorageHelper::GetStorageFromStream( xStream, embed::ElementModes::READWRITE, m_xContext )); if( xStorage.is()) { impl_store( aReducedMediaDescriptor, xStorage ); @@ -528,11 +524,7 @@ void SAL_CALL ChartModel::load( return; } - Reference< lang::XSingleServiceFactory > xStorageFact( - m_xContext->getServiceManager()->createInstanceWithContext( - C2U("com.sun.star.embed.StorageFactory"), - m_xContext ), - uno::UNO_QUERY_THROW ); + Reference< lang::XSingleServiceFactory > xStorageFact( embed::StorageFactory::create(m_xContext) ); if( aMDHelper.ISSET_Stream ) { diff --git a/comphelper/inc/comphelper/storagehelper.hxx b/comphelper/inc/comphelper/storagehelper.hxx index f26f997cc2f3..e98a40727688 100644 --- a/comphelper/inc/comphelper/storagehelper.hxx +++ b/comphelper/inc/comphelper/storagehelper.hxx @@ -71,8 +71,8 @@ class COMPHELPER_DLLPUBLIC OStorageHelper public: static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > GetStorageFactory( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSF - = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() ) + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext + = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() ) throw ( ::com::sun::star::uno::Exception ); static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > @@ -83,8 +83,8 @@ public: static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetTemporaryStorage( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory - = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() ) + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext + = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() ) throw ( ::com::sun::star::uno::Exception ); /// this one will only return Storage @@ -92,8 +92,8 @@ public: GetStorageFromURL( const ::rtl::OUString& aURL, sal_Int32 nStorageMode, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory - = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() ) + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xrxContext + = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() ) throw ( ::com::sun::star::uno::Exception ); /// this one will return either Storage or FileSystemStorage @@ -109,16 +109,16 @@ public: static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetStorageFromInputStream( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >& xStream, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory - = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() ) + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext + = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() ) throw ( ::com::sun::star::uno::Exception ); static ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > GetStorageFromStream( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream >& xStream, sal_Int32 nStorageMode = ::com::sun::star::embed::ElementModes::READWRITE, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory - = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >() ) + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext + = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() ) throw ( ::com::sun::star::uno::Exception ); static void CopyInputToOutput( @@ -147,8 +147,8 @@ public: const ::rtl::OUString& aFormat, const ::rtl::OUString& aURL, sal_Int32 nStorageMode, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory - = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >(), + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext + = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >(), sal_Bool bRepairStorage = sal_False ) throw ( ::com::sun::star::uno::Exception ); @@ -156,8 +156,8 @@ public: GetStorageOfFormatFromInputStream( const ::rtl::OUString& aFormat, const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >& xStream, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory - = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >(), + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext + = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >(), sal_Bool bRepairStorage = sal_False ) throw ( ::com::sun::star::uno::Exception ); @@ -166,8 +166,8 @@ public: const ::rtl::OUString& aFormat, const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream >& xStream, sal_Int32 nStorageMode = ::com::sun::star::embed::ElementModes::READWRITE, - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory - = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >(), + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext + = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >(), sal_Bool bRepairStorage = sal_False ) throw ( ::com::sun::star::uno::Exception ); diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx index e4a1048622c7..888a8b3596f0 100644 --- a/comphelper/source/misc/storagehelper.cxx +++ b/comphelper/source/misc/storagehelper.cxx @@ -21,6 +21,7 @@ #include <com/sun/star/embed/XEncryptionProtectedSource2.hpp> #include <com/sun/star/embed/XStorage.hpp> #include <com/sun/star/embed/XTransactedObject.hpp> +#include <com/sun/star/embed/StorageFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/ucb/SimpleFileAccess.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -49,26 +50,12 @@ namespace comphelper { // ---------------------------------------------------------------------- uno::Reference< lang::XSingleServiceFactory > OStorageHelper::GetStorageFactory( - const uno::Reference< lang::XMultiServiceFactory >& xSF ) + const uno::Reference< uno::XComponentContext >& rxContext ) throw ( uno::Exception ) { - uno::Reference< lang::XMultiServiceFactory > xFactory = xSF.is() ? xSF : ::comphelper::getProcessServiceFactory(); - if ( !xFactory.is() ) - throw uno::RuntimeException(); - - rtl::OUString sService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.StorageFactory")); - - uno::Reference < lang::XSingleServiceFactory > xStorageFactory( - xFactory->createInstance(sService), uno::UNO_QUERY); - - if ( !xStorageFactory.is() ) - { - throw uno::RuntimeException(rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("Could not load: ")) + sService, - uno::Reference< uno::XInterface >()); - } + uno::Reference< uno::XComponentContext> xContext = rxContext.is() ? rxContext : ::comphelper::getProcessComponentContext(); - return xStorageFactory; + return embed::StorageFactory::create( xContext ); } // ---------------------------------------------------------------------- @@ -97,10 +84,10 @@ uno::Reference< lang::XSingleServiceFactory > OStorageHelper::GetFileSystemStora // ---------------------------------------------------------------------- uno::Reference< embed::XStorage > OStorageHelper::GetTemporaryStorage( - const uno::Reference< lang::XMultiServiceFactory >& xFactory ) + const uno::Reference< uno::XComponentContext >& rxContext ) throw ( uno::Exception ) { - uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstance(), + uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( rxContext )->createInstance(), uno::UNO_QUERY ); if ( !xTempStorage.is() ) throw uno::RuntimeException(); @@ -112,14 +99,14 @@ uno::Reference< embed::XStorage > OStorageHelper::GetTemporaryStorage( uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL( const ::rtl::OUString& aURL, sal_Int32 nStorageMode, - const uno::Reference< lang::XMultiServiceFactory >& xFactory ) + const uno::Reference< uno::XComponentContext >& rxContext ) throw ( uno::Exception ) { uno::Sequence< uno::Any > aArgs( 2 ); aArgs[0] <<= aURL; aArgs[1] <<= nStorageMode; - uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), + uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( rxContext )->createInstanceWithArguments( aArgs ), uno::UNO_QUERY ); if ( !xTempStorage.is() ) throw uno::RuntimeException(); @@ -144,7 +131,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL2( uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > (), getProcessComponentContext() ); if (aCntnt.isDocument()) { - xFact = GetStorageFactory( xFactory ); + xFact = GetStorageFactory( comphelper::getComponentContext(xFactory) ); } else { xFact = GetFileSystemStorageFactory( xFactory ); } @@ -163,14 +150,14 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromURL2( // ---------------------------------------------------------------------- uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromInputStream( const uno::Reference < io::XInputStream >& xStream, - const uno::Reference< lang::XMultiServiceFactory >& xFactory ) + const uno::Reference< uno::XComponentContext >& rxContext ) throw ( uno::Exception ) { uno::Sequence< uno::Any > aArgs( 2 ); aArgs[0] <<= xStream; aArgs[1] <<= embed::ElementModes::READ; - uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), + uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( rxContext )->createInstanceWithArguments( aArgs ), uno::UNO_QUERY ); if ( !xTempStorage.is() ) throw uno::RuntimeException(); @@ -182,14 +169,14 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromInputStream( uno::Reference< embed::XStorage > OStorageHelper::GetStorageFromStream( const uno::Reference < io::XStream >& xStream, sal_Int32 nStorageMode, - const uno::Reference< lang::XMultiServiceFactory >& xFactory ) + const uno::Reference< uno::XComponentContext >& rxContext ) throw ( uno::Exception ) { uno::Sequence< uno::Any > aArgs( 2 ); aArgs[0] <<= xStream; aArgs[1] <<= nStorageMode; - uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), + uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( rxContext )->createInstanceWithArguments( aArgs ), uno::UNO_QUERY ); if ( !xTempStorage.is() ) throw uno::RuntimeException(); @@ -311,7 +298,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromURL( const ::rtl::OUString& aFormat, const ::rtl::OUString& aURL, sal_Int32 nStorageMode, - const uno::Reference< lang::XMultiServiceFactory >& xFactory, + const uno::Reference< uno::XComponentContext >& rxContext, sal_Bool bRepairStorage ) throw ( uno::Exception ) { @@ -330,7 +317,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromURL( aArgs[1] <<= nStorageMode; aArgs[2] <<= aProps; - uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), + uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( rxContext )->createInstanceWithArguments( aArgs ), uno::UNO_QUERY ); if ( !xTempStorage.is() ) throw uno::RuntimeException(); @@ -342,7 +329,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromURL( uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromInputStream( const ::rtl::OUString& aFormat, const uno::Reference < io::XInputStream >& xStream, - const uno::Reference< lang::XMultiServiceFactory >& xFactory, + const uno::Reference< uno::XComponentContext >& rxContext, sal_Bool bRepairStorage ) throw ( uno::Exception ) { @@ -361,7 +348,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromInputStr aArgs[1] <<= embed::ElementModes::READ; aArgs[2] <<= aProps; - uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), + uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( rxContext )->createInstanceWithArguments( aArgs ), uno::UNO_QUERY ); if ( !xTempStorage.is() ) throw uno::RuntimeException(); @@ -374,7 +361,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromStream( const ::rtl::OUString& aFormat, const uno::Reference < io::XStream >& xStream, sal_Int32 nStorageMode, - const uno::Reference< lang::XMultiServiceFactory >& xFactory, + const uno::Reference< uno::XComponentContext >& rxContext, sal_Bool bRepairStorage ) throw ( uno::Exception ) { @@ -393,7 +380,7 @@ uno::Reference< embed::XStorage > OStorageHelper::GetStorageOfFormatFromStream( aArgs[1] <<= nStorageMode; aArgs[2] <<= aProps; - uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( xFactory )->createInstanceWithArguments( aArgs ), + uno::Reference< embed::XStorage > xTempStorage( GetStorageFactory( rxContext )->createInstanceWithArguments( aArgs ), uno::UNO_QUERY ); if ( !xTempStorage.is() ) throw uno::RuntimeException(); diff --git a/cui/source/customize/acccfg.cxx b/cui/source/customize/acccfg.cxx index 931a025d2c91..a0bac71abd32 100644 --- a/cui/source/customize/acccfg.cxx +++ b/cui/source/customize/acccfg.cxx @@ -31,6 +31,7 @@ #include <sfx2/sfxresid.hxx> #include <svl/stritem.hxx> #include "svtools/treelistentry.hxx" +#include <com/sun/star/embed/StorageFactory.hpp> #include <sal/macros.h> @@ -74,7 +75,6 @@ using namespace com::sun::star; //----------------------------------------------- -static ::rtl::OUString SERVICE_STORAGEFACTORY (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.StorageFactory" )); static ::rtl::OUString SERVICE_UICONFIGMGR (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.UIConfigurationManager" )); static ::rtl::OUString SERVICE_DESKTOP (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop" )); static ::rtl::OUString SERVICE_GLOBALACCCFG (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.GlobalAcceleratorConfiguration" )); @@ -1232,7 +1232,7 @@ IMPL_LINK_NOARG(SfxAcceleratorConfigPage, LoadHdl) { // URL doesn't point to a loaded document, try to access it as a single storage // dont forget to release the storage afterwards! - css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory(m_xSMGR->createInstance(SERVICE_STORAGEFACTORY), css::uno::UNO_QUERY_THROW); + css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory( css::embed::StorageFactory::create( comphelper::getComponentContext(m_xSMGR) ) ); css::uno::Sequence< css::uno::Any > lArgs(2); lArgs[0] <<= sCfgName; lArgs[1] <<= css::embed::ElementModes::READ; @@ -1315,7 +1315,7 @@ IMPL_LINK_NOARG(SfxAcceleratorConfigPage, SaveHdl) else { // URL doesn't point to a loaded document, try to access it as a single storage - css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory(m_xSMGR->createInstance(SERVICE_STORAGEFACTORY), css::uno::UNO_QUERY_THROW); + css::uno::Reference< css::lang::XSingleServiceFactory > xStorageFactory( css::embed::StorageFactory::create( comphelper::getComponentContext(m_xSMGR) ) ); css::uno::Sequence< css::uno::Any > lArgs(2); lArgs[0] <<= sCfgName; lArgs[1] <<= css::embed::ElementModes::WRITE; 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 ); } } diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx index a54f3a9f3bd0..abb841813765 100644 --- a/embeddedobj/source/commonembedding/persistence.cxx +++ b/embeddedobj/source/commonembedding/persistence.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/embed/XOptimizedStorage.hpp> #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/EmbedUpdateModes.hpp> +#include <com/sun/star/embed/StorageFactory.hpp> #include <com/sun/star/io/TempFile.hpp> #include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XStorable.hpp> @@ -119,18 +120,15 @@ uno::Sequence< beans::PropertyValue > addAsTemplate( const uno::Sequence< beans: //------------------------------------------------------ uno::Reference< io::XInputStream > createTempInpStreamFromStor( const uno::Reference< embed::XStorage >& xStorage, - const uno::Reference< lang::XMultiServiceFactory >& xFactory ) + const uno::Reference< uno::XComponentContext >& xContext ) { OSL_ENSURE( xStorage.is(), "The storage can not be empty!" ); uno::Reference< io::XInputStream > xResult; - uno::Reference < io::XStream > xTempStream( io::TempFile::create(comphelper::getComponentContext(xFactory)), - uno::UNO_QUERY_THROW ); + uno::Reference < io::XStream > xTempStream( io::TempFile::create(xContext), uno::UNO_QUERY_THROW ); - uno::Reference < lang::XSingleServiceFactory > xStorageFactory( - xFactory->createInstance ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.StorageFactory" )) ), - uno::UNO_QUERY ); + uno::Reference < lang::XSingleServiceFactory > xStorageFactory( embed::StorageFactory::create(xContext) ); uno::Sequence< uno::Any > aArgs( 2 ); aArgs[0] <<= xTempStream; @@ -509,7 +507,7 @@ uno::Reference< util::XCloseable > OCommonEmbeddedObject::LoadDocumentFromStorag uno::Reference< io::XInputStream > xTempInpStream; if ( !xDoc.is() ) { - xTempInpStream = createTempInpStreamFromStor( xSourceStorage, m_xFactory ); + xTempInpStream = createTempInpStreamFromStor( xSourceStorage, comphelper::getComponentContext(m_xFactory) ); if ( !xTempInpStream.is() ) throw uno::RuntimeException(); diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx index 861be9d81b95..546215173995 100644 --- a/filter/source/msfilter/msdffimp.cxx +++ b/filter/source/msfilter/msdffimp.cxx @@ -2702,47 +2702,44 @@ void DffPropertyReader::CheckAndCorrectExcelTextRotation( SvStream& rIn, SfxItem ( new ::comphelper::SequenceInputStream( aXMLDataSeq ) ); try { - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); - if ( xFactory.is() ) + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > xContext( ::comphelper::getProcessComponentContext() ); + ::com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage + ( ::comphelper::OStorageHelper::GetStorageOfFormatFromInputStream( + OFOPXML_STORAGE_FORMAT_STRING, xInputStream, xContext, sal_True ) ); + if ( xStorage.is() ) { - ::com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage - ( ::comphelper::OStorageHelper::GetStorageOfFormatFromInputStream( - OFOPXML_STORAGE_FORMAT_STRING, xInputStream, xFactory, sal_True ) ); - if ( xStorage.is() ) + const rtl::OUString sDRS( RTL_CONSTASCII_USTRINGPARAM ( "drs" ) ); + ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > + xStorageDRS( xStorage->openStorageElement( sDRS, ::com::sun::star::embed::ElementModes::SEEKABLEREAD ) ); + if ( xStorageDRS.is() ) { - const rtl::OUString sDRS( RTL_CONSTASCII_USTRINGPARAM ( "drs" ) ); - ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage > - xStorageDRS( xStorage->openStorageElement( sDRS, ::com::sun::star::embed::ElementModes::SEEKABLEREAD ) ); - if ( xStorageDRS.is() ) + const rtl::OUString sShapeXML( RTL_CONSTASCII_USTRINGPARAM ( "shapexml.xml" ) ); + ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > xShapeXMLStream( xStorageDRS->openStreamElement( sShapeXML, ::com::sun::star::embed::ElementModes::SEEKABLEREAD ) ); + if ( xShapeXMLStream.is() ) { - const rtl::OUString sShapeXML( RTL_CONSTASCII_USTRINGPARAM ( "shapexml.xml" ) ); - ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > xShapeXMLStream( xStorageDRS->openStreamElement( sShapeXML, ::com::sun::star::embed::ElementModes::SEEKABLEREAD ) ); - if ( xShapeXMLStream.is() ) + ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xShapeXMLInputStream( xShapeXMLStream->getInputStream() ); + if ( xShapeXMLInputStream.is() ) { - ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > xShapeXMLInputStream( xShapeXMLStream->getInputStream() ); - if ( xShapeXMLInputStream.is() ) - { - ::com::sun::star::uno::Sequence< sal_Int8 > aSeq; - sal_Int32 nBytesRead = xShapeXMLInputStream->readBytes( aSeq, 0x7fffffff ); - if ( nBytesRead ) - { // for only one property I spare to use a XML parser at this point, this - // should be enhanced if needed - - bRotateTextWithShape = sal_True; // using the correct xml default - const char* pArry = reinterpret_cast< char* >( aSeq.getArray() ); - const char* pUpright = "upright="; - const char* pEnd = pArry + nBytesRead; - const char* pPtr = pArry; - while( ( pPtr + 12 ) < pEnd ) + ::com::sun::star::uno::Sequence< sal_Int8 > aSeq; + sal_Int32 nBytesRead = xShapeXMLInputStream->readBytes( aSeq, 0x7fffffff ); + if ( nBytesRead ) + { // for only one property I spare to use a XML parser at this point, this + // should be enhanced if needed + + bRotateTextWithShape = sal_True; // using the correct xml default + const char* pArry = reinterpret_cast< char* >( aSeq.getArray() ); + const char* pUpright = "upright="; + const char* pEnd = pArry + nBytesRead; + const char* pPtr = pArry; + while( ( pPtr + 12 ) < pEnd ) + { + if ( !memcmp( pUpright, pPtr, 8 ) ) { - if ( !memcmp( pUpright, pPtr, 8 ) ) - { - bRotateTextWithShape = ( pPtr[ 9 ] != '1' ) && ( pPtr[ 9 ] != 't' ); - break; - } - else - pPtr++; + bRotateTextWithShape = ( pPtr[ 9 ] != '1' ) && ( pPtr[ 9 ] != 't' ); + break; } + else + pPtr++; } } } diff --git a/framework/inc/services.h b/framework/inc/services.h index e32de32c1ed3..beae088e22ea 100644 --- a/framework/inc/services.h +++ b/framework/inc/services.h @@ -68,7 +68,6 @@ namespace framework{ #define SERVICENAME_GLOBALACCELERATORCONFIGURATION DECLARE_ASCII("com.sun.star.ui.GlobalAcceleratorConfiguration") #define SERVICENAME_MODULEACCELERATORCONFIGURATION DECLARE_ASCII("com.sun.star.ui.ModuleAcceleratorConfiguration") #define SERVICENAME_DOCUMENTACCELERATORCONFIGURATION DECLARE_ASCII("com.sun.star.ui.DocumentAcceleratorConfiguration") -#define SERVICENAME_STORAGEFACTORY DECLARE_ASCII("com.sun.star.embed.StorageFactory" ) #define SERVICENAME_FILESYSTEMSTORAGEFACTORY DECLARE_ASCII("com.sun.star.embed.FileSystemStorageFactory" ) #define SERVICENAME_PACKAGESTRUCTURECREATOR DECLARE_ASCII("com.sun.star.embed.PackageStructureCreator" ) #define SERVICENAME_TOOLBARFACTORY DECLARE_ASCII("com.sun.star.ui.ToolBarFactory" ) diff --git a/oox/source/helper/zipstorage.cxx b/oox/source/helper/zipstorage.cxx index 1845afdc7c89..0e16107f615e 100644 --- a/oox/source/helper/zipstorage.cxx +++ b/oox/source/helper/zipstorage.cxx @@ -62,9 +62,8 @@ ZipStorage::ZipStorage( const Reference< XComponentContext >& rxContext, const R TODO: #i105410# switch to 'OFOPXMLFormat' and use its implementation of relations handling. */ - Reference< XMultiServiceFactory > xFactory( rxContext->getServiceManager(), UNO_QUERY_THROW ); mxStorage = ::comphelper::OStorageHelper::GetStorageOfFormatFromInputStream( - ZIP_STORAGE_FORMAT_STRING, rxInStream, xFactory, + ZIP_STORAGE_FORMAT_STRING, rxInStream, rxContext, sal_False ); // DEV300_m80: Was sal_True, but DOCX and others did not load } catch (Exception const& e) @@ -81,10 +80,9 @@ ZipStorage::ZipStorage( const Reference< XComponentContext >& rxContext, const R // create base storage object if( rxContext.is() ) try { - Reference< XMultiServiceFactory > xFactory( rxContext->getServiceManager(), UNO_QUERY_THROW ); const sal_Int32 nOpenMode = ElementModes::READWRITE | ElementModes::TRUNCATE; mxStorage = ::comphelper::OStorageHelper::GetStorageOfFormatFromStream( - OFOPXML_STORAGE_FORMAT_STRING, rxStream, nOpenMode, xFactory, sal_True ); + OFOPXML_STORAGE_FORMAT_STRING, rxStream, nOpenMode, rxContext, sal_True ); } catch (Exception const& e) { diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx index 3fc9edba8c70..92267c311fd5 100644 --- a/reportdesign/source/core/api/ReportDefinition.cxx +++ b/reportdesign/source/core/api/ReportDefinition.cxx @@ -51,6 +51,7 @@ #include <com/sun/star/embed/EntryInitModes.hpp> #include <com/sun/star/embed/XEmbedPersist.hpp> #include <com/sun/star/embed/XTransactedObject.hpp> +#include <com/sun/star/embed/StorageFactory.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/io/XActiveDataSource.hpp> @@ -1813,12 +1814,7 @@ void SAL_CALL OReportDefinition::load( const uno::Sequence< beans::PropertyValue 1 ); - uno::Reference< lang::XSingleServiceFactory > xStorageFactory( - m_aProps->m_xContext->getServiceManager()->createInstanceWithContext( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.StorageFactory" ) ), - m_aProps->m_xContext ), - uno::UNO_QUERY_THROW - ); + uno::Reference< lang::XSingleServiceFactory > xStorageFactory( embed::StorageFactory::create( m_aProps->m_xContext ) ); // open read-write per default, unless told otherwise in the MediaDescriptor uno::Reference< embed::XStorage > xDocumentStorage; diff --git a/reportdesign/source/core/api/ReportEngineJFree.cxx b/reportdesign/source/core/api/ReportEngineJFree.cxx index 27b26e38c4c8..4af87c18e2e9 100644 --- a/reportdesign/source/core/api/ReportEngineJFree.cxx +++ b/reportdesign/source/core/api/ReportEngineJFree.cxx @@ -178,7 +178,7 @@ void SAL_CALL OReportEngineJFree::setStatusIndicator( const uno::Reference< task else sExt = rtl::OUString(".rpt"); - uno::Reference< embed::XStorage > xTemp = OStorageHelper::GetTemporaryStorage(/*sFileTemp,embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE,*/uno::Reference< lang::XMultiServiceFactory >(m_xContext->getServiceManager(),uno::UNO_QUERY)); + uno::Reference< embed::XStorage > xTemp = OStorageHelper::GetTemporaryStorage(/*sFileTemp,embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE,*/ m_xContext); utl::DisposableComponent aTemp(xTemp); uno::Sequence< beans::PropertyValue > aEmpty; uno::Reference< beans::XPropertySet> xStorageProp(xTemp,uno::UNO_QUERY); @@ -210,7 +210,7 @@ void SAL_CALL OReportEngineJFree::setStatusIndicator( const uno::Reference< task sFileURL = aTestFile.GetURL(); } - uno::Reference< embed::XStorage > xOut = OStorageHelper::GetStorageFromURL(sFileURL,embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE,uno::Reference< lang::XMultiServiceFactory >(m_xContext->getServiceManager(),uno::UNO_QUERY)); + uno::Reference< embed::XStorage > xOut = OStorageHelper::GetStorageFromURL(sFileURL,embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE, m_xContext); utl::DisposableComponent aOut(xOut); xStorageProp.set(xOut,uno::UNO_QUERY); if ( xStorageProp.is() ) diff --git a/reportdesign/source/filter/xml/dbloader2.cxx b/reportdesign/source/filter/xml/dbloader2.cxx index 71fc57682add..72408c52d3a5 100644 --- a/reportdesign/source/filter/xml/dbloader2.cxx +++ b/reportdesign/source/filter/xml/dbloader2.cxx @@ -60,7 +60,7 @@ ORptTypeDetection::ORptTypeDetection(Reference< XComponentContext > const & xCon { try { - Reference<XPropertySet> xProp(::comphelper::OStorageHelper::GetStorageFromURL(sTemp,ElementModes::READ,Reference< XMultiServiceFactory >(m_xContext->getServiceManager(),UNO_QUERY)),UNO_QUERY); + Reference<XPropertySet> xProp(::comphelper::OStorageHelper::GetStorageFromURL(sTemp,ElementModes::READ, m_xContext),UNO_QUERY); if ( xProp.is() ) { ::rtl::OUString sMediaType; diff --git a/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx b/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx index b387af6c2cba..7bc2713abaad 100644 --- a/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx +++ b/sd/source/ui/toolpanel/controls/MasterPageContainerProviders.cxx @@ -30,6 +30,7 @@ #include <vcl/image.hxx> #include <vcl/pngread.hxx> #include <com/sun/star/embed/ElementModes.hpp> +#include <com/sun/star/embed/StorageFactory.hpp> #include <tools/diagnose_ex.h> using namespace ::com::sun::star; @@ -112,93 +113,84 @@ Image TemplatePreviewProvider::operator() ( // Load the thumbnail from a template document. uno::Reference<io::XInputStream> xIStream; - uno::Reference< lang::XMultiServiceFactory > xServiceManager ( - ::comphelper::getProcessServiceFactory()); - if (xServiceManager.is()) + uno::Reference< uno::XComponentContext > xContext(::comphelper::getProcessComponentContext()); + try { + uno::Reference<lang::XSingleServiceFactory> xStorageFactory = embed::StorageFactory::create(xContext); + + uno::Sequence<uno::Any> aArgs (2); + aArgs[0] <<= msURL; + aArgs[1] <<= embed::ElementModes::READ; + uno::Reference<embed::XStorage> xDocStorage ( + xStorageFactory->createInstanceWithArguments(aArgs), + uno::UNO_QUERY); + try { - uno::Reference<lang::XSingleServiceFactory> xStorageFactory( - xServiceManager->createInstance( "com.sun.star.embed.StorageFactory"), - uno::UNO_QUERY); - - if (xStorageFactory.is()) + if (xDocStorage.is()) { - uno::Sequence<uno::Any> aArgs (2); - aArgs[0] <<= msURL; - aArgs[1] <<= embed::ElementModes::READ; - uno::Reference<embed::XStorage> xDocStorage ( - xStorageFactory->createInstanceWithArguments(aArgs), - uno::UNO_QUERY); - - try - { - if (xDocStorage.is()) - { - uno::Reference<embed::XStorage> xStorage ( - xDocStorage->openStorageElement( - "Thumbnails", - embed::ElementModes::READ)); - if (xStorage.is()) - { - uno::Reference<io::XStream> xThumbnailCopy ( - xStorage->cloneStreamElement("thumbnail.png")); - if (xThumbnailCopy.is()) - xIStream = xThumbnailCopy->getInputStream(); - } - } - } - catch (const uno::Exception& rException) + uno::Reference<embed::XStorage> xStorage ( + xDocStorage->openStorageElement( + "Thumbnails", + embed::ElementModes::READ)); + if (xStorage.is()) { - OSL_TRACE ( - "caught exception while trying to access Thumbnail/thumbnail.png of %s: %s", - ::rtl::OUStringToOString(msURL, - RTL_TEXTENCODING_UTF8).getStr(), - ::rtl::OUStringToOString(rException.Message, - RTL_TEXTENCODING_UTF8).getStr()); + uno::Reference<io::XStream> xThumbnailCopy ( + xStorage->cloneStreamElement("thumbnail.png")); + if (xThumbnailCopy.is()) + xIStream = xThumbnailCopy->getInputStream(); } + } + } + catch (const uno::Exception& rException) + { + OSL_TRACE ( + "caught exception while trying to access Thumbnail/thumbnail.png of %s: %s", + ::rtl::OUStringToOString(msURL, + RTL_TEXTENCODING_UTF8).getStr(), + ::rtl::OUStringToOString(rException.Message, + RTL_TEXTENCODING_UTF8).getStr()); + } - try - { - // An (older) implementation had a bug - The storage - // name was "Thumbnail" instead of "Thumbnails". The - // old name is still used as fallback but this code can - // be removed soon. - if ( ! xIStream.is()) - { - uno::Reference<embed::XStorage> xStorage ( - xDocStorage->openStorageElement( "Thumbnail", - embed::ElementModes::READ)); - if (xStorage.is()) - { - uno::Reference<io::XStream> xThumbnailCopy ( - xStorage->cloneStreamElement("thumbnail.png")); - if (xThumbnailCopy.is()) - xIStream = xThumbnailCopy->getInputStream(); - } - } - } - catch (const uno::Exception& rException) + try + { + // An (older) implementation had a bug - The storage + // name was "Thumbnail" instead of "Thumbnails". The + // old name is still used as fallback but this code can + // be removed soon. + if ( ! xIStream.is()) + { + uno::Reference<embed::XStorage> xStorage ( + xDocStorage->openStorageElement( "Thumbnail", + embed::ElementModes::READ)); + if (xStorage.is()) { - OSL_TRACE ( - "caught exception while trying to access Thumbnails/thumbnail.png of %s: %s", - ::rtl::OUStringToOString(msURL, - RTL_TEXTENCODING_UTF8).getStr(), - ::rtl::OUStringToOString(rException.Message, - RTL_TEXTENCODING_UTF8).getStr()); + uno::Reference<io::XStream> xThumbnailCopy ( + xStorage->cloneStreamElement("thumbnail.png")); + if (xThumbnailCopy.is()) + xIStream = xThumbnailCopy->getInputStream(); } } } catch (const uno::Exception& rException) { OSL_TRACE ( - "caught exception while trying to access tuhmbnail of %s: %s", + "caught exception while trying to access Thumbnails/thumbnail.png of %s: %s", ::rtl::OUStringToOString(msURL, RTL_TEXTENCODING_UTF8).getStr(), ::rtl::OUStringToOString(rException.Message, RTL_TEXTENCODING_UTF8).getStr()); } } + catch (const uno::Exception& rException) + { + OSL_TRACE ( + "caught exception while trying to access tuhmbnail of %s: %s", + ::rtl::OUStringToOString(msURL, + RTL_TEXTENCODING_UTF8).getStr(), + ::rtl::OUStringToOString(rException.Message, + RTL_TEXTENCODING_UTF8).getStr()); + } // Extract the image from the stream. BitmapEx aThumbnail; diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index 0baed64e28d5..dd004490659a 100644 --- a/sfx2/source/control/templateabstractview.cxx +++ b/sfx2/source/control/templateabstractview.cxx @@ -17,6 +17,7 @@ #include <com/sun/star/embed/ElementModes.hpp> #include <com/sun/star/embed/XStorage.hpp> +#include <com/sun/star/embed/StorageFactory.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> @@ -176,93 +177,85 @@ BitmapEx TemplateAbstractView::fetchThumbnail (const OUString &msURL, long width // Load the thumbnail from a template document. uno::Reference<io::XInputStream> xIStream; - uno::Reference< lang::XMultiServiceFactory > xServiceManager (comphelper::getProcessServiceFactory()); + uno::Reference< uno::XComponentContext > xContext (comphelper::getProcessComponentContext()); - if (xServiceManager.is()) + try { + uno::Reference<lang::XSingleServiceFactory> xStorageFactory = embed::StorageFactory::create( xContext ); + + uno::Sequence<uno::Any> aArgs (2); + aArgs[0] <<= msURL; + aArgs[1] <<= embed::ElementModes::READ; + uno::Reference<embed::XStorage> xDocStorage ( + xStorageFactory->createInstanceWithArguments(aArgs), + uno::UNO_QUERY); + try { - uno::Reference<lang::XSingleServiceFactory> xStorageFactory( - xServiceManager->createInstance( "com.sun.star.embed.StorageFactory"), - uno::UNO_QUERY); - - if (xStorageFactory.is()) + if (xDocStorage.is()) { - uno::Sequence<uno::Any> aArgs (2); - aArgs[0] <<= msURL; - aArgs[1] <<= embed::ElementModes::READ; - uno::Reference<embed::XStorage> xDocStorage ( - xStorageFactory->createInstanceWithArguments(aArgs), - uno::UNO_QUERY); - - try + uno::Reference<embed::XStorage> xStorage ( + xDocStorage->openStorageElement( + "Thumbnails", + embed::ElementModes::READ)); + if (xStorage.is()) { - if (xDocStorage.is()) - { - uno::Reference<embed::XStorage> xStorage ( - xDocStorage->openStorageElement( - "Thumbnails", - embed::ElementModes::READ)); - if (xStorage.is()) - { - uno::Reference<io::XStream> xThumbnailCopy ( - xStorage->cloneStreamElement("thumbnail.png")); - if (xThumbnailCopy.is()) - xIStream = xThumbnailCopy->getInputStream(); - } - } - } - catch (const uno::Exception& rException) - { - OSL_TRACE ( - "caught exception while trying to access Thumbnail/thumbnail.png of %s: %s", - ::rtl::OUStringToOString(msURL, - RTL_TEXTENCODING_UTF8).getStr(), - ::rtl::OUStringToOString(rException.Message, - RTL_TEXTENCODING_UTF8).getStr()); + uno::Reference<io::XStream> xThumbnailCopy ( + xStorage->cloneStreamElement("thumbnail.png")); + if (xThumbnailCopy.is()) + xIStream = xThumbnailCopy->getInputStream(); } + } + } + catch (const uno::Exception& rException) + { + OSL_TRACE ( + "caught exception while trying to access Thumbnail/thumbnail.png of %s: %s", + ::rtl::OUStringToOString(msURL, + RTL_TEXTENCODING_UTF8).getStr(), + ::rtl::OUStringToOString(rException.Message, + RTL_TEXTENCODING_UTF8).getStr()); + } - try - { - // An (older) implementation had a bug - The storage - // name was "Thumbnail" instead of "Thumbnails". The - // old name is still used as fallback but this code can - // be removed soon. - if ( ! xIStream.is()) - { - uno::Reference<embed::XStorage> xStorage ( - xDocStorage->openStorageElement( "Thumbnail", - embed::ElementModes::READ)); - if (xStorage.is()) - { - uno::Reference<io::XStream> xThumbnailCopy ( - xStorage->cloneStreamElement("thumbnail.png")); - if (xThumbnailCopy.is()) - xIStream = xThumbnailCopy->getInputStream(); - } - } - } - catch (const uno::Exception& rException) + try + { + // An (older) implementation had a bug - The storage + // name was "Thumbnail" instead of "Thumbnails". The + // old name is still used as fallback but this code can + // be removed soon. + if ( ! xIStream.is()) + { + uno::Reference<embed::XStorage> xStorage ( + xDocStorage->openStorageElement( "Thumbnail", + embed::ElementModes::READ)); + if (xStorage.is()) { - OSL_TRACE ( - "caught exception while trying to access Thumbnails/thumbnail.png of %s: %s", - ::rtl::OUStringToOString(msURL, - RTL_TEXTENCODING_UTF8).getStr(), - ::rtl::OUStringToOString(rException.Message, - RTL_TEXTENCODING_UTF8).getStr()); + uno::Reference<io::XStream> xThumbnailCopy ( + xStorage->cloneStreamElement("thumbnail.png")); + if (xThumbnailCopy.is()) + xIStream = xThumbnailCopy->getInputStream(); } } } catch (const uno::Exception& rException) { OSL_TRACE ( - "caught exception while trying to access tuhmbnail of %s: %s", + "caught exception while trying to access Thumbnails/thumbnail.png of %s: %s", ::rtl::OUStringToOString(msURL, RTL_TEXTENCODING_UTF8).getStr(), ::rtl::OUStringToOString(rException.Message, RTL_TEXTENCODING_UTF8).getStr()); } } + catch (const uno::Exception& rException) + { + OSL_TRACE ( + "caught exception while trying to access tuhmbnail of %s: %s", + ::rtl::OUStringToOString(msURL, + RTL_TEXTENCODING_UTF8).getStr(), + ::rtl::OUStringToOString(rException.Message, + RTL_TEXTENCODING_UTF8).getStr()); + } // Extract the image from the stream. BitmapEx aThumbnail; diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx index 8ee9bfdc27b6..f0dd1f0e75ca 100644 --- a/sfx2/source/doc/DocumentMetadataAccess.cxx +++ b/sfx2/source/doc/DocumentMetadataAccess.cxx @@ -1290,12 +1290,12 @@ throw (uno::RuntimeException, lang::IllegalArgumentException, } uno::Reference<embed::XStorage> xStorage; try { - const uno::Reference<lang::XMultiServiceFactory> xMsf ( - m_pImpl->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW); if (xIn.is()) { xStorage = ::comphelper::OStorageHelper::GetStorageFromInputStream( - xIn, xMsf); + xIn, m_pImpl->m_xContext); } else { // fallback to url + const uno::Reference<lang::XMultiServiceFactory> xMsf ( + m_pImpl->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW); xStorage = ::comphelper::OStorageHelper::GetStorageFromURL2( URL, embed::ElementModes::READ, xMsf); } diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index c41257822611..ae61ed75ed6a 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -2054,15 +2054,13 @@ SfxDocumentMetaData::loadFromMedium(const ::rtl::OUString & URL, md[ ::comphelper::MediaDescriptor::PROP_INPUTSTREAM() ] >>= xIn; } css::uno::Reference<css::embed::XStorage> xStorage; - css::uno::Reference<css::lang::XMultiServiceFactory> xMsf ( - m_xContext->getServiceManager(), css::uno::UNO_QUERY_THROW); try { if (xIn.is()) { xStorage = ::comphelper::OStorageHelper::GetStorageFromInputStream( - xIn, xMsf); + xIn, m_xContext); } else { // fallback to url parameter xStorage = ::comphelper::OStorageHelper::GetStorageFromURL( - URL, css::embed::ElementModes::READ, xMsf); + URL, css::embed::ElementModes::READ, m_xContext); } } catch (const css::uno::RuntimeException &) { throw; diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index f2713f576ca0..8214774c9216 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -1640,7 +1640,7 @@ void SmViewShell::Execute(SfxRequest& rReq) try { uno::Reference < embed::XStorage > xStorage = - ::comphelper::OStorageHelper::GetStorageFromInputStream( xStrm, ::comphelper::getProcessServiceFactory() ); + ::comphelper::OStorageHelper::GetStorageFromInputStream( xStrm, ::comphelper::getProcessComponentContext() ); uno::Reference < beans::XPropertySet > xProps( xStorage, uno::UNO_QUERY ); SfxMedium aMedium( xStorage, OUString() ); Insert( aMedium ); diff --git a/ucb/source/ucp/tdoc/tdoc_provider.cxx b/ucb/source/ucp/tdoc/tdoc_provider.cxx index d5fbb0b6ea2a..7a9c223a04c5 100644 --- a/ucb/source/ucp/tdoc/tdoc_provider.cxx +++ b/ucb/source/ucp/tdoc/tdoc_provider.cxx @@ -50,10 +50,10 @@ using namespace tdoc_ucp; //========================================================================= ContentProvider::ContentProvider( - const uno::Reference< lang::XMultiServiceFactory >& xSMgr ) -: ::ucbhelper::ContentProviderImplHelper( comphelper::getComponentContext(xSMgr) ), - m_xDocsMgr( new OfficeDocumentsManager( comphelper::getComponentContext(xSMgr), this ) ), - m_xStgElemFac( new StorageElementFactory( xSMgr, m_xDocsMgr ) ) + const uno::Reference< uno::XComponentContext >& rxContext ) +: ::ucbhelper::ContentProviderImplHelper( rxContext ), + m_xDocsMgr( new OfficeDocumentsManager( rxContext, this ) ), + m_xStgElemFac( new StorageElementFactory( rxContext, m_xDocsMgr ) ) { } @@ -95,7 +95,7 @@ XTYPEPROVIDER_IMPL_4( ContentProvider, // //========================================================================= -XSERVICEINFO_IMPL_1( +XSERVICEINFO_IMPL_1_CTX( ContentProvider, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.ucb.TransientDocumentsContentProvider" ) ), diff --git a/ucb/source/ucp/tdoc/tdoc_provider.hxx b/ucb/source/ucp/tdoc/tdoc_provider.hxx index eaa3fd850398..69bc2b2fed3f 100644 --- a/ucb/source/ucp/tdoc/tdoc_provider.hxx +++ b/ucb/source/ucp/tdoc/tdoc_provider.hxx @@ -64,7 +64,7 @@ class ContentProvider : { public: ContentProvider( const com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory >& rXSMgr ); + com::sun::star::uno::XComponentContext >& rxContext ); virtual ~ContentProvider(); // XInterface diff --git a/ucb/source/ucp/tdoc/tdoc_storage.cxx b/ucb/source/ucp/tdoc/tdoc_storage.cxx index dd86cff85a92..e31a877796f2 100644 --- a/ucb/source/ucp/tdoc/tdoc_storage.cxx +++ b/ucb/source/ucp/tdoc/tdoc_storage.cxx @@ -21,7 +21,7 @@ #include "com/sun/star/beans/XPropertySet.hpp" #include "com/sun/star/embed/ElementModes.hpp" -#include "com/sun/star/lang/XSingleServiceFactory.hpp" +#include "com/sun/star/embed/StorageFactory.hpp" #include "comphelper/processfactory.hxx" #include "tdoc_uri.hxx" @@ -43,10 +43,10 @@ using namespace tdoc_ucp; //========================================================================= StorageElementFactory::StorageElementFactory( - const uno::Reference< lang::XMultiServiceFactory > & xSMgr, + const uno::Reference< uno::XComponentContext > & rxContext, const rtl::Reference< OfficeDocumentsManager > & xDocsMgr ) : m_xDocsMgr( xDocsMgr ), - m_xSMgr( xSMgr ) + m_xContext( rxContext ) { } @@ -65,13 +65,9 @@ StorageElementFactory::createTemporaryStorage() { uno::Reference< embed::XStorage > xStorage; uno::Reference< lang::XSingleServiceFactory > xStorageFac; - if ( m_xSMgr.is() ) + if ( m_xContext.is() ) { - xStorageFac = uno::Reference< lang::XSingleServiceFactory >( - m_xSMgr->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.embed.StorageFactory" ) ) ), - uno::UNO_QUERY ); + xStorageFac = embed::StorageFactory::create( m_xContext ); } OSL_ENSURE( xStorageFac.is(), "Can't create storage factory!" ); @@ -185,7 +181,7 @@ StorageElementFactory::createStorage( const rtl::OUString & rUri, || ( eMode == READ_WRITE_CREATE ) ); std::auto_ptr< Storage > xElement( - new Storage( comphelper::getComponentContext(m_xSMgr), this, aUriKey, xParentStorage, xStorage ) ); + new Storage( m_xContext, this, aUriKey, xParentStorage, xStorage ) ); aIt = m_aMap.insert( StorageMap::value_type( @@ -234,8 +230,7 @@ StorageElementFactory::createStorage( const rtl::OUString & rUri, return xStorage; } - aIt->second - = new Storage( comphelper::getComponentContext(m_xSMgr), this, aUriKey, xParentStorage, xStorage ); + aIt->second = new Storage( m_xContext, this, aUriKey, xParentStorage, xStorage ); aIt->second->m_aContainerIt = aIt; return aIt->second; } @@ -312,8 +307,7 @@ StorageElementFactory::createOutputStream( const rtl::OUString & rUri, // and even no writable instance if there is already another // read-only instance!) return uno::Reference< io::XOutputStream >( - new OutputStream( - comphelper::getComponentContext(m_xSMgr), rUri, xParentStorage, xStream->getOutputStream() ) ); + new OutputStream( m_xContext, rUri, xParentStorage, xStream->getOutputStream() ) ); } //========================================================================= @@ -353,7 +347,7 @@ StorageElementFactory::createStream( const rtl::OUString & rUri, } return uno::Reference< io::XStream >( - new Stream( comphelper::getComponentContext(m_xSMgr), rUri, xParentStorage, xStream ) ); + new Stream( m_xContext, rUri, xParentStorage, xStream ) ); } //========================================================================= diff --git a/ucb/source/ucp/tdoc/tdoc_storage.hxx b/ucb/source/ucp/tdoc/tdoc_storage.hxx index 2dc5dc0bd078..9904ab9d62ba 100644 --- a/ucb/source/ucp/tdoc/tdoc_storage.hxx +++ b/ucb/source/ucp/tdoc/tdoc_storage.hxx @@ -45,7 +45,7 @@ namespace tdoc_ucp { public: StorageElementFactory( const com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > & xSMgr, + com::sun::star::uno::XComponentContext > & rxContext, const rtl::Reference< OfficeDocumentsManager > & xDocsMgr ); ~StorageElementFactory(); @@ -156,7 +156,7 @@ namespace tdoc_ucp { osl::Mutex m_aMutex; rtl::Reference< OfficeDocumentsManager > m_xDocsMgr; com::sun::star::uno::Reference< - com::sun::star::lang::XMultiServiceFactory > m_xSMgr; + com::sun::star::uno::XComponentContext > m_xContext; }; } // namespace tdoc_ucp diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 5ae8e1389589..dd61686f57b3 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -103,9 +103,8 @@ LoggedStream(dmapper_logger, "DomainMapper"), //import document properties try { - uno::Reference< lang::XMultiServiceFactory > xFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW); uno::Reference< embed::XStorage > xDocumentStorage = - (comphelper::OStorageHelper::GetStorageOfFormatFromInputStream(OFOPXML_STORAGE_FORMAT_STRING, xInputStream, xFactory, bRepairStorage )); + (comphelper::OStorageHelper::GetStorageOfFormatFromInputStream(OFOPXML_STORAGE_FORMAT_STRING, xInputStream, xContext, bRepairStorage )); uno::Reference< uno::XInterface > xTemp = xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.document.OOXMLDocumentPropertiesImporter", diff --git a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx index a8c62bf9e495..96f37bdfbacd 100644 --- a/writerfilter/source/ooxml/OOXMLStreamImpl.cxx +++ b/writerfilter/source/ooxml/OOXMLStreamImpl.cxx @@ -40,10 +40,9 @@ OOXMLStreamImpl::OOXMLStreamImpl StreamType_t nType, bool bRepairStorage) : mxContext(xContext), mxStorageStream(xStorageStream), mnStreamType(nType) { - uno::Reference< lang::XMultiServiceFactory > xFactory(xContext->getServiceManager(), uno::UNO_QUERY_THROW); mxStorage.set (comphelper::OStorageHelper::GetStorageOfFormatFromInputStream - (OFOPXML_STORAGE_FORMAT_STRING, mxStorageStream, xFactory, bRepairStorage)); + (OFOPXML_STORAGE_FORMAT_STRING, mxStorageStream, xContext, bRepairStorage)); mxRelationshipAccess.set(mxStorage, uno::UNO_QUERY_THROW); init(); |