LCOV - code coverage report
Current view: top level - xmloff/source/chart - XMLChartStyleContext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 45 48 93.8 %
Date: 2015-06-13 12:38:46 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        1965 : TYPEINIT1( XMLChartStyleContext, XMLPropStyleContext );
      41             : 
      42        2151 : void XMLChartStyleContext::SetAttribute(
      43             :     sal_uInt16 nPrefixKey,
      44             :     const OUString& rLocalName,
      45             :     const OUString& rValue )
      46             : {
      47        2151 :     if( IsXMLToken( rLocalName, XML_DATA_STYLE_NAME ) )
      48             :     {
      49         318 :         msDataStyleName =rValue;
      50             :     }
      51        1833 :     else if( IsXMLToken( rLocalName, XML_PERCENTAGE_DATA_STYLE_NAME ) )
      52             :     {
      53           1 :         msPercentageDataStyleName =rValue;
      54             :     }
      55             :     else
      56             :     {
      57        1832 :         XMLShapeStyleContext::SetAttribute( nPrefixKey, rLocalName, rValue );
      58             :     }
      59        2151 : }
      60             : 
      61         916 : 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         916 :         mrStyles( rStyles )
      69         916 : {}
      70             : 
      71        1832 : XMLChartStyleContext::~XMLChartStyleContext()
      72        1832 : {}
      73             : 
      74             : namespace
      75             : {
      76             : 
      77        1994 : void lcl_NumberFormatStyleToProperty( const OUString& rStyleName, const OUString& rPropertyName,
      78             :         const SvXMLStylesContext& rStylesContext,
      79             :         const uno::Reference< beans::XPropertySet >& rPropSet )
      80             : {
      81        1994 :     if( !rStyleName.isEmpty())
      82             :     {
      83             :         const SvXMLNumFormatContext* pStyle = static_cast<const SvXMLNumFormatContext *>(rStylesContext.FindStyleChildContext(
      84         358 :             XML_STYLE_FAMILY_DATA_STYLE, rStyleName, true ));
      85         358 :         if( pStyle )
      86             :         {
      87         358 :             uno::Any aNumberFormat;
      88         358 :             sal_Int32 nNumberFormat = const_cast<SvXMLNumFormatContext*>(pStyle)->GetKey();
      89         358 :             aNumberFormat <<= nNumberFormat;
      90         358 :             rPropSet->setPropertyValue( rPropertyName, aNumberFormat );
      91             :         }
      92             :     }
      93        1994 : }
      94             : 
      95             : }
      96             : 
      97         997 : void XMLChartStyleContext::FillPropertySet(
      98             :     const uno::Reference< beans::XPropertySet > & rPropSet )
      99             : {
     100             :     try
     101             :     {
     102         997 :         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         997 :     lcl_NumberFormatStyleToProperty( msDataStyleName, OUString( "NumberFormat" ), mrStyles, rPropSet );
     110         997 :     lcl_NumberFormatStyleToProperty( msPercentageDataStyleName, OUString( "PercentageNumberFormat" ), mrStyles, rPropSet );
     111         997 : }
     112             : 
     113        1761 : SvXMLImportContext *XMLChartStyleContext::CreateChildContext(
     114             :     sal_uInt16 nPrefix,
     115             :     const OUString& rLocalName,
     116             :     const uno::Reference< xml::sax::XAttributeList > & xAttrList )
     117             : {
     118        1761 :     SvXMLImportContext* pContext = NULL;
     119             : 
     120        1761 :     if( XML_NAMESPACE_STYLE == nPrefix || XML_NAMESPACE_LO_EXT == nPrefix )
     121             :     {
     122        1761 :         sal_uInt32 nFamily = 0;
     123        1761 :         if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
     124         441 :             nFamily = XML_TYPE_PROP_TEXT;
     125        1320 :         else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
     126           0 :             nFamily = XML_TYPE_PROP_PARAGRAPH;
     127        1320 :         else if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
     128         772 :             nFamily = XML_TYPE_PROP_GRAPHIC;
     129         548 :         else if( IsXMLToken( rLocalName, XML_CHART_PROPERTIES ) )
     130         548 :             nFamily = XML_TYPE_PROP_CHART;
     131        1761 :         if( nFamily )
     132             :         {
     133             :             rtl::Reference < SvXMLImportPropertyMapper > xImpPrMap =
     134        1761 :                 GetStyles()->GetImportPropertyMapper( GetFamily() );
     135        1761 :             if( xImpPrMap.is() )
     136             :                 pContext = new XMLChartPropertyContext(
     137        1761 :                     GetImport(), nPrefix, rLocalName, xAttrList, nFamily,
     138        1761 :                     GetProperties(), xImpPrMap );
     139             :         }
     140             :     }
     141             : 
     142        1761 :     if( !pContext )
     143             :         pContext = XMLShapeStyleContext::CreateChildContext( nPrefix, rLocalName,
     144           0 :                                                              xAttrList );
     145             : 
     146        1761 :     return pContext;
     147             : }
     148             : 
     149             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11