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

Generated by: LCOV version 1.11