LCOV - code coverage report
Current view: top level - xmloff/source/transform - ChartOOoTContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 46 56 82.1 %
Date: 2012-08-25 Functions: 4 9 44.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 37 85 43.5 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "ChartOOoTContext.hxx"
      30                 :            : #include "MutableAttrList.hxx"
      31                 :            : #include "xmloff/xmlnmspe.hxx"
      32                 :            : #include "ActionMapTypesOOo.hxx"
      33                 :            : #include "AttrTransformerAction.hxx"
      34                 :            : #include "TransformerActions.hxx"
      35                 :            : #include "TransformerBase.hxx"
      36                 :            : 
      37                 :            : using ::rtl::OUString;
      38                 :            : 
      39                 :            : using namespace ::com::sun::star::uno;
      40                 :            : using namespace ::com::sun::star::xml::sax;
      41                 :            : using namespace ::xmloff::token;
      42                 :            : 
      43                 :            : // -----------------------------------------------------------------------------
      44                 :            : 
      45 [ #  # ][ #  # ]:          0 : TYPEINIT1( XMLChartOOoTransformerContext, XMLTransformerContext );
      46                 :            : 
      47                 :          6 : XMLChartOOoTransformerContext::XMLChartOOoTransformerContext(
      48                 :            :         XMLTransformerBase& rImp,
      49                 :            :         const OUString& rQName ) :
      50                 :          6 :     XMLTransformerContext( rImp, rQName )
      51                 :            : {
      52                 :          6 : }
      53                 :            : 
      54                 :          6 : XMLChartOOoTransformerContext::~XMLChartOOoTransformerContext()
      55                 :            : {
      56         [ -  + ]:         12 : }
      57                 :            : 
      58                 :          6 : void XMLChartOOoTransformerContext::StartElement(
      59                 :            :     const Reference< XAttributeList >& rAttrList )
      60                 :            : {
      61                 :            :     XMLTransformerActions *pActions =
      62         [ +  - ]:          6 :         GetTransformer().GetUserDefinedActions( OOO_CHART_ACTIONS );
      63                 :            :     OSL_ENSURE( pActions, "go no actions" );
      64                 :            : 
      65                 :          6 :     sal_Int16 nClassName = -1;
      66                 :          6 :     OUString aAddInName;
      67                 :          6 :     Reference< XAttributeList > xAttrList( rAttrList );
      68                 :          6 :     XMLMutableAttributeList *pMutableAttrList = 0;
      69 [ +  - ][ +  - ]:          6 :     sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
                 [ +  - ]
      70         [ +  + ]:         30 :     for( sal_Int16 i=0; i < nAttrCount; i++ )
      71                 :            :     {
      72 [ +  - ][ +  - ]:         24 :         const OUString& rAttrName = xAttrList->getNameByIndex( i );
      73                 :         24 :         OUString aLocalName;
      74                 :            :         sal_uInt16 nPrefix =
      75                 :         24 :             GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
      76         [ +  - ]:         24 :                                                                  &aLocalName );
      77                 :         24 :         XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
      78                 :            :         XMLTransformerActions::const_iterator aIter =
      79         [ +  - ]:         24 :             pActions->find( aKey );
      80 [ +  - ][ +  - ]:         24 :         if( !(aIter == pActions->end() ) )
      81                 :            :         {
      82         [ +  + ]:         24 :             if( !pMutableAttrList )
      83                 :            :             {
      84                 :            :                 pMutableAttrList =
      85         [ +  - ]:          6 :                         new XMLMutableAttributeList( xAttrList );
      86 [ +  - ][ +  - ]:          6 :                 xAttrList = pMutableAttrList;
      87                 :            :             }
      88 [ +  - ][ +  - ]:         24 :             const OUString& rAttrValue = xAttrList->getValueByIndex( i );
      89 [ +  - ][ +  +  :         24 :             switch( (*aIter).second.m_nActionType )
                +  -  - ]
      90                 :            :             {
      91                 :            :             case XML_ATACTION_INCH2IN:
      92                 :            :                 {
      93                 :         12 :                     OUString aAttrValue( rAttrValue );
      94         [ -  + ]:         12 :                     if( XMLTransformerBase::ReplaceSingleInchWithIn(
      95         [ +  - ]:         12 :                                 aAttrValue ) )
      96         [ #  # ]:         12 :                         pMutableAttrList->SetValueByIndex( i, aAttrValue );
      97                 :            :                 }
      98                 :         12 :                 break;
      99                 :            :             case XML_ATACTION_ENCODE_STYLE_NAME_REF:
     100                 :            :                 {
     101                 :          6 :                     OUString aAttrValue( rAttrValue );
     102 [ -  + ][ +  - ]:          6 :                     if( GetTransformer().EncodeStyleName(aAttrValue) )
     103         [ #  # ]:          6 :                         pMutableAttrList->SetValueByIndex( i, aAttrValue );
     104                 :            :                 }
     105                 :          6 :                 break;
     106                 :            :             case XML_ATACTION_ADD_NAMESPACE_PREFIX:
     107                 :            :                 OSL_ENSURE( ::xmloff::token::IsXMLToken( aLocalName, XML_CLASS ),
     108                 :            :                                "unexpected class token" );
     109 [ +  - ][ -  + ]:          6 :                 if( ::xmloff::token::IsXMLToken( rAttrValue, XML_ADD_IN ) )
     110                 :            :                 {
     111                 :          0 :                     nClassName = i;
     112                 :            :                 }
     113                 :            :                 else
     114                 :            :                 {
     115                 :          6 :                     OUString aAttrValue( rAttrValue );
     116                 :            :                     sal_uInt16 nValPrefix =
     117         [ +  - ]:          6 :                         static_cast<sal_uInt16>((*aIter).second.m_nParam1);
     118         [ +  - ]:         12 :                     if( GetTransformer().AddNamespacePrefix( aAttrValue,
     119         [ +  - ]:          6 :                                                              nValPrefix ) )
     120         [ +  - ]:          6 :                         pMutableAttrList->SetValueByIndex( i, aAttrValue );
     121                 :            :                 }
     122                 :          6 :                 break;
     123                 :            :             case XML_ATACTION_REMOVE:
     124                 :            :                 OSL_ENSURE( ::xmloff::token::IsXMLToken( aLocalName, XML_ADD_IN_NAME ),
     125                 :            :                                "unexpected class token" );
     126                 :          0 :                 aAddInName = rAttrValue;
     127         [ #  # ]:          0 :                 pMutableAttrList->RemoveAttributeByIndex( i );
     128                 :          0 :                 --i;
     129                 :          0 :                 --nAttrCount;
     130                 :          0 :                 break;
     131                 :            :             default:
     132                 :            :                 OSL_ENSURE( !this, "unknown action" );
     133                 :          0 :                 break;
     134                 :         24 :             }
     135                 :            :         }
     136                 :         24 :     }
     137                 :            : 
     138 [ -  + ][ #  # ]:          6 :     if( nClassName != -1 && !aAddInName.isEmpty() )
                 [ -  + ]
     139                 :            :     {
     140         [ #  # ]:          0 :         GetTransformer().AddNamespacePrefix( aAddInName, XML_NAMESPACE_OOO );
     141         [ #  # ]:          0 :         pMutableAttrList->SetValueByIndex( nClassName, aAddInName );
     142                 :            :     }
     143                 :            : 
     144         [ +  - ]:          6 :     XMLTransformerContext::StartElement( xAttrList );
     145                 :          6 : }
     146                 :            : 
     147                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10