LCOV - code coverage report
Current view: top level - xmloff/source/transform - ChartOASISTContext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 53 0.0 %
Date: 2014-04-14 Functions: 0 9 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 "ChartOASISTContext.hxx"
      21             : #include "MutableAttrList.hxx"
      22             : #include <xmloff/xmlnmspe.hxx>
      23             : #include "ActionMapTypesOASIS.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( XMLChartOASISTransformerContext, XMLTransformerContext );
      33             : 
      34           0 : XMLChartOASISTransformerContext::XMLChartOASISTransformerContext(
      35             :         XMLTransformerBase& rImp,
      36             :         const OUString& rQName ) :
      37           0 :     XMLTransformerContext( rImp, rQName )
      38             : {
      39           0 : }
      40             : 
      41           0 : XMLChartOASISTransformerContext::~XMLChartOASISTransformerContext()
      42             : {
      43           0 : }
      44             : 
      45           0 : void XMLChartOASISTransformerContext::StartElement(
      46             :     const Reference< XAttributeList >& rAttrList )
      47             : {
      48             :     XMLTransformerActions *pActions =
      49           0 :         GetTransformer().GetUserDefinedActions( OASIS_CHART_ACTIONS );
      50             :     OSL_ENSURE( pActions, "go no actions" );
      51             : 
      52           0 :     OUString aAddInName;
      53           0 :     Reference< XAttributeList > xAttrList( rAttrList );
      54           0 :     XMLMutableAttributeList *pMutableAttrList = 0;
      55           0 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
      56           0 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
      57             :     {
      58           0 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
      59           0 :         OUString aLocalName;
      60             :         sal_uInt16 nPrefix =
      61           0 :             GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
      62           0 :                                                                  &aLocalName );
      63           0 :         XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
      64             :         XMLTransformerActions::const_iterator aIter =
      65           0 :             pActions->find( aKey );
      66           0 :         if( !(aIter == pActions->end() ) )
      67             :         {
      68           0 :             if( !pMutableAttrList )
      69             :             {
      70             :                 pMutableAttrList =
      71           0 :                         new XMLMutableAttributeList( xAttrList );
      72           0 :                 xAttrList = pMutableAttrList;
      73             :             }
      74           0 :             const OUString& rAttrValue = xAttrList->getValueByIndex( i );
      75           0 :             switch( (*aIter).second.m_nActionType )
      76             :             {
      77             :             case XML_ATACTION_IN2INCH:
      78             :                 {
      79           0 :                     OUString aAttrValue( rAttrValue );
      80           0 :                     if( XMLTransformerBase::ReplaceSingleInWithInch(
      81           0 :                                 aAttrValue ) )
      82           0 :                         pMutableAttrList->SetValueByIndex( i, aAttrValue );
      83             :                 }
      84           0 :                 break;
      85             :             case XML_ATACTION_DECODE_STYLE_NAME_REF:
      86             :                 {
      87           0 :                     OUString aAttrValue( rAttrValue );
      88           0 :                     if( GetTransformer().DecodeStyleName(aAttrValue) )
      89           0 :                         pMutableAttrList->SetValueByIndex( i, aAttrValue );
      90             :                 }
      91           0 :                 break;
      92             :             case XML_ATACTION_REMOVE_ANY_NAMESPACE_PREFIX:
      93             :                 OSL_ENSURE( IsXMLToken( aLocalName, XML_CLASS ),
      94             :                                "unexpected class token" );
      95             :                 {
      96           0 :                     OUString aChartClass;
      97             :                     sal_uInt16 nValuePrefix =
      98           0 :                         GetTransformer().GetNamespaceMap().GetKeyByAttrName(
      99             :                             rAttrValue,
     100           0 :                             &aChartClass );
     101           0 :                     if( XML_NAMESPACE_CHART == nValuePrefix )
     102             :                     {
     103           0 :                         pMutableAttrList->SetValueByIndex( i, aChartClass );
     104             :                     }
     105           0 :                     else if ( XML_NAMESPACE_OOO == nValuePrefix )
     106             :                     {
     107             :                         pMutableAttrList->SetValueByIndex( i,
     108           0 :                                                 GetXMLToken(XML_ADD_IN ) );
     109           0 :                         aAddInName = aChartClass;
     110           0 :                     }
     111             :                 }
     112           0 :                 break;
     113             :             default:
     114             :                 OSL_ENSURE( !this, "unknown action" );
     115           0 :                 break;
     116           0 :             }
     117             :         }
     118           0 :     }
     119             : 
     120           0 :     if( !aAddInName.isEmpty() )
     121             :     {
     122           0 :         OUString aAttrQName( GetTransformer().GetNamespaceMap().GetQNameByKey(
     123             :                                 XML_NAMESPACE_CHART,
     124           0 :                                 GetXMLToken( XML_ADD_IN_NAME ) ) );
     125           0 :         pMutableAttrList->AddAttribute( aAttrQName, aAddInName );
     126             :     }
     127             : 
     128           0 :     XMLTransformerContext::StartElement( xAttrList );
     129           0 : }
     130             : 
     131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10