From b70c3ec8f7575ed39e180854f8a7de91b9f05d49 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 28 Feb 2013 07:55:26 +0200 Subject: [PATCH] fdo#46808, remove unnecessary XMultiServiceFactory usage No-one was calling the constructor with anything other than an empty reference. Change-Id: If1948ff236f6fdb3579e472d66c5f9c04879bc4e --- sfx2/inc/guisaveas.hxx | 5 +---- sfx2/source/doc/guisaveas.cxx | 30 ++++++++---------------------- sfx2/source/doc/objserv.cxx | 3 +-- sfx2/source/view/ipclient.cxx | 3 +-- 4 files changed, 11 insertions(+), 30 deletions(-) diff --git a/sfx2/inc/guisaveas.hxx b/sfx2/inc/guisaveas.hxx index 514508745d79..9d6329049673 100644 --- a/sfx2/inc/guisaveas.hxx +++ b/sfx2/inc/guisaveas.hxx @@ -21,7 +21,6 @@ #define _SFX_GUISAVEAS_HXX_ #include -#include #include #include #include @@ -47,18 +46,16 @@ class SfxStoringHelper friend class ModelData_Impl; private: - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xFilterCFG; ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerQuery > m_xFilterQuery; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > GetServiceFactory(); ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > GetFilterConfiguration(); ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerQuery > GetFilterQuery(); ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > GetModuleManager(); public: - SfxStoringHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory ); + SfxStoringHelper(); sal_Bool GUIStoreModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel, diff --git a/sfx2/source/doc/guisaveas.cxx b/sfx2/source/doc/guisaveas.cxx index bc2fb54f3814..ecf930b8016f 100644 --- a/sfx2/source/doc/guisaveas.cxx +++ b/sfx2/source/doc/guisaveas.cxx @@ -446,7 +446,7 @@ void ModelData_Impl::CheckInteractionHandler() { try { m_aMediaDescrHM[ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InteractionHandler")) ] - <<= task::InteractionHandler::createWithParent(comphelper::getComponentContext(m_pOwner->GetServiceFactory()), 0); + <<= task::InteractionHandler::createWithParent( comphelper::getProcessComponentContext(), 0); } catch( const uno::Exception& ) { @@ -554,7 +554,7 @@ sal_Bool ModelData_Impl::ExecuteFilterDialog_Impl( const ::rtl::OUString& aFilte if( !aServiceName.isEmpty() ) { uno::Reference< ui::dialogs::XExecutableDialog > xFilterDialog( - m_pOwner->GetServiceFactory()->createInstance( aServiceName ), uno::UNO_QUERY ); + comphelper::getProcessServiceFactory()->createInstance( aServiceName ), uno::UNO_QUERY ); uno::Reference< beans::XPropertyAccess > xFilterProperties( xFilterDialog, uno::UNO_QUERY ); if( xFilterDialog.is() && xFilterProperties.is() ) @@ -619,7 +619,7 @@ sal_Int8 ModelData_Impl::CheckSaveAcceptable( sal_Int8 nCurStatus ) // check whether save is acceptable by the configuration // it is done only for documents that have persistence already uno::Reference< uno::XInterface > xCommonConfig = ::comphelper::ConfigurationHelper::openConfig( - comphelper::getComponentContext(m_pOwner->GetServiceFactory()), + comphelper::getProcessComponentContext(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common" ) ), ::comphelper::ConfigurationHelper::E_STANDARD ); if ( !xCommonConfig.is() ) @@ -1164,7 +1164,7 @@ sal_Bool ModelData_Impl::ShowDocumentInfoDialog() util::URL aURL; aURL.Complete = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:SetDocumentProperties")); - uno::Reference < util::XURLTransformer > xTransformer( util::URLTransformer::create( ::comphelper::getComponentContext(m_pOwner->GetServiceFactory()) ) ); + uno::Reference < util::XURLTransformer > xTransformer( util::URLTransformer::create( comphelper::getProcessComponentContext() ) ); if ( xTransformer->parseStrict( aURL ) ) { uno::Reference< frame::XDispatch > xDispatch = xFrameDispatch->queryDispatch( @@ -1248,7 +1248,7 @@ sal_Bool ModelData_Impl::ShowDocumentInfoDialog() { // adjust the extension to the type uno::Reference< container::XNameAccess > xTypeDetection = uno::Reference< container::XNameAccess >( - m_pOwner->GetServiceFactory()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.TypeDetection")) ), + comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.TypeDetection")) ), uno::UNO_QUERY ); if ( xTypeDetection.is() ) { @@ -1278,31 +1278,17 @@ sal_Bool ModelData_Impl::ShowDocumentInfoDialog() // class SfxStoringHelper //========================================================================= //------------------------------------------------------------------------- -SfxStoringHelper::SfxStoringHelper( const uno::Reference< lang::XMultiServiceFactory >& xFactory ) -: m_xFactory( xFactory ) +SfxStoringHelper::SfxStoringHelper() { } -//------------------------------------------------------------------------- -uno::Reference< lang::XMultiServiceFactory > SfxStoringHelper::GetServiceFactory() -{ - if ( !m_xFactory.is() ) - { - m_xFactory = ::comphelper::getProcessServiceFactory(); - if( !m_xFactory.is() ) - throw uno::RuntimeException(); // TODO: - } - - return m_xFactory; -} - //------------------------------------------------------------------------- uno::Reference< container::XNameAccess > SfxStoringHelper::GetFilterConfiguration() { if ( !m_xFilterCFG.is() ) { m_xFilterCFG = uno::Reference< container::XNameAccess >( - GetServiceFactory()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.FilterFactory")) ), + comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.FilterFactory")) ), uno::UNO_QUERY ); if ( !m_xFilterCFG.is() ) @@ -1331,7 +1317,7 @@ uno::Reference< ::com::sun::star::frame::XModuleManager2 > SfxStoringHelper::Get if ( !m_xModuleManager.is() ) { m_xModuleManager = frame::ModuleManager::create( - comphelper::getComponentContext(GetServiceFactory())); + comphelper::getProcessComponentContext() ); } return m_xModuleManager; diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index 9c4ee5aff3c2..1d921c7009c5 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -658,8 +658,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) if ( !pSlot ) throw uno::Exception(); - uno::Reference< lang::XMultiServiceFactory > xEmptyFactory; - SfxStoringHelper aHelper( xEmptyFactory ); + SfxStoringHelper aHelper; if ( QueryHiddenInformation( bIsPDFExport ? WhenCreatingPDF : WhenSaving, NULL ) == RET_YES ) { diff --git a/sfx2/source/view/ipclient.cxx b/sfx2/source/view/ipclient.cxx index 64c9a81e6c9f..d3c5989fac83 100644 --- a/sfx2/source/view/ipclient.cxx +++ b/sfx2/source/view/ipclient.cxx @@ -891,8 +891,7 @@ ErrCode SfxInPlaceClient::DoVerb( long nVerb ) try { - uno::Reference< lang::XMultiServiceFactory > xEmptyFactory; - SfxStoringHelper aHelper( xEmptyFactory ); + SfxStoringHelper aHelper; uno::Sequence< beans::PropertyValue > aDispatchArgs( 1 ); aDispatchArgs[0].Name = "SaveTo"; aDispatchArgs[0].Value <<= (sal_Bool)sal_True;