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

Generated by: LCOV version 1.10