LCOV - code coverage report
Current view: top level - xmloff/source/transform - CreateElemTContext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 45 47 95.7 %
Date: 2014-11-03 Functions: 4 9 44.4 %
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 "CreateElemTContext.hxx"
      21             : #include "MutableAttrList.hxx"
      22             : #include "TransformerBase.hxx"
      23             : #include "TransformerActions.hxx"
      24             : #include "TContextVector.hxx"
      25             : #include "FlatTContext.hxx"
      26             : #include "AttrTransformerAction.hxx"
      27             : #include <xmloff/nmspmap.hxx>
      28             : 
      29             : using namespace ::com::sun::star::uno;
      30             : using namespace ::com::sun::star::xml::sax;
      31             : using namespace ::xmloff::token;
      32             : 
      33           0 : TYPEINIT1( XMLCreateElemTransformerContext, XMLTransformerContext );
      34             : 
      35          10 : XMLCreateElemTransformerContext::XMLCreateElemTransformerContext(
      36             :         XMLTransformerBase& rImp,
      37             :         const OUString& rQName,
      38             :        sal_uInt16 nActionMap ) :
      39             :     XMLTransformerContext( rImp, rQName ),
      40          10 :     m_nActionMap( nActionMap )
      41             : {
      42          10 : }
      43             : 
      44          20 : XMLCreateElemTransformerContext::~XMLCreateElemTransformerContext()
      45             : {
      46          20 : }
      47             : 
      48          10 : void XMLCreateElemTransformerContext::StartElement(
      49             :         const Reference< XAttributeList >& rAttrList )
      50             : {
      51          10 :     Reference< XAttributeList > xAttrList( rAttrList );
      52             : 
      53          20 :     XMLTransformerContextVector aChildContexts;
      54             : 
      55          10 :     XMLMutableAttributeList *pMutableAttrList = 0;
      56             :     XMLTransformerActions *pActions =
      57          10 :         GetTransformer().GetUserDefinedActions( m_nActionMap );
      58             :     OSL_ENSURE( pActions, "go no actions" );
      59          10 :     if( pActions )
      60             :     {
      61          10 :         sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
      62          30 :         for( sal_Int16 i=0; i < nAttrCount; ++i )
      63             :         {
      64          20 :             const OUString& rAttrName = xAttrList->getNameByIndex( i );
      65          40 :             const OUString& rAttrValue = xAttrList->getValueByIndex( i );
      66          40 :             OUString aLocalName;
      67             :             sal_uInt16 nPrefix =
      68          20 :                 GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
      69          20 :                                                            &aLocalName );
      70             : 
      71          40 :             XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
      72             :             XMLTransformerActions::const_iterator aIter =
      73          20 :                     pActions->find( aKey );
      74          20 :             if( !(aIter == pActions->end() ) )
      75             :             {
      76          10 :                 if( !pMutableAttrList )
      77             :                 {
      78          10 :                     pMutableAttrList = new XMLMutableAttributeList( xAttrList );
      79          10 :                     xAttrList = pMutableAttrList;
      80             :                 }
      81          10 :                 sal_uInt32 nAction = (*aIter).second.m_nActionType;
      82          10 :                 switch( nAction )
      83             :                 {
      84             :                 case XML_ATACTION_MOVE_TO_ELEM:
      85             :                     {
      86             :                         OUString aElemQName(
      87          10 :                             GetTransformer().GetNamespaceMap().GetQNameByKey(
      88          10 :                                 (*aIter).second.GetQNamePrefixFromParam1(),
      89             :                                 ::xmloff::token::GetXMLToken(
      90          30 :                                 (*aIter).second.GetQNameTokenFromParam1()) ) );
      91             :                         XMLTransformerContext *pContext =
      92          10 :                             new XMLPersTextContentTContext( GetTransformer(),
      93          10 :                                                        aElemQName );
      94          10 :                         pContext->Characters( rAttrValue );
      95             :                         XMLTransformerContextVector::value_type aVal(
      96          20 :                                 pContext );
      97          10 :                         aChildContexts.push_back( aVal );
      98          10 :                         pMutableAttrList->RemoveAttributeByIndex( i );
      99          10 :                         --i;
     100          20 :                         --nAttrCount;
     101             :                     }
     102          10 :                     break;
     103             :                 default:
     104             :                     OSL_ENSURE( false, "unknown action" );
     105           0 :                     break;
     106             :                 }
     107             :             }
     108          20 :         }
     109             :     }
     110          10 :     XMLTransformerContext::StartElement( xAttrList );
     111             : 
     112          10 :     XMLTransformerContextVector::iterator aIter = aChildContexts.begin();
     113             : 
     114          20 :     for( ; aIter != aChildContexts.end(); ++aIter )
     115             :     {
     116          10 :         (*aIter)->Export();
     117          10 :     }
     118          10 : }
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10