summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-05-31 09:54:28 +0200
committerNoel Grandin <noel@peralex.com>2013-06-03 10:00:01 +0200
commite6c13f2846c684410e060701cbf1deb9bcaec890 (patch)
tree7c18df0ad2de8297cff389c091714b3eedd92621
parent1f79707438d84ba639a2c601ae9d25c4647d37f6 (diff)
fdo#46808, Convert XMultiServiceFactory to XComponentContext
Change-Id: Ice5ec3a056f7f2f5184523bda1c709ccac876736
-rw-r--r--basctl/source/basicide/baside3.cxx10
-rw-r--r--basctl/source/basicide/basides3.cxx8
-rw-r--r--basctl/source/basicide/moduldlg.cxx8
-rw-r--r--basctl/source/dlged/dlged.cxx8
-rw-r--r--basctl/source/dlged/dlgedfac.cxx4
-rw-r--r--basic/source/classes/eventatt.cxx7
-rw-r--r--desktop/source/app/app.cxx2
-rw-r--r--sfx2/source/sidebar/ContextChangeBroadcaster.cxx8
-rw-r--r--sfx2/source/sidebar/ControllerFactory.cxx14
-rw-r--r--sfx2/source/sidebar/ResourceManager.cxx11
-rw-r--r--sfx2/source/sidebar/SidebarController.cxx9
-rw-r--r--sfx2/source/sidebar/Tools.cxx40
12 files changed, 51 insertions, 78 deletions
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
index 2eb27e302d42..25bb1ea32265 100644
--- a/basctl/source/basicide/baside3.cxx
+++ b/basctl/source/basicide/baside3.cxx
@@ -942,8 +942,7 @@ bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocum
{
bool bDone = false;
- Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
- Reference< XComponentContext > xContext( comphelper::getComponentContext( xMSF ) );
+ Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
Reference < XFilePicker3 > xFP = FilePicker::createWithMode(xContext, TemplateDescription::FILEOPEN_SIMPLE);
Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
@@ -975,10 +974,11 @@ bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocum
try
{
// create dialog model
- Reference< container::XNameContainer > xDialogModel( xMSF->createInstance
- ( "com.sun.star.awt.UnoControlDialogModel" ), UNO_QUERY_THROW );
+ Reference< container::XNameContainer > xDialogModel(
+ xContext->getServiceManager()->createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", xContext),
+ UNO_QUERY_THROW );
- Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(comphelper::getProcessComponentContext()) );
+ Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) );
Reference< XInputStream > xInput;
if( xSFI->exists( aCurPath ) )
diff --git a/basctl/source/basicide/basides3.cxx b/basctl/source/basicide/basides3.cxx
index 8d0b70dbb251..10db2edf59d5 100644
--- a/basctl/source/basicide/basides3.cxx
+++ b/basctl/source/basicide/basides3.cxx
@@ -75,12 +75,10 @@ DialogWindow* Shell::CreateDlgWin( const ScriptDocument& rDocument, const OUStri
if ( xISP.is() )
{
// create dialog model
- Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
- Reference< container::XNameContainer > xDialogModel( xMSF->createInstance
- ( "com.sun.star.awt.UnoControlDialogModel" ), UNO_QUERY );
+ Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
+ Reference< container::XNameContainer > xDialogModel( xContext->getServiceManager()->createInstanceWithContext
+ ( "com.sun.star.awt.UnoControlDialogModel", xContext ), UNO_QUERY );
Reference< XInputStream > xInput( xISP->createInputStream() );
- 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 49c58a31af09..1aabbefd4fe1 100644
--- a/basctl/source/basicide/moduldlg.cxx
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -284,12 +284,10 @@ void Shell::CopyDialogResources(
return;
// create dialog model
- Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
- Reference< container::XNameContainer > xDialogModel = Reference< container::XNameContainer >( xMSF->createInstance
- ( "com.sun.star.awt.UnoControlDialogModel" ), UNO_QUERY );
+ Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
+ Reference< container::XNameContainer > xDialogModel = Reference< container::XNameContainer >( xContext->getServiceManager()->createInstanceWithContext
+ ( "com.sun.star.awt.UnoControlDialogModel", xContext ), UNO_QUERY );
Reference< io::XInputStream > xInput( io_xISP->createInputStream() );
- 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/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index d2f55c589810..8ee3f9f10fb9 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -872,9 +872,9 @@ void DlgEditor::Paste()
if ( xTransf->isDataFlavorSupported( m_ClipboardDataFlavors[0] ) )
{
// create clipboard dialog model from xml
- Reference< lang::XMultiServiceFactory > xMSF = getProcessServiceFactory();
- Reference< container::XNameContainer > xClipDialogModel( xMSF->createInstance(
- "com.sun.star.awt.UnoControlDialogModel" ), uno::UNO_QUERY );
+ Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
+ Reference< container::XNameContainer > xClipDialogModel( xContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.awt.UnoControlDialogModel", xContext ), uno::UNO_QUERY );
bool bSourceIsLocalized = false;
Sequence< sal_Int8 > DialogModelBytes;
@@ -916,8 +916,6 @@ void DlgEditor::Paste()
if ( xClipDialogModel.is() )
{
- 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/dlgedfac.cxx b/basctl/source/dlged/dlgedfac.cxx
index 1ffbff22968d..e5584374d018 100644
--- a/basctl/source/dlged/dlgedfac.cxx
+++ b/basctl/source/dlged/dlgedfac.cxx
@@ -50,8 +50,8 @@ IMPL_LINK( DlgEdFactory, MakeObject, SdrObjFactory *, pObjFactory )
if( bNeedsInit )
{
- uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory();
- uno::Reference< container::XNameContainer > xC( xMSF->createInstance( "com.sun.star.awt.UnoControlDialogModel" ), uno::UNO_QUERY );
+ uno::Reference< uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
+ uno::Reference< container::XNameContainer > xC( xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.awt.UnoControlDialogModel", xContext ), uno::UNO_QUERY );
if( xC.is() )
{
uno::Reference< lang::XMultiServiceFactory > xModFact( xC, uno::UNO_QUERY );
diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx
index 68ba8319816e..e7ab71579983 100644
--- a/basic/source/classes/eventatt.cxx
+++ b/basic/source/classes/eventatt.cxx
@@ -423,7 +423,7 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit
(void)pBasic;
(void)bWrite;
- Reference< XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory() );
+ Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
// We need at least 1 parameter
if ( rPar.Count() < 2 )
@@ -450,8 +450,8 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit
}
// Create new uno dialog
- Reference< XNameContainer > xDialogModel( xMSF->createInstance(
- OUString("com.sun.star.awt.UnoControlDialogModel")), UNO_QUERY );
+ Reference< XNameContainer > xDialogModel( xContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.awt.UnoControlDialogModel", xContext), UNO_QUERY );
if( !xDialogModel.is() )
{
return;
@@ -462,7 +462,6 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit
{
return;
}
- Reference< XComponentContext > xContext( comphelper::getComponentContext( xMSF ) );
// Import the DialogModel
Reference< XInputStream > xInput( xISP->createInputStream() );
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 374a239af97f..b8623f773ef5 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -2253,8 +2253,6 @@ void Desktop::OpenClients()
const CommandLineArgs& rArgs = GetCommandLineArgs();
- Reference<XMultiServiceFactory> rFactory = ::comphelper::getProcessServiceFactory();
-
if (!rArgs.IsQuickstart())
{
sal_Bool bShowHelp = sal_False;
diff --git a/sfx2/source/sidebar/ContextChangeBroadcaster.cxx b/sfx2/source/sidebar/ContextChangeBroadcaster.cxx
index 7d5dd3a86e3b..d004ce94400c 100644
--- a/sfx2/source/sidebar/ContextChangeBroadcaster.cxx
+++ b/sfx2/source/sidebar/ContextChangeBroadcaster.cxx
@@ -19,7 +19,7 @@
#include "sfx2/sidebar/EnumContext.hxx"
#include <com/sun/star/ui/ContextChangeEventObject.hpp>
#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
#include <comphelper/componentcontext.hxx>
#include <comphelper/processfactory.hxx>
@@ -115,10 +115,8 @@ OUString ContextChangeBroadcaster::GetModuleName (const cssu::Reference<css::fra
return OUString();
try
{
- const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory());
- const Reference<frame::XModuleManager> xModuleManager (
- aContext.createComponent("com.sun.star.frame.ModuleManager" ),
- UNO_QUERY_THROW );
+ const Reference<XComponentContext> xContext (::comphelper::getProcessComponentContext() );
+ const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( xContext );
return xModuleManager->identify(rxFrame);
}
catch (const Exception&)
diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx
index 4702c898fb9e..0c9d7217b735 100644
--- a/sfx2/source/sidebar/ControllerFactory.cxx
+++ b/sfx2/source/sidebar/ControllerFactory.cxx
@@ -22,7 +22,7 @@
#include <com/sun/star/frame/XToolbarController.hpp>
#include <com/sun/star/frame/XFrame.hpp>
-#include <com/sun/star/frame/XUIControllerFactory.hpp>
+#include <com/sun/star/frame/ToolbarControllerFactory.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <framework/sfxhelperfunctions.hxx>
@@ -145,9 +145,8 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBarController(
{
try
{
- Reference<frame::XUIControllerFactory> xFactory (
- comphelper::getProcessServiceFactory()->createInstance(A2S("com.sun.star.frame.ToolbarControllerFactory")),
- UNO_QUERY);
+ Reference<XComponentContext> xContext = comphelper::getProcessComponentContext();
+ Reference<frame::XUIControllerFactory> xFactory = frame::ToolbarControllerFactory::create( xContext );
OUString sModuleName (Tools::GetModuleName(rxFrame));
if (xFactory.is() && xFactory->hasController(rsCommandName, sModuleName))
@@ -178,17 +177,12 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBarController(
aPropertyVector.push_back( makeAny( aPropValue ));
}
- Reference<beans::XPropertySet> xFactoryProperties (comphelper::getProcessServiceFactory(), UNO_QUERY);
- Reference<XComponentContext > xComponentContext;
- if (xFactoryProperties.is())
- xFactoryProperties->getPropertyValue(A2S("DefaultContext")) >>= xComponentContext;
-
Sequence<Any> aArgs (comphelper::containerToSequence(aPropertyVector));
return Reference<frame::XToolbarController>(
xFactory->createInstanceWithArgumentsAndContext(
rsCommandName,
aArgs,
- xComponentContext),
+ xContext),
UNO_QUERY);
}
}
diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx
index 96395ebd77b1..97095a30cf44 100644
--- a/sfx2/source/sidebar/ResourceManager.cxx
+++ b/sfx2/source/sidebar/ResourceManager.cxx
@@ -29,7 +29,7 @@
#include <rtl/ustrbuf.hxx>
#include <tools/diagnose_ex.h>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
#include <map>
@@ -598,10 +598,9 @@ void ResourceManager::StorePanelExpansionState (
{
try
{
- const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory());
- const Reference<container::XNameAccess> xModuleAccess (
- aContext.createComponent("com.sun.star.frame.ModuleManager"),
- UNO_QUERY_THROW);
+ const Reference<XComponentContext> xContext (::comphelper::getProcessComponentContext() );
+ const Reference<frame::XModuleManager2> xModuleAccess =
+ frame::ModuleManager::create( xContext );
const ::comphelper::NamedValueCollection aModuleProperties (xModuleAccess->getByName(rsModuleName));
const ::rtl::OUString sWindowStateRef (aModuleProperties.getOrDefault(
"ooSetupFactoryWindowStateConfigRef",
@@ -612,7 +611,7 @@ void ResourceManager::StorePanelExpansionState (
aPathComposer.append(sWindowStateRef);
aPathComposer.appendAscii("/UIElements/States");
- return ::utl::OConfigurationTreeRoot(::comphelper::getProcessComponentContext(),
+ return ::utl::OConfigurationTreeRoot(xContext,
aPathComposer.makeStringAndClear(), false);
}
catch( const Exception& )
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 970e96ad5c20..da9746e204d1 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -47,7 +47,7 @@
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
#include <com/sun/star/ui/ContextChangeEventObject.hpp>
-#include <com/sun/star/ui/XUIElementFactory.hpp>
+#include <com/sun/star/ui/UIElementFactoryManager.hpp>
#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/util/URL.hpp>
#include <com/sun/star/rendering/XSpriteCanvas.hpp>
@@ -689,10 +689,9 @@ Reference<ui::XUIElement> SidebarController::CreateUIElement (
{
try
{
- const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory());
- const Reference<ui::XUIElementFactory> xUIElementFactory (
- aComponentContext.createComponent("com.sun.star.ui.UIElementFactoryManager"),
- UNO_QUERY_THROW);
+ const Reference<XComponentContext> xComponentContext (::comphelper::getProcessComponentContext() );
+ const Reference<ui::XUIElementFactory> xUIElementFactory =
+ ui::UIElementFactoryManager::create( xComponentContext );
// Create the XUIElement.
::comphelper::NamedValueCollection aCreationArguments;
diff --git a/sfx2/source/sidebar/Tools.cxx b/sfx2/source/sidebar/Tools.cxx
index 62c244cd6045..6b0609ecd9f2 100644
--- a/sfx2/source/sidebar/Tools.cxx
+++ b/sfx2/source/sidebar/Tools.cxx
@@ -27,9 +27,9 @@
#include <vcl/gradient.hxx>
#include <com/sun/star/frame/XDispatchProvider.hpp>
-#include <com/sun/star/graphic/XGraphicProvider.hpp>
-#include <com/sun/star/util/XURLTransformer.hpp>
-#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/graphic/GraphicProvider.hpp>
+#include <com/sun/star/util/URLTransformer.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
#include <cstring>
@@ -80,20 +80,16 @@ Image Tools::GetImage (
}
else
{
- const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory());
- const Reference<graphic::XGraphicProvider> xGraphicProvider (
- aContext.createComponent("com.sun.star.graphic.GraphicProvider"),
+ const Reference<XComponentContext> xContext (::comphelper::getProcessComponentContext());
+ const Reference<graphic::XGraphicProvider> xGraphicProvider =
+ graphic::GraphicProvider::create( xContext );
+ ::comphelper::NamedValueCollection aMediaProperties;
+ aMediaProperties.put("URL", rsURL);
+ const Reference<graphic::XGraphic> xGraphic (
+ xGraphicProvider->queryGraphic(aMediaProperties.getPropertyValues()),
UNO_QUERY);
- if ( xGraphicProvider.is())
- {
- ::comphelper::NamedValueCollection aMediaProperties;
- aMediaProperties.put("URL", rsURL);
- const Reference<graphic::XGraphic> xGraphic (
- xGraphicProvider->queryGraphic(aMediaProperties.getPropertyValues()),
- UNO_QUERY);
- if (xGraphic.is())
- return Image(xGraphic);
- }
+ if (xGraphic.is())
+ return Image(xGraphic);
}
}
return Image();
@@ -158,10 +154,8 @@ util::URL Tools::GetURL (const ::rtl::OUString& rsCommand)
util::URL aURL;
aURL.Complete = rsCommand;
- const ::comphelper::ComponentContext aComponentContext (::comphelper::getProcessServiceFactory());
- const Reference<util::XURLTransformer> xParser (
- aComponentContext.createComponent("com.sun.star.util.URLTransformer"),
- UNO_QUERY_THROW);
+ const Reference<XComponentContext> xComponentContext (::comphelper::getProcessComponentContext());
+ const Reference<util::XURLTransformer> xParser = util::URLTransformer::create( xComponentContext );
xParser->parseStrict(aURL);
return aURL;
@@ -190,10 +184,8 @@ Reference<frame::XDispatch> Tools::GetDispatch (
try
{
- const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory());
- const Reference<frame::XModuleManager> xModuleManager (
- aContext.createComponent("com.sun.star.frame.ModuleManager"),
- UNO_QUERY_THROW);
+ const Reference<XComponentContext> xComponentContext (::comphelper::getProcessComponentContext());
+ const Reference<frame::XModuleManager> xModuleManager = frame::ModuleManager::create( xComponentContext );
return xModuleManager->identify(rxFrame);
}
catch (const Exception&)