LCOV - code coverage report
Current view: top level - oox/source/drawingml - transform2dcontext.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 44 44 100.0 %
Date: 2014-11-03 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 "drawingml/transform2dcontext.hxx"
      21             : #include "oox/helper/attributelist.hxx"
      22             : #include "oox/drawingml/shape.hxx"
      23             : #include "drawingml/customshapeproperties.hxx"
      24             : #include "drawingml/textbody.hxx"
      25             : 
      26             : using namespace ::com::sun::star;
      27             : using ::com::sun::star::uno::Reference;
      28             : using ::com::sun::star::uno::RuntimeException;
      29             : using ::com::sun::star::xml::sax::SAXException;
      30             : using ::com::sun::star::xml::sax::XFastAttributeList;
      31             : using ::com::sun::star::xml::sax::XFastContextHandler;
      32             : using ::oox::core::ContextHandlerRef;
      33             : 
      34             : namespace oox {
      35             : namespace drawingml {
      36             : 
      37             : /** context to import a CT_Transform2D */
      38        5760 : Transform2DContext::Transform2DContext( ContextHandler2Helper& rParent, const AttributeList& rAttribs, Shape& rShape, bool btxXfrm ) throw()
      39             : : ContextHandler2( rParent )
      40             : , mrShape( rShape )
      41        5760 : , mbtxXfrm ( btxXfrm )
      42             : {
      43        5760 :     if( !btxXfrm )
      44             :     {
      45        5630 :         mrShape.setRotation( rAttribs.getInteger( XML_rot, 0 ) ); // 60000ths of a degree Positive angles are clockwise; negative angles are counter-clockwise
      46        5630 :         mrShape.setFlip( rAttribs.getBool( XML_flipH, false ), rAttribs.getBool( XML_flipV, false ) );
      47             :     }
      48             :     else
      49             :     {
      50         130 :         if( rAttribs.hasAttribute( XML_rot ) )
      51           2 :             mrShape.getTextBody()->getTextProperties().moRotation = -rAttribs.getInteger( XML_rot ).get();
      52             :     }
      53        5760 : }
      54             : 
      55       12440 : ContextHandlerRef Transform2DContext::onCreateContext( sal_Int32 aElementToken, const AttributeList& rAttribs )
      56             : {
      57       12440 :     if( mbtxXfrm )
      58             :     {
      59             :         // Workaround: only for rectangles
      60         260 :         const sal_Int32 nType = mrShape.getCustomShapeProperties()->getShapePresetType();
      61         260 :         if( nType == XML_rect || nType == XML_roundRect )
      62             :         {
      63         256 :             switch( aElementToken )
      64             :             {
      65             :                 case A_TOKEN( off ):
      66             :                     {
      67         128 :                         const OUString sXValue = rAttribs.getString( XML_x ).get();
      68         256 :                         const OUString sYValue = rAttribs.getString( XML_y ).get();
      69         128 :                         if( !sXValue.isEmpty() && nType == XML_rect )
      70         120 :                             mrShape.getTextBody()->getTextProperties().moTextOffLeft = GetCoordinate( sXValue.toInt32() - mrShape.getPosition().X );
      71         128 :                         if( !sYValue.isEmpty() )
      72         256 :                             mrShape.getTextBody()->getTextProperties().moTextOffUpper = GetCoordinate( sYValue.toInt32() - mrShape.getPosition().Y );
      73             :                     }
      74         128 :                     break;
      75             :                 case A_TOKEN( ext ):
      76             :                     {
      77         128 :                         const OUString sXValue = rAttribs.getString( XML_cx ).get();
      78         256 :                         const OUString sYValue = rAttribs.getString( XML_cy ).get();
      79             : 
      80         128 :                         if( !sXValue.isEmpty() && nType == XML_rect )
      81             :                         {
      82         120 :                             mrShape.getTextBody()->getTextProperties().moTextOffRight = GetCoordinate(mrShape.getSize().Width - sXValue.toInt32());
      83         120 :                             if( mrShape.getTextBody()->getTextProperties().moTextOffLeft )
      84         120 :                                *mrShape.getTextBody()->getTextProperties().moTextOffRight -=  *mrShape.getTextBody()->getTextProperties().moTextOffLeft;
      85             :                         }
      86         128 :                         if( !sYValue.isEmpty() )
      87             :                         {
      88         128 :                             mrShape.getTextBody()->getTextProperties().moTextOffLower = GetCoordinate(mrShape.getSize().Height - sYValue.toInt32());
      89         128 :                             if( mrShape.getTextBody()->getTextProperties().moTextOffUpper )
      90         128 :                                *mrShape.getTextBody()->getTextProperties().moTextOffLower -=  *mrShape.getTextBody()->getTextProperties().moTextOffUpper;
      91             : 
      92         128 :                         }
      93             :                     }
      94         128 :                     break;
      95             :             }
      96             :         }
      97         260 :         return 0;
      98             :     }
      99             : 
     100       12180 :     switch( aElementToken )
     101             :     {
     102             :     case A_TOKEN( off ):        // horz/vert translation
     103        5630 :         mrShape.setPosition( awt::Point( rAttribs.getString( XML_x ).get().toInt32(), rAttribs.getString( XML_y ).get().toInt32() ) );
     104        5630 :         break;
     105             :     case A_TOKEN( ext ):        // horz/vert size
     106        5630 :         mrShape.setSize( awt::Size( rAttribs.getString( XML_cx ).get().toInt32(), rAttribs.getString( XML_cy ).get().toInt32() ) );
     107        5630 :         break;
     108             :     case A_TOKEN( chOff ):  // horz/vert translation of children
     109         460 :         mrShape.setChildPosition( awt::Point( rAttribs.getString( XML_x ).get().toInt32(), rAttribs.getString( XML_y ).get().toInt32() ) );
     110         460 :         break;
     111             :     case A_TOKEN( chExt ):  // horz/vert size of children
     112         460 :         mrShape.setChildSize( awt::Size( rAttribs.getString( XML_cx ).get().toInt32(), rAttribs.getString( XML_cy ).get().toInt32() ) );
     113         460 :         break;
     114             :     }
     115             : 
     116       12180 :     return 0;
     117             : }
     118             : 
     119             : } // namespace drawingml
     120         408 : } // namespace oox
     121             : 
     122             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10