LCOV - code coverage report
Current view: top level - libreoffice/oox/source/drawingml - themeelementscontext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 70 74 94.6 %
Date: 2012-12-27 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          36 : class FillStyleListContext : public ContextHandler
      41             : {
      42             : public:
      43             :     FillStyleListContext( ContextHandler& rParent, FillStyleList& rFillStyleList );
      44             :     virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& Attribs ) throw (SAXException, RuntimeException);
      45             : 
      46             : private:
      47             :     FillStyleList& mrFillStyleList;
      48             : };
      49             : 
      50          18 : FillStyleListContext::FillStyleListContext( ContextHandler& rParent, FillStyleList& rFillStyleList ) :
      51             :     ContextHandler( rParent ),
      52          18 :     mrFillStyleList( rFillStyleList )
      53             : {
      54          18 : }
      55             : 
      56          54 : Reference< XFastContextHandler > FillStyleListContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttribs )
      57             :     throw (SAXException, RuntimeException)
      58             : {
      59          54 :     switch( nElement )
      60             :     {
      61             :         case A_TOKEN( noFill ):
      62             :         case A_TOKEN( solidFill ):
      63             :         case A_TOKEN( gradFill ):
      64             :         case A_TOKEN( blipFill ):
      65             :         case A_TOKEN( pattFill ):
      66             :         case A_TOKEN( grpFill ):
      67          54 :             mrFillStyleList.push_back( FillPropertiesPtr( new FillProperties ) );
      68          54 :             return FillPropertiesContext::createFillContext( *this, nElement, xAttribs, *mrFillStyleList.back() );
      69             :     }
      70           0 :     return 0;
      71             : }
      72             : 
      73             : // ============================================================================
      74             : 
      75          18 : class LineStyleListContext : public ContextHandler
      76             : {
      77             : public:
      78             :     LineStyleListContext( ContextHandler& rParent, LineStyleList& rLineStyleList );
      79             :     virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& Attribs ) throw (SAXException, RuntimeException);
      80             : 
      81             : private:
      82             :     LineStyleList& mrLineStyleList;
      83             : };
      84             : 
      85           9 : LineStyleListContext::LineStyleListContext( ContextHandler& rParent, LineStyleList& rLineStyleList ) :
      86             :     ContextHandler( rParent ),
      87           9 :     mrLineStyleList( rLineStyleList )
      88             : {
      89           9 : }
      90             : 
      91          27 : Reference< XFastContextHandler > LineStyleListContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttribs )
      92             :     throw (SAXException, RuntimeException)
      93             : {
      94          27 :     switch( nElement )
      95             :     {
      96             :         case A_TOKEN( ln ):
      97          27 :             mrLineStyleList.push_back( LinePropertiesPtr( new LineProperties ) );
      98          27 :             return new LinePropertiesContext( *this, xAttribs, *mrLineStyleList.back() );
      99             :     }
     100           0 :     return 0;
     101             : }
     102             : 
     103             : // ============================================================================
     104             : 
     105          18 : class EffectStyleListContext : public ContextHandler
     106             : {
     107             : public:
     108             :     EffectStyleListContext( ContextHandler& rParent, EffectStyleList& rEffectStyleList );
     109             :     virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& Attribs ) throw (SAXException, RuntimeException);
     110             : 
     111             : private:
     112             :     EffectStyleList& mrEffectStyleList;
     113             : };
     114             : 
     115           9 : EffectStyleListContext::EffectStyleListContext( ContextHandler& rParent, EffectStyleList& rEffectStyleList ) :
     116             :     ContextHandler( rParent ),
     117           9 :     mrEffectStyleList( rEffectStyleList )
     118             : {
     119           9 : }
     120             : 
     121          68 : Reference< XFastContextHandler > EffectStyleListContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& /*xAttribs*/ ) throw (SAXException, RuntimeException)
     122             : {
     123          68 :     switch( nElement )
     124             :     {
     125             :         case A_TOKEN( effectStyle ):
     126          27 :             mrEffectStyleList.push_back( EffectPropertiesPtr( new EffectProperties ) );
     127          27 :             return this;
     128             : 
     129             :         case A_TOKEN( effectLst ):  // CT_EffectList
     130          27 :             if( mrEffectStyleList.back() )
     131          27 :                 return new EffectPropertiesContext( *this, *mrEffectStyleList.back() );
     132           0 :             break;
     133             :     }
     134          14 :     return 0;
     135             : }
     136             : 
     137             : // ============================================================================
     138             : 
     139          18 : class FontSchemeContext : public ContextHandler
     140             : {
     141             : public:
     142             :     FontSchemeContext( ContextHandler& rParent, FontScheme& rFontScheme );
     143             :     virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& Attribs ) throw (SAXException, RuntimeException);
     144             :     virtual void SAL_CALL endFastElement( sal_Int32 nElement ) throw (SAXException, RuntimeException);
     145             : 
     146             : private:
     147             :     FontScheme& mrFontScheme;
     148             :     TextCharacterPropertiesPtr mxCharProps;
     149             : };
     150             : 
     151           9 : FontSchemeContext::FontSchemeContext( ContextHandler& rParent, FontScheme& rFontScheme ) :
     152             :     ContextHandler( rParent ),
     153           9 :     mrFontScheme( rFontScheme )
     154             : {
     155           9 : }
     156             : 
     157         488 : Reference< XFastContextHandler > FontSchemeContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs )
     158             :     throw (SAXException, RuntimeException)
     159             : {
     160         488 :     AttributeList aAttribs( rxAttribs );
     161         488 :     switch( nElement )
     162             :     {
     163             :         case A_TOKEN( majorFont ):
     164           9 :             mxCharProps.reset( new TextCharacterProperties );
     165           9 :             mrFontScheme[ XML_major ] = mxCharProps;
     166           9 :             return this;
     167             :         case A_TOKEN( minorFont ):
     168           9 :             mxCharProps.reset( new TextCharacterProperties );
     169           9 :             mrFontScheme[ XML_minor ] = mxCharProps;
     170           9 :             return this;
     171             : 
     172             :         case A_TOKEN( latin ):
     173          18 :             if( mxCharProps.get() )
     174          18 :                 mxCharProps->maLatinFont.setAttributes( aAttribs );
     175          18 :         break;
     176             :         case A_TOKEN( ea ):
     177          18 :             if( mxCharProps.get() )
     178          18 :                 mxCharProps->maAsianFont.setAttributes( aAttribs );
     179          18 :         break;
     180             :         case A_TOKEN( cs ):
     181          18 :             if( mxCharProps.get() )
     182          18 :                 mxCharProps->maComplexFont.setAttributes( aAttribs );
     183          18 :         break;
     184             :     }
     185         470 :     return 0;
     186             : }
     187             : 
     188          27 : void FontSchemeContext::endFastElement( sal_Int32 nElement ) throw (SAXException, RuntimeException)
     189             : {
     190          27 :     switch( nElement )
     191             :     {
     192             :         case A_TOKEN( majorFont ):
     193             :         case A_TOKEN( minorFont ):
     194          18 :             mxCharProps.reset();
     195          18 :         break;
     196             :     }
     197          27 : }
     198             : 
     199             : // ============================================================================
     200             : 
     201           9 : ThemeElementsContext::ThemeElementsContext( ContextHandler& rParent, Theme& rTheme ) :
     202             :     ContextHandler( rParent ),
     203           9 :     mrTheme( rTheme )
     204             : {
     205           9 : }
     206             : 
     207          63 : Reference< XFastContextHandler > ThemeElementsContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
     208             : {
     209             :     // CT_BaseStyles
     210          63 :     Reference< XFastContextHandler > xRet;
     211          63 :     switch( nElement )
     212             :     {
     213             :         case A_TOKEN( clrScheme ):  // CT_ColorScheme
     214           9 :             return new clrSchemeContext( *this, mrTheme.getClrScheme() );
     215             :         case A_TOKEN( fontScheme ): // CT_FontScheme
     216           9 :             return new FontSchemeContext( *this, mrTheme.getFontScheme() );
     217             : 
     218             :         case A_TOKEN( fmtScheme ):  // CT_StyleMatrix
     219           9 :             mrTheme.setStyleName( xAttribs->getOptionalValue( XML_name ) );
     220           9 :             return this;
     221             : 
     222             :         case A_TOKEN( fillStyleLst ):   // CT_FillStyleList
     223           9 :             return new FillStyleListContext( *this, mrTheme.getFillStyleList() );
     224             :         case A_TOKEN( lnStyleLst ):    // CT_LineStyleList
     225           9 :             return new LineStyleListContext( *this, mrTheme.getLineStyleList() );
     226             :         case A_TOKEN( effectStyleLst ): // CT_EffectStyleList
     227           9 :             return new EffectStyleListContext( *this, mrTheme.getEffectStyleList() );
     228             :         case A_TOKEN( bgFillStyleLst ): // CT_BackgroundFillStyleList
     229           9 :             return new FillStyleListContext( *this, mrTheme.getBgFillStyleList() );
     230             :     }
     231           0 :     return 0;
     232             : }
     233             : 
     234             : // ============================================================================
     235             : 
     236             : } // namespace drawingml
     237          51 : } // namespace oox
     238             : 
     239             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10