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

Generated by: LCOV version 1.11