LCOV - code coverage report
Current view: top level - libreoffice/sax/source/expatwrap - sax_expat.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 197 379 52.0 %
Date: 2012-12-27 Functions: 37 60 61.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #include <stdlib.h>
      20             : #include <string.h>
      21             : #include <sal/alloca.h>
      22             : #include <vector>
      23             : 
      24             : #include <osl/diagnose.h>
      25             : 
      26             : #include <com/sun/star/lang/XServiceInfo.hpp>
      27             : #include <com/sun/star/util/XCloneable.hpp>
      28             : #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
      29             : #include <com/sun/star/xml/sax/XParser.hpp>
      30             : #include <com/sun/star/xml/sax/SAXParseException.hpp>
      31             : #include <com/sun/star/io/XSeekable.hpp>
      32             : 
      33             : #include <cppuhelper/factory.hxx>
      34             : #include <cppuhelper/weak.hxx>
      35             : #include <cppuhelper/implbase1.hxx>
      36             : #include <cppuhelper/implbase2.hxx>
      37             : 
      38             : #include <expat.h>
      39             : 
      40             : using namespace ::rtl;
      41             : using namespace ::std;
      42             : using namespace ::osl;
      43             : using namespace ::cppu;
      44             : using namespace ::com::sun::star::uno;
      45             : using namespace ::com::sun::star::lang;
      46             : using namespace ::com::sun::star::registry;
      47             : using namespace ::com::sun::star::xml::sax;
      48             : using namespace ::com::sun::star::util;
      49             : using namespace ::com::sun::star::io;
      50             : 
      51             : #include "factory.hxx"
      52             : #include "attrlistimpl.hxx"
      53             : #include "xml2utf.hxx"
      54             : 
      55             : namespace sax_expatwrap {
      56             : 
      57             : // Useful macros for correct String conversion depending on the choosen expat-mode
      58             : #ifdef XML_UNICODE
      59             : OUString XmlNChar2OUString( const XML_Char *p , int nLen )
      60             : {
      61             :     if( p ) {
      62             :         if( sizeof( sal_Unicode ) == sizeof( XML_Char ) )
      63             :         {
      64             :             return OUString( (sal_Unicode*)p,nLen);
      65             :         }
      66             :         else
      67             :         {
      68             :             sal_Unicode *pWchar = (sal_Unicode *)alloca( sizeof( sal_Unicode ) * nLen );
      69             :             for( int n = 0 ; n < nLen ; n++ ) {
      70             :                 pWchar[n] = (sal_Unicode) p[n];
      71             :             }
      72             :             return OUString( pWchar , nLen );
      73             :         }
      74             :     }
      75             :     else {
      76             :         return OUString();
      77             :     }
      78             : }
      79             : 
      80             : OUString XmlChar2OUString( const XML_Char *p )
      81             : {
      82             :     if( p ) {
      83             :         int nLen;
      84             :         for( nLen = 0 ; p[nLen] ; nLen ++ )
      85             :             ;
      86             :          return XmlNChar2OUString( p , nLen );
      87             :      }
      88             :      else return OUString();
      89             : }
      90             : 
      91             : 
      92             : #define XML_CHAR_TO_OUSTRING(x) XmlChar2OUString(x)
      93             : #define XML_CHAR_N_TO_USTRING(x,n) XmlNChar2OUString(x,n)
      94             : #else
      95             : #define XML_CHAR_TO_OUSTRING(x) OUString(x , strlen( x ), RTL_TEXTENCODING_UTF8)
      96             : #define XML_CHAR_N_TO_USTRING(x,n) OUString(x,n, RTL_TEXTENCODING_UTF8 )
      97             : #endif
      98             : 
      99             : 
     100             : /*
     101             : * The following macro encapsulates any call to an event handler.
     102             : * It ensures, that exceptions thrown by the event handler are
     103             : * treated properly.
     104             : */
     105             : #define CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS(pThis,call) \
     106             :     if( ! pThis->bExceptionWasThrown ) { \
     107             :         try {\
     108             :             pThis->call;\
     109             :         }\
     110             :         catch( const SAXParseException &e ) {\
     111             :             pThis->callErrorHandler( pThis ,  e );\
     112             :          }\
     113             :         catch( const SAXException &e ) {\
     114             :             pThis->callErrorHandler( pThis , SAXParseException(\
     115             :                                             e.Message, \
     116             :                                             e.Context, \
     117             :                                             e.WrappedException,\
     118             :                                             pThis->rDocumentLocator->getPublicId(),\
     119             :                                             pThis->rDocumentLocator->getSystemId(),\
     120             :                                             pThis->rDocumentLocator->getLineNumber(),\
     121             :                                             pThis->rDocumentLocator->getColumnNumber()\
     122             :                                      ) );\
     123             :         }\
     124             :         catch( const com::sun::star::uno::RuntimeException &e ) {\
     125             :             pThis->bExceptionWasThrown = true; \
     126             :             pThis->bRTExceptionWasThrown = true; \
     127             :             pImpl->rtexception = e; \
     128             :         }\
     129             :     }\
     130             :     ((void)0)
     131             : 
     132             : #define IMPLEMENTATION_NAME "com.sun.star.comp.extensions.xml.sax.ParserExpat"
     133             : #define SERVICE_NAME        "com.sun.star.xml.sax.Parser"
     134             : 
     135             : class SaxExpatParser_Impl;
     136             : 
     137             : 
     138             : // This class implements the external Parser interface
     139             : class SaxExpatParser :
     140             :     public WeakImplHelper2<
     141             :                 XParser,
     142             :                 XServiceInfo
     143             :                           >
     144             : {
     145             : 
     146             : public:
     147             :     SaxExpatParser();
     148             :     ~SaxExpatParser();
     149             : 
     150             : public:
     151             : 
     152             :     // The implementation details
     153             :     static Sequence< OUString >     getSupportedServiceNames_Static(void) throw ();
     154             : 
     155             : public:
     156             :     // The SAX-Parser-Interface
     157             :     virtual void SAL_CALL parseStream(  const InputSource& structSource)
     158             :         throw ( SAXException,
     159             :                 IOException,
     160             :                 RuntimeException);
     161             :     virtual void SAL_CALL setDocumentHandler(const Reference< XDocumentHandler > & xHandler)
     162             :         throw (RuntimeException);
     163             : 
     164             :     virtual void SAL_CALL setErrorHandler(const Reference< XErrorHandler > & xHandler)
     165             :         throw (RuntimeException);
     166             :     virtual void SAL_CALL setDTDHandler(const Reference < XDTDHandler > & xHandler)
     167             :         throw (RuntimeException);
     168             :     virtual void SAL_CALL setEntityResolver(const Reference<  XEntityResolver >& xResolver)
     169             :         throw (RuntimeException);
     170             : 
     171             :     virtual void SAL_CALL setLocale( const Locale &locale )                     throw (RuntimeException);
     172             : 
     173             : public: // XServiceInfo
     174             :     OUString                     SAL_CALL getImplementationName() throw ();
     175             :     Sequence< OUString >         SAL_CALL getSupportedServiceNames(void) throw ();
     176             :     sal_Bool                     SAL_CALL supportsService(const OUString& ServiceName) throw ();
     177             : 
     178             : private:
     179             : 
     180             :     SaxExpatParser_Impl         *m_pImpl;
     181             : 
     182             : };
     183             : 
     184             : //--------------------------------------
     185             : // the extern interface
     186             : //---------------------------------------
     187        1594 : Reference< XInterface > SAL_CALL SaxExpatParser_CreateInstance(
     188             :     SAL_UNUSED_PARAMETER const Reference< XMultiServiceFactory > & )
     189             :     throw(Exception)
     190             : {
     191        1594 :     SaxExpatParser *p = new SaxExpatParser;
     192             : 
     193        1594 :     return Reference< XInterface > ( (OWeakObject * ) p );
     194             : }
     195             : 
     196             : 
     197             : 
     198         234 : Sequence< OUString >    SaxExpatParser::getSupportedServiceNames_Static(void) throw ()
     199             : {
     200         234 :     Sequence<OUString> aRet(1);
     201         234 :     aRet.getArray()[0] = ::rtl::OUString( SERVICE_NAME );
     202         234 :     return aRet;
     203             : }
     204             : 
     205             : 
     206             : //---------------------------------------------
     207             : // the implementation part
     208             : //---------------------------------------------
     209             : 
     210             : 
     211             : // Entity binds all information neede for a single file
     212        3852 : struct Entity
     213             : {
     214             :     InputSource         structSource;
     215             :     XML_Parser          pParser;
     216             :     XMLFile2UTFConverter converter;
     217             : };
     218             : 
     219             : 
     220        1594 : class SaxExpatParser_Impl
     221             : {
     222             : public: // module scope
     223             :     Mutex               aMutex;
     224             :     OUString            sCDATA;
     225             : 
     226             :     Reference< XDocumentHandler >   rDocumentHandler;
     227             :     Reference< XExtendedDocumentHandler > rExtendedDocumentHandler;
     228             : 
     229             :     Reference< XErrorHandler >  rErrorHandler;
     230             :     Reference< XDTDHandler >    rDTDHandler;
     231             :     Reference< XEntityResolver > rEntityResolver;
     232             :     Reference < XLocator >      rDocumentLocator;
     233             : 
     234             : 
     235             :     Reference < XAttributeList >    rAttrList;
     236             :     AttributeList   *pAttrList;
     237             : 
     238             :     // External entity stack
     239             :     vector<struct Entity>   vecEntity;
     240         956 :     void pushEntity( const struct Entity &entity )
     241         956 :         { vecEntity.push_back( entity ); }
     242         956 :     void popEntity()
     243         956 :         { vecEntity.pop_back( ); }
     244        4326 :     struct Entity &getEntity()
     245        4326 :         { return vecEntity.back(); }
     246             : 
     247             : 
     248             :     // Exception cannot be thrown through the C-XmlParser (possible resource leaks),
     249             :     // therefor the exception must be saved somewhere.
     250             :     SAXParseException   exception;
     251             :     RuntimeException    rtexception;
     252             :     bool                bExceptionWasThrown;
     253             :     bool                bRTExceptionWasThrown;
     254             : 
     255             :     Locale              locale;
     256             : 
     257             : public:
     258        1594 :     SaxExpatParser_Impl()
     259        1594 :         : sCDATA("CDATA")
     260             :     {
     261        1594 :     }
     262             : 
     263             :     // the C-Callbacks for the expat parser
     264             :     void static callbackStartElement(void *userData, const XML_Char *name , const XML_Char **atts);
     265             :     void static callbackEndElement(void *userData, const XML_Char *name);
     266             :     void static callbackCharacters( void *userData , const XML_Char *s , int nLen );
     267             :     void static callbackProcessingInstruction(  void *userData ,
     268             :                                                 const XML_Char *sTarget ,
     269             :                                                 const XML_Char *sData );
     270             : 
     271             :     void static callbackEntityDecl( void *userData ,
     272             :                                     const XML_Char *entityName,
     273             :                                     int is_parameter_entity,
     274             :                                     const XML_Char *value,
     275             :                                     int value_length,
     276             :                                     const XML_Char *base,
     277             :                                     const XML_Char *systemId,
     278             :                                     const XML_Char *publicId,
     279             :                                     const XML_Char *notationName);
     280             : 
     281             :     void static callbackNotationDecl(   void *userData,
     282             :                                         const XML_Char *notationName,
     283             :                                         const XML_Char *base,
     284             :                                         const XML_Char *systemId,
     285             :                                         const XML_Char *publicId);
     286             : 
     287             :     int static callbackExternalEntityRef(   XML_Parser parser,
     288             :                                             const XML_Char *openEntityNames,
     289             :                                             const XML_Char *base,
     290             :                                             const XML_Char *systemId,
     291             :                                             const XML_Char *publicId);
     292             : 
     293             :     int static callbackUnknownEncoding(void *encodingHandlerData,
     294             :                                                   const XML_Char *name,
     295             :                                                   XML_Encoding *info);
     296             : 
     297             :     void static callbackDefault( void *userData,  const XML_Char *s,  int len);
     298             : 
     299             :     void static callbackStartCDATA( void *userData );
     300             :     void static callbackEndCDATA( void *userData );
     301             :     void static callbackComment( void *userData , const XML_Char *s );
     302             :     void static callErrorHandler( SaxExpatParser_Impl *pImpl , const SAXParseException &e );
     303             : 
     304             : public:
     305             :     void parse();
     306             : };
     307             : 
     308             : extern "C"
     309             : {
     310       70250 :     static void call_callbackStartElement(void *userData, const XML_Char *name , const XML_Char **atts)
     311             :     {
     312       70250 :         SaxExpatParser_Impl::callbackStartElement(userData,name,atts);
     313       70250 :     }
     314       70250 :     static void call_callbackEndElement(void *userData, const XML_Char *name)
     315             :     {
     316       70250 :         SaxExpatParser_Impl::callbackEndElement(userData,name);
     317       70250 :     }
     318      163438 :     static void call_callbackCharacters( void *userData , const XML_Char *s , int nLen )
     319             :     {
     320      163438 :         SaxExpatParser_Impl::callbackCharacters(userData,s,nLen);
     321      163438 :     }
     322           0 :     static void call_callbackProcessingInstruction(void *userData,const XML_Char *sTarget,const XML_Char *sData )
     323             :     {
     324           0 :         SaxExpatParser_Impl::callbackProcessingInstruction(userData,sTarget,sData );
     325           0 :     }
     326           0 :     static void call_callbackEntityDecl(void *userData ,
     327             :                                         const XML_Char *entityName,
     328             :                                         int is_parameter_entity,
     329             :                                         const XML_Char *value,
     330             :                                         int value_length,
     331             :                                         const XML_Char *base,
     332             :                                         const XML_Char *systemId,
     333             :                                         const XML_Char *publicId,
     334             :                                         const XML_Char *notationName)
     335             :     {
     336             :         SaxExpatParser_Impl::callbackEntityDecl(userData, entityName,
     337             :                 is_parameter_entity, value, value_length,
     338           0 :                 base, systemId, publicId, notationName);
     339           0 :     }
     340           0 :     static void call_callbackNotationDecl(void *userData,
     341             :                                           const XML_Char *notationName,
     342             :                                           const XML_Char *base,
     343             :                                           const XML_Char *systemId,
     344             :                                           const XML_Char *publicId)
     345             :     {
     346           0 :         SaxExpatParser_Impl::callbackNotationDecl(userData,notationName,base,systemId,publicId);
     347           0 :     }
     348           0 :     static int call_callbackExternalEntityRef(XML_Parser parser,
     349             :                                               const XML_Char *openEntityNames,
     350             :                                               const XML_Char *base,
     351             :                                               const XML_Char *systemId,
     352             :                                               const XML_Char *publicId)
     353             :     {
     354           0 :         return SaxExpatParser_Impl::callbackExternalEntityRef(parser,openEntityNames,base,systemId,publicId);
     355             :     }
     356           0 :     static int call_callbackUnknownEncoding(void *encodingHandlerData,
     357             :                                               const XML_Char *name,
     358             :                                             XML_Encoding *info)
     359             :     {
     360           0 :         return SaxExpatParser_Impl::callbackUnknownEncoding(encodingHandlerData,name,info);
     361             :     }
     362        3065 :     static void call_callbackDefault( void *userData,  const XML_Char *s,  int len)
     363             :     {
     364        3065 :         SaxExpatParser_Impl::callbackDefault(userData,s,len);
     365        3065 :     }
     366           0 :     static void call_callbackStartCDATA( void *userData )
     367             :     {
     368           0 :         SaxExpatParser_Impl::callbackStartCDATA(userData);
     369           0 :     }
     370           0 :     static void call_callbackEndCDATA( void *userData )
     371             :     {
     372           0 :         SaxExpatParser_Impl::callbackEndCDATA(userData);
     373           0 :     }
     374         375 :     static void call_callbackComment( void *userData , const XML_Char *s )
     375             :     {
     376         375 :         SaxExpatParser_Impl::callbackComment(userData,s);
     377         375 :     }
     378             : }
     379             : 
     380             : 
     381             : //---------------------------------------------
     382             : // LocatorImpl
     383             : //---------------------------------------------
     384        3188 : class LocatorImpl :
     385             :     public WeakImplHelper2< XLocator, com::sun::star::io::XSeekable >
     386             :     // should use a different interface for stream positions!
     387             : {
     388             : public:
     389        1594 :     LocatorImpl( SaxExpatParser_Impl *p )
     390        1594 :     {
     391        1594 :         m_pParser    = p;
     392        1594 :     }
     393             : 
     394             : public: //XLocator
     395          43 :     virtual sal_Int32 SAL_CALL getColumnNumber(void) throw ()
     396             :     {
     397          43 :         return XML_GetCurrentColumnNumber( m_pParser->getEntity().pParser );
     398             :     }
     399          44 :     virtual sal_Int32 SAL_CALL getLineNumber(void) throw ()
     400             :     {
     401          44 :         return XML_GetCurrentLineNumber( m_pParser->getEntity().pParser );
     402             :     }
     403          43 :     virtual OUString SAL_CALL getPublicId(void) throw ()
     404             :     {
     405          43 :         return m_pParser->getEntity().structSource.sPublicId;
     406             :     }
     407          44 :     virtual OUString SAL_CALL getSystemId(void) throw ()
     408             :     {
     409          44 :         return m_pParser->getEntity().structSource.sSystemId;
     410             :     }
     411             : 
     412             :     // XSeekable (only for getPosition)
     413             : 
     414           0 :     virtual void SAL_CALL seek( sal_Int64 ) throw()
     415             :     {
     416           0 :     }
     417         100 :     virtual sal_Int64 SAL_CALL getPosition() throw()
     418             :     {
     419         100 :         return XML_GetCurrentByteIndex( m_pParser->getEntity().pParser );
     420             :     }
     421           0 :     virtual ::sal_Int64 SAL_CALL getLength() throw()
     422             :     {
     423           0 :         return 0;
     424             :     }
     425             : 
     426             : private:
     427             : 
     428             :     SaxExpatParser_Impl *m_pParser;
     429             : };
     430             : 
     431             : 
     432             : 
     433             : 
     434        1594 : SaxExpatParser::SaxExpatParser(  )
     435             : {
     436        1594 :     m_pImpl = new SaxExpatParser_Impl;
     437             : 
     438        1594 :     LocatorImpl *pLoc = new LocatorImpl( m_pImpl );
     439        1594 :     m_pImpl->rDocumentLocator = Reference< XLocator > ( pLoc );
     440             : 
     441             :     // performance-Improvment. Reference is needed when calling the startTag callback.
     442             :     // Handing out the same object with every call is allowed (see sax-specification)
     443        1594 :     m_pImpl->pAttrList = new AttributeList;
     444        1594 :     m_pImpl->rAttrList = Reference< XAttributeList > ( m_pImpl->pAttrList );
     445             : 
     446        1594 :     m_pImpl->bExceptionWasThrown = false;
     447        1594 :     m_pImpl->bRTExceptionWasThrown = false;
     448        1594 : }
     449             : 
     450        4782 : SaxExpatParser::~SaxExpatParser()
     451             : {
     452        1594 :     delete m_pImpl;
     453        3188 : }
     454             : 
     455             : 
     456             : /***************
     457             : *
     458             : * parseStream does Parser-startup initializations. The SaxExpatParser_Impl::parse() method does
     459             : * the file-specific initialization work. (During a parser run, external files may be opened)
     460             : *
     461             : ****************/
     462         970 : void SaxExpatParser::parseStream(   const InputSource& structSource)
     463             :     throw (SAXException,
     464             :            IOException,
     465             :            RuntimeException)
     466             : {
     467             :     // Only one text at one time
     468         970 :     MutexGuard guard( m_pImpl->aMutex );
     469             : 
     470             : 
     471         970 :     struct Entity entity;
     472         970 :     entity.structSource = structSource;
     473             : 
     474         970 :     if( ! entity.structSource.aInputStream.is() )
     475             :     {
     476             :         throw SAXException( OUString("No input source") ,
     477          14 :                             Reference< XInterface > () , Any() );
     478             :     }
     479             : 
     480         956 :     entity.converter.setInputStream( entity.structSource.aInputStream );
     481         956 :     if( !entity.structSource.sEncoding.isEmpty() )
     482             :     {
     483             :         entity.converter.setEncoding(
     484           0 :             OUStringToOString( entity.structSource.sEncoding , RTL_TEXTENCODING_ASCII_US ) );
     485             :     }
     486             : 
     487             :     // create parser with proper encoding
     488         956 :     entity.pParser = XML_ParserCreate( 0 );
     489         956 :     if( ! entity.pParser )
     490             :     {
     491             :         throw SAXException( OUString("Couldn't create parser") ,
     492           0 :                             Reference< XInterface > (), Any() );
     493             :     }
     494             : 
     495             :     // set all necessary C-Callbacks
     496         956 :     XML_SetUserData( entity.pParser , m_pImpl );
     497             :     XML_SetElementHandler(  entity.pParser ,
     498             :                             call_callbackStartElement ,
     499         956 :                             call_callbackEndElement );
     500         956 :     XML_SetCharacterDataHandler( entity.pParser , call_callbackCharacters );
     501             :     XML_SetProcessingInstructionHandler(entity.pParser ,
     502         956 :                                         call_callbackProcessingInstruction );
     503         956 :     XML_SetEntityDeclHandler(entity.pParser, call_callbackEntityDecl);
     504         956 :     XML_SetNotationDeclHandler( entity.pParser, call_callbackNotationDecl );
     505             :     XML_SetExternalEntityRefHandler(    entity.pParser,
     506         956 :                                         call_callbackExternalEntityRef);
     507         956 :     XML_SetUnknownEncodingHandler( entity.pParser,  call_callbackUnknownEncoding ,0);
     508             : 
     509         956 :     if( m_pImpl->rExtendedDocumentHandler.is() ) {
     510             : 
     511             :         // These handlers just delegate calls to the ExtendedHandler. If no extended handler is
     512             :         // given, these callbacks can be ignored
     513         396 :         XML_SetDefaultHandlerExpand( entity.pParser, call_callbackDefault );
     514         396 :         XML_SetCommentHandler( entity.pParser, call_callbackComment );
     515             :         XML_SetCdataSectionHandler(     entity.pParser ,
     516             :                                         call_callbackStartCDATA ,
     517         396 :                                          call_callbackEndCDATA );
     518             :     }
     519             : 
     520             : 
     521         956 :     m_pImpl->exception = SAXParseException();
     522         956 :     m_pImpl->pushEntity( entity );
     523             :     try
     524             :     {
     525             :         // start the document
     526         956 :         if( m_pImpl->rDocumentHandler.is() ) {
     527         956 :             m_pImpl->rDocumentHandler->setDocumentLocator( m_pImpl->rDocumentLocator );
     528         956 :             m_pImpl->rDocumentHandler->startDocument();
     529             :         }
     530             : 
     531         956 :         m_pImpl->parse();
     532             : 
     533             :         // finish document
     534         954 :         if( m_pImpl->rDocumentHandler.is() ) {
     535         954 :             m_pImpl->rDocumentHandler->endDocument();
     536             :         }
     537             :     }
     538             : //      catch( SAXParseException &e )
     539             : //  {
     540             : //      m_pImpl->popEntity();
     541             : //          XML_ParserFree( entity.pParser );
     542             : //        Any aAny;
     543             : //        aAny <<= e;
     544             : //          throw SAXException( e.Message, e.Context, aAny );
     545             : //      }
     546           2 :     catch( SAXException & )
     547             :     {
     548           1 :         m_pImpl->popEntity();
     549           1 :         XML_ParserFree( entity.pParser );
     550           1 :           throw;
     551             :     }
     552           2 :     catch( IOException & )
     553             :     {
     554           1 :         m_pImpl->popEntity();
     555           1 :         XML_ParserFree( entity.pParser );
     556           1 :         throw;
     557             :     }
     558           0 :     catch( RuntimeException & )
     559             :     {
     560           0 :         m_pImpl->popEntity();
     561           0 :         XML_ParserFree( entity.pParser );
     562           0 :         throw;
     563             :     }
     564             : 
     565         954 :     m_pImpl->popEntity();
     566         970 :     XML_ParserFree( entity.pParser );
     567         954 : }
     568             : 
     569        1618 : void SaxExpatParser::setDocumentHandler(const Reference< XDocumentHandler > & xHandler)
     570             :     throw (RuntimeException)
     571             : {
     572        1618 :     m_pImpl->rDocumentHandler = xHandler;
     573             :     m_pImpl->rExtendedDocumentHandler =
     574        1618 :         Reference< XExtendedDocumentHandler >( xHandler , UNO_QUERY );
     575        1618 : }
     576             : 
     577           0 : void SaxExpatParser::setErrorHandler(const Reference< XErrorHandler > & xHandler)
     578             :     throw (RuntimeException)
     579             : {
     580           0 :     m_pImpl->rErrorHandler = xHandler;
     581           0 : }
     582             : 
     583           0 : void SaxExpatParser::setDTDHandler(const Reference< XDTDHandler > & xHandler)
     584             :     throw (RuntimeException)
     585             : {
     586           0 :     m_pImpl->rDTDHandler = xHandler;
     587           0 : }
     588             : 
     589         220 : void SaxExpatParser::setEntityResolver(const Reference < XEntityResolver > & xResolver)
     590             :     throw (RuntimeException)
     591             : {
     592         220 :     m_pImpl->rEntityResolver = xResolver;
     593         220 : }
     594             : 
     595             : 
     596           0 : void SaxExpatParser::setLocale( const Locale & locale ) throw (RuntimeException)
     597             : {
     598           0 :     m_pImpl->locale = locale;
     599           0 : }
     600             : 
     601             : // XServiceInfo
     602           0 : OUString SaxExpatParser::getImplementationName() throw ()
     603             : {
     604           0 :     return OUString( IMPLEMENTATION_NAME );
     605             : }
     606             : 
     607             : // XServiceInfo
     608           0 : sal_Bool SaxExpatParser::supportsService(const OUString& ServiceName) throw ()
     609             : {
     610           0 :     Sequence< OUString > aSNL = getSupportedServiceNames();
     611           0 :     const OUString * pArray = aSNL.getConstArray();
     612             : 
     613           0 :     for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
     614           0 :         if( pArray[i] == ServiceName )
     615           0 :             return sal_True;
     616             : 
     617           0 :     return sal_False;
     618             : }
     619             : 
     620             : // XServiceInfo
     621           0 : Sequence< OUString > SaxExpatParser::getSupportedServiceNames(void) throw ()
     622             : {
     623             : 
     624           0 :     Sequence<OUString> seq(1);
     625           0 :     seq.getArray()[0] = OUString( SERVICE_NAME );
     626           0 :     return seq;
     627             : }
     628             : 
     629             : 
     630             : /*---------------------------------------
     631             : *
     632             : * Helper functions and classes
     633             : *
     634             : *
     635             : *-------------------------------------------*/
     636           1 : OUString getErrorMessage( XML_Error xmlE, OUString sSystemId , sal_Int32 nLine )
     637             : {
     638           1 :     OUString Message;
     639           1 :     if( XML_ERROR_NONE == xmlE ) {
     640           0 :         Message = OUString("No");
     641             :     }
     642           1 :     else if( XML_ERROR_NO_MEMORY == xmlE ) {
     643           0 :         Message = OUString("no memory");
     644             :     }
     645           1 :     else if( XML_ERROR_SYNTAX == xmlE ) {
     646           0 :         Message = OUString("syntax");
     647             :     }
     648           1 :     else if( XML_ERROR_NO_ELEMENTS == xmlE ) {
     649           0 :         Message = OUString("no elements");
     650             :     }
     651           1 :     else if( XML_ERROR_INVALID_TOKEN == xmlE ) {
     652           1 :         Message = OUString("invalid token");
     653             :     }
     654           0 :     else if( XML_ERROR_UNCLOSED_TOKEN == xmlE ) {
     655           0 :         Message = OUString("unclosed token");
     656             :     }
     657           0 :     else if( XML_ERROR_PARTIAL_CHAR == xmlE ) {
     658           0 :         Message = OUString("partial char");
     659             :     }
     660           0 :     else if( XML_ERROR_TAG_MISMATCH == xmlE ) {
     661           0 :         Message = OUString("tag mismatch");
     662             :     }
     663           0 :     else if( XML_ERROR_DUPLICATE_ATTRIBUTE == xmlE ) {
     664           0 :         Message = OUString("duplicate attribute");
     665             :     }
     666           0 :     else if( XML_ERROR_JUNK_AFTER_DOC_ELEMENT == xmlE ) {
     667           0 :         Message = OUString("junk after doc element");
     668             :     }
     669           0 :     else if( XML_ERROR_PARAM_ENTITY_REF == xmlE ) {
     670           0 :         Message = OUString("parameter entity reference");
     671             :     }
     672           0 :     else if( XML_ERROR_UNDEFINED_ENTITY == xmlE ) {
     673           0 :         Message = OUString("undefined entity");
     674             :     }
     675           0 :     else if( XML_ERROR_RECURSIVE_ENTITY_REF == xmlE ) {
     676           0 :         Message = OUString("recursive entity reference");
     677             :     }
     678           0 :     else if( XML_ERROR_ASYNC_ENTITY == xmlE ) {
     679           0 :         Message = OUString("async entity");
     680             :     }
     681           0 :     else if( XML_ERROR_BAD_CHAR_REF == xmlE ) {
     682           0 :         Message = OUString("bad char reference");
     683             :     }
     684           0 :     else if( XML_ERROR_BINARY_ENTITY_REF == xmlE ) {
     685           0 :         Message = OUString("binary entity reference");
     686             :     }
     687           0 :     else if( XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF == xmlE ) {
     688           0 :         Message = OUString("attribute external entity reference");
     689             :     }
     690           0 :     else if( XML_ERROR_MISPLACED_XML_PI == xmlE ) {
     691           0 :         Message = OUString("misplaced xml processing instruction");
     692             :     }
     693           0 :     else if( XML_ERROR_UNKNOWN_ENCODING == xmlE ) {
     694           0 :         Message = OUString("unknown encoding");
     695             :     }
     696           0 :     else if( XML_ERROR_INCORRECT_ENCODING == xmlE ) {
     697           0 :         Message = OUString("incorrect encoding");
     698             :     }
     699           0 :     else if( XML_ERROR_UNCLOSED_CDATA_SECTION == xmlE ) {
     700           0 :         Message = OUString("unclosed cdata section");
     701             :     }
     702           0 :     else if( XML_ERROR_EXTERNAL_ENTITY_HANDLING == xmlE ) {
     703           0 :         Message = OUString("external entity reference");
     704             :     }
     705           0 :     else if( XML_ERROR_NOT_STANDALONE == xmlE ) {
     706           0 :         Message = OUString("not standalone");
     707             :     }
     708             : 
     709           1 :     OUString str("[");
     710           1 :     str += sSystemId;
     711           1 :     str += OUString(" line ");
     712           1 :     str += OUString::valueOf( nLine );
     713           1 :     str += OUString("]: ");
     714           1 :     str += Message;
     715           1 :     str += OUString("error");
     716             : 
     717           1 :     return str;
     718             : }
     719             : 
     720             : 
     721             : // starts parsing with actual parser !
     722         956 : void SaxExpatParser_Impl::parse( )
     723             : {
     724         956 :     const int nBufSize = 16*1024;
     725             : 
     726         956 :     int nRead   = nBufSize;
     727         956 :     Sequence< sal_Int8 > seqOut(nBufSize);
     728             : 
     729        2982 :     while( nRead ) {
     730        2026 :         nRead = getEntity().converter.readAndConvert( seqOut , nBufSize );
     731             : 
     732        2025 :         if( ! nRead ) {
     733         954 :             XML_Parse( getEntity().pParser ,
     734         954 :                                    ( const char * ) seqOut.getArray() ,
     735             :                                    0 ,
     736         954 :                                    1 );
     737         954 :             break;
     738             :         }
     739             : 
     740        1071 :         sal_Bool bContinue = ( XML_Parse( getEntity().pParser ,
     741        1071 :                                                 (const char *) seqOut.getArray(),
     742             :                                                 nRead,
     743        1071 :                                                 0 ) != XML_STATUS_ERROR );
     744             : 
     745        1071 :         if( ! bContinue || this->bExceptionWasThrown ) {
     746             : 
     747           1 :             if ( this->bRTExceptionWasThrown )
     748           0 :                 throw rtexception;
     749             : 
     750             :             // Error during parsing !
     751           1 :             XML_Error xmlE = XML_GetErrorCode( getEntity().pParser );
     752           1 :             OUString sSystemId = rDocumentLocator->getSystemId();
     753           1 :             sal_Int32 nLine = rDocumentLocator->getLineNumber();
     754             : 
     755             :             SAXParseException aExcept(
     756             :                 getErrorMessage(xmlE , sSystemId, nLine) ,
     757             :                 Reference< XInterface >(),
     758           1 :                 Any( &exception , getCppuType( &exception) ),
     759           1 :                 rDocumentLocator->getPublicId(),
     760           1 :                 rDocumentLocator->getSystemId(),
     761           1 :                 rDocumentLocator->getLineNumber(),
     762           1 :                 rDocumentLocator->getColumnNumber()
     763           5 :                 );
     764             : 
     765           1 :             if( rErrorHandler.is() ) {
     766             : 
     767             :                 // error handler is set, so the handler may throw the exception
     768           0 :                 Any a;
     769           0 :                 a <<= aExcept;
     770           0 :                 rErrorHandler->fatalError( a );
     771             :             }
     772             : 
     773             :             // Error handler has not thrown an exception, but parsing cannot go on,
     774             :             // so an exception MUST be thrown.
     775           1 :             throw aExcept;
     776             :         } // if( ! bContinue )
     777         956 :     } // while
     778         954 : }
     779             : 
     780             : //------------------------------------------
     781             : //
     782             : // The C-Callbacks
     783             : //
     784             : //-----------------------------------------
     785       70250 : void SaxExpatParser_Impl::callbackStartElement( void *pvThis ,
     786             :                                                 const XML_Char *pwName ,
     787             :                                                 const XML_Char **awAttributes )
     788             : {
     789       70250 :     SaxExpatParser_Impl *pImpl = ((SaxExpatParser_Impl*)pvThis);
     790             : 
     791       70250 :     if( pImpl->rDocumentHandler.is() ) {
     792             : 
     793       70250 :         int i = 0;
     794       70250 :         pImpl->pAttrList->clear();
     795             : 
     796      236533 :         while( awAttributes[i] ) {
     797             :             OSL_ASSERT( awAttributes[i+1] );
     798             :             pImpl->pAttrList->addAttribute(
     799      192066 :                 XML_CHAR_TO_OUSTRING( awAttributes[i] ) ,
     800             :                 pImpl->sCDATA,  // expat doesn't know types
     801      288099 :                 XML_CHAR_TO_OUSTRING( awAttributes[i+1] ) );
     802       96033 :             i +=2;
     803             :         }
     804             : 
     805       70250 :         CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS(
     806             :             pImpl ,
     807             :             rDocumentHandler->startElement( XML_CHAR_TO_OUSTRING( pwName ) ,
     808             :                                             pImpl->rAttrList ) );
     809             :     }
     810       70250 : }
     811             : 
     812       70250 : void SaxExpatParser_Impl::callbackEndElement( void *pvThis , const XML_Char *pwName  )
     813             : {
     814       70250 :     SaxExpatParser_Impl  *pImpl = ((SaxExpatParser_Impl*)pvThis);
     815             : 
     816       70250 :     if( pImpl->rDocumentHandler.is() ) {
     817       70250 :         CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS( pImpl,
     818             :                 rDocumentHandler->endElement( XML_CHAR_TO_OUSTRING( pwName ) ) );
     819             :     }
     820       70250 : }
     821             : 
     822             : 
     823      163438 : void SaxExpatParser_Impl::callbackCharacters( void *pvThis , const XML_Char *s , int nLen )
     824             : {
     825      163438 :     SaxExpatParser_Impl *pImpl = ((SaxExpatParser_Impl*)pvThis);
     826             : 
     827      163438 :     if( pImpl->rDocumentHandler.is() ) {
     828      163438 :         CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS( pImpl ,
     829             :                 rDocumentHandler->characters( XML_CHAR_N_TO_USTRING(s,nLen) ) );
     830             :     }
     831      163438 : }
     832             : 
     833           0 : void SaxExpatParser_Impl::callbackProcessingInstruction(    void *pvThis,
     834             :                                                     const XML_Char *sTarget ,
     835             :                                                     const XML_Char *sData )
     836             : {
     837           0 :     SaxExpatParser_Impl *pImpl = ((SaxExpatParser_Impl*)pvThis);
     838           0 :     if( pImpl->rDocumentHandler.is() ) {
     839           0 :         CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS(
     840             :                     pImpl ,
     841             :                     rDocumentHandler->processingInstruction( XML_CHAR_TO_OUSTRING( sTarget ),
     842             :                     XML_CHAR_TO_OUSTRING( sData ) ) );
     843             :     }
     844           0 : }
     845             : 
     846             : 
     847           0 : void SaxExpatParser_Impl::callbackEntityDecl(
     848             :     void *pvThis, const XML_Char *entityName,
     849             :     SAL_UNUSED_PARAMETER int /*is_parameter_entity*/,
     850             :     const XML_Char *value, SAL_UNUSED_PARAMETER int /*value_length*/,
     851             :     SAL_UNUSED_PARAMETER const XML_Char * /*base*/, const XML_Char *systemId,
     852             :     const XML_Char *publicId, const XML_Char *notationName)
     853             : {
     854           0 :     SaxExpatParser_Impl *pImpl = ((SaxExpatParser_Impl*)pvThis);
     855           0 :     if (value) { // value != 0 means internal entity
     856             :         OSL_TRACE("SaxExpatParser: internal entity declaration, stopping");
     857           0 :         XML_StopParser(pImpl->getEntity().pParser, XML_FALSE);
     858             :         pImpl->exception = SAXParseException(
     859             :             ::rtl::OUString( "SaxExpatParser: internal entity declaration, stopping"),
     860             :             0, Any(),
     861           0 :             pImpl->rDocumentLocator->getPublicId(),
     862           0 :             pImpl->rDocumentLocator->getSystemId(),
     863           0 :             pImpl->rDocumentLocator->getLineNumber(),
     864           0 :             pImpl->rDocumentLocator->getColumnNumber() );
     865           0 :         pImpl->bExceptionWasThrown = true;
     866             :     } else {
     867           0 :         if( pImpl->rDTDHandler.is() ) {
     868           0 :             CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS(
     869             :                 pImpl ,
     870             :                 rDTDHandler->unparsedEntityDecl(
     871             :                     XML_CHAR_TO_OUSTRING( entityName ),
     872             :                     XML_CHAR_TO_OUSTRING( publicId ) ,
     873             :                     XML_CHAR_TO_OUSTRING( systemId ) ,
     874             :                     XML_CHAR_TO_OUSTRING( notationName ) ) );
     875             :         }
     876             :     }
     877           0 : }
     878             : 
     879           0 : void SaxExpatParser_Impl::callbackNotationDecl(
     880             :     void *pvThis, const XML_Char *notationName,
     881             :     SAL_UNUSED_PARAMETER const XML_Char * /*base*/, const XML_Char *systemId,
     882             :     const XML_Char *publicId)
     883             : {
     884           0 :     SaxExpatParser_Impl *pImpl = ((SaxExpatParser_Impl*)pvThis);
     885           0 :     if( pImpl->rDTDHandler.is() ) {
     886           0 :         CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS( pImpl,
     887             :                 rDTDHandler->notationDecl(  XML_CHAR_TO_OUSTRING( notationName ) ,
     888             :                                             XML_CHAR_TO_OUSTRING( publicId ) ,
     889             :                                             XML_CHAR_TO_OUSTRING( systemId ) ) );
     890             :     }
     891             : 
     892           0 : }
     893             : 
     894             : 
     895             : 
     896           0 : int SaxExpatParser_Impl::callbackExternalEntityRef(
     897             :     XML_Parser parser, const XML_Char *context,
     898             :     SAL_UNUSED_PARAMETER const XML_Char * /*base*/, const XML_Char *systemId,
     899             :     const XML_Char *publicId)
     900             : {
     901           0 :     sal_Bool bOK = sal_True;
     902           0 :     InputSource source;
     903           0 :     SaxExpatParser_Impl *pImpl = ((SaxExpatParser_Impl*)XML_GetUserData( parser ));
     904             : 
     905           0 :     struct Entity entity;
     906             : 
     907           0 :     if( pImpl->rEntityResolver.is() ) {
     908             :         try
     909             :         {
     910           0 :             entity.structSource = pImpl->rEntityResolver->resolveEntity(
     911           0 :                 XML_CHAR_TO_OUSTRING( publicId ) ,
     912           0 :                 XML_CHAR_TO_OUSTRING( systemId ) );
     913             :         }
     914           0 :         catch( const SAXParseException & e )
     915             :         {
     916           0 :             pImpl->exception = e;
     917           0 :             bOK = sal_False;
     918             :         }
     919           0 :         catch( const SAXException & e )
     920             :         {
     921             :             pImpl->exception = SAXParseException(
     922             :                 e.Message , e.Context , e.WrappedException ,
     923           0 :                 pImpl->rDocumentLocator->getPublicId(),
     924           0 :                 pImpl->rDocumentLocator->getSystemId(),
     925           0 :                 pImpl->rDocumentLocator->getLineNumber(),
     926           0 :                 pImpl->rDocumentLocator->getColumnNumber() );
     927           0 :             bOK = sal_False;
     928             :         }
     929             :     }
     930             : 
     931           0 :     if( entity.structSource.aInputStream.is() ) {
     932           0 :         entity.pParser = XML_ExternalEntityParserCreate( parser , context, 0 );
     933           0 :         if( ! entity.pParser )
     934             :         {
     935           0 :             return sal_False;
     936             :         }
     937             : 
     938           0 :         entity.converter.setInputStream( entity.structSource.aInputStream );
     939           0 :         pImpl->pushEntity( entity );
     940             :         try
     941             :         {
     942           0 :             pImpl->parse();
     943             :         }
     944           0 :         catch( const SAXParseException & e )
     945             :         {
     946           0 :             pImpl->exception = e;
     947           0 :             bOK = sal_False;
     948             :         }
     949           0 :         catch( const IOException &e )
     950             :         {
     951           0 :             pImpl->exception.WrappedException <<= e;
     952           0 :             bOK = sal_False;
     953             :         }
     954           0 :         catch( const RuntimeException &e )
     955             :         {
     956           0 :             pImpl->exception.WrappedException <<=e;
     957           0 :             bOK = sal_False;
     958             :         }
     959             : 
     960           0 :         pImpl->popEntity();
     961             : 
     962           0 :         XML_ParserFree( entity.pParser );
     963             :     }
     964             : 
     965           0 :     return bOK;
     966             : }
     967             : 
     968           0 : int SaxExpatParser_Impl::callbackUnknownEncoding(
     969             :     SAL_UNUSED_PARAMETER void * /*encodingHandlerData*/,
     970             :     SAL_UNUSED_PARAMETER const XML_Char * /*name*/,
     971             :     SAL_UNUSED_PARAMETER XML_Encoding * /*info*/)
     972             : {
     973           0 :     return 0;
     974             : }
     975             : 
     976        3065 : void SaxExpatParser_Impl::callbackDefault( void *pvThis,  const XML_Char *s,  int len)
     977             : {
     978        3065 :     SaxExpatParser_Impl *pImpl = ((SaxExpatParser_Impl*)pvThis);
     979             : 
     980        3065 :     CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS(  pImpl,
     981             :                 rExtendedDocumentHandler->unknown( XML_CHAR_N_TO_USTRING( s ,len) ) );
     982        3065 : }
     983             : 
     984         375 : void SaxExpatParser_Impl::callbackComment( void *pvThis , const XML_Char *s )
     985             : {
     986         375 :     SaxExpatParser_Impl *pImpl = ((SaxExpatParser_Impl*)pvThis);
     987         375 :     CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS( pImpl,
     988             :                 rExtendedDocumentHandler->comment( XML_CHAR_TO_OUSTRING( s ) ) );
     989         375 : }
     990             : 
     991           0 : void SaxExpatParser_Impl::callbackStartCDATA( void *pvThis )
     992             : {
     993           0 :     SaxExpatParser_Impl *pImpl = ((SaxExpatParser_Impl*)pvThis);
     994             : 
     995           0 :     CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS( pImpl, rExtendedDocumentHandler->startCDATA() );
     996           0 : }
     997             : 
     998             : 
     999           0 : void SaxExpatParser_Impl::callErrorHandler( SaxExpatParser_Impl *pImpl ,
    1000             :                                             const SAXParseException & e )
    1001             : {
    1002             :     try
    1003             :     {
    1004           0 :         if( pImpl->rErrorHandler.is() ) {
    1005           0 :             Any a;
    1006           0 :             a <<= e;
    1007           0 :             pImpl->rErrorHandler->error( a );
    1008             :         }
    1009             :         else {
    1010           0 :             pImpl->exception = e;
    1011           0 :             pImpl->bExceptionWasThrown = true;
    1012             :         }
    1013             :     }
    1014           0 :     catch( const SAXParseException & ex ) {
    1015           0 :         pImpl->exception = ex;
    1016           0 :         pImpl->bExceptionWasThrown = true;
    1017             :     }
    1018           0 :     catch( const SAXException & ex ) {
    1019             :         pImpl->exception = SAXParseException(
    1020             :                                     ex.Message,
    1021             :                                     ex.Context,
    1022             :                                     ex.WrappedException,
    1023           0 :                                     pImpl->rDocumentLocator->getPublicId(),
    1024           0 :                                     pImpl->rDocumentLocator->getSystemId(),
    1025           0 :                                     pImpl->rDocumentLocator->getLineNumber(),
    1026           0 :                                     pImpl->rDocumentLocator->getColumnNumber()
    1027           0 :                              );
    1028           0 :         pImpl->bExceptionWasThrown = true;
    1029             :     }
    1030           0 : }
    1031             : 
    1032           0 : void SaxExpatParser_Impl::callbackEndCDATA( void *pvThis )
    1033             : {
    1034           0 :     SaxExpatParser_Impl *pImpl = ((SaxExpatParser_Impl*)pvThis);
    1035             : 
    1036           0 :     CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS(pImpl,rExtendedDocumentHandler->endCDATA() );
    1037           0 : }
    1038             : 
    1039             : }
    1040             : using namespace sax_expatwrap;
    1041             : 
    1042             : extern "C"
    1043             : {
    1044             : 
    1045         241 : SAL_DLLPUBLIC_EXPORT void * SAL_CALL expwrap_component_getFactory(
    1046             :     const sal_Char * pImplName, void * pServiceManager,
    1047             :     SAL_UNUSED_PARAMETER void * /*pRegistryKey*/ )
    1048             : {
    1049         241 :     void * pRet = 0;
    1050             : 
    1051         241 :     if (pServiceManager )
    1052             :     {
    1053         241 :         Reference< XSingleServiceFactory > xRet;
    1054             :         Reference< XMultiServiceFactory > xSMgr =
    1055         241 :             reinterpret_cast< XMultiServiceFactory * > ( pServiceManager );
    1056             : 
    1057         241 :         OUString aImplementationName = OUString::createFromAscii( pImplName );
    1058             : 
    1059         241 :         if ( aImplementationName == IMPLEMENTATION_NAME  )
    1060             :         {
    1061             :             xRet = createSingleFactory( xSMgr, aImplementationName,
    1062             :                                         SaxExpatParser_CreateInstance,
    1063         234 :                                         SaxExpatParser::getSupportedServiceNames_Static() );
    1064             :         }
    1065           7 :         else if ( aImplementationName == SaxWriter_getImplementationName() )
    1066             :         {
    1067             :             xRet = createSingleFactory( xSMgr, aImplementationName,
    1068             :                                         SaxWriter_CreateInstance,
    1069           7 :                                         SaxWriter_getSupportedServiceNames() );
    1070             :         }
    1071             : 
    1072         241 :         if (xRet.is())
    1073             :         {
    1074         241 :             xRet->acquire();
    1075         241 :             pRet = xRet.get();
    1076         241 :         }
    1077             :     }
    1078             : 
    1079         241 :     return pRet;
    1080             : }
    1081             : 
    1082             : 
    1083             : }
    1084             : 
    1085             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10