LCOV - code coverage report
Current view: top level - xmloff/source/transform - ChartOOoTContext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 43 55 78.2 %
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 "ChartOOoTContext.hxx"
      21             : #include "MutableAttrList.hxx"
      22             : #include <xmloff/xmlnmspe.hxx>
      23             : #include "ActionMapTypesOOo.hxx"
      24             : #include "AttrTransformerAction.hxx"
      25             : #include "TransformerActions.hxx"
      26             : #include "TransformerBase.hxx"
      27             : 
      28             : using namespace ::com::sun::star::uno;
      29             : using namespace ::com::sun::star::xml::sax;
      30             : using namespace ::xmloff::token;
      31             : 
      32           0 : TYPEINIT1( XMLChartOOoTransformerContext, XMLTransformerContext );
      33             : 
      34           6 : XMLChartOOoTransformerContext::XMLChartOOoTransformerContext(
      35             :         XMLTransformerBase& rImp,
      36             :         const OUString& rQName ) :
      37           6 :     XMLTransformerContext( rImp, rQName )
      38             : {
      39           6 : }
      40             : 
      41          12 : XMLChartOOoTransformerContext::~XMLChartOOoTransformerContext()
      42             : {
      43          12 : }
      44             : 
      45           6 : void XMLChartOOoTransformerContext::StartElement(
      46             :     const Reference< XAttributeList >& rAttrList )
      47             : {
      48             :     XMLTransformerActions *pActions =
      49           6 :         GetTransformer().GetUserDefinedActions( OOO_CHART_ACTIONS );
      50             :     OSL_ENSURE( pActions, "go no actions" );
      51             : 
      52           6 :     sal_Int16 nClassName = -1;
      53           6 :     OUString aAddInName;
      54          12 :     Reference< XAttributeList > xAttrList( rAttrList );
      55           6 :     XMLMutableAttributeList *pMutableAttrList = 0;
      56           6 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
      57          30 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
      58             :     {
      59          24 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
      60          48 :         OUString aLocalName;
      61             :         sal_uInt16 nPrefix =
      62          24 :             GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
      63          24 :                                                                  &aLocalName );
      64          48 :         XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
      65             :         XMLTransformerActions::const_iterator aIter =
      66          24 :             pActions->find( aKey );
      67          24 :         if( !(aIter == pActions->end() ) )
      68             :         {
      69          24 :             if( !pMutableAttrList )
      70             :             {
      71             :                 pMutableAttrList =
      72           6 :                         new XMLMutableAttributeList( xAttrList );
      73           6 :                 xAttrList = pMutableAttrList;
      74             :             }
      75          24 :             const OUString& rAttrValue = xAttrList->getValueByIndex( i );
      76          24 :             switch( (*aIter).second.m_nActionType )
      77             :             {
      78             :             case XML_ATACTION_INCH2IN:
      79             :                 {
      80          12 :                     OUString aAttrValue( rAttrValue );
      81          12 :                     if( XMLTransformerBase::ReplaceSingleInchWithIn(
      82             :                                 aAttrValue ) )
      83           0 :                         pMutableAttrList->SetValueByIndex( i, aAttrValue );
      84             :                 }
      85          12 :                 break;
      86             :             case XML_ATACTION_ENCODE_STYLE_NAME_REF:
      87             :                 {
      88           6 :                     OUString aAttrValue( rAttrValue );
      89           6 :                     if( GetTransformer().EncodeStyleName(aAttrValue) )
      90           0 :                         pMutableAttrList->SetValueByIndex( i, aAttrValue );
      91             :                 }
      92           6 :                 break;
      93             :             case XML_ATACTION_ADD_NAMESPACE_PREFIX:
      94             :                 OSL_ENSURE( ::xmloff::token::IsXMLToken( aLocalName, XML_CLASS ),
      95             :                                "unexpected class token" );
      96           6 :                 if( ::xmloff::token::IsXMLToken( rAttrValue, XML_ADD_IN ) )
      97             :                 {
      98           0 :                     nClassName = i;
      99             :                 }
     100             :                 else
     101             :                 {
     102           6 :                     OUString aAttrValue( rAttrValue );
     103             :                     sal_uInt16 nValPrefix =
     104           6 :                         static_cast<sal_uInt16>((*aIter).second.m_nParam1);
     105           6 :                     if( GetTransformer().AddNamespacePrefix( aAttrValue,
     106           6 :                                                              nValPrefix ) )
     107           6 :                         pMutableAttrList->SetValueByIndex( i, aAttrValue );
     108             :                 }
     109           6 :                 break;
     110             :             case XML_ATACTION_REMOVE:
     111             :                 OSL_ENSURE( ::xmloff::token::IsXMLToken( aLocalName, XML_ADD_IN_NAME ),
     112             :                                "unexpected class token" );
     113           0 :                 aAddInName = rAttrValue;
     114           0 :                 pMutableAttrList->RemoveAttributeByIndex( i );
     115           0 :                 --i;
     116           0 :                 --nAttrCount;
     117           0 :                 break;
     118             :             default:
     119             :                 OSL_ENSURE( false, "unknown action" );
     120           0 :                 break;
     121          24 :             }
     122             :         }
     123          24 :     }
     124             : 
     125           6 :     if( nClassName != -1 && !aAddInName.isEmpty() )
     126             :     {
     127           0 :         GetTransformer().AddNamespacePrefix( aAddInName, XML_NAMESPACE_OOO );
     128           0 :         pMutableAttrList->SetValueByIndex( nClassName, aAddInName );
     129             :     }
     130             : 
     131          12 :     XMLTransformerContext::StartElement( xAttrList );
     132           6 : }
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10