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

Generated by: LCOV version 1.11