LCOV - code coverage report
Current view: top level - oox/source/drawingml - textbodypropertiescontext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 40 48 83.3 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 51 105 48.6 %

           Branch data     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/textbodypropertiescontext.hxx"
      21                 :            : 
      22                 :            : #include <com/sun/star/text/WritingMode.hpp>
      23                 :            : #include <com/sun/star/drawing/TextFitToSizeType.hpp>
      24                 :            : #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
      25                 :            : #include "oox/drawingml/textbodyproperties.hxx"
      26                 :            : #include "oox/drawingml/drawingmltypes.hxx"
      27                 :            : #include "oox/helper/attributelist.hxx"
      28                 :            : #include "oox/helper/propertymap.hxx"
      29                 :            : 
      30                 :            : using ::rtl::OUString;
      31                 :            : using namespace ::oox::core;
      32                 :            : using namespace ::com::sun::star;
      33                 :            : using namespace ::com::sun::star::drawing;
      34                 :            : using namespace ::com::sun::star::text;
      35                 :            : using namespace ::com::sun::star::uno;
      36                 :            : using namespace ::com::sun::star::xml::sax;
      37                 :            : 
      38                 :            : namespace oox { namespace drawingml {
      39                 :            : 
      40                 :            : // --------------------------------------------------------------------
      41                 :            : 
      42                 :            : // CT_TextBodyProperties
      43                 :        132 : TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler& rParent,
      44                 :            :     const Reference< XFastAttributeList >& xAttributes, TextBodyProperties& rTextBodyProp )
      45                 :            : : ContextHandler( rParent )
      46                 :        132 : , mrTextBodyProp( rTextBodyProp )
      47                 :            : {
      48         [ +  - ]:        132 :     AttributeList aAttribs( xAttributes );
      49                 :            : 
      50                 :            :     // ST_TextWrappingType
      51         [ +  - ]:        132 :     sal_Int32 nWrappingType = aAttribs.getToken( XML_wrap, XML_square );
      52 [ +  - ][ +  - ]:        132 :     mrTextBodyProp.maPropertyMap[ PROP_TextWordWrap ] <<= static_cast< sal_Bool >( nWrappingType == XML_square );
      53                 :            : 
      54                 :            :     // ST_Coordinate
      55                 :        132 :     OUString sValue;
      56                 :        132 :     sal_Int32 aIns[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
      57         [ +  + ]:        660 :     for( sal_Int32 i = 0; i < ( sal_Int32 )( sizeof( aIns ) / sizeof( sal_Int32 ) ); i++)
      58                 :            :     {
      59 [ +  - ][ +  - ]:        528 :         sValue = xAttributes->getOptionalValue( aIns[i] );
      60         [ +  + ]:        528 :         if( !sValue.isEmpty() )
      61 [ +  - ][ +  - ]:        336 :             mrTextBodyProp.moInsets[i] = GetCoordinate( sValue );
      62                 :            :     }
      63                 :            : 
      64         [ +  - ]:        132 :     bool bAnchorCenter = aAttribs.getBool( XML_anchorCtr, false );
      65 [ +  - ][ +  - ]:        132 :     if( xAttributes->hasAttribute( XML_anchorCtr ) ) {
                 [ +  + ]
      66         [ -  + ]:          9 :         if( bAnchorCenter )
      67         [ #  # ]:          0 :             mrTextBodyProp.maPropertyMap[ PROP_TextHorizontalAdjust ] <<=
      68         [ #  # ]:          0 :                 TextHorizontalAdjust_CENTER;
      69                 :            :     }
      70                 :            : //   bool bCompatLineSpacing = aAttribs.getBool( XML_compatLnSpc, false );
      71                 :            : //   bool bForceAA = aAttribs.getBool( XML_forceAA, false );
      72                 :            : //   bool bFromWordArt = aAttribs.getBool( XML_fromWordArt, false );
      73                 :            : 
      74                 :            :   // ST_TextHorzOverflowType
      75                 :            : //   sal_Int32 nHorzOverflow = xAttributes->getOptionalValueToken( XML_horzOverflow, XML_overflow );
      76                 :            :     // ST_TextVertOverflowType
      77                 :            : //   sal_Int32 nVertOverflow =  xAttributes->getOptionalValueToken( XML_vertOverflow, XML_overflow );
      78                 :            : 
      79                 :            :     // ST_TextColumnCount
      80                 :            : //   sal_Int32 nNumCol = aAttribs.getInteger( XML_numCol, 1 );
      81                 :            : 
      82                 :            :     // ST_Angle
      83         [ +  - ]:        132 :     mrTextBodyProp.moRotation = aAttribs.getInteger( XML_rot );
      84                 :            : 
      85                 :            : //   bool bRtlCol = aAttribs.getBool( XML_rtlCol, false );
      86                 :            :     // ST_PositiveCoordinate
      87                 :            : //   sal_Int32 nSpcCol = aAttribs.getInteger( XML_spcCol, 0 );
      88                 :            : //   bool bSpcFirstLastPara = aAttribs.getBool( XML_spcFirstLastPara, 0 );
      89                 :            : //   bool bUpRight = aAttribs.getBool( XML_upright, 0 );
      90                 :            : 
      91                 :            :     // ST_TextVerticalType
      92 [ +  - ][ +  - ]:        132 :     if( xAttributes->hasAttribute( XML_vert ) ) {
                 [ +  + ]
      93         [ +  - ]:         57 :         mrTextBodyProp.moVert = aAttribs.getToken( XML_vert );
      94         [ +  - ]:         57 :         bool bRtl = aAttribs.getBool( XML_rtl, false );
      95                 :         57 :         sal_Int32 tVert = mrTextBodyProp.moVert.get( XML_horz );
      96 [ +  - ][ +  - ]:         57 :         if( tVert == XML_vert || tVert == XML_eaVert || tVert == XML_vert270 || tVert == XML_mongolianVert )
         [ -  + ][ +  - ]
      97 [ #  # ][ #  # ]:          0 :             mrTextBodyProp.moRotation = 5400000*(tVert==XML_vert270?3:1);
      98                 :            :         else
      99         [ +  - ]:         57 :             mrTextBodyProp.maPropertyMap[ PROP_TextWritingMode ]
     100 [ -  + ][ +  - ]:        114 :                 <<= ( bRtl ? WritingMode_RL_TB : WritingMode_LR_TB );
     101                 :            :     }
     102                 :            : 
     103                 :            :     // ST_TextAnchoringType
     104 [ +  - ][ +  - ]:        132 :     if( xAttributes->hasAttribute( XML_anchor ) ) {
                 [ +  + ]
     105 [ +  - ][ +  - ]:         57 :         switch( xAttributes->getOptionalValueToken( XML_anchor, XML_t ) )
              [ +  +  - ]
     106                 :            :         {
     107                 :          6 :             case XML_b :    mrTextBodyProp.meVA = drawing::TextVerticalAdjust_BOTTOM; break;
     108                 :            :             case XML_dist :
     109                 :            :             case XML_just :
     110                 :         51 :             case XML_ctr :  mrTextBodyProp.meVA = drawing::TextVerticalAdjust_CENTER; break;
     111                 :            :             default:
     112                 :          0 :             case XML_t :    mrTextBodyProp.meVA = drawing::TextVerticalAdjust_TOP; break;
     113                 :            :         }
     114 [ +  - ][ +  - ]:         57 :         mrTextBodyProp.maPropertyMap[ PROP_TextVerticalAdjust ] <<= mrTextBodyProp.meVA;
     115         [ +  - ]:        132 :     }
     116                 :        132 : }
     117                 :            : 
     118                 :            : // --------------------------------------------------------------------
     119                 :            : 
     120                 :        132 : void TextBodyPropertiesContext::endFastElement( sal_Int32 ) throw (SAXException, RuntimeException)
     121                 :            : {
     122                 :        132 : }
     123                 :            : 
     124                 :            : // --------------------------------------------------------------------
     125                 :            : 
     126                 :         24 : Reference< XFastContextHandler > TextBodyPropertiesContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& /*xAttributes*/) throw (SAXException, RuntimeException)
     127                 :            : {
     128                 :         24 :     Reference< XFastContextHandler > xRet;
     129   [ -  +  +  -  :         24 :     switch( aElementToken )
                   -  - ]
     130                 :            :     {
     131                 :            :             // Sequence
     132                 :            :             case A_TOKEN( prstTxWarp ):     // CT_PresetTextShape
     133                 :            :             case A_TOKEN( prot ):           // CT_TextProtectionProperty
     134                 :          0 :                 break;
     135                 :            : 
     136                 :            :             // EG_TextAutofit
     137                 :            :             case A_TOKEN( noAutofit ):
     138 [ +  - ][ +  - ]:          9 :                 mrTextBodyProp.maPropertyMap[ PROP_TextAutoGrowHeight ] <<= false;   // CT_TextNoAutofit
     139                 :          9 :                 break;
     140                 :            :             case A_TOKEN( normAutofit ):    // CT_TextNormalAutofit
     141 [ +  - ][ +  - ]:         15 :                 mrTextBodyProp.maPropertyMap[ PROP_TextFitToSize ] <<= TextFitToSizeType_AUTOFIT;
     142 [ +  - ][ +  - ]:         15 :                 mrTextBodyProp.maPropertyMap[ PROP_TextAutoGrowHeight ] <<= false;
     143                 :         15 :                 break;
     144                 :            :             case A_TOKEN( spAutoFit ):
     145 [ #  # ][ #  # ]:          0 :                 mrTextBodyProp.maPropertyMap[ PROP_TextAutoGrowHeight ] <<= true;
     146                 :          0 :                 break;
     147                 :            : 
     148                 :            :             case A_TOKEN( scene3d ):        // CT_Scene3D
     149                 :            : 
     150                 :            :             // EG_Text3D
     151                 :            :             case A_TOKEN( sp3d ):           // CT_Shape3D
     152                 :            :             case A_TOKEN( flatTx ):         // CT_FlatText
     153                 :            : 
     154                 :          0 :                 break;
     155                 :            :     }
     156                 :            : 
     157                 :         24 :     return xRet;
     158                 :            : }
     159                 :            : 
     160                 :            : // --------------------------------------------------------------------
     161                 :            : 
     162                 :            : } }
     163                 :            : 
     164                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10