LCOV - code coverage report
Current view: top level - oox/source/drawingml - themeelementscontext.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 68 72 94.4 %
Date: 2014-04-11 Functions: 21 21 100.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 "oox/drawingml/themeelementscontext.hxx"
      21             : #include "oox/drawingml/clrschemecontext.hxx"
      22             : #include "oox/drawingml/lineproperties.hxx"
      23             : #include "oox/drawingml/linepropertiescontext.hxx"
      24             : #include "oox/drawingml/effectproperties.hxx"
      25             : #include "oox/drawingml/effectpropertiescontext.hxx"
      26             : #include "oox/drawingml/fillproperties.hxx"
      27             : #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
      28             : #include "oox/drawingml/theme.hxx"
      29             : #include "oox/helper/attributelist.hxx"
      30             : 
      31             : using namespace ::oox::core;
      32             : using namespace ::com::sun::star::uno;
      33             : using namespace ::com::sun::star::xml::sax;
      34             : 
      35             : namespace oox {
      36             : namespace drawingml {
      37             : 
      38             : 
      39             : 
      40        3272 : class FillStyleListContext : public ContextHandler2
      41             : {
      42             : public:
      43             :     FillStyleListContext( ContextHandler2Helper& rParent, FillStyleList& rFillStyleList );
      44             :     virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
      45             : 
      46             : private:
      47             :     FillStyleList& mrFillStyleList;
      48             : };
      49             : 
      50        1636 : FillStyleListContext::FillStyleListContext( ContextHandler2Helper& rParent, FillStyleList& rFillStyleList ) :
      51             :     ContextHandler2( rParent ),
      52        1636 :     mrFillStyleList( rFillStyleList )
      53             : {
      54        1636 : }
      55             : 
      56        4908 : ContextHandlerRef FillStyleListContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      57             : {
      58        4908 :     switch( nElement )
      59             :     {
      60             :         case A_TOKEN( noFill ):
      61             :         case A_TOKEN( solidFill ):
      62             :         case A_TOKEN( gradFill ):
      63             :         case A_TOKEN( blipFill ):
      64             :         case A_TOKEN( pattFill ):
      65             :         case A_TOKEN( grpFill ):
      66        4908 :             mrFillStyleList.push_back( FillPropertiesPtr( new FillProperties ) );
      67        4908 :             return FillPropertiesContext::createFillContext( *this, nElement, rAttribs, *mrFillStyleList.back() );
      68             :     }
      69           0 :     return 0;
      70             : }
      71             : 
      72             : 
      73             : 
      74        1636 : class LineStyleListContext : public ContextHandler2
      75             : {
      76             : public:
      77             :     LineStyleListContext( ContextHandler2Helper& rParent, LineStyleList& rLineStyleList );
      78             :     virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
      79             : 
      80             : private:
      81             :     LineStyleList& mrLineStyleList;
      82             : };
      83             : 
      84         818 : LineStyleListContext::LineStyleListContext( ContextHandler2Helper& rParent, LineStyleList& rLineStyleList ) :
      85             :     ContextHandler2( rParent ),
      86         818 :     mrLineStyleList( rLineStyleList )
      87             : {
      88         818 : }
      89             : 
      90        2454 : ContextHandlerRef LineStyleListContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      91             : {
      92        2454 :     switch( nElement )
      93             :     {
      94             :         case A_TOKEN( ln ):
      95        2454 :             mrLineStyleList.push_back( LinePropertiesPtr( new LineProperties ) );
      96        2454 :             return new LinePropertiesContext( *this, rAttribs, *mrLineStyleList.back() );
      97             :     }
      98           0 :     return 0;
      99             : }
     100             : 
     101             : 
     102             : 
     103        1636 : class EffectStyleListContext : public ContextHandler2
     104             : {
     105             : public:
     106             :     EffectStyleListContext( ContextHandler2Helper& rParent, EffectStyleList& rEffectStyleList );
     107             :     virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
     108             : 
     109             : private:
     110             :     EffectStyleList& mrEffectStyleList;
     111             : };
     112             : 
     113         818 : EffectStyleListContext::EffectStyleListContext( ContextHandler2Helper& rParent, EffectStyleList& rEffectStyleList ) :
     114             :     ContextHandler2( rParent ),
     115         818 :     mrEffectStyleList( rEffectStyleList )
     116             : {
     117         818 : }
     118             : 
     119        6416 : ContextHandlerRef EffectStyleListContext::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
     120             : {
     121        6416 :     switch( nElement )
     122             :     {
     123             :         case A_TOKEN( effectStyle ):
     124        2454 :             mrEffectStyleList.push_back( EffectPropertiesPtr( new EffectProperties ) );
     125        2454 :             return this;
     126             : 
     127             :         case A_TOKEN( effectLst ):  // CT_EffectList
     128        2454 :             if( mrEffectStyleList.back() )
     129        2454 :                 return new EffectPropertiesContext( *this, *mrEffectStyleList.back() );
     130           0 :             break;
     131             :     }
     132        1508 :     return 0;
     133             : }
     134             : 
     135             : 
     136             : 
     137        1636 : class FontSchemeContext : public ContextHandler2
     138             : {
     139             : public:
     140             :     FontSchemeContext( ContextHandler2Helper& rParent, FontScheme& rFontScheme );
     141             :     virtual ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) SAL_OVERRIDE;
     142             :     virtual void onEndElement() SAL_OVERRIDE;
     143             : 
     144             : private:
     145             :     FontScheme& mrFontScheme;
     146             :     TextCharacterPropertiesPtr mxCharProps;
     147             : };
     148             : 
     149         818 : FontSchemeContext::FontSchemeContext( ContextHandler2Helper& rParent, FontScheme& rFontScheme ) :
     150             :     ContextHandler2( rParent ),
     151         818 :     mrFontScheme( rFontScheme )
     152             : {
     153         818 : }
     154             : 
     155       54578 : ContextHandlerRef FontSchemeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     156             : {
     157       54578 :     switch( nElement )
     158             :     {
     159             :         case A_TOKEN( majorFont ):
     160         818 :             mxCharProps.reset( new TextCharacterProperties );
     161         818 :             mrFontScheme[ XML_major ] = mxCharProps;
     162         818 :             return this;
     163             :         case A_TOKEN( minorFont ):
     164         818 :             mxCharProps.reset( new TextCharacterProperties );
     165         818 :             mrFontScheme[ XML_minor ] = mxCharProps;
     166         818 :             return this;
     167             : 
     168             :         case A_TOKEN( latin ):
     169        1636 :             if( mxCharProps.get() )
     170        1636 :                 mxCharProps->maLatinFont.setAttributes( rAttribs );
     171        1636 :         break;
     172             :         case A_TOKEN( ea ):
     173        1636 :             if( mxCharProps.get() )
     174        1636 :                 mxCharProps->maAsianFont.setAttributes( rAttribs );
     175        1636 :         break;
     176             :         case A_TOKEN( cs ):
     177        1636 :             if( mxCharProps.get() )
     178        1636 :                 mxCharProps->maComplexFont.setAttributes( rAttribs );
     179        1636 :         break;
     180             :     }
     181       52942 :     return 0;
     182             : }
     183             : 
     184        2454 : void FontSchemeContext::onEndElement()
     185             : {
     186        2454 :     switch( getCurrentElement() )
     187             :     {
     188             :         case A_TOKEN( majorFont ):
     189             :         case A_TOKEN( minorFont ):
     190        1636 :             mxCharProps.reset();
     191        1636 :         break;
     192             :     }
     193        2454 : }
     194             : 
     195             : 
     196             : 
     197         818 : ThemeElementsContext::ThemeElementsContext( ContextHandler2Helper& rParent, Theme& rTheme ) :
     198             :     ContextHandler2( rParent ),
     199         818 :     mrTheme( rTheme )
     200             : {
     201         818 : }
     202             : 
     203        5726 : ContextHandlerRef ThemeElementsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     204             : {
     205             :     // CT_BaseStyles
     206        5726 :     switch( nElement )
     207             :     {
     208             :         case A_TOKEN( clrScheme ):  // CT_ColorScheme
     209         818 :             return new clrSchemeContext( *this, mrTheme.getClrScheme() );
     210             :         case A_TOKEN( fontScheme ): // CT_FontScheme
     211         818 :             return new FontSchemeContext( *this, mrTheme.getFontScheme() );
     212             : 
     213             :         case A_TOKEN( fmtScheme ):  // CT_StyleMatrix
     214         818 :             mrTheme.setStyleName( rAttribs.getString( XML_name ).get() );
     215         818 :             return this;
     216             : 
     217             :         case A_TOKEN( fillStyleLst ):   // CT_FillStyleList
     218         818 :             return new FillStyleListContext( *this, mrTheme.getFillStyleList() );
     219             :         case A_TOKEN( lnStyleLst ):    // CT_LineStyleList
     220         818 :             return new LineStyleListContext( *this, mrTheme.getLineStyleList() );
     221             :         case A_TOKEN( effectStyleLst ): // CT_EffectStyleList
     222         818 :             return new EffectStyleListContext( *this, mrTheme.getEffectStyleList() );
     223             :         case A_TOKEN( bgFillStyleLst ): // CT_BackgroundFillStyleList
     224         818 :             return new FillStyleListContext( *this, mrTheme.getBgFillStyleList() );
     225             :     }
     226           0 :     return 0;
     227             : }
     228             : 
     229             : 
     230             : 
     231             : } // namespace drawingml
     232         177 : } // namespace oox
     233             : 
     234             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10