summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-05-08 15:43:12 +0200
committerNoel Grandin <noel@peralex.com>2013-05-13 09:38:02 +0200
commitc50c240e4048bd5c3d5017138ff37893476cc74f (patch)
tree14c60356a6e0c86e4943f3efd9db5819e6ac8c72
parent86c1ebc1ef4a90e9bc58fb69c2d1d978765a34ca (diff)
fdo#46808, Convert some XMultiServiceFactory to XComponentContext
Change-Id: I409d4820dd772aa761e806ac06a4f210c801fb41
-rw-r--r--sc/inc/xmlwrap.hxx4
-rw-r--r--sc/source/filter/xml/xmlwrap.cxx41
2 files changed, 18 insertions, 27 deletions
diff --git a/sc/inc/xmlwrap.hxx b/sc/inc/xmlwrap.hxx
index 5a94c52701ca..fb7b15681137 100644
--- a/sc/inc/xmlwrap.hxx
+++ b/sc/inc/xmlwrap.hxx
@@ -50,7 +50,7 @@ class ScXMLImportWrapper
com::sun::star::uno::Reference< com::sun::star::task::XStatusIndicator> GetStatusIndicator();
- sal_uInt32 ImportFromComponent(com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory>& xServiceFactory,
+ sal_uInt32 ImportFromComponent(const com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>& xContext,
com::sun::star::uno::Reference<com::sun::star::frame::XModel>& xModel,
com::sun::star::uno::Reference<com::sun::star::xml::sax::XParser>& xParser,
com::sun::star::xml::sax::InputSource& aParserInput,
@@ -58,7 +58,7 @@ class ScXMLImportWrapper
com::sun::star::uno::Sequence<com::sun::star::uno::Any>& aArgs,
sal_Bool bMustBeSuccessfull);
- sal_Bool ExportToComponent(com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory>& xServiceFactory,
+ sal_Bool ExportToComponent(const com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>& xContext,
com::sun::star::uno::Reference<com::sun::star::frame::XModel>& xModel,
com::sun::star::uno::Reference<com::sun::star::xml::sax::XWriter>& xWriter,
com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& aDescriptor,
diff --git a/sc/source/filter/xml/xmlwrap.cxx b/sc/source/filter/xml/xmlwrap.cxx
index 0dcaf5ee9452..61cebdc69812 100644
--- a/sc/source/filter/xml/xmlwrap.cxx
+++ b/sc/source/filter/xml/xmlwrap.cxx
@@ -104,7 +104,7 @@ uno::Reference <task::XStatusIndicator> ScXMLImportWrapper::GetStatusIndicator()
return xStatusIndicator;
}
-sal_uInt32 ScXMLImportWrapper::ImportFromComponent(uno::Reference<lang::XMultiServiceFactory>& xServiceFactory,
+sal_uInt32 ScXMLImportWrapper::ImportFromComponent(const uno::Reference<uno::XComponentContext>& xContext,
uno::Reference<frame::XModel>& xModel, uno::Reference<xml::sax::XParser>& xParser,
xml::sax::InputSource& aParserInput,
const OUString& sComponentName, const OUString& sDocName,
@@ -169,8 +169,8 @@ sal_uInt32 ScXMLImportWrapper::ImportFromComponent(uno::Reference<lang::XMultiSe
rDoc.SetRangeOverflowType(0); // is modified by the importer if limits are exceeded
uno::Reference<xml::sax::XDocumentHandler> xDocHandler(
- xServiceFactory->createInstanceWithArguments(
- sComponentName, aArgs ),
+ xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+ sComponentName, aArgs, xContext ),
uno::UNO_QUERY );
OSL_ENSURE( xDocHandler.is(), "can't get Calc importer" );
uno::Reference<document::XImporter> xImporter( xDocHandler, uno::UNO_QUERY );
@@ -317,12 +317,7 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError)
{
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "sb99857", "ScXMLImportWrapper::Import" );
- uno::Reference<lang::XMultiServiceFactory> xServiceFactory =
- comphelper::getProcessServiceFactory();
uno::Reference<uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
- OSL_ENSURE( xServiceFactory.is(), "got no service manager" );
- if( !xServiceFactory.is() )
- return false;
xml::sax::InputSource aParserInput;
if (pMedium)
@@ -433,11 +428,10 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError)
// RDF metadata: ODF >= 1.2
try
{
- ::comphelper::ComponentContext aContext( xServiceFactory );
const uno::Reference< rdf::XDocumentMetadataAccess > xDMA(
xModel, uno::UNO_QUERY_THROW );
const uno::Reference< rdf::XURI > xBaseURI(
- ::sfx2::createBaseURI( aContext.getUNOContext(), xStorage, aBaseURL, aName ) );
+ ::sfx2::createBaseURI( xContext, xStorage, aBaseURL, aName ) );
const uno::Reference< task::XInteractionHandler > xHandler(
pObjSh->GetMedium()->GetInteractionHandler() );
xDMA->loadMetadataFromStorage( xStorage, xBaseURI, xHandler );
@@ -469,7 +463,7 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError)
RTL_LOGFILE_CONTEXT_TRACE( aLog, "meta import start" );
nMetaRetval = ImportFromComponent(
- xServiceFactory, xModel, xXMLParser, aParserInput,
+ xContext, xModel, xXMLParser, aParserInput,
bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisMetaImporter")
: OUString("com.sun.star.comp.Calc.XMLMetaImporter"),
"meta.xml", "Meta.xml", aMetaArgs, false);
@@ -513,7 +507,7 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError)
RTL_LOGFILE_CONTEXT_TRACE( aLog, "settings import start" );
nSettingsRetval = ImportFromComponent(
- xServiceFactory, xModel, xXMLParser, aParserInput,
+ xContext, xModel, xXMLParser, aParserInput,
bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisSettingsImporter")
: OUString("com.sun.star.comp.Calc.XMLSettingsImporter"),
"settings.xml", sEmpty, aSettingsArgs, false);
@@ -525,7 +519,7 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError)
{
RTL_LOGFILE_CONTEXT_TRACE( aLog, "styles import start" );
- nStylesRetval = ImportFromComponent(xServiceFactory, xModel, xXMLParser, aParserInput,
+ nStylesRetval = ImportFromComponent(xContext, xModel, xXMLParser, aParserInput,
bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisStylesImporter")
: OUString("com.sun.star.comp.Calc.XMLStylesImporter"),
OUString("styles.xml"),
@@ -546,7 +540,7 @@ sal_Bool ScXMLImportWrapper::Import(sal_Bool bStylesOnly, ErrCode& nError)
RTL_LOGFILE_CONTEXT_TRACE( aLog, "content import start" );
- nDocRetval = ImportFromComponent(xServiceFactory, xModel, xXMLParser, aParserInput,
+ nDocRetval = ImportFromComponent(xContext, xModel, xXMLParser, aParserInput,
bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisContentImporter")
: OUString("com.sun.star.comp.Calc.XMLContentImporter"),
OUString("content.xml"),
@@ -657,7 +651,7 @@ static bool lcl_HasValidStream(ScDocument& rDoc)
return false;
}
-sal_Bool ScXMLImportWrapper::ExportToComponent(uno::Reference<lang::XMultiServiceFactory>& xServiceFactory,
+sal_Bool ScXMLImportWrapper::ExportToComponent(const uno::Reference<uno::XComponentContext>& xContext,
uno::Reference<frame::XModel>& xModel, uno::Reference<xml::sax::XWriter>& xWriter,
uno::Sequence<beans::PropertyValue>& aDescriptor, const OUString& sName,
const OUString& sMediaType, const OUString& sComponentName,
@@ -704,8 +698,9 @@ sal_Bool ScXMLImportWrapper::ExportToComponent(uno::Reference<lang::XMultiServic
xWriter->setOutputStream( xOut );
uno::Reference<document::XFilter> xFilter(
- xServiceFactory->createInstanceWithArguments( sComponentName , aArgs ),
- uno::UNO_QUERY );
+ xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+ sComponentName , aArgs, xContext ),
+ uno::UNO_QUERY );
OSL_ENSURE( xFilter.is(), "can't get exporter" );
uno::Reference<document::XExporter> xExporter( xFilter, uno::UNO_QUERY );
uno::Reference<lang::XComponent> xComponent( xModel, uno::UNO_QUERY );
@@ -774,11 +769,7 @@ sal_Bool ScXMLImportWrapper::Export(sal_Bool bStylesOnly)
{
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "sb99857", "ScXMLImportWrapper::Export" );
- uno::Reference<lang::XMultiServiceFactory> xServiceFactory(comphelper::getProcessServiceFactory());
uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
- OSL_ENSURE( xServiceFactory.is(), "got no service manager" );
- if( !xServiceFactory.is() )
- return false;
uno::Reference<xml::sax::XWriter> xWriter = xml::sax::Writer::create(xContext);
@@ -899,7 +890,7 @@ sal_Bool ScXMLImportWrapper::Export(sal_Bool bStylesOnly)
RTL_LOGFILE_CONTEXT_TRACE( aLog, "meta export start" );
- bMetaRet = ExportToComponent(xServiceFactory, xModel, xWriter, aDescriptor,
+ bMetaRet = ExportToComponent(xContext, xModel, xWriter, aDescriptor,
OUString("meta.xml"),
sTextMediaType,
bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisMetaExporter")
@@ -940,7 +931,7 @@ sal_Bool ScXMLImportWrapper::Export(sal_Bool bStylesOnly)
RTL_LOGFILE_CONTEXT_TRACE( aLog, "styles export start" );
- bStylesRet = ExportToComponent(xServiceFactory, xModel, xWriter, aDescriptor,
+ bStylesRet = ExportToComponent(xContext, xModel, xWriter, aDescriptor,
OUString("styles.xml"),
sTextMediaType,
bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisStylesExporter")
@@ -964,7 +955,7 @@ sal_Bool ScXMLImportWrapper::Export(sal_Bool bStylesOnly)
RTL_LOGFILE_CONTEXT_TRACE( aLog, "content export start" );
- bDocRet = ExportToComponent(xServiceFactory, xModel, xWriter, aDescriptor,
+ bDocRet = ExportToComponent(xContext, xModel, xWriter, aDescriptor,
OUString("content.xml"),
sTextMediaType,
bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisContentExporter")
@@ -992,7 +983,7 @@ sal_Bool ScXMLImportWrapper::Export(sal_Bool bStylesOnly)
RTL_LOGFILE_CONTEXT_TRACE( aLog, "settings export start" );
- bSettingsRet = ExportToComponent(xServiceFactory, xModel, xWriter, aDescriptor,
+ bSettingsRet = ExportToComponent(xContext, xModel, xWriter, aDescriptor,
OUString("settings.xml"),
sTextMediaType,
bOasis ? OUString("com.sun.star.comp.Calc.XMLOasisSettingsExporter")