From b498ff10d202287eabb27aa286c860cb766f8423 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 3 Jan 2013 13:41:37 +0200 Subject: fdo#46808, convert some starmath code to XComponentContext Change-Id: I60f1d4a6ce0089f828428fa3ae6707a8c086a0ad --- starmath/source/mathmlexport.cxx | 28 +++++++++++----------------- starmath/source/mathmlexport.hxx | 7 +++---- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx index 53445fc7c5d1..d87fc6076b17 100644 --- a/starmath/source/mathmlexport.cxx +++ b/starmath/source/mathmlexport.cxx @@ -95,9 +95,7 @@ using ::rtl::OUStringBuffer; sal_Bool SmXMLExportWrapper::Export(SfxMedium &rMedium) { sal_Bool bRet=sal_True; - uno::Reference - xServiceFactory(comphelper::getProcessServiceFactory()); - OSL_ENSURE(xServiceFactory.is(),"got no service manager"); + uno::Reference xContext(comphelper::getProcessComponentContext()); //Get model uno::Reference< lang::XComponent > xModelComp(xModel, uno::UNO_QUERY ); @@ -207,7 +205,7 @@ sal_Bool SmXMLExportWrapper::Export(SfxMedium &rMedium) xStatusIndicator->setValue(nSteps++); bRet = WriteThroughComponent( - xStg, xModelComp, "meta.xml", xServiceFactory, xInfoSet, + xStg, xModelComp, "meta.xml", xContext, xInfoSet, (bOASIS ? "com.sun.star.comp.Math.XMLOasisMetaExporter" : "com.sun.star.comp.Math.XMLMetaExporter")); } @@ -217,7 +215,7 @@ sal_Bool SmXMLExportWrapper::Export(SfxMedium &rMedium) xStatusIndicator->setValue(nSteps++); bRet = WriteThroughComponent( - xStg, xModelComp, "content.xml", xServiceFactory, xInfoSet, + xStg, xModelComp, "content.xml", xContext, xInfoSet, "com.sun.star.comp.Math.XMLContentExporter"); } @@ -227,7 +225,7 @@ sal_Bool SmXMLExportWrapper::Export(SfxMedium &rMedium) xStatusIndicator->setValue(nSteps++); bRet = WriteThroughComponent( - xStg, xModelComp, "settings.xml", xServiceFactory, xInfoSet, + xStg, xModelComp, "settings.xml", xContext, xInfoSet, (bOASIS ? "com.sun.star.comp.Math.XMLOasisSettingsExporter" : "com.sun.star.comp.Math.XMLSettingsExporter") ); } @@ -242,7 +240,7 @@ sal_Bool SmXMLExportWrapper::Export(SfxMedium &rMedium) xStatusIndicator->setValue(nSteps++); bRet = WriteThroughComponent( - xOut, xModelComp, xServiceFactory, xInfoSet, + xOut, xModelComp, xContext, xInfoSet, "com.sun.star.comp.Math.XMLContentExporter"); } @@ -257,7 +255,7 @@ sal_Bool SmXMLExportWrapper::Export(SfxMedium &rMedium) sal_Bool SmXMLExportWrapper::WriteThroughComponent( Reference xOutputStream, Reference xComponent, - Reference & rFactory, + Reference & rxContext, Reference & rPropSet, const sal_Char* pComponentName ) { @@ -266,11 +264,7 @@ sal_Bool SmXMLExportWrapper::WriteThroughComponent( OSL_ENSURE(NULL != pComponentName, "Need component name!"); // get component - Reference< xml::sax::XWriter > xSaxWriter = xml::sax::Writer::create( - comphelper::getComponentContext(rFactory) ); - OSL_ENSURE( xSaxWriter.is(), "can't instantiate XML writer" ); - if (!xSaxWriter.is()) - return sal_False; + Reference< xml::sax::XWriter > xSaxWriter = xml::sax::Writer::create(rxContext ); // connect XML writer to output stream xSaxWriter->setOutputStream( xOutputStream ); @@ -284,8 +278,8 @@ sal_Bool SmXMLExportWrapper::WriteThroughComponent( // get filter component Reference< document::XExporter > xExporter( - rFactory->createInstanceWithArguments( - OUString::createFromAscii(pComponentName), aArgs), UNO_QUERY); + rxContext->getServiceManager()->createInstanceWithArgumentsAndContext(OUString::createFromAscii(pComponentName), aArgs, rxContext), + UNO_QUERY); OSL_ENSURE( xExporter.is(), "can't instantiate export filter component" ); if ( !xExporter.is() ) @@ -315,7 +309,7 @@ sal_Bool SmXMLExportWrapper::WriteThroughComponent( const Reference < embed::XStorage >& xStorage, Reference xComponent, const sal_Char* pStreamName, - Reference & rFactory, + Reference & rxContext, Reference & rPropSet, const sal_Char* pComponentName ) @@ -359,7 +353,7 @@ sal_Bool SmXMLExportWrapper::WriteThroughComponent( } // write the stuff - sal_Bool bRet = WriteThroughComponent( xStream->getOutputStream(), xComponent, rFactory, + sal_Bool bRet = WriteThroughComponent( xStream->getOutputStream(), xComponent, rxContext, rPropSet, pComponentName ); return bRet; diff --git a/starmath/source/mathmlexport.hxx b/starmath/source/mathmlexport.hxx index c4cc22eaa605..82eaf7a4fa14 100644 --- a/starmath/source/mathmlexport.hxx +++ b/starmath/source/mathmlexport.hxx @@ -56,18 +56,17 @@ public: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComponent, ::com::sun::star::uno::Reference< - ::com::sun::star::lang::XMultiServiceFactory > & rFactory, + ::com::sun::star::uno::XComponentContext > & rxContext, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPropSet, const sal_Char* pComponentName ); sal_Bool WriteThroughComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStor, - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > - xComponent, + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > xComponent, const sal_Char* pStreamName, ::com::sun::star::uno::Reference< - ::com::sun::star::lang::XMultiServiceFactory > & rFactory, + ::com::sun::star::uno::XComponentContext > & rxContext, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & rPropSet, const sal_Char* pComponentName ); -- cgit v1.2.3