summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-09-29 17:20:22 +0200
committerStephan Bergmann <sbergman@redhat.com>2012-09-29 18:18:28 +0200
commitc2ca6fabd1afc3fc07001721c2069d3c8db7000a (patch)
tree350741d6d19564bcaf00506bd7d22b4c644e0fdc
parentf05d7abf93bbcf443cb0b5759ca19992e2fa85a3 (diff)
Use comphelper::getComponentContext
...and some further clean up. Change-Id: Id294c0f38fe0041646fc86cacbd2e19734c746a9
-rw-r--r--basctl/source/basicide/baside3.cxx17
-rw-r--r--basctl/source/basicide/basides3.cxx6
-rw-r--r--basctl/source/basicide/moduldlg.cxx7
-rw-r--r--basctl/source/basicide/scriptdocument.cxx5
-rw-r--r--basctl/source/dlged/dlged.cxx12
-rw-r--r--basctl/source/dlged/propbrw.cxx4
-rw-r--r--basic/source/classes/eventatt.cxx33
-rw-r--r--basic/source/classes/sbunoobj.cxx96
-rw-r--r--basic/source/classes/sbxmod.cxx10
-rw-r--r--basic/source/uno/dlgcont.cxx28
-rw-r--r--basic/source/uno/namecont.cxx55
-rw-r--r--comphelper/source/misc/componentcontext.cxx23
-rw-r--r--connectivity/Library_postgresql-sdbc.mk1
-rw-r--r--connectivity/source/drivers/postgresql/pq_driver.cxx23
-rw-r--r--connectivity/source/resource/sharedresources.cxx9
-rw-r--r--cui/source/customize/cfg.cxx10
-rw-r--r--cui/source/customize/cfgutil.cxx6
-rw-r--r--cui/source/dialogs/scriptdlg.cxx9
-rw-r--r--cui/source/options/treeopt.cxx11
-rw-r--r--desktop/Library_offacc.mk1
-rw-r--r--desktop/inc/app.hxx2
-rw-r--r--desktop/source/app/app.cxx5
-rw-r--r--desktop/source/app/appinit.cxx19
-rw-r--r--desktop/source/offacc/acceptor.cxx18
-rw-r--r--embeddedobj/source/general/docholder.cxx11
-rw-r--r--extensions/Executable_nsplugin.mk1
-rw-r--r--extensions/source/nsplugin/source/so_instance.cxx5
-rw-r--r--fileaccess/source/FileAccess.cxx12
-rw-r--r--filter/source/xsltfilter/XSLTFilter.cxx9
-rw-r--r--framework/inc/macros/xserviceinfo.hxx8
-rw-r--r--framework/source/fwe/classes/addonsoptions.cxx11
-rw-r--r--framework/source/fwe/xml/menudocumenthandler.cxx14
-rw-r--r--framework/source/layoutmanager/toolbarlayoutmanager.cxx1
-rw-r--r--framework/source/lomenubar/FrameHelper.cxx10
-rw-r--r--framework/source/uielement/addonstoolbarmanager.cxx10
-rw-r--r--framework/source/uielement/imagebuttontoolbarcontroller.cxx13
-rw-r--r--framework/source/uielement/menubarmanager.cxx8
-rw-r--r--framework/source/uielement/popupmenucontroller.cxx4
-rw-r--r--framework/source/uielement/statusbarmanager.cxx9
-rw-r--r--framework/source/uielement/toolbarmanager.cxx7
-rw-r--r--linguistic/source/lngsvcmgr.cxx24
-rw-r--r--oox/source/core/xmlfilterbase.cxx26
-rw-r--r--oox/source/export/chartexport.cxx28
-rw-r--r--reportdesign/source/ui/report/propbrw.cxx10
-rw-r--r--sc/source/core/data/dpobject.cxx8
-rw-r--r--sc/source/core/tool/addincol.cxx18
-rw-r--r--sc/source/ui/docshell/docsh.cxx50
-rw-r--r--sc/source/ui/miscdlgs/solverutil.cxx33
-rw-r--r--sc/source/ui/vba/excelvbahelper.cxx6
-rw-r--r--sc/source/ui/vba/vbahelper.cxx15
-rw-r--r--sc/source/ui/vba/vbaworksheet.cxx6
-rw-r--r--scripting/Library_protocolhandler.mk1
-rw-r--r--scripting/source/protocolhandler/scripthandler.cxx9
-rw-r--r--scripting/source/vbaevents/eventhelper.cxx12
-rw-r--r--sd/source/core/CustomAnimationPreset.cxx20
-rw-r--r--sd/source/core/TransitionPreset.cxx22
-rw-r--r--sfx2/source/dialog/dockwin.cxx15
-rw-r--r--sfx2/source/doc/doctemplates.cxx51
-rw-r--r--svl/source/misc/urihelper.cxx13
-rw-r--r--svtools/Library_hatchwindowfactory.mk1
-rw-r--r--svtools/source/hatchwindow/documentcloser.cxx17
-rw-r--r--svtools/source/misc/templatefoldercache.cxx36
-rw-r--r--svx/source/form/fmPropBrw.cxx4
-rw-r--r--sw/source/filter/ww8/ww8toolbar.cxx4
-rw-r--r--sw/source/ui/config/mailconfigpage.cxx5
-rw-r--r--sw/source/ui/dbui/mailmergehelper.cxx16
-rw-r--r--sw/source/ui/inc/mailmergehelper.hxx20
-rw-r--r--ucb/Library_ucphier1.mk1
-rw-r--r--ucb/source/core/ucbcmds.cxx9
-rw-r--r--ucb/source/ucp/hierarchy/hierarchyprovider.cxx28
-rw-r--r--ucb/source/ucp/webdav/webdavcontent.cxx9
-rw-r--r--unotools/source/config/lingucfg.cxx13
-rw-r--r--vbahelper/source/vbahelper/vbahelper.cxx12
-rw-r--r--vcl/aqua/source/app/salinst.cxx22
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.cxx25
-rw-r--r--xmlhelp/source/cxxhelp/provider/provider.cxx13
-rw-r--r--xmlhelp/source/cxxhelp/provider/urlparameter.cxx18
-rw-r--r--xmloff/source/chart/SchXMLExport.cxx31
-rw-r--r--xmloff/source/chart/SchXMLImport.cxx18
-rw-r--r--xmloff/source/chart/SchXMLTools.cxx27
80 files changed, 339 insertions, 900 deletions
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
index 619704312955..e5fc1ce20e04 100644
--- a/basctl/source/basicide/baside3.cxx
+++ b/basctl/source/basicide/baside3.cxx
@@ -724,10 +724,7 @@ bool DialogWindow::SaveDialog()
// export dialog model to xml
Reference< container::XNameContainer > xDialogModel = GetDialog();
- Reference< XComponentContext > xContext;
- Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() );
Reference< XInputStream > xInput( xISP->createInputStream() );
@@ -1002,10 +999,8 @@ bool implImportDialog( Window* pWin, const ::rtl::OUString& rCurPath, const Scri
if( xSFI->exists( aCurPath ) )
xInput = xSFI->openFileRead( aCurPath );
- Reference< XComponentContext > xContext;
- Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XComponentContext > xContext(
+ comphelper::getComponentContext( xMSF ) );
::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() );
::rtl::OUString aXmlDlgName;
@@ -1327,10 +1322,8 @@ void DialogWindow::StoreData()
if( xDialogModel.is() )
{
- Reference< XComponentContext > xContext;
- Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() );
xLib->replaceByName( ::rtl::OUString( GetName() ), makeAny( xISP ) );
}
diff --git a/basctl/source/basicide/basides3.cxx b/basctl/source/basicide/basides3.cxx
index 5f6d86b039a2..d642a2ae1785 100644
--- a/basctl/source/basicide/basides3.cxx
+++ b/basctl/source/basicide/basides3.cxx
@@ -81,10 +81,8 @@ DialogWindow* Shell::CreateDlgWin( const ScriptDocument& rDocument, const ::rtl:
Reference< container::XNameContainer > xDialogModel( xMSF->createInstance
( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY );
Reference< XInputStream > xInput( xISP->createInputStream() );
- Reference< XComponentContext > xContext;
- Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XComponentContext > xContext(
+ comphelper::getComponentContext( xMSF ) );
::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rDocument.isDocument() ? rDocument.getDocument() : Reference< frame::XModel >() );
LocalizationMgr::setStringResourceAtDialog( rDocument, rLibName, aDlgName, xDialogModel );
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
index 0d0d867c4e4a..4a8cdb5e6261 100644
--- a/basctl/source/basicide/moduldlg.cxx
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -28,7 +28,6 @@
#include "iderdll.hxx"
#include <basic/basmgr.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/script/XLibraryContainerPassword.hpp>
#include <comphelper/processfactory.hxx>
#include <sfx2/app.hxx>
@@ -288,10 +287,8 @@ void Shell::CopyDialogResources(
Reference< container::XNameContainer > xDialogModel = Reference< container::XNameContainer >( xMSF->createInstance
( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY );
Reference< io::XInputStream > xInput( io_xISP->createInputStream() );
- Reference< XComponentContext > xContext;
- Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XComponentContext > xContext(
+ comphelper::getComponentContext( xMSF ) );
::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rSourceDoc.isDocument() ? rSourceDoc.getDocument() : Reference< frame::XModel >() );
if( xDialogModel.is() )
diff --git a/basctl/source/basicide/scriptdocument.cxx b/basctl/source/basicide/scriptdocument.cxx
index dfede33a0f73..cdf91fbc37e5 100644
--- a/basctl/source/basicide/scriptdocument.cxx
+++ b/basctl/source/basicide/scriptdocument.cxx
@@ -960,9 +960,8 @@ namespace basctl
{
::rtl::OUString aDecodedURL( aAuthority.copy( sizeof ( "vnd.sun.star.expand:" ) - 1 ) );
aDecodedURL = ::rtl::Uri::decode( aDecodedURL, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
- Reference< XComponentContext > xContext;
- Reference< XPropertySet > xProps( xMSF, UNO_QUERY_THROW );
- xContext.set( xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" )) ), UNO_QUERY_THROW );
+ Reference< XComponentContext > xContext(
+ comphelper::getComponentContext( xMSF ) );
Reference< XMacroExpander > xMacroExpander(
xContext->getValueByName(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.util.theMacroExpander" )) ),
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index 9dfb43182c94..422a9d80eba2 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -742,10 +742,8 @@ void DlgEditor::Copy()
}
// export clipboard dialog model to xml
- Reference< XComponentContext > xContext;
- Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument );
Reference< XInputStream > xStream( xISP->createInputStream() );
Sequence< sal_Int8 > DialogModelBytes;
@@ -920,10 +918,8 @@ void DlgEditor::Paste()
if ( xClipDialogModel.is() )
{
- Reference< XComponentContext > xContext;
- Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XComponentContext > xContext(
+ comphelper::getComponentContext( xMSF ) );
::xmlscript::importDialogModel( ::xmlscript::createInputStream( rtl::ByteSequence(DialogModelBytes.getArray(), DialogModelBytes.getLength()) ) , xClipDialogModel, xContext, m_xDocument );
}
diff --git a/basctl/source/dlged/propbrw.cxx b/basctl/source/dlged/propbrw.cxx
index 11529c240369..986a69b8baae 100644
--- a/basctl/source/dlged/propbrw.cxx
+++ b/basctl/source/dlged/propbrw.cxx
@@ -127,10 +127,8 @@ void PropBrw::ImplReCreateController()
try
{
- Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW );
Reference< XComponentContext > xOwnContext(
- xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
- UNO_QUERY_THROW );
+ comphelper::getComponentContext( m_xORB ) );
// a ComponentContext for the
::cppu::ContextEntry_Init aHandlerContextInfo[] =
diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx
index 1c111e2d2eda..79e2c3b707ee 100644
--- a/basic/source/classes/eventatt.cxx
+++ b/basic/source/classes/eventatt.cxx
@@ -94,23 +94,18 @@ void SFURL_firing_impl( const ScriptEvent& aScriptEvent, Any* pRet, const Refere
}
else
{
- Reference< XComponentContext > xContext;
- Reference< XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
- if ( xContext.is() )
- {
- Reference< provider::XScriptProviderFactory > xFactory(
- xContext->getValueByName(
+ Reference< XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
+ Reference< provider::XScriptProviderFactory > xFactory(
+ xContext->getValueByName(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory")) ),
- UNO_QUERY );
- OSL_ENSURE( xFactory.is(), "SFURL_firing_impl: failed to get master script provider factory" );
- if ( xFactory.is() )
- {
- Any aCtx;
- aCtx <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user"));
- xScriptProvider.set( xFactory->createScriptProvider( aCtx ), UNO_QUERY );
- }
+ UNO_QUERY );
+ OSL_ENSURE( xFactory.is(), "SFURL_firing_impl: failed to get master script provider factory" );
+ if ( xFactory.is() )
+ {
+ Any aCtx;
+ aCtx <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user"));
+ xScriptProvider.set( xFactory->createScriptProvider( aCtx ), UNO_QUERY );
}
}
@@ -469,10 +464,8 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit
if( !xISP.is() )
return;
- Reference< XComponentContext > xContext;
- Reference< XPropertySet > xProps( xMSF, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XComponentContext > xContext(
+ comphelper::getComponentContext( xMSF ) );
// Import the DialogModel
Reference< XInputStream > xInput( xISP->createInputStream() );
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index c79263493714..6735dfe6299c 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -162,26 +162,6 @@ void SetSbUnoObjectDfltPropName( SbxObject* pObj )
}
}
-Reference< XComponentContext > getComponentContext_Impl( void )
-{
- static Reference< XComponentContext > xContext;
-
- // Do we have already CoreReflection; if not obtain it
- if( !xContext.is() )
- {
- Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
- Reference< XPropertySet > xProps( xFactory, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- if (xProps.is())
- {
- xProps->getPropertyValue(
- ::rtl::OUString( "DefaultContext" ) ) >>= xContext;
- OSL_ASSERT( xContext.is() );
- }
- }
- return xContext;
-}
-
// save CoreReflection statically
Reference< XIdlReflection > getCoreReflection_Impl( void )
{
@@ -190,7 +170,8 @@ Reference< XIdlReflection > getCoreReflection_Impl( void )
// Do we have already CoreReflection; if not obtain it
if( !xCoreReflection.is() )
{
- Reference< XComponentContext > xContext = getComponentContext_Impl();
+ Reference< XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
if( xContext.is() )
{
xContext->getValueByName(
@@ -233,7 +214,8 @@ Reference< XHierarchicalNameAccess > getTypeProvider_Impl( void )
// Do we have already CoreReflection; if not obtain it
if( !xAccess.is() )
{
- Reference< XComponentContext > xContext = getComponentContext_Impl();
+ Reference< XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
if( xContext.is() )
{
xContext->getValueByName(
@@ -260,7 +242,8 @@ Reference< XTypeConverter > getTypeConverter_Impl( void )
// Do we have already CoreReflection; if not obtain it
if( !xTypeConverter.is() )
{
- Reference< XComponentContext > xContext = getComponentContext_Impl();
+ Reference< XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
if( xContext.is() )
{
xTypeConverter = Converter::create(xContext);
@@ -287,7 +270,8 @@ SbUnoObject* createOLEObject_Impl( const ::rtl::OUString& aType )
{
bNeedsInit = false;
- Reference< XComponentContext > xContext = getComponentContext_Impl();
+ Reference< XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
if( xContext.is() )
{
Reference<XMultiComponentFactory> xSMgr = xContext->getServiceManager();
@@ -3694,33 +3678,24 @@ void SbUnoService::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
}
// "Call" ctor using createInstanceWithArgumentsAndContext
- Reference < XComponentContext > xContext;
- if( xFirstParamContext.is() )
- {
- xContext = xFirstParamContext;
- }
- else
- {
- Reference < XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
- xContext.set( xProps->getPropertyValue( rtl::OUString( "DefaultContext" ) ), UNO_QUERY_THROW );
- }
+ Reference < XComponentContext > xContext(
+ xFirstParamContext.is()
+ ? xFirstParamContext
+ : comphelper::getProcessComponentContext() );
Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() );
Any aRetAny;
- if( xServiceMgr.is() )
+ ::rtl::OUString aServiceName = GetName();
+ Reference < XInterface > xRet;
+ try
{
- ::rtl::OUString aServiceName = GetName();
- Reference < XInterface > xRet;
- try
- {
- xRet = xServiceMgr->createInstanceWithArgumentsAndContext( aServiceName, args, xContext );
- }
- catch( const Exception& )
- {
- implHandleAnyException( ::cppu::getCaughtException() );
- }
- aRetAny <<= xRet;
+ xRet = xServiceMgr->createInstanceWithArgumentsAndContext( aServiceName, args, xContext );
+ }
+ catch( const Exception& )
+ {
+ implHandleAnyException( ::cppu::getCaughtException() );
}
+ aRetAny <<= xRet;
unoToSbxValue( pVar, aRetAny );
// Copy back out parameters?
@@ -3835,8 +3810,7 @@ void SbUnoSingleton::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
if( !xContextToUse.is() )
{
- Reference < XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
- xContextToUse.set( xProps->getPropertyValue( rtl::OUString( "DefaultContext" ) ), UNO_QUERY_THROW );
+ xContextToUse = comphelper::getProcessComponentContext();
--nAllowedParamCount;
}
@@ -4205,22 +4179,12 @@ void RTL_Impl_GetDefaultContext( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWr
SbxVariableRef refVar = rPar.Get(0);
- Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
- Reference< XPropertySet> xPSMPropertySet( xFactory, UNO_QUERY );
- if( xPSMPropertySet.is() )
- {
- Any aContextAny = xPSMPropertySet->getPropertyValue(
- ::rtl::OUString( "DefaultContext" ) );
+ Any aContextAny( comphelper::getProcessComponentContext() );
- SbUnoObjectRef xUnoObj = new SbUnoObject
- ( ::rtl::OUString( "DefaultContext" ),
- aContextAny );
- refVar->PutObject( (SbUnoObject*)xUnoObj );
- }
- else
- {
- refVar->PutObject( NULL );
- }
+ SbUnoObjectRef xUnoObj = new SbUnoObject
+ ( ::rtl::OUString( "DefaultContext" ),
+ aContextAny );
+ refVar->PutObject( (SbUnoObject*)xUnoObj );
}
//========================================================================
@@ -4544,7 +4508,8 @@ Reference< XInterface > createComListener( const Any& aControlAny, const ::rtl::
{
Reference< XInterface > xRet;
- Reference< XComponentContext > xContext = getComponentContext_Impl();
+ Reference< XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() );
Reference< XInvocation > xProxy = new ModuleInvocationProxy( aPrefix, xScopeObj );
@@ -4665,7 +4630,8 @@ bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pP
// For now: Take first interface that allows to instantiate COM wrapper
// TODO: Check if support for multiple interfaces is needed
- Reference< XComponentContext > xContext = getComponentContext_Impl();
+ Reference< XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() );
Reference< XSingleServiceFactory > xComImplementsFactory
(
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 3257a4ad5214..759b9b25f74b 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -139,7 +139,6 @@ DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pV
{
if ( pMod->GetModuleType() == ModuleType::DOCUMENT )
{
- Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
// Use proxy factory service to create aggregatable proxy.
SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pMod->GetObject() );
Reference< XInterface > xIf;
@@ -157,11 +156,10 @@ DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pV
{
try
{
- Reference< XMultiComponentFactory > xMFac( xFactory, UNO_QUERY_THROW );
- Reference< XPropertySet> xPSMPropertySet( xMFac, UNO_QUERY_THROW );
- Reference< XComponentContext > xCtx;
- xPSMPropertySet->getPropertyValue(
- String( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xCtx;
+ Reference< XComponentContext > xCtx(
+ comphelper::getProcessComponentContext() );
+ Reference< XMultiComponentFactory > xMFac(
+ xCtx->getServiceManager() );
Reference< XProxyFactory > xProxyFac( xMFac->createInstanceWithContext( rtl::OUString( "com.sun.star.reflection.ProxyFactory" ), xCtx ), UNO_QUERY_THROW );
m_xAggProxy = xProxyFac->createProxy( xIf );
}
diff --git a/basic/source/uno/dlgcont.cxx b/basic/source/uno/dlgcont.cxx
index 3f1101c4eac0..2cfe035a21b7 100644
--- a/basic/source/uno/dlgcont.cxx
+++ b/basic/source/uno/dlgcont.cxx
@@ -24,7 +24,6 @@
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess2.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/io/XActiveDataSource.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
@@ -117,23 +116,12 @@ bool SAL_CALL SfxDialogLibraryContainer::isLibraryElementValid( Any aElement ) c
bool writeOasis2OOoLibraryElement(
Reference< XInputStream > xInput, Reference< XOutputStream > xOutput )
{
- Reference< XMultiServiceFactory > xMSF(
- comphelper::getProcessServiceFactory() );
-
- Reference< XComponentContext > xContext;
- Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- OSL_VERIFY( xProps->getPropertyValue(
- OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
Reference< lang::XMultiComponentFactory > xSMgr(
xContext->getServiceManager() );
- if (! xSMgr.is())
- {
- return sal_False;
- }
-
Reference< xml::sax::XParser > xParser(
xSMgr->createInstanceWithContext(
OUString( RTL_CONSTASCII_USTRINGPARAM(
@@ -267,10 +255,8 @@ void SfxDialogLibraryContainer::storeLibrariesToStorage( const uno::Reference< e
Reference< io::XInputStream > xInput( xISP->createInputStream() );
Reference< XNameContainer > xDialogModel( mxMSF->createInstance
( OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY );
- Reference< XComponentContext > xContext;
- Reference< beans::XPropertySet > xProps( mxMSF, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XComponentContext > xContext(
+ comphelper::getComponentContext( mxMSF ) );
::xmlscript::importDialogModel( xInput, xDialogModel, xContext, mxOwnerDocument );
std::vector< rtl::OUString > vEmbeddedImageURLs;
GraphicObject::InspectForGraphicObjectImageURL( Reference< XInterface >( xDialogModel, UNO_QUERY ), vEmbeddedImageURLs );
@@ -351,10 +337,8 @@ Any SAL_CALL SfxDialogLibraryContainer::importLibraryElement
if( !xInput.is() )
return aRetAny;
- Reference< XComponentContext > xContext;
- Reference< beans::XPropertySet > xProps( mxMSF, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
+ Reference< XComponentContext > xContext(
+ comphelper::getComponentContext( mxMSF ) );
InputSource source;
source.aInputStream = xInput;
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index f8d946edd69c..77ced57a2eec 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -2725,29 +2725,20 @@ OUString SfxLibraryContainer::expand_url( const OUString& url )
{
if( !mxMacroExpander.is() )
{
- Reference< XPropertySet > xProps( mxMSF, UNO_QUERY_THROW );
- if( xProps.is() )
+ Reference< XComponentContext > xContext(
+ comphelper::getComponentContext( mxMSF ) );
+ Reference< util::XMacroExpander > xExpander;
+ xContext->getValueByName(
+ OUSTR("/singletons/com.sun.star.util.theMacroExpander") ) >>= xExpander;
+ if(! xExpander.is())
{
- Reference< XComponentContext > xContext;
- xProps->getPropertyValue(
- OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xContext;
- SAL_WARN_IF(!xContext.is(), "basic", "no DefaultContext");
- if( xContext.is() )
- {
- Reference< util::XMacroExpander > xExpander;
- xContext->getValueByName(
- OUSTR("/singletons/com.sun.star.util.theMacroExpander") ) >>= xExpander;
- if(! xExpander.is())
- {
- throw uno::DeploymentException(
- OUSTR("no macro expander singleton available!"), Reference< XInterface >() );
- }
- MutexGuard guard( Mutex::getGlobalMutex() );
- if( !mxMacroExpander.is() )
- {
- mxMacroExpander = xExpander;
- }
- }
+ throw uno::DeploymentException(
+ OUSTR("no macro expander singleton available!"), Reference< XInterface >() );
+ }
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( !mxMacroExpander.is() )
+ {
+ mxMacroExpander = xExpander;
}
}
@@ -3172,7 +3163,8 @@ void SAL_CALL SfxLibrary::removeChangesListener( const Reference< XChangesListen
#define sDialogLibMediaType "application/vnd.sun.star.dialog-library"
ScriptExtensionIterator::ScriptExtensionIterator( void )
- : m_eState( USER_EXTENSIONS )
+ : m_xContext( comphelper::getProcessComponentContext() )
+ , m_eState( USER_EXTENSIONS )
, m_bUserPackagesLoaded( false )
, m_bSharedPackagesLoaded( false )
, m_bBundledPackagesLoaded( false )
@@ -3180,22 +3172,7 @@ ScriptExtensionIterator::ScriptExtensionIterator( void )
, m_iSharedPackage( 0 )
, m_iBundledPackage( 0 )
, m_pScriptSubPackageIterator( NULL )
-{
- Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
- Reference< XPropertySet > xProps( xFactory, UNO_QUERY_THROW );
- if (xProps.is())
- {
- xProps->getPropertyValue(
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= m_xContext;
- SAL_WARN_IF(!m_xContext.is(), "basic", "no DefaultContext");
- }
- if( !m_xContext.is() )
- {
- throw RuntimeException(
- ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScriptExtensionIterator::init(), no XComponentContext")),
- Reference< XInterface >() );
- }
-}
+{}
rtl::OUString ScriptExtensionIterator::nextBasicOrDialogLibrary( bool& rbPureDialogLib )
{
diff --git a/comphelper/source/misc/componentcontext.cxx b/comphelper/source/misc/componentcontext.cxx
index df7db6a16185..8ec65d33542e 100644
--- a/comphelper/source/misc/componentcontext.cxx
+++ b/comphelper/source/misc/componentcontext.cxx
@@ -18,7 +18,7 @@
*/
#include <comphelper/componentcontext.hxx>
-
+#include <comphelper/processfactory.hxx>
#include <com/sun/star/lang/NullPointerException.hpp>
#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -53,8 +53,6 @@ namespace comphelper
{
if ( m_xContext.is() )
m_xORB = m_xContext->getServiceManager();
- if ( !m_xORB.is() )
- throw NullPointerException();
}
//------------------------------------------------------------------------
@@ -63,23 +61,8 @@ namespace comphelper
if ( !_rxLegacyFactory.is() )
throw NullPointerException();
- try
- {
- Reference< XPropertySet > xFactoryProperties( _rxLegacyFactory, UNO_QUERY_THROW );
- m_xContext = Reference< XComponentContext >(
- xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
- UNO_QUERY );
- }
- catch( const RuntimeException& ) { throw; }
- catch( const Exception& )
- {
- throw RuntimeException();
- }
-
- if ( m_xContext.is() )
- m_xORB = m_xContext->getServiceManager();
- if ( !m_xORB.is() )
- throw NullPointerException();
+ m_xContext = comphelper::getComponentContext( _rxLegacyFactory );
+ m_xORB = m_xContext->getServiceManager();
}
//------------------------------------------------------------------------
diff --git a/connectivity/Library_postgresql-sdbc.mk b/connectivity/Library_postgresql-sdbc.mk
index 1a9f8eb1dd6c..4ce53d8eada0 100644
--- a/connectivity/Library_postgresql-sdbc.mk
+++ b/connectivity/Library_postgresql-sdbc.mk
@@ -36,6 +36,7 @@ $(eval $(call gb_Library_add_defs,postgresql-sdbc,\
$(eval $(call gb_Library_use_sdk_api,postgresql-sdbc))
$(eval $(call gb_Library_use_libraries,postgresql-sdbc,\
+ comphelper \
cppu \
cppuhelper \
sal \
diff --git a/connectivity/source/drivers/postgresql/pq_driver.cxx b/connectivity/source/drivers/postgresql/pq_driver.cxx
index ed8480c318c4..5a8dd9c15bf3 100644
--- a/connectivity/source/drivers/postgresql/pq_driver.cxx
+++ b/connectivity/source/drivers/postgresql/pq_driver.cxx
@@ -57,13 +57,12 @@
#include <stdio.h>
+#include <comphelper/processfactory.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/compbase1.hxx>
#include <cppuhelper/compbase2.hxx>
#include <cppuhelper/implementationentry.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
-
#include "pq_driver.hxx"
using rtl::OUString;
@@ -86,7 +85,6 @@ using com::sun::star::uno::XComponentContext;
using com::sun::star::uno::Any;
using com::sun::star::beans::PropertyValue;
-using com::sun::star::beans::XPropertySet;
using com::sun::star::sdbc::XConnection;
using com::sun::star::sdbc::SQLException;
@@ -352,26 +350,17 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
// XSingleComponentFactory interface ...
void * pRet = 0;
Reference< XSingleComponentFactory > xFactory;
- Reference< XInterface > xSmgr( (XInterface * ) pServiceManager );
+ Reference< com::sun::star::lang::XMultiServiceFactory > xSmgr(
+ static_cast< XInterface * >(pServiceManager),
+ com::sun::star::uno::UNO_QUERY_THROW );
for( sal_Int32 i = 0 ; g_entries[i].create ; i ++ )
{
OUString implName = g_entries[i].getImplementationName();
if( 0 == implName.compareToAscii( pImplName ) )
{
- Reference< XComponentContext > defaultContext;
- Reference< XPropertySet > propSet( xSmgr, UNO_QUERY );
- if( propSet.is() )
- {
- try
- {
- propSet->getPropertyValue( ASCII_STR( "DefaultContext" ) ) >>= defaultContext;
- }
- catch( com::sun::star::uno::Exception & )
- {
- // if there is no default context, ignore it
- }
- }
+ Reference< XComponentContext > defaultContext(
+ comphelper::getComponentContext( xSmgr ) );
xFactory = new pq_sdbc_driver::OOneInstanceComponentFactory(
implName,
g_entries[i].create,
diff --git a/connectivity/source/resource/sharedresources.cxx b/connectivity/source/resource/sharedresources.cxx
index 246591063547..902807829cb5 100644
--- a/connectivity/source/resource/sharedresources.cxx
+++ b/connectivity/source/resource/sharedresources.cxx
@@ -22,7 +22,6 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/officeresourcebundle.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <tools/diagnose_ex.h>
@@ -35,8 +34,6 @@ namespace connectivity
/** === begin UNO using === **/
using ::com::sun::star::uno::Reference;
- using ::com::sun::star::beans::XPropertySet;
- using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::uno::XComponentContext;
using ::com::sun::star::uno::Exception;
/** === end UNO using === **/
@@ -82,12 +79,8 @@ namespace connectivity
{
try
{
- Reference< XPropertySet > xFactoryProps(
- ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
Reference< XComponentContext > xContext(
- xFactoryProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
- UNO_QUERY_THROW
- );
+ comphelper::getProcessComponentContext() );
m_pResourceBundle.reset( new ::comphelper::OfficeResourceBundle( xContext, "cnr" ) );
}
catch( const Exception& )
diff --git a/cui/source/customize/cfg.cxx b/cui/source/customize/cfg.cxx
index f7dc04eae4c4..5b9b3170f65e 100644
--- a/cui/source/customize/cfg.cxx
+++ b/cui/source/customize/cfg.cxx
@@ -888,15 +888,9 @@ SaveInData::SaveInData(
bDocConfig( isDocConfig ),
bReadOnly( sal_False ),
m_xCfgMgr( xCfgMgr ),
- m_xParentCfgMgr( xParentCfgMgr )
+ m_xParentCfgMgr( xParentCfgMgr ),
+ m_xComponentContext( comphelper::getProcessComponentContext() )
{
- uno::Reference< beans::XPropertySet > xProps(
- ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
-
- xProps->getPropertyValue(
- OUString("DefaultContext" ))
- >>= m_xComponentContext;
-
m_aSeparatorSeq.realloc( 1 );
m_aSeparatorSeq[0].Name = OUString( ITEM_DESCRIPTOR_TYPE );
m_aSeparatorSeq[0].Value <<= css::ui::ItemType::SEPARATOR_LINE;
diff --git a/cui/source/customize/cfgutil.cxx b/cui/source/customize/cfgutil.cxx
index 405c6fa83e10..4d2be18383e7 100644
--- a/cui/source/customize/cfgutil.cxx
+++ b/cui/source/customize/cfgutil.cxx
@@ -596,12 +596,10 @@ void SfxConfigGroupListBox_Impl::Init(const css::uno::Reference< css::lang::XMul
OSL_TRACE("** ** About to initialise SF Scripts");
// Add Scripting Framework entries
Reference< browse::XBrowseNode > rootNode;
- Reference< XComponentContext > xCtx;
+ Reference< XComponentContext > xCtx(
+ comphelper::getProcessComponentContext() );
try
{
- Reference < beans::XPropertySet > xProps(
- ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
- xCtx.set( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY_THROW );
Reference< browse::XBrowseNodeFactory > xFac( xCtx->getValueByName(
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.script.browse.theBrowseNodeFactory") ) ), UNO_QUERY_THROW );
rootNode.set( xFac->createView( browse::BrowseNodeFactoryViewTypes::MACROSELECTOR ) );
diff --git a/cui/source/dialogs/scriptdlg.cxx b/cui/source/dialogs/scriptdlg.cxx
index 2c7b1544dd74..e91e53fb67d3 100644
--- a/cui/source/dialogs/scriptdlg.cxx
+++ b/cui/source/dialogs/scriptdlg.cxx
@@ -164,7 +164,8 @@ void SFTreeListBox::Init( const ::rtl::OUString& language )
deleteAllTree();
Reference< browse::XBrowseNode > rootNode;
- Reference< XComponentContext > xCtx;
+ Reference< XComponentContext > xCtx(
+ comphelper::getProcessComponentContext() );
Sequence< Reference< browse::XBrowseNode > > children;
@@ -175,12 +176,6 @@ void SFTreeListBox::Init( const ::rtl::OUString& language )
try
{
- Reference < beans::XPropertySet > xProps(
- ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
-
- xCtx.set( xProps->getPropertyValue( rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("DefaultContext" ))), UNO_QUERY_THROW );
-
Reference< browse::XBrowseNodeFactory > xFac(
xCtx->getValueByName( singleton ), UNO_QUERY_THROW );
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 19c6a5070690..57189590616b 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -835,13 +835,10 @@ void OfaTreeOptionsDialog::ActivateLastSelection()
if ( bMustExpand )
{
- Reference< XComponentContext > xContext;
- Reference< XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
- xProps->getPropertyValue(
- ::rtl::OUString( "DefaultContext" ) ) >>= xContext;
- if ( xContext.is() )
- m_xMacroExpander = Reference< com::sun::star::util::XMacroExpander >(
- xContext->getValueByName( ::rtl::OUString( "/singletons/com.sun.star.util.theMacroExpander" ) ), UNO_QUERY );
+ Reference< XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
+ m_xMacroExpander = Reference< com::sun::star::util::XMacroExpander >(
+ xContext->getValueByName( ::rtl::OUString( "/singletons/com.sun.star.util.theMacroExpander" ) ), UNO_QUERY );
}
SvLBoxEntry* pTemp = aTreeLB.First();
diff --git a/desktop/Library_offacc.mk b/desktop/Library_offacc.mk
index 8272b4d49920..6e3c84589d76 100644
--- a/desktop/Library_offacc.mk
+++ b/desktop/Library_offacc.mk
@@ -34,6 +34,7 @@ $(eval $(call gb_Library_set_include,offacc,\
$(eval $(call gb_Library_use_sdk_api,offacc))
$(eval $(call gb_Library_use_libraries,offacc,\
+ comphelper \
cppu \
cppuhelper \
sal \
diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx
index 7b8359d44d15..4f56c32560e7 100644
--- a/desktop/inc/app.hxx
+++ b/desktop/inc/app.hxx
@@ -144,8 +144,6 @@ class Desktop : public Application
void RegisterServices();
void DeregisterServices();
- void DestroyApplicationServiceManager( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xSMgr );
-
void CreateTemporaryDirectory();
void RemoveTemporaryDirectory();
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 4741ce6833a8..cff9f8ed65e6 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -665,8 +665,9 @@ void Desktop::DeInit()
// close splashscreen if it's still open
CloseSplashScreen();
- Reference<XMultiServiceFactory> xXMultiServiceFactory(::comphelper::getProcessServiceFactory());
- DestroyApplicationServiceManager( xXMultiServiceFactory );
+ Reference< XComponent >(
+ comphelper::getProcessComponentContext(), UNO_QUERY_THROW )->
+ dispose();
// nobody should get a destroyd service factory...
::comphelper::setProcessServiceFactory( NULL );
diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx
index 367b77ab08fd..157621ac92ed 100644
--- a/desktop/source/app/appinit.cxx
+++ b/desktop/source/app/appinit.cxx
@@ -128,25 +128,6 @@ void Desktop::InitApplicationServiceManager()
comphelper::setProcessServiceFactory(sm);
}
-void Desktop::DestroyApplicationServiceManager( Reference< XMultiServiceFactory >& xSMgr )
-{
- Reference< XPropertySet > xProps( xSMgr, UNO_QUERY );
- if ( xProps.is() )
- {
- try
- {
- Reference< XComponent > xComp;
- if (xProps->getPropertyValue( OUString( "DefaultContext" )) >>= xComp )
- {
- xComp->dispose();
- }
- }
- catch (const UnknownPropertyException&)
- {
- }
- }
-}
-
void Desktop::RegisterServices()
{
if( !m_bServicesRegistered )
diff --git a/desktop/source/offacc/acceptor.cxx b/desktop/source/offacc/acceptor.cxx
index 2fd0da302885..4510f65dcbc5 100644
--- a/desktop/source/offacc/acceptor.cxx
+++ b/desktop/source/offacc/acceptor.cxx
@@ -31,10 +31,9 @@
#include <unotools/bootstrap.hxx>
#include <tools/stream.hxx>
#include <vcl/svapp.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/bridge/BridgeFactory.hpp>
#include <com/sun/star/uno/XNamingService.hpp>
-
+#include <comphelper/processfactory.hxx>
#include <cppuhelper/factory.hxx>
namespace desktop
@@ -45,15 +44,6 @@ extern "C" void workerfunc (void * acc)
((Acceptor*)acc)->run();
}
-static Reference<XComponentContext> getComponentContext( const Reference<XMultiServiceFactory>& rFactory)
-{
- Reference<XComponentContext> rContext;
- Reference< XPropertySet > rPropSet( rFactory, UNO_QUERY );
- Any a = rPropSet->getPropertyValue( ::rtl::OUString( "DefaultContext" ) );
- a >>= rContext;
- return rContext;
-}
-
Mutex Acceptor::m_aMutex;
Acceptor::Acceptor( const Reference< XMultiServiceFactory >& rFactory )
@@ -66,7 +56,7 @@ Acceptor::Acceptor( const Reference< XMultiServiceFactory >& rFactory )
{
m_rSMgr = rFactory;
// get component context
- m_rContext = getComponentContext(m_rSMgr);
+ m_rContext = comphelper::getComponentContext(m_rSMgr);
m_rAcceptor = Reference< XAcceptor > (m_rSMgr->createInstance(
rtl::OUString("com.sun.star.connection.Acceptor" )),
UNO_QUERY );
@@ -266,7 +256,7 @@ Reference<XInterface> SAL_CALL AccInstanceProvider::getInstance (const OUString&
}
else if(aName.compareToAscii( "StarOffice.ComponentContext" ) == 0 )
{
- rInstance = getComponentContext( m_rSMgr );
+ rInstance = comphelper::getComponentContext( m_rSMgr );
}
else if ( aName.compareToAscii("StarOffice.NamingService" ) == 0 )
{
@@ -278,7 +268,7 @@ Reference<XInterface> SAL_CALL AccInstanceProvider::getInstance (const OUString&
rNamingService->registerObject(
OUString("StarOffice.ServiceManager" ), m_rSMgr );
rNamingService->registerObject(
- OUString("StarOffice.ComponentContext" ), getComponentContext( m_rSMgr ));
+ OUString("StarOffice.ComponentContext" ), comphelper::getComponentContext( m_rSMgr ));
rInstance = rNamingService;
}
}
diff --git a/embeddedobj/source/general/docholder.cxx b/embeddedobj/source/general/docholder.cxx
index 65235d0f4d17..75643c901bda 100644
--- a/embeddedobj/source/general/docholder.cxx
+++ b/embeddedobj/source/general/docholder.cxx
@@ -18,7 +18,6 @@
*/
#include <com/sun/star/embed/Aspects.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp>
#include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -635,15 +634,9 @@ uno::Reference< container::XIndexAccess > DocumentHolder::MergeMenuesForInplace(
uno::Reference< lang::XSingleComponentFactory > xIndAccessFact( xContMenu, uno::UNO_QUERY_THROW );
- uno::Reference< uno::XComponentContext > xComponentContext;
-
- uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
- if ( xProps.is() )
- xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>=
- xComponentContext;
-
uno::Reference< container::XIndexContainer > xMergedMenu(
- xIndAccessFact->createInstanceWithContext( xComponentContext ),
+ xIndAccessFact->createInstanceWithContext(
+ comphelper::getProcessComponentContext() ),
uno::UNO_QUERY_THROW );
FindConnectPoints( xContMenu, nContPoints );
diff --git a/extensions/Executable_nsplugin.mk b/extensions/Executable_nsplugin.mk
index 05bf003cd550..0f6af603c9ee 100644
--- a/extensions/Executable_nsplugin.mk
+++ b/extensions/Executable_nsplugin.mk
@@ -53,6 +53,7 @@ $(eval $(call gb_Executable_add_libs,nsplugin,\
))
$(eval $(call gb_Executable_use_libraries,nsplugin,\
+ comphelper \
cppu \
cppuhelper \
sal \
diff --git a/extensions/source/nsplugin/source/so_instance.cxx b/extensions/source/nsplugin/source/so_instance.cxx
index b70a3e60ab40..c9b6ee9212df 100644
--- a/extensions/source/nsplugin/source/so_instance.cxx
+++ b/extensions/source/nsplugin/source/so_instance.cxx
@@ -38,6 +38,7 @@
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <com/sun/star/presentation/XPresentation.hpp>
#include <com/sun/star/presentation/XPresentationSupplier.hpp>
+#include <comphelper/processfactory.hxx>
#include <vcl/window.hxx>
#include <rtl/textenc.h>
#include <rtl/locale.h>
@@ -239,8 +240,8 @@ sal_Bool SoPluginInstance::LoadDocument(NSP_HWND hParent)
}
//create stream for the document
- Reference< beans::XPropertySet > xFactoryProperties( mxRemoteMSF, uno::UNO_QUERY );
- Reference< uno::XComponentContext > xContext( xFactoryProperties->getPropertyValue( "DefaultContext" ), UNO_QUERY );
+ Reference< uno::XComponentContext > xContext(
+ comphelper::getComponentContext( mxRemoteMSF ) );
Reference< ucb::XSimpleFileAccess2 > xSimpleFileAccess( ucb::SimpleFileAccess::create(xContext) );
Reference<io::XInputStream> xInputStream = xSimpleFileAccess->openFileRead( m_sURL );
diff --git a/fileaccess/source/FileAccess.cxx b/fileaccess/source/FileAccess.cxx
index 478a340bf823..b4c45db5beda 100644
--- a/fileaccess/source/FileAccess.cxx
+++ b/fileaccess/source/FileAccess.cxx
@@ -31,7 +31,6 @@
#include <tools/stream.hxx>
#include <com/sun/star/beans/Property.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/io/XActiveDataSink.hpp>
#include <com/sun/star/io/XActiveDataSource.hpp>
@@ -253,15 +252,8 @@ void OFileAccess::transferImpl( const rtl::OUString& rSource,
try
{
- Reference< XComponentContext > xCtx;
- Reference< XPropertySet > xPropSet( mxSMgr, UNO_QUERY_THROW );
- if ( xPropSet.is() )
- {
- xPropSet->getPropertyValue(
- rtl::OUString(
- "DefaultContext" ) )
- >>= xCtx;
- }
+ Reference< XComponentContext > xCtx(
+ comphelper::getComponentContext( mxSMgr ) );
Reference< XMacroExpander > xExpander;
diff --git a/filter/source/xsltfilter/XSLTFilter.cxx b/filter/source/xsltfilter/XSLTFilter.cxx
index a5b28d571c9b..ba8503f7238a 100644
--- a/filter/source/xsltfilter/XSLTFilter.cxx
+++ b/filter/source/xsltfilter/XSLTFilter.cxx
@@ -58,7 +58,6 @@
#include <com/sun/star/xml/sax/SAXException.hpp>
#include <com/sun/star/xml/XImportFilter.hpp>
#include <com/sun/star/xml/XExportFilter.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/util/XMacroExpander.hpp>
@@ -190,12 +189,8 @@ m_rServiceFactory(r), m_bTerminated(sal_False), m_bError(sal_False)
::rtl::OUString sExpandedUrl;
try
{
- css::uno::Reference<XComponentContext> xContext;
- css::uno::Reference<XPropertySet> xProps(m_rServiceFactory,
- UNO_QUERY_THROW);
- xContext.set(xProps->getPropertyValue(::rtl::OUString(
- "DefaultContext" )),
- UNO_QUERY_THROW);
+ css::uno::Reference<XComponentContext> xContext(
+ comphelper::getComponentContext(m_rServiceFactory));
css::uno::Reference<XMacroExpander>
xMacroExpander(
xContext->getValueByName(
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 );
diff --git a/linguistic/source/lngsvcmgr.cxx b/linguistic/source/lngsvcmgr.cxx
index 0a5de43332f2..acb037817002 100644
--- a/linguistic/source/lngsvcmgr.cxx
+++ b/linguistic/source/lngsvcmgr.cxx
@@ -1088,10 +1088,8 @@ void LngSvcMgr::GetAvailableSpellSvcs_Impl()
{
try
{
- uno::Reference < uno::XComponentContext > xContext;
- uno::Reference< beans::XPropertySet > xProps( xFac, uno::UNO_QUERY );
-
- xProps->getPropertyValue( "DefaultContext" ) >>= xContext;
+ uno::Reference < uno::XComponentContext > xContext(
+ comphelper::getComponentContext( xFac ) );
xSvc = uno::Reference< linguistic2::XSpellChecker >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY );
}
catch (const uno::Exception &)
@@ -1152,10 +1150,8 @@ void LngSvcMgr::GetAvailableGrammarSvcs_Impl()
{
try
{
- uno::Reference < uno::XComponentContext > xContext;
- uno::Reference< beans::XPropertySet > xProps( xFac, uno::UNO_QUERY );
-
- xProps->getPropertyValue( "DefaultContext" ) >>= xContext;
+ uno::Reference < uno::XComponentContext > xContext(
+ comphelper::getComponentContext( xFac ) );
xSvc = uno::Reference< linguistic2::XProofreader >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY );
}
catch (const uno::Exception &)
@@ -1215,10 +1211,8 @@ void LngSvcMgr::GetAvailableHyphSvcs_Impl()
{
try
{
- uno::Reference < uno::XComponentContext > xContext;
- uno::Reference< beans::XPropertySet > xProps( xFac, uno::UNO_QUERY );
-
- xProps->getPropertyValue( "DefaultContext" ) >>= xContext;
+ uno::Reference < uno::XComponentContext > xContext(
+ comphelper::getComponentContext( xFac ) );
xSvc = uno::Reference< linguistic2::XHyphenator >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY );
}
@@ -1281,10 +1275,8 @@ void LngSvcMgr::GetAvailableThesSvcs_Impl()
{
try
{
- uno::Reference < uno::XComponentContext > xContext;
- uno::Reference< beans::XPropertySet > xProps( xFac, uno::UNO_QUERY );
-
- xProps->getPropertyValue( "DefaultContext" ) >>= xContext;
+ uno::Reference < uno::XComponentContext > xContext(
+ comphelper::getComponentContext( xFac ) );
xSvc = uno::Reference< linguistic2::XThesaurus >( ( xCompFactory.is() ? xCompFactory->createInstanceWithContext( xContext ) : xFactory->createInstance() ), uno::UNO_QUERY );
}
catch (const uno::Exception &)
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 06773dc4be9e..70b39364e099 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -44,7 +44,6 @@
#include <com/sun/star/document/XOOXMLDocumentPropertiesImporter.hpp>
#include <com/sun/star/xml/dom/XDocument.hpp>
#include <com/sun/star/xml/dom/DocumentBuilder.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/mediadescriptor.hxx>
#include <oox/core/filterdetect.hxx>
@@ -56,7 +55,6 @@ using ::com::sun::star::xml::dom::DocumentBuilder;
using ::com::sun::star::xml::dom::XDocument;
using ::com::sun::star::xml::dom::XDocumentBuilder;
using ::com::sun::star::xml::sax::XFastSAXSerializable;
-using ::com::sun::star::beans::XPropertySet;
using ::com::sun::star::lang::XComponent;
namespace oox {
@@ -194,26 +192,6 @@ XmlFilterBaseImpl::XmlFilterBaseImpl( const Reference< XComponentContext >& rxCo
maFastParser.registerNamespace( ids[i].Second );
}
-
-static Reference< XComponentContext > lcl_getComponentContext(Reference< XMultiServiceFactory > aFactory)
-{
- Reference< XComponentContext > xContext;
- try
- {
- Reference< XPropertySet > xFactProp( aFactory, UNO_QUERY );
- if( xFactProp.is() )
- xFactProp->getPropertyValue( "DefaultContext") >>= xContext;
- }
- catch( Exception& )
- {}
-
- return xContext;
-}
-
-// ============================================================================
-
-// ============================================================================
-
XmlFilterBase::XmlFilterBase( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
FilterBase( rxContext ),
mxImpl( new XmlFilterBaseImpl( rxContext ) ),
@@ -233,7 +211,7 @@ void XmlFilterBase::importDocumentProperties() throw()
Reference< XMultiServiceFactory > xFactory( getServiceFactory(), UNO_QUERY );
MediaDescriptor aMediaDesc( getMediaDescriptor() );
Reference< XInputStream > xInputStream;
- Reference< XComponentContext > xContext = lcl_getComponentContext(getServiceFactory());
+ Reference< XComponentContext > xContext = comphelper::getComponentContext(getServiceFactory());
::oox::core::FilterDetect aDetector( xContext );
xInputStream = aDetector.extractUnencryptedPackage( aMediaDesc );
Reference< XComponent > xModel( getModel(), UNO_QUERY );
@@ -357,7 +335,7 @@ Reference<XDocument> XmlFilterBase::importFragment( const ::rtl::OUString& aFrag
{
// create the dom parser
Reference< XComponentContext > xContext =
- lcl_getComponentContext(getServiceFactory());
+ comphelper::getComponentContext(getServiceFactory());
Reference<XDocumentBuilder> xDomBuilder( DocumentBuilder::create(xContext) );
// create DOM from fragment
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 65195432d41e..08cc68c29f9e 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -121,21 +121,6 @@ namespace oox { namespace drawingml {
if ( GETA(propName) ) \
mAny >>= variable;
-Reference< uno::XComponentContext > lcl_getComponentContext()
-{
- Reference< uno::XComponentContext > xContext;
- try
- {
- Reference< beans::XPropertySet > xFactProp( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
- if( xFactProp.is())
- xFactProp->getPropertyValue(OUString("DefaultContext")) >>= xContext;
- }
- catch( uno::Exception& )
- {}
-
- return xContext;
-}
-
class lcl_MatchesRole : public ::std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool >
{
public:
@@ -217,13 +202,12 @@ Reference< chart2::data::XLabeledDataSequence > lcl_getCategories( const Referen
Reference< chart2::data::XDataSource > lcl_createDataSource(
const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aData )
{
- Reference< chart2::data::XDataSink > xSink;
- Reference< uno::XComponentContext > xContext( lcl_getComponentContext());
- if( xContext.is() )
- xSink.set(
- xContext->getServiceManager()->createInstanceWithContext(
- OUString("com.sun.star.chart2.data.DataSource"),
- xContext ), uno::UNO_QUERY_THROW );
+ Reference< uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
+ Reference< chart2::data::XDataSink > xSink(
+ xContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.chart2.data.DataSource", xContext ),
+ uno::UNO_QUERY_THROW );
if( xSink.is())
xSink->setData( aData );
diff --git a/reportdesign/source/ui/report/propbrw.cxx b/reportdesign/source/ui/report/propbrw.cxx
index 3ad3355426bc..42a195cca4de 100644
--- a/reportdesign/source/ui/report/propbrw.cxx
+++ b/reportdesign/source/ui/report/propbrw.cxx
@@ -132,16 +132,10 @@ PropBrw::PropBrw(const Reference< XMultiServiceFactory >& _xORB,Window* pParen
if (m_xMeAsFrame.is())
{
- Reference< XComponentContext > xOwnContext;
+ Reference< XComponentContext > xOwnContext(
+ comphelper::getComponentContext( m_xORB ) );
try
{
- // our own component context
- Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW );
- xOwnContext.set(
- xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
- UNO_QUERY_THROW );
-
- // a ComponentContext for the
::cppu::ContextEntry_Init aHandlerContextInfo[] =
{
::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ), makeAny( m_pDesignView->getController().getModel() )),
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index a9462b6465e1..8c5e0c4a0274 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2628,9 +2628,6 @@ uno::Sequence<rtl::OUString> ScDPObject::GetRegisteredSources()
return aSeq;
}
-// use getContext from addincol.cxx
-uno::Reference<uno::XComponentContext> getContext(uno::Reference<lang::XMultiServiceFactory> xMSF);
-
uno::Reference<sheet::XDimensionsSupplier> ScDPObject::CreateSource( const ScDPServiceDesc& rDesc )
{
rtl::OUString aImplName = rDesc.aServiceName;
@@ -2664,9 +2661,10 @@ uno::Reference<sheet::XDimensionsSupplier> ScDPObject::CreateSource( const ScDPS
// passing the context to the component (see ScUnoAddInCollection::Initialize)
uno::Reference<uno::XInterface> xInterface;
- uno::Reference<uno::XComponentContext> xCtx = getContext(xManager);
+ uno::Reference<uno::XComponentContext> xCtx(
+ comphelper::getComponentContext(xManager));
uno::Reference<lang::XSingleComponentFactory> xCFac( xIntFac, uno::UNO_QUERY );
- if (xCtx.is() && xCFac.is())
+ if (xCFac.is())
xInterface = xCFac->createInstanceWithContext(xCtx);
if (!xInterface.is())
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 33c92320c7b7..ac3b81272a76 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -281,19 +281,6 @@ void ScUnoAddInCollection::Clear()
bInitialized = false;
}
-uno::Reference<uno::XComponentContext> getContext(uno::Reference<lang::XMultiServiceFactory> xMSF)
-{
- uno::Reference<uno::XComponentContext> xCtx;
- try {
- uno::Reference<beans::XPropertySet> xPropset(xMSF, uno::UNO_QUERY);
- xPropset->getPropertyValue(
- ::rtl::OUString("DefaultContext")) >>= xCtx;
- }
- catch ( uno::Exception & ) {
- }
- return xCtx;
-}
-
void ScUnoAddInCollection::Initialize()
{
OSL_ENSURE( !bInitialized, "Initialize twice?" );
@@ -321,9 +308,10 @@ void ScUnoAddInCollection::Initialize()
// passing the context to the component
uno::Reference<uno::XInterface> xInterface;
- uno::Reference<uno::XComponentContext> xCtx = getContext(xManager);
+ uno::Reference<uno::XComponentContext> xCtx(
+ comphelper::getComponentContext(xManager));
uno::Reference<lang::XSingleComponentFactory> xCFac( xIntFac, uno::UNO_QUERY );
- if (xCtx.is() && xCFac.is())
+ if (xCFac.is())
{
xInterface = xCFac->createInstanceWithContext(xCtx);
if (xInterface.is())
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 211473104ebf..645911d8e5a5 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -683,36 +683,34 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
try
{
- uno::Reference< uno::XComponentContext > xContext;
- uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory();
- uno::Reference< beans::XPropertySet > xProp( xServiceManager, uno::UNO_QUERY_THROW );
- xProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ) >>= xContext;
- if ( xContext.is() )
+ uno::Reference< uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
+ uno::Reference< lang::XMultiServiceFactory > xServiceManager(
+ xContext->getServiceManager(),
+ uno::UNO_QUERY_THROW );
+ uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xServiceManager, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XEnumeration> xEnum = xEnumAccess->createContentEnumeration(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocumentJob" ) ) );
+ if ( xEnum.is() )
{
- uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xServiceManager, uno::UNO_QUERY_THROW );
- uno::Reference< container::XEnumeration> xEnum = xEnumAccess->createContentEnumeration(
- ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocumentJob" ) ) );
- if ( xEnum.is() )
+ while ( xEnum->hasMoreElements() )
{
- while ( xEnum->hasMoreElements() )
+ uno::Any aAny = xEnum->nextElement();
+ uno::Reference< lang::XSingleComponentFactory > xFactory;
+ aAny >>= xFactory;
+ if ( xFactory.is() )
{
- uno::Any aAny = xEnum->nextElement();
- uno::Reference< lang::XSingleComponentFactory > xFactory;
- aAny >>= xFactory;
- if ( xFactory.is() )
- {
- uno::Reference< task::XJob > xJob( xFactory->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW );
- uno::Sequence< beans::NamedValue > aArgsForJob(1);
- ScViewData* pViewData = GetViewData();
- SfxViewShell* pViewShell = ( pViewData ? pViewData->GetViewShell() : NULL );
- SfxViewFrame* pViewFrame = ( pViewShell ? pViewShell->GetViewFrame() : NULL );
- SfxFrame* pFrame = ( pViewFrame ? &pViewFrame->GetFrame() : NULL );
- uno::Reference< frame::XController > xController = ( pFrame ? pFrame->GetController() : 0 );
- uno::Reference< sheet::XSpreadsheetView > xSpreadsheetView( xController, uno::UNO_QUERY_THROW );
- aArgsForJob[0] = beans::NamedValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "SpreadsheetView" )),
+ uno::Reference< task::XJob > xJob( xFactory->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW );
+ uno::Sequence< beans::NamedValue > aArgsForJob(1);
+ ScViewData* pViewData = GetViewData();
+ SfxViewShell* pViewShell = ( pViewData ? pViewData->GetViewShell() : NULL );
+ SfxViewFrame* pViewFrame = ( pViewShell ? pViewShell->GetViewFrame() : NULL );
+ SfxFrame* pFrame = ( pViewFrame ? &pViewFrame->GetFrame() : NULL );
+ uno::Reference< frame::XController > xController = ( pFrame ? pFrame->GetController() : 0 );
+ uno::Reference< sheet::XSpreadsheetView > xSpreadsheetView( xController, uno::UNO_QUERY_THROW );
+ aArgsForJob[0] = beans::NamedValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "SpreadsheetView" )),
uno::makeAny( xSpreadsheetView ) );
- xJob->execute( aArgsForJob );
- }
+ xJob->execute( aArgsForJob );
}
}
}
diff --git a/sc/source/ui/miscdlgs/solverutil.cxx b/sc/source/ui/miscdlgs/solverutil.cxx
index 356eef7440e2..8ed768e1f760 100644
--- a/sc/source/ui/miscdlgs/solverutil.cxx
+++ b/sc/source/ui/miscdlgs/solverutil.cxx
@@ -29,6 +29,7 @@
#include "solverutil.hxx"
#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XSingleComponentFactory.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
@@ -84,19 +85,13 @@ void ScSolverUtil::GetImplementations( uno::Sequence<rtl::OUString>& rImplNames,
rImplNames.realloc(0); // clear
rDescriptions.realloc(0);
- uno::Reference<uno::XComponentContext> xCtx;
- uno::Reference<lang::XMultiServiceFactory> xMSF = comphelper::getProcessServiceFactory();
- uno::Reference<beans::XPropertySet> xPropset(xMSF, uno::UNO_QUERY);
- try
- {
- xPropset->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xCtx;
- }
- catch ( uno::Exception & )
- {
- }
+ uno::Reference<uno::XComponentContext> xCtx(
+ comphelper::getProcessComponentContext() );
+ uno::Reference<lang::XMultiServiceFactory> xMSF(
+ xCtx->getServiceManager(), uno::UNO_QUERY_THROW );
uno::Reference<container::XContentEnumerationAccess> xEnAc( xMSF, uno::UNO_QUERY );
- if ( xCtx.is() && xEnAc.is() )
+ if ( xEnAc.is() )
{
uno::Reference<container::XEnumeration> xEnum =
xEnAc->createContentEnumeration( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SCSOLVER_SERVICE)) );
@@ -140,19 +135,13 @@ uno::Reference<sheet::XSolver> ScSolverUtil::GetSolver( const rtl::OUString& rIm
{
uno::Reference<sheet::XSolver> xSolver;
- uno::Reference<uno::XComponentContext> xCtx;
- uno::Reference<lang::XMultiServiceFactory> xMSF = comphelper::getProcessServiceFactory();
- uno::Reference<beans::XPropertySet> xPropset(xMSF, uno::UNO_QUERY);
- try
- {
- xPropset->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xCtx;
- }
- catch ( uno::Exception & )
- {
- }
+ uno::Reference<uno::XComponentContext> xCtx(
+ comphelper::getProcessComponentContext() );
+ uno::Reference<lang::XMultiServiceFactory> xMSF(
+ xCtx->getServiceManager(), uno::UNO_QUERY_THROW );
uno::Reference<container::XContentEnumerationAccess> xEnAc( xMSF, uno::UNO_QUERY );
- if ( xCtx.is() && xEnAc.is() )
+ if ( xEnAc.is() )
{
uno::Reference<container::XEnumeration> xEnum =
xEnAc->createContentEnumeration( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SCSOLVER_SERVICE)) );
diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx
index cfbb7e79b64b..ec54e24a5051 100644
--- a/sc/source/ui/vba/excelvbahelper.cxx
+++ b/sc/source/ui/vba/excelvbahelper.cxx
@@ -118,10 +118,10 @@ private:
bool bInitialWarningState;
static uno::Reference< beans::XPropertySet > getGlobalSheetSettings() throw ( uno::RuntimeException )
{
- static uno::Reference< beans::XPropertySet > xTmpProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
- static uno::Reference<uno::XComponentContext > xContext( xTmpProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
+ static uno::Reference<uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
static uno::Reference<lang::XMultiComponentFactory > xServiceManager(
- xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ xContext->getServiceManager() );
static uno::Reference< beans::XPropertySet > xProps( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.GlobalSheetSettings" ) ) ,xContext ), uno::UNO_QUERY_THROW );
return xProps;
}
diff --git a/sc/source/ui/vba/vbahelper.cxx b/sc/source/ui/vba/vbahelper.cxx
index a2a2217531f7..ce5e680f1c26 100644
--- a/sc/source/ui/vba/vbahelper.cxx
+++ b/sc/source/ui/vba/vbahelper.cxx
@@ -124,10 +124,10 @@ private:
bool bInitialWarningState;
static uno::Reference< beans::XPropertySet > getGlobalSheetSettings() throw ( uno::RuntimeException )
{
- static uno::Reference< beans::XPropertySet > xTmpProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
- static uno::Reference<uno::XComponentContext > xContext( xTmpProps->getPropertyValue( rtl::OUString( "DefaultContext" )), uno::UNO_QUERY_THROW );
+ static uno::Reference<uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
static uno::Reference<lang::XMultiComponentFactory > xServiceManager(
- xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ xContext->getServiceManager() );
static uno::Reference< beans::XPropertySet > xProps( xServiceManager->createInstanceWithContext( rtl::OUString( "com.sun.star.sheet.GlobalSheetSettings" ) ,xContext ), uno::UNO_QUERY_THROW );
return xProps;
}
@@ -279,11 +279,10 @@ getCurrentDocument() throw (uno::RuntimeException)
if ( false == ( aModel >>= xModel ) ||
!xModel.is() )
{
- // trying last gasp try the current component
- uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
- // test if vba service is present
- uno::Reference< uno::XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( "DefaultContext" )), uno::UNO_QUERY_THROW );
- uno::Reference<lang::XMultiComponentFactory > xSMgr( xCtx->getServiceManager(), uno::UNO_QUERY_THROW );
+ uno::Reference< uno::XComponentContext > xCtx(
+ comphelper::getProcessComponentContext() );
+ uno::Reference<lang::XMultiComponentFactory > xSMgr(
+ xCtx->getServiceManager() );
uno::Reference< frame::XDesktop > xDesktop (xSMgr->createInstanceWithContext(::rtl::OUString("com.sun.star.frame.Desktop"), xCtx), uno::UNO_QUERY_THROW );
xModel.set( xDesktop->getCurrentComponent(), uno::UNO_QUERY );
if ( !xModel.is() )
diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx
index 528941b090d7..d5fe171afde2 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -167,10 +167,10 @@ openNewDoc(rtl::OUString aSheetName )
uno::Reference<frame::XModel> xModel;
try
{
- uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
- uno::Reference< uno::XComponentContext > xContext( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
+ uno::Reference< uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
uno::Reference<lang::XMultiComponentFactory > xServiceManager(
- xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ xContext->getServiceManager() );
uno::Reference <frame::XComponentLoader > xComponentLoader(
xServiceManager->createInstanceWithContext(
diff --git a/scripting/Library_protocolhandler.mk b/scripting/Library_protocolhandler.mk
index 291b1ecb03c1..d2a684ab852f 100644
--- a/scripting/Library_protocolhandler.mk
+++ b/scripting/Library_protocolhandler.mk
@@ -38,6 +38,7 @@ $(eval $(call gb_Library_set_include,protocolhandler,\
$(eval $(call gb_Library_use_sdk_api,protocolhandler))
$(eval $(call gb_Library_use_libraries,protocolhandler,\
+ comphelper \
cppu \
cppuhelper \
fwe \
diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx
index ed41ebcfadc2..1881c917c4ae 100644
--- a/scripting/source/protocolhandler/scripthandler.cxx
+++ b/scripting/source/protocolhandler/scripthandler.cxx
@@ -41,6 +41,7 @@
#include <vcl/abstdlg.hxx>
#include <tools/diagnose_ex.h>
+#include <comphelper/processfactory.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <util/util.hxx>
@@ -50,7 +51,6 @@
#include "com/sun/star/uri/XUriReference.hpp"
#include "com/sun/star/uri/XUriReferenceFactory.hpp"
#include "com/sun/star/uri/XVndSunStarScriptUrl.hpp"
-#include "com/sun/star/beans/XPropertySet.hpp"
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -383,13 +383,8 @@ void ScriptProtocolHandler::createScriptProvider()
// if nothing of this is successful, use the master script provider
if ( !m_xScriptProvider.is() )
{
- Reference< XPropertySet > xProps( m_xFactory, UNO_QUERY_THROW );
-
- ::rtl::OUString dc(
- "DefaultContext" );
-
Reference< XComponentContext > xCtx(
- xProps->getPropertyValue( dc ), UNO_QUERY_THROW );
+ comphelper::getComponentContext( m_xFactory ) );
::rtl::OUString tmspf(
"/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory");
diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx
index 00981f075898..7249d143a8d0 100644
--- a/scripting/source/vbaevents/eventhelper.cxx
+++ b/scripting/source/vbaevents/eventhelper.cxx
@@ -368,14 +368,10 @@ eventMethodToDescriptor( const ::rtl::OUString& rEventMethod, ScriptEventDescrip
}
-ScriptEventHelper::ScriptEventHelper( const Reference< XInterface >& xControl ) : m_xControl( xControl )
-{
- Reference < beans::XPropertySet > xProps(
- ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
- m_xCtx.set( xProps->getPropertyValue( rtl::OUString(
- "DefaultContext" )),
- uno::UNO_QUERY_THROW );
-}
+ScriptEventHelper::ScriptEventHelper( const Reference< XInterface >& xControl ):
+ m_xCtx( comphelper::getProcessComponentContext() ),
+ m_xControl( xControl )
+{}
Sequence< rtl::OUString >
ScriptEventHelper::getEventListeners()
diff --git a/sd/source/core/CustomAnimationPreset.cxx b/sd/source/core/CustomAnimationPreset.cxx
index bf8fd5027a2a..8eb74eeaabcf 100644
--- a/sd/source/core/CustomAnimationPreset.cxx
+++ b/sd/source/core/CustomAnimationPreset.cxx
@@ -34,7 +34,6 @@
#include <com/sun/star/xml/sax/XParser.hpp>
#include <com/sun/star/xml/sax/SAXParseException.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/presentation/EffectPresetClass.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
#include <unotools/streamwrap.hxx>
@@ -316,19 +315,14 @@ void CustomAnimationPresets::importEffects()
{
try
{
- // Get service factory
- Reference< XMultiServiceFactory > xServiceFactory( comphelper::getProcessServiceFactory() );
- DBG_ASSERT( xServiceFactory.is(), "sd::CustomAnimationPresets::import(), got no service manager" );
- if( !xServiceFactory.is() )
- return;
-
- uno::Reference< beans::XPropertySet > xProps( xServiceFactory, UNO_QUERY );
- uno::Reference< uno::XComponentContext > xContext;
- xProps->getPropertyValue( "DefaultContext" ) >>= xContext;
+ uno::Reference< uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
+ Reference< XMultiServiceFactory > xServiceFactory(
+ xContext->getServiceManager(), UNO_QUERY_THROW );
- uno::Reference< util::XMacroExpander > xMacroExpander;
- if( xContext.is() )
- xMacroExpander.set( xContext->getValueByName("/singletons/com.sun.star.util.theMacroExpander"), UNO_QUERY );
+ uno::Reference< util::XMacroExpander > xMacroExpander(
+ xContext->getValueByName("/singletons/com.sun.star.util.theMacroExpander"),
+ UNO_QUERY );
Reference< XMultiServiceFactory > xConfigProvider(
xServiceFactory->createInstance("com.sun.star.configuration.ConfigurationProvider" ),
diff --git a/sd/source/core/TransitionPreset.cxx b/sd/source/core/TransitionPreset.cxx
index dd03514cd5d4..3c77ead958fe 100644
--- a/sd/source/core/TransitionPreset.cxx
+++ b/sd/source/core/TransitionPreset.cxx
@@ -31,7 +31,6 @@
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/beans/NamedValue.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/util/XMacroExpander.hpp>
#include <com/sun/star/animations/AnimationNodeType.hpp>
#include <vcl/svapp.hxx>
@@ -152,19 +151,14 @@ bool TransitionPreset::importTransitionPresetList( TransitionPresetList& rList )
try
{
- // Get service factory
- Reference< XMultiServiceFactory > xServiceFactory( comphelper::getProcessServiceFactory() );
- DBG_ASSERT( xServiceFactory.is(), "sd::CustomAnimationPresets::import(), got no service manager" );
- if( !xServiceFactory.is() )
- return false;
-
- uno::Reference< beans::XPropertySet > xProps( xServiceFactory, UNO_QUERY );
- uno::Reference< uno::XComponentContext > xContext;
- xProps->getPropertyValue( "DefaultContext" ) >>= xContext;
-
- uno::Reference< util::XMacroExpander > xMacroExpander;
- if( xContext.is() )
- xMacroExpander.set( xContext->getValueByName("/singletons/com.sun.star.util.theMacroExpander"), UNO_QUERY );
+ uno::Reference< uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
+ Reference< XMultiServiceFactory > xServiceFactory(
+ xContext->getServiceManager(), UNO_QUERY_THROW );
+
+ uno::Reference< util::XMacroExpander > xMacroExpander(
+ xContext->getValueByName("/singletons/com.sun.star.util.theMacroExpander"),
+ UNO_QUERY );
// import ui strings
Reference< XMultiServiceFactory > xConfigProvider(
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 "
diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx
index ed96a698f48c..2ae2890f4c63 100644
--- a/svl/source/misc/urihelper.cxx
+++ b/svl/source/misc/urihelper.cxx
@@ -18,8 +18,6 @@
*/
#include <svl/urihelper.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include "com/sun/star/lang/XMultiComponentFactory.hpp"
#include "com/sun/star/ucb/Command.hpp"
#include "com/sun/star/ucb/IllegalIdentifierException.hpp"
#include "com/sun/star/ucb/UniversalContentBroker.hpp"
@@ -291,15 +289,8 @@ rtl::OUString URIHelper::simpleNormalizedMakeRelative(
{
com::sun::star::uno::Reference< com::sun::star::uri::XUriReference > rel(
URIHelper::normalizedMakeRelative(
- com::sun::star::uno::Reference<
- com::sun::star::uno::XComponentContext >(
- (com::sun::star::uno::Reference<
- com::sun::star::beans::XPropertySet >(
- comphelper::getProcessServiceFactory(),
- com::sun::star::uno::UNO_QUERY_THROW)->
- getPropertyValue("DefaultContext")),
- com::sun::star::uno::UNO_QUERY_THROW),
- baseUriReference, uriReference));
+ comphelper::getProcessComponentContext(), baseUriReference,
+ uriReference));
return rel.is() ? rel->getUriReference() : uriReference;
}
diff --git a/svtools/Library_hatchwindowfactory.mk b/svtools/Library_hatchwindowfactory.mk
index a25abdb3bcf3..03f2566bfae9 100644
--- a/svtools/Library_hatchwindowfactory.mk
+++ b/svtools/Library_hatchwindowfactory.mk
@@ -38,6 +38,7 @@ $(eval $(call gb_Library_set_include,hatchwindowfactory,\
$(eval $(call gb_Library_use_sdk_api,hatchwindowfactory))
$(eval $(call gb_Library_use_libraries,hatchwindowfactory,\
+ comphelper \
cppu \
cppuhelper \
sal \
diff --git a/svtools/source/hatchwindow/documentcloser.cxx b/svtools/source/hatchwindow/documentcloser.cxx
index fe934549d202..0cf4d7d120fd 100644
--- a/svtools/source/hatchwindow/documentcloser.cxx
+++ b/svtools/source/hatchwindow/documentcloser.cxx
@@ -22,9 +22,8 @@
#include <com/sun/star/lang/DisposedException.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/frame/DoubleInitializationException.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/awt/XVclWindowPeer.hpp>
-
+#include <comphelper/processfactory.hxx>
#include <osl/mutex.hxx>
#include <vcl/svapp.hxx>
#include <vcl/dialog.hxx>
@@ -267,18 +266,8 @@ uno::Sequence< ::rtl::OUString > SAL_CALL ODocumentCloser::impl_staticGetSupport
uno::Reference< uno::XInterface > SAL_CALL ODocumentCloser::impl_staticCreateSelfInstance(
const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
{
- uno::Reference< uno::XComponentContext > xContext;
- uno::Reference< beans::XPropertySet > xPropSet( xServiceManager, uno::UNO_QUERY );
- if ( xPropSet.is() )
- xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ) >>= xContext;
-
- if ( !xContext.is() )
- {
- throw uno::RuntimeException(
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unable to obtain component context from service manager!" ) ),
- uno::Reference< uno::XInterface >() );
- }
-
+ uno::Reference< uno::XComponentContext > xContext(
+ comphelper::getComponentContext( xServiceManager ) );
return static_cast< cppu::OWeakObject * >( new ODocumentCloser( xContext ) );
}
diff --git a/svtools/source/misc/templatefoldercache.cxx b/svtools/source/misc/templatefoldercache.cxx
index 139d84ad7336..b49d74aa0648 100644
--- a/svtools/source/misc/templatefoldercache.cxx
+++ b/svtools/source/misc/templatefoldercache.cxx
@@ -29,7 +29,6 @@
#include <svtools/templatefoldercache.hxx>
#include <unotools/ucbstreamhelper.hxx>
#include <unotools/localfilehelper.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/ucb/XDynamicResultSet.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
@@ -837,36 +836,15 @@ namespace svt
osl::MutexGuard aGuard( m_aMutex );
if ( !m_xOfficeInstDirs.is() )
{
- // @@@ This is bad!
- uno::Reference< lang::XMultiServiceFactory > xSMgr
- = comphelper::getProcessServiceFactory();
- OSL_ENSURE( xSMgr.is(), "No service manager!" );
-
- uno::Reference< beans::XPropertySet > xPropSet(
- xSMgr, uno::UNO_QUERY );
- if ( xPropSet.is() )
- {
- uno::Reference< uno::XComponentContext > xCtx;
- xPropSet->getPropertyValue(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) )
- >>= xCtx;
-
- OSL_ENSURE( xCtx.is(),
- "Unable to obtain component context from service manager!" );
-
- if ( xCtx.is() )
- {
- xCtx->getValueByName(
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ uno::Reference< uno::XComponentContext > xCtx(
+ comphelper::getProcessComponentContext() );
+ xCtx->getValueByName(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
"/singletons/com.sun.star.util.theOfficeInstallationDirectories" ) ) )
- >>= m_xOfficeInstDirs;
- }
+ >>= m_xOfficeInstDirs;
- OSL_ENSURE( m_xOfficeInstDirs.is(),
- "Unable to obtain office directories singleton!" );
-
- }
+ OSL_ENSURE( m_xOfficeInstDirs.is(),
+ "Unable to obtain office directories singleton!" );
}
}
return m_xOfficeInstDirs;
diff --git a/svx/source/form/fmPropBrw.cxx b/svx/source/form/fmPropBrw.cxx
index 044eb783380e..e83c2d89d16a 100644
--- a/svx/source/form/fmPropBrw.cxx
+++ b/svx/source/form/fmPropBrw.cxx
@@ -570,10 +570,8 @@ void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell )
xControlMap = pFormPage->GetImpl().getControlToShapeMap();
// our own component context
- Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW );
Reference< XComponentContext > xOwnContext(
- xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
- UNO_QUERY_THROW );
+ comphelper::getComponentContext( m_xORB ) );
// a ComponentContext for the
::cppu::ContextEntry_Init aHandlerContextInfo[] =
diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx
index ff1ae4971bf4..48910c0bead1 100644
--- a/sw/source/filter/ww8/ww8toolbar.cxx
+++ b/sw/source/filter/ww8/ww8toolbar.cxx
@@ -370,8 +370,8 @@ bool Customization::ImportMenu( CTBWrapper& rWrapper, CustomToolBarImportHelper&
}
uno::Reference< lang::XSingleComponentFactory > xSCF( xIndexContainer, uno::UNO_QUERY_THROW );
- uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
- uno::Reference< uno::XComponentContext > xContext( xProps->getPropertyValue( "DefaultContext" ), uno::UNO_QUERY_THROW );
+ uno::Reference< uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
// create the popup menu
uno::Sequence< beans::PropertyValue > aPopupMenu( 4 );
aPopupMenu[0].Name = "CommandURL";
diff --git a/sw/source/ui/config/mailconfigpage.cxx b/sw/source/ui/config/mailconfigpage.cxx
index da6591eea945..430312c0883e 100644
--- a/sw/source/ui/config/mailconfigpage.cxx
+++ b/sw/source/ui/config/mailconfigpage.cxx
@@ -339,8 +339,9 @@ void SwTestAccountSettingsDialog::Test()
try
{
uno::Reference< mail::XMailService > xInMailService;
- uno::Reference< mail::XMailServiceProvider > xMailServiceProvider =
- mail::MailServiceProvider::create(getCurrentCmpCtx(rMgr));
+ uno::Reference< mail::XMailServiceProvider > xMailServiceProvider(
+ mail::MailServiceProvider::create(
+ comphelper::getComponentContext(rMgr)));
uno::Reference< mail::XMailService > xMailService =
xMailServiceProvider->create(
mail::MailServiceType_SMTP);
diff --git a/sw/source/ui/dbui/mailmergehelper.cxx b/sw/source/ui/dbui/mailmergehelper.cxx
index 9f756c267c69..91fd9fcdced8 100644
--- a/sw/source/ui/dbui/mailmergehelper.cxx
+++ b/sw/source/ui/dbui/mailmergehelper.cxx
@@ -110,8 +110,9 @@ uno::Reference< mail::XSmtpService > ConnectToSmtpServer(
if (rMgr.is())
try
{
- uno::Reference< mail::XMailServiceProvider > xMailServiceProvider =
- mail::MailServiceProvider::create(getCurrentCmpCtx(rMgr));
+ uno::Reference< mail::XMailServiceProvider > xMailServiceProvider(
+ mail::MailServiceProvider::create(
+ comphelper::getComponentContext(rMgr)));
xSmtpServer = uno::Reference< mail::XSmtpService > (
xMailServiceProvider->create(
mail::MailServiceType_SMTP
@@ -673,17 +674,6 @@ void SwConnectionListener::disposing(const lang::EventObject& /*aEvent*/)
{
}
-uno::Reference< uno::XComponentContext> getCurrentCmpCtx(
- uno::Reference<lang::XMultiServiceFactory> rSrvMgr)
-{
- uno::Reference< beans::XPropertySet > xPropSet =
- uno::Reference< beans::XPropertySet>(rSrvMgr, uno::UNO_QUERY);
- Any aAny = xPropSet->getPropertyValue( ::rtl::OUString("DefaultContext"));
- uno::Reference< uno::XComponentContext> rCmpCtx;
- aAny >>= rCmpCtx;
- return rCmpCtx;
-}
-
SwMailTransferable::SwMailTransferable(const rtl::OUString& rBody, const rtl::OUString& rMimeType) :
cppu::WeakComponentImplHelper2< datatransfer::XTransferable, beans::XPropertySet >(m_aMutex),
m_aMimeType( rMimeType ),
diff --git a/sw/source/ui/inc/mailmergehelper.hxx b/sw/source/ui/inc/mailmergehelper.hxx
index d7024d3c39a3..7796046c0b0b 100644
--- a/sw/source/ui/inc/mailmergehelper.hxx
+++ b/sw/source/ui/inc/mailmergehelper.hxx
@@ -45,18 +45,10 @@
class SwMailMergeConfigItem;
-namespace com{ namespace sun{ namespace star{
- namespace uno{
- class XComponentContext;
- }
- namespace lang{
- class XMultiServiceFactory;
- }
- namespace mail{
- class XSmtpService;
- class XMailService;
- }
-}}}
+namespace com { namespace sun { namespace star { namespace mail {
+ class XMailService;
+ class XSmtpService;
+} } } }
namespace SwMailMergeHelper
{
@@ -317,10 +309,6 @@ public:
{m_sSenderAddress = rSenderAddress;}
};
-SW_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>
- getCurrentCmpCtx(
- ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XMultiServiceFactory> rSrvMgr);
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/Library_ucphier1.mk b/ucb/Library_ucphier1.mk
index 767fbd15208a..83798585807c 100644
--- a/ucb/Library_ucphier1.mk
+++ b/ucb/Library_ucphier1.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_Library_set_componentfile,ucphier1,ucb/source/ucp/hierarchy/ucp
$(eval $(call gb_Library_use_sdk_api,ucphier1))
$(eval $(call gb_Library_use_libraries,ucphier1,\
+ comphelper \
cppu \
cppuhelper \
sal \
diff --git a/ucb/source/core/ucbcmds.cxx b/ucb/source/core/ucbcmds.cxx
index 0f6794b59b1c..4585efb6a3e3 100644
--- a/ucb/source/core/ucbcmds.cxx
+++ b/ucb/source/core/ucbcmds.cxx
@@ -41,7 +41,6 @@
#include <com/sun/star/uno/XInterface.hpp>
#include <com/sun/star/beans/PropertyState.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XChild.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/io/Pipe.hpp>
@@ -1705,12 +1704,8 @@ void UniversalContentBroker::globalTransfer(
uno::Reference< ucb::XCommandEnvironment > xLocalEnv;
if (xEnv.is())
{
- uno::Reference< beans::XPropertySet > const xProps(
- m_xSMgr, uno::UNO_QUERY_THROW );
- uno::Reference< uno::XComponentContext > xCtx;
- xCtx.set( xProps->getPropertyValue(
- rtl::OUString( "DefaultContext" ) ),
- uno::UNO_QUERY_THROW );
+ uno::Reference< uno::XComponentContext > xCtx(
+ comphelper::getComponentContext( m_xSMgr ) );
xLocalEnv.set( ucb::CommandEnvironment::create(
xCtx,
diff --git a/ucb/source/ucp/hierarchy/hierarchyprovider.cxx b/ucb/source/ucp/hierarchy/hierarchyprovider.cxx
index cf0db7a82a90..dfed6f6600be 100644
--- a/ucb/source/ucp/hierarchy/hierarchyprovider.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchyprovider.cxx
@@ -36,9 +36,9 @@
*************************************************************************/
#include <osl/diagnose.h>
#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/util/XOfficeInstallationDirectories.hpp>
+#include <comphelper/processfactory.hxx>
#include <ucbhelper/contentidentifier.hxx>
#include "hierarchyprovider.hxx"
#include "hierarchycontent.hxx"
@@ -279,30 +279,16 @@ HierarchyContentProvider::getOfficeInstallationDirectories()
{
OSL_ENSURE( m_xSMgr.is(), "No service manager!" );
- uno::Reference< uno::XComponentContext > xCtx;
- uno::Reference< beans::XPropertySet > xPropSet(
- m_xSMgr, uno::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< uno::XComponentContext > xCtx(
+ comphelper::getComponentContext( m_xSMgr ) );
- if ( xCtx.is() )
- {
- xCtx->getValueByName(
- rtl::OUString( "/singletons/com.sun.star.util.theOfficeInstallationDirectories" ) )
+ xCtx->getValueByName(
+ rtl::OUString( "/singletons/com.sun.star.util.theOfficeInstallationDirectories" ) )
>>= m_xOfficeInstDirs;
// Be silent. singleton only available in an Office environment.
-// OSL_ENSURE( m_xOfficeInstDirs.is(),
-// "Unable to obtain office directories singleton!" );
- }
+// OSL_ENSURE( m_xOfficeInstDirs.is(),
+// "Unable to obtain office directories singleton!" );
}
}
return m_xOfficeInstDirs;
diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx
index 64a369a40548..bfabf8cedfac 100644
--- a/ucb/source/ucp/webdav/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav/webdavcontent.cxx
@@ -33,6 +33,7 @@
*************************************************************************/
+#include <comphelper/processfactory.hxx>
#include <osl/diagnose.h>
#include "osl/doublecheckedlocking.h"
#include <rtl/uri.hxx>
@@ -199,12 +200,8 @@ uno::Any SAL_CALL Content::queryInterface( const uno::Type & rType )
{
try
{
- uno::Reference< beans::XPropertySet > const xProps(
- m_xSMgr, uno::UNO_QUERY_THROW );
- uno::Reference< uno::XComponentContext > xCtx;
- xCtx.set( xProps->getPropertyValue(
- rtl::OUString( "DefaultContext" ) ),
- uno::UNO_QUERY_THROW );
+ uno::Reference< uno::XComponentContext > xCtx(
+ comphelper::getComponentContext( m_xSMgr ) );
uno::Reference< task::XInteractionHandler > xIH(
task::PasswordContainerInteractionHandler::create( xCtx ) );
diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx
index be309293d466..e8956c464d18 100644
--- a/unotools/source/config/lingucfg.cxx
+++ b/unotools/source/config/lingucfg.cxx
@@ -24,7 +24,6 @@
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/container/XNameReplace.hpp>
#include "com/sun/star/util/XMacroExpander.hpp"
-#include "com/sun/star/beans/XPropertySet.hpp"
#include <rtl/uri.hxx>
#include <rtl/instance.hxx>
#include <osl/mutex.hxx>
@@ -939,16 +938,12 @@ static uno::Reference< util::XMacroExpander > lcl_GetMacroExpander()
{
if ( !xMacroExpander.is() )
{
- uno::Reference< uno::XComponentContext > xContext;
- uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
- xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))) >>= xContext;
- if ( xContext.is() )
- {
- aG_xMacroExpander = uno::Reference< com::sun::star::util::XMacroExpander >( xContext->getValueByName(
+ uno::Reference< uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
+ aG_xMacroExpander = uno::Reference< com::sun::star::util::XMacroExpander >( xContext->getValueByName(
OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.util.theMacroExpander"))),
uno::UNO_QUERY );
- xMacroExpander = aG_xMacroExpander;
- }
+ xMacroExpander = aG_xMacroExpander;
}
}
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index 9db368e72b68..dece6b5d4ef5 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -29,7 +29,6 @@
#include <com/sun/star/script/XDefaultProperty.hpp>
#include <com/sun/star/script/Converter.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XIntrospection.hpp>
@@ -155,15 +154,8 @@ dispatchRequests (const uno::Reference< frame::XModel>& xModel, const OUString &
uno::Reference<frame::XDispatchProvider> xDispatchProvider (xFrame,uno::UNO_QUERY_THROW);
try
{
- uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
- uno::Reference<uno::XComponentContext > xContext( xProps->getPropertyValue( "DefaultContext" ), uno::UNO_QUERY_THROW );
- if ( !xContext.is() )
- return;
-
- uno::Reference<lang::XMultiComponentFactory > xServiceManager = xContext->getServiceManager();
- if ( !xServiceManager.is() )
- return;
-
+ uno::Reference<uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
uno::Reference<util::XURLTransformer> xParser( util::URLTransformer::create(xContext) );
xParser->parseStrict (url);
}
diff --git a/vcl/aqua/source/app/salinst.cxx b/vcl/aqua/source/app/salinst.cxx
index f8a883528804..ecf17755e15f 100644
--- a/vcl/aqua/source/app/salinst.cxx
+++ b/vcl/aqua/source/app/salinst.cxx
@@ -59,8 +59,6 @@
#include <comphelper/processfactory.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uri/XExternalUriReferenceTranslator.hpp>
#include <com/sun/star/uri/ExternalUriReferenceTranslator.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
@@ -1083,23 +1081,9 @@ void* AquaSalInstance::GetConnectionIdentifier( ConnectionIdentifierType& rRetur
// to UTF-8 before encoding non ascii characters, which is not what other apps expect.
static rtl::OUString translateToExternalUrl(const rtl::OUString& internalUrl)
{
- rtl::OUString extUrl;
-
- uno::Reference< lang::XMultiServiceFactory > sm = comphelper::getProcessServiceFactory();
- if (sm.is())
- {
- uno::Reference< beans::XPropertySet > pset;
- sm->queryInterface( getCppuType( &pset )) >>= pset;
- if (pset.is())
- {
- uno::Reference< uno::XComponentContext > context;
- static const rtl::OUString DEFAULT_CONTEXT( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) );
- pset->getPropertyValue(DEFAULT_CONTEXT) >>= context;
- if (context.is())
- extUrl = uri::ExternalUriReferenceTranslator::create(context)->translateToExternal(internalUrl);
- }
- }
- return extUrl;
+ uno::Reference< uno::XComponentContext > context(
+ comphelper::getProcessComponentContext());
+ return uri::ExternalUriReferenceTranslator::create(context)->translateToExternal(internalUrl);
}
// #i104525# many versions of OSX have problems with some URLs:
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index 1472bea879f2..8537685ae278 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -36,6 +36,7 @@
#include <rtl/ustrbuf.hxx>
#include "inputstream.hxx"
#include <algorithm>
+#include <cassert>
#include <string.h>
#include <helpcompiler/HelpIndexer.hxx>
@@ -44,7 +45,6 @@
#include "com/sun/star/deployment/ExtensionManager.hpp"
#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
#include <comphelper/processfactory.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <com/sun/star/beans/Optional.hpp>
@@ -1406,12 +1406,14 @@ ExtensionIteratorBase::ExtensionIteratorBase( Reference< XComponentContext > xCo
, m_aInitialModule( aInitialModule )
, m_aLanguage( aLanguage )
{
+ assert( m_xContext.is() );
init();
}
ExtensionIteratorBase::ExtensionIteratorBase( Databases& rDatabases,
const rtl::OUString& aInitialModule, const rtl::OUString& aLanguage )
- : m_rDatabases( rDatabases )
+ : m_xContext( comphelper::getProcessComponentContext() )
+ , m_rDatabases( rDatabases )
, m_eState( INITIAL_MODULE )
, m_aInitialModule( aInitialModule )
, m_aLanguage( aLanguage )
@@ -1421,25 +1423,6 @@ ExtensionIteratorBase::ExtensionIteratorBase( Databases& rDatabases,
void ExtensionIteratorBase::init()
{
- if( !m_xContext.is() )
- {
- Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
- Reference< XPropertySet > xProps( xFactory, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- if (xProps.is())
- {
- xProps->getPropertyValue(
- ::rtl::OUString( "DefaultContext" ) ) >>= m_xContext;
- OSL_ASSERT( m_xContext.is() );
- }
- }
- if( !m_xContext.is() )
- {
- throw RuntimeException(
- ::rtl::OUString( "ExtensionIteratorBase::init(), no XComponentContext" ),
- Reference< XInterface >() );
- }
-
m_xSFA = ucb::SimpleFileAccess::create(m_xContext);
m_bUserPackagesLoaded = false;
diff --git a/xmlhelp/source/cxxhelp/provider/provider.cxx b/xmlhelp/source/cxxhelp/provider/provider.cxx
index 79e4c0a1e5bb..e3deabafd57e 100644
--- a/xmlhelp/source/cxxhelp/provider/provider.cxx
+++ b/xmlhelp/source/cxxhelp/provider/provider.cxx
@@ -44,7 +44,7 @@
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XNameReplace.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/processfactory.hxx>
#include <unotools/configmgr.hxx>
#include <rtl/bootstrap.hxx>
@@ -345,15 +345,8 @@ void ContentProvider::init()
rtl::Bootstrap::expandMacros(aPath);
aImagesZipPaths[ 1 ] = aPath;
- uno::Reference< uno::XComponentContext > xContext;
- uno::Reference< beans::XPropertySet > xProps( m_xSMgr, uno::UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- if (xProps.is())
- {
- xProps->getPropertyValue(
- ::rtl::OUString( "DefaultContext" ) ) >>= xContext;
- OSL_ASSERT( xContext.is() );
- }
+ uno::Reference< uno::XComponentContext > xContext(
+ comphelper::getComponentContext( m_xSMgr ) );
sal_Bool showBasic = getBooleanKey(xHierAccess,"Help/ShowBasic");
m_pDatabases = new Databases( showBasic,
diff --git a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
index 39c72815a06e..cb44797bd343 100644
--- a/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
+++ b/xmlhelp/source/cxxhelp/provider/urlparameter.cxx
@@ -53,7 +53,6 @@
#include <com/sun/star/ucb/XContentProvider.hpp>
#include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
#include "urlparameter.hxx"
#include "databases.hxx"
@@ -993,21 +992,8 @@ InputStreamTransformer::InputStreamTransformer( URLParameter* urlParam,
if( bAddExtensionPath )
{
- Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
- Reference< XPropertySet > xProps( xFactory, UNO_QUERY );
- OSL_ASSERT( xProps.is() );
- Reference< XComponentContext > xContext;
- if (xProps.is())
- {
- xProps->getPropertyValue(
- ::rtl::OUString( "DefaultContext" ) ) >>= xContext;
- }
- if( !xContext.is() )
- {
- throw RuntimeException(
- ::rtl::OUString( "InputStreamTransformer::InputStreamTransformer(), no XComponentContext" ),
- Reference< XInterface >() );
- }
+ Reference< XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
rtl::OUString aOUExpandedExtensionPath = Databases::expandURL( aExtensionRegistryPath, xContext );
rtl::OString aExpandedExtensionPath = rtl::OUStringToOString( aOUExpandedExtensionPath, osl_getThreadTextEncoding() );
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 9b2bcb708192..4640b85eda55 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -296,21 +296,6 @@ public:
namespace
{
-Reference< uno::XComponentContext > lcl_getComponentContext()
-{
- Reference< uno::XComponentContext > xContext;
- try
- {
- Reference< beans::XPropertySet > xFactProp( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
- if( xFactProp.is())
- xFactProp->getPropertyValue(OUString( "DefaultContext" )) >>= xContext;
- }
- catch( const uno::Exception& )
- {
- }
-
- return xContext;
-}
class lcl_MatchesRole : public ::std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool >
{
@@ -400,15 +385,13 @@ Reference< chart2::data::XLabeledDataSequence > lcl_getCategories( const Referen
Reference< chart2::data::XDataSource > lcl_createDataSource(
const Sequence< Reference< chart2::data::XLabeledDataSequence > > & aData )
{
- Reference< chart2::data::XDataSink > xSink;
- Reference< uno::XComponentContext > xContext( lcl_getComponentContext());
- if( xContext.is() )
- xSink.set(
- xContext->getServiceManager()->createInstanceWithContext(
- OUString( "com.sun.star.chart2.data.DataSource" ),
- xContext ), uno::UNO_QUERY_THROW );
- if( xSink.is())
- xSink->setData( aData );
+ Reference< uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
+ Reference< chart2::data::XDataSink > xSink(
+ xContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.chart2.data.DataSource", xContext ),
+ uno::UNO_QUERY_THROW );
+ xSink->setData( aData );
return Reference< chart2::data::XDataSource >( xSink, uno::UNO_QUERY );
}
diff --git a/xmloff/source/chart/SchXMLImport.cxx b/xmloff/source/chart/SchXMLImport.cxx
index ab0ae4dd5493..729203bdc83b 100644
--- a/xmloff/source/chart/SchXMLImport.cxx
+++ b/xmloff/source/chart/SchXMLImport.cxx
@@ -70,21 +70,6 @@ using ::com::sun::star::uno::Sequence;
namespace
{
-Reference< uno::XComponentContext > lcl_getComponentContext()
-{
- Reference< uno::XComponentContext > xContext;
- try
- {
- Reference< beans::XPropertySet > xFactProp( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
- if( xFactProp.is())
- xFactProp->getPropertyValue(OUString( "DefaultContext" )) >>= xContext;
- }
- catch( uno::Exception& )
- {}
-
- return xContext;
-}
-
class lcl_MatchesChartType : public ::std::unary_function< Reference< chart2::XChartType >, bool >
{
public:
@@ -489,7 +474,8 @@ Reference< chart2::XDataSeries > SchXMLImportHelper::GetNewDataSeries(
xDoc->getFirstDiagram(), uno::UNO_QUERY_THROW );
Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq(
xCooSysCnt->getCoordinateSystems());
- Reference< uno::XComponentContext > xContext( lcl_getComponentContext());
+ Reference< uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
if( nCoordinateSystemIndex < aCooSysSeq.getLength())
{
diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx
index 524058f42756..948475a21ccf 100644
--- a/xmloff/source/chart/SchXMLTools.cxx
+++ b/xmloff/source/chart/SchXMLTools.cxx
@@ -72,20 +72,6 @@ using ::com::sun::star::uno::Sequence;
namespace
{
-Reference< uno::XComponentContext > lcl_getComponentContext()
-{
- Reference< uno::XComponentContext > xContext;
- try
- {
- Reference< beans::XPropertySet > xFactProp( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
- if( xFactProp.is())
- xFactProp->getPropertyValue(OUString( "DefaultContext" )) >>= xContext;
- }
- catch( uno::Exception& )
- {}
-
- return xContext;
-}
rtl::OUString lcl_getGeneratorFromModel( const uno::Reference< frame::XModel >& xChartModel )
{
@@ -375,13 +361,12 @@ XMLTokenEnum getTokenByChartType(
Reference< chart2::data::XLabeledDataSequence > GetNewLabeledDataSequence()
{
- Reference< chart2::data::XLabeledDataSequence > xResult;
- Reference< uno::XComponentContext > xContext( lcl_getComponentContext());
- if( xContext.is() )
- xResult.set(
- xContext->getServiceManager()->createInstanceWithContext(
- OUString( "com.sun.star.chart2.data.LabeledDataSequence" ),
- xContext ), uno::UNO_QUERY_THROW );
+ Reference< uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
+ Reference< chart2::data::XLabeledDataSequence > xResult(
+ xContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.chart2.data.LabeledDataSequence", xContext ),
+ uno::UNO_QUERY_THROW );
return xResult;
}