LCOV - code coverage report
Current view: top level - oox/source/drawingml/chart - axiscontext.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 96 137 70.1 %
Date: 2014-04-11 Functions: 21 26 80.8 %
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/axiscontext.hxx"
      21             : 
      22             : #include "oox/drawingml/shapepropertiescontext.hxx"
      23             : #include "oox/drawingml/textbodycontext.hxx"
      24             : #include "oox/drawingml/chart/axismodel.hxx"
      25             : #include "oox/drawingml/chart/titlecontext.hxx"
      26             : 
      27             : namespace oox {
      28             : namespace drawingml {
      29             : namespace chart {
      30             : 
      31             : 
      32             : 
      33             : using ::oox::core::ContextHandlerRef;
      34             : using ::oox::core::ContextHandler2Helper;
      35             : 
      36             : 
      37             : 
      38           2 : AxisDispUnitsContext::AxisDispUnitsContext( ContextHandler2Helper& rParent, AxisDispUnitsModel& rModel ) :
      39           2 :     ContextBase< AxisDispUnitsModel >( rParent, rModel )
      40             : {
      41           2 : }
      42             : 
      43           4 : AxisDispUnitsContext::~AxisDispUnitsContext()
      44             : {
      45           4 : }
      46             : 
      47           4 : ContextHandlerRef AxisDispUnitsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      48             : {
      49           4 :     switch( getCurrentElement() )
      50             :     {
      51             :         case C_TOKEN( dispUnits ):
      52           4 :             switch( nElement )
      53             :             {
      54             :                 case C_TOKEN( builtInUnit ):
      55           2 :                     mrModel.mnBuiltInUnit = rAttribs.getString( XML_val, "thousands" );
      56           2 :                     return 0;
      57             :                 case C_TOKEN( custUnit ):
      58           0 :                     mrModel.mfCustomUnit = rAttribs.getDouble( XML_val, 0.0 );
      59           0 :                     return 0;
      60             :                 case C_TOKEN( dispUnitsLbl ):
      61           2 :                     return this;
      62             :             }
      63           0 :         break;
      64             : 
      65             :         case C_TOKEN( dispUnitsLbl ):
      66           0 :             switch( nElement )
      67             :             {
      68             :                 case C_TOKEN( layout ):
      69           0 :                     return new LayoutContext( *this, mrModel.mxLayout.create() );
      70             :                 case C_TOKEN( spPr ):
      71           0 :                     return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
      72             :                 case C_TOKEN( tx ):
      73           0 :                     return new TextContext( *this, mrModel.mxText.create() );
      74             :                 case C_TOKEN( txPr ):
      75           0 :                     return new TextBodyContext( *this, mrModel.mxTextProp.create() );
      76             :             }
      77           0 :         break;
      78             :     }
      79           0 :     return 0;
      80             : }
      81             : 
      82             : 
      83             : 
      84         112 : AxisContextBase::AxisContextBase( ContextHandler2Helper& rParent, AxisModel& rModel ) :
      85         112 :     ContextBase< AxisModel >( rParent, rModel )
      86             : {
      87         112 : }
      88             : 
      89         112 : AxisContextBase::~AxisContextBase()
      90             : {
      91         112 : }
      92             : 
      93        1226 : ContextHandlerRef AxisContextBase::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      94             : {
      95        1226 :     switch( getCurrentElement() )
      96             :     {
      97             :         case C_TOKEN( catAx ):
      98             :         case C_TOKEN( dateAx ):
      99             :         case C_TOKEN( serAx ):
     100             :         case C_TOKEN( valAx ):
     101        1112 :             switch( nElement )
     102             :             {
     103             :                 case C_TOKEN( axId ):
     104         112 :                     mrModel.mnAxisId = rAttribs.getInteger( XML_val, -1 );
     105         112 :                     return 0;
     106             :                 case C_TOKEN( crossAx ):
     107         112 :                     mrModel.mnCrossAxisId = rAttribs.getInteger( XML_val, -1 );
     108         112 :                     return 0;
     109             :                 case C_TOKEN( crosses ):
     110         109 :                     mrModel.mnCrossMode = rAttribs.getToken( XML_val, XML_autoZero );
     111         109 :                     return 0;
     112             :                 case C_TOKEN( crossesAt ):
     113           2 :                     mrModel.mofCrossesAt = rAttribs.getDouble( XML_val, 0.0 );
     114           2 :                     return 0;
     115             :                 case C_TOKEN( delete ):
     116             :                     // default is 'false', not 'true' as specified
     117          97 :                     mrModel.mbDeleted = rAttribs.getBool( XML_val, false );
     118          97 :                     return 0;
     119             :                 case C_TOKEN( majorGridlines ):
     120          57 :                     return new ShapePrWrapperContext( *this, mrModel.mxMajorGridLines.create() );
     121             :                 case C_TOKEN( majorTickMark ):
     122             :                     // default is 'out', not 'cross' as specified
     123         102 :                     mrModel.mnMajorTickMark = rAttribs.getToken( XML_val, XML_out );
     124         102 :                     return 0;
     125             :                 case C_TOKEN( minorGridlines ):
     126          12 :                     return new ShapePrWrapperContext( *this, mrModel.mxMinorGridLines.create() );
     127             :                 case C_TOKEN( minorTickMark ):
     128             :                     // default is 'none', not 'cross' as specified
     129          96 :                     mrModel.mnMinorTickMark = rAttribs.getToken( XML_val, XML_none );
     130          96 :                     return 0;
     131             :                 case C_TOKEN( numFmt ):
     132          34 :                     mrModel.maNumberFormat.setAttributes( rAttribs );
     133          34 :                     return 0;
     134             :                 case C_TOKEN( scaling ):
     135         112 :                     return this;
     136             :                 case C_TOKEN( spPr ):
     137          61 :                     return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
     138             :                 case C_TOKEN( tickLblPos ):
     139         112 :                     mrModel.mnTickLabelPos = rAttribs.getToken( XML_val, XML_nextTo );
     140         112 :                     return 0;
     141             :                 case C_TOKEN( title ):
     142          22 :                     return new TitleContext( *this, mrModel.mxTitle.create() );
     143             :                 case C_TOKEN( txPr ):
     144           6 :                     return new TextBodyContext( *this, mrModel.mxTextProp.create() );
     145             :             }
     146          66 :         break;
     147             : 
     148             :         case C_TOKEN( scaling ):
     149         114 :             switch( nElement )
     150             :             {
     151             :                 case C_TOKEN( logBase ):
     152           2 :                     mrModel.mofLogBase = rAttribs.getDouble( XML_val, 0.0 );
     153           2 :                     return 0;
     154             :                 case C_TOKEN( max ):
     155           0 :                     mrModel.mofMax = rAttribs.getDouble( XML_val, 0.0 );
     156           0 :                     return 0;
     157             :                 case C_TOKEN( min ):
     158           0 :                     mrModel.mofMin = rAttribs.getDouble( XML_val, 0.0 );
     159           0 :                     return 0;
     160             :                 case C_TOKEN( orientation ):
     161         112 :                     mrModel.mnOrientation = rAttribs.getToken( XML_val, XML_minMax );
     162         112 :                     return 0;
     163             :             }
     164           0 :         break;
     165             :     }
     166          66 :     return 0;
     167             : }
     168             : 
     169             : 
     170             : 
     171          46 : CatAxisContext::CatAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
     172          46 :     AxisContextBase( rParent, rModel )
     173             : {
     174          46 : }
     175             : 
     176          92 : CatAxisContext::~CatAxisContext()
     177             : {
     178          92 : }
     179             : 
     180         652 : ContextHandlerRef CatAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     181             : {
     182         652 :     if( isRootElement() ) switch( nElement )
     183             :     {
     184             :         case C_TOKEN( auto ):
     185             :             // default is 'false', not 'true' as specified
     186          46 :             mrModel.mbAuto = rAttribs.getBool( XML_val, false );
     187          46 :             return 0;
     188             :         case C_TOKEN( axPos ):
     189          46 :             mrModel.mnAxisPos = rAttribs.getToken( XML_val, XML_TOKEN_INVALID );
     190          46 :             return 0;
     191             :         case C_TOKEN( lblAlgn ):
     192          46 :             mrModel.mnLabelAlign = rAttribs.getToken( XML_val, XML_ctr );
     193          46 :             return 0;
     194             :         case C_TOKEN( lblOffset ):
     195          46 :             mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
     196          46 :             return 0;
     197             :         case C_TOKEN( noMultiLvlLbl ):
     198             :             // default is 'false', not 'true' as specified
     199          19 :             mrModel.mbNoMultiLevel = rAttribs.getBool( XML_val, false );
     200          19 :             return 0;
     201             :         case C_TOKEN( tickLblSkip ):
     202           1 :             mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
     203           1 :             return 0;
     204             :         case C_TOKEN( tickMarkSkip ):
     205           0 :             mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
     206           0 :             return 0;
     207             :     }
     208         448 :     return AxisContextBase::onCreateContext( nElement, rAttribs );
     209             : }
     210             : 
     211             : 
     212             : 
     213           5 : DateAxisContext::DateAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
     214           5 :     AxisContextBase( rParent, rModel )
     215             : {
     216           5 : }
     217             : 
     218          10 : DateAxisContext::~DateAxisContext()
     219             : {
     220          10 : }
     221             : 
     222          60 : ContextHandlerRef DateAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     223             : {
     224          60 :     if( isRootElement() ) switch( nElement )
     225             :     {
     226             :         case C_TOKEN( auto ):
     227             :             // default is 'false', not 'true' as specified
     228           5 :             mrModel.mbAuto = rAttribs.getBool( XML_val, false );
     229           5 :             return 0;
     230             :         case C_TOKEN( baseTimeUnit ):
     231           1 :             mrModel.monBaseTimeUnit = rAttribs.getToken( XML_val, XML_days );
     232           1 :             return 0;
     233             :         case C_TOKEN( lblOffset ):
     234           5 :             mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
     235           5 :             return 0;
     236             :         case C_TOKEN( majorTimeUnit ):
     237           0 :             mrModel.mnMajorTimeUnit = rAttribs.getToken( XML_val, XML_days );
     238           0 :             return 0;
     239             :         case C_TOKEN( majorUnit ):
     240           0 :             mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
     241           0 :             return 0;
     242             :         case C_TOKEN( minorTimeUnit ):
     243           0 :             mrModel.mnMinorTimeUnit = rAttribs.getToken( XML_val, XML_days );
     244           0 :             return 0;
     245             :         case C_TOKEN( minorUnit ):
     246           0 :             mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
     247           0 :             return 0;
     248             :     }
     249          49 :     return AxisContextBase::onCreateContext( nElement, rAttribs );
     250             : }
     251             : 
     252             : 
     253             : 
     254           0 : SerAxisContext::SerAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
     255           0 :     AxisContextBase( rParent, rModel )
     256             : {
     257           0 : }
     258             : 
     259           0 : SerAxisContext::~SerAxisContext()
     260             : {
     261           0 : }
     262             : 
     263           0 : ContextHandlerRef SerAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     264             : {
     265           0 :     if( isRootElement() ) switch( nElement )
     266             :     {
     267             :         case C_TOKEN( tickLblSkip ):
     268           0 :             mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
     269           0 :             return 0;
     270             :         case C_TOKEN( tickMarkSkip ):
     271           0 :             mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
     272           0 :             return 0;
     273             :     }
     274           0 :     return AxisContextBase::onCreateContext( nElement, rAttribs );
     275             : }
     276             : 
     277             : 
     278             : 
     279          61 : ValAxisContext::ValAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
     280          61 :     AxisContextBase( rParent, rModel )
     281             : {
     282          61 : }
     283             : 
     284         122 : ValAxisContext::~ValAxisContext()
     285             : {
     286         122 : }
     287             : 
     288         763 : ContextHandlerRef ValAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     289             : {
     290         763 :     if( isRootElement() ) switch( nElement )
     291             :     {
     292             :         case C_TOKEN( crossBetween ):
     293          32 :             mrModel.mnCrossBetween = rAttribs.getToken( XML_val, XML_between );
     294          32 :             return 0;
     295             :         case C_TOKEN( dispUnits ):
     296           2 :             return new AxisDispUnitsContext( *this, mrModel.mxDispUnits.create() );
     297             :         case C_TOKEN( majorUnit ):
     298           0 :             mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
     299           0 :             return 0;
     300             :         case C_TOKEN( minorUnit ):
     301           0 :             mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
     302           0 :             return 0;
     303             :     }
     304         729 :     return AxisContextBase::onCreateContext( nElement, rAttribs );
     305             : }
     306             : 
     307             : 
     308             : 
     309             : } // namespace chart
     310             : } // namespace drawingml
     311         177 : } // namespace oox
     312             : 
     313             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10