LCOV - code coverage report
Current view: top level - chart2/source/view/axes - VPolarAngleAxis.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 83 0.0 %
Date: 2014-04-14 Functions: 0 8 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 <basegfx/numeric/ftools.hxx>
      21             : 
      22             : #include "VPolarAngleAxis.hxx"
      23             : #include "VPolarGrid.hxx"
      24             : #include "AbstractShapeFactory.hxx"
      25             : #include "macros.hxx"
      26             : #include "NumberFormatterWrapper.hxx"
      27             : #include "PolarLabelPositionHelper.hxx"
      28             : #include <tools/color.hxx>
      29             : 
      30             : #include <boost/scoped_ptr.hpp>
      31             : 
      32             : namespace chart
      33             : {
      34             : using namespace ::com::sun::star;
      35             : using namespace ::com::sun::star::chart2;
      36             : using namespace ::rtl::math;
      37             : 
      38           0 : VPolarAngleAxis::VPolarAngleAxis( const AxisProperties& rAxisProperties
      39             :             , const uno::Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier
      40             :             , sal_Int32 nDimensionCount )
      41           0 :             : VPolarAxis( rAxisProperties, xNumberFormatsSupplier, 0/*nDimensionIndex*/, nDimensionCount )
      42             : {
      43           0 : }
      44             : 
      45           0 : VPolarAngleAxis::~VPolarAngleAxis()
      46             : {
      47           0 :     delete m_pPosHelper;
      48           0 :     m_pPosHelper = NULL;
      49           0 : }
      50             : 
      51           0 : bool VPolarAngleAxis::createTextShapes_ForAngleAxis(
      52             :                        const uno::Reference< drawing::XShapes >& xTarget
      53             :                      , EquidistantTickIter& rTickIter
      54             :                      , AxisLabelProperties& rAxisLabelProperties
      55             :                      , double fLogicRadius
      56             :                      , double fLogicZ )
      57             : {
      58           0 :     sal_Int32 nDimensionCount = 2;
      59           0 :     AbstractShapeFactory* pShapeFactory = AbstractShapeFactory::getOrCreateShapeFactory(m_xShapeFactory);
      60             : 
      61             :     FixedNumberFormatter aFixedNumberFormatter(
      62           0 :         m_xNumberFormatsSupplier, rAxisLabelProperties.nNumberFormatKey );
      63             : 
      64             :     //prepare text properties for multipropertyset-interface of shape
      65           0 :     tNameSequence aPropNames;
      66           0 :     tAnySequence aPropValues;
      67             : 
      68           0 :     uno::Reference< beans::XPropertySet > xProps( m_aAxisProperties.m_xAxisModel, uno::UNO_QUERY );
      69           0 :     PropertyMapper::getTextLabelMultiPropertyLists( xProps, aPropNames, aPropValues, false );
      70             :     LabelPositionHelper::doDynamicFontResize( aPropValues, aPropNames, xProps
      71           0 :         , rAxisLabelProperties.m_aFontReferenceSize );
      72             : 
      73           0 :     uno::Any* pColorAny = PropertyMapper::getValuePointer(aPropValues,aPropNames,"CharColor");
      74           0 :     sal_Int32 nColor = Color( COL_AUTO ).GetColor();
      75           0 :     if(pColorAny)
      76           0 :         *pColorAny >>= nColor;
      77             : 
      78           0 :     const uno::Sequence< OUString >* pLabels = m_bUseTextLabels? &m_aTextLabels : 0;
      79             : 
      80             :     //TickInfo* pLastVisibleNeighbourTickInfo = NULL;
      81           0 :     sal_Int32 nTick = 0;
      82             : 
      83           0 :     for( TickInfo* pTickInfo = rTickIter.firstInfo()
      84             :         ; pTickInfo
      85           0 :         ; pTickInfo = rTickIter.nextInfo(), nTick++ )
      86             :     {
      87             :         //don't create labels which does not fit into the rhythm
      88           0 :         if( nTick%rAxisLabelProperties.nRhythm != 0)
      89           0 :             continue;
      90             : 
      91             :         //don't create labels for invisible ticks
      92           0 :         if( !pTickInfo->bPaintIt )
      93           0 :             continue;
      94             : 
      95             :         //if NO OVERLAP -> don't create labels where the
      96             :         //anchor position is the same as for the last label
      97             :         //@todo
      98             : 
      99           0 :         if(!pTickInfo->xTextShape.is())
     100             :         {
     101             :             //create single label
     102           0 :             bool bHasExtraColor=false;
     103           0 :             sal_Int32 nExtraColor=0;
     104             : 
     105           0 :             OUString aLabel;
     106           0 :             if(pLabels)
     107             :             {
     108           0 :                 sal_Int32 nIndex = static_cast< sal_Int32 >(pTickInfo->getUnscaledTickValue()) - 1; //first category (index 0) matches with real number 1.0
     109           0 :                 if( nIndex>=0 && nIndex<pLabels->getLength() )
     110           0 :                     aLabel = (*pLabels)[nIndex];
     111             :             }
     112             :             else
     113           0 :                 aLabel = aFixedNumberFormatter.getFormattedString( pTickInfo->getUnscaledTickValue(), nExtraColor, bHasExtraColor );
     114             : 
     115           0 :             if(pColorAny)
     116           0 :                 *pColorAny = uno::makeAny(bHasExtraColor?nExtraColor:nColor);
     117             : 
     118           0 :             double fLogicAngle = pTickInfo->getUnscaledTickValue();
     119             : 
     120           0 :             LabelAlignment eLabelAlignment(LABEL_ALIGN_CENTER);
     121           0 :             PolarLabelPositionHelper aPolarLabelPositionHelper(m_pPosHelper,nDimensionCount,xTarget, pShapeFactory);
     122           0 :             sal_Int32 nScreenValueOffsetInRadiusDirection = m_aAxisLabelProperties.m_aMaximumSpaceForLabels.Height/15;
     123             :             awt::Point aAnchorScreenPosition2D( aPolarLabelPositionHelper.getLabelScreenPositionAndAlignmentForLogicValues(
     124           0 :                     eLabelAlignment, fLogicAngle, fLogicRadius, fLogicZ, nScreenValueOffsetInRadiusDirection ));
     125           0 :             LabelPositionHelper::changeTextAdjustment( aPropValues, aPropNames, eLabelAlignment );
     126             : 
     127             :             // #i78696# use mathematically correct rotation now
     128           0 :             const double fRotationAnglePi(rAxisLabelProperties.fRotationAngleDegree * (F_PI / -180.0));
     129             : 
     130           0 :             uno::Any aATransformation = AbstractShapeFactory::makeTransformation( aAnchorScreenPosition2D, fRotationAnglePi );
     131           0 :             OUString aStackedLabel = AbstractShapeFactory::getStackedString( aLabel, rAxisLabelProperties.bStackCharacters );
     132             : 
     133           0 :             pTickInfo->xTextShape = pShapeFactory->createText( xTarget, aStackedLabel, aPropNames, aPropValues, aATransformation );
     134             :         }
     135             : 
     136             :         //if NO OVERLAP -> remove overlapping shapes
     137             :         //@todo
     138             :     }
     139           0 :     return true;
     140             : }
     141             : 
     142           0 : void VPolarAngleAxis::createMaximumLabels()
     143             : {
     144           0 :     if( !prepareShapeCreation() )
     145           0 :         return;
     146             : 
     147           0 :     createLabels();
     148             : }
     149             : 
     150           0 : void VPolarAngleAxis::updatePositions()
     151             : {
     152             :     //todo: really only update the positions
     153             : 
     154           0 :     if( !prepareShapeCreation() )
     155           0 :         return;
     156             : 
     157           0 :     createLabels();
     158             : }
     159             : 
     160           0 : void VPolarAngleAxis::createLabels()
     161             : {
     162           0 :     if( !prepareShapeCreation() )
     163           0 :         return;
     164             : 
     165           0 :     double fLogicRadius = m_pPosHelper->getOuterLogicRadius();
     166             : 
     167           0 :     if( m_aAxisProperties.m_bDisplayLabels )
     168             :     {
     169             :         //get the transformed screen values for all tickmarks in aAllTickInfos
     170           0 :         boost::scoped_ptr< TickFactory > apTickFactory( this->createTickFactory() );
     171             : 
     172             :         //create tick mark text shapes
     173             :         //@todo: iterate through all tick depth which should be labeled
     174             : 
     175           0 :         EquidistantTickIter aTickIter( m_aAllTickInfos, m_aIncrement, 0, 0 );
     176           0 :         this->updateUnscaledValuesAtTicks( aTickIter );
     177             : 
     178           0 :         removeTextShapesFromTicks();
     179             : 
     180           0 :         AxisLabelProperties aAxisLabelProperties( m_aAxisLabelProperties );
     181           0 :         aAxisLabelProperties.bOverlapAllowed = true;
     182           0 :         double fLogicZ      = 1.0;//as defined
     183           0 :         while( !createTextShapes_ForAngleAxis( m_xTextTarget, aTickIter
     184             :                         , aAxisLabelProperties
     185             :                         , fLogicRadius, fLogicZ
     186           0 :                         ) )
     187             :         {
     188           0 :         };
     189             : 
     190             :         //no staggering for polar angle axis
     191             :     }
     192             : }
     193             : 
     194           0 : void VPolarAngleAxis::createShapes()
     195             : {
     196           0 :     if( !prepareShapeCreation() )
     197           0 :         return;
     198             : 
     199           0 :     double fLogicRadius = m_pPosHelper->getOuterLogicRadius();
     200           0 :     double fLogicZ      = 1.0;//as defined
     201             : 
     202             :     //create axis main lines
     203           0 :     drawing::PointSequenceSequence aPoints(1);
     204           0 :     VPolarGrid::createLinePointSequence_ForAngleAxis( aPoints, m_aAllTickInfos, m_aIncrement, m_aScale, m_pPosHelper, fLogicRadius, fLogicZ );
     205             :     uno::Reference< drawing::XShape > xShape = m_pShapeFactory->createLine2D(
     206           0 :             m_xGroupShape_Shapes, aPoints, &m_aAxisProperties.m_aLineProperties );
     207             :     //because of this name this line will be used for marking the axis
     208           0 :     m_pShapeFactory->setShapeName( xShape, "MarkHandles" );
     209             : 
     210             :     //create labels
     211           0 :     createLabels();
     212             : }
     213             : 
     214             : } //namespace chart
     215             : 
     216             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10