LCOV - code coverage report
Current view: top level - chart2/source/view/main - LabelPositionHelper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 81 246 32.9 %
Date: 2015-06-13 12:38:46 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        1728 : 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        1728 :                     , m_pShapeFactory(pShapeFactory)
      44             : {
      45        1728 : }
      46             : 
      47        1728 : LabelPositionHelper::~LabelPositionHelper()
      48             : {
      49        1728 : }
      50             : 
      51        1890 : awt::Point LabelPositionHelper::transformSceneToScreenPosition( const drawing::Position3D& rScenePosition3D ) const
      52             : {
      53             :     return PlottingPositionHelper::transformSceneToScreenPosition(
      54        1890 :                   rScenePosition3D, m_xLogicTarget, m_pShapeFactory, m_nDimensionCount );
      55             : }
      56             : 
      57        5488 : void LabelPositionHelper::changeTextAdjustment( tAnySequence& rPropValues, const tNameSequence& rPropNames, LabelAlignment eAlignment)
      58             : {
      59             :     //HorizontalAdjustment
      60             :     {
      61        5488 :         drawing::TextHorizontalAdjust eHorizontalAdjust = drawing::TextHorizontalAdjust_CENTER;
      62        5488 :         if( LABEL_ALIGN_RIGHT==eAlignment || LABEL_ALIGN_RIGHT_TOP==eAlignment || LABEL_ALIGN_RIGHT_BOTTOM==eAlignment )
      63         156 :             eHorizontalAdjust = drawing::TextHorizontalAdjust_LEFT;
      64        5332 :         else if( LABEL_ALIGN_LEFT==eAlignment || LABEL_ALIGN_LEFT_TOP==eAlignment || LABEL_ALIGN_LEFT_BOTTOM==eAlignment )
      65        1678 :             eHorizontalAdjust = drawing::TextHorizontalAdjust_RIGHT;
      66        5488 :         uno::Any* pHorizontalAdjustAny = PropertyMapper::getValuePointer(rPropValues,rPropNames,"TextHorizontalAdjust");
      67        5488 :         if(pHorizontalAdjustAny)
      68        5488 :             *pHorizontalAdjustAny = uno::makeAny(eHorizontalAdjust);
      69             :     }
      70             : 
      71             :     //VerticalAdjustment
      72             :     {
      73        5488 :         drawing::TextVerticalAdjust eVerticalAdjust = drawing::TextVerticalAdjust_CENTER;
      74        5488 :         if( LABEL_ALIGN_TOP==eAlignment || LABEL_ALIGN_RIGHT_TOP==eAlignment || LABEL_ALIGN_LEFT_TOP==eAlignment )
      75        1545 :             eVerticalAdjust = drawing::TextVerticalAdjust_BOTTOM;
      76        3943 :         else if( LABEL_ALIGN_BOTTOM==eAlignment || LABEL_ALIGN_RIGHT_BOTTOM==eAlignment || LABEL_ALIGN_LEFT_BOTTOM==eAlignment )
      77        1938 :             eVerticalAdjust = drawing::TextVerticalAdjust_TOP;
      78        5488 :         uno::Any* pVerticalAdjustAny = PropertyMapper::getValuePointer(rPropValues,rPropNames,"TextVerticalAdjust");
      79        5488 :         if(pVerticalAdjustAny)
      80        5488 :             *pVerticalAdjustAny = uno::makeAny(eVerticalAdjust);
      81             :     }
      82        5488 : }
      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        4274 : 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        4274 :     awt::Size aOldReferenceSize;
     104        4274 :     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        4274 : }
     114             : 
     115             : namespace
     116             : {
     117             : 
     118       13826 : 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       13826 :     double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
     123       13826 :     if( fAnglePositiveDegree==0.0 )
     124             :     {
     125             :     }
     126         182 :     else if( fAnglePositiveDegree<= 90.0 )
     127             :     {
     128         182 :         rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi )/2.0;
     129         182 :         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       13826 : }
     160             : 
     161         713 : 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         713 :     double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
     166         713 :     if( fAnglePositiveDegree== 0.0 )
     167             :     {
     168             :     }
     169         265 :     else if( fAnglePositiveDegree<= 90.0 )
     170             :     {
     171         265 :         rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi )/2.0;
     172         265 :         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         713 : }
     202             : 
     203         761 : 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         761 :     double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
     208         761 :     if( fAnglePositiveDegree== 0.0 )
     209             :     {
     210             :     }
     211         134 :     else if( fAnglePositiveDegree<= 90.0 )
     212             :     {
     213         134 :         rfXCorrection = aSize.Height*rtl::math::sin( fAnglePi )/2.0;
     214         134 :         if( !bRotateAroundCenter )
     215           0 :             rfXCorrection += aSize.Width*rtl::math::cos( fAnglePi )/2.0;
     216         134 :         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         761 : }
     244             : 
     245       11685 : 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       11685 :     double fAnglePi = fAnglePositiveDegree*F_PI/180.0;
     250       11685 :     if( fAnglePositiveDegree==0.0 )
     251             :     {
     252             :     }
     253         141 :     else if( fAnglePositiveDegree<= 90.0 )
     254             :     {
     255         141 :         rfXCorrection = -aSize.Height*rtl::math::sin( fAnglePi )/2.0;
     256         141 :         if( !bRotateAroundCenter )
     257         141 :             rfXCorrection -= aSize.Width *rtl::math::cos( fAnglePi )/2.0;
     258         141 :         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       11685 : }
     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       26985 : void LabelPositionHelper::correctPositionForRotation( const uno::Reference< drawing::XShape >& xShape2DText
     419             :                      , LabelAlignment eLabelAlignment, const double fRotationAngle, bool bRotateAroundCenter )
     420             : {
     421       26985 :     if( !xShape2DText.is() )
     422       26985 :         return;
     423             : 
     424       26985 :     awt::Point aOldPos = xShape2DText->getPosition();
     425       26985 :     awt::Size  aSize   = xShape2DText->getSize();
     426             : 
     427       26985 :     double fYCorrection = 0.0;
     428       26985 :     double fXCorrection  = 0.0;
     429             : 
     430       26985 :     double fAnglePositiveDegree = fRotationAngle;
     431       53970 :     while(fAnglePositiveDegree<0.0)
     432           0 :         fAnglePositiveDegree+=360.0;
     433             : 
     434       26985 :     switch(eLabelAlignment)
     435             :     {
     436             :         case LABEL_ALIGN_LEFT:
     437       13826 :             lcl_correctRotation_Left( fXCorrection, fYCorrection, fAnglePositiveDegree, aSize, bRotateAroundCenter );
     438       13826 :             break;
     439             :         case LABEL_ALIGN_RIGHT:
     440         713 :             lcl_correctRotation_Right( fXCorrection, fYCorrection, fAnglePositiveDegree, aSize, bRotateAroundCenter );
     441         713 :             break;
     442             :         case LABEL_ALIGN_TOP:
     443         761 :             lcl_correctRotation_Top( fXCorrection, fYCorrection, fAnglePositiveDegree, aSize, bRotateAroundCenter );
     444         761 :             break;
     445             :         case LABEL_ALIGN_BOTTOM:
     446       11685 :             lcl_correctRotation_Bottom( fXCorrection, fYCorrection, fAnglePositiveDegree, aSize, bRotateAroundCenter );
     447       11685 :             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       26985 :     xShape2DText->setPosition( awt::Point(
     465       26985 :           static_cast<sal_Int32>(aOldPos.X + fXCorrection  )
     466       53970 :         , 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.11