LCOV - code coverage report
Current view: top level - chart2/source/view/main - LabelPositionHelper.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 81 246 32.9 %
Date: 2014-04-11 Functions: 10 16 62.5 %
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 "LabelPositionHelper.hxx"
      21             : #include "PlottingPositionHelper.hxx"
      22             : #include "CommonConverters.hxx"
      23             : #include "PropertyMapper.hxx"
      24             : #include "AbstractShapeFactory.hxx"
      25             : #include "macros.hxx"
      26             : #include "RelativeSizeHelper.hxx"
      27             : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
      28             : #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
      29             : 
      30             : namespace chart
      31             : {
      32             : using namespace ::com::sun::star;
      33             : using namespace ::com::sun::star::chart2;
      34             : 
      35         893 : LabelPositionHelper::LabelPositionHelper(
      36             :                     PlottingPositionHelper* pPosHelper
      37             :                     , sal_Int32 nDimensionCount
      38             :                     , const uno::Reference< drawing::XShapes >& xLogicTarget
      39             :                     , AbstractShapeFactory* pShapeFactory )
      40             :                     : m_pPosHelper(pPosHelper)
      41             :                     , m_nDimensionCount(nDimensionCount)
      42             :                     , m_xLogicTarget(xLogicTarget)
      43         893 :                     , m_pShapeFactory(pShapeFactory)
      44             : {
      45         893 : }
      46             : 
      47         893 : LabelPositionHelper::~LabelPositionHelper()
      48             : {
      49         893 : }
      50             : 
      51         893 : awt::Point LabelPositionHelper::transformSceneToScreenPosition( const drawing::Position3D& rScenePosition3D ) const
      52             : {
      53             :     return PlottingPositionHelper::transformSceneToScreenPosition(
      54         893 :                   rScenePosition3D, m_xLogicTarget, m_pShapeFactory, m_nDimensionCount );
      55             : }
      56             : 
      57        3103 : void LabelPositionHelper::changeTextAdjustment( tAnySequence& rPropValues, const tNameSequence& rPropNames, LabelAlignment eAlignment)
      58             : {
      59             :     //HorizontalAdjustment
      60             :     {
      61        3103 :         drawing::TextHorizontalAdjust eHorizontalAdjust = drawing::TextHorizontalAdjust_CENTER;
      62        3103 :         if( LABEL_ALIGN_RIGHT==eAlignment || LABEL_ALIGN_RIGHT_TOP==eAlignment || LABEL_ALIGN_RIGHT_BOTTOM==eAlignment )
      63          18 :             eHorizontalAdjust = drawing::TextHorizontalAdjust_LEFT;
      64        3085 :         else if( LABEL_ALIGN_LEFT==eAlignment || LABEL_ALIGN_LEFT_TOP==eAlignment || LABEL_ALIGN_LEFT_BOTTOM==eAlignment )
      65         988 :             eHorizontalAdjust = drawing::TextHorizontalAdjust_RIGHT;
      66        3103 :         uno::Any* pHorizontalAdjustAny = PropertyMapper::getValuePointer(rPropValues,rPropNames,"TextHorizontalAdjust");
      67        3103 :         if(pHorizontalAdjustAny)
      68        3103 :             *pHorizontalAdjustAny = uno::makeAny(eHorizontalAdjust);
      69             :     }
      70             : 
      71             :     //VerticalAdjustment
      72             :     {
      73        3103 :         drawing::TextVerticalAdjust eVerticalAdjust = drawing::TextVerticalAdjust_CENTER;
      74        3103 :         if( LABEL_ALIGN_TOP==eAlignment || LABEL_ALIGN_RIGHT_TOP==eAlignment || LABEL_ALIGN_LEFT_TOP==eAlignment )
      75         926 :             eVerticalAdjust = drawing::TextVerticalAdjust_BOTTOM;
      76        2177 :         else if( LABEL_ALIGN_BOTTOM==eAlignment || LABEL_ALIGN_RIGHT_BOTTOM==eAlignment || LABEL_ALIGN_LEFT_BOTTOM==eAlignment )
      77        1148 :             eVerticalAdjust = drawing::TextVerticalAdjust_TOP;
      78        3103 :         uno::Any* pVerticalAdjustAny = PropertyMapper::getValuePointer(rPropValues,rPropNames,"TextVerticalAdjust");
      79        3103 :         if(pVerticalAdjustAny)
      80        3103 :             *pVerticalAdjustAny = uno::makeAny(eVerticalAdjust);
      81             :     }
      82        3103 : }
      83             : 
      84           0 : void lcl_doDynamicFontResize( uno::Any* pAOldAndNewFontHeightAny
      85             :                           , const awt::Size& rOldReferenceSize
      86             :                           , const awt::Size& rNewReferenceSize  )
      87             : {
      88           0 :     double fOldFontHeight = 0;
      89           0 :     if( pAOldAndNewFontHeightAny && ( *pAOldAndNewFontHeightAny >>= fOldFontHeight ) )
      90             :     {
      91           0 :         double fNewFontHeight = RelativeSizeHelper::calculate( fOldFontHeight, rOldReferenceSize, rNewReferenceSize );
      92           0 :         *pAOldAndNewFontHeightAny = uno::makeAny(fNewFontHeight);
      93             :     }
      94           0 : }
      95             : 
      96        2402 : void LabelPositionHelper::doDynamicFontResize( tAnySequence& rPropValues
      97             :                     , const tNameSequence& rPropNames
      98             :                     , const uno::Reference< beans::XPropertySet >& xAxisModelProps
      99             :                     , const awt::Size& rNewReferenceSize
     100             :                     )
     101             : {
     102             :     //handle dynamic font resize:
     103        2402 :     awt::Size aOldReferenceSize;
     104        2402 :     if( xAxisModelProps->getPropertyValue( "ReferencePageSize") >>= aOldReferenceSize )
     105             :     {
     106           0 :         uno::Any* pAOldAndNewFontHeightAny = PropertyMapper::getValuePointer( rPropValues, rPropNames, "CharHeight" );
     107           0 :         lcl_doDynamicFontResize( pAOldAndNewFontHeightAny, aOldReferenceSize, rNewReferenceSize );
     108           0 :         pAOldAndNewFontHeightAny = PropertyMapper::getValuePointer( rPropValues, rPropNames, "CharHeightAsian" );
     109           0 :         lcl_doDynamicFontResize( pAOldAndNewFontHeightAny, aOldReferenceSize, rNewReferenceSize );
     110           0 :         pAOldAndNewFontHeightAny = PropertyMapper::getValuePointer( rPropValues, rPropNames, "CharHeightComplex" );
     111           0 :         lcl_doDynamicFontResize( pAOldAndNewFontHeightAny, aOldReferenceSize, rNewReferenceSize );
     112             :     }
     113        2402 : }
     114             : 
     115             : namespace
     116             : {
     117             : 
     118        8477 : void lcl_correctRotation_Left( double& rfXCorrection, double& rfYCorrection
     119             :                            , double fAnglePositiveDegree, const awt::Size& aSize, bool bRotateAroundCenter )
     120             : {
     121             :     //correct label positions for labels on a left side of something with a right centered alignment
     122        8477 :     double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
     123        8477 :     if( fAnglePositiveDegree==0.0 )
     124             :     {
     125             :     }
     126          75 :     else if( fAnglePositiveDegree<= 90.0 )
     127             :     {
     128          75 :         rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi )/2.0;
     129          75 :         if( bRotateAroundCenter )
     130           0 :             rfYCorrection = -aSize.Width*rtl::math::sin( fAnglePi )/2.0;
     131             :     }
     132           0 :     else if( fAnglePositiveDegree<= 180.0 )
     133             :     {
     134           0 :         double beta = fAnglePi-F_PI/2.0;
     135           0 :         rfXCorrection = -aSize.Width *rtl::math::sin( beta )
     136           0 :             -aSize.Height *rtl::math::cos( beta )/2.0;
     137           0 :         if( bRotateAroundCenter )
     138           0 :             rfYCorrection = -aSize.Width *rtl::math::cos( beta )/2.0;
     139             :         else
     140           0 :             rfYCorrection = -aSize.Width *rtl::math::cos( beta );
     141             :     }
     142           0 :     else if( fAnglePositiveDegree<= 270.0 )
     143             :     {
     144           0 :         double beta = fAnglePi - F_PI;
     145           0 :         rfXCorrection = -aSize.Width *rtl::math::cos( beta )
     146           0 :             -aSize.Height*rtl::math::sin( beta )/2.0;
     147           0 :         if( bRotateAroundCenter )
     148           0 :             rfYCorrection = aSize.Width *rtl::math::sin( beta )/2.0;
     149             :         else
     150           0 :             rfYCorrection = aSize.Width *rtl::math::sin( beta );
     151             :     }
     152             :     else
     153             :     {
     154           0 :         double beta = 2*F_PI - fAnglePi;
     155           0 :         rfXCorrection = -aSize.Height*rtl::math::sin( beta )/2.0;
     156           0 :         if( bRotateAroundCenter )
     157           0 :             rfYCorrection = aSize.Width*rtl::math::sin( beta )/2.0;
     158             :     }
     159        8477 : }
     160             : 
     161         145 : void lcl_correctRotation_Right( double& rfXCorrection, double& rfYCorrection
     162             :                            , double fAnglePositiveDegree, const awt::Size& aSize, bool bRotateAroundCenter )
     163             : {
     164             :     //correct label positions for labels on a right side of something with a left centered alignment
     165         145 :     double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
     166         145 :     if( fAnglePositiveDegree== 0.0 )
     167             :     {
     168             :     }
     169          78 :     else if( fAnglePositiveDegree<= 90.0 )
     170             :     {
     171          78 :         rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi )/2.0;
     172          78 :         if( bRotateAroundCenter )
     173           0 :             rfYCorrection = aSize.Width*rtl::math::sin( fAnglePi )/2.0;
     174             :     }
     175           0 :     else if( fAnglePositiveDegree<= 180.0 )
     176             :     {
     177           0 :         double beta = F_PI - fAnglePi;
     178           0 :         rfXCorrection = aSize.Width *rtl::math::cos( beta )
     179           0 :             + aSize.Height*rtl::math::sin( beta )/2.0;
     180           0 :         if( bRotateAroundCenter )
     181           0 :             rfYCorrection = aSize.Width *rtl::math::sin( beta )/2.0;
     182             :         else
     183           0 :             rfYCorrection = aSize.Width *rtl::math::sin( beta );
     184             :     }
     185           0 :     else if( fAnglePositiveDegree<= 270.0 )
     186             :     {
     187           0 :         double beta = 3*F_PI/2.0 - fAnglePi;
     188           0 :         rfXCorrection = aSize.Width *rtl::math::sin( beta )
     189           0 :                     +aSize.Height*rtl::math::cos( beta )/2.0;
     190           0 :         if( bRotateAroundCenter )
     191           0 :             rfYCorrection = -aSize.Width *rtl::math::cos( beta )/2.0;
     192             :         else
     193           0 :             rfYCorrection = -aSize.Width *rtl::math::cos( beta );
     194             :     }
     195             :     else
     196             :     {
     197           0 :         rfXCorrection  = aSize.Height*rtl::math::sin( 2*F_PI - fAnglePi )/2.0;
     198           0 :         if( bRotateAroundCenter )
     199           0 :             rfYCorrection = -aSize.Width*rtl::math::sin( 2*F_PI - fAnglePi )/2.0;
     200             :     }
     201         145 : }
     202             : 
     203         410 : void lcl_correctRotation_Top( double& rfXCorrection, double& rfYCorrection
     204             :                            , double fAnglePositiveDegree, const awt::Size& aSize, bool bRotateAroundCenter )
     205             : {
     206             :     //correct label positions for labels on top of something with a bottom centered alignment
     207         410 :     double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
     208         410 :     if( fAnglePositiveDegree== 0.0 )
     209             :     {
     210             :     }
     211          74 :     else if( fAnglePositiveDegree<= 90.0 )
     212             :     {
     213          74 :         rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi )/2.0;
     214          74 :         if( !bRotateAroundCenter )
     215           0 :             rfXCorrection += aSize.Width*rtl::math::cos( fAnglePi )/2.0;
     216          74 :         rfYCorrection = -aSize.Width*rtl::math::sin( fAnglePi )/2.0;
     217             :     }
     218           0 :     else if( fAnglePositiveDegree<= 180.0 )
     219             :     {
     220           0 :         double beta = fAnglePi - F_PI/2.0;
     221           0 :         rfXCorrection = aSize.Height*rtl::math::cos( beta )/2.0;
     222           0 :         if( !bRotateAroundCenter )
     223           0 :             rfXCorrection -= aSize.Width*rtl::math::sin( beta )/2.0;
     224           0 :         rfYCorrection = -aSize.Width*rtl::math::cos( beta )/2.0
     225           0 :             - aSize.Height*rtl::math::sin( beta );
     226             :     }
     227           0 :     else if( fAnglePositiveDegree<= 270.0 )
     228             :     {
     229           0 :         double beta = fAnglePi - F_PI;
     230           0 :         rfXCorrection = -aSize.Height *rtl::math::sin( beta )/2.0;
     231           0 :         if( !bRotateAroundCenter )
     232           0 :             rfXCorrection += aSize.Width *rtl::math::cos( beta )/2.0;
     233           0 :         rfYCorrection = -aSize.Width *rtl::math::sin( beta )/2.0
     234           0 :             -aSize.Height *rtl::math::cos( beta );
     235             :     }
     236             :     else
     237             :     {
     238           0 :         rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi )/2.0;
     239           0 :         if( !bRotateAroundCenter )
     240           0 :             rfXCorrection -= aSize.Width*rtl::math::cos( fAnglePi )/2.0;
     241           0 :         rfYCorrection = aSize.Width*rtl::math::sin( fAnglePi )/2.0;
     242             :     }
     243         410 : }
     244             : 
     245        7354 : void lcl_correctRotation_Bottom( double& rfXCorrection, double& rfYCorrection
     246             :                            , double fAnglePositiveDegree, const awt::Size& aSize, bool bRotateAroundCenter )
     247             : {
     248             :     //correct label positions for labels below something with a top centered alignment
     249        7354 :     double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
     250        7354 :     if( fAnglePositiveDegree==0.0 )
     251             :     {
     252             :     }
     253          14 :     else if( fAnglePositiveDegree<= 90.0 )
     254             :     {
     255          14 :         rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi )/2.0;
     256          14 :         if( !bRotateAroundCenter )
     257          14 :             rfXCorrection -= aSize.Width *rtl::math::cos( fAnglePi )/2.0;
     258          14 :         rfYCorrection = aSize.Width*rtl::math::sin( fAnglePi )/2.0;
     259             :     }
     260           0 :     else if( fAnglePositiveDegree<= 180.0 )
     261             :     {
     262           0 :         double beta = fAnglePi-F_PI/2.0;
     263           0 :         rfXCorrection = -aSize.Height*rtl::math::cos( beta )/2.0;
     264           0 :         if( !bRotateAroundCenter )
     265           0 :             rfXCorrection += aSize.Width *rtl::math::sin( beta )/2.0;
     266           0 :         rfYCorrection = aSize.Width *rtl::math::cos( beta )/2.0
     267           0 :             +aSize.Height*rtl::math::sin( beta );
     268             :     }
     269           0 :     else if( fAnglePositiveDegree<= 270.0 )
     270             :     {
     271           0 :         double beta = 3*F_PI/2.0 - fAnglePi;
     272           0 :         rfXCorrection = aSize.Height*rtl::math::cos( beta )/2.0;
     273           0 :         if( !bRotateAroundCenter )
     274           0 :             rfXCorrection -= aSize.Width *rtl::math::sin( beta )/2.0;
     275           0 :         rfYCorrection = aSize.Height*rtl::math::sin( beta )
     276           0 :                         +aSize.Width*rtl::math::cos( beta )/2.0;
     277             :     }
     278             :     else
     279             :     {
     280           0 :         double beta = 2*F_PI - fAnglePi;
     281           0 :         rfXCorrection = aSize.Height*rtl::math::sin( beta )/2.0;
     282           0 :         if( !bRotateAroundCenter )
     283           0 :             rfXCorrection += aSize.Width*rtl::math::cos( beta )/2.0;
     284           0 :         rfYCorrection = aSize.Width*rtl::math::sin( beta )/2.0;
     285             :     }
     286        7354 : }
     287             : 
     288           0 : void lcl_correctRotation_Left_Top( double& rfXCorrection, double& rfYCorrection
     289             :                            , double fAnglePositiveDegree, const awt::Size& aSize )
     290             : {
     291             :     //correct position for labels at the left top corner of something with a bottom right alignment
     292           0 :     double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
     293           0 :     if( fAnglePositiveDegree==0.0 )
     294             :     {
     295             :     }
     296           0 :     else if( fAnglePositiveDegree<= 90.0 )
     297             :     {
     298           0 :         rfYCorrection = -aSize.Width*rtl::math::sin( fAnglePi );
     299             :     }
     300           0 :     else if( fAnglePositiveDegree<= 180.0 )
     301             :     {
     302           0 :         double beta = fAnglePi-F_PI/2.0;
     303           0 :         rfXCorrection = -aSize.Width*rtl::math::sin( beta );
     304           0 :         rfYCorrection = -aSize.Height*rtl::math::sin( beta )
     305           0 :                         -aSize.Width*rtl::math::cos( beta );
     306             :     }
     307           0 :     else if( fAnglePositiveDegree<= 270.0 )
     308             :     {
     309           0 :         double beta = 3*F_PI/2.0 - fAnglePi;
     310           0 :         rfXCorrection = -aSize.Height*rtl::math::cos( beta )
     311           0 :                         -aSize.Width*rtl::math::sin( beta );
     312           0 :         rfYCorrection = -aSize.Height*rtl::math::sin( beta );
     313             :     }
     314             :     else
     315             :     {
     316           0 :         rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi );
     317             :     }
     318           0 : }
     319             : 
     320           0 : void lcl_correctRotation_Left_Bottom( double& rfXCorrection, double& rfYCorrection
     321             :                            , double fAnglePositiveDegree, const awt::Size& aSize )
     322             : {
     323             :     //correct position for labels at the left bottom corner of something with a top right alignment
     324           0 :     double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
     325           0 :     if( fAnglePositiveDegree==0.0 )
     326             :     {
     327             :     }
     328           0 :     else if( fAnglePositiveDegree<= 90.0 )
     329             :     {
     330           0 :         rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi );
     331             :     }
     332           0 :     else if( fAnglePositiveDegree<= 180.0 )
     333             :     {
     334           0 :         double beta = fAnglePi-F_PI/2.0;
     335           0 :         rfXCorrection = -aSize.Width*rtl::math::sin( beta )
     336           0 :                         -aSize.Height*rtl::math::cos( beta );;
     337           0 :         rfYCorrection = aSize.Height*rtl::math::sin( beta );
     338             :     }
     339           0 :     else if( fAnglePositiveDegree<= 270.0 )
     340             :     {
     341           0 :         double beta = 3*F_PI/2.0 - fAnglePi;
     342           0 :         rfXCorrection = -aSize.Width*rtl::math::sin( beta );
     343           0 :         rfYCorrection = aSize.Width*rtl::math::cos( beta )
     344           0 :                         +aSize.Height*rtl::math::sin( beta );
     345             :     }
     346             :     else
     347             :     {
     348           0 :         rfYCorrection = -aSize.Width*rtl::math::sin( fAnglePi );
     349             :     }
     350           0 : }
     351             : 
     352           0 : void lcl_correctRotation_Right_Top( double& rfXCorrection, double& rfYCorrection
     353             :                            , double fAnglePositiveDegree, const awt::Size& aSize )
     354             : {
     355             :     //correct position for labels at the right top corner of something with a bottom left alignment
     356           0 :     double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
     357           0 :     if( fAnglePositiveDegree==0.0 )
     358             :     {
     359             :     }
     360           0 :     else if( fAnglePositiveDegree<= 90.0 )
     361             :     {
     362           0 :         rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi );
     363             :     }
     364           0 :     else if( fAnglePositiveDegree<= 180.0 )
     365             :     {
     366           0 :         double beta = fAnglePi-F_PI/2.0;
     367           0 :         rfXCorrection = aSize.Width*rtl::math::sin( beta )
     368           0 :                         +aSize.Height*rtl::math::cos( beta );
     369           0 :         rfYCorrection = -aSize.Height*rtl::math::sin( beta );
     370             :     }
     371           0 :     else if( fAnglePositiveDegree<= 270.0 )
     372             :     {
     373           0 :         double beta = 3*F_PI/2.0 - fAnglePi;
     374           0 :         rfXCorrection = aSize.Width*rtl::math::sin( beta );
     375           0 :         rfYCorrection = -aSize.Width*rtl::math::cos( beta )
     376           0 :                         -aSize.Height*rtl::math::sin( beta );
     377             :     }
     378             :     else
     379             :     {
     380           0 :         rfYCorrection = aSize.Width*rtl::math::sin( fAnglePi );
     381             :     }
     382           0 : }
     383             : 
     384           0 : void lcl_correctRotation_Right_Bottom( double& rfXCorrection, double& rfYCorrection
     385             :                            , double fAnglePositiveDegree, const awt::Size& aSize )
     386             : {
     387             :     //correct position for labels at the right bottom corner of something with a top left alignment
     388           0 :     double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
     389           0 :     if( fAnglePositiveDegree==0.0 )
     390             :     {
     391             :     }
     392           0 :     else if( fAnglePositiveDegree<= 90.0 )
     393             :     {
     394           0 :         rfYCorrection = aSize.Width*rtl::math::sin( fAnglePi );
     395             :     }
     396           0 :     else if( fAnglePositiveDegree<= 180.0 )
     397             :     {
     398           0 :         double beta = fAnglePi-F_PI/2.0;
     399           0 :         rfXCorrection = aSize.Width*rtl::math::sin( beta );
     400           0 :         rfYCorrection = aSize.Height*rtl::math::sin( beta )
     401           0 :                         +aSize.Width*rtl::math::cos( beta );
     402             :     }
     403           0 :     else if( fAnglePositiveDegree<= 270.0 )
     404             :     {
     405           0 :         double beta = 3*F_PI/2.0 - fAnglePi;
     406           0 :         rfXCorrection = aSize.Height*rtl::math::cos( beta )
     407           0 :                         +aSize.Width*rtl::math::sin( beta );
     408           0 :         rfYCorrection = aSize.Height*rtl::math::sin( beta );
     409             :     }
     410             :     else
     411             :     {
     412           0 :         rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi );
     413             :     }
     414           0 : }
     415             : 
     416             : }//end anonymous namespace
     417             : 
     418       16386 : void LabelPositionHelper::correctPositionForRotation( const uno::Reference< drawing::XShape >& xShape2DText
     419             :                      , LabelAlignment eLabelAlignment, const double fRotationAngle, bool bRotateAroundCenter )
     420             : {
     421       16386 :     if( !xShape2DText.is() )
     422       16386 :         return;
     423             : 
     424       16386 :     awt::Point aOldPos = xShape2DText->getPosition();
     425       16386 :     awt::Size  aSize   = xShape2DText->getSize();
     426             : 
     427       16386 :     double fYCorrection = 0.0;
     428       16386 :     double fXCorrection  = 0.0;
     429             : 
     430       16386 :     double fAnglePositiveDegree = fRotationAngle;
     431       32772 :     while(fAnglePositiveDegree<0.0)
     432           0 :         fAnglePositiveDegree+=360.0;
     433             : 
     434       16386 :     switch(eLabelAlignment)
     435             :     {
     436             :         case LABEL_ALIGN_LEFT:
     437        8477 :             lcl_correctRotation_Left( fXCorrection, fYCorrection, fAnglePositiveDegree, aSize, bRotateAroundCenter );
     438        8477 :             break;
     439             :         case LABEL_ALIGN_RIGHT:
     440         145 :             lcl_correctRotation_Right( fXCorrection, fYCorrection, fAnglePositiveDegree, aSize, bRotateAroundCenter );
     441         145 :             break;
     442             :         case LABEL_ALIGN_TOP:
     443         410 :             lcl_correctRotation_Top( fXCorrection, fYCorrection, fAnglePositiveDegree, aSize, bRotateAroundCenter );
     444         410 :             break;
     445             :         case LABEL_ALIGN_BOTTOM:
     446        7354 :             lcl_correctRotation_Bottom( fXCorrection, fYCorrection, fAnglePositiveDegree, aSize, bRotateAroundCenter );
     447        7354 :             break;
     448             :         case LABEL_ALIGN_LEFT_TOP:
     449           0 :             lcl_correctRotation_Left_Top( fXCorrection, fYCorrection, fAnglePositiveDegree, aSize );
     450           0 :             break;
     451             :         case LABEL_ALIGN_LEFT_BOTTOM:
     452           0 :             lcl_correctRotation_Left_Bottom( fXCorrection, fYCorrection, fAnglePositiveDegree, aSize );
     453           0 :             break;
     454             :         case LABEL_ALIGN_RIGHT_TOP:
     455           0 :             lcl_correctRotation_Right_Top( fXCorrection, fYCorrection, fAnglePositiveDegree, aSize );
     456           0 :             break;
     457             :         case LABEL_ALIGN_RIGHT_BOTTOM:
     458           0 :             lcl_correctRotation_Right_Bottom( fXCorrection, fYCorrection, fAnglePositiveDegree, aSize );
     459           0 :             break;
     460             :         default: //LABEL_ALIGN_CENTER
     461           0 :             break;
     462             :     }
     463             : 
     464       16386 :     xShape2DText->setPosition( awt::Point(
     465       16386 :           static_cast<sal_Int32>(aOldPos.X + fXCorrection  )
     466       32772 :         , static_cast<sal_Int32>(aOldPos.Y + fYCorrection ) ) );
     467             : }
     468             : 
     469             : } //namespace chart
     470             : 
     471             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10