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

Generated by: LCOV version 1.11