LCOV - code coverage report
Current view: top level - xmloff/source/transform - DeepTContext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 50 68 73.5 %
Date: 2015-06-13 12:38:46 Functions: 8 14 57.1 %
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 "DeepTContext.hxx"
      21             : #include "FlatTContext.hxx"
      22             : #include "EventOOoTContext.hxx"
      23             : #include "TransformerActions.hxx"
      24             : #include "ElemTransformerAction.hxx"
      25             : #include "PersMixedContentTContext.hxx"
      26             : #include "TransformerBase.hxx"
      27             : #include <osl/diagnose.h>
      28             : 
      29             : using namespace ::com::sun::star::uno;
      30             : using namespace ::com::sun::star::xml::sax;
      31             : 
      32           0 : TYPEINIT1( XMLPersElemContentTContext, XMLPersAttrListTContext );
      33             : 
      34           3 : void XMLPersElemContentTContext::AddContent( XMLTransformerContext *pContext )
      35             : {
      36             :     OSL_ENSURE( pContext && pContext->IsPersistent(),
      37             :                 "non-persistent context" );
      38           3 :     XMLTransformerContextVector::value_type aVal( pContext );
      39           3 :     m_aChildContexts.push_back( aVal );
      40           3 : }
      41             : 
      42        1313 : XMLPersElemContentTContext::XMLPersElemContentTContext(
      43             :         XMLTransformerBase& rImp,
      44             :         const OUString& rQName ) :
      45        1313 :     XMLPersAttrListTContext( rImp, rQName )
      46             : {
      47        1313 : }
      48             : 
      49          50 : XMLPersElemContentTContext::XMLPersElemContentTContext(
      50             :         XMLTransformerBase& rImp,
      51             :         const OUString& rQName,
      52             :        sal_uInt16 nActionMap ) :
      53          50 :     XMLPersAttrListTContext( rImp, rQName, nActionMap )
      54             : {
      55          50 : }
      56             : 
      57         508 : XMLPersElemContentTContext::XMLPersElemContentTContext(
      58             :         XMLTransformerBase& rImp,
      59             :         const OUString& rQName,
      60             :         sal_uInt16 nPrefix,
      61             :         ::xmloff::token::XMLTokenEnum eToken ) :
      62         508 :     XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken )
      63             : {
      64         508 : }
      65             : 
      66           2 : XMLPersElemContentTContext::XMLPersElemContentTContext(
      67             :         XMLTransformerBase& rImp,
      68             :         const OUString& rQName,
      69             :         sal_uInt16 nPrefix,
      70             :         ::xmloff::token::XMLTokenEnum eToken,
      71             :        sal_uInt16 nActionMap ) :
      72           2 :     XMLPersAttrListTContext( rImp, rQName, nPrefix, eToken, nActionMap )
      73             : {
      74           2 : }
      75             : 
      76        1873 : XMLPersElemContentTContext::~XMLPersElemContentTContext()
      77             : {
      78        1873 : }
      79             : 
      80         231 : XMLTransformerContext *XMLPersElemContentTContext::CreateChildContext(
      81             :         sal_uInt16 nPrefix,
      82             :         const OUString& rLocalName,
      83             :         const OUString& rQName,
      84             :         const Reference< XAttributeList >& )
      85             : {
      86         231 :     XMLTransformerContext *pContext = 0;
      87             : 
      88         231 :     XMLTransformerActions::key_type aKey( nPrefix, rLocalName );
      89             :     XMLTransformerActions::const_iterator aIter =
      90         231 :         GetTransformer().GetElemActions().find( aKey );
      91             : 
      92         231 :     if( !(aIter == GetTransformer().GetElemActions().end()) )
      93             :     {
      94          92 :         switch( (*aIter).second.m_nActionType )
      95             :         {
      96             :         case XML_ETACTION_COPY:
      97           0 :             pContext = new XMLPersMixedContentTContext( GetTransformer(),
      98           0 :                                                        rQName );
      99           0 :             break;
     100             :         case XML_ETACTION_COPY_TEXT:
     101           0 :             pContext = new XMLPersMixedContentTContext( GetTransformer(),
     102           0 :                                                        rQName );
     103           0 :             break;
     104             :         case XML_ETACTION_RENAME_ELEM:
     105           0 :             pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName,
     106           0 :                     (*aIter).second.GetQNamePrefixFromParam1(),
     107           0 :                     (*aIter).second.GetQNameTokenFromParam1() );
     108           0 :             break;
     109             :         case XML_ETACTION_RENAME_ELEM_PROC_ATTRS:
     110           0 :             pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName,
     111           0 :                     (*aIter).second.GetQNamePrefixFromParam1(),
     112           0 :                     (*aIter).second.GetQNameTokenFromParam1(),
     113           0 :                        static_cast< sal_uInt16 >( (*aIter).second.m_nParam2 ) );
     114           0 :             break;
     115             :         case XML_ETACTION_RENAME_ELEM_ADD_PROC_ATTR:
     116             :             {
     117             :                 XMLPersMixedContentTContext *pMC =
     118           2 :                     new XMLPersMixedContentTContext( GetTransformer(), rQName,
     119           2 :                         (*aIter).second.GetQNamePrefixFromParam1(),
     120           2 :                         (*aIter).second.GetQNameTokenFromParam1(),
     121             :                         static_cast< sal_uInt16 >(
     122           6 :                             (*aIter).second.m_nParam3  >> 16 ) );
     123             :                 pMC->AddAttribute(
     124           2 :                     (*aIter).second.GetQNamePrefixFromParam2(),
     125           2 :                     (*aIter).second.GetQNameTokenFromParam2(),
     126             :                        static_cast< ::xmloff::token::XMLTokenEnum >(
     127           6 :                         (*aIter).second.m_nParam3 & 0xffff ) );
     128           2 :                 pContext = pMC;
     129             :             }
     130           2 :             break;
     131             :         case XML_ETACTION_PROC_ATTRS:
     132          50 :             pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName,
     133          50 :                        static_cast< sal_uInt16 >( (*aIter).second.m_nParam1 ) );
     134          50 :             break;
     135             :         default:
     136          40 :             pContext = GetTransformer().CreateUserDefinedContext(
     137          40 :                             (*aIter).second, rQName, true );
     138             :             OSL_ENSURE( pContext && pContext->IsPersistent(),
     139             :                         "unknown or not persistent action" );
     140          40 :             if( pContext && !pContext->IsPersistent() )
     141             :             {
     142           0 :                 delete pContext;
     143           0 :                 pContext = 0;
     144             :             }
     145          40 :             break;
     146             :         }
     147             :     }
     148             : 
     149             :     // default is copying
     150         231 :     if( !pContext )
     151         139 :         pContext = new XMLPersMixedContentTContext( GetTransformer(), rQName );
     152         231 :     XMLTransformerContextVector::value_type aVal( pContext );
     153         231 :     m_aChildContexts.push_back( aVal );
     154             : 
     155         231 :     return pContext;
     156             : }
     157             : 
     158        1022 : void XMLPersElemContentTContext::ExportContent()
     159             : {
     160        1022 :     XMLTransformerContextVector::iterator aIter = m_aChildContexts.begin();
     161             : 
     162        1256 :     for( ; aIter != m_aChildContexts.end(); ++aIter )
     163             :     {
     164         234 :         (*aIter)->Export();
     165             :     }
     166        1022 : }
     167             : 
     168             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11