diff options
author | Noel Grandin <noel@peralex.com> | 2012-10-03 13:30:43 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-10-04 16:29:53 +0200 |
commit | a20f9a410fdd3f776f870434bc39219d5fc64b40 (patch) | |
tree | 079278e5859c5782fbe9bfcc34302d09bd8dfadd /editeng | |
parent | bd6b41bce491ac5a5f562652b7e32045cc22c35c (diff) |
fdo#46808, Adapt xml::sax::XParser UNO service to new style
The xml.sax.Parser service already existed, it just did not have
a new-style service to create it.
Change-Id: I6f145a7504ff9e149c802f723991954a2801cbc9
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 35 | ||||
-rw-r--r-- | editeng/source/xml/xmltxtimp.cxx | 10 |
2 files changed, 14 insertions, 31 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index 9c5809009587..a970e8aba8f9 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -45,6 +45,7 @@ #include <unotools/transliterationwrapper.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/io/XActiveDataSource.hpp> +#include <comphelper/componentcontext.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/storagehelper.hxx> #include <comphelper/string.hxx> @@ -58,7 +59,7 @@ #include "vcl/window.hxx" #include <helpid.hrc> #include <com/sun/star/xml/sax/InputSource.hpp> -#include <com/sun/star/xml/sax/XParser.hpp> +#include <com/sun/star/xml/sax/Parser.hpp> #include <unotools/streamwrap.hxx> #include <SvXMLAutoCorrectImport.hxx> #include <SvXMLAutoCorrectExport.hxx> @@ -2003,21 +2004,11 @@ void SvxAutoCorrectLanguageLists::LoadXMLExceptList_Imp( xStrm->SetBufferSize( 8 * 1024 ); aParserInput.aInputStream = new utl::OInputStreamWrapper( *xStrm ); - // get parser - uno::Reference< XInterface > xXMLParser = xServiceFactory->createInstance( - OUString("com.sun.star.xml.sax.Parser") ); - OSL_ENSURE( xXMLParser.is(), - "XMLReader::Read: com.sun.star.xml.sax.Parser service missing" ); - if( !xXMLParser.is() ) - { - // Maybe throw an exception? - } - // get filter uno::Reference< xml::sax::XDocumentHandler > xFilter = new SvXMLExceptionListImport ( xServiceFactory, *rpLst ); // connect parser and filter - uno::Reference< xml::sax::XParser > xParser( xXMLParser, UNO_QUERY ); + uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create( comphelper::getComponentContext(xServiceFactory) ); xParser->setDocumentHandler( xFilter ); // parse @@ -2130,26 +2121,22 @@ SvxAutocorrWordList* SvxAutoCorrectLanguageLists::LoadAutocorrWordList() String aXMLWordListName( pXMLImplAutocorr_ListStr, RTL_TEXTENCODING_MS_1252 ); uno::Reference < io::XStream > xStrm = xStg->openStreamElement( aXMLWordListName, embed::ElementModes::READ ); uno::Reference< lang::XMultiServiceFactory > xServiceFactory = comphelper::getProcessServiceFactory(); + uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext(); xml::sax::InputSource aParserInput; aParserInput.sSystemId = aXMLWordListName; aParserInput.aInputStream = xStrm->getInputStream(); // get parser - uno::Reference< XInterface > xXMLParser = xServiceFactory->createInstance( OUString("com.sun.star.xml.sax.Parser") ); - OSL_ENSURE( xXMLParser.is(), "XMLReader::Read: com.sun.star.xml.sax.Parser service missing" ); - if( xXMLParser.is() ) - { - RTL_LOGFILE_PRODUCT_CONTEXT( aLog, "AutoCorrect Import" ); - uno::Reference< xml::sax::XDocumentHandler > xFilter = new SvXMLAutoCorrectImport( xServiceFactory, pAutocorr_List, rAutoCorrect, xStg ); + uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create(xContext); + RTL_LOGFILE_PRODUCT_CONTEXT( aLog, "AutoCorrect Import" ); + uno::Reference< xml::sax::XDocumentHandler > xFilter = new SvXMLAutoCorrectImport( xServiceFactory, pAutocorr_List, rAutoCorrect, xStg ); - // connect parser and filter - uno::Reference< xml::sax::XParser > xParser( xXMLParser, UNO_QUERY ); - xParser->setDocumentHandler( xFilter ); + // connect parser and filter + xParser->setDocumentHandler( xFilter ); - // parse - xParser->parseStream( aParserInput ); - } + // parse + xParser->parseStream( aParserInput ); } catch ( const uno::Exception& ) { diff --git a/editeng/source/xml/xmltxtimp.cxx b/editeng/source/xml/xmltxtimp.cxx index cc5d11115436..27e6b3613a7f 100644 --- a/editeng/source/xml/xmltxtimp.cxx +++ b/editeng/source/xml/xmltxtimp.cxx @@ -29,7 +29,7 @@ #include <com/sun/star/io/Pipe.hpp> #include <com/sun/star/io/XActiveDataControl.hpp> #include <com/sun/star/io/XActiveDataSource.hpp> -#include <com/sun/star/xml/sax/XParser.hpp> +#include <com/sun/star/xml/sax/Parser.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp> #include <com/sun/star/io/XOutputStream.hpp> #include <com/sun/star/text/XText.hpp> @@ -170,18 +170,14 @@ void SvxReadXML( EditEngine& rEditEngine, SvStream& rStream, const ESelection& r do { uno::Reference<lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() ); + uno::Reference<uno::XComponentContext> xContext( ::comphelper::getProcessComponentContext() ); if( !xServiceFactory.is() ) { OSL_FAIL( "SvxXMLXTableImport::load: got no service manager" ); break; } - uno::Reference< xml::sax::XParser > xParser( xServiceFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.Parser" ) ) ), uno::UNO_QUERY ); - if( !xParser.is() ) - { - OSL_FAIL( "com.sun.star.xml.sax.Parser service missing" ); - break; - } + uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create( xContext ); uno::Reference<io::XInputStream> xInputStream = new utl::OInputStreamWrapper( rStream ); |