LCOV - code coverage report
Current view: top level - oox/source/drawingml - themeelementscontext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 68 72 94.4 %
Date: 2014-11-03 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       10280 : 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        5140 : FillStyleListContext::FillStyleListContext( ContextHandler2Helper& rParent, FillStyleList& rFillStyleList ) :
      50             :     ContextHandler2( rParent ),
      51        5140 :     mrFillStyleList( rFillStyleList )
      52             : {
      53        5140 : }
      54             : 
      55       15420 : ContextHandlerRef FillStyleListContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      56             : {
      57       15420 :     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       15420 :             mrFillStyleList.push_back( FillPropertiesPtr( new FillProperties ) );
      66       15420 :             return FillPropertiesContext::createFillContext( *this, nElement, rAttribs, *mrFillStyleList.back() );
      67             :     }
      68           0 :     return 0;
      69             : }
      70             : 
      71        5140 : 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        2570 : LineStyleListContext::LineStyleListContext( ContextHandler2Helper& rParent, LineStyleList& rLineStyleList ) :
      82             :     ContextHandler2( rParent ),
      83        2570 :     mrLineStyleList( rLineStyleList )
      84             : {
      85        2570 : }
      86             : 
      87        7710 : ContextHandlerRef LineStyleListContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      88             : {
      89        7710 :     switch( nElement )
      90             :     {
      91             :         case A_TOKEN( ln ):
      92        7710 :             mrLineStyleList.push_back( LinePropertiesPtr( new LineProperties ) );
      93        7710 :             return new LinePropertiesContext( *this, rAttribs, *mrLineStyleList.back() );
      94             :     }
      95           0 :     return 0;
      96             : }
      97             : 
      98        5140 : 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        2570 : EffectStyleListContext::EffectStyleListContext( ContextHandler2Helper& rParent, EffectStyleList& rEffectStyleList ) :
     109             :     ContextHandler2( rParent ),
     110        2570 :     mrEffectStyleList( rEffectStyleList )
     111             : {
     112        2570 : }
     113             : 
     114       20176 : ContextHandlerRef EffectStyleListContext::onCreateContext( sal_Int32 nElement, const AttributeList& /*rAttribs*/ )
     115             : {
     116       20176 :     switch( nElement )
     117             :     {
     118             :         case A_TOKEN( effectStyle ):
     119        7710 :             mrEffectStyleList.push_back( EffectPropertiesPtr( new EffectProperties ) );
     120        7710 :             return this;
     121             : 
     122             :         case A_TOKEN( effectLst ):  // CT_EffectList
     123        7710 :             if( mrEffectStyleList.back() )
     124        7710 :                 return new EffectPropertiesContext( *this, *mrEffectStyleList.back() );
     125           0 :             break;
     126             :     }
     127        4756 :     return 0;
     128             : }
     129             : 
     130        5140 : 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        2570 : FontSchemeContext::FontSchemeContext( ContextHandler2Helper& rParent, FontScheme& rFontScheme ) :
     143             :     ContextHandler2( rParent ),
     144        2570 :     mrFontScheme( rFontScheme )
     145             : {
     146        2570 : }
     147             : 
     148      171284 : ContextHandlerRef FontSchemeContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     149             : {
     150      171284 :     switch( nElement )
     151             :     {
     152             :         case A_TOKEN( majorFont ):
     153        2570 :             mxCharProps.reset( new TextCharacterProperties );
     154        2570 :             mrFontScheme[ XML_major ] = mxCharProps;
     155        2570 :             return this;
     156             :         case A_TOKEN( minorFont ):
     157        2570 :             mxCharProps.reset( new TextCharacterProperties );
     158        2570 :             mrFontScheme[ XML_minor ] = mxCharProps;
     159        2570 :             return this;
     160             : 
     161             :         case A_TOKEN( latin ):
     162        5140 :             if( mxCharProps.get() )
     163        5140 :                 mxCharProps->maLatinFont.setAttributes( rAttribs );
     164        5140 :         break;
     165             :         case A_TOKEN( ea ):
     166        5140 :             if( mxCharProps.get() )
     167        5140 :                 mxCharProps->maAsianFont.setAttributes( rAttribs );
     168        5140 :         break;
     169             :         case A_TOKEN( cs ):
     170        5140 :             if( mxCharProps.get() )
     171        5140 :                 mxCharProps->maComplexFont.setAttributes( rAttribs );
     172        5140 :         break;
     173             :     }
     174      166144 :     return 0;
     175             : }
     176             : 
     177        7710 : void FontSchemeContext::onEndElement()
     178             : {
     179        7710 :     switch( getCurrentElement() )
     180             :     {
     181             :         case A_TOKEN( majorFont ):
     182             :         case A_TOKEN( minorFont ):
     183        5140 :             mxCharProps.reset();
     184        5140 :         break;
     185             :     }
     186        7710 : }
     187             : 
     188        2570 : ThemeElementsContext::ThemeElementsContext( ContextHandler2Helper& rParent, Theme& rTheme ) :
     189             :     ContextHandler2( rParent ),
     190        2570 :     mrTheme( rTheme )
     191             : {
     192        2570 : }
     193             : 
     194       17990 : ContextHandlerRef ThemeElementsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     195             : {
     196             :     // CT_BaseStyles
     197       17990 :     switch( nElement )
     198             :     {
     199             :         case A_TOKEN( clrScheme ):  // CT_ColorScheme
     200        2570 :             return new clrSchemeContext( *this, mrTheme.getClrScheme() );
     201             :         case A_TOKEN( fontScheme ): // CT_FontScheme
     202        2570 :             return new FontSchemeContext( *this, mrTheme.getFontScheme() );
     203             : 
     204             :         case A_TOKEN( fmtScheme ):  // CT_StyleMatrix
     205        2570 :             mrTheme.setStyleName( rAttribs.getString( XML_name ).get() );
     206        2570 :             return this;
     207             : 
     208             :         case A_TOKEN( fillStyleLst ):   // CT_FillStyleList
     209        2570 :             return new FillStyleListContext( *this, mrTheme.getFillStyleList() );
     210             :         case A_TOKEN( lnStyleLst ):    // CT_LineStyleList
     211        2570 :             return new LineStyleListContext( *this, mrTheme.getLineStyleList() );
     212             :         case A_TOKEN( effectStyleLst ): // CT_EffectStyleList
     213        2570 :             return new EffectStyleListContext( *this, mrTheme.getEffectStyleList() );
     214             :         case A_TOKEN( bgFillStyleLst ): // CT_BackgroundFillStyleList
     215        2570 :             return new FillStyleListContext( *this, mrTheme.getBgFillStyleList() );
     216             :     }
     217           0 :     return 0;
     218             : }
     219             : 
     220             : } // namespace drawingml
     221         408 : } // namespace oox
     222             : 
     223             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10