LCOV - code coverage report
Current view: top level - oox/source/drawingml - themeelementscontext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 71 71 100.0 %
Date: 2012-08-25 Functions: 21 21 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 75 138 54.3 %

           Branch data     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/fillproperties.hxx"
      25                 :            : #include "oox/drawingml/fillpropertiesgroupcontext.hxx"
      26                 :            : #include "oox/drawingml/theme.hxx"
      27                 :            : #include "oox/helper/attributelist.hxx"
      28                 :            : 
      29                 :            : using ::rtl::OUString;
      30                 :            : using namespace ::oox::core;
      31                 :            : using namespace ::com::sun::star::uno;
      32                 :            : using namespace ::com::sun::star::xml::sax;
      33                 :            : 
      34                 :            : namespace oox {
      35                 :            : namespace drawingml {
      36                 :            : 
      37                 :            : // ============================================================================
      38                 :            : 
      39         [ -  + ]:         72 : class FillStyleListContext : public ContextHandler
      40                 :            : {
      41                 :            : public:
      42                 :            :     FillStyleListContext( ContextHandler& rParent, FillStyleList& rFillStyleList );
      43                 :            :     virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& Attribs ) throw (SAXException, RuntimeException);
      44                 :            : 
      45                 :            : private:
      46                 :            :     FillStyleList& mrFillStyleList;
      47                 :            : };
      48                 :            : 
      49                 :         36 : FillStyleListContext::FillStyleListContext( ContextHandler& rParent, FillStyleList& rFillStyleList ) :
      50                 :            :     ContextHandler( rParent ),
      51                 :         36 :     mrFillStyleList( rFillStyleList )
      52                 :            : {
      53                 :         36 : }
      54                 :            : 
      55                 :        108 : Reference< XFastContextHandler > FillStyleListContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttribs )
      56                 :            :     throw (SAXException, RuntimeException)
      57                 :            : {
      58         [ +  - ]:        108 :     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 [ +  - ][ +  - ]:        108 :             mrFillStyleList.push_back( FillPropertiesPtr( new FillProperties ) );
      67                 :        108 :             return FillPropertiesContext::createFillContext( *this, nElement, xAttribs, *mrFillStyleList.back() );
      68                 :            :     }
      69                 :        108 :     return 0;
      70                 :            : }
      71                 :            : 
      72                 :            : // ============================================================================
      73                 :            : 
      74         [ -  + ]:         36 : class LineStyleListContext : public ContextHandler
      75                 :            : {
      76                 :            : public:
      77                 :            :     LineStyleListContext( ContextHandler& rParent, LineStyleList& rLineStyleList );
      78                 :            :     virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& Attribs ) throw (SAXException, RuntimeException);
      79                 :            : 
      80                 :            : private:
      81                 :            :     LineStyleList& mrLineStyleList;
      82                 :            : };
      83                 :            : 
      84                 :         18 : LineStyleListContext::LineStyleListContext( ContextHandler& rParent, LineStyleList& rLineStyleList ) :
      85                 :            :     ContextHandler( rParent ),
      86                 :         18 :     mrLineStyleList( rLineStyleList )
      87                 :            : {
      88                 :         18 : }
      89                 :            : 
      90                 :         54 : Reference< XFastContextHandler > LineStyleListContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttribs )
      91                 :            :     throw (SAXException, RuntimeException)
      92                 :            : {
      93         [ +  - ]:         54 :     switch( nElement )
      94                 :            :     {
      95                 :            :         case A_TOKEN( ln ):
      96 [ +  - ][ +  - ]:         54 :             mrLineStyleList.push_back( LinePropertiesPtr( new LineProperties ) );
      97         [ +  - ]:         54 :             return new LinePropertiesContext( *this, xAttribs, *mrLineStyleList.back() );
      98                 :            :     }
      99                 :         54 :     return 0;
     100                 :            : }
     101                 :            : 
     102                 :            : // ============================================================================
     103                 :            : 
     104         [ -  + ]:         36 : class EffectStyleListContext : public ContextHandler
     105                 :            : {
     106                 :            : public:
     107                 :            :     EffectStyleListContext( ContextHandler& rParent, EffectStyleList& rEffectStyleList );
     108                 :            :     virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& Attribs ) throw (SAXException, RuntimeException);
     109                 :            : 
     110                 :            : private:
     111                 :            :     EffectStyleList& mrEffectStyleList;
     112                 :            : };
     113                 :            : 
     114                 :         18 : EffectStyleListContext::EffectStyleListContext( ContextHandler& rParent, EffectStyleList& rEffectStyleList ) :
     115                 :            :     ContextHandler( rParent ),
     116                 :         18 :     mrEffectStyleList( rEffectStyleList )
     117                 :            : {
     118                 :         18 : }
     119                 :            : 
     120                 :         54 : Reference< XFastContextHandler > EffectStyleListContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& /*xAttribs*/ ) throw (SAXException, RuntimeException)
     121                 :            : {
     122         [ +  - ]:         54 :     switch( nElement )
     123                 :            :     {
     124                 :            :         case A_TOKEN( effectStyle ):
     125 [ +  - ][ +  - ]:         54 :             mrEffectStyleList.push_back( EffectStyleList::value_type( new PropertyMap ) );
     126                 :            :             // TODO: import effect styles
     127                 :         54 :             return 0;
     128                 :            :     }
     129                 :         54 :     return 0;
     130                 :            : }
     131                 :            : 
     132                 :            : // ============================================================================
     133                 :            : 
     134 [ +  - ][ -  + ]:         36 : class FontSchemeContext : public ContextHandler
     135                 :            : {
     136                 :            : public:
     137                 :            :     FontSchemeContext( ContextHandler& rParent, FontScheme& rFontScheme );
     138                 :            :     virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& Attribs ) throw (SAXException, RuntimeException);
     139                 :            :     virtual void SAL_CALL endFastElement( sal_Int32 nElement ) throw (SAXException, RuntimeException);
     140                 :            : 
     141                 :            : private:
     142                 :            :     FontScheme& mrFontScheme;
     143                 :            :     TextCharacterPropertiesPtr mxCharProps;
     144                 :            : };
     145                 :            : 
     146                 :         18 : FontSchemeContext::FontSchemeContext( ContextHandler& rParent, FontScheme& rFontScheme ) :
     147                 :            :     ContextHandler( rParent ),
     148         [ +  - ]:         18 :     mrFontScheme( rFontScheme )
     149                 :            : {
     150                 :         18 : }
     151                 :            : 
     152                 :       1032 : Reference< XFastContextHandler > FontSchemeContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& rxAttribs )
     153                 :            :     throw (SAXException, RuntimeException)
     154                 :            : {
     155         [ +  - ]:       1032 :     AttributeList aAttribs( rxAttribs );
     156   [ +  +  +  +  :       1032 :     switch( nElement )
                   +  + ]
     157                 :            :     {
     158                 :            :         case A_TOKEN( majorFont ):
     159 [ +  - ][ +  - ]:         18 :             mxCharProps.reset( new TextCharacterProperties );
                 [ +  - ]
     160 [ +  - ][ +  - ]:         18 :             mrFontScheme[ XML_major ] = mxCharProps;
     161         [ +  - ]:         18 :             return this;
     162                 :            :         case A_TOKEN( minorFont ):
     163 [ +  - ][ +  - ]:         18 :             mxCharProps.reset( new TextCharacterProperties );
                 [ +  - ]
     164 [ +  - ][ +  - ]:         18 :             mrFontScheme[ XML_minor ] = mxCharProps;
     165         [ +  - ]:         18 :             return this;
     166                 :            : 
     167                 :            :         case A_TOKEN( latin ):
     168         [ +  - ]:         36 :             if( mxCharProps.get() )
     169         [ +  - ]:         36 :                 mxCharProps->maLatinFont.setAttributes( aAttribs );
     170                 :         36 :         break;
     171                 :            :         case A_TOKEN( ea ):
     172         [ +  - ]:         36 :             if( mxCharProps.get() )
     173         [ +  - ]:         36 :                 mxCharProps->maAsianFont.setAttributes( aAttribs );
     174                 :         36 :         break;
     175                 :            :         case A_TOKEN( cs ):
     176         [ +  - ]:         36 :             if( mxCharProps.get() )
     177         [ +  - ]:         36 :                 mxCharProps->maComplexFont.setAttributes( aAttribs );
     178                 :         36 :         break;
     179                 :            :     }
     180 [ +  - ][ +  - ]:       1032 :     return 0;
     181                 :            : }
     182                 :            : 
     183                 :         54 : void FontSchemeContext::endFastElement( sal_Int32 nElement ) throw (SAXException, RuntimeException)
     184                 :            : {
     185         [ +  + ]:         54 :     switch( nElement )
     186                 :            :     {
     187                 :            :         case A_TOKEN( majorFont ):
     188                 :            :         case A_TOKEN( minorFont ):
     189                 :         36 :             mxCharProps.reset();
     190                 :         36 :         break;
     191                 :            :     }
     192                 :         54 : }
     193                 :            : 
     194                 :            : // ============================================================================
     195                 :            : 
     196                 :         18 : ThemeElementsContext::ThemeElementsContext( ContextHandler& rParent, Theme& rTheme ) :
     197                 :            :     ContextHandler( rParent ),
     198                 :         18 :     mrTheme( rTheme )
     199                 :            : {
     200                 :         18 : }
     201                 :            : 
     202                 :        126 : Reference< XFastContextHandler > ThemeElementsContext::createFastChildContext( sal_Int32 nElement, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
     203                 :            : {
     204                 :            :     // CT_BaseStyles
     205                 :        126 :     Reference< XFastContextHandler > xRet;
     206   [ +  +  +  +  :        126 :     switch( nElement )
             +  +  +  - ]
     207                 :            :     {
     208                 :            :         case A_TOKEN( clrScheme ):  // CT_ColorScheme
     209 [ +  - ][ +  - ]:         18 :             return new clrSchemeContext( *this, mrTheme.getClrScheme() );
                 [ +  - ]
     210                 :            :         case A_TOKEN( fontScheme ): // CT_FontScheme
     211 [ +  - ][ +  - ]:         18 :             return new FontSchemeContext( *this, mrTheme.getFontScheme() );
                 [ +  - ]
     212                 :            : 
     213                 :            :         case A_TOKEN( fmtScheme ):  // CT_StyleMatrix
     214 [ +  - ][ +  - ]:         18 :             mrTheme.setStyleName( xAttribs->getOptionalValue( XML_name ) );
     215         [ +  - ]:         18 :             return this;
     216                 :            : 
     217                 :            :         case A_TOKEN( fillStyleLst ):   // CT_FillStyleList
     218 [ +  - ][ +  - ]:         18 :             return new FillStyleListContext( *this, mrTheme.getFillStyleList() );
                 [ +  - ]
     219                 :            :         case A_TOKEN( lnStyleLst ):    // CT_LineStyleList
     220 [ +  - ][ +  - ]:         18 :             return new LineStyleListContext( *this, mrTheme.getLineStyleList() );
                 [ +  - ]
     221                 :            :         case A_TOKEN( effectStyleLst ): // CT_EffectStyleList
     222 [ +  - ][ +  - ]:         18 :             return new EffectStyleListContext( *this, mrTheme.getEffectStyleList() );
                 [ +  - ]
     223                 :            :         case A_TOKEN( bgFillStyleLst ): // CT_BackgroundFillStyleList
     224 [ +  - ][ +  - ]:         18 :             return new FillStyleListContext( *this, mrTheme.getBgFillStyleList() );
                 [ +  - ]
     225                 :            :     }
     226         [ #  # ]:        126 :     return 0;
     227                 :            : }
     228                 :            : 
     229                 :            : // ============================================================================
     230                 :            : 
     231                 :            : } // namespace drawingml
     232 [ +  - ][ +  - ]:        285 : } // namespace oox
     233                 :            : 
     234                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10