LCOV - code coverage report
Current view: top level - sax/source/tools - fshelper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 1 77 1.3 %
Date: 2014-04-14 Functions: 2 21 9.5 %
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             : 
      20             : #include <sax/fshelper.hxx>
      21             : #include "fastserializer.hxx"
      22             : #include <com/sun/star/xml/sax/FastTokenHandler.hpp>
      23             : #include <comphelper/processfactory.hxx>
      24             : #include <rtl/ustrbuf.hxx>
      25             : 
      26             : using namespace ::com::sun::star;
      27             : using namespace ::com::sun::star::uno;
      28             : 
      29             : namespace sax_fastparser {
      30             : 
      31           0 : FastSerializerHelper::FastSerializerHelper(const Reference< io::XOutputStream >& xOutputStream, bool bWriteHeader ) :
      32           0 :     mpSerializer(new FastSaxSerializer())
      33             : {
      34           0 :     Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext(), UNO_SET_THROW );
      35           0 :     mxTokenHandler = css::xml::sax::FastTokenHandler::create(xContext);
      36             : 
      37           0 :     mpSerializer->setFastTokenHandler( mxTokenHandler );
      38           0 :     mpSerializer->setOutputStream( xOutputStream );
      39           0 :     if( bWriteHeader )
      40           0 :         mpSerializer->startDocument();
      41           0 : }
      42             : 
      43           0 : FastSerializerHelper::~FastSerializerHelper()
      44             : {
      45           0 :     mpSerializer->endDocument();
      46           0 :     delete mpSerializer;
      47           0 : }
      48             : 
      49           0 : void FastSerializerHelper::startElementInternal(sal_Int32 elementTokenId, ...)
      50             : {
      51             :     va_list args;
      52           0 :     va_start( args, elementTokenId );
      53           0 :     FastAttributeList* pAttrList = new FastAttributeList( mxTokenHandler );
      54             : 
      55             :     while (true)
      56             :     {
      57           0 :         sal_Int32 nName = va_arg(args, sal_Int32);
      58           0 :         if (nName == FSEND_internal)
      59           0 :             break;
      60           0 :         const char* pValue = va_arg(args, const char*);
      61           0 :         if (pValue)
      62           0 :             pAttrList->add(nName, pValue);
      63             :     }
      64             : 
      65           0 :     const com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> xAttrList(pAttrList);
      66           0 :     mpSerializer->startFastElement(elementTokenId, xAttrList);
      67           0 :     va_end( args );
      68           0 : }
      69             : 
      70           0 : void FastSerializerHelper::singleElementInternal(sal_Int32 elementTokenId, ...)
      71             : {
      72             :     va_list args;
      73           0 :     va_start( args, elementTokenId );
      74           0 :     FastAttributeList* pAttrList = new FastAttributeList( mxTokenHandler );
      75             : 
      76             :     while (true)
      77             :     {
      78           0 :         sal_Int32 nName = va_arg(args, sal_Int32);
      79           0 :         if (nName == FSEND_internal)
      80           0 :             break;
      81           0 :         const char* pValue = va_arg(args, const char*);
      82           0 :         if  (pValue)
      83           0 :             pAttrList->add(nName, pValue);
      84             :     }
      85             : 
      86           0 :     const com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> xAttrList(pAttrList);
      87           0 :     mpSerializer->singleFastElement(elementTokenId, xAttrList);
      88           0 :     va_end( args );
      89           0 : }
      90             : 
      91           0 : void FastSerializerHelper::endElement(sal_Int32 elementTokenId)
      92             : {
      93           0 :     mpSerializer->endFastElement(elementTokenId);
      94           0 : }
      95             : 
      96           0 : void FastSerializerHelper::startElement(sal_Int32 elementTokenId, XFastAttributeListRef xAttrList)
      97             : {
      98           0 :     mpSerializer->startFastElement(elementTokenId, xAttrList);
      99           0 : }
     100             : 
     101             : 
     102           0 : void FastSerializerHelper::singleElement(sal_Int32 elementTokenId, XFastAttributeListRef xAttrList)
     103             : {
     104           0 :     mpSerializer->singleFastElement(elementTokenId, xAttrList);
     105           0 : }
     106             : 
     107           0 : FastSerializerHelper* FastSerializerHelper::write(const char* value)
     108             : {
     109           0 :     return write(OUString::createFromAscii(value));
     110             : }
     111             : 
     112           0 : FastSerializerHelper* FastSerializerHelper::write(const OUString& value)
     113             : {
     114           0 :     mpSerializer->characters(value);
     115           0 :     return this;
     116             : }
     117             : 
     118           0 : FastSerializerHelper* FastSerializerHelper::write(sal_Int32 value)
     119             : {
     120           0 :     return write(OUString::number(value));
     121             : }
     122             : 
     123           0 : FastSerializerHelper* FastSerializerHelper::write(sal_Int64 value)
     124             : {
     125           0 :     return write(OUString::number(value));
     126             : }
     127             : 
     128           0 : FastSerializerHelper* FastSerializerHelper::write(double value)
     129             : {
     130           0 :     return write(OUString::number(value));
     131             : }
     132             : 
     133           0 : FastSerializerHelper* FastSerializerHelper::writeEscaped(const char* value)
     134             : {
     135           0 :     return writeEscaped(OUString::createFromAscii(value));
     136             : }
     137             : 
     138           0 : FastSerializerHelper* FastSerializerHelper::writeEscaped(const OUString& value)
     139             : {
     140           0 :     return write(FastSaxSerializer::escapeXml(value));
     141             : }
     142             : 
     143           0 : FastSerializerHelper* FastSerializerHelper::writeId(sal_Int32 tokenId)
     144             : {
     145           0 :     mpSerializer->writeId(tokenId);
     146           0 :     return this;
     147             : }
     148             : 
     149           0 : ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > FastSerializerHelper::getOutputStream()
     150             : {
     151           0 :     return mpSerializer->getOutputStream();
     152             : }
     153             : 
     154           0 : void FastSerializerHelper::mark( Sequence< sal_Int32 > aOrder )
     155             : {
     156           0 :     mpSerializer->mark( aOrder );
     157           0 : }
     158             : 
     159           0 : void FastSerializerHelper::mergeTopMarks( MergeMarksEnum eMergeType )
     160             : {
     161           0 :     mpSerializer->mergeTopMarks( eMergeType );
     162           0 : }
     163             : 
     164           0 : FastAttributeList * FastSerializerHelper::createAttrList()
     165             : {
     166           0 :     return new FastAttributeList( mxTokenHandler );
     167             : }
     168             : 
     169             : 
     170           3 : }
     171             : 
     172             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10