LCOV - code coverage report
Current view: top level - sax/source/tools - fshelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 62 73 84.9 %
Date: 2012-08-25 Functions: 14 19 73.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 37 78 47.4 %

           Branch data     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 <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                 :        345 : FastSerializerHelper::FastSerializerHelper(const Reference< io::XOutputStream >& xOutputStream, bool bWriteHeader ) :
      32         [ +  - ]:        345 :     mpSerializer(new FastSaxSerializer())
      33                 :            : {
      34 [ +  - ][ +  - ]:        345 :     Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext(), UNO_SET_THROW );
      35 [ +  - ][ +  - ]:        345 :     Reference< lang::XMultiComponentFactory > xFactory( xContext->getServiceManager(), UNO_SET_THROW );
                 [ +  - ]
      36 [ +  - ][ +  - ]:        345 :     mxTokenHandler.set( xFactory->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.sax.FastTokenHandler") ), xContext ), UNO_QUERY_THROW );
         [ +  - ][ +  - ]
      37                 :            : 
      38         [ +  - ]:        345 :     mpSerializer->setFastTokenHandler( mxTokenHandler );
      39         [ +  - ]:        345 :     mpSerializer->setOutputStream( xOutputStream );
      40         [ +  - ]:        345 :     if( bWriteHeader )
      41         [ +  - ]:        345 :         mpSerializer->startDocument();
      42                 :        345 : }
      43                 :            : 
      44                 :        345 : FastSerializerHelper::~FastSerializerHelper()
      45                 :            : {
      46         [ +  - ]:        345 :     mpSerializer->endDocument();
      47 [ +  - ][ +  - ]:        345 :     delete mpSerializer;
      48                 :        345 : }
      49                 :            : 
      50                 :       5178 : void FastSerializerHelper::startElementV(sal_Int32 elementTokenId, va_list args)
      51                 :            : {
      52         [ +  - ]:       5178 :     FastAttributeList* pAttrList = new FastAttributeList( mxTokenHandler );
      53                 :            : 
      54                 :       2571 :     while (true)
      55                 :            :     {
      56                 :       7749 :         sal_Int32 nName = va_arg(args, sal_Int32);
      57         [ +  + ]:       7749 :         if (nName == FSEND)
      58                 :            :             break;
      59                 :       2571 :         const char* pValue = va_arg(args, const char*);
      60         [ +  - ]:       2571 :         if (pValue)
      61         [ +  - ]:       2571 :             pAttrList->add(nName, pValue);
      62                 :            :     }
      63                 :            : 
      64 [ +  - ][ +  - ]:       5178 :     const com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> xAttrList(pAttrList);
      65         [ +  - ]:       5178 :     mpSerializer->startFastElement(elementTokenId, xAttrList);
      66                 :       5178 : }
      67                 :            : 
      68                 :       3474 : void FastSerializerHelper::singleElementV(sal_Int32 elementTokenId, va_list args)
      69                 :            : {
      70         [ +  - ]:       3474 :     FastAttributeList* pAttrList = new FastAttributeList( mxTokenHandler );
      71                 :            : 
      72                 :       3159 :     while (true)
      73                 :            :     {
      74                 :       6633 :         sal_Int32 nName = va_arg(args, sal_Int32);
      75         [ +  + ]:       6633 :         if (nName == FSEND)
      76                 :            :             break;
      77                 :       3159 :         const char* pValue = va_arg(args, const char*);
      78         [ +  - ]:       3159 :         if  (pValue)
      79         [ +  - ]:       3159 :             pAttrList->add(nName, pValue);
      80                 :            :     }
      81                 :            : 
      82 [ +  - ][ +  - ]:       3474 :     const com::sun::star::uno::Reference<com::sun::star::xml::sax::XFastAttributeList> xAttrList(pAttrList);
      83         [ +  - ]:       3474 :     mpSerializer->singleFastElement(elementTokenId, xAttrList);
      84                 :       3474 : }
      85                 :            : 
      86                 :       5238 : void FastSerializerHelper::endElement(sal_Int32 elementTokenId)
      87                 :            : {
      88                 :       5238 :     mpSerializer->endFastElement(elementTokenId);
      89                 :       5238 : }
      90                 :            : 
      91                 :         60 : void FastSerializerHelper::startElementV(sal_Int32 elementTokenId, XFastAttributeListRef xAttrList)
      92                 :            : {
      93                 :         60 :     mpSerializer->startFastElement(elementTokenId, xAttrList);
      94                 :         60 : }
      95                 :            : 
      96                 :            : 
      97                 :       1104 : void FastSerializerHelper::singleElementV(sal_Int32 elementTokenId, XFastAttributeListRef xAttrList)
      98                 :            : {
      99                 :       1104 :     mpSerializer->singleFastElement(elementTokenId, xAttrList);
     100                 :       1104 : }
     101                 :            : 
     102                 :         69 : FastSerializerHelper* FastSerializerHelper::write(const char* value)
     103                 :            : {
     104         [ +  - ]:         69 :     return write(rtl::OUString::createFromAscii(value));
     105                 :            : }
     106                 :            : 
     107                 :       1086 : FastSerializerHelper* FastSerializerHelper::write(const rtl::OUString& value)
     108                 :            : {
     109                 :       1086 :     mpSerializer->characters(value);
     110                 :       1086 :     return this;
     111                 :            : }
     112                 :            : 
     113                 :          0 : FastSerializerHelper* FastSerializerHelper::write(sal_Int32 value)
     114                 :            : {
     115         [ #  # ]:          0 :     return write(::rtl::OUString::valueOf(value));
     116                 :            : }
     117                 :            : 
     118                 :          0 : FastSerializerHelper* FastSerializerHelper::write(sal_Int64 value)
     119                 :            : {
     120         [ #  # ]:          0 :     return write(::rtl::OUString::valueOf(value));
     121                 :            : }
     122                 :            : 
     123                 :          0 : FastSerializerHelper* FastSerializerHelper::write(double value)
     124                 :            : {
     125         [ #  # ]:          0 :     return write(::rtl::OUString::valueOf(value));
     126                 :            : }
     127                 :            : 
     128                 :          0 : FastSerializerHelper* FastSerializerHelper::writeEscaped(const char* value)
     129                 :            : {
     130         [ #  # ]:          0 :     return writeEscaped(::rtl::OUString::createFromAscii(value));
     131                 :            : }
     132                 :            : 
     133                 :        855 : FastSerializerHelper* FastSerializerHelper::writeEscaped(const ::rtl::OUString& value)
     134                 :            : {
     135         [ +  - ]:        855 :     return write(FastSaxSerializer::escapeXml(value));
     136                 :            : }
     137                 :            : 
     138                 :          0 : FastSerializerHelper* FastSerializerHelper::writeId(sal_Int32 tokenId)
     139                 :            : {
     140                 :          0 :     mpSerializer->writeId(tokenId);
     141                 :          0 :     return this;
     142                 :            : }
     143                 :            : 
     144                 :        174 : ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > FastSerializerHelper::getOutputStream()
     145                 :            : {
     146                 :        174 :     return mpSerializer->getOutputStream();
     147                 :            : }
     148                 :            : 
     149                 :       2061 : void FastSerializerHelper::mark( Sequence< sal_Int32 > aOrder )
     150                 :            : {
     151         [ +  - ]:       2061 :     mpSerializer->mark( aOrder );
     152                 :       2061 : }
     153                 :            : 
     154                 :       2061 : void FastSerializerHelper::mergeTopMarks( MergeMarksEnum eMergeType )
     155                 :            : {
     156                 :       2061 :     mpSerializer->mergeTopMarks( eMergeType );
     157                 :       2061 : }
     158                 :            : 
     159                 :       1164 : FastAttributeList * FastSerializerHelper::createAttrList()
     160                 :            : {
     161         [ +  - ]:       1164 :     return new FastAttributeList( mxTokenHandler );
     162                 :            : }
     163                 :            : 
     164                 :            : 
     165                 :            : }
     166                 :            : 
     167                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10