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

Generated by: LCOV version 1.10