LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/oox/source/drawingml - textbodycontext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 46 48 95.8 %
Date: 2013-07-09 Functions: 12 12 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 "oox/drawingml/textbodycontext.hxx"
      21             : #include "oox/drawingml/textbodypropertiescontext.hxx"
      22             : #include "oox/drawingml/textparagraph.hxx"
      23             : #include "oox/drawingml/textparagraphpropertiescontext.hxx"
      24             : #include "oox/drawingml/textcharacterpropertiescontext.hxx"
      25             : #include "oox/drawingml/textliststylecontext.hxx"
      26             : #include "oox/drawingml/textfield.hxx"
      27             : #include "oox/drawingml/textfieldcontext.hxx"
      28             : 
      29             : using namespace ::oox::core;
      30             : using namespace ::com::sun::star::uno;
      31             : using namespace ::com::sun::star::text;
      32             : using namespace ::com::sun::star::xml::sax;
      33             : 
      34             : namespace oox { namespace drawingml {
      35             : 
      36             : // --------------------------------------------------------------------
      37             : 
      38             : // CT_TextParagraph
      39         490 : class TextParagraphContext : public ContextHandler2
      40             : {
      41             : public:
      42             :     TextParagraphContext( ContextHandler2Helper& rParent, TextParagraph& rPara );
      43             : 
      44             :     virtual ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) SAL_OVERRIDE;
      45             : 
      46             : protected:
      47             :     TextParagraph& mrParagraph;
      48             : };
      49             : 
      50             : // --------------------------------------------------------------------
      51         245 : TextParagraphContext::TextParagraphContext( ContextHandler2Helper& rParent, TextParagraph& rPara )
      52             : : ContextHandler2( rParent )
      53         245 : , mrParagraph( rPara )
      54             : {
      55         245 : }
      56             : 
      57             : // --------------------------------------------------------------------
      58             : 
      59         498 : ContextHandlerRef TextParagraphContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      60             : {
      61             :     // EG_TextRun
      62         498 :     switch( aElementToken )
      63             :     {
      64             :     case A_TOKEN( r ):      // "CT_RegularTextRun" Regular Text Run.
      65             :     {
      66         107 :         TextRunPtr pRun( new TextRun );
      67         107 :         mrParagraph.addRun( pRun );
      68         107 :         return new RegularTextRunContext( *this, pRun );
      69             :     }
      70             :     case A_TOKEN( br ): // "CT_TextLineBreak" Soft return line break (vertical tab).
      71             :     {
      72           2 :         TextRunPtr pRun( new TextRun );
      73           2 :         pRun->setLineBreak();
      74           2 :         mrParagraph.addRun( pRun );
      75           2 :         return new RegularTextRunContext( *this, pRun );
      76             :     }
      77             :     case A_TOKEN( fld ):    // "CT_TextField" Text Field.
      78             :     {
      79          24 :         TextFieldPtr pField( new TextField );
      80          24 :         mrParagraph.addRun( pField );
      81          24 :         return new TextFieldContext( *this, rAttribs, *pField );
      82             :     }
      83             :     case A_TOKEN( pPr ):
      84         183 :         return new TextParagraphPropertiesContext( *this, rAttribs, mrParagraph.getProperties() );
      85             :     case A_TOKEN( endParaRPr ):
      86         182 :         return new TextCharacterPropertiesContext( *this, rAttribs, mrParagraph.getEndProperties() );
      87             :     }
      88             : 
      89           0 :     return 0;
      90             : }
      91             : // --------------------------------------------------------------------
      92             : 
      93         109 : RegularTextRunContext::RegularTextRunContext( ContextHandler2Helper& rParent, TextRunPtr pRunPtr )
      94             : : ContextHandler2( rParent )
      95             : , mpRunPtr( pRunPtr )
      96         109 : , mbIsInText( false )
      97             : {
      98         109 : }
      99             : 
     100             : // --------------------------------------------------------------------
     101             : 
     102         216 : void RegularTextRunContext::onEndElement( )
     103             : {
     104         216 :     switch( getCurrentElement() )
     105             :     {
     106             :     case A_TOKEN( t ):
     107             :     {
     108         107 :         mbIsInText = false;
     109         107 :         break;
     110             :     }
     111             :     case A_TOKEN( r ):
     112             :     {
     113         107 :         break;
     114             :     }
     115             : 
     116             :     }
     117         216 : }
     118             : 
     119             : // --------------------------------------------------------------------
     120             : 
     121         104 : void RegularTextRunContext::onCharacters( const OUString& aChars )
     122             : {
     123         104 :     if( mbIsInText )
     124             :     {
     125         104 :         mpRunPtr->getText() += aChars;
     126             :     }
     127         104 : }
     128             : 
     129             : // --------------------------------------------------------------------
     130             : 
     131         216 : ContextHandlerRef RegularTextRunContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs)
     132             : {
     133         216 :     switch( aElementToken )
     134             :     {
     135             :     case A_TOKEN( rPr ):    // "CT_TextCharPropertyBag" The text char properties of this text run.
     136         109 :         return new TextCharacterPropertiesContext( *this, rAttribs, mpRunPtr->getTextCharacterProperties() );
     137             :         break;
     138             :     case A_TOKEN( t ):      // "xsd:string" minOccurs="1" The actual text string.
     139         107 :         mbIsInText = true;
     140         107 :         break;
     141             :     }
     142             : 
     143         107 :     return this;
     144             : }
     145             : 
     146             : // --------------------------------------------------------------------
     147             : 
     148         145 : TextBodyContext::TextBodyContext( ContextHandler2Helper& rParent, TextBody& rTextBody )
     149             : : ContextHandler2( rParent )
     150         145 : , mrTextBody( rTextBody )
     151             : {
     152         145 : }
     153             : 
     154             : // --------------------------------------------------------------------
     155             : 
     156         526 : ContextHandlerRef TextBodyContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
     157             : {
     158         526 :     switch( aElementToken )
     159             :     {
     160             :     case A_TOKEN( bodyPr ):     // CT_TextBodyPropertyBag
     161         145 :         return new TextBodyPropertiesContext( *this, rAttribs, mrTextBody.getTextProperties() );
     162             :     case A_TOKEN( lstStyle ):   // CT_TextListStyle
     163         136 :         return new TextListStyleContext( *this, mrTextBody.getTextListStyle() );
     164             :     case A_TOKEN( p ):          // CT_TextParagraph
     165         245 :         return new TextParagraphContext( *this, mrTextBody.addParagraph() );
     166             :     }
     167             : 
     168           0 :     return 0;
     169             : }
     170             : 
     171             : // --------------------------------------------------------------------
     172             : 
     173         141 : } }
     174             : 
     175             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10