LCOV - code coverage report
Current view: top level - libreoffice/oox/source/drawingml - transform2dcontext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 32 65.6 %
Date: 2012-12-27 Functions: 4 4 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/transform2dcontext.hxx"
      21             : #include "oox/helper/attributelist.hxx"
      22             : #include "oox/drawingml/shape.hxx"
      23             : #include "oox/drawingml/textbody.hxx"
      24             : 
      25             : using namespace ::com::sun::star;
      26             : using ::com::sun::star::uno::Reference;
      27             : using ::com::sun::star::uno::RuntimeException;
      28             : using ::com::sun::star::xml::sax::SAXException;
      29             : using ::com::sun::star::xml::sax::XFastAttributeList;
      30             : using ::com::sun::star::xml::sax::XFastContextHandler;
      31             : using ::oox::core::ContextHandler;
      32             : 
      33             : namespace oox {
      34             : namespace drawingml {
      35             : 
      36             : // ============================================================================
      37             : 
      38             : /** context to import a CT_Transform2D */
      39          72 : Transform2DContext::Transform2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, Shape& rShape, bool btxXfrm ) throw()
      40             : : ContextHandler( rParent )
      41             : , mrShape( rShape )
      42          72 : , mbtxXfrm ( btxXfrm )
      43             : {
      44          72 :     AttributeList aAttributeList( xAttribs );
      45          72 :     if( !btxXfrm )
      46             :     {
      47          72 :         mrShape.setRotation( aAttributeList.getInteger( XML_rot, 0 ) ); // 60000ths of a degree Positive angles are clockwise; negative angles are counter-clockwise
      48          72 :         mrShape.setFlip( aAttributeList.getBool( XML_flipH, sal_False ), aAttributeList.getBool( XML_flipV, sal_False ) );
      49             :     }
      50             :     else
      51             :     {
      52           0 :         mrShape.getTextBody()->getTextProperties().moRotation = aAttributeList.getInteger( XML_rot );
      53          72 :     }
      54          72 : }
      55             : 
      56         172 : Reference< XFastContextHandler > Transform2DContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
      57             : {
      58         172 :     if( mbtxXfrm )
      59             :     {
      60           0 :         switch( aElementToken )
      61             :         {
      62             :             case A_TOKEN( off ):
      63             :                 {
      64           0 :                     OUString sXValue = xAttribs->getOptionalValue( XML_x );
      65           0 :                     OUString sYValue = xAttribs->getOptionalValue( XML_y );
      66           0 :                     if( !sXValue.isEmpty() )
      67           0 :                         mrShape.getTextBody()->getTextProperties().moTextOffX = GetCoordinate( sXValue.toInt32() - mrShape.getPosition().X );
      68           0 :                     if( !sYValue.isEmpty() )
      69           0 :                         mrShape.getTextBody()->getTextProperties().moTextOffY = GetCoordinate( sYValue.toInt32() - mrShape.getPosition().Y );
      70             :                 }
      71           0 :                 break;
      72             :             case A_TOKEN( ext ):
      73           0 :                 break;
      74             :         }
      75           0 :         return 0;
      76             :     }
      77             : 
      78         172 :     switch( aElementToken )
      79             :     {
      80             :     case A_TOKEN( off ):        // horz/vert translation
      81          72 :         mrShape.setPosition( awt::Point( xAttribs->getOptionalValue( XML_x ).toInt32(), xAttribs->getOptionalValue( XML_y ).toInt32() ) );
      82          72 :         break;
      83             :     case A_TOKEN( ext ):        // horz/vert size
      84          72 :         mrShape.setSize( awt::Size( xAttribs->getOptionalValue( XML_cx ).toInt32(), xAttribs->getOptionalValue( XML_cy ).toInt32() ) );
      85          72 :         break;
      86             :     case A_TOKEN( chOff ):  // horz/vert translation of children
      87          14 :         mrShape.setChildPosition( awt::Point( xAttribs->getOptionalValue( XML_x ).toInt32(), xAttribs->getOptionalValue( XML_y ).toInt32() ) );
      88          14 :         break;
      89             :     case A_TOKEN( chExt ):  // horz/vert size of children
      90          14 :         mrShape.setChildSize( awt::Size( xAttribs->getOptionalValue( XML_cx ).toInt32(), xAttribs->getOptionalValue( XML_cy ).toInt32() ) );
      91          14 :         break;
      92             :     }
      93             : 
      94         172 :     return 0;
      95             : }
      96             : 
      97             : // ============================================================================
      98             : 
      99             : } // namespace drawingml
     100          51 : } // namespace oox
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10