LCOV - code coverage report
Current view: top level - chart2/source/view/main - VTitle.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 43 49 87.8 %
Date: 2014-04-11 Functions: 9 9 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 "VTitle.hxx"
      21             : #include "CommonConverters.hxx"
      22             : #include "macros.hxx"
      23             : #include "PropertyMapper.hxx"
      24             : #include "AbstractShapeFactory.hxx"
      25             : #include <com/sun/star/chart2/XFormattedString.hpp>
      26             : #include <rtl/math.hxx>
      27             : #include <com/sun/star/beans/XPropertySet.hpp>
      28             : #include <com/sun/star/text/ControlCharacter.hpp>
      29             : #include <com/sun/star/text/XText.hpp>
      30             : #include <com/sun/star/text/XTextCursor.hpp>
      31             : 
      32             : namespace chart
      33             : {
      34             : using namespace ::com::sun::star;
      35             : using namespace ::com::sun::star::chart2;
      36             : 
      37         528 : VTitle::VTitle( const uno::Reference< XTitle > & xTitle )
      38             :                 : m_xTarget(NULL)
      39             :                 , m_xShapeFactory(NULL)
      40             :                 , m_xTitle(xTitle)
      41             :                 , m_xShape(NULL)
      42             :                 , m_aCID()
      43             :                 , m_fRotationAngleDegree(0.0)
      44             :                 , m_nXPos(0)
      45         528 :                 , m_nYPos(0)
      46             : {
      47         528 : }
      48             : 
      49        1056 : VTitle::~VTitle()
      50             : {
      51        1056 : }
      52             : 
      53         528 : void VTitle::init(
      54             :               const uno::Reference< drawing::XShapes >& xTargetPage
      55             :             , const uno::Reference< lang::XMultiServiceFactory >& xFactory
      56             :             , const OUString& rCID )
      57             : {
      58         528 :     m_xTarget = xTargetPage;
      59         528 :     m_xShapeFactory = xFactory;
      60         528 :     m_aCID = rCID;
      61         528 : }
      62             : 
      63         368 : double VTitle::getRotationAnglePi() const
      64             : {
      65         368 :     return m_fRotationAngleDegree*F_PI/180.0;
      66             : }
      67             : 
      68         528 : awt::Size VTitle::getUnrotatedSize() const //size before rotation
      69             : {
      70         528 :     awt::Size aRet;
      71         528 :     if(m_xShape.is())
      72         528 :         aRet = m_xShape->getSize();
      73         528 :     return aRet;
      74             : }
      75             : 
      76         533 : awt::Size VTitle::getFinalSize() const //size after rotation
      77             : {
      78             :     return AbstractShapeFactory::getSizeAfterRotation(
      79         533 :          m_xShape, m_fRotationAngleDegree );
      80             : }
      81             : 
      82         533 : void VTitle::changePosition( const awt::Point& rPos )
      83             : {
      84         533 :     if(!m_xShape.is())
      85           0 :         return;
      86         533 :     uno::Reference< beans::XPropertySet > xShapeProp( m_xShape, uno::UNO_QUERY );
      87         533 :     if(!xShapeProp.is())
      88           0 :         return;
      89             :     try
      90             :     {
      91         533 :         m_nXPos = rPos.X;
      92         533 :         m_nYPos = rPos.Y;
      93             : 
      94             :         //set position matrix
      95             :         //the matrix needs to be set at the end behind autogrow and such position influencing properties
      96         533 :         ::basegfx::B2DHomMatrix aM;
      97         533 :         aM.rotate( -m_fRotationAngleDegree*F_PI/180.0 );//#i78696#->#i80521#
      98         533 :         aM.translate( m_nXPos, m_nYPos);
      99         533 :         xShapeProp->setPropertyValue( "Transformation", uno::makeAny( B2DHomMatrixToHomogenMatrix3(aM) ) );
     100             :     }
     101           0 :     catch( const uno::Exception& e )
     102             :     {
     103             :         ASSERT_EXCEPTION( e );
     104         533 :     }
     105             : }
     106             : 
     107         528 : void VTitle::createShapes(
     108             :       const awt::Point& rPos
     109             :     , const awt::Size& rReferenceSize )
     110             : {
     111         528 :     if(!m_xTitle.is())
     112           0 :         return;
     113             : 
     114         528 :     uno::Sequence< uno::Reference< XFormattedString > > aStringList = m_xTitle->getText();
     115         528 :     if(aStringList.getLength()<=0)
     116           0 :         return;
     117             : 
     118         528 :     m_nXPos = rPos.X;
     119         528 :     m_nYPos = rPos.Y;
     120             : 
     121        1056 :     uno::Reference< beans::XPropertySet > xTitleProperties( m_xTitle, uno::UNO_QUERY );
     122             : 
     123             :     try
     124             :     {
     125         528 :         double fAngleDegree = 0;
     126         528 :         xTitleProperties->getPropertyValue( "TextRotation" ) >>= fAngleDegree;
     127         528 :         m_fRotationAngleDegree += fAngleDegree;
     128             :     }
     129           0 :     catch( const uno::Exception& e )
     130             :     {
     131             :         ASSERT_EXCEPTION( e );
     132             :     }
     133             : 
     134         528 :     AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory);
     135        1056 :     m_xShape =pShapeFactory->createText( m_xTarget, rReferenceSize, rPos, aStringList,
     136        1584 :             xTitleProperties, m_fRotationAngleDegree, m_aCID );
     137             : }
     138             : 
     139             : } //namespace chart
     140             : 
     141             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10