LCOV - code coverage report
Current view: top level - xmloff/source/chart - XMLChartStyleContext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 44 48 91.7 %
Date: 2012-08-25 Functions: 10 12 83.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 30 54 55.6 %

           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 "XMLChartStyleContext.hxx"
      30                 :            : #include <xmloff/xmltoken.hxx>
      31                 :            : #include "xmloff/xmlnmspe.hxx"
      32                 :            : #include <xmloff/xmlnumfi.hxx>
      33                 :            : #include <xmloff/families.hxx>
      34                 :            : 
      35                 :            : #include "XMLChartPropertyContext.hxx"
      36                 :            : 
      37                 :            : using namespace com::sun::star;
      38                 :            : using ::xmloff::token::IsXMLToken;
      39                 :            : using ::xmloff::token::XML_DATA_STYLE_NAME;
      40                 :            : using ::xmloff::token::XML_PERCENTAGE_DATA_STYLE_NAME;
      41                 :            : using ::xmloff::token::XML_TEXT_PROPERTIES;
      42                 :            : using ::xmloff::token::XML_PARAGRAPH_PROPERTIES;
      43                 :            : using ::xmloff::token::XML_GRAPHIC_PROPERTIES;
      44                 :            : using ::xmloff::token::XML_CHART_PROPERTIES;
      45                 :            : 
      46                 :            : 
      47 [ -  + ][ +  - ]:        180 : TYPEINIT1( XMLChartStyleContext, XMLPropStyleContext );
      48                 :            : 
      49                 :            : // protected
      50                 :            : 
      51                 :        168 : void XMLChartStyleContext::SetAttribute(
      52                 :            :     sal_uInt16 nPrefixKey,
      53                 :            :     const ::rtl::OUString& rLocalName,
      54                 :            :     const ::rtl::OUString& rValue )
      55                 :            : {
      56         [ +  + ]:        168 :     if( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
      57                 :            :     {
      58                 :         12 :         msDataStyleName =rValue;
      59                 :            :     }
      60         [ -  + ]:        156 :     else if( IsXMLToken( rLocalName, XML_PERCENTAGE_DATA_STYLE_NAME ) )
      61                 :            :     {
      62                 :          0 :         msPercentageDataStyleName =rValue;
      63                 :            :     }
      64                 :            :     else
      65                 :            :     {
      66                 :        156 :         XMLShapeStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
      67                 :            :     }
      68                 :        168 : }
      69                 :            : 
      70                 :            : //public
      71                 :            : 
      72                 :            : // CTOR
      73                 :         78 : XMLChartStyleContext::XMLChartStyleContext(
      74                 :            :     SvXMLImport& rImport, sal_uInt16 nPrfx,
      75                 :            :     const ::rtl::OUString& rLName,
      76                 :            :     const uno::Reference< xml::sax::XAttributeList > & xAttrList,
      77                 :            :     SvXMLStylesContext& rStyles, sal_uInt16 nFamily ) :
      78                 :            : 
      79                 :            :         XMLShapeStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily ),
      80                 :         78 :         mrStyles( rStyles )
      81                 :         78 : {}
      82                 :            : 
      83                 :            : // DTOR
      84                 :         78 : XMLChartStyleContext::~XMLChartStyleContext()
      85         [ -  + ]:        156 : {}
      86                 :            : 
      87                 :            : namespace
      88                 :            : {
      89                 :            : 
      90                 :        168 :     void lcl_NumberFormatStyleToProperty( const ::rtl::OUString& rStyleName, const ::rtl::OUString& rPropertyName,
      91                 :            :                                       const SvXMLStylesContext& rStylesContext,
      92                 :            :                                       const uno::Reference< beans::XPropertySet >& rPropSet )
      93                 :            : {
      94         [ +  + ]:        168 :     if( !rStyleName.isEmpty())
      95                 :            :     {
      96                 :            :         SvXMLNumFormatContext* pStyle = (SvXMLNumFormatContext *)rStylesContext.FindStyleChildContext(
      97                 :         12 :             XML_STYLE_FAMILY_DATA_STYLE, rStyleName, sal_True );
      98         [ +  - ]:         12 :         if( pStyle )
      99                 :            :         {
     100                 :         12 :             uno::Any aNumberFormat;
     101         [ +  - ]:         12 :             sal_Int32 nNumberFormat = pStyle->GetKey();
     102         [ +  - ]:         12 :             aNumberFormat <<= nNumberFormat;
     103 [ +  - ][ +  - ]:         12 :             rPropSet->setPropertyValue( rPropertyName, aNumberFormat );
     104                 :            :         }
     105                 :            :     }
     106                 :        168 : }
     107                 :            : 
     108                 :            : }// anonymous namespace
     109                 :            : 
     110                 :         84 : void XMLChartStyleContext::FillPropertySet(
     111                 :            :     const uno::Reference< beans::XPropertySet > & rPropSet )
     112                 :            : {
     113                 :            :     try
     114                 :            :     {
     115         [ +  - ]:         84 :         XMLShapeStyleContext::FillPropertySet( rPropSet );
     116                 :            :     }
     117                 :          0 :     catch( beans::UnknownPropertyException&  )
     118                 :            :     {
     119                 :            :         DBG_ASSERT( false, "unknown property exception -> shape style not completly imported for chart style" );
     120                 :            :     }
     121                 :            : 
     122         [ +  - ]:         84 :     lcl_NumberFormatStyleToProperty( msDataStyleName, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NumberFormat" )), mrStyles, rPropSet );
     123         [ +  - ]:         84 :     lcl_NumberFormatStyleToProperty( msPercentageDataStyleName, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PercentageNumberFormat" )), mrStyles, rPropSet );
     124         [ #  # ]:         84 : }
     125                 :            : 
     126                 :        168 : SvXMLImportContext *XMLChartStyleContext::CreateChildContext(
     127                 :            :     sal_uInt16 nPrefix,
     128                 :            :     const ::rtl::OUString& rLocalName,
     129                 :            :     const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     130                 :            : {
     131                 :        168 :     SvXMLImportContext* pContext = NULL;
     132                 :            : 
     133         [ +  - ]:        168 :     if( XML_NAMESPACE_STYLE == nPrefix )
     134                 :            :     {
     135                 :        168 :         sal_uInt32 nFamily = 0;
     136         [ +  + ]:        168 :         if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
     137                 :         48 :             nFamily = XML_TYPE_PROP_TEXT;
     138         [ -  + ]:        120 :         else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
     139                 :          0 :             nFamily = XML_TYPE_PROP_PARAGRAPH;
     140         [ +  + ]:        120 :         else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
     141                 :         72 :             nFamily = XML_TYPE_PROP_GRAPHIC;
     142         [ +  - ]:         48 :         else if( IsXMLToken( rLocalName, XML_CHART_PROPERTIES ) )
     143                 :         48 :             nFamily = XML_TYPE_PROP_CHART;
     144         [ +  - ]:        168 :         if( nFamily )
     145                 :            :         {
     146                 :            :             UniReference < SvXMLImportPropertyMapper > xImpPrMap =
     147         [ +  - ]:        168 :                 GetStyles()->GetImportPropertyMapper( GetFamily() );
     148         [ +  - ]:        168 :             if( xImpPrMap.is() )
     149                 :            :                 pContext = new XMLChartPropertyContext(
     150                 :        168 :                     GetImport(), nPrefix, rLocalName, xAttrList, nFamily,
     151 [ +  - ][ +  - ]:        168 :                     GetProperties(), xImpPrMap );
                 [ +  - ]
     152                 :            :         }
     153                 :            :     }
     154                 :            : 
     155         [ -  + ]:        168 :     if( !pContext )
     156                 :            :         pContext = XMLShapeStyleContext::CreateChildContext( nPrefix, rLocalName,
     157                 :          0 :                                                              xAttrList );
     158                 :            : 
     159                 :        168 :     return pContext;
     160                 :            : }
     161                 :            : 
     162                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10