LCOV - code coverage report
Current view: top level - libreoffice/oox/source/drawingml - textbodycontext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 64 64 100.0 %
Date: 2012-12-17 Functions: 14 14 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         372 : class TextParagraphContext : public ContextHandler
      40             : {
      41             : public:
      42             :     TextParagraphContext( ContextHandler& rParent, TextParagraph& rPara );
      43             : 
      44             :     virtual void SAL_CALL endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException);
      45             :     virtual Reference< XFastContextHandler > SAL_CALL createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException);
      46             : 
      47             : protected:
      48             :     TextParagraph& mrParagraph;
      49             : };
      50             : 
      51             : // --------------------------------------------------------------------
      52         186 : TextParagraphContext::TextParagraphContext( ContextHandler& rParent, TextParagraph& rPara )
      53             : : ContextHandler( rParent )
      54         186 : , mrParagraph( rPara )
      55             : {
      56         186 : }
      57             : 
      58             : // --------------------------------------------------------------------
      59         186 : void TextParagraphContext::endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException)
      60             : {
      61             :     if( aElementToken == (A_TOKEN( p )) )
      62             :     {
      63             :     }
      64         186 : }
      65             : 
      66             : // --------------------------------------------------------------------
      67             : 
      68         412 : Reference< XFastContextHandler > TextParagraphContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
      69             : {
      70         412 :     Reference< XFastContextHandler > xRet;
      71             : 
      72             :     // EG_TextRun
      73         412 :     switch( aElementToken )
      74             :     {
      75             :     case A_TOKEN( r ):      // "CT_RegularTextRun" Regular Text Run.
      76             :     {
      77         150 :         TextRunPtr pRun( new TextRun );
      78         150 :         mrParagraph.addRun( pRun );
      79         150 :         xRet.set( new RegularTextRunContext( *this, pRun ) );
      80         150 :         break;
      81             :     }
      82             :     case A_TOKEN( br ): // "CT_TextLineBreak" Soft return line break (vertical tab).
      83             :     {
      84           4 :         TextRunPtr pRun( new TextRun );
      85           4 :         pRun->setLineBreak();
      86           4 :         mrParagraph.addRun( pRun );
      87           4 :         xRet.set( new RegularTextRunContext( *this, pRun ) );
      88           4 :         break;
      89             :     }
      90             :     case A_TOKEN( fld ):    // "CT_TextField" Text Field.
      91             :     {
      92          24 :         TextFieldPtr pField( new TextField );
      93          24 :         mrParagraph.addRun( pField );
      94          24 :         xRet.set( new TextFieldContext( *this, xAttribs, *pField ) );
      95          24 :         break;
      96             :     }
      97             :     case A_TOKEN( pPr ):
      98         124 :         xRet.set( new TextParagraphPropertiesContext( *this, xAttribs, mrParagraph.getProperties() ) );
      99         124 :         break;
     100             :     case A_TOKEN( endParaRPr ):
     101         110 :         xRet.set( new TextCharacterPropertiesContext( *this, xAttribs, mrParagraph.getEndProperties() ) );
     102         110 :         break;
     103             :     }
     104             : 
     105         412 :     return xRet;
     106             : }
     107             : // --------------------------------------------------------------------
     108             : 
     109         154 : RegularTextRunContext::RegularTextRunContext( ContextHandler& rParent, TextRunPtr pRunPtr )
     110             : : ContextHandler( rParent )
     111             : , mpRunPtr( pRunPtr )
     112         154 : , mbIsInText( false )
     113             : {
     114         154 : }
     115             : 
     116             : // --------------------------------------------------------------------
     117             : 
     118         304 : void RegularTextRunContext::endFastElement( sal_Int32 aElementToken ) throw (SAXException, RuntimeException)
     119             : {
     120         304 :     switch( aElementToken )
     121             :     {
     122             :     case A_TOKEN( t ):
     123             :     {
     124         150 :         mbIsInText = false;
     125         150 :         break;
     126             :     }
     127             :     case A_TOKEN( r ):
     128             :     {
     129         150 :         break;
     130             :     }
     131             : 
     132             :     }
     133         304 : }
     134             : 
     135             : // --------------------------------------------------------------------
     136             : 
     137         154 : void RegularTextRunContext::characters( const OUString& aChars ) throw (SAXException, RuntimeException)
     138             : {
     139         154 :     if( mbIsInText )
     140             :     {
     141         154 :         mpRunPtr->getText() += aChars;
     142             :     }
     143         154 : }
     144             : 
     145             : // --------------------------------------------------------------------
     146             : 
     147         304 : Reference< XFastContextHandler > RegularTextRunContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs) throw (SAXException, RuntimeException)
     148             : {
     149         304 :     Reference< XFastContextHandler > xRet( this );
     150             : 
     151         304 :     switch( aElementToken )
     152             :     {
     153             :     case A_TOKEN( rPr ):    // "CT_TextCharPropertyBag" The text char properties of this text run.
     154         154 :         xRet.set( new TextCharacterPropertiesContext( *this, xAttribs, mpRunPtr->getTextCharacterProperties() ) );
     155         154 :         break;
     156             :     case A_TOKEN( t ):      // "xsd:string" minOccurs="1" The actual text string.
     157         150 :         mbIsInText = true;
     158         150 :         break;
     159             :     }
     160             : 
     161         304 :     return xRet;
     162             : }
     163             : 
     164             : // --------------------------------------------------------------------
     165             : 
     166         102 : TextBodyContext::TextBodyContext( ContextHandler& rParent, TextBody& rTextBody )
     167             : : ContextHandler( rParent )
     168         102 : , mrTextBody( rTextBody )
     169             : {
     170         102 : }
     171             : 
     172             : // --------------------------------------------------------------------
     173             : 
     174         102 : void TextBodyContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
     175             : {
     176         102 : }
     177             : 
     178             : // --------------------------------------------------------------------
     179             : 
     180         372 : Reference< XFastContextHandler > TextBodyContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
     181             : {
     182         372 :     Reference< XFastContextHandler > xRet;
     183             : 
     184         372 :     switch( aElementToken )
     185             :     {
     186             :     case A_TOKEN( bodyPr ):     // CT_TextBodyPropertyBag
     187         102 :         xRet.set( new TextBodyPropertiesContext( *this, xAttribs, mrTextBody.getTextProperties() ) );
     188         102 :         break;
     189             :     case A_TOKEN( lstStyle ):   // CT_TextListStyle
     190          84 :         xRet.set( new TextListStyleContext( *this, mrTextBody.getTextListStyle() ) );
     191          84 :         break;
     192             :     case A_TOKEN( p ):          // CT_TextParagraph
     193         186 :         xRet.set( new TextParagraphContext( *this, mrTextBody.addParagraph() ) );
     194         186 :         break;
     195             :     }
     196             : 
     197         372 :     return xRet;
     198             : }
     199             : 
     200             : // --------------------------------------------------------------------
     201             : 
     202         174 : } }
     203             : 
     204             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10