diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-09-29 17:20:22 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-09-29 18:18:28 +0200 |
commit | c2ca6fabd1afc3fc07001721c2069d3c8db7000a (patch) | |
tree | 350741d6d19564bcaf00506bd7d22b4c644e0fdc /framework | |
parent | f05d7abf93bbcf443cb0b5759ca19992e2fa85a3 (diff) |
Use comphelper::getComponentContext
...and some further clean up.
Change-Id: Id294c0f38fe0041646fc86cacbd2e19734c746a9
Diffstat (limited to 'framework')
-rw-r--r-- | framework/inc/macros/xserviceinfo.hxx | 8 | ||||
-rw-r--r-- | framework/source/fwe/classes/addonsoptions.cxx | 11 | ||||
-rw-r--r-- | framework/source/fwe/xml/menudocumenthandler.cxx | 14 | ||||
-rw-r--r-- | framework/source/layoutmanager/toolbarlayoutmanager.cxx | 1 | ||||
-rw-r--r-- | framework/source/lomenubar/FrameHelper.cxx | 10 | ||||
-rw-r--r-- | framework/source/uielement/addonstoolbarmanager.cxx | 10 | ||||
-rw-r--r-- | framework/source/uielement/imagebuttontoolbarcontroller.cxx | 13 | ||||
-rw-r--r-- | framework/source/uielement/menubarmanager.cxx | 8 | ||||
-rw-r--r-- | framework/source/uielement/popupmenucontroller.cxx | 4 | ||||
-rw-r--r-- | framework/source/uielement/statusbarmanager.cxx | 9 | ||||
-rw-r--r-- | framework/source/uielement/toolbarmanager.cxx | 7 |
11 files changed, 30 insertions, 65 deletions
diff --git a/framework/inc/macros/xserviceinfo.hxx b/framework/inc/macros/xserviceinfo.hxx index 7d9fa130a6d0..bcca5c25f6a0 100644 --- a/framework/inc/macros/xserviceinfo.hxx +++ b/framework/inc/macros/xserviceinfo.hxx @@ -41,8 +41,8 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Type.hxx> #include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> #include <cppuhelper/factory.hxx> +#include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> #include <rtl/ustring.hxx> #include <rtl/logfile.hxx> @@ -143,10 +143,8 @@ ________________________________________________________________________________ throw( css::uno::Exception ) \ { \ /* retrieve component context from the given service manager */ \ - static const ::rtl::OUString PROP_DEFAULTCONTEXT("DefaultContext"); \ - css::uno::Reference< css::beans::XPropertySet > xSMGRProps(xServiceManager, css::uno::UNO_QUERY_THROW); \ - css::uno::Reference< css::uno::XComponentContext > xComponentContext; \ - xSMGRProps->getPropertyValue( PROP_DEFAULTCONTEXT ) >>= xComponentContext; \ + css::uno::Reference< css::uno::XComponentContext > xComponentContext( \ + comphelper::getComponentContext( xServiceManager ) ); \ /* create new instance of service */ \ CLASS* pClass = new CLASS( xComponentContext ); \ /* hold it alive by increasing his ref count!!! */ \ diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx index c1789c81a313..06dbc83c5d8c 100644 --- a/framework/source/fwe/classes/addonsoptions.cxx +++ b/framework/source/fwe/classes/addonsoptions.cxx @@ -35,7 +35,6 @@ #include <com/sun/star/uno/Sequence.hxx> #include "com/sun/star/util/XMacroExpander.hpp" #include "com/sun/star/uno/XComponentContext.hpp" -#include "com/sun/star/beans/XPropertySet.hpp" #include <rtl/ustrbuf.hxx> #include <rtl/uri.hxx> #include <comphelper/processfactory.hxx> @@ -415,15 +414,11 @@ AddonsOptions_Impl::AddonsOptions_Impl() m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_MERGECONTEXT ] = PROPERTYNAME_MERGETOOLBAR_MERGECONTEXT; m_aPropMergeToolbarNames[ OFFSET_MERGETOOLBAR_TOOLBARITEMS ] = PROPERTYNAME_MERGETOOLBAR_TOOLBARITEMS; - Reference< XComponentContext > xContext; - Reference< com::sun::star::beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY ); - xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xContext; - if ( xContext.is() ) - { - m_xMacroExpander = Reference< com::sun::star::util::XMacroExpander >( xContext->getValueByName( + Reference< XComponentContext > xContext( + comphelper::getProcessComponentContext() ); + m_xMacroExpander = Reference< com::sun::star::util::XMacroExpander >( xContext->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.util.theMacroExpander"))), UNO_QUERY ); - } ReadConfigurationData(); diff --git a/framework/source/fwe/xml/menudocumenthandler.cxx b/framework/source/fwe/xml/menudocumenthandler.cxx index 680835d77bbd..24a133184a07 100644 --- a/framework/source/fwe/xml/menudocumenthandler.cxx +++ b/framework/source/fwe/xml/menudocumenthandler.cxx @@ -39,7 +39,6 @@ #include <com/sun/star/ui/ItemType.hpp> #include <com/sun/star/ui/ItemStyle.hpp> #include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> #include <comphelper/processfactory.hxx> #include <rtl/logfile.hxx> @@ -376,10 +375,8 @@ throw( SAXException, RuntimeException ) m_bMenuMode = sal_True; // Container must be factory to create sub container - Reference< XComponentContext > xComponentContext; - Reference< XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY ); - xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= - xComponentContext; + Reference< XComponentContext > xComponentContext( + comphelper::getProcessComponentContext() ); Reference< XIndexContainer > xSubItemContainer; if ( m_xContainerFactory.is() ) @@ -573,6 +570,7 @@ OReadMenuPopupHandler::OReadMenuPopupHandler( m_bMenuMode( sal_False ), m_xMenuContainer( rMenuContainer ), m_xContainerFactory( rFactory ), + m_xComponentContext( comphelper::getProcessComponentContext() ), m_nNextElementExpected( ELEM_CLOSE_NONE ) { } @@ -612,12 +610,6 @@ throw( SAXException, RuntimeException ) m_bMenuMode = sal_True; // Container must be factory to create sub container - if ( !m_xComponentContext.is() ) - { - const Reference< XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW ); - m_xComponentContext.set(xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY_THROW ); - } - Reference< XIndexContainer > xSubItemContainer; if ( m_xContainerFactory.is() ) xSubItemContainer = Reference< XIndexContainer >( m_xContainerFactory->createInstanceWithContext( m_xComponentContext ), UNO_QUERY ); diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx index 0fbd031d0b12..3a490d4b11b8 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx @@ -34,6 +34,7 @@ #include <uiconfiguration/windowstateconfiguration.hxx> #include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/ui/UIElementType.hpp> #include <com/sun/star/container/XNameReplace.hpp> #include <com/sun/star/container/XNameContainer.hpp> diff --git a/framework/source/lomenubar/FrameHelper.cxx b/framework/source/lomenubar/FrameHelper.cxx index f7e0ba6a414a..bc90ebabb2dd 100644 --- a/framework/source/lomenubar/FrameHelper.cxx +++ b/framework/source/lomenubar/FrameHelper.cxx @@ -591,9 +591,8 @@ FrameHelper::rebuildMenu (Reference < XMenu > xMenu, //we need to access that info through a special XPopupMenuController if (isSpecialSubmenu (oUCommand)) { - Reference < XPropertySet > xMSFProps (m_xMSF, UNO_QUERY); - Reference <XComponentContext> xContext (xMSFProps->getPropertyValue (OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))), - UNO_QUERY); + Reference <XComponentContext> xContext( + comphelper::getComponentContext(m_xMSF)); Reference < XPopupMenuController > xRFC (m_xPCF->createInstanceWithArgumentsAndContext(oUCommand, m_args, @@ -736,9 +735,8 @@ FrameHelper::dispatchCommand (OUString command) { target = OUString(RTL_CONSTASCII_USTRINGPARAM("_default")); - Reference < XPropertySet > xMSFProps (m_xMSF, UNO_QUERY); - Reference <XComponentContext> xContext (xMSFProps->getPropertyValue (OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))), - UNO_QUERY); + Reference <XComponentContext> xContext( + comphelper::getComponentContext(m_xMSF)); Reference < XPopupMenuController > xRFC (m_xPCF->createInstanceWithArgumentsAndContext(OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:RecentFileList")), m_args, xContext), diff --git a/framework/source/uielement/addonstoolbarmanager.cxx b/framework/source/uielement/addonstoolbarmanager.cxx index ad1ddc476da2..1bc24dda35e1 100644 --- a/framework/source/uielement/addonstoolbarmanager.cxx +++ b/framework/source/uielement/addonstoolbarmanager.cxx @@ -50,12 +50,11 @@ #include <com/sun/star/ui/ItemType.hpp> #include <com/sun/star/frame/XToolbarController.hpp> #include <com/sun/star/frame/XDispatchProvider.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> #include <com/sun/star/ui/DockingArea.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp> - +#include <comphelper/processfactory.hxx> #include <svtools/imgdef.hxx> #include <svtools/toolboxcontroller.hxx> #include <toolkit/unohlp.hxx> @@ -235,11 +234,8 @@ void AddonsToolBarManager::FillToolbar( const Sequence< Sequence< PropertyValue } Reference< XMultiComponentFactory > xToolbarControllerFactory( m_xToolbarControllerRegistration, UNO_QUERY ); - Reference< XComponentContext > xComponentContext; - Reference< XPropertySet > xProps( m_xServiceManager, UNO_QUERY ); - - if ( xProps.is() ) - xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xComponentContext; + Reference< XComponentContext > xComponentContext( + comphelper::getComponentContext( m_xServiceManager ) ); sal_uInt32 nElements( 0 ); sal_Bool bAppendSeparator( sal_False ); diff --git a/framework/source/uielement/imagebuttontoolbarcontroller.cxx b/framework/source/uielement/imagebuttontoolbarcontroller.cxx index f7d39231d665..4fd83d43869f 100644 --- a/framework/source/uielement/imagebuttontoolbarcontroller.cxx +++ b/framework/source/uielement/imagebuttontoolbarcontroller.cxx @@ -38,7 +38,6 @@ #include <com/sun/star/frame/XControlNotificationListener.hpp> #include "com/sun/star/util/XMacroExpander.hpp" #include "com/sun/star/uno/XComponentContext.hpp" -#include "com/sun/star/beans/XPropertySet.hpp" #include <rtl/uri.hxx> #include <osl/mutex.hxx> @@ -81,16 +80,12 @@ uno::Reference< util::XMacroExpander > GetMacroExpander() if ( !xMacroExpander.is() ) { - uno::Reference< uno::XComponentContext > xContext; - uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY ); - xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xContext; - if ( xContext.is() ) - { - m_xMacroExpander = Reference< com::sun::star::util::XMacroExpander >( xContext->getValueByName( + uno::Reference< uno::XComponentContext > xContext( + comphelper::getProcessComponentContext() ); + m_xMacroExpander = Reference< com::sun::star::util::XMacroExpander >( xContext->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.util.theMacroExpander"))), UNO_QUERY ); - xMacroExpander = m_xMacroExpander; - } + xMacroExpander = m_xMacroExpander; } } diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index c7b9d7c92ebe..b79f1795bce8 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -43,7 +43,6 @@ #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/DisposedException.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XFramesSupplier.hpp> #include <com/sun/star/frame/XDesktop.hpp> #include <com/sun/star/container/XEnumeration.hpp> @@ -1217,11 +1216,8 @@ sal_Bool MenuBarManager::CreatePopupMenuController( MenuItemHandler* pMenuItemHa aPropValue.Value <<= m_xFrame; aSeq[1] <<= aPropValue; - Reference< XComponentContext > xComponentContext; - Reference< XPropertySet > xProps( getServiceFactory(), UNO_QUERY ); - - xProps->getPropertyValue( rtl::OUString( "DefaultContext" )) >>= - xComponentContext; + Reference< XComponentContext > xComponentContext( + comphelper::getComponentContext( getServiceFactory() ) ); Reference< XPopupMenuController > xPopupMenuController( xPopupMenuControllerFactory->createInstanceWithArgumentsAndContext( diff --git a/framework/source/uielement/popupmenucontroller.cxx b/framework/source/uielement/popupmenucontroller.cxx index c1afcd45c876..47e1a9cb4502 100644 --- a/framework/source/uielement/popupmenucontroller.cxx +++ b/framework/source/uielement/popupmenucontroller.cxx @@ -177,8 +177,8 @@ bool PopupMenuController::CreatePopupMenuController() throw (Exception) aPropValue.Value <<= m_xFrame; aSeq[1] <<= aPropValue; - Reference< XPropertySet > xProps( getServiceManager(), UNO_QUERY_THROW ); - Reference< XComponentContext > xComponentContext( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY_THROW ); + Reference< XComponentContext > xComponentContext( + comphelper::getComponentContext( getServiceManager() ) ); Reference< XPopupMenuController > xPopupMenuController( xPopupMenuControllerRegistration->createInstanceWithArgumentsAndContext( getCommandURL(), aSeq, xComponentContext ), UNO_QUERY ); if ( xPopupMenuController.is() ) diff --git a/framework/source/uielement/statusbarmanager.cxx b/framework/source/uielement/statusbarmanager.cxx index 692c81dc07e0..7766746ee883 100644 --- a/framework/source/uielement/statusbarmanager.cxx +++ b/framework/source/uielement/statusbarmanager.cxx @@ -50,7 +50,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/awt/Command.hpp> #include <com/sun/star/lang/DisposedException.hpp> - +#include <comphelper/processfactory.hxx> #include <toolkit/unohlp.hxx> #include <svtools/statusbarcontroller.hxx> @@ -335,13 +335,10 @@ void StatusBarManager::CreateControllers() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::CreateControllers" ); uno::Reference< lang::XMultiComponentFactory > xStatusbarControllerFactory( m_xStatusbarControllerRegistration, uno::UNO_QUERY ); - uno::Reference< uno::XComponentContext > xComponentContext; - uno::Reference< beans::XPropertySet > xProps( m_xServiceManager, uno::UNO_QUERY ); + uno::Reference< uno::XComponentContext > xComponentContext( + comphelper::getComponentContext( m_xServiceManager ) ); uno::Reference< awt::XWindow > xStatusbarWindow = VCLUnoHelper::GetInterface( m_pStatusBar ); - if ( xProps.is() ) - xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xComponentContext; - for ( sal_uInt16 i = 0; i < m_pStatusBar->GetItemCount(); i++ ) { sal_uInt16 nId = m_pStatusBar->GetItemId( i ); diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index bf39ac075d17..208fe1dc81af 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -897,17 +897,14 @@ void ToolBarManager::CreateControllers() RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::ToolBarManager::CreateControllers" ); Reference< XMultiComponentFactory > xToolbarControllerFactory( m_xToolbarControllerRegistration, UNO_QUERY ); - Reference< XComponentContext > xComponentContext; - Reference< XPropertySet > xProps( m_xServiceManager, UNO_QUERY ); + Reference< XComponentContext > xComponentContext( + comphelper::getComponentContext( m_xServiceManager ) ); Reference< XWindow > xToolbarWindow = VCLUnoHelper::GetInterface( m_pToolBar ); css::util::URL aURL; sal_Bool bHasDisabledEntries = SvtCommandOptions().HasEntries( SvtCommandOptions::CMDOPTION_DISABLED ); SvtCommandOptions aCmdOptions; - if ( xProps.is() ) - xProps->getPropertyValue( rtl::OUString( "DefaultContext" )) >>= xComponentContext; - for ( sal_uInt16 i = 0; i < m_pToolBar->GetItemCount(); i++ ) { sal_uInt16 nId = m_pToolBar->GetItemId( i ); |