LCOV - code coverage report
Current view: top level - oox/source/drawingml - textbodycontext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 55 57 96.5 %
Date: 2015-06-13 12:38:46 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 "drawingml/textbodycontext.hxx"
      21             : #include "drawingml/textbodypropertiescontext.hxx"
      22             : #include "drawingml/textparagraph.hxx"
      23             : #include "drawingml/textparagraphpropertiescontext.hxx"
      24             : #include "drawingml/textcharacterpropertiescontext.hxx"
      25             : #include "drawingml/textliststylecontext.hxx"
      26             : #include "drawingml/textfield.hxx"
      27             : #include "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             : // CT_TextParagraph
      37        7722 : class TextParagraphContext : public ContextHandler2
      38             : {
      39             : public:
      40             :     TextParagraphContext( ContextHandler2Helper& rParent, TextParagraph& rPara );
      41             : 
      42             :     virtual ContextHandlerRef onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs ) SAL_OVERRIDE;
      43             : 
      44             : protected:
      45             :     TextParagraph& mrParagraph;
      46             : };
      47             : 
      48        3861 : TextParagraphContext::TextParagraphContext( ContextHandler2Helper& rParent, TextParagraph& rPara )
      49             : : ContextHandler2( rParent )
      50        3861 : , mrParagraph( rPara )
      51             : {
      52        3861 :     mbEnableTrimSpace = false;
      53        3861 : }
      54             : 
      55        7539 : ContextHandlerRef TextParagraphContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      56             : {
      57             :     // EG_TextRun
      58        7539 :     switch( aElementToken )
      59             :     {
      60             :         case A_TOKEN( r ):      // "CT_RegularTextRun" Regular Text Run.
      61             :         case W_TOKEN( r ):
      62             :         {
      63        2314 :             TextRunPtr pRun( new TextRun );
      64        2314 :             mrParagraph.addRun( pRun );
      65        2314 :             return new RegularTextRunContext( *this, pRun );
      66             :         }
      67             :         case A_TOKEN( br ): // "CT_TextLineBreak" Soft return line break (vertical tab).
      68             :         {
      69          22 :             TextRunPtr pRun( new TextRun );
      70          22 :             pRun->setLineBreak();
      71          22 :             mrParagraph.addRun( pRun );
      72          22 :             return new RegularTextRunContext( *this, pRun );
      73             :         }
      74             :         case A_TOKEN( fld ):    // "CT_TextField" Text Field.
      75             :         {
      76         219 :             TextFieldPtr pField( new TextField );
      77         219 :             mrParagraph.addRun( pField );
      78         219 :             return new TextFieldContext( *this, rAttribs, *pField );
      79             :         }
      80             :         case A_TOKEN( pPr ):
      81             :         case W_TOKEN( pPr ):
      82        2006 :             return new TextParagraphPropertiesContext( *this, rAttribs, mrParagraph.getProperties() );
      83             :         case A_TOKEN( endParaRPr ):
      84        2924 :             return new TextCharacterPropertiesContext( *this, rAttribs, mrParagraph.getEndProperties() );
      85             :         case W_TOKEN( sdt ):
      86             :         case W_TOKEN( sdtContent ):
      87          10 :             return this;
      88             :         case W_TOKEN( del ):
      89           1 :         break;
      90             :         case W_TOKEN( ins ):
      91           1 :             return this;
      92             :         break;
      93             :         default:
      94             :             SAL_WARN("oox", "TextParagraphContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
      95             :     }
      96             : 
      97          43 :     return 0;
      98             : }
      99             : 
     100        2336 : RegularTextRunContext::RegularTextRunContext( ContextHandler2Helper& rParent, TextRunPtr pRunPtr )
     101             : : ContextHandler2( rParent )
     102             : , mpRunPtr( pRunPtr )
     103        2336 : , mbIsInText( false )
     104             : {
     105        2336 : }
     106             : 
     107        4648 : void RegularTextRunContext::onEndElement( )
     108             : {
     109        4648 :     switch( getCurrentElement() )
     110             :     {
     111             :         case A_TOKEN( t ):
     112             :         case W_TOKEN( t ):
     113             :         {
     114        2302 :             mbIsInText = false;
     115        2302 :             break;
     116             :         }
     117             :         case A_TOKEN( r ):
     118        2073 :         break;
     119             :     }
     120        4648 : }
     121             : 
     122        2431 : void RegularTextRunContext::onCharacters( const OUString& aChars )
     123             : {
     124        2431 :     if( mbIsInText )
     125             :     {
     126        2300 :         mpRunPtr->getText() += aChars;
     127             :     }
     128        2431 : }
     129             : 
     130        4619 : ContextHandlerRef RegularTextRunContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs)
     131             : {
     132        4619 :     switch( aElementToken )
     133             :     {
     134             :         case A_TOKEN( rPr ):    // "CT_TextCharPropertyBag" The text char properties of this text run.
     135             :         case W_TOKEN( rPr ):
     136        2307 :             return new TextCharacterPropertiesContext( *this, rAttribs, mpRunPtr->getTextCharacterProperties() );
     137             :         case A_TOKEN( t ):      // "xsd:string" minOccurs="1" The actual text string.
     138             :         case W_TOKEN( t ):
     139        2302 :             mbIsInText = true;
     140        2302 :         break;
     141             :         case W_TOKEN( drawing ):
     142           0 :         break;
     143             :         default:
     144             :             SAL_WARN("oox", "RegularTextRunContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
     145          10 :         break;
     146             :     }
     147             : 
     148        2312 :     return this;
     149             : }
     150             : 
     151        3006 : TextBodyContext::TextBodyContext( ContextHandler2Helper& rParent, TextBody& rTextBody )
     152             : : ContextHandler2( rParent )
     153        3006 : , mrTextBody( rTextBody )
     154             : {
     155        3006 : }
     156             : 
     157        9256 : ContextHandlerRef TextBodyContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
     158             : {
     159        9256 :     switch( aElementToken )
     160             :     {
     161             :         case A_TOKEN( bodyPr ):     // CT_TextBodyPropertyBag
     162        2850 :             return new TextBodyPropertiesContext( *this, rAttribs, mrTextBody.getTextProperties() );
     163             :         case A_TOKEN( lstStyle ):   // CT_TextListStyle
     164        2477 :             return new TextListStyleContext( *this, mrTextBody.getTextListStyle() );
     165             :         case A_TOKEN( p ):          // CT_TextParagraph
     166             :         case W_TOKEN( p ):
     167        3861 :             return new TextParagraphContext( *this, mrTextBody.addParagraph() );
     168             :         case W_TOKEN( sdt ):
     169             :         case W_TOKEN( sdtContent ):
     170          36 :             return this;
     171             :         case W_TOKEN( sdtPr ):
     172             :         case W_TOKEN( sdtEndPr ):
     173          32 :         break;
     174             :         case W_TOKEN( tbl ):
     175           0 :         break;
     176             :         default:
     177             :             SAL_WARN("oox", "TextBodyContext::onCreateContext: unhandled element: " << getBaseToken(aElementToken));
     178             :     }
     179             : 
     180          32 :     return 0;
     181             : }
     182             : 
     183         246 : } }
     184             : 
     185             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11