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 /i18npool | |
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 'i18npool')
-rw-r--r-- | i18npool/Executable_saxparser.mk | 1 | ||||
-rw-r--r-- | i18npool/source/localedata/saxparser.cxx | 55 |
2 files changed, 24 insertions, 32 deletions
diff --git a/i18npool/Executable_saxparser.mk b/i18npool/Executable_saxparser.mk index ba0be63c5fc9..ce47a701a9c8 100644 --- a/i18npool/Executable_saxparser.mk +++ b/i18npool/Executable_saxparser.mk @@ -35,6 +35,7 @@ $(eval $(call gb_Executable_set_include,saxparser,\ $(eval $(call gb_Executable_use_sdk_api,saxparser)) $(eval $(call gb_Executable_use_libraries,saxparser,\ + comphelper \ cppu \ cppuhelper \ sal \ diff --git a/i18npool/source/localedata/saxparser.cxx b/i18npool/source/localedata/saxparser.cxx index c23d4ad389f4..6908c6fefac3 100644 --- a/i18npool/source/localedata/saxparser.cxx +++ b/i18npool/source/localedata/saxparser.cxx @@ -27,12 +27,13 @@ #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/xml/sax/SAXParseException.hpp> -#include <com/sun/star/xml/sax/XParser.hpp> +#include <com/sun/star/xml/sax/Parser.hpp> #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> #include <com/sun/star/io/XOutputStream.hpp> #include <com/sun/star/io/XActiveDataSource.hpp> +#include <comphelper/processfactory.hxx> #include <cppuhelper/servicefactory.hxx> #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase3.hxx> @@ -322,46 +323,36 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) // parser demo // read xml from a file and count elements //-------------------------------- - Reference< XInterface > x = xSMgr->createInstance( - OUString("com.sun.star.xml.sax.Parser") ); - int nError = 0; - if( x.is() ) - { - Reference< XParser > rParser( x , UNO_QUERY ); - - // create and connect the document handler to the parser - TestDocumentHandler *pDocHandler = new TestDocumentHandler( argv[1], argv[3]); + Reference< XParser > rParser = Parser::create(comphelper::getComponentContext(xSMgr)); - Reference < XDocumentHandler > rDocHandler( (XDocumentHandler *) pDocHandler ); - Reference< XEntityResolver > rEntityResolver( (XEntityResolver *) pDocHandler ); + int nError = 0; + // create and connect the document handler to the parser + TestDocumentHandler *pDocHandler = new TestDocumentHandler( argv[1], argv[3]); - rParser->setDocumentHandler( rDocHandler ); - rParser->setEntityResolver( rEntityResolver ); + Reference < XDocumentHandler > rDocHandler( (XDocumentHandler *) pDocHandler ); + Reference< XEntityResolver > rEntityResolver( (XEntityResolver *) pDocHandler ); - // create the input stream - InputSource source; - source.aInputStream = createStreamFromFile( argv[2] ); - source.sSystemId = OUString::createFromAscii( argv[2] ); + rParser->setDocumentHandler( rDocHandler ); + rParser->setEntityResolver( rEntityResolver ); - try - { - // start parsing - rParser->parseStream( source ); - } + // create the input stream + InputSource source; + source.aInputStream = createStreamFromFile( argv[2] ); + source.sSystemId = OUString::createFromAscii( argv[2] ); - catch( const Exception & e ) - { - OString o1 = OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8 ); - printf( "Exception during parsing : %s\n" , o1.getStr() ); - exit(1); - } - nError = pDocHandler->nError; + try + { + // start parsing + rParser->parseStream( source ); } - else + + catch( const Exception & e ) { - printf( "couldn't create sax-parser component\n" ); + OString o1 = OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8 ); + printf( "Exception during parsing : %s\n" , o1.getStr() ); exit(1); } + nError = pDocHandler->nError; return nError; } |