From a726677724a5a8dd6ae39d5a7a829c2ed62f3efd Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 22 May 2013 11:08:43 +0200 Subject: fdo#46808, Convert XMultiServiceFactory to XComponentContext Change-Id: Ib5e6fb4d6a4ff8f2bd315f19bde5028be2c569ea --- .../inc/uielement/genericstatusbarcontroller.hxx | 2 +- .../uielement/langselectionstatusbarcontroller.hxx | 2 +- .../source/uielement/addonstoolbarmanager.cxx | 1 + .../uielement/genericstatusbarcontroller.cxx | 4 ++-- .../uielement/langselectionstatusbarcontroller.cxx | 14 +++++------- framework/source/uielement/statusbarmanager.cxx | 4 ++-- framework/source/uielement/toolbarmanager.cxx | 1 + include/svtools/statusbarcontroller.hxx | 10 ++++----- reportdesign/source/ui/inc/statusbarcontroller.hxx | 2 +- .../source/ui/misc/statusbarcontroller.cxx | 8 +++---- svtools/source/uno/statusbarcontroller.cxx | 26 +++++++++++++--------- 11 files changed, 40 insertions(+), 34 deletions(-) diff --git a/framework/inc/uielement/genericstatusbarcontroller.hxx b/framework/inc/uielement/genericstatusbarcontroller.hxx index bc4a71d63112..59548a26c63b 100644 --- a/framework/inc/uielement/genericstatusbarcontroller.hxx +++ b/framework/inc/uielement/genericstatusbarcontroller.hxx @@ -30,7 +30,7 @@ struct AddonStatusbarItemData; class GenericStatusbarController : public svt::StatusbarController { public: - GenericStatusbarController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager, + GenericStatusbarController( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext, const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame, const com::sun::star::uno::Reference< com::sun::star::ui::XStatusbarItem >& rxItem, AddonStatusbarItemData *pItemData ); diff --git a/framework/inc/uielement/langselectionstatusbarcontroller.hxx b/framework/inc/uielement/langselectionstatusbarcontroller.hxx index 71896ef18a4b..0f7a77d888a7 100644 --- a/framework/inc/uielement/langselectionstatusbarcontroller.hxx +++ b/framework/inc/uielement/langselectionstatusbarcontroller.hxx @@ -42,7 +42,7 @@ namespace framework { class LangSelectionStatusbarController : public svt::StatusbarController { public: - explicit LangSelectionStatusbarController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); + explicit LangSelectionStatusbarController( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ); // XServiceInfo DECLARE_XSERVICEINFO diff --git a/framework/source/uielement/addonstoolbarmanager.cxx b/framework/source/uielement/addonstoolbarmanager.cxx index 0bde95d0ccae..6723b950cc72 100644 --- a/framework/source/uielement/addonstoolbarmanager.cxx +++ b/framework/source/uielement/addonstoolbarmanager.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include diff --git a/framework/source/uielement/genericstatusbarcontroller.cxx b/framework/source/uielement/genericstatusbarcontroller.cxx index 4b4d721e1621..4140ab8b696e 100644 --- a/framework/source/uielement/genericstatusbarcontroller.cxx +++ b/framework/source/uielement/genericstatusbarcontroller.cxx @@ -43,11 +43,11 @@ namespace framework { GenericStatusbarController::GenericStatusbarController( - const Reference< XMultiServiceFactory >& rxServiceManager, + const Reference< XComponentContext >& rxContext, const Reference< XFrame >& rxFrame, const Reference< ui::XStatusbarItem >& rxItem, AddonStatusbarItemData *pItemData ) - : svt::StatusbarController( rxServiceManager, rxFrame, OUString(), 0 ) + : svt::StatusbarController( rxContext, rxFrame, OUString(), 0 ) , m_bEnabled( sal_False ) , m_bOwnerDraw( sal_False ) , m_pItemData( pItemData ) diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx index 09c0a3d02dae..8773c819bb0f 100644 --- a/framework/source/uielement/langselectionstatusbarcontroller.cxx +++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx @@ -44,8 +44,6 @@ #include #include #include -#include -#include #include #include @@ -75,7 +73,7 @@ using ::rtl::OUStringBuffer; namespace framework { -DEFINE_XSERVICEINFO_MULTISERVICE ( LangSelectionStatusbarController , +DEFINE_XSERVICEINFO_MULTISERVICE_2 ( LangSelectionStatusbarController , OWeakObject , SERVICENAME_STATUSBARCONTROLLER , IMPLEMENTATIONNAME_LANGSELECTIONSTATUSBARCONTROLLER @@ -83,11 +81,11 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( LangSelectionStatusbarController DEFINE_INIT_SERVICE ( LangSelectionStatusbarController, {} ) -LangSelectionStatusbarController::LangSelectionStatusbarController( const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) : - svt::StatusbarController( xServiceManager, uno::Reference< frame::XFrame >(), OUString(), 0 ), +LangSelectionStatusbarController::LangSelectionStatusbarController( const uno::Reference< uno::XComponentContext >& xContext ) : + svt::StatusbarController( xContext, uno::Reference< frame::XFrame >(), OUString(), 0 ), m_bShowMenu( sal_True ), m_nScriptType( LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX ), - m_aLangGuessHelper( comphelper::getComponentContext(xServiceManager) ) + m_aLangGuessHelper( xContext ) { } @@ -114,9 +112,9 @@ throw (::com::sun::star::uno::RuntimeException) return; //add context menu - Reference< awt::XPopupMenu > xPopupMenu( awt::PopupMenu::create( comphelper::getComponentContext(m_xServiceManager) ) ); + Reference< awt::XPopupMenu > xPopupMenu( awt::PopupMenu::create( m_xContext ) ); //sub menu that contains all items except the last two items: Separator + Set Language for Paragraph - Reference< awt::XPopupMenu > subPopupMenu( awt::PopupMenu::create( comphelper::getComponentContext(m_xServiceManager) ) ); + Reference< awt::XPopupMenu > subPopupMenu( awt::PopupMenu::create( m_xContext ) ); SvtLanguageTable aLanguageTable; diff --git a/framework/source/uielement/statusbarmanager.cxx b/framework/source/uielement/statusbarmanager.cxx index b6ba2462350a..2b096a52ab88 100644 --- a/framework/source/uielement/statusbarmanager.cxx +++ b/framework/source/uielement/statusbarmanager.cxx @@ -421,7 +421,7 @@ void StatusBarManager::CreateControllers() // 3º) Is Add-on? Generic statusbar controller if ( pItemData ) { - pController = new GenericStatusbarController( uno::Reference(m_xContext->getServiceManager(), uno::UNO_QUERY_THROW), + pController = new GenericStatusbarController( m_xContext, m_xFrame, xStatusbarItem, pItemData ); @@ -429,7 +429,7 @@ void StatusBarManager::CreateControllers() else { // 4º) Default Statusbar controller - pController = new svt::StatusbarController( uno::Reference(m_xContext->getServiceManager(), uno::UNO_QUERY_THROW), m_xFrame, aCommandURL, nId ); + pController = new svt::StatusbarController( m_xContext, m_xFrame, aCommandURL, nId ); } } diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index fdbb17ba8634..2ddcda576c88 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/include/svtools/statusbarcontroller.hxx b/include/svtools/statusbarcontroller.hxx index 9d094fa151b8..3b0f5bdf00d6 100644 --- a/include/svtools/statusbarcontroller.hxx +++ b/include/svtools/statusbarcontroller.hxx @@ -21,13 +21,13 @@ #define _SVTOOLS_STATUSBARCONTROLLER_HXX #include "svtools/svtdllapi.h" -#include -#include #include #include #include -#include #include +#include +#include +#include #include #include #include @@ -46,7 +46,7 @@ class SVT_DLLPUBLIC StatusbarController : public ::cppu::OWeakObject { public: - StatusbarController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager, + StatusbarController( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& rxContext, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame, const OUString& aCommandURL, unsigned short nID ); @@ -123,7 +123,7 @@ class SVT_DLLPUBLIC StatusbarController : unsigned short m_nID; ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame; ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xParentWindow; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; OUString m_aCommandURL; URLToDispatchMap m_aListenerMap; ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener diff --git a/reportdesign/source/ui/inc/statusbarcontroller.hxx b/reportdesign/source/ui/inc/statusbarcontroller.hxx index 6e6fda959e5d..91ff2329b2f9 100644 --- a/reportdesign/source/ui/inc/statusbarcontroller.hxx +++ b/reportdesign/source/ui/inc/statusbarcontroller.hxx @@ -37,7 +37,7 @@ namespace rptui sal_uInt16 m_nSlotId; sal_uInt16 m_nId; public: - OStatusbarController(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB); + OStatusbarController(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxORB); static OUString getImplementationName_Static() throw( ::com::sun::star::uno::RuntimeException ); static ::com::sun::star::uno::Sequence< OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException ); diff --git a/reportdesign/source/ui/misc/statusbarcontroller.cxx b/reportdesign/source/ui/misc/statusbarcontroller.cxx index 9bb946e7f132..4294d5b020bd 100644 --- a/reportdesign/source/ui/misc/statusbarcontroller.cxx +++ b/reportdesign/source/ui/misc/statusbarcontroller.cxx @@ -69,15 +69,15 @@ Sequence< OUString> SAL_CALL OStatusbarController::getSupportedServiceNames() th // ------------------------------------------------------------------------- Reference< XInterface > OStatusbarController::create(Reference< XComponentContext > const & xContext) { - return *(new OStatusbarController(Reference< XMultiServiceFactory >(xContext->getServiceManager(),UNO_QUERY))); + return *(new OStatusbarController(xContext)); } IMPLEMENT_FORWARD_XINTERFACE2(OStatusbarController, ::svt::StatusbarController,OStatusbarController_BASE) -OStatusbarController::OStatusbarController(const Reference< XMultiServiceFactory >& _rxORB) -: m_nSlotId(0) +OStatusbarController::OStatusbarController(const Reference< XComponentContext >& rxContext) +: ::svt::StatusbarController(rxContext, Reference< XFrame >(), OUString(), 0) +,m_nSlotId(0) ,m_nId(1) { - m_xServiceManager = _rxORB; } // ----------------------------------------------------------------------------- void SAL_CALL OStatusbarController::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException) diff --git a/svtools/source/uno/statusbarcontroller.cxx b/svtools/source/uno/statusbarcontroller.cxx index d93feed5ff78..2f6fbba437b5 100644 --- a/svtools/source/uno/statusbarcontroller.cxx +++ b/svtools/source/uno/statusbarcontroller.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -45,7 +46,7 @@ namespace svt { StatusbarController::StatusbarController( - const Reference< XMultiServiceFactory >& rServiceManager, + const Reference< XComponentContext >& rxContext, const Reference< XFrame >& xFrame, const OUString& aCommandURL, unsigned short nID ) : @@ -54,7 +55,7 @@ StatusbarController::StatusbarController( , m_bDisposed( sal_False ) , m_nID( nID ) , m_xFrame( xFrame ) - , m_xServiceManager( rServiceManager ) + , m_xContext( rxContext ) , m_aCommandURL( aCommandURL ) , m_aListenerContainer( m_aMutex ) { @@ -82,9 +83,9 @@ Reference< XFrame > StatusbarController::getFrameInterface() const Reference< XURLTransformer > StatusbarController::getURLTransformer() const { SolarMutexGuard aSolarMutexGuard; - if ( !m_xURLTransformer.is() && m_xServiceManager.is() ) + if ( !m_xURLTransformer.is() && m_xContext.is() ) { - m_xURLTransformer = com::sun::star::util::URLTransformer::create( ::comphelper::getComponentContext(m_xServiceManager) ); + m_xURLTransformer = com::sun::star::util::URLTransformer::create( m_xContext ); } return m_xURLTransformer; @@ -148,7 +149,12 @@ throw ( Exception, RuntimeException ) else if ( aPropValue.Name == "CommandURL" ) aPropValue.Value >>= m_aCommandURL; else if ( aPropValue.Name == "ServiceManager" ) - aPropValue.Value >>= m_xServiceManager; + { + Reference xMSF; + aPropValue.Value >>= xMSF; + if( xMSF.is() ) + m_xContext = comphelper::getComponentContext(xMSF); + } else if ( aPropValue.Name == "ParentWindow" ) aPropValue.Value >>= m_xParentWindow; else if ( aPropValue.Name == "Identifier" ) @@ -219,7 +225,7 @@ throw (::com::sun::star::uno::RuntimeException) // release references m_xURLTransformer.clear(); - m_xServiceManager.clear(); + m_xContext.clear(); m_xFrame.clear(); m_xParentWindow.clear(); m_xStatusbarItem.clear(); @@ -373,7 +379,7 @@ void StatusbarController::addStatusListener( const OUString& aCommandURL ) { // Add status listener directly as intialize has already been called. Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - if ( m_xServiceManager.is() && xDispatchProvider.is() ) + if ( m_xContext.is() && xDispatchProvider.is() ) { Reference< XURLTransformer > xURLTransformer = getURLTransformer(); aTargetURL.Complete = aCommandURL; @@ -426,7 +432,7 @@ void StatusbarController::bindListener() // Collect all registered command URL's and store them temporary Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - if ( m_xServiceManager.is() && xDispatchProvider.is() ) + if ( m_xContext.is() && xDispatchProvider.is() ) { xStatusListener = Reference< XStatusListener >( static_cast< OWeakObject* >( this ), UNO_QUERY ); URLToDispatchMap::iterator pIter = m_aListenerMap.begin(); @@ -533,7 +539,7 @@ void StatusbarController::execute( const ::com::sun::star::uno::Sequence< ::com: if ( m_bInitialized && m_xFrame.is() && - m_xServiceManager.is() && + m_xContext.is() && !m_aCommandURL.isEmpty() ) { xURLTransformer = getURLTransformer(); @@ -575,7 +581,7 @@ void StatusbarController::execute( if ( m_bInitialized && m_xFrame.is() && - m_xServiceManager.is() && + m_xContext.is() && !m_aCommandURL.isEmpty() ) { Reference< XURLTransformer > xURLTransformer( getURLTransformer() ); -- cgit v1.2.3