summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2013-03-08 14:06:05 +0200
committerNoel Grandin <noel@peralex.com>2013-03-20 07:32:52 +0200
commitb4b0b400071a0fd12587334e3b9d615f35be671b (patch)
treebbaadae1d60fda7c1195f5dbf9c055db1b5ea029 /sw
parent51a2b574bf6e163d34d2301c2b526a09cd7ff1aa (diff)
fdo#46808, cleanup some usage of getProcessServiceFactory()
Change-Id: I2ab4c7c0a19bd436c84e62bfc6aeda1fea079a44
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/docnode/swthreadjoiner.cxx8
-rw-r--r--sw/source/core/swg/SwXMLTextBlocks1.cxx120
-rw-r--r--sw/source/filter/ww8/ww8par.cxx1
-rw-r--r--sw/source/filter/xml/wrtxml.cxx28
-rw-r--r--sw/source/filter/xml/wrtxml.hxx4
5 files changed, 69 insertions, 92 deletions
diff --git a/sw/source/core/docnode/swthreadjoiner.cxx b/sw/source/core/docnode/swthreadjoiner.cxx
index 0f5c74e7fdf7..f68e9cb821bf 100644
--- a/sw/source/core/docnode/swthreadjoiner.cxx
+++ b/sw/source/core/docnode/swthreadjoiner.cxx
@@ -18,7 +18,7 @@
*/
#include <swthreadjoiner.hxx>
#include <finalthreadmanager.hxx>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/JobManager.hpp>
#include <comphelper/processfactory.hxx>
#include <osl/mutex.hxx>
#include <rtl/instance.hxx>
@@ -42,11 +42,7 @@ uno::Reference< util::XJobManager >& SwThreadJoiner::GetThreadJoiner()
if ( !mpThreadJoiner.is() )
{
- mpThreadJoiner =
- uno::Reference< util::XJobManager >(
- ::comphelper::getProcessServiceFactory()->createInstance(
- OUString("com.sun.star.util.JobManager") ),
- uno::UNO_QUERY );
+ mpThreadJoiner = util::JobManager::create( comphelper::getProcessComponentContext() );
}
return mpThreadJoiner;
diff --git a/sw/source/core/swg/SwXMLTextBlocks1.cxx b/sw/source/core/swg/SwXMLTextBlocks1.cxx
index a793fe732e2f..bcb26b4a01f5 100644
--- a/sw/source/core/swg/SwXMLTextBlocks1.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks1.cxx
@@ -193,73 +193,65 @@ sal_uLong SwXMLTextBlocks::GetMacroTable( sal_uInt16 nIdx,
aParserInput.aInputStream = xInputStream;
// get service factory
- uno::Reference< lang::XMultiServiceFactory > xServiceFactory =
- comphelper::getProcessServiceFactory();
uno::Reference< uno::XComponentContext > xContext =
comphelper::getProcessComponentContext();
- if ( xServiceFactory.is() )
+
+ // get parser
+ uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create( xContext );
+
+ // create descriptor and reference to it. Either
+ // both or neither must be kept because of the
+ // reference counting!
+ SvMacroTableEventDescriptor* pDescriptor =
+ new SvMacroTableEventDescriptor(aAutotextEvents);
+ uno::Reference<XNameReplace> xReplace = pDescriptor;
+ Sequence<Any> aFilterArguments( 1 );
+ aFilterArguments[0] <<= xReplace;
+
+ // get filter
+ OUString sFilterComponent = bOasis
+ ? OUString("com.sun.star.comp.Writer.XMLOasisAutotextEventsImporter")
+ : OUString("com.sun.star.comp.Writer.XMLAutotextEventsImporter");
+ uno::Reference< xml::sax::XDocumentHandler > xFilter(
+ xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+ sFilterComponent, aFilterArguments, xContext),
+ UNO_QUERY );
+ OSL_ENSURE( xFilter.is(),
+ "can't instantiate atevents filter");
+ if ( xFilter.is() )
{
+ // connect parser and filter
+ xParser->setDocumentHandler( xFilter );
+
+ // connect model and filter
+ uno::Reference<document::XImporter> xImporter( xFilter,
+ UNO_QUERY );
+
+ // we don't need a model
+ // xImporter->setTargetDocument( xModelComponent );
- // get parser
- uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create( xContext );
-
- // create descriptor and reference to it. Either
- // both or neither must be kept because of the
- // reference counting!
- SvMacroTableEventDescriptor* pDescriptor =
- new SvMacroTableEventDescriptor(aAutotextEvents);
- uno::Reference<XNameReplace> xReplace = pDescriptor;
- Sequence<Any> aFilterArguments( 1 );
- aFilterArguments[0] <<= xReplace;
-
- // get filter
- OUString sFilterComponent = bOasis
- ? OUString("com.sun.star.comp.Writer.XMLOasisAutotextEventsImporter")
- : OUString("com.sun.star.comp.Writer.XMLAutotextEventsImporter");
- uno::Reference< xml::sax::XDocumentHandler > xFilter(
- xServiceFactory->createInstanceWithArguments(
- sFilterComponent, aFilterArguments),
- UNO_QUERY );
- OSL_ENSURE( xFilter.is(),
- "can't instantiate atevents filter");
- if ( xFilter.is() )
+ // parse the stream
+ try
{
- // connect parser and filter
- xParser->setDocumentHandler( xFilter );
-
- // connect model and filter
- uno::Reference<document::XImporter> xImporter( xFilter,
- UNO_QUERY );
-
- // we don't need a model
- // xImporter->setTargetDocument( xModelComponent );
-
- // parse the stream
- try
- {
- xParser->parseStream( aParserInput );
- }
- catch( xml::sax::SAXParseException& )
- {
- // workaround for #83452#: SetSize doesn't work
- // nRet = ERR_SWG_READ_ERROR;
- }
- catch( xml::sax::SAXException& )
- {
- nRet = ERR_SWG_READ_ERROR;
- }
- catch( io::IOException& )
- {
- nRet = ERR_SWG_READ_ERROR;
- }
-
- // and finally, copy macro into table
- if (0 == nRet)
- pDescriptor->copyMacrosIntoTable(rMacroTbl);
+ xParser->parseStream( aParserInput );
}
- else
+ catch( xml::sax::SAXParseException& )
+ {
+ // workaround for #83452#: SetSize doesn't work
+ // nRet = ERR_SWG_READ_ERROR;
+ }
+ catch( xml::sax::SAXException& )
+ {
nRet = ERR_SWG_READ_ERROR;
+ }
+ catch( io::IOException& )
+ {
+ nRet = ERR_SWG_READ_ERROR;
+ }
+ // and finally, copy macro into table
+ if (0 == nRet)
+ pDescriptor->copyMacrosIntoTable(rMacroTbl);
}
else
nRet = ERR_SWG_READ_ERROR;
@@ -529,14 +521,8 @@ sal_uLong SwXMLTextBlocks::SetMacroTable(
// start XML autotext event export
sal_uLong nRes = 0;
- uno::Reference< lang::XMultiServiceFactory > xServiceFactory =
- comphelper::getProcessServiceFactory();
uno::Reference< uno::XComponentContext > xContext =
comphelper::getProcessComponentContext();
- OSL_ENSURE( xServiceFactory.is(),
- "XML autotext event write:: got no service manager" );
- if( !xServiceFactory.is() )
- return ERR_SWG_WRITE_ERROR;
// Get model
uno::Reference< lang::XComponent > xModelComp(
@@ -595,8 +581,8 @@ sal_uLong SwXMLTextBlocks::SetMacroTable(
? OUString("com.sun.star.comp.Writer.XMLOasisAutotextEventsExporter")
: OUString("com.sun.star.comp.Writer.XMLAutotextEventsExporter");
uno::Reference< document::XExporter > xExporter(
- xServiceFactory->createInstanceWithArguments(
- sFilterComponent, aParams), UNO_QUERY);
+ xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+ sFilterComponent, aParams, xContext), UNO_QUERY);
OSL_ENSURE( xExporter.is(),
"can't instantiate export filter component" );
if( xExporter.is() )
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 45aeba057d54..840f2f969671 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -132,7 +132,6 @@ using namespace nsHdFtFlags;
#include <oox/ole/olestorage.hxx>
using ::comphelper::MediaDescriptor;
-using ::comphelper::getProcessServiceFactory;
class BasicProjImportHelper
{
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
index 6cf84811940d..0d2abe0cee99 100644
--- a/sw/source/filter/xml/wrtxml.cxx
+++ b/sw/source/filter/xml/wrtxml.cxx
@@ -78,12 +78,8 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
const rtl::OUString& aDocHierarchicalName )
{
// Get service factory
- uno::Reference< lang::XMultiServiceFactory > xServiceFactory =
- comphelper::getProcessServiceFactory();
- OSL_ENSURE( xServiceFactory.is(),
- "SwXMLWriter::Write: got no service manager" );
- if( !xServiceFactory.is() )
- return ERR_SWG_WRITE_ERROR;
+ uno::Reference< uno::XComponentContext > xContext =
+ comphelper::getProcessComponentContext();
// Get data sink ...
uno::Reference< io::XOutputStream > xOut;
@@ -345,7 +341,7 @@ pGraphicHelper = SvXMLGraphicHelper::Create( xStg,
if( !bOrganizerMode && !bBlock && bStoreMeta )
{
if( !WriteThroughComponent(
- xModelComp, "meta.xml", xServiceFactory,
+ xModelComp, "meta.xml", xContext,
(bOASIS ? "com.sun.star.comp.Writer.XMLOasisMetaExporter"
: "com.sun.star.comp.Writer.XMLMetaExporter"),
aEmptyArgs, aProps ) )
@@ -361,7 +357,7 @@ pGraphicHelper = SvXMLGraphicHelper::Create( xStg,
if( !bBlock )
{
if( !WriteThroughComponent(
- xModelComp, "settings.xml", xServiceFactory,
+ xModelComp, "settings.xml", xContext,
(bOASIS ? "com.sun.star.comp.Writer.XMLOasisSettingsExporter"
: "com.sun.star.comp.Writer.XMLSettingsExporter"),
aEmptyArgs, aProps ) )
@@ -377,7 +373,7 @@ pGraphicHelper = SvXMLGraphicHelper::Create( xStg,
}
if( !WriteThroughComponent(
- xModelComp, "styles.xml", xServiceFactory,
+ xModelComp, "styles.xml", xContext,
(bOASIS ? "com.sun.star.comp.Writer.XMLOasisStylesExporter"
: "com.sun.star.comp.Writer.XMLStylesExporter"),
aFilterArgs, aProps ) )
@@ -391,7 +387,7 @@ pGraphicHelper = SvXMLGraphicHelper::Create( xStg,
if( !bOrganizerMode && !bErr )
{
if( !WriteThroughComponent(
- xModelComp, "content.xml", xServiceFactory,
+ xModelComp, "content.xml", xContext,
(bOASIS ? "com.sun.star.comp.Writer.XMLOasisContentExporter"
: "com.sun.star.comp.Writer.XMLContentExporter"),
aFilterArgs, aProps ) )
@@ -501,7 +497,7 @@ sal_uLong SwXMLWriter::Write( SwPaM& rPaM, SfxMedium& rMed,
bool SwXMLWriter::WriteThroughComponent(
const uno::Reference<XComponent> & xComponent,
const sal_Char* pStreamName,
- const uno::Reference<lang::XMultiServiceFactory> & rFactory,
+ const uno::Reference<uno::XComponentContext> & rxContext,
const sal_Char* pServiceName,
const Sequence<Any> & rArguments,
const Sequence<beans::PropertyValue> & rMediaDesc )
@@ -555,7 +551,7 @@ bool SwXMLWriter::WriteThroughComponent(
// write the stuff
bRet = WriteThroughComponent(
- xOutputStream, xComponent, rFactory,
+ xOutputStream, xComponent, rxContext,
pServiceName, rArguments, rMediaDesc );
}
catch ( uno::Exception& )
@@ -569,7 +565,7 @@ bool SwXMLWriter::WriteThroughComponent(
bool SwXMLWriter::WriteThroughComponent(
const uno::Reference<io::XOutputStream> & xOutputStream,
const uno::Reference<XComponent> & xComponent,
- const uno::Reference<XMultiServiceFactory> & rFactory,
+ const uno::Reference<XComponentContext> & rxContext,
const sal_Char* pServiceName,
const Sequence<Any> & rArguments,
const Sequence<PropertyValue> & rMediaDesc )
@@ -582,7 +578,7 @@ bool SwXMLWriter::WriteThroughComponent(
"SwXMLWriter::WriteThroughComponent" );
// get component
- uno::Reference< xml::sax::XWriter > xSaxWriter = xml::sax::Writer::create(comphelper::getComponentContext(rFactory));
+ uno::Reference< xml::sax::XWriter > xSaxWriter = xml::sax::Writer::create(rxContext);
RTL_LOGFILE_CONTEXT_TRACE( aFilterLog, "SAX-Writer created" );
// connect XML writer to output stream
@@ -597,8 +593,8 @@ bool SwXMLWriter::WriteThroughComponent(
// get filter component
uno::Reference< document::XExporter > xExporter(
- rFactory->createInstanceWithArguments(
- OUString::createFromAscii(pServiceName), aArgs), UNO_QUERY);
+ rxContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+ OUString::createFromAscii(pServiceName), aArgs, rxContext), UNO_QUERY);
OSL_ENSURE( xExporter.is(),
"can't instantiate export filter component" );
if( !xExporter.is() )
diff --git a/sw/source/filter/xml/wrtxml.hxx b/sw/source/filter/xml/wrtxml.hxx
index 4ee80a018b1e..debc8d98d27e 100644
--- a/sw/source/filter/xml/wrtxml.hxx
+++ b/sw/source/filter/xml/wrtxml.hxx
@@ -66,7 +66,7 @@ private:
const sal_Char* pStreamName, /// the stream name
/// service factory for pServiceName
const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XMultiServiceFactory> & rFactory,
+ ::com::sun::star::uno::XComponentContext> & rFactory,
const sal_Char* pServiceName, /// service name of the component
/// the argument (XInitialization)
const ::com::sun::star::uno::Sequence<
@@ -83,7 +83,7 @@ private:
const ::com::sun::star::uno::Reference<
::com::sun::star::lang::XComponent> & xComponent,
const ::com::sun::star::uno::Reference<
- ::com::sun::star::lang::XMultiServiceFactory> & rFactory,
+ ::com::sun::star::uno::XComponentContext> & rFactory,
const sal_Char* pServiceName,
const ::com::sun::star::uno::Sequence<
::com::sun::star::uno::Any> & rArguments,