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

Generated by: LCOV version 1.11