LCOV - code coverage report
Current view: top level - oox/source/drawingml/chart - titlecontext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 40 48 83.3 %
Date: 2014-11-03 Functions: 15 15 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/titlecontext.hxx"
      21             : 
      22             : #include "drawingml/shapepropertiescontext.hxx"
      23             : #include "drawingml/textbodycontext.hxx"
      24             : #include "drawingml/chart/datasourcecontext.hxx"
      25             : #include "drawingml/chart/titlemodel.hxx"
      26             : 
      27             : #include "rtl/ustrbuf.hxx"
      28             : 
      29             : namespace oox {
      30             : namespace drawingml {
      31             : namespace chart {
      32             : 
      33             : using ::oox::core::ContextHandler2Helper;
      34             : using ::oox::core::ContextHandlerRef;
      35             : 
      36         634 : TextContext::TextContext( ContextHandler2Helper& rParent, TextModel& rModel ) :
      37         634 :     ContextBase< TextModel >( rParent, rModel )
      38             : {
      39         634 : }
      40             : 
      41        1268 : TextContext::~TextContext()
      42             : {
      43        1268 : }
      44             : 
      45         634 : ContextHandlerRef TextContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
      46             : {
      47             :     // this context handler is used for <c:tx> and embedded <c:v> elements
      48         634 :     if( isCurrentElement( C_TOKEN( tx ) ) ) switch( nElement )
      49             :     {
      50             :         case C_TOKEN( rich ):
      51         156 :             return new TextBodyContext( *this, mrModel.mxTextBody.create() );
      52             : 
      53             :         case C_TOKEN( strRef ):
      54             :             OSL_ENSURE( !mrModel.mxDataSeq, "TextContext::onCreateContext - multiple data sequences" );
      55         478 :             return new StringSequenceContext( *this, mrModel.mxDataSeq.create() );
      56             : 
      57             :         case C_TOKEN( v ):
      58             :             OSL_ENSURE( !mrModel.mxDataSeq, "TextContext::onCreateContext - multiple data sequences" );
      59           0 :             return this;    // collect value in onCharacters()
      60             :     }
      61           0 :     return 0;
      62             : }
      63             : 
      64           4 : void TextContext::onCharacters( const OUString& rChars )
      65             : {
      66           4 :     if( isCurrentElement( C_TOKEN( v ) ) )
      67             :     {
      68             :         // Static text is stored as a single string formula token for Excel document.
      69           0 :         OUStringBuffer aBuf;
      70           0 :         aBuf.append('"').append(rChars).append('"');
      71           0 :         mrModel.mxDataSeq.create().maFormula = aBuf.makeStringAndClear();
      72             : 
      73             :         // Also store it as a single element type for non-Excel document.
      74           0 :         mrModel.mxDataSeq->maData[0] <<= rChars;
      75             :     }
      76           4 : }
      77             : 
      78         132 : TitleContext::TitleContext( ContextHandler2Helper& rParent, TitleModel& rModel ) :
      79         132 :     ContextBase< TitleModel >( rParent, rModel )
      80             : {
      81         132 : }
      82             : 
      83         264 : TitleContext::~TitleContext()
      84             : {
      85         264 : }
      86             : 
      87         296 : ContextHandlerRef TitleContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
      88             : {
      89             :     // this context handler is used for <c:title> only
      90         296 :     switch( nElement )
      91             :     {
      92             :         case C_TOKEN( layout ):
      93         114 :             return new LayoutContext( *this, mrModel.mxLayout.create() );
      94             : 
      95             :         case C_TOKEN( overlay ):
      96             :             // default is 'false', not 'true' as specified
      97          68 :             mrModel.mbOverlay = rAttribs.getBool( XML_val, false );
      98          68 :             return 0;
      99             : 
     100             :         case C_TOKEN( spPr ):
     101          16 :             return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
     102             : 
     103             :         case C_TOKEN( tx ):
     104          82 :             return new TextContext( *this, mrModel.mxText.create() );
     105             : 
     106             :         case C_TOKEN( txPr ):
     107          16 :             return new TextBodyContext( *this, mrModel.mxTextProp.create() );
     108             :     }
     109           0 :     return 0;
     110             : }
     111             : 
     112         182 : LegendContext::LegendContext( ContextHandler2Helper& rParent, LegendModel& rModel ) :
     113         182 :     ContextBase< LegendModel >( rParent, rModel )
     114             : {
     115         182 : }
     116             : 
     117         364 : LegendContext::~LegendContext()
     118             : {
     119         364 : }
     120             : 
     121         534 : ContextHandlerRef LegendContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
     122             : {
     123             :     // this context handler is used for <c:legend> only
     124         534 :     switch( nElement )
     125             :     {
     126             :         case C_TOKEN( layout ):
     127          82 :             return new LayoutContext( *this, mrModel.mxLayout.create() );
     128             : 
     129             :         case C_TOKEN( legendPos ):
     130         180 :             mrModel.mnPosition = rAttribs.getToken( XML_val, XML_r );
     131         180 :             return 0;
     132             : 
     133             :         case C_TOKEN( overlay ):
     134             :             // default is 'false', not 'true' as specified
     135         164 :             mrModel.mbOverlay = rAttribs.getBool( XML_val, false );
     136         164 :             return 0;
     137             : 
     138             :         case C_TOKEN( spPr ):
     139          96 :             return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
     140             : 
     141             :         case C_TOKEN( txPr ):
     142          12 :             return new TextBodyContext( *this, mrModel.mxTextProp.create() );
     143             :     }
     144           0 :     return 0;
     145             : }
     146             : 
     147             : } // namespace chart
     148             : } // namespace drawingml
     149         408 : } // namespace oox
     150             : 
     151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10