LCOV - code coverage report
Current view: top level - writerfilter/source/ooxml - OOXMLFastDocumentHandler.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 33 38 86.8 %
Date: 2015-06-13 12:38:46 Functions: 13 15 86.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             : 
      20             : #include <iostream>
      21             : #include "OOXMLFastDocumentHandler.hxx"
      22             : #include "OOXMLFastContextHandler.hxx"
      23             : #include "oox/token/tokens.hxx"
      24             : #include "OOXMLFactory.hxx"
      25             : 
      26             : namespace writerfilter {
      27             : namespace ooxml
      28             : {
      29             : using namespace ::com::sun::star;
      30             : using namespace ::std;
      31             : 
      32             : 
      33       24954 : OOXMLFastDocumentHandler::OOXMLFastDocumentHandler(
      34             :     uno::Reference< uno::XComponentContext > const & context,
      35             :     Stream* pStream,
      36             :     OOXMLDocumentImpl* pDocument,
      37             :     sal_Int32 nXNoteId )
      38             :     : m_xContext(context)
      39             :     , mpStream( pStream )
      40             : #ifdef DEBUG_WRITERFILTER
      41             :     , mpTmpStream()
      42             : #endif
      43             :     , mpDocument( pDocument )
      44             :     , mnXNoteId( nXNoteId )
      45       24954 :     , mpContextHandler()
      46             : {
      47       24954 : }
      48             : 
      49             : // css::xml::sax::XFastContextHandler:
      50           0 : void SAL_CALL OOXMLFastDocumentHandler::startFastElement
      51             : (::sal_Int32
      52             : #ifdef DEBUG_WRITERFILTER
      53             : Element
      54             : #endif
      55             : , const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
      56             :     throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
      57             : {
      58             : #ifdef DEBUG_WRITERFILTER
      59             :     clog << this << ":start element:"
      60             :          << fastTokenToId(Element)
      61             :          << endl;
      62             : #endif
      63           0 : }
      64             : 
      65        5611 : void SAL_CALL OOXMLFastDocumentHandler::startUnknownElement
      66             : (const OUString &
      67             : #ifdef DEBUG_WRITERFILTER
      68             : Namespace
      69             : #endif
      70             : , const OUString &
      71             : #ifdef DEBUG_WRITERFILTER
      72             : Name
      73             : #endif
      74             : ,
      75             :  const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
      76             : throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
      77             : {
      78             : #ifdef DEBUG_WRITERFILTER
      79             :     clog << this << ":start unknown element:"
      80             :          << OUStringToOString(Namespace, RTL_TEXTENCODING_ASCII_US).getStr()
      81             :          << ":"
      82             :          << OUStringToOString(Name, RTL_TEXTENCODING_ASCII_US).getStr()
      83             :          << endl;
      84             : #endif
      85        5611 : }
      86             : 
      87           0 : void SAL_CALL OOXMLFastDocumentHandler::endFastElement(::sal_Int32
      88             : #ifdef DEBUG_WRITERFILTER
      89             : Element
      90             : #endif
      91             : )
      92             : throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
      93             : {
      94             : #ifdef DEBUG_WRITERFILTER
      95             :     clog << this << ":end element:"
      96             :          << fastTokenToId(Element)
      97             :          << endl;
      98             : #endif
      99           0 : }
     100             : 
     101        5611 : void SAL_CALL OOXMLFastDocumentHandler::endUnknownElement
     102             : (const OUString &
     103             : #ifdef DEBUG_WRITERFILTER
     104             : Namespace
     105             : #endif
     106             : , const OUString &
     107             : #ifdef DEBUG_WRITERFILTER
     108             : Name
     109             : #endif
     110             : )
     111             : throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
     112             : {
     113             : #ifdef DEBUG_WRITERFILTER
     114             :     clog << this << ":end unknown element:"
     115             :          << OUStringToOString(Namespace, RTL_TEXTENCODING_ASCII_US).getStr()
     116             :          << ":"
     117             :          << OUStringToOString(Name, RTL_TEXTENCODING_ASCII_US).getStr()
     118             :          << endl;
     119             : #endif
     120        5611 : }
     121             : 
     122             : OOXMLFastContextHandler::Pointer_t
     123       13439 : OOXMLFastDocumentHandler::getContextHandler() const
     124             : {
     125       13439 :     if (mpContextHandler == OOXMLFastContextHandler::Pointer_t())
     126             :     {
     127             :         mpContextHandler.reset
     128       10530 :         (new OOXMLFastContextHandler(m_xContext));
     129       10530 :         mpContextHandler->setStream(mpStream);
     130       10530 :         mpContextHandler->setDocument(mpDocument);
     131       10530 :         mpContextHandler->setXNoteId(mnXNoteId);
     132       10530 :         mpContextHandler->setForwardEvents(true);
     133             :     }
     134             : 
     135       13439 :     return mpContextHandler;
     136             : }
     137             : 
     138             : uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
     139       10529 :  OOXMLFastDocumentHandler::createFastChildContext
     140             : (::sal_Int32 Element,
     141             :  const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
     142             :     throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
     143             : {
     144       10529 :     if ( mpStream == nullptr && mpDocument == nullptr )
     145             :     {
     146             :         // document handler has been created as unknown child - see <OOXMLFastDocumentHandler::createUnknownChildContext(..)>
     147             :         // --> do not provide a child context
     148           0 :         return nullptr;
     149             :     }
     150             : 
     151       10529 :     return OOXMLFactory::createFastChildContextFromStart(getContextHandler().get(), Element);
     152             : }
     153             : 
     154             : uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
     155        5611 : OOXMLFastDocumentHandler::createUnknownChildContext
     156             : (const OUString &
     157             : #ifdef DEBUG_WRITERFILTER
     158             : Namespace
     159             : #endif
     160             : ,
     161             :  const OUString &
     162             : #ifdef DEBUG_WRITERFILTER
     163             : Name
     164             : #endif
     165             : , const uno::Reference< xml::sax::XFastAttributeList > & /*Attribs*/)
     166             :     throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
     167             : {
     168             : #ifdef DEBUG_WRITERFILTER
     169             :     clog << this << ":createUnknownChildContext:"
     170             :          << OUStringToOString(Namespace, RTL_TEXTENCODING_ASCII_US).getStr()
     171             :          << ":"
     172             :          << OUStringToOString(Name, RTL_TEXTENCODING_ASCII_US).getStr()
     173             :          << endl;
     174             : #endif
     175             : 
     176             :     return uno::Reference< xml::sax::XFastContextHandler >
     177        5611 :         ( new OOXMLFastDocumentHandler( m_xContext, nullptr, nullptr, 0 ) );
     178             : }
     179             : 
     180        4530 : void SAL_CALL OOXMLFastDocumentHandler::characters(const OUString & /*aChars*/)
     181             :     throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
     182             : {
     183        4530 : }
     184             : 
     185             : // css::xml::sax::XFastDocumentHandler:
     186       11026 : void SAL_CALL OOXMLFastDocumentHandler::startDocument()
     187             :     throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
     188             : {
     189       11026 : }
     190             : 
     191       11025 : void SAL_CALL OOXMLFastDocumentHandler::endDocument()
     192             :     throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
     193             : {
     194       11025 : }
     195             : 
     196       11026 : void SAL_CALL OOXMLFastDocumentHandler::setDocumentLocator
     197             : (const uno::Reference< xml::sax::XLocator > & /*xLocator*/)
     198             :     throw (uno::RuntimeException, xml::sax::SAXException, std::exception)
     199             : {
     200       11026 : }
     201             : 
     202        2910 : void OOXMLFastDocumentHandler::setIsSubstream( bool bSubstream )
     203             : {
     204        2910 :     if ( mpStream != nullptr && mpDocument != nullptr )
     205             :     {
     206        2910 :         getContextHandler( )->getParserState( )->setInSectionGroup( bSubstream );
     207             :     }
     208        2910 : }
     209             : 
     210          72 : }}
     211             : 
     212             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11