LCOV - code coverage report
Current view: top level - libreoffice/oox/source/drawingml - textbodyproperties.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 37 62.2 %
Date: 2012-12-27 Functions: 3 3 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 <com/sun/star/text/WritingMode.hpp>
      21             : #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
      22             : #include "oox/drawingml/drawingmltypes.hxx"
      23             : #include "oox/drawingml/textbodyproperties.hxx"
      24             : #include "oox/token/tokens.hxx"
      25             : 
      26             : using namespace ::com::sun::star::drawing;
      27             : using namespace ::com::sun::star::text;
      28             : 
      29             : namespace oox {
      30             : namespace drawingml {
      31             : 
      32             : // ============================================================================
      33             : 
      34          53 : TextBodyProperties::TextBodyProperties():
      35          53 :     meVA( TextVerticalAdjust_TOP )
      36             : {
      37          53 : }
      38             : 
      39             : /* For Legacy purposes: TODO: Check if it is required at all! */
      40          17 : void TextBodyProperties::pushVertSimulation()
      41             : {
      42          17 :     sal_Int32 tVert = moVert.get( XML_horz );
      43          17 :     if( tVert == XML_vert || tVert == XML_eaVert || tVert == XML_vert270 || tVert == XML_mongolianVert ) {
      44             :         // #160799# fake different vertical text modes by top-bottom writing mode
      45           0 :         maPropertyMap[ PROP_TextWritingMode ] <<= WritingMode_TB_RL;
      46             : 
      47             :         // workaround for TB_LR as using WritingMode2 doesn't work
      48           0 :         if( meVA != TextVerticalAdjust_CENTER )
      49           0 :             maPropertyMap[ PROP_TextHorizontalAdjust ] <<=
      50           0 :                                 (tVert == XML_vert270) ? TextHorizontalAdjust_RIGHT : TextHorizontalAdjust_LEFT;
      51           0 :         if( tVert == XML_vert270 )
      52           0 :             maPropertyMap[ PROP_TextVerticalAdjust ] <<= TextVerticalAdjust_BOTTOM;
      53           0 :         if( ( tVert == XML_vert && meVA == TextVerticalAdjust_TOP ) ||
      54             :             ( tVert == XML_vert270 && meVA == TextVerticalAdjust_BOTTOM ) )
      55           0 :             maPropertyMap[ PROP_TextHorizontalAdjust ] <<= TextHorizontalAdjust_RIGHT;
      56           0 :         else if( meVA == TextVerticalAdjust_CENTER )
      57           0 :             maPropertyMap[ PROP_TextHorizontalAdjust ] <<= TextHorizontalAdjust_CENTER;
      58             :     }
      59          17 : }
      60             : 
      61             : /* Push adjusted values, taking into consideration Shape Rotation */
      62          22 : void TextBodyProperties::pushRotationAdjustments( sal_Int32 nRotation )
      63             : {
      64          22 :     sal_Int32 nOff      = 0;
      65          22 :     sal_Int32 aProps[]  = { PROP_TextLeftDistance, PROP_TextUpperDistance, PROP_TextRightDistance, PROP_TextLowerDistance };
      66          22 :     sal_Int32 n         = ( sal_Int32 )( sizeof( aProps ) / sizeof( sal_Int32 ) );
      67             : 
      68          22 :     switch( nRotation ) // TODO: What happens for part rotations ?
      69             :     {
      70           0 :         case (90*1*60000): nOff = 1; break;
      71           0 :         case (90*2*60000): nOff = 2; break;
      72           0 :         case (90*3*60000): nOff = 3; break;
      73          22 :         default: break;
      74             :     }
      75             : 
      76         110 :     for( sal_Int32 i = 0; i < n; i++ )
      77             :     {
      78          88 :         sal_Int32 nVal = 0;
      79             : 
      80             :         // Hack for n#760986
      81             :         // TODO: Preferred method would be to have a textbox on top
      82             :         // of the shape and the place it according to the (off,ext)
      83          88 :         if( nOff == 0 && moTextOffX ) nVal = *moTextOffX;
      84          88 :         if( nOff == 1 && moTextOffY ) nVal = *moTextOffY;
      85          88 :         if( nVal < 0 ) nVal = 0;
      86             : 
      87          88 :         if( moInsets[i] )
      88          84 :             maPropertyMap[ aProps[ nOff ] ] <<= static_cast< sal_Int32 >( *moInsets[i] + nVal );
      89           4 :         else if( nVal )
      90           0 :             maPropertyMap[ aProps[ nOff ] ] <<= static_cast< sal_Int32 >( nVal );
      91             : 
      92          88 :         nOff = (nOff+1) % n;
      93             :     }
      94          22 : }
      95             : 
      96             : // ============================================================================
      97             : 
      98             : } // namespace drawingml
      99             : } // namespace oox
     100             : 
     101             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10