Kaydet (Commit) 6f0b59e3 authored tarafından Noel Grandin's avatar Noel Grandin

fdo#46808, Convert some XMultiServiceFactory to XComponentContext

Change-Id: If7cc52ffeb35efe0969876a9822106b1fd958b10
üst 19a1d238
......@@ -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() )
......
......@@ -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 );
......
......@@ -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;
}
}
}
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment