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