diff options
author | Noel Grandin <noel@peralex.com> | 2012-10-10 10:13:18 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-10-22 17:01:11 +0200 |
commit | fb741b5e1e6aeaee74cf14af4f1cc152f0ab0952 (patch) | |
tree | 24864ba5addb12799a508ce4718868026519f057 /editeng | |
parent | CLANGPLUGIN_CPPFLAGS for building plugin for Clang in nonstandard location (diff) | |
download | core-fb741b5e1e6aeaee74cf14af4f1cc152f0ab0952.tar.gz core-fb741b5e1e6aeaee74cf14af4f1cc152f0ab0952.zip |
fdo#46808, Adapt xml::sax::XWriter UNO service to new style
Create a merged XWriter interface for the service.
The xml.sax.Writer service already existed, it just did not have
an IDL file.
Change-Id: I4e6d3f3c68f9282a55fc7aa19778f97632fd8ad5
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 41 | ||||
-rw-r--r-- | editeng/source/xml/xmltxtexp.cxx | 17 |
2 files changed, 18 insertions, 40 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index a970e8aba8f9..45f63a944eda 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -60,6 +60,7 @@ #include <helpid.hrc> #include <com/sun/star/xml/sax/InputSource.hpp> #include <com/sun/star/xml/sax/Parser.hpp> +#include <com/sun/star/xml/sax/Writer.hpp> #include <unotools/streamwrap.hxx> #include <SvXMLAutoCorrectImport.hxx> #include <SvXMLAutoCorrectExport.hxx> @@ -2069,23 +2070,15 @@ void SvxAutoCorrectLanguageLists::SaveExceptList_Imp( uno::Reference< lang::XMultiServiceFactory > xServiceFactory = comphelper::getProcessServiceFactory(); - OSL_ENSURE( xServiceFactory.is(), - "XMLReader::Read: got no service manager" ); - if( !xServiceFactory.is() ) - { - // Throw an exception ? - } + uno::Reference< uno::XComponentContext > xContext = + comphelper::getProcessComponentContext(); - uno::Reference < XInterface > xWriter (xServiceFactory->createInstance( - OUString("com.sun.star.xml.sax.Writer"))); - OSL_ENSURE(xWriter.is(),"com.sun.star.xml.sax.Writer service missing"); + uno::Reference < xml::sax::XWriter > xWriter = xml::sax::Writer::create(xContext); uno::Reference < io::XOutputStream> xOut = new utl::OOutputStreamWrapper( *xStrm ); - uno::Reference<io::XActiveDataSource> xSrc(xWriter, uno::UNO_QUERY); - xSrc->setOutputStream(xOut); + xWriter->setOutputStream(xOut); - uno::Reference<xml::sax::XDocumentHandler> xHandler(xWriter, uno::UNO_QUERY); - - SvXMLExceptionListExport aExp( xServiceFactory, rLst, sStrmName, xHandler ); + uno::Reference < xml::sax::XDocumentHandler > xHandler(xWriter, UNO_QUERY_THROW); + SvXMLExceptionListExport aExp( xServiceFactory, rLst, sStrmName, xHandler ); aExp.exportDoc( XML_BLOCK_LIST ); @@ -2440,23 +2433,15 @@ sal_Bool SvxAutoCorrectLanguageLists::MakeBlocklist_Imp( SvStorage& rStg ) uno::Reference< lang::XMultiServiceFactory > xServiceFactory = comphelper::getProcessServiceFactory(); - OSL_ENSURE( xServiceFactory.is(), - "XMLReader::Read: got no service manager" ); - if( !xServiceFactory.is() ) - { - // Throw an exception ? - } + uno::Reference< uno::XComponentContext > xContext = + comphelper::getProcessComponentContext(); - uno::Reference < XInterface > xWriter (xServiceFactory->createInstance( - OUString("com.sun.star.xml.sax.Writer"))); - OSL_ENSURE(xWriter.is(),"com.sun.star.xml.sax.Writer service missing"); + uno::Reference < xml::sax::XWriter > xWriter = xml::sax::Writer::create(xContext); uno::Reference < io::XOutputStream> xOut = new utl::OOutputStreamWrapper( *refList ); - uno::Reference<io::XActiveDataSource> xSrc(xWriter, uno::UNO_QUERY); - xSrc->setOutputStream(xOut); - - uno::Reference<xml::sax::XDocumentHandler> xHandler(xWriter, uno::UNO_QUERY); + xWriter->setOutputStream(xOut); - SvXMLAutoCorrectExport aExp( xServiceFactory, pAutocorr_List, sStrmName, xHandler ); + uno::Reference<xml::sax::XDocumentHandler> xHandler(xWriter, uno::UNO_QUERY); + SvXMLAutoCorrectExport aExp( xServiceFactory, pAutocorr_List, sStrmName, xHandler ); aExp.exportDoc( XML_BLOCK_LIST ); diff --git a/editeng/source/xml/xmltxtexp.cxx b/editeng/source/xml/xmltxtexp.cxx index 382965de3b43..9148b23c1358 100644 --- a/editeng/source/xml/xmltxtexp.cxx +++ b/editeng/source/xml/xmltxtexp.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/xml/sax/Writer.hpp> #include <svl/itemprop.hxx> #include <svl/brdcst.hxx> #include <com/sun/star/uno/Sequence.hxx> @@ -420,6 +421,7 @@ void SvxWriteXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection& // create service factory uno::Reference< lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() ); + uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); if( !xServiceFactory.is() ) { @@ -428,16 +430,7 @@ void SvxWriteXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection& } // create document handler - - uno::Reference< uno::XInterface > xWriter( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Writer" ) ) ) ); - - if( !xWriter.is() ) - { - OSL_FAIL( "com.sun.star.xml.sax.Writer service missing" ); - break; - } - - uno::Reference<xml::sax::XDocumentHandler> xHandler( xWriter, uno::UNO_QUERY ); + uno::Reference< xml::sax::XWriter > xWriter = xml::sax::Writer::create( xContext ); // create output stream and active data source uno::Reference<io::XOutputStream> xOut( new utl::OOutputStreamWrapper( rStream ) ); @@ -450,13 +443,13 @@ void SvxWriteXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection& */ - uno::Reference<io::XActiveDataSource> xMetaSrc( xWriter, uno::UNO_QUERY ); - xMetaSrc->setOutputStream( xOut ); + xWriter->setOutputStream( xOut ); // export text const OUString aName; // SvxXMLTextExportComponent aExporter( &rEditEngine, rSel, aName, xHandler ); + uno::Reference< xml::sax::XDocumentHandler > xHandler(xWriter, UNO_QUERY_THROW); SvxXMLTextExportComponent aExporter( xServiceFactory, &rEditEngine, rSel, aName, xHandler ); aExporter.exportDoc(); |