LCOV - code coverage report
Current view: top level - sc/source/filter/oox - extlstcontext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 62 69 89.9 %
Date: 2014-11-03 Functions: 14 14 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             : 
      10             : #include "extlstcontext.hxx"
      11             : #include "worksheethelper.hxx"
      12             : #include <oox/core/contexthandler.hxx>
      13             : #include "colorscale.hxx"
      14             : #include "condformatbuffer.hxx"
      15             : 
      16             : using ::oox::core::ContextHandlerRef;
      17             : 
      18             : namespace oox {
      19             : namespace xls {
      20             : 
      21          30 : ExtCfRuleContext::ExtCfRuleContext( WorksheetContextBase& rFragment, void* pTarget ):
      22             :     WorksheetContextBase( rFragment ),
      23             :     mpTarget( pTarget ),
      24          30 :     mbFirstEntry(true)
      25             : {
      26          30 : }
      27             : 
      28         150 : ContextHandlerRef ExtCfRuleContext::onCreateContext( sal_Int32 , const AttributeList& )
      29             : {
      30         150 :     return this;
      31             : }
      32             : 
      33         180 : void ExtCfRuleContext::onStartElement( const AttributeList& rAttribs )
      34             : {
      35         180 :     switch( getCurrentElement() )
      36             :     {
      37             :         case XLS_EXT_TOKEN( dataBar ):
      38             :         {
      39          30 :             ExtCfRuleRef xRule = getCondFormats().createExtCfRule(mpTarget);
      40          30 :             xRule->importDataBar( rAttribs );
      41          30 :             break;
      42             :         }
      43             :         case XLS_EXT_TOKEN( negativeFillColor ):
      44             :         {
      45          30 :             ExtCfRuleRef xRule = getCondFormats().createExtCfRule(mpTarget);
      46          30 :             xRule->importNegativeFillColor( rAttribs );
      47          30 :             break;
      48             :         }
      49             :         case XLS_EXT_TOKEN( axisColor ):
      50             :         {
      51          30 :             ExtCfRuleRef xRule = getCondFormats().createExtCfRule(mpTarget);
      52          30 :             xRule->importAxisColor( rAttribs );
      53          30 :             break;
      54             :         }
      55             :         case XLS_EXT_TOKEN( cfvo ):
      56             :         {
      57          60 :             ExtCfRuleRef xRule = getCondFormats().createExtCfRule(mpTarget);
      58          60 :             xRule->importCfvo( rAttribs );
      59          60 :             xRule->getModel().mbIsLower = mbFirstEntry;
      60          60 :             mbFirstEntry = false;
      61          60 :             break;
      62             :         }
      63             :         default:
      64          30 :             break;
      65             :     }
      66         180 : }
      67             : 
      68          30 : ExtLstLocalContext::ExtLstLocalContext( WorksheetContextBase& rFragment, void* pTarget ):
      69             :     WorksheetContextBase(rFragment),
      70          30 :     mpTarget(pTarget)
      71             : {
      72          30 : }
      73             : 
      74          60 : ContextHandlerRef ExtLstLocalContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
      75             : {
      76          60 :     switch( getCurrentElement() )
      77             :     {
      78             :         case XLS_TOKEN( extLst ):
      79          30 :             if(nElement == XLS_TOKEN( ext ))
      80          30 :                 return this;
      81             :             else
      82           0 :                 return 0;
      83             :             break;
      84             :         case XLS_TOKEN( ext ):
      85          30 :             if (nElement == XLS_EXT_TOKEN( id ))
      86          30 :                 return this;
      87             :             else
      88           0 :                 return 0;
      89             :     }
      90           0 :     return 0;
      91             : }
      92             : 
      93          90 : void ExtLstLocalContext::onStartElement( const AttributeList& )
      94             : {
      95          90 :     switch( getCurrentElement() )
      96             :     {
      97             :         case XLS_EXT_TOKEN( id ):
      98          30 :         break;
      99             :     }
     100          90 : }
     101             : 
     102          30 : void ExtLstLocalContext::onCharacters( const OUString& rChars )
     103             : {
     104          30 :     if (getCurrentElement() == XLS_EXT_TOKEN( id ))
     105             :     {
     106          30 :         getExtLst().insert( std::pair< OUString, void*>(rChars, mpTarget) );
     107             :     }
     108          30 : }
     109             : 
     110           6 : ExtGlobalContext::ExtGlobalContext( WorksheetContextBase& rFragment ):
     111           6 :     WorksheetContextBase(rFragment)
     112             : {
     113           6 : }
     114             : 
     115          96 : ContextHandlerRef ExtGlobalContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     116             : {
     117          96 :     if(!rAttribs.hasAttribute( XML_id))
     118          66 :         return this;
     119             :     else
     120             :     {
     121          30 :         if(nElement == XLS_EXT_TOKEN( cfRule ))
     122             :         {
     123          30 :             OUString aId = rAttribs.getString( XML_id, OUString() );
     124             : 
     125             :             // an ext entrie does not need to have an existing corresponding entry
     126          30 :             ExtLst::const_iterator aExt = getExtLst().find( aId );
     127          30 :             if(aExt == getExtLst().end())
     128           0 :                 return NULL;
     129             : 
     130          30 :             void* pInfo = aExt->second;
     131          30 :             if (!pInfo)
     132             :             {
     133           0 :                 return NULL;
     134             :             }
     135          30 :             return new ExtCfRuleContext( *this, pInfo );
     136             :         }
     137             :         else
     138           0 :             return this;
     139             :     }
     140             : }
     141             : 
     142          72 : void ExtGlobalContext::onStartElement( const AttributeList& /*rAttribs*/ )
     143             : {
     144          72 : }
     145             : 
     146           6 : ExtLstGlobalContext::ExtLstGlobalContext( WorksheetFragment& rFragment ):
     147           6 :     WorksheetContextBase(rFragment)
     148             : {
     149           6 : }
     150             : 
     151           6 : ContextHandlerRef ExtLstGlobalContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
     152             : {
     153           6 :     if (nElement == XLS_TOKEN( ext ))
     154           6 :         return new ExtGlobalContext( *this );
     155             : 
     156           0 :     return this;
     157             : }
     158             : 
     159             : } //namespace oox
     160          48 : } //namespace xls
     161             : 
     162             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10