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

Generated by: LCOV version 1.10