LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/filter/oox - condformatcontext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 67 110 60.9 %
Date: 2013-07-09 Functions: 13 19 68.4 %
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 "condformatcontext.hxx"
      21             : #include "extlstcontext.hxx"
      22             : 
      23             : namespace oox {
      24             : namespace xls {
      25             : 
      26             : // ============================================================================
      27             : 
      28             : using ::oox::core::ContextHandlerRef;
      29             : 
      30             : // ============================================================================
      31             : 
      32          18 : ColorScaleContext::ColorScaleContext( CondFormatContext& rFragment, CondFormatRuleRef xRule ) :
      33             :     WorksheetContextBase( rFragment ),
      34          18 :     mxRule( xRule )
      35             : {
      36          18 : }
      37             : 
      38          90 : ContextHandlerRef ColorScaleContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
      39             : {
      40          90 :     switch( getCurrentElement() )
      41             :     {
      42             :         case XLS_TOKEN( cfRule ):
      43           0 :             return (nElement == XLS_TOKEN( colorScale )) ? this : 0;
      44             :         case XLS_TOKEN( colorScale ):
      45          90 :             if (nElement == XLS_TOKEN( cfvo ))
      46          45 :                 return this;
      47          45 :             else if (nElement == XLS_TOKEN( color ))
      48          45 :                 return this;
      49             :             else
      50           0 :                 return 0;
      51             :     }
      52           0 :     return 0;
      53             : }
      54             : 
      55         108 : void ColorScaleContext::onStartElement( const AttributeList& rAttribs )
      56             : {
      57         108 :     switch( getCurrentElement() )
      58             :     {
      59             :         case XLS_TOKEN( cfvo ):
      60          45 :             mxRule->getColorScale()->importCfvo( rAttribs );
      61          45 :         break;
      62             :         case XLS_TOKEN( color ):
      63          45 :             mxRule->getColorScale()->importColor( rAttribs );
      64          45 :         break;
      65             :     }
      66         108 : }
      67             : 
      68             : // ============================================================================
      69             : 
      70           5 : DataBarContext::DataBarContext( CondFormatContext& rFragment, CondFormatRuleRef xRule ) :
      71             :     WorksheetContextBase( rFragment ),
      72           5 :     mxRule( xRule )
      73             : {
      74           5 : }
      75             : 
      76          15 : ContextHandlerRef DataBarContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
      77             : {
      78          15 :     switch( getCurrentElement() )
      79             :     {
      80             :         case XLS_TOKEN( cfRule ):
      81           0 :             return (nElement == XLS_TOKEN( dataBar )) ? this : 0;
      82             :         case XLS_TOKEN( dataBar ):
      83          15 :             if (nElement == XLS_TOKEN( cfvo ))
      84          10 :                 return this;
      85           5 :             else if (nElement == XLS_TOKEN( color ))
      86           5 :                 return this;
      87             :             else
      88           0 :                 return 0;
      89             :     }
      90           0 :     return 0;
      91             : }
      92             : 
      93          20 : void DataBarContext::onStartElement( const AttributeList& rAttribs )
      94             : {
      95          20 :     switch( getCurrentElement() )
      96             :     {
      97             :         case XLS_TOKEN( dataBar ):
      98           5 :             mxRule->getDataBar()->importAttribs( rAttribs );
      99           5 :         break;
     100             :         case XLS_TOKEN( cfvo ):
     101          10 :             mxRule->getDataBar()->importCfvo( rAttribs );
     102          10 :         break;
     103             :         case XLS_TOKEN( color ):
     104           5 :             mxRule->getDataBar()->importColor( rAttribs );
     105           5 :         break;
     106             :     }
     107          20 : }
     108             : 
     109             : // ============================================================================
     110             : 
     111           0 : IconSetContext::IconSetContext( CondFormatContext& rFragment, CondFormatRuleRef xRule ) :
     112             :     WorksheetContextBase( rFragment ),
     113           0 :     mxRule( xRule )
     114             : {
     115           0 : }
     116             : 
     117           0 : ContextHandlerRef IconSetContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
     118             : {
     119           0 :     switch( getCurrentElement() )
     120             :     {
     121             :         case XLS_TOKEN( cfRule ):
     122           0 :             return (nElement == XLS_TOKEN( iconSet )) ? this : 0;
     123             :         case XLS_TOKEN( iconSet ):
     124           0 :             if (nElement == XLS_TOKEN( cfvo ))
     125           0 :                 return this;
     126             :             else
     127           0 :                 return 0;
     128             :     }
     129           0 :     return 0;
     130             : }
     131             : 
     132           0 : void IconSetContext::onStartElement( const AttributeList& rAttribs )
     133             : {
     134           0 :     switch( getCurrentElement() )
     135             :     {
     136             :         case XLS_TOKEN( iconSet ):
     137           0 :             mxRule->getIconSet()->importAttribs( rAttribs );
     138           0 :         break;
     139             :         case XLS_TOKEN( cfvo ):
     140           0 :             mxRule->getIconSet()->importCfvo( rAttribs );
     141           0 :         break;
     142             :     }
     143           0 : }
     144             : 
     145             : // ============================================================================
     146             : 
     147          47 : CondFormatContext::CondFormatContext( WorksheetFragmentBase& rFragment ) :
     148          47 :     WorksheetContextBase( rFragment )
     149             : {
     150          47 : }
     151             : 
     152          79 : ContextHandlerRef CondFormatContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
     153             : {
     154          79 :     switch( getCurrentElement() )
     155             :     {
     156             :         case XLS_TOKEN( conditionalFormatting ):
     157          47 :             return (nElement == XLS_TOKEN( cfRule )) ? this : 0;
     158             :         case XLS_TOKEN( cfRule ):
     159          32 :             if (nElement == XLS_TOKEN( formula ))
     160           4 :                 return this;
     161          28 :             else if (nElement == XLS_TOKEN( colorScale ) )
     162          18 :                 return new ColorScaleContext( *this, mxRule );
     163          10 :             else if (nElement == XLS_TOKEN( dataBar ) )
     164           5 :                 return new DataBarContext( *this, mxRule );
     165           5 :             else if (nElement == XLS_TOKEN( iconSet ) )
     166           0 :                 return new IconSetContext( *this, mxRule );
     167           5 :             else if (nElement == XLS_TOKEN( extLst ) )
     168           5 :                 return new ExtLstLocalContext( *this, mxRule->getDataBar()->getDataBarFormatData() );
     169             :             else
     170           0 :                 return 0;
     171             :     }
     172           0 :     return 0;
     173             : }
     174             : 
     175          98 : void CondFormatContext::onEndElement()
     176             : {
     177          98 :     switch( getCurrentElement() )
     178             :     {
     179             :         case XLS_TOKEN( conditionalFormatting ):
     180          47 :             if(mxCondFmt.get())
     181          47 :                 mxCondFmt->setReadyForFinalize();
     182          47 :             break;
     183             :     }
     184          98 : }
     185             : 
     186          98 : void CondFormatContext::onStartElement( const AttributeList& rAttribs )
     187             : {
     188          98 :     switch( getCurrentElement() )
     189             :     {
     190             :         case XLS_TOKEN( conditionalFormatting ):
     191          47 :             mxCondFmt = getCondFormats().importConditionalFormatting( rAttribs );
     192          47 :         break;
     193             :         case XLS_TOKEN( cfRule ):
     194          47 :             if( mxCondFmt.get() ) mxRule = mxCondFmt->importCfRule( rAttribs );
     195          47 :         break;
     196             :     }
     197          98 : }
     198             : 
     199           4 : void CondFormatContext::onCharacters( const OUString& rChars )
     200             : {
     201           4 :     if( isCurrentElement( XLS_TOKEN( formula ) ) && mxCondFmt.get() && mxRule.get() )
     202           4 :         mxRule->appendFormula( rChars );
     203           4 : }
     204             : 
     205           0 : ContextHandlerRef CondFormatContext::onCreateRecordContext( sal_Int32 nRecId, SequenceInputStream& )
     206             : {
     207           0 :     switch( getCurrentElement() )
     208             :     {
     209             :         case BIFF12_ID_CONDFORMATTING:
     210           0 :             return (nRecId == BIFF12_ID_CFRULE) ? this : 0;
     211             :     }
     212           0 :     return 0;
     213             : }
     214             : 
     215           0 : void CondFormatContext::onStartRecord( SequenceInputStream& rStrm )
     216             : {
     217           0 :     switch( getCurrentElement() )
     218             :     {
     219             :         case BIFF12_ID_CONDFORMATTING:
     220           0 :             mxCondFmt = getCondFormats().importCondFormatting( rStrm );
     221           0 :         break;
     222             :         case BIFF12_ID_CFRULE:
     223           0 :             if( mxCondFmt.get() ) mxCondFmt->importCfRule( rStrm );
     224           0 :         break;
     225             :     }
     226           0 : }
     227             : 
     228           0 : void CondFormatContext::onEndRecord()
     229             : {
     230           0 :     switch( getCurrentElement() )
     231             :     {
     232             :         case BIFF12_ID_CONDFORMATTING:
     233           0 :             if( mxCondFmt.get() )
     234           0 :                 mxCondFmt->finalizeImport();
     235           0 :             break;
     236             :     }
     237           0 : }
     238             : 
     239             : // ============================================================================
     240             : 
     241             : } // namespace xls
     242          15 : } // namespace oox
     243             : 
     244             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10