LCOV - code coverage report
Current view: top level - oox/source/drawingml - transform2dcontext.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 31 31 100.0 %
Date: 2014-04-11 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::ContextHandlerRef;
      32             : 
      33             : namespace oox {
      34             : namespace drawingml {
      35             : 
      36             : /** context to import a CT_Transform2D */
      37        2101 : Transform2DContext::Transform2DContext( ContextHandler2Helper& rParent, const AttributeList& rAttribs, Shape& rShape, bool btxXfrm ) throw()
      38             : : ContextHandler2( rParent )
      39             : , mrShape( rShape )
      40        2101 : , mbtxXfrm ( btxXfrm )
      41             : {
      42        2101 :     if( !btxXfrm )
      43             :     {
      44        2039 :         mrShape.setRotation( rAttribs.getInteger( XML_rot, 0 ) ); // 60000ths of a degree Positive angles are clockwise; negative angles are counter-clockwise
      45        2039 :         mrShape.setFlip( rAttribs.getBool( XML_flipH, false ), rAttribs.getBool( XML_flipV, false ) );
      46             :     }
      47             :     else
      48             :     {
      49          62 :         if( rAttribs.hasAttribute( XML_rot ) )
      50           1 :             mrShape.getTextBody()->getTextProperties().moRotation = -rAttribs.getInteger( XML_rot ).get();
      51             :     }
      52        2101 : }
      53             : 
      54        4458 : ContextHandlerRef Transform2DContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      55             : {
      56        4458 :     if( mbtxXfrm )
      57             :     {
      58         124 :         switch( aElementToken )
      59             :         {
      60             :             case A_TOKEN( off ):
      61             :                 {
      62          62 :                     OUString sXValue = rAttribs.getString( XML_x ).get();
      63         124 :                     OUString sYValue = rAttribs.getString( XML_y ).get();
      64          62 :                     if( !sXValue.isEmpty() )
      65          62 :                         mrShape.getTextBody()->getTextProperties().moTextOffX = GetCoordinate( sXValue.toInt32() - mrShape.getPosition().X );
      66          62 :                     if( !sYValue.isEmpty() )
      67         124 :                         mrShape.getTextBody()->getTextProperties().moTextOffY = GetCoordinate( sYValue.toInt32() - mrShape.getPosition().Y );
      68             :                 }
      69          62 :                 break;
      70             :             case A_TOKEN( ext ):
      71          62 :                 break;
      72             :         }
      73         124 :         return 0;
      74             :     }
      75             : 
      76        4334 :     switch( aElementToken )
      77             :     {
      78             :     case A_TOKEN( off ):        // horz/vert translation
      79        2039 :         mrShape.setPosition( awt::Point( rAttribs.getString( XML_x ).get().toInt32(), rAttribs.getString( XML_y ).get().toInt32() ) );
      80        2039 :         break;
      81             :     case A_TOKEN( ext ):        // horz/vert size
      82        2039 :         mrShape.setSize( awt::Size( rAttribs.getString( XML_cx ).get().toInt32(), rAttribs.getString( XML_cy ).get().toInt32() ) );
      83        2039 :         break;
      84             :     case A_TOKEN( chOff ):  // horz/vert translation of children
      85         128 :         mrShape.setChildPosition( awt::Point( rAttribs.getString( XML_x ).get().toInt32(), rAttribs.getString( XML_y ).get().toInt32() ) );
      86         128 :         break;
      87             :     case A_TOKEN( chExt ):  // horz/vert size of children
      88         128 :         mrShape.setChildSize( awt::Size( rAttribs.getString( XML_cx ).get().toInt32(), rAttribs.getString( XML_cy ).get().toInt32() ) );
      89         128 :         break;
      90             :     }
      91             : 
      92        4334 :     return 0;
      93             : }
      94             : 
      95             : } // namespace drawingml
      96         177 : } // namespace oox
      97             : 
      98             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10