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

Generated by: LCOV version 1.11