LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/oox/source/drawingml/chart - datasourcecontext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 64 80 80.0 %
Date: 2013-07-09 Functions: 16 16 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/chart/datasourcecontext.hxx"
      21             : 
      22             : #include "oox/drawingml/chart/datasourcemodel.hxx"
      23             : 
      24             : namespace oox {
      25             : namespace drawingml {
      26             : namespace chart {
      27             : 
      28             : // ============================================================================
      29             : 
      30             : using ::oox::core::ContextHandler2Helper;
      31             : using ::oox::core::ContextHandlerRef;
      32             : 
      33             : // ============================================================================
      34             : 
      35           4 : DoubleSequenceContext::DoubleSequenceContext( ContextHandler2Helper& rParent, DataSequenceModel& rModel ) :
      36             :     DataSequenceContextBase( rParent, rModel ),
      37           4 :     mnPtIndex( -1 )
      38             : {
      39           4 : }
      40             : 
      41           8 : DoubleSequenceContext::~DoubleSequenceContext()
      42             : {
      43           8 : }
      44             : 
      45          44 : ContextHandlerRef DoubleSequenceContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      46             : {
      47          44 :     switch( getCurrentElement() )
      48             :     {
      49             :         case C_TOKEN( numRef ):
      50           8 :             switch( nElement )
      51             :             {
      52             :                 case C_TOKEN( f ):
      53             :                 case C_TOKEN( numCache ):
      54           8 :                     return this;
      55             :             }
      56           0 :         break;
      57             : 
      58             :         case C_TOKEN( numCache ):
      59             :         case C_TOKEN( numLit ):
      60          22 :             switch( nElement )
      61             :             {
      62             :                 case C_TOKEN( formatCode ):
      63           4 :                     return this;
      64             :                 case C_TOKEN( ptCount ):
      65           4 :                     mrModel.mnPointCount = rAttribs.getInteger( XML_val, -1 );
      66           4 :                     return 0;
      67             :                 case C_TOKEN( pt ):
      68          14 :                     mnPtIndex = rAttribs.getInteger( XML_idx, -1 );
      69          14 :                     return this;
      70             :             }
      71           0 :         break;
      72             : 
      73             :         case C_TOKEN( pt ):
      74          14 :             switch( nElement )
      75             :             {
      76             :                 case C_TOKEN( v ):
      77          14 :                     return this;
      78             :             }
      79           0 :         break;
      80             :     }
      81           0 :     return 0;
      82             : }
      83             : 
      84          22 : void DoubleSequenceContext::onCharacters( const OUString& rChars )
      85             : {
      86          22 :     switch( getCurrentElement() )
      87             :     {
      88             :         case C_TOKEN( f ):
      89           4 :             mrModel.maFormula = rChars;
      90           4 :         break;
      91             :         case C_TOKEN( formatCode ):
      92           4 :             mrModel.maFormatCode = rChars;
      93           4 :         break;
      94             :         case C_TOKEN( v ):
      95          14 :             if( mnPtIndex >= 0 )
      96             :             {
      97             :                 /* Import categories as String even though it could
      98             :                  * be values.
      99             :                  * n#810508: xVal needs to be imported as double
     100             :                  * TODO: NumberFormat conversion, remove the check then.
     101             :                  */
     102          14 :                 if( isParentElement( C_TOKEN( cat ), 4 ) )
     103           0 :                     mrModel.maData[ mnPtIndex ] <<= rChars;
     104             :                 else
     105          14 :                     mrModel.maData[ mnPtIndex ] <<= rChars.toDouble();
     106             :             }
     107          14 :         break;
     108             :     }
     109          22 : }
     110             : 
     111             : // ============================================================================
     112             : 
     113           2 : StringSequenceContext::StringSequenceContext( ContextHandler2Helper& rParent, DataSequenceModel& rModel ) :
     114           2 :     DataSequenceContextBase( rParent, rModel )
     115             : {
     116           2 : }
     117             : 
     118           4 : StringSequenceContext::~StringSequenceContext()
     119             : {
     120           4 : }
     121             : 
     122          10 : ContextHandlerRef StringSequenceContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     123             : {
     124          10 :     switch( getCurrentElement() )
     125             :     {
     126             :         case C_TOKEN( multiLvlStrRef ):
     127           0 :             switch( nElement )
     128             :             {
     129             :                 case C_TOKEN( f ):
     130           0 :                     return this;
     131             :             }
     132           0 :         break;
     133             : 
     134             :         case C_TOKEN( strRef ):
     135           4 :             switch( nElement )
     136             :             {
     137             :                 case C_TOKEN( f ):
     138             :                 case C_TOKEN( strCache ):
     139           4 :                     return this;
     140             :             }
     141           0 :         break;
     142             : 
     143             :         case C_TOKEN( strCache ):
     144             :         case C_TOKEN( strLit ):
     145           4 :             switch( nElement )
     146             :             {
     147             :                 case C_TOKEN( ptCount ):
     148           2 :                     mrModel.mnPointCount = rAttribs.getInteger( XML_val, -1 );
     149           2 :                     return 0;
     150             :                 case C_TOKEN( pt ):
     151           2 :                     mnPtIndex = rAttribs.getInteger( XML_idx, -1 );
     152           2 :                     return this;
     153             :             }
     154           0 :         break;
     155             : 
     156             :         case C_TOKEN( pt ):
     157           2 :             switch( nElement )
     158             :             {
     159             :                 case C_TOKEN( v ):
     160           2 :                     return this;
     161             :             }
     162           0 :         break;
     163             :     }
     164           0 :     return 0;
     165             : }
     166             : 
     167           4 : void StringSequenceContext::onCharacters( const OUString& rChars )
     168             : {
     169           4 :     switch( getCurrentElement() )
     170             :     {
     171             :         case C_TOKEN( f ):
     172           2 :             mrModel.maFormula = rChars;
     173           2 :         break;
     174             :         case C_TOKEN( v ):
     175           2 :             if( mnPtIndex >= 0 )
     176           2 :                 mrModel.maData[ mnPtIndex ] <<= rChars;
     177           2 :         break;
     178             :     }
     179           4 : }
     180             : 
     181             : // ============================================================================
     182             : 
     183           4 : DataSourceContext::DataSourceContext( ContextHandler2Helper& rParent, DataSourceModel& rModel ) :
     184           4 :     ContextBase< DataSourceModel >( rParent, rModel )
     185             : {
     186           4 : }
     187             : 
     188           8 : DataSourceContext::~DataSourceContext()
     189             : {
     190           8 : }
     191             : 
     192           4 : ContextHandlerRef DataSourceContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
     193             : {
     194           4 :     switch( getCurrentElement() )
     195             :     {
     196             :         case C_TOKEN( cat ):
     197             :         case C_TOKEN( xVal ):
     198           2 :             switch( nElement )
     199             :             {
     200             :                 case C_TOKEN( multiLvlStrRef ):
     201             :                 case C_TOKEN( strLit ):
     202             :                 case C_TOKEN( strRef ):
     203             :                     OSL_ENSURE( !mrModel.mxDataSeq, "DataSourceContext::onCreateContext - multiple data sequences" );
     204           0 :                     return new StringSequenceContext( *this, mrModel.mxDataSeq.create() );
     205             : 
     206             :                 case C_TOKEN( numLit ):
     207             :                 case C_TOKEN( numRef ):
     208             :                     OSL_ENSURE( !mrModel.mxDataSeq, "DataSourceContext::onCreateContext - multiple data sequences" );
     209           2 :                     return new DoubleSequenceContext( *this, mrModel.mxDataSeq.create() );
     210             :             }
     211           0 :         break;
     212             : 
     213             :         case C_TOKEN( plus ):
     214             :         case C_TOKEN( minus ):
     215             :         case C_TOKEN( val ):
     216             :         case C_TOKEN( yVal ):
     217             :         case C_TOKEN( bubbleSize ):
     218           2 :             switch( nElement )
     219             :             {
     220             :                 case C_TOKEN( numLit ):
     221             :                 case C_TOKEN( numRef ):
     222             :                     OSL_ENSURE( !mrModel.mxDataSeq, "DataSourceContext::onCreateContext - multiple data sequences" );
     223           2 :                     return new DoubleSequenceContext( *this, mrModel.mxDataSeq.create() );
     224             :             }
     225           0 :         break;
     226             :     }
     227           0 :     return 0;
     228             : }
     229             : 
     230             : // ============================================================================
     231             : 
     232             : } // namespace chart
     233             : } // namespace drawingml
     234         141 : } // namespace oox
     235             : 
     236             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10