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

Generated by: LCOV version 1.10