LCOV - code coverage report
Current view: top level - oox/source/core - fragmenthandler2.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 76 0.0 %
Date: 2014-04-14 Functions: 0 24 0.0 %
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 "oox/core/fragmenthandler2.hxx"
      21             : #include "oox/core/xmlfilterbase.hxx"
      22             : 
      23             : namespace oox {
      24             : namespace core {
      25             : 
      26             : 
      27             : 
      28             : using namespace ::com::sun::star::uno;
      29             : using namespace ::com::sun::star::xml::sax;
      30             : 
      31             : 
      32             : 
      33             : using ::com::sun::star::uno::Sequence;
      34             : 
      35             : 
      36             : 
      37           0 : FragmentHandler2::FragmentHandler2( XmlFilterBase& rFilter, const OUString& rFragmentPath, bool bEnableTrimSpace ) :
      38             :     FragmentHandler( rFilter, rFragmentPath ),
      39           0 :     ContextHandler2Helper( bEnableTrimSpace )
      40             : {
      41           0 : }
      42             : 
      43           0 : FragmentHandler2::~FragmentHandler2()
      44             : {
      45           0 : }
      46             : 
      47             : // com.sun.star.xml.sax.XFastDocumentHandler interface --------------------
      48             : 
      49           0 : void SAL_CALL FragmentHandler2::startDocument() throw( SAXException, RuntimeException, std::exception )
      50             : {
      51           0 :     initializeImport();
      52           0 : }
      53             : 
      54           0 : void SAL_CALL FragmentHandler2::endDocument() throw( SAXException, RuntimeException, std::exception )
      55             : {
      56           0 :     finalizeImport();
      57           0 : }
      58             : 
      59           0 : bool FragmentHandler2::prepareMceContext( sal_Int32 nElement, const AttributeList& rAttribs )
      60             : {
      61           0 :     switch( nElement )
      62             :     {
      63             :         case MCE_TOKEN( AlternateContent ):
      64           0 :             aMceState.push_back( MCE_STARTED );
      65           0 :             break;
      66             : 
      67             :         case MCE_TOKEN( Choice ):
      68             :             {
      69           0 :                 OUString aRequires = rAttribs.getString( ( XML_Requires ), OUString("none") );
      70           0 :                 if (!getFilter().hasNamespaceURL(aRequires))
      71             :                     // Check to see if we have this namespace defined first,
      72             :                     // because calling getNamespaceURL() would throw if the
      73             :                     // namespace doesn't exist.
      74           0 :                     return false;
      75             : 
      76           0 :                 aRequires = getFilter().getNamespaceURL( aRequires );
      77           0 :                 if( getFilter().getNamespaceId( aRequires ) > 0 && !aMceState.empty() && aMceState.back() == MCE_STARTED )
      78           0 :                     aMceState.back() = MCE_FOUND_CHOICE;
      79             :                 else
      80           0 :                     return false;
      81             :             }
      82           0 :             break;
      83             : 
      84             :         case MCE_TOKEN( Fallback ):
      85           0 :             if( !aMceState.empty() && aMceState.back() == MCE_STARTED )
      86           0 :                 break;
      87           0 :             return false;
      88             :         default:
      89             :             {
      90           0 :                 OUString str = rAttribs.getString( MCE_TOKEN( Ignorable ), OUString() );
      91           0 :                 if( !str.isEmpty() )
      92             :                 {
      93             :                     // Sequence< ::com::sun::star::xml::FastAttribute > attrs = rAttribs.getFastAttributeList()->getFastAttributes();
      94             :                     // printf("MCE: %s\n", OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() );
      95             :                     // TODO: Check & Get the namespaces in "Ignorable"
      96             :                     // printf("NS: %d : %s\n", attrs.getLength(), OUStringToOString( str, RTL_TEXTENCODING_UTF8 ).getStr() );
      97           0 :                 }
      98             :             }
      99           0 :             return false;
     100             :     }
     101           0 :     return true;
     102             : }
     103             : 
     104             : 
     105             : 
     106             : // com.sun.star.xml.sax.XFastContextHandler interface -------------------------
     107             : 
     108           0 : Reference< XFastContextHandler > SAL_CALL FragmentHandler2::createFastChildContext(
     109             :         sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs ) throw( SAXException, RuntimeException, std::exception )
     110             : {
     111           0 :     if( getNamespace( nElement ) == NMSP_mce ) // TODO for checking 'Ignorable'
     112             :     {
     113           0 :         if( prepareMceContext( nElement, AttributeList( rxAttribs ) ) )
     114           0 :             return getFastContextHandler();
     115           0 :         return NULL;
     116             :     }
     117           0 :     return implCreateChildContext( nElement, rxAttribs );
     118             : }
     119             : 
     120           0 : void SAL_CALL FragmentHandler2::startFastElement(
     121             :         sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs ) throw( SAXException, RuntimeException, std::exception )
     122             : {
     123           0 :     implStartElement( nElement, rxAttribs );
     124           0 : }
     125             : 
     126           0 : void SAL_CALL FragmentHandler2::characters( const OUString& rChars ) throw( SAXException, RuntimeException, std::exception )
     127             : {
     128           0 :     implCharacters( rChars );
     129           0 : }
     130             : 
     131           0 : void SAL_CALL FragmentHandler2::endFastElement( sal_Int32 nElement ) throw( SAXException, RuntimeException, std::exception )
     132             : {
     133             :     /* If MCE */
     134           0 :     switch( nElement )
     135             :     {
     136             :         case MCE_TOKEN( AlternateContent ):
     137           0 :             aMceState.pop_back();
     138           0 :             break;
     139             :     }
     140             : 
     141           0 :     implEndElement( nElement );
     142           0 : }
     143             : 
     144             : // oox.core.ContextHandler interface ------------------------------------------
     145             : 
     146           0 : ContextHandlerRef FragmentHandler2::createRecordContext( sal_Int32 nRecId, SequenceInputStream& rStrm )
     147             : {
     148           0 :     return implCreateRecordContext( nRecId, rStrm );
     149             : }
     150             : 
     151           0 : void FragmentHandler2::startRecord( sal_Int32 nRecId, SequenceInputStream& rStrm )
     152             : {
     153           0 :     implStartRecord( nRecId, rStrm );
     154           0 : }
     155             : 
     156           0 : void FragmentHandler2::endRecord( sal_Int32 nRecId )
     157             : {
     158           0 :     implEndRecord( nRecId );
     159           0 : }
     160             : 
     161             : // oox.core.ContextHandler2Helper interface -----------------------------------
     162             : 
     163           0 : ContextHandlerRef FragmentHandler2::onCreateContext( sal_Int32, const AttributeList& )
     164             : {
     165           0 :     return 0;
     166             : }
     167             : 
     168           0 : void FragmentHandler2::onStartElement( const AttributeList& )
     169             : {
     170           0 : }
     171             : 
     172           0 : void FragmentHandler2::onCharacters( const OUString& )
     173             : {
     174           0 : }
     175             : 
     176           0 : void FragmentHandler2::onEndElement()
     177             : {
     178           0 : }
     179             : 
     180           0 : ContextHandlerRef FragmentHandler2::onCreateRecordContext( sal_Int32, SequenceInputStream& )
     181             : {
     182           0 :     return 0;
     183             : }
     184             : 
     185           0 : void FragmentHandler2::onStartRecord( SequenceInputStream& )
     186             : {
     187           0 : }
     188             : 
     189           0 : void FragmentHandler2::onEndRecord()
     190             : {
     191           0 : }
     192             : 
     193             : // oox.core.FragmentHandler2 interface ----------------------------------------
     194             : 
     195           0 : void FragmentHandler2::initializeImport()
     196             : {
     197           0 : }
     198             : 
     199           0 : void FragmentHandler2::finalizeImport()
     200             : {
     201           0 : }
     202             : 
     203             : 
     204             : 
     205             : } // namespace core
     206           0 : } // namespace oox
     207             : 
     208             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10