LCOV - code coverage report
Current view: top level - oox/source/drawingml - textbodypropertiescontext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 40 41 97.6 %
Date: 2014-11-03 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 "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 "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        5274 : TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler2Helper& rParent,
      41             :     const AttributeList& rAttribs, TextBodyProperties& rTextBodyProp )
      42             : : ContextHandler2( rParent )
      43        5274 : , mrTextBodyProp( rTextBodyProp )
      44             : {
      45             :     // ST_TextWrappingType
      46        5274 :     sal_Int32 nWrappingType = rAttribs.getToken( XML_wrap, XML_square );
      47        5274 :     mrTextBodyProp.maPropertyMap.setProperty( PROP_TextWordWrap, nWrappingType == XML_square );
      48             : 
      49             :     // ST_Coordinate
      50        5274 :     OUString sValue;
      51        5274 :     sal_Int32 aIns[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
      52       26370 :     for( sal_Int32 i = 0; i < ( sal_Int32 )( sizeof( aIns ) / sizeof( sal_Int32 ) ); i++)
      53             :     {
      54       21096 :         sValue = rAttribs.getString( aIns[i] ).get();
      55       21096 :         if( !sValue.isEmpty() )
      56        5362 :             mrTextBodyProp.moInsets[i] = GetCoordinate( sValue );
      57             :     }
      58             : 
      59        5274 :     mrTextBodyProp.mbAnchorCtr = rAttribs.getBool( XML_anchorCtr, false );
      60        5274 :     if( mrTextBodyProp.mbAnchorCtr )
      61          68 :         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        5274 :     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        5274 :     if( rAttribs.hasAttribute( XML_vert ) ) {
      86        1032 :         mrTextBodyProp.moVert = rAttribs.getToken( XML_vert );
      87        1032 :         bool bRtl = rAttribs.getBool( XML_rtl, false );
      88        1032 :         sal_Int32 tVert = mrTextBodyProp.moVert.get( XML_horz );
      89        1032 :         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        1032 :                 ( bRtl ? WritingMode_RL_TB : WritingMode_LR_TB ));
      94             :     }
      95             : 
      96             :     // ST_TextAnchoringType
      97        5274 :     if( rAttribs.hasAttribute( XML_anchor ) )
      98             :     {
      99        1342 :         mrTextBodyProp.meVA = GetTextVerticalAdjust( rAttribs.getToken( XML_anchor, XML_t ) );
     100        1342 :         mrTextBodyProp.maPropertyMap.setProperty( PROP_TextVerticalAdjust, mrTextBodyProp.meVA);
     101             :     }
     102             : 
     103             :     // Push defaults
     104        5274 :     mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight, false);
     105        5274 :     mrTextBodyProp.maPropertyMap.setProperty( PROP_TextFitToSize, drawing::TextFitToSizeType_NONE);
     106        5274 : }
     107             : 
     108        1140 : ContextHandlerRef TextBodyPropertiesContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& /*rAttribs*/)
     109             : {
     110        1140 :     switch( aElementToken )
     111             :     {
     112             :             // Sequence
     113             :             case A_TOKEN( prstTxWarp ):     // CT_PresetTextShape
     114             :             case A_TOKEN( prot ):           // CT_TextProtectionProperty
     115         178 :                 break;
     116             : 
     117             :             // EG_TextAutofit
     118             :             case A_TOKEN( noAutofit ):
     119         580 :                 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight, false);   // CT_TextNoAutofit
     120         580 :                 break;
     121             :             case A_TOKEN( normAutofit ):    // CT_TextNormalAutofit
     122         144 :                 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextFitToSize, TextFitToSizeType_AUTOFIT);
     123         144 :                 mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight, false);
     124         144 :                 break;
     125             :             case A_TOKEN( spAutoFit ):
     126             :                 {
     127         230 :                     const sal_Int32 tVert = mrTextBodyProp.moVert.get( XML_horz );
     128         230 :                     if( tVert != XML_vert && tVert != XML_eaVert && tVert != XML_vert270 && tVert != XML_mongolianVert )
     129         230 :                         mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight, true);
     130             :                 }
     131         230 :                 break;
     132             : 
     133             :             case A_TOKEN( scene3d ):        // CT_Scene3D
     134             : 
     135             :             // EG_Text3D
     136             :             case A_TOKEN( sp3d ):           // CT_Shape3D
     137             :             case A_TOKEN( flatTx ):         // CT_FlatText
     138             : 
     139           8 :                 break;
     140             :     }
     141             : 
     142        1140 :     return 0;
     143             : }
     144             : 
     145             : } }
     146             : 
     147             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10