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 /sfx2 | |
parent | f05d7abf93bbcf443cb0b5759ca19992e2fa85a3 (diff) |
Use comphelper::getComponentContext
...and some further clean up.
Change-Id: Id294c0f38fe0041646fc86cacbd2e19734c746a9
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/dockwin.cxx | 15 | ||||
-rw-r--r-- | sfx2/source/doc/doctemplates.cxx | 51 |
2 files changed, 18 insertions, 48 deletions
diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx index 7106771db298..d95318b00704 100644 --- a/sfx2/source/dialog/dockwin.cxx +++ b/sfx2/source/dialog/dockwin.cxx @@ -163,17 +163,12 @@ SfxDockingWrapper::SfxDockingWrapper( Window* pParentWnd , uno::Reference< awt::XWindow > xWindow; try { - uno::Reference< beans::XPropertySet > xProps( xServiceManager, uno::UNO_QUERY ); - uno::Reference< uno::XComponentContext > xContext; + uno::Reference< uno::XComponentContext > xContext( + comphelper::getComponentContext( xServiceManager ) ); - if ( xProps.is() ) - xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xContext; - if ( xContext.is() ) - { - xWindow = uno::Reference< awt::XWindow>( - xFactoryMgr->createInstanceWithArgumentsAndContext( aArgs, xContext ), - uno::UNO_QUERY ); - } + xWindow = uno::Reference< awt::XWindow>( + xFactoryMgr->createInstanceWithArgumentsAndContext( aArgs, xContext ), + uno::UNO_QUERY ); static uno::WeakReference< frame::XModuleManager2 > m_xModuleManager; diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index c7a2fa62d6b5..25ed45909bcc 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -581,29 +581,18 @@ void SfxDocTplService_Impl::getDirList() maTemplateDirs = Sequence< OUString >( nCount ); - uno::Reference< XComponentContext > xCtx; + uno::Reference< XComponentContext > xCtx( + comphelper::getComponentContext( mxFactory ) ); uno::Reference< util::XMacroExpander > xExpander; - uno::Reference< XPropertySet > xPropSet( mxFactory, UNO_QUERY ); const rtl::OUString aPrefix( "vnd.sun.star.expand:" ); - if ( xPropSet.is() ) - { - xPropSet->getPropertyValue( - rtl::OUString( - "DefaultContext" ) ) - >>= xCtx; - } + xCtx->getValueByName( + rtl::OUString( "/singletons/com.sun.star.util.theMacroExpander" ) ) + >>= xExpander; - if ( xCtx.is() ) - { - xCtx->getValueByName( - rtl::OUString( "/singletons/com.sun.star.util.theMacroExpander" ) ) - >>= xExpander; - - OSL_ENSURE( xExpander.is(), - "Unable to obtain macro expander singleton!" ); - } + OSL_ENSURE( xExpander.is(), + "Unable to obtain macro expander singleton!" ); for ( sal_uInt16 i=0; i<nCount; i++ ) { @@ -2861,28 +2850,14 @@ void SfxURLRelocator_Impl::initOfficeInstDirs() { OSL_ENSURE( mxFactory.is(), "No service manager!" ); - uno::Reference< XComponentContext > xCtx; - uno::Reference< XPropertySet > xPropSet( mxFactory, UNO_QUERY ); - if ( xPropSet.is() ) - { - xPropSet->getPropertyValue( - rtl::OUString( - "DefaultContext" ) ) - >>= xCtx; - } - - OSL_ENSURE( xCtx.is(), - "Unable to obtain component context from " - "service manager!" ); + uno::Reference< XComponentContext > xCtx( + comphelper::getComponentContext( mxFactory ) ); - if ( xCtx.is() ) - { - xCtx->getValueByName( - rtl::OUString( - "/singletons/" - "com.sun.star.util.theOfficeInstallationDirectories" ) ) + xCtx->getValueByName( + rtl::OUString( + "/singletons/" + "com.sun.star.util.theOfficeInstallationDirectories" ) ) >>= mxOfficeInstDirs; - } OSL_ENSURE( mxOfficeInstDirs.is(), "Unable to obtain office installation directory " |