summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-04-25 11:18:59 +0200
committerNoel Grandin <noel@peralex.com>2013-04-25 14:44:06 +0200
commit6f0b59e36437b8962769559dc4aabaaba897df00 (patch)
treeb5e5246c3e80b3098ce88279ac5b56ec1895bd15
parent19a1d2383d343375b3c4b4ab1845df6435679bd6 (diff)
fdo#46808, Convert some XMultiServiceFactory to XComponentContext
Change-Id: If7cc52ffeb35efe0969876a9822106b1fd958b10
-rw-r--r--sd/source/filter/ppt/pptinanimations.cxx15
-rw-r--r--sd/source/filter/xml/sdxmlwrp.cxx37
-rw-r--r--sd/source/ui/framework/module/ModuleController.cxx57
-rw-r--r--sd/source/ui/slideshow/slideshowviewimpl.cxx3
4 files changed, 45 insertions, 67 deletions
diff --git a/sd/source/filter/ppt/pptinanimations.cxx b/sd/source/filter/ppt/pptinanimations.cxx
index 8b5a2f251856..c6a02baf7591 100644
--- a/sd/source/filter/ppt/pptinanimations.cxx
+++ b/sd/source/filter/ppt/pptinanimations.cxx
@@ -66,19 +66,12 @@
#include <algorithm>
using ::std::map;
-using ::com::sun::star::uno::Any;
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::UNO_QUERY;
-using ::com::sun::star::uno::UNO_QUERY_THROW;
-using ::com::sun::star::uno::Sequence;
-using ::com::sun::star::uno::makeAny;
-using ::com::sun::star::uno::Exception;
-using ::com::sun::star::uno::XInterface;
using ::com::sun::star::beans::NamedValue;
using ::com::sun::star::container::XEnumerationAccess;
using ::com::sun::star::container::XEnumeration;
using ::com::sun::star::lang::XMultiServiceFactory;
+using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::drawing;
using namespace ::com::sun::star::animations;
using namespace ::com::sun::star::presentation;
@@ -328,8 +321,9 @@ Reference< XAnimationNode > AnimationImporter::createNode( const Atom* pAtom, co
Reference< XAnimationNode > xNode;
if( pServiceName )
{
+ Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
const OUString aServiceName( OUString::createFromAscii(pServiceName) );
- Reference< XInterface > xFac( ::comphelper::getProcessServiceFactory()->createInstance(aServiceName) );
+ Reference< XInterface > xFac( xContext->getServiceManager()->createInstanceWithContext(aServiceName, xContext) );
xNode.set(xFac , UNO_QUERY );
}
@@ -1424,8 +1418,9 @@ int AnimationImporter::importTimeContainer( const Atom* pAtom, const Reference<
{
if( pChildAtom->hasChildAtom( DFF_msofbtAnimCommand ) )
{
+ Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
const OUString aServiceName( "com.sun.star.animations.Command" );
- Reference< XAnimationNode > xChildNode( ::comphelper::getProcessServiceFactory()->createInstance(aServiceName), UNO_QUERY );
+ Reference< XAnimationNode > xChildNode( xContext->getServiceManager()->createInstanceWithContext(aServiceName, xContext), UNO_QUERY );
nNodes += importAnimationNodeContainer( pChildAtom, xChildNode );
Reference< XTimeContainer > xParentContainer( xNode, UNO_QUERY );
if( xParentContainer.is() && xChildNode.is() )
diff --git a/sd/source/filter/xml/sdxmlwrp.cxx b/sd/source/filter/xml/sdxmlwrp.cxx
index e82ae25753b5..cab013acb118 100644
--- a/sd/source/filter/xml/sdxmlwrp.cxx
+++ b/sd/source/filter/xml/sdxmlwrp.cxx
@@ -199,7 +199,7 @@ sal_Int32 ReadThroughComponent(
Reference<io::XInputStream> xInputStream,
Reference<XComponent> xModelComponent,
const String& rStreamName,
- Reference<lang::XMultiServiceFactory> & rFactory,
+ Reference<uno::XComponentContext> & rxContext,
const sal_Char* pFilterName,
Sequence<Any> rFilterArguments,
const OUString& rName,
@@ -208,7 +208,7 @@ sal_Int32 ReadThroughComponent(
{
DBG_ASSERT(xInputStream.is(), "input stream missing");
DBG_ASSERT(xModelComponent.is(), "document missing");
- DBG_ASSERT(rFactory.is(), "factory missing");
+ DBG_ASSERT(rxContext.is(), "factory missing");
DBG_ASSERT(NULL != pFilterName,"I need a service name for the component!");
RTL_LOGFILE_CONTEXT( aLog, "ReadThroughComponent" );
@@ -219,13 +219,13 @@ sal_Int32 ReadThroughComponent(
aParserInput.aInputStream = xInputStream;
// get parser
- Reference< xml::sax::XParser > xParser = xml::sax::Parser::create(comphelper::getComponentContext(rFactory));
+ Reference< xml::sax::XParser > xParser = xml::sax::Parser::create(rxContext);
RTL_LOGFILE_CONTEXT_TRACE( aLog, "parser created" );
// get filter
OUString aFilterName(OUString::createFromAscii(pFilterName));
Reference< xml::sax::XDocumentHandler > xFilter(
- rFactory->createInstanceWithArguments(aFilterName, rFilterArguments),
+ rxContext->getServiceManager()->createInstanceWithArgumentsAndContext(aFilterName, rFilterArguments, rxContext),
UNO_QUERY );
SAL_WARN_IF(!xFilter.is(), "sd", "Can't instantiate filter component: " << aFilterName);
if( !xFilter.is() )
@@ -361,7 +361,7 @@ sal_Int32 ReadThroughComponent(
Reference<XComponent> xModelComponent,
const sal_Char* pStreamName,
const sal_Char* pCompatibilityStreamName,
- Reference<lang::XMultiServiceFactory> & rFactory,
+ Reference<uno::XComponentContext> & rxContext,
const sal_Char* pFilterName,
Sequence<Any> rFilterArguments,
const OUString& rName,
@@ -433,7 +433,7 @@ sal_Int32 ReadThroughComponent(
// read from the stream
return ReadThroughComponent(
- xInputStream, xModelComponent, sStreamName, rFactory,
+ xInputStream, xModelComponent, sStreamName, rxContext,
pFilterName, rFilterArguments,
rName, bMustBeSuccessfull, bEncrypted );
}
@@ -464,12 +464,8 @@ sal_Bool SdXMLFilter::Import( ErrCode& nError )
sal_uInt32 nRet = 0;
// Get service factory
- Reference< lang::XMultiServiceFactory > xServiceFactory =
- comphelper::getProcessServiceFactory();
- DBG_ASSERT( xServiceFactory.is(),
- "XMLReader::Read: got no service manager" );
- if( !xServiceFactory.is() )
- return sal_False;
+ Reference< uno::XComponentContext > rxContext =
+ comphelper::getProcessComponentContext();
// -------------------------------------
@@ -660,26 +656,26 @@ sal_Bool SdXMLFilter::Import( ErrCode& nError )
// read storage streams
// #i103539#: always read meta.xml for generator
nWarn = ReadThroughComponent(
- xStorage, xModelComp, "meta.xml", "Meta.xml", xServiceFactory,
+ xStorage, xModelComp, "meta.xml", "Meta.xml", rxContext,
pServices->mpMeta,
aEmptyArgs, aName, sal_False );
if( meFilterMode != SDXMLMODE_Organizer )
{
nWarn2 = ReadThroughComponent(
- xStorage, xModelComp, "settings.xml", NULL, xServiceFactory,
+ xStorage, xModelComp, "settings.xml", NULL, rxContext,
pServices->mpSettings,
aFilterArgs, aName, sal_False );
}
nRet = ReadThroughComponent(
- xStorage, xModelComp, "styles.xml", NULL, xServiceFactory,
+ xStorage, xModelComp, "styles.xml", NULL, rxContext,
pServices->mpStyles,
aFilterArgs, aName, sal_True );
if( !nRet && (meFilterMode != SDXMLMODE_Organizer) )
nRet = ReadThroughComponent(
- xStorage, xModelComp, "content.xml", "Content.xml", xServiceFactory,
+ xStorage, xModelComp, "content.xml", "Content.xml", rxContext,
pServices->mpContent,
aFilterArgs, aName, sal_True );
@@ -867,15 +863,8 @@ sal_Bool SdXMLFilter::Export()
return sal_False;
}
- uno::Reference< lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() );
uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
- if( !xServiceFactory.is() )
- {
- OSL_FAIL( "got no service manager" );
- return sal_False;
- }
-
uno::Reference< xml::sax::XWriter > xWriter = xml::sax::Writer::create( xContext );
/** property map for export info set */
@@ -1056,7 +1045,7 @@ sal_Bool SdXMLFilter::Export()
*pArgs <<= xWriter;
- uno::Reference< document::XFilter > xFilter( xServiceFactory->createInstanceWithArguments( OUString::createFromAscii( pServices->mpService ), aArgs ), uno::UNO_QUERY );
+ uno::Reference< document::XFilter > xFilter( xContext->getServiceManager()->createInstanceWithArgumentsAndContext( OUString::createFromAscii( pServices->mpService ), aArgs, xContext ), uno::UNO_QUERY );
if( xFilter.is() )
{
uno::Reference< document::XExporter > xExporter( xFilter, uno::UNO_QUERY );
diff --git a/sd/source/ui/framework/module/ModuleController.cxx b/sd/source/ui/framework/module/ModuleController.cxx
index a1825f28bd86..25abb78d2df9 100644
--- a/sd/source/ui/framework/module/ModuleController.cxx
+++ b/sd/source/ui/framework/module/ModuleController.cxx
@@ -234,22 +234,20 @@ void ModuleController::ProcessStartupService (const ::std::vector<Any>& rValues)
rValues[0] >>= sServiceName;
// Instantiate service.
- Reference<lang::XMultiServiceFactory> xGlobalFactory (
- ::comphelper::getProcessServiceFactory(), UNO_QUERY);
- if (xGlobalFactory.is())
- {
- // Create the startup service.
- Sequence<Any> aArguments(1);
- aArguments[0] <<= mxController;
- // Note that when the new object will be destroyed at the end of
- // this scope when it does not register itself anywhere.
- // Typically it will add itself as ConfigurationChangeListener
- // at the configuration controller.
- xGlobalFactory->createInstanceWithArguments(sServiceName, aArguments);
-
- SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": ModuleController::created startup service " <<
- OUStringToOString(sServiceName, RTL_TEXTENCODING_UTF8).getStr());
- }
+ Reference<uno::XComponentContext> xContext =
+ ::comphelper::getProcessComponentContext();
+
+ // Create the startup service.
+ Sequence<Any> aArguments(1);
+ aArguments[0] <<= mxController;
+ // Note that when the new object will be destroyed at the end of
+ // this scope when it does not register itself anywhere.
+ // Typically it will add itself as ConfigurationChangeListener
+ // at the configuration controller.
+ xContext->getServiceManager()->createInstanceWithArgumentsAndContext(sServiceName, aArguments, xContext);
+
+ SAL_INFO("sd.fwk", OSL_THIS_FUNC << ": ModuleController::created startup service " <<
+ OUStringToOString(sServiceName, RTL_TEXTENCODING_UTF8).getStr());
}
catch (Exception&)
{
@@ -278,20 +276,19 @@ void SAL_CALL ModuleController::requestResource (const OUString& rsResourceURL)
if ( ! xFactory.is())
{
// Create a new instance of the factory.
- Reference<lang::XMultiServiceFactory> xGlobalFactory (
- ::comphelper::getProcessServiceFactory(), UNO_QUERY);
- if (xGlobalFactory.is())
- {
- // Create the factory service.
- Sequence<Any> aArguments(1);
- aArguments[0] <<= mxController;
- xFactory = xGlobalFactory->createInstanceWithArguments(
- iFactory->second,
- aArguments);
-
- // Remember that this factory has been instanced.
- (*mpLoadedFactories)[iFactory->second] = xFactory;
- }
+ Reference<uno::XComponentContext> xContext =
+ ::comphelper::getProcessComponentContext();
+
+ // Create the factory service.
+ Sequence<Any> aArguments(1);
+ aArguments[0] <<= mxController;
+ xFactory = xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+ iFactory->second,
+ aArguments,
+ xContext);
+
+ // Remember that this factory has been instanced.
+ (*mpLoadedFactories)[iFactory->second] = xFactory;
}
}
}
diff --git a/sd/source/ui/slideshow/slideshowviewimpl.cxx b/sd/source/ui/slideshow/slideshowviewimpl.cxx
index 5a1cffb12ae7..e2678b848c69 100644
--- a/sd/source/ui/slideshow/slideshowviewimpl.cxx
+++ b/sd/source/ui/slideshow/slideshowviewimpl.cxx
@@ -655,9 +655,6 @@ void SlideShowView::init()
mxWindow->addWindowListener( this );
mxWindow->addMouseListener( this );
- Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory(),
- uno::UNO_QUERY_THROW );
-
mxPointer = awt::Pointer::create( ::comphelper::getProcessComponentContext() );
getTransformation();