LCOV - code coverage report
Current view: top level - sax/source/tools - fshelper.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 77 80 96.2 %
Date: 2014-11-03 Functions: 20 21 95.2 %
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/XFastTokenHandler.hpp>
      23             : #include <rtl/ustrbuf.hxx>
      24             : 
      25             : using namespace ::com::sun::star;
      26             : using namespace ::com::sun::star::uno;
      27             : 
      28             : namespace sax_fastparser {
      29             : 
      30        7446 : FastSerializerHelper::FastSerializerHelper(const Reference< io::XOutputStream >& xOutputStream, bool bWriteHeader ) :
      31        7446 :     mpSerializer(new FastSaxSerializer(xOutputStream))
      32             : {
      33        7446 :     if( bWriteHeader )
      34        7446 :         mpSerializer->startDocument();
      35        7446 : }
      36             : 
      37        7446 : FastSerializerHelper::~FastSerializerHelper()
      38             : {
      39        7446 :     mpSerializer->endDocument();
      40        7446 :     delete mpSerializer;
      41        7446 : }
      42             : 
      43      259944 : void FastSerializerHelper::startElementInternal(sal_Int32 elementTokenId, ...)
      44             : {
      45             :     va_list args;
      46      259944 :     va_start( args, elementTokenId );
      47      259944 :     TokenValueList& rAttrList = mpSerializer->getTokenValueList();
      48             : 
      49             :     while (true)
      50             :     {
      51      370732 :         sal_Int32 nName = va_arg(args, sal_Int32);
      52      370732 :         if (nName == FSEND_internal)
      53      259944 :             break;
      54      110788 :         const char* pValue = va_arg(args, const char*);
      55      110788 :         if (pValue)
      56       92104 :             rAttrList.push_back(TokenValue(nName, pValue));
      57             :     }
      58             : 
      59      259944 :     mpSerializer->startFastElement(elementTokenId);
      60      370732 :     va_end( args );
      61      259944 : }
      62             : 
      63      325460 : void FastSerializerHelper::singleElementInternal(sal_Int32 elementTokenId, ...)
      64             : {
      65             :     va_list args;
      66      325460 :     va_start( args, elementTokenId );
      67      325460 :     TokenValueList& rAttrList = mpSerializer->getTokenValueList();
      68             : 
      69             :     while (true)
      70             :     {
      71      616636 :         sal_Int32 nName = va_arg(args, sal_Int32);
      72      616636 :         if (nName == FSEND_internal)
      73      325460 :             break;
      74      291176 :         const char* pValue = va_arg(args, const char*);
      75      291176 :         if  (pValue)
      76      290358 :             rAttrList.push_back(TokenValue(nName, pValue));
      77             :     }
      78             : 
      79      325460 :     mpSerializer->singleFastElement(elementTokenId);
      80      616636 :     va_end( args );
      81      325460 : }
      82             : 
      83      295900 : void FastSerializerHelper::endElement(sal_Int32 elementTokenId)
      84             : {
      85      295900 :     mpSerializer->endFastElement(elementTokenId);
      86      295900 : }
      87             : 
      88       35956 : void FastSerializerHelper::startElement(sal_Int32 elementTokenId, XFastAttributeListRef xAttrList)
      89             : {
      90       35956 :     FastAttributeList* pAttrList = dynamic_cast< FastAttributeList* >(xAttrList.get());
      91             :     assert(pAttrList);
      92       35956 :     mpSerializer->startFastElement(elementTokenId, pAttrList);
      93       35956 : }
      94             : 
      95      221966 : void FastSerializerHelper::singleElement(sal_Int32 elementTokenId, XFastAttributeListRef xAttrList)
      96             : {
      97      221966 :     FastAttributeList* pAttrList = dynamic_cast< FastAttributeList* >(xAttrList.get());
      98             :     assert(pAttrList);
      99      221966 :     mpSerializer->singleFastElement(elementTokenId, pAttrList);
     100      221966 : }
     101             : 
     102        6590 : FastSerializerHelper* FastSerializerHelper::write(const char* value)
     103             : {
     104        6590 :     mpSerializer->write(value, -1, false);
     105        6590 :     return this;
     106             : }
     107             : 
     108           0 : FastSerializerHelper* FastSerializerHelper::write(const OUString& value)
     109             : {
     110           0 :     mpSerializer->write(value);
     111           0 :     return this;
     112             : }
     113             : 
     114        7244 : FastSerializerHelper* FastSerializerHelper::write(sal_Int32 value)
     115             : {
     116        7244 :     mpSerializer->write(OString::number(value));
     117        7244 :     return this;
     118             : }
     119             : 
     120        1322 : FastSerializerHelper* FastSerializerHelper::write(sal_Int64 value)
     121             : {
     122        1322 :     mpSerializer->write(OString::number(value));
     123        1322 :     return this;
     124             : }
     125             : 
     126        2352 : FastSerializerHelper* FastSerializerHelper::write(double value)
     127             : {
     128        2352 :     mpSerializer->write(value);
     129        2352 :     return this;
     130             : }
     131             : 
     132         204 : FastSerializerHelper* FastSerializerHelper::writeEscaped(const char* value)
     133             : {
     134         204 :     mpSerializer->write(value, -1, true);
     135         204 :     return this;
     136             : }
     137             : 
     138       27118 : FastSerializerHelper* FastSerializerHelper::writeEscaped(const OUString& value)
     139             : {
     140       27118 :     if (!value.isEmpty())
     141       27000 :         mpSerializer->write(value, true);
     142       27118 :     return this;
     143             : }
     144             : 
     145        1498 : FastSerializerHelper* FastSerializerHelper::writeId(sal_Int32 tokenId)
     146             : {
     147        1498 :     mpSerializer->writeId(tokenId);
     148        1498 :     return this;
     149             : }
     150             : 
     151        6812 : ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > FastSerializerHelper::getOutputStream()
     152             : {
     153        6812 :     return mpSerializer->getOutputStream();
     154             : }
     155             : 
     156      213072 : void FastSerializerHelper::mark( const Sequence< sal_Int32 >& aOrder )
     157             : {
     158      213072 :     mpSerializer->mark( aOrder );
     159      213072 : }
     160             : 
     161      213072 : void FastSerializerHelper::mergeTopMarks( MergeMarksEnum eMergeType )
     162             : {
     163      213072 :     mpSerializer->mergeTopMarks( eMergeType );
     164      213072 : }
     165             : 
     166      258712 : FastAttributeList * FastSerializerHelper::createAttrList()
     167             : {
     168      258712 :     return new FastAttributeList( Reference< xml::sax::XFastTokenHandler >() );
     169             : }
     170             : 
     171             : 
     172        3291 : }
     173             : 
     174             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10