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

Generated by: LCOV version 1.10