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

Generated by: LCOV version 1.10