LCOV - code coverage report
Current view: top level - oox/source/drawingml - textbodypropertiescontext.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 38 39 97.4 %
Date: 2014-04-11 Functions: 2 2 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/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 namespace ::oox::core;
      31             : using namespace ::com::sun::star;
      32             : using namespace ::com::sun::star::drawing;
      33             : using namespace ::com::sun::star::text;
      34             : using namespace ::com::sun::star::uno;
      35             : using namespace ::com::sun::star::xml::sax;
      36             : 
      37             : namespace oox { namespace drawingml {
      38             : 
      39             : // CT_TextBodyProperties
      40        1804 : TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler2Helper& rParent,
      41             :     const AttributeList& rAttribs, TextBodyProperties& rTextBodyProp )
      42             : : ContextHandler2( rParent )
      43        1804 : , mrTextBodyProp( rTextBodyProp )
      44             : {
      45             :     // ST_TextWrappingType
      46        1804 :     sal_Int32 nWrappingType = rAttribs.getToken( XML_wrap, XML_square );
      47        1804 :     mrTextBodyProp.maPropertyMap.setProperty( PROP_TextWordWrap, static_cast< sal_Bool >( nWrappingType == XML_square ));
      48             : 
      49             :     // ST_Coordinate
      50        1804 :     OUString sValue;
      51        1804 :     sal_Int32 aIns[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
      52        9020 :     for( sal_Int32 i = 0; i < ( sal_Int32 )( sizeof( aIns ) / sizeof( sal_Int32 ) ); i++)
      53             :     {
      54        7216 :         sValue = rAttribs.getString( aIns[i] ).get();
      55        7216 :         if( !sValue.isEmpty() )
      56        1853 :             mrTextBodyProp.moInsets[i] = GetCoordinate( sValue );
      57             :     }
      58             : 
      59        1804 :     mrTextBodyProp.mbAnchorCtr = rAttribs.getBool( XML_anchorCtr, false );
      60        1804 :     if( mrTextBodyProp.mbAnchorCtr )
      61          14 :         mrTextBodyProp.maPropertyMap.setProperty( PROP_TextHorizontalAdjust, TextHorizontalAdjust_CENTER );
      62             : 
      63             : //   bool bCompatLineSpacing = rAttribs.getBool( XML_compatLnSpc, false );
      64             : //   bool bForceAA = rAttribs.getBool( XML_forceAA, false );
      65             : //   bool bFromWordArt = rAttribs.getBool( XML_fromWordArt, false );
      66             : 
      67             :   // ST_TextHorzOverflowType
      68             : //   sal_Int32 nHorzOverflow = rAttribs.getToken( XML_horzOverflow, XML_overflow );
      69             :     // ST_TextVertOverflowType
      70             : //   sal_Int32 nVertOverflow =  rAttribs.getToken( XML_vertOverflow, XML_overflow );
      71             : 
      72             :     // ST_TextColumnCount
      73             : //   sal_Int32 nNumCol = rAttribs.getInteger( XML_numCol, 1 );
      74             : 
      75             :     // ST_Angle
      76        1804 :     mrTextBodyProp.moRotation = rAttribs.getInteger( XML_rot );
      77             : 
      78             : //   bool bRtlCol = rAttribs.getBool( XML_rtlCol, false );
      79             :     // ST_PositiveCoordinate
      80             : //   sal_Int32 nSpcCol = rAttribs.getInteger( XML_spcCol, 0 );
      81             : //   bool bSpcFirstLastPara = rAttribs.getBool( XML_spcFirstLastPara, 0 );
      82             : //   bool bUpRight = rAttribs.getBool( XML_upright, 0 );
      83             : 
      84             :     // ST_TextVerticalType
      85        1804 :     if( rAttribs.hasAttribute( XML_vert ) ) {
      86         351 :         mrTextBodyProp.moVert = rAttribs.getToken( XML_vert );
      87         351 :         bool bRtl = rAttribs.getBool( XML_rtl, false );
      88         351 :         sal_Int32 tVert = mrTextBodyProp.moVert.get( XML_horz );
      89         351 :         if( tVert == XML_vert || tVert == XML_eaVert || tVert == XML_vert270 || tVert == XML_mongolianVert )
      90           0 :             mrTextBodyProp.moRotation = -5400000*(tVert==XML_vert270?3:1);
      91             :         else
      92             :             mrTextBodyProp.maPropertyMap.setProperty( PROP_TextWritingMode,
      93         351 :                 ( bRtl ? WritingMode_RL_TB : WritingMode_LR_TB ));
      94             :     }
      95             : 
      96             :     // ST_TextAnchoringType
      97        1804 :     if( rAttribs.hasAttribute( XML_anchor ) )
      98             :     {
      99         436 :         mrTextBodyProp.meVA = GetTextVerticalAdjust( rAttribs.getToken( XML_anchor, XML_t ) );
     100         436 :         mrTextBodyProp.maPropertyMap.setProperty( PROP_TextVerticalAdjust, mrTextBodyProp.meVA);
     101             :     }
     102             : 
     103             :     // Push defaults
     104        1804 :     mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight, false);
     105        1804 :     mrTextBodyProp.maPropertyMap.setProperty( PROP_TextFitToSize, drawing::TextFitToSizeType_NONE);
     106        1804 : }
     107             : 
     108         338 : ContextHandlerRef TextBodyPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& /*rAttribs*/)
     109             : {
     110         338 :     switch( aElementToken )
     111             :     {
     112             :             // Sequence
     113             :             case A_TOKEN( prstTxWarp ):     // CT_PresetTextShape
     114             :             case A_TOKEN( prot ):           // CT_TextProtectionProperty
     115          69 :                 break;
     116             : 
     117             :             // EG_TextAutofit
     118             :             case A_TOKEN( noAutofit ):
     119         210 :                 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight, false);   // CT_TextNoAutofit
     120         210 :                 break;
     121             :             case A_TOKEN( normAutofit ):    // CT_TextNormalAutofit
     122          34 :                 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextFitToSize, TextFitToSizeType_AUTOFIT);
     123          34 :                 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight, false);
     124          34 :                 break;
     125             :             case A_TOKEN( spAutoFit ):
     126          21 :                 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight, true);
     127          21 :                 break;
     128             : 
     129             :             case A_TOKEN( scene3d ):        // CT_Scene3D
     130             : 
     131             :             // EG_Text3D
     132             :             case A_TOKEN( sp3d ):           // CT_Shape3D
     133             :             case A_TOKEN( flatTx ):         // CT_FlatText
     134             : 
     135           4 :                 break;
     136             :     }
     137             : 
     138         338 :     return 0;
     139             : }
     140             : 
     141             : } }
     142             : 
     143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10