From 8c31a6baf06e711d5e45d477abedfa6afb7ffe51 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 5 Mar 2013 15:51:52 +0200 Subject: fdo#46808 use document::DocumentRevisionListPersistence constructor Change-Id: I1a591ec4061c73657c26552d41c58b970696038f --- sfx2/source/doc/docfile.cxx | 54 ++++++++++++++++--------------------- sfx2/source/doc/doctempl.cxx | 2 +- sfx2/source/doc/doctemplates.cxx | 38 +++++++++++--------------- sfx2/source/inc/sfxurlrelocator.hxx | 5 ++-- 4 files changed, 42 insertions(+), 57 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index 453a87aab30e..9a5967328ca2 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -111,6 +111,7 @@ using namespace ::com::sun::star::io; #include #include #include +#include #include "helper.hxx" #include // SFX_ITEMSET_SET @@ -3101,17 +3102,14 @@ const uno::Sequence < util::RevisionTag >& SfxMedium::GetVersionList( bool _bNoR if ( ( !_bNoReload || !pImp->m_bVersionsAlreadyLoaded ) && !pImp->aVersions.getLength() && ( !pImp->m_aName.isEmpty() || !pImp->m_aLogicName.isEmpty() ) && GetStorage().is() ) { - uno::Reference < document::XDocumentRevisionListPersistence > xReader( comphelper::getProcessServiceFactory()->createInstance( - ::rtl::OUString("com.sun.star.document.DocumentRevisionListPersistence") ), uno::UNO_QUERY ); - if ( xReader.is() ) + uno::Reference < document::XDocumentRevisionListPersistence > xReader = + document::DocumentRevisionListPersistence::create( comphelper::getProcessComponentContext() ); + try + { + pImp->aVersions = xReader->load( GetStorage() ); + } + catch ( const uno::Exception& ) { - try - { - pImp->aVersions = xReader->load( GetStorage() ); - } - catch ( const uno::Exception& ) - { - } } } @@ -3123,17 +3121,14 @@ const uno::Sequence < util::RevisionTag >& SfxMedium::GetVersionList( bool _bNoR uno::Sequence < util::RevisionTag > SfxMedium::GetVersionList( const uno::Reference < embed::XStorage >& xStorage ) { - uno::Reference < document::XDocumentRevisionListPersistence > xReader( comphelper::getProcessServiceFactory()->createInstance( - ::rtl::OUString("com.sun.star.document.DocumentRevisionListPersistence") ), uno::UNO_QUERY ); - if ( xReader.is() ) + uno::Reference < document::XDocumentRevisionListPersistence > xReader = + document::DocumentRevisionListPersistence::create( comphelper::getProcessComponentContext() ); + try + { + return xReader->load( xStorage ); + } + catch ( const uno::Exception& ) { - try - { - return xReader->load( xStorage ); - } - catch ( const uno::Exception& ) - { - } } return uno::Sequence < util::RevisionTag >(); @@ -3210,18 +3205,15 @@ sal_Bool SfxMedium::SaveVersionList_Impl( sal_Bool /*bUseXML*/ ) if ( !pImp->aVersions.getLength() ) return true; - uno::Reference < document::XDocumentRevisionListPersistence > xWriter( comphelper::getProcessServiceFactory()->createInstance( - ::rtl::OUString("com.sun.star.document.DocumentRevisionListPersistence") ), uno::UNO_QUERY ); - if ( xWriter.is() ) + uno::Reference < document::XDocumentRevisionListPersistence > xWriter = + document::DocumentRevisionListPersistence::create( comphelper::getProcessComponentContext() ); + try + { + xWriter->store( GetStorage(), pImp->aVersions ); + return true; + } + catch ( const uno::Exception& ) { - try - { - xWriter->store( GetStorage(), pImp->aVersions ); - return true; - } - catch ( const uno::Exception& ) - { - } } } diff --git a/sfx2/source/doc/doctempl.cxx b/sfx2/source/doc/doctempl.cxx index ef0dd02b7bba..b9f04fa1fe44 100644 --- a/sfx2/source/doc/doctempl.cxx +++ b/sfx2/source/doc/doctempl.cxx @@ -1846,7 +1846,7 @@ sal_Bool getTextProperty_Impl( Content& rContent, if ( SfxURLRelocator_Impl::propertyCanContainOfficeDir( rPropName ) ) { - SfxURLRelocator_Impl aRelocImpl( ::comphelper::getProcessServiceFactory() ); + SfxURLRelocator_Impl aRelocImpl( ::comphelper::getProcessComponentContext() ); aRelocImpl.makeAbsoluteURL( rPropValue ); } diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index 9251b5f11512..b067332248da 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -176,7 +176,7 @@ public: class SfxDocTplService_Impl { - uno::Reference< XMultiServiceFactory > mxFactory; + uno::Reference< XComponentContext > mxContext; uno::Reference< XCommandEnvironment > maCmdEnv; uno::Reference< XDocumentProperties> m_xDocProps; uno::Reference< XTypeDetection > mxType; @@ -268,7 +268,7 @@ class SfxDocTplService_Impl void updateData( DocTemplates_EntryData_Impl *pData ); public: - SfxDocTplService_Impl( uno::Reference< XMultiServiceFactory > xFactory ); + SfxDocTplService_Impl( const uno::Reference< XComponentContext > & xContext ); ~SfxDocTplService_Impl(); sal_Bool init() { if ( !mbIsInitialized ) init_Impl(); return mbIsInitialized; } @@ -451,7 +451,7 @@ void SfxDocTplService_Impl::init_Impl() } OUString const aService = OUString( SERVICENAME_TYPEDETECTION ); - mxType = uno::Reference< XTypeDetection > ( mxFactory->createInstance( aService ), UNO_QUERY ); + mxType = uno::Reference< XTypeDetection > ( mxContext->getServiceManager()->createInstanceWithContext(aService, mxContext), UNO_QUERY ); getDirList(); readFolderList(); @@ -580,9 +580,7 @@ void SfxDocTplService_Impl::getDirList() maTemplateDirs = Sequence< OUString >( nCount ); - uno::Reference< XComponentContext > xCtx( - comphelper::getComponentContext( mxFactory ) ); - uno::Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(xCtx); + uno::Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(mxContext); const rtl::OUString aPrefix( "vnd.sun.star.expand:" ); @@ -1122,10 +1120,10 @@ bool SfxURLRelocator_Impl::propertyCanContainOfficeDir( // public SfxDocTplService_Impl //----------------------------------------------------------------------------- -SfxDocTplService_Impl::SfxDocTplService_Impl( uno::Reference< XMultiServiceFactory > xFactory ) -: maRelocator( xFactory ) +SfxDocTplService_Impl::SfxDocTplService_Impl( const uno::Reference< XComponentContext > & xContext ) +: maRelocator( xContext ) { - mxFactory = xFactory; + mxContext = xContext; mpUpdater = NULL; mbIsInitialized = sal_False; mbLocaleSet = sal_False; @@ -1290,7 +1288,7 @@ uno::Sequence< beans::StringPair > SfxDocTplService_Impl::ReadUINamesForTemplate { uno::Reference< io::XInputStream > xLocStream = aLocContent.openStream(); if ( xLocStream.is() ) - aUINames = DocTemplLocaleHelper::ReadGroupLocalizationSequence( xLocStream, comphelper::getComponentContext(mxFactory) ); + aUINames = DocTemplLocaleHelper::ReadGroupLocalizationSequence( xLocStream, mxContext ); } catch( uno::Exception& ) {} @@ -1378,7 +1376,7 @@ sal_Bool SfxDocTplService_Impl::WriteUINamesForTemplateDir_Impl( const ::rtl::OU sal_Bool bResult = sal_False; try { uno::Reference< beans::XPropertySet > xTempFile( - io::TempFile::create(comphelper::getComponentContext(mxFactory)), + io::TempFile::create(mxContext), uno::UNO_QUERY_THROW ); ::rtl::OUString aTempURL; @@ -1390,7 +1388,7 @@ sal_Bool SfxDocTplService_Impl::WriteUINamesForTemplateDir_Impl( const ::rtl::OU if ( !xOutStream.is() ) throw uno::RuntimeException(); - DocTemplLocaleHelper::WriteGroupLocalizationSequence( xOutStream, aUINames, comphelper::getComponentContext(mxFactory)); + DocTemplLocaleHelper::WriteGroupLocalizationSequence( xOutStream, aUINames, mxContext); try { // the SAX writer might close the stream xOutStream->closeOutput(); @@ -2212,7 +2210,7 @@ SFX_IMPL_SINGLEFACTORY( SfxDocTplService ) //----------------------------------------------------------------------------- SfxDocTplService::SfxDocTplService( const uno::Reference< XMultiServiceFactory >& xFactory ) { - pImp = new SfxDocTplService_Impl( xFactory ); + pImp = new SfxDocTplService_Impl( comphelper::getComponentContext(xFactory) ); } //----------------------------------------------------------------------------- @@ -2806,8 +2804,8 @@ DocTemplates_EntryData_Impl::DocTemplates_EntryData_Impl( const OUString& rTitle } // ----------------------------------------------------------------------- -SfxURLRelocator_Impl::SfxURLRelocator_Impl( uno::Reference< XMultiServiceFactory > xFactory ) -: mxFactory( xFactory ) +SfxURLRelocator_Impl::SfxURLRelocator_Impl( const uno::Reference< XComponentContext > & xContext ) +: mxContext( xContext ) { } @@ -2824,12 +2822,9 @@ void SfxURLRelocator_Impl::initOfficeInstDirs() osl::MutexGuard aGuard( maMutex ); if ( !mxOfficeInstDirs.is() ) { - OSL_ENSURE( mxFactory.is(), "No service manager!" ); + OSL_ENSURE( mxContext.is(), "No service manager!" ); - uno::Reference< XComponentContext > xCtx( - comphelper::getComponentContext( mxFactory ) ); - - mxOfficeInstDirs = theOfficeInstallationDirectories::get(xCtx); + mxOfficeInstDirs = theOfficeInstallationDirectories::get(mxContext); } } } @@ -2846,8 +2841,7 @@ void SfxURLRelocator_Impl::implExpandURL( ::rtl::OUString& io_url ) { if ( !mxMacroExpander.is() ) { - ::comphelper::ComponentContext aContext( mxFactory ); - mxMacroExpander.set( theMacroExpander::get(aContext.getUNOContext()), UNO_QUERY_THROW ); + mxMacroExpander.set( theMacroExpander::get(mxContext), UNO_QUERY_THROW ); } io_url = mxMacroExpander->expandMacros( io_url ); } diff --git a/sfx2/source/inc/sfxurlrelocator.hxx b/sfx2/source/inc/sfxurlrelocator.hxx index 031ca663bb7b..1406d60e9cf8 100644 --- a/sfx2/source/inc/sfxurlrelocator.hxx +++ b/sfx2/source/inc/sfxurlrelocator.hxx @@ -20,7 +20,6 @@ #ifndef _SFX_SFXURLRELOCATOR_HXX_ #define _SFX_SFXURLRELOCATOR_HXX_ -#include #include #include @@ -30,7 +29,7 @@ class SfxURLRelocator_Impl { ::osl::Mutex maMutex; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxFactory; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext; ::com::sun::star::uno::Reference< ::com::sun::star::util::XOfficeInstallationDirectories > mxOfficeInstDirs; ::com::sun::star::uno::Reference< ::com::sun::star::util::XMacroExpander > mxMacroExpander; @@ -40,7 +39,7 @@ public: void makeRelocatableURL( rtl::OUString & rURL ); void makeAbsoluteURL( rtl::OUString & rURL ); - SfxURLRelocator_Impl( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory ); + SfxURLRelocator_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext ); ~SfxURLRelocator_Impl(); private: -- cgit