LCOV - code coverage report
Current view: top level - xmloff/source/chart - XMLChartStyleContext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 45 48 93.8 %
Date: 2014-11-03 Functions: 10 12 83.3 %
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 "XMLChartStyleContext.hxx"
      21             : #include <xmloff/xmltoken.hxx>
      22             : #include <xmloff/xmlnmspe.hxx>
      23             : #include <xmloff/xmlnumfi.hxx>
      24             : #include <xmloff/families.hxx>
      25             : #include <xmloff/xmltypes.hxx>
      26             : #include <tools/debug.hxx>
      27             : 
      28             : #include "XMLChartPropertyContext.hxx"
      29             : 
      30             : using namespace com::sun::star;
      31             : using ::xmloff::token::IsXMLToken;
      32             : using ::xmloff::token::XML_DATA_STYLE_NAME;
      33             : using ::xmloff::token::XML_PERCENTAGE_DATA_STYLE_NAME;
      34             : using ::xmloff::token::XML_TEXT_PROPERTIES;
      35             : using ::xmloff::token::XML_PARAGRAPH_PROPERTIES;
      36             : using ::xmloff::token::XML_GRAPHIC_PROPERTIES;
      37             : using ::xmloff::token::XML_CHART_PROPERTIES;
      38             : 
      39             : 
      40        5676 : TYPEINIT1( XMLChartStyleContext, XMLPropStyleContext );
      41             : 
      42        6322 : void XMLChartStyleContext::SetAttribute(
      43             :     sal_uInt16 nPrefixKey,
      44             :     const OUString& rLocalName,
      45             :     const OUString& rValue )
      46             : {
      47        6322 :     if( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
      48             :     {
      49        1004 :         msDataStyleName =rValue;
      50             :     }
      51        5318 :     else if( IsXMLToken( rLocalName, XML_PERCENTAGE_DATA_STYLE_NAME ) )
      52             :     {
      53           2 :         msPercentageDataStyleName =rValue;
      54             :     }
      55             :     else
      56             :     {
      57        5316 :         XMLShapeStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
      58             :     }
      59        6322 : }
      60             : 
      61        2658 : XMLChartStyleContext::XMLChartStyleContext(
      62             :     SvXMLImport& rImport, sal_uInt16 nPrfx,
      63             :     const OUString& rLName,
      64             :     const uno::Reference< xml::sax::XAttributeList > & xAttrList,
      65             :     SvXMLStylesContext& rStyles, sal_uInt16 nFamily ) :
      66             : 
      67             :         XMLShapeStyleContext( rImport, nPrfx, rLName, xAttrList, rStyles, nFamily ),
      68        2658 :         mrStyles( rStyles )
      69        2658 : {}
      70             : 
      71        5316 : XMLChartStyleContext::~XMLChartStyleContext()
      72        5316 : {}
      73             : 
      74             : namespace
      75             : {
      76             : 
      77        5800 : void lcl_NumberFormatStyleToProperty( const OUString& rStyleName, const OUString& rPropertyName,
      78             :         const SvXMLStylesContext& rStylesContext,
      79             :         const uno::Reference< beans::XPropertySet >& rPropSet )
      80             : {
      81        5800 :     if( !rStyleName.isEmpty())
      82             :     {
      83             :         const SvXMLNumFormatContext* pStyle = static_cast<const SvXMLNumFormatContext *>(rStylesContext.FindStyleChildContext(
      84        1098 :             XML_STYLE_FAMILY_DATA_STYLE, rStyleName, true ));
      85        1098 :         if( pStyle )
      86             :         {
      87        1098 :             uno::Any aNumberFormat;
      88        1098 :             sal_Int32 nNumberFormat = const_cast<SvXMLNumFormatContext*>(pStyle)->GetKey();
      89        1098 :             aNumberFormat <<= nNumberFormat;
      90        1098 :             rPropSet->setPropertyValue( rPropertyName, aNumberFormat );
      91             :         }
      92             :     }
      93        5800 : }
      94             : 
      95             : }
      96             : 
      97        2900 : void XMLChartStyleContext::FillPropertySet(
      98             :     const uno::Reference< beans::XPropertySet > & rPropSet )
      99             : {
     100             :     try
     101             :     {
     102        2900 :         XMLShapeStyleContext::FillPropertySet( rPropSet );
     103             :     }
     104           0 :     catch( beans::UnknownPropertyException&  )
     105             :     {
     106             :         DBG_ASSERT( false, "unknown property exception -> shape style not completely imported for chart style" );
     107             :     }
     108             : 
     109        2900 :     lcl_NumberFormatStyleToProperty( msDataStyleName, OUString( "NumberFormat" ), mrStyles, rPropSet );
     110        2900 :     lcl_NumberFormatStyleToProperty( msPercentageDataStyleName, OUString( "PercentageNumberFormat" ), mrStyles, rPropSet );
     111        2900 : }
     112             : 
     113        5288 : SvXMLImportContext *XMLChartStyleContext::CreateChildContext(
     114             :     sal_uInt16 nPrefix,
     115             :     const OUString& rLocalName,
     116             :     const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     117             : {
     118        5288 :     SvXMLImportContext* pContext = NULL;
     119             : 
     120        5288 :     if( XML_NAMESPACE_STYLE == nPrefix || XML_NAMESPACE_LO_EXT == nPrefix )
     121             :     {
     122        5288 :         sal_uInt32 nFamily = 0;
     123        5288 :         if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
     124        1320 :             nFamily = XML_TYPE_PROP_TEXT;
     125        3968 :         else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
     126           0 :             nFamily = XML_TYPE_PROP_PARAGRAPH;
     127        3968 :         else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
     128        2294 :             nFamily = XML_TYPE_PROP_GRAPHIC;
     129        1674 :         else if( IsXMLToken( rLocalName, XML_CHART_PROPERTIES ) )
     130        1674 :             nFamily = XML_TYPE_PROP_CHART;
     131        5288 :         if( nFamily )
     132             :         {
     133             :             rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap =
     134        5288 :                 GetStyles()->GetImportPropertyMapper( GetFamily() );
     135        5288 :             if( xImpPrMap.is() )
     136             :                 pContext = new XMLChartPropertyContext(
     137        5288 :                     GetImport(), nPrefix, rLocalName, xAttrList, nFamily,
     138        5288 :                     GetProperties(), xImpPrMap );
     139             :         }
     140             :     }
     141             : 
     142        5288 :     if( !pContext )
     143             :         pContext = XMLShapeStyleContext::CreateChildContext( nPrefix, rLocalName,
     144           0 :                                                              xAttrList );
     145             : 
     146        5288 :     return pContext;
     147             : }
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10