LCOV - code coverage report
Current view: top level - chart2/source/view/main - VDataSeries.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 418 588 71.1 %
Date: 2014-04-11 Functions: 68 79 86.1 %
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 "VDataSeries.hxx"
      21             : #include "ObjectIdentifier.hxx"
      22             : #include "macros.hxx"
      23             : #include "CommonConverters.hxx"
      24             : #include "LabelPositionHelper.hxx"
      25             : #include "ChartTypeHelper.hxx"
      26             : #include "ContainerHelper.hxx"
      27             : #include "DataSeriesHelper.hxx"
      28             : #include "RegressionCurveHelper.hxx"
      29             : 
      30             : #include <com/sun/star/chart/MissingValueTreatment.hpp>
      31             : #include <com/sun/star/chart2/Symbol.hpp>
      32             : 
      33             : #include <rtl/math.hxx>
      34             : #include <com/sun/star/beans/XPropertySet.hpp>
      35             : #include <com/sun/star/beans/XPropertyState.hpp>
      36             : #include <com/sun/star/drawing/LineStyle.hpp>
      37             : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
      38             : #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
      39             : #include <com/sun/star/text/WritingMode.hpp>
      40             : #include <com/sun/star/chart2/data/XDataSource.hpp>
      41             : 
      42             : namespace chart {
      43             : 
      44             : using namespace ::com::sun::star;
      45             : using namespace ::com::sun::star::chart2;
      46             : using ::com::sun::star::uno::Reference;
      47             : 
      48        2017 : void VDataSequence::init( const uno::Reference< data::XDataSequence >& xModel )
      49             : {
      50        2017 :     Model = xModel;
      51        2017 :     Doubles = DataSequenceToDoubleSequence( xModel );
      52        2017 : }
      53             : 
      54       83277 : bool VDataSequence::is() const
      55             : {
      56       83277 :     return Model.is();
      57             : }
      58        1962 : void VDataSequence::clear()
      59             : {
      60        1962 :     Model = NULL;
      61        1962 :     Doubles.realloc(0);
      62        1962 : }
      63             : 
      64         420 : double VDataSequence::getValue( sal_Int32 index ) const
      65             : {
      66         420 :     if( 0<=index && index<Doubles.getLength() )
      67         294 :         return Doubles[index];
      68             :     else
      69             :     {
      70             :         double fNan;
      71         126 :         ::rtl::math::setNan( & fNan );
      72         126 :         return fNan;
      73             :     }
      74             : }
      75             : 
      76         823 : sal_Int32 VDataSequence::detectNumberFormatKey( sal_Int32 index ) const
      77             : {
      78         823 :     sal_Int32 nNumberFormatKey = -1;
      79             : 
      80             :     // -1 is allowed and means a key for the whole sequence
      81        1646 :     if( -1<=index && index<Doubles.getLength() &&
      82         823 :         Model.is())
      83             :     {
      84         823 :         nNumberFormatKey = Model->getNumberFormatKeyByIndex( index );
      85             :     }
      86             : 
      87         823 :     return nNumberFormatKey;
      88             : }
      89             : 
      90       38358 : sal_Int32 VDataSequence::getLength() const
      91             : {
      92       38358 :     return Doubles.getLength();
      93             : }
      94             : 
      95             : namespace
      96             : {
      97             : struct lcl_LessXOfPoint
      98             : {
      99           0 :     inline bool operator() ( const std::vector< double >& first,
     100             :                              const std::vector< double >& second )
     101             :     {
     102           0 :         if( !first.empty() && !second.empty() )
     103             :         {
     104           0 :             return first[0]<second[0];
     105             :         }
     106           0 :         return false;
     107             :     }
     108             : };
     109             : 
     110          18 : void lcl_clearIfNoValuesButTextIsContained( VDataSequence& rData, const uno::Reference<data::XDataSequence>& xDataSequence )
     111             : {
     112             :     //#i71686#, #i101968#, #i102428#
     113          18 :     sal_Int32 nCount = rData.Doubles.getLength();
     114          18 :     for( sal_Int32 i = 0; i < nCount; ++i )
     115             :     {
     116          18 :         if( !::rtl::math::isNan( rData.Doubles[i] ) )
     117          36 :             return;
     118             :     }
     119             :     //no double value is countained
     120             :     //is there any text?
     121           0 :     uno::Sequence< OUString > aStrings( DataSequenceToStringSequence( xDataSequence ) );
     122           0 :     sal_Int32 nTextCount = aStrings.getLength();
     123           0 :     for( sal_Int32 j = 0; j < nTextCount; ++j )
     124             :     {
     125           0 :         if( !aStrings[j].isEmpty() )
     126             :         {
     127           0 :             rData.clear();
     128           0 :             return;
     129             :         }
     130           0 :     }
     131             :     //no content at all
     132             : }
     133             : 
     134       66865 : void lcl_maybeReplaceNanWithZero( double& rfValue, sal_Int32 nMissingValueTreatment )
     135             : {
     136       66865 :     if( nMissingValueTreatment == ::com::sun::star::chart::MissingValueTreatment::USE_ZERO
     137       66865 :         && (::rtl::math::isNan(rfValue) || ::rtl::math::isInf(rfValue)) )
     138           0 :             rfValue = 0.0;
     139       66865 : }
     140             : 
     141             : }
     142             : 
     143        1980 : VDataSeries::VDataSeries( const uno::Reference< XDataSeries >& xDataSeries )
     144             :     : m_nPolygonIndex(0)
     145             :     , m_fLogicMinX(0.0)
     146             :     , m_fLogicMaxX(0.0)
     147             :     , m_fLogicZPos(0.0)
     148             :     , m_xGroupShape(NULL)
     149             :     , m_xLabelsGroupShape(NULL)
     150             :     , m_xErrorXBarsGroupShape(NULL)
     151             :     , m_xErrorYBarsGroupShape(NULL)
     152             :     , m_xFrontSubGroupShape(NULL)
     153             :     , m_xBackSubGroupShape(NULL)
     154             :     , m_xDataSeries(xDataSeries)
     155             :     , m_nPointCount(0)
     156             : 
     157             :     , m_pValueSequenceForDataLabelNumberFormatDetection(&m_aValues_Y)
     158             : 
     159             :     , m_fXMeanValue(1.0)
     160             :     , m_fYMeanValue(1.0)
     161             : 
     162             :     , m_aAttributedDataPointIndexList()
     163             : 
     164             :     , m_eStackingDirection(StackingDirection_NO_STACKING)
     165             :     , m_nAxisIndex(0)
     166             :     , m_bConnectBars(sal_False)
     167             :     , m_bGroupBarsPerAxis(sal_True)
     168             :     , m_nStartingAngle(90)
     169             : 
     170             :     , m_nGlobalSeriesIndex(0)
     171             : 
     172             :     , m_apLabel_Series(NULL)
     173             :     , m_apLabelPropNames_Series(NULL)
     174             :     , m_apLabelPropValues_Series(NULL)
     175             :     , m_apSymbolProperties_Series(NULL)
     176             : 
     177             :     , m_apLabel_AttributedPoint(NULL)
     178             :     , m_apLabelPropNames_AttributedPoint(NULL)
     179             :     , m_apLabelPropValues_AttributedPoint(NULL)
     180             :     , m_apSymbolProperties_AttributedPoint(NULL)
     181             :     , m_apSymbolProperties_InvisibleSymbolForSelection(NULL)
     182             :     , m_nCurrentAttributedPoint(-1)
     183             :     , m_nMissingValueTreatment(::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)
     184             :     , m_bAllowPercentValueInDataLabel(false)
     185             :     , mpOldSeries(NULL)
     186        1980 :     , mnPercent(0.0)
     187             : {
     188        1980 :     ::rtl::math::setNan( & m_fXMeanValue );
     189        1980 :     ::rtl::math::setNan( & m_fYMeanValue );
     190             : 
     191             :     uno::Reference<data::XDataSource> xDataSource =
     192        1980 :             uno::Reference<data::XDataSource>( xDataSeries, uno::UNO_QUERY );
     193             : 
     194             :     uno::Sequence< uno::Reference<
     195             :         chart2::data::XLabeledDataSequence > > aDataSequences =
     196        3960 :             xDataSource->getDataSequences();
     197             : 
     198        5977 :     for(sal_Int32 nN = aDataSequences.getLength();nN--;)
     199             :     {
     200        2017 :         if(!aDataSequences[nN].is())
     201           0 :             continue;
     202        2017 :         uno::Reference<data::XDataSequence>  xDataSequence( aDataSequences[nN]->getValues());
     203        4034 :         uno::Reference<beans::XPropertySet> xProp(xDataSequence, uno::UNO_QUERY );
     204        2017 :         if( xProp.is())
     205             :         {
     206             :             try
     207             :             {
     208        2017 :                 uno::Any aARole = xProp->getPropertyValue("Role");
     209        4034 :                 OUString aRole;
     210        2017 :                 aARole >>= aRole;
     211             : 
     212        2017 :                 if (aRole == "values-x")
     213             :                 {
     214          18 :                     m_aValues_X.init( xDataSequence );
     215          18 :                     lcl_clearIfNoValuesButTextIsContained( m_aValues_X, xDataSequence );
     216             :                 }
     217        1999 :                 else if (aRole =="values-y")
     218        1969 :                     m_aValues_Y.init( xDataSequence );
     219          30 :                 else if (aRole == "values-min")
     220          11 :                     m_aValues_Y_Min.init( xDataSequence );
     221          19 :                 else if (aRole == "values-max")
     222           9 :                     m_aValues_Y_Max.init( xDataSequence );
     223          10 :                 else if (aRole == "values-first")
     224           1 :                     m_aValues_Y_First.init( xDataSequence );
     225           9 :                 else if (aRole == "values-last")
     226           9 :                     m_aValues_Y_Last.init( xDataSequence );
     227           0 :                 else if (aRole == "values-size")
     228           0 :                     m_aValues_Bubble_Size.init( xDataSequence );
     229             :                 else
     230             :                 {
     231           0 :                     VDataSequence* pSequence = new VDataSequence();
     232           0 :                     pSequence->init( xDataSequence );
     233           0 :                     maPropertyMap.insert(aRole, pSequence);
     234        2017 :                 }
     235             :             }
     236           0 :             catch( const uno::Exception& e )
     237             :             {
     238             :                 ASSERT_EXCEPTION( e );
     239             :             }
     240             :         }
     241        2017 :     }
     242             : 
     243             :     //determine the point count
     244        1980 :     m_nPointCount = m_aValues_Y.getLength();
     245             :     {
     246        1980 :         if( m_nPointCount < m_aValues_Bubble_Size.getLength() )
     247           0 :             m_nPointCount = m_aValues_Bubble_Size.getLength();
     248        1980 :         if( m_nPointCount < m_aValues_Y_Min.getLength() )
     249          11 :             m_nPointCount = m_aValues_Y_Min.getLength();
     250        1980 :         if( m_nPointCount < m_aValues_Y_Max.getLength() )
     251           0 :             m_nPointCount = m_aValues_Y_Max.getLength();
     252        1980 :         if( m_nPointCount < m_aValues_Y_First.getLength() )
     253           0 :             m_nPointCount = m_aValues_Y_First.getLength();
     254        1980 :         if( m_nPointCount < m_aValues_Y_Last.getLength() )
     255           0 :             m_nPointCount = m_aValues_Y_Last.getLength();
     256             :     }
     257             : 
     258        3960 :     uno::Reference<beans::XPropertySet> xProp(xDataSeries, uno::UNO_QUERY );
     259        1980 :     if( xProp.is())
     260             :     {
     261             :         try
     262             :         {
     263             :             //get AttributedDataPoints
     264        1980 :             xProp->getPropertyValue("AttributedDataPoints") >>= m_aAttributedDataPointIndexList;
     265             : 
     266        1980 :             xProp->getPropertyValue("StackingDirection") >>= m_eStackingDirection;
     267             : 
     268        1980 :             xProp->getPropertyValue("AttachedAxisIndex") >>= m_nAxisIndex;
     269        1980 :             if(m_nAxisIndex<0)
     270           0 :                 m_nAxisIndex=0;
     271             :         }
     272           0 :         catch( const uno::Exception& e )
     273             :         {
     274             :             ASSERT_EXCEPTION( e );
     275             :         }
     276        1980 :     }
     277        1980 : }
     278             : 
     279        1980 : VDataSeries::~VDataSeries()
     280             : {
     281        1980 : }
     282             : 
     283           0 : void VDataSeries::doSortByXValues()
     284             : {
     285           0 :     if( m_aValues_X.is() && m_aValues_X.Doubles.getLength() )
     286             :     {
     287             :         //prepare a vector for sorting
     288           0 :         std::vector< ::std::vector< double > > aTmp;//outer vector are points, inner vector are the different values of athe point
     289             :         double fNan;
     290           0 :         ::rtl::math::setNan( & fNan );
     291           0 :         sal_Int32 nPointIndex = 0;
     292           0 :         for( nPointIndex=0; nPointIndex < m_nPointCount; nPointIndex++ )
     293             :         {
     294           0 :             std::vector< double > aSinglePoint;
     295           0 :             aSinglePoint.push_back( (nPointIndex < m_aValues_X.Doubles.getLength()) ? m_aValues_X.Doubles[nPointIndex] : fNan );
     296           0 :             aSinglePoint.push_back( (nPointIndex < m_aValues_Y.Doubles.getLength()) ? m_aValues_Y.Doubles[nPointIndex] : fNan );
     297           0 :             aTmp.push_back( aSinglePoint );
     298           0 :         }
     299             : 
     300             :         //do sort
     301           0 :         std::stable_sort( aTmp.begin(), aTmp.end(), lcl_LessXOfPoint() );
     302             : 
     303             :         //fill the sorted points back to the members
     304           0 :         m_aValues_X.Doubles.realloc( m_nPointCount );
     305           0 :         m_aValues_Y.Doubles.realloc( m_nPointCount );
     306             : 
     307           0 :         for( nPointIndex=0; nPointIndex < m_nPointCount; nPointIndex++ )
     308             :         {
     309           0 :             m_aValues_X.Doubles[nPointIndex]=aTmp[nPointIndex][0];
     310           0 :             m_aValues_Y.Doubles[nPointIndex]=aTmp[nPointIndex][1];
     311           0 :         }
     312             :     }
     313           0 : }
     314             : 
     315        7519 : uno::Reference< XDataSeries > VDataSeries::getModel() const
     316             : {
     317        7519 :     return m_xDataSeries;
     318             : }
     319             : 
     320          42 : void VDataSeries::releaseShapes()
     321             : {
     322          42 :     m_xGroupShape.set(0);
     323          42 :     m_xLabelsGroupShape.set(0);
     324          42 :     m_xErrorXBarsGroupShape.set(0);
     325          42 :     m_xErrorYBarsGroupShape.set(0);
     326          42 :     m_xFrontSubGroupShape.set(0);
     327          42 :     m_xBackSubGroupShape.set(0);
     328             : 
     329          42 :     m_aPolyPolygonShape3D.SequenceX.realloc(0);
     330          42 :     m_aPolyPolygonShape3D.SequenceY.realloc(0);
     331          42 :     m_aPolyPolygonShape3D.SequenceZ.realloc(0);
     332          42 :     m_nPolygonIndex = 0;
     333          42 : }
     334             : 
     335        1962 : void VDataSeries::setCategoryXAxis()
     336             : {
     337        1962 :     m_aValues_X.clear();
     338        1962 :     m_bAllowPercentValueInDataLabel = true;
     339        1962 : }
     340             : 
     341           0 : void VDataSeries::setXValues( const Reference< chart2::data::XDataSequence >& xValues )
     342             : {
     343           0 :     m_aValues_X.clear();
     344           0 :     m_aValues_X.init( xValues );
     345           0 :     m_bAllowPercentValueInDataLabel = true;
     346           0 : }
     347             : 
     348          18 : void VDataSeries::setXValuesIfNone( const Reference< chart2::data::XDataSequence >& xValues )
     349             : {
     350          18 :     if( m_aValues_X.is() )
     351          36 :         return;
     352             : 
     353           0 :     m_aValues_X.init( xValues );
     354           0 :     lcl_clearIfNoValuesButTextIsContained( m_aValues_X, xValues );
     355             : }
     356             : 
     357        1980 : void VDataSeries::setGlobalSeriesIndex( sal_Int32 nGlobalSeriesIndex )
     358             : {
     359        1980 :     m_nGlobalSeriesIndex = nGlobalSeriesIndex;
     360        1980 : }
     361             : 
     362        1980 : void VDataSeries::setParticle( const OUString& rSeriesParticle )
     363             : {
     364        1980 :     m_aSeriesParticle = rSeriesParticle;
     365             : 
     366             :     //get CID
     367        1980 :     m_aCID = ObjectIdentifier::createClassifiedIdentifierForParticle( m_aSeriesParticle );
     368        1980 :     m_aPointCID_Stub = ObjectIdentifier::createSeriesSubObjectStub( OBJECTTYPE_DATA_POINT, m_aSeriesParticle );
     369             : 
     370        3960 :     m_aLabelCID_Stub = ObjectIdentifier::createClassifiedIdentifierWithParent(
     371        1980 :                         OBJECTTYPE_DATA_LABEL, OUString(), getLabelsCID() );
     372        1980 : }
     373        2093 : OUString VDataSeries::getSeriesParticle() const
     374             : {
     375        2093 :     return m_aSeriesParticle;
     376             : }
     377        1968 : OUString VDataSeries::getCID() const
     378             : {
     379        1968 :     return m_aCID;
     380             : }
     381        7718 : OUString VDataSeries::getPointCID_Stub() const
     382             : {
     383        7718 :     return m_aPointCID_Stub;
     384             : }
     385         565 : OUString VDataSeries::getErrorBarsCID(bool bYError) const
     386             : {
     387             :     OUString aChildParticle( ObjectIdentifier::getStringForType(
     388         565 :                                       bYError ? OBJECTTYPE_DATA_ERRORS_Y : OBJECTTYPE_DATA_ERRORS_X ) );
     389         565 :     aChildParticle += "=";
     390             : 
     391             :     return ObjectIdentifier::createClassifiedIdentifierForParticles(
     392         565 :             m_aSeriesParticle, aChildParticle );
     393             : }
     394        2172 : OUString VDataSeries::getLabelsCID() const
     395             : {
     396        2172 :     OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) );
     397        2172 :     aChildParticle += "=";
     398             : 
     399             :     return ObjectIdentifier::createClassifiedIdentifierForParticles(
     400        2172 :             m_aSeriesParticle, aChildParticle );
     401             : }
     402         893 : OUString VDataSeries::getLabelCID_Stub() const
     403             : {
     404         893 :     return m_aLabelCID_Stub;
     405             : }
     406          50 : OUString VDataSeries::getDataCurveCID( sal_Int32 nCurveIndex, bool bAverageLine ) const
     407             : {
     408          50 :     OUString aRet;
     409          50 :     aRet = ObjectIdentifier::createDataCurveCID( m_aSeriesParticle, nCurveIndex, bAverageLine );
     410          50 :     return aRet;
     411             : }
     412             : 
     413          53 : OUString VDataSeries::getDataCurveEquationCID( sal_Int32 nCurveIndex ) const
     414             : {
     415          53 :     OUString aRet;
     416          53 :     aRet = ObjectIdentifier::createDataCurveEquationCID( m_aSeriesParticle, nCurveIndex );
     417          53 :     return aRet;
     418             : }
     419        1980 : void VDataSeries::setPageReferenceSize( const awt::Size & rPageRefSize )
     420             : {
     421        1980 :     m_aReferenceSize = rPageRefSize;
     422        1980 : }
     423             : 
     424        3857 : StackingDirection VDataSeries::getStackingDirection() const
     425             : {
     426        3857 :     return m_eStackingDirection;
     427             : }
     428       28176 : sal_Int32 VDataSeries::getAttachedAxisIndex() const
     429             : {
     430       28176 :     return m_nAxisIndex;
     431             : }
     432        1980 : void VDataSeries::setConnectBars( sal_Bool bConnectBars )
     433             : {
     434        1980 :     m_bConnectBars = bConnectBars;
     435        1980 : }
     436         549 : sal_Bool VDataSeries::getConnectBars() const
     437             : {
     438         549 :     return m_bConnectBars;
     439             : }
     440        1980 : void VDataSeries::setGroupBarsPerAxis( sal_Bool bGroupBarsPerAxis )
     441             : {
     442        1980 :     m_bGroupBarsPerAxis = bGroupBarsPerAxis;
     443        1980 : }
     444        2301 : sal_Bool VDataSeries::getGroupBarsPerAxis() const
     445             : {
     446        2301 :     return m_bGroupBarsPerAxis;
     447             : }
     448             : 
     449        1980 : void VDataSeries::setStartingAngle( sal_Int32 nStartingAngle )
     450             : {
     451        1980 :     m_nStartingAngle = nStartingAngle;
     452        1980 : }
     453          30 : sal_Int32 VDataSeries::getStartingAngle() const
     454             : {
     455          30 :     return m_nStartingAngle;
     456             : }
     457             : 
     458           0 : void VDataSeries::setAttachedAxisIndex( sal_Int32 nAttachedAxisIndex )
     459             : {
     460           0 :     if( nAttachedAxisIndex < 0 )
     461           0 :         nAttachedAxisIndex = 0;
     462           0 :     m_nAxisIndex = nAttachedAxisIndex;
     463           0 : }
     464             : 
     465        9844 : sal_Int32 VDataSeries::getTotalPointCount() const
     466             : {
     467        9844 :     return m_nPointCount;
     468             : }
     469             : 
     470       41263 : double VDataSeries::getXValue( sal_Int32 index ) const
     471             : {
     472       41263 :     double fRet = 0.0;
     473       41263 :     if(m_aValues_X.is())
     474             :     {
     475         801 :         if( 0<=index && index<m_aValues_X.getLength() )
     476             :         {
     477         801 :             fRet = m_aValues_X.Doubles[index];
     478         801 :             if(mpOldSeries && index < mpOldSeries->m_aValues_X.getLength())
     479             :             {
     480           0 :                 double nOldVal = mpOldSeries->m_aValues_X.Doubles[index];
     481           0 :                 fRet = nOldVal + (fRet - nOldVal) * mnPercent;
     482             :             }
     483             :         }
     484             :         else
     485           0 :             ::rtl::math::setNan( &fRet );
     486             :     }
     487             :     else
     488             :     {
     489             :         // #i70133# always return correct X position - needed for short data series
     490       40462 :         if( 0<=index /*&& index < m_nPointCount*/ )
     491       40462 :             fRet = index+1;//first category (index 0) matches with real number 1.0
     492             :         else
     493           0 :             ::rtl::math::setNan( &fRet );
     494             :     }
     495       41263 :     lcl_maybeReplaceNanWithZero( fRet, getMissingValueTreatment() );
     496       41263 :     return fRet;
     497             : }
     498             : 
     499       25602 : double VDataSeries::getYValue( sal_Int32 index ) const
     500             : {
     501       25602 :     double fRet = 0.0;
     502       25602 :     if(m_aValues_Y.is())
     503             :     {
     504       25602 :         if( 0<=index && index<m_aValues_Y.getLength() )
     505             :         {
     506       25602 :             fRet = m_aValues_Y.Doubles[index];
     507       25602 :             if(mpOldSeries && index < mpOldSeries->m_aValues_Y.getLength())
     508             :             {
     509           0 :                 double nOldVal = mpOldSeries->m_aValues_Y.Doubles[index];
     510           0 :                 fRet = nOldVal + (fRet - nOldVal) * mnPercent;
     511             :             }
     512             :         }
     513             :         else
     514           0 :             ::rtl::math::setNan( &fRet );
     515             :     }
     516             :     else
     517             :     {
     518             :         // #i70133# always return correct X position - needed for short data series
     519           0 :         if( 0<=index /*&& index < m_nPointCount*/ )
     520           0 :             fRet = index+1;//first category (index 0) matches with real number 1.0
     521             :         else
     522           0 :             ::rtl::math::setNan( &fRet );
     523             :     }
     524       25602 :     lcl_maybeReplaceNanWithZero( fRet, getMissingValueTreatment() );
     525       25602 :     return fRet;
     526             : }
     527             : 
     528          21 : void VDataSeries::getMinMaxXValue(double& fMin, double& fMax) const
     529             : {
     530          21 :     rtl::math::setNan( &fMax );
     531          21 :     rtl::math::setNan( &fMin );
     532             : 
     533          21 :     uno::Sequence< double > aValuesX = getAllX();
     534             : 
     535          21 :     if(aValuesX.getLength() > 0)
     536             :     {
     537             :         double aValue;
     538             : 
     539          21 :         fMax = fMin = aValuesX[0];
     540             : 
     541         147 :         for (sal_Int32 i = 1; i < aValuesX.getLength(); i++)
     542             :         {
     543         126 :             aValue = aValuesX[i];
     544         126 :             if ( aValue > fMax)
     545             :             {
     546         126 :                 fMax = aValue;
     547             :             }
     548           0 :             else if ( aValue < fMin)
     549             :             {
     550           0 :                 fMin = aValue;
     551             :             }
     552             :         }
     553          21 :     }
     554          21 : }
     555         105 : double VDataSeries::getY_Min( sal_Int32 index ) const
     556             : {
     557         105 :     return m_aValues_Y_Min.getValue( index );
     558             : }
     559         105 : double VDataSeries::getY_Max( sal_Int32 index ) const
     560             : {
     561         105 :     return m_aValues_Y_Max.getValue( index );
     562             : }
     563         105 : double VDataSeries::getY_First( sal_Int32 index ) const
     564             : {
     565         105 :     return m_aValues_Y_First.getValue( index );
     566             : }
     567         105 : double VDataSeries::getY_Last( sal_Int32 index ) const
     568             : {
     569         105 :     return m_aValues_Y_Last.getValue( index );
     570             : }
     571           0 : double VDataSeries::getBubble_Size( sal_Int32 index ) const
     572             : {
     573           0 :     double nNewVal = m_aValues_Bubble_Size.getValue( index );
     574           0 :     if(mpOldSeries && index < mpOldSeries->m_aValues_Bubble_Size.getLength())
     575             :     {
     576           0 :         double nOldVal = mpOldSeries->m_aValues_Bubble_Size.getValue( index );
     577           0 :         nNewVal = nOldVal + (nNewVal - nOldVal) * mnPercent;
     578             :     }
     579             : 
     580           0 :     return nNewVal;
     581             : }
     582             : 
     583         895 : bool VDataSeries::hasExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const
     584             : {
     585         895 :     OUString aPropName = bForPercentage ? OUString("PercentageNumberFormat") : OUString("NumberFormat");
     586         895 :     bool bHasNumberFormat = false;
     587        1790 :     uno::Reference< beans::XPropertySet > xPointProp( this->getPropertiesOfPoint( nPointIndex ));
     588         895 :     sal_Int32 nNumberFormat = -1;
     589         895 :     if( xPointProp.is() && (xPointProp->getPropertyValue(aPropName) >>= nNumberFormat) )
     590          23 :         bHasNumberFormat = true;
     591        1790 :     return bHasNumberFormat;
     592             : }
     593          23 : sal_Int32 VDataSeries::getExplicitNumberFormat( sal_Int32 nPointIndex, bool bForPercentage ) const
     594             : {
     595          23 :     OUString aPropName = bForPercentage ? OUString("PercentageNumberFormat") : OUString("NumberFormat");
     596          23 :     sal_Int32 nNumberFormat = -1;
     597          46 :     uno::Reference< beans::XPropertySet > xPointProp( this->getPropertiesOfPoint( nPointIndex ));
     598          23 :     if( xPointProp.is() )
     599          23 :         xPointProp->getPropertyValue(aPropName) >>= nNumberFormat;
     600          46 :     return nNumberFormat;
     601             : }
     602        1980 : void VDataSeries::setRoleOfSequenceForDataLabelNumberFormatDetection( const OUString& rRole )
     603             : {
     604        1980 :     if (rRole == "values-y")
     605        1969 :         m_pValueSequenceForDataLabelNumberFormatDetection = &m_aValues_Y;
     606          11 :     else if (rRole == "values-size")
     607           0 :         m_pValueSequenceForDataLabelNumberFormatDetection = &m_aValues_Bubble_Size;
     608          11 :     else if (rRole == "values-min")
     609           0 :         m_pValueSequenceForDataLabelNumberFormatDetection = &m_aValues_Y_Min;
     610          11 :     else if (rRole == "values-max")
     611           0 :         m_pValueSequenceForDataLabelNumberFormatDetection = &m_aValues_Y_Max;
     612          11 :     else if (rRole == "values-first")
     613           0 :         m_pValueSequenceForDataLabelNumberFormatDetection = &m_aValues_Y_First;
     614          11 :     else if (rRole == "values-last")
     615          11 :         m_pValueSequenceForDataLabelNumberFormatDetection = &m_aValues_Y_Last;
     616           0 :     else if (rRole == "values-x")
     617           0 :         m_pValueSequenceForDataLabelNumberFormatDetection = &m_aValues_X;
     618        1980 : }
     619         823 : bool VDataSeries::shouldLabelNumberFormatKeyBeDetectedFromYAxis() const
     620             : {
     621         823 :     if( m_pValueSequenceForDataLabelNumberFormatDetection == &m_aValues_Bubble_Size )
     622           0 :         return false;
     623         823 :     else if( m_pValueSequenceForDataLabelNumberFormatDetection == &m_aValues_X )
     624           0 :         return false;
     625         823 :     return true;
     626             : }
     627         823 : sal_Int32 VDataSeries::detectNumberFormatKey( sal_Int32 index ) const
     628             : {
     629         823 :     sal_Int32 nRet = 0;
     630         823 :     if( m_pValueSequenceForDataLabelNumberFormatDetection )
     631         823 :         nRet = m_pValueSequenceForDataLabelNumberFormatDetection->detectNumberFormatKey( index );
     632         823 :     return nRet;
     633             : }
     634             : 
     635         893 : sal_Int32 VDataSeries::getLabelPlacement( sal_Int32 nPointIndex, const uno::Reference< chart2::XChartType >& xChartType, sal_Int32 nDimensionCount, sal_Bool bSwapXAndY ) const
     636             : {
     637         893 :     sal_Int32 nLabelPlacement=0;
     638             :     try
     639             :     {
     640         893 :         uno::Reference< beans::XPropertySet > xPointProps( this->getPropertiesOfPoint( nPointIndex ) );
     641         893 :         if( xPointProps.is() )
     642         893 :             xPointProps->getPropertyValue("LabelPlacement") >>= nLabelPlacement;
     643             : 
     644             :         //ensure that the set label placement is supported by this charttype
     645             : 
     646             :         uno::Sequence < sal_Int32 > aAvailablePlacements( ChartTypeHelper::getSupportedLabelPlacements(
     647         893 :                 xChartType, nDimensionCount, bSwapXAndY, m_xDataSeries ) );
     648             : 
     649        5441 :         for( sal_Int32 nN = 0; nN < aAvailablePlacements.getLength(); nN++ )
     650        4548 :             if( aAvailablePlacements[nN] == nLabelPlacement )
     651           0 :                 return nLabelPlacement; //ok
     652             : 
     653             :         //otherwise use the first supported one
     654         893 :         if( aAvailablePlacements.getLength() )
     655             :         {
     656         893 :             nLabelPlacement = aAvailablePlacements[0];
     657         893 :             return nLabelPlacement;
     658             :         }
     659             : 
     660           0 :         OSL_FAIL("no label placement supported");
     661             :     }
     662           0 :     catch( const uno::Exception& e )
     663             :     {
     664             :         ASSERT_EXCEPTION( e );
     665             :     }
     666           0 :     return nLabelPlacement;
     667             : }
     668             : 
     669        7970 : double VDataSeries::getMinimumofAllDifferentYValues( sal_Int32 index ) const
     670             : {
     671        7970 :     double fMin=0.0;
     672        7970 :     ::rtl::math::setInf(&fMin, false);
     673             : 
     674        8040 :     if( !m_aValues_Y.is() &&
     675          35 :         (m_aValues_Y_Min.is() || m_aValues_Y_Max.is()
     676           0 :         || m_aValues_Y_First.is() || m_aValues_Y_Last.is() ) )
     677             :     {
     678          35 :         double fY_Min = getY_Min( index );
     679          35 :         double fY_Max = getY_Max( index );
     680          35 :         double fY_First = getY_First( index );
     681          35 :         double fY_Last = getY_Last( index );
     682             : 
     683          35 :         if(fMin>fY_First)
     684           5 :             fMin=fY_First;
     685          35 :         if(fMin>fY_Last)
     686          26 :             fMin=fY_Last;
     687          35 :         if(fMin>fY_Min)
     688          20 :             fMin=fY_Min;
     689          35 :         if(fMin>fY_Max)
     690          13 :             fMin=fY_Max;
     691             :     }
     692             :     else
     693             :     {
     694        7935 :         double fY = getYValue( index );
     695        7935 :         if(fMin>fY)
     696        7919 :             fMin=fY;
     697             :     }
     698             : 
     699        7970 :     if( ::rtl::math::isInf(fMin) )
     700          16 :         ::rtl::math::setNan(&fMin);
     701             : 
     702        7970 :     return fMin;
     703             : }
     704             : 
     705        7970 : double VDataSeries::getMaximumofAllDifferentYValues( sal_Int32 index ) const
     706             : {
     707        7970 :     double fMax=0.0;
     708        7970 :     ::rtl::math::setInf(&fMax, true);
     709             : 
     710        8040 :     if( !m_aValues_Y.is() &&
     711          35 :         (m_aValues_Y_Min.is() || m_aValues_Y_Max.is()
     712           0 :         || m_aValues_Y_First.is() || m_aValues_Y_Last.is() ) )
     713             :     {
     714          35 :         double fY_Min = getY_Min( index );
     715          35 :         double fY_Max = getY_Max( index );
     716          35 :         double fY_First = getY_First( index );
     717          35 :         double fY_Last = getY_Last( index );
     718             : 
     719          35 :         if(fMax<fY_First)
     720           5 :             fMax=fY_First;
     721          35 :         if(fMax<fY_Last)
     722          27 :             fMax=fY_Last;
     723          35 :         if(fMax<fY_Min)
     724          21 :             fMax=fY_Min;
     725          35 :         if(fMax<fY_Max)
     726           8 :             fMax=fY_Max;
     727             :     }
     728             :     else
     729             :     {
     730        7935 :         double fY = getYValue( index );
     731        7935 :         if(fMax<fY)
     732        7919 :             fMax=fY;
     733             :     }
     734             : 
     735        7970 :     if( ::rtl::math::isInf(fMax) )
     736          16 :         ::rtl::math::setNan(&fMax);
     737             : 
     738        7970 :     return fMax;
     739             : }
     740             : 
     741          74 : uno::Sequence< double > VDataSeries::getAllX() const
     742             : {
     743          74 :     if(!m_aValues_X.is() && !m_aValues_X.getLength() && m_nPointCount)
     744             :     {
     745             :         //init x values from category indexes
     746             :         //first category (index 0) matches with real number 1.0
     747          32 :         m_aValues_X.Doubles.realloc( m_nPointCount );
     748         453 :         for(sal_Int32 nN=m_aValues_X.getLength();nN--;)
     749         389 :             m_aValues_X.Doubles[nN] = nN+1;
     750             :     }
     751          74 :     return m_aValues_X.Doubles;
     752             : }
     753             : 
     754         310 : uno::Sequence< double > VDataSeries::getAllY() const
     755             : {
     756         310 :     if(!m_aValues_Y.is() && !m_aValues_Y.getLength() && m_nPointCount)
     757             :     {
     758             :         //init y values from indexes
     759             :         //first y-value (index 0) matches with real number 1.0
     760           0 :         m_aValues_Y.Doubles.realloc( m_nPointCount );
     761           0 :         for(sal_Int32 nN=m_aValues_Y.getLength();nN--;)
     762           0 :             m_aValues_Y.Doubles[nN] = nN+1;
     763             :     }
     764         310 :     return m_aValues_Y.Doubles;
     765             : }
     766             : 
     767           0 : double VDataSeries::getXMeanValue() const
     768             : {
     769           0 :     if( ::rtl::math::isNan( m_fXMeanValue ) )
     770             :     {
     771           0 :         uno::Reference< XRegressionCurveCalculator > xCalculator( RegressionCurveHelper::createRegressionCurveCalculatorByServiceName( "com.sun.star.chart2.MeanValueRegressionCurve" ) );
     772           0 :         uno::Sequence< double > aXValuesDummy;
     773           0 :         xCalculator->recalculateRegression( aXValuesDummy, getAllX() );
     774           0 :         double fXDummy = 1.0;
     775           0 :         m_fXMeanValue = xCalculator->getCurveValue( fXDummy );
     776             :     }
     777           0 :     return m_fXMeanValue;
     778             : }
     779             : 
     780           0 : double VDataSeries::getYMeanValue() const
     781             : {
     782           0 :     if( ::rtl::math::isNan( m_fYMeanValue ) )
     783             :     {
     784             :         uno::Reference< XRegressionCurveCalculator > xCalculator(
     785           0 :             RegressionCurveHelper::createRegressionCurveCalculatorByServiceName("com.sun.star.chart2.MeanValueRegressionCurve"));
     786           0 :         uno::Sequence< double > aXValuesDummy;
     787           0 :         xCalculator->recalculateRegression( aXValuesDummy, getAllY() );
     788           0 :         double fXDummy = 1.0;
     789           0 :         m_fYMeanValue = xCalculator->getCurveValue( fXDummy );
     790             :     }
     791           0 :     return m_fYMeanValue;
     792             : }
     793             : 
     794         164 : Symbol* getSymbolPropertiesFromPropertySet( const uno::Reference< beans::XPropertySet >& xProp )
     795             : {
     796             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     797         164 :     ::std::auto_ptr< Symbol > apSymbolProps( new Symbol() );
     798             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     799             :     try
     800             :     {
     801         164 :         if( xProp->getPropertyValue("Symbol") >>= *apSymbolProps )
     802             :         {
     803             :             //use main color to fill symbols
     804         164 :             xProp->getPropertyValue("Color") >>= apSymbolProps->FillColor;
     805             :             // border of symbols always same as fill color
     806         164 :             apSymbolProps->BorderColor = apSymbolProps->FillColor;
     807             :         }
     808             :         else
     809           0 :             apSymbolProps.reset();
     810             :     }
     811           0 :     catch(const uno::Exception &e)
     812             :     {
     813             :         ASSERT_EXCEPTION( e );
     814             :     }
     815         164 :     return apSymbolProps.release();
     816             : }
     817             : 
     818        1149 : Symbol* VDataSeries::getSymbolProperties( sal_Int32 index ) const
     819             : {
     820        1149 :     Symbol* pRet=NULL;
     821        1149 :     if( isAttributedDataPoint( index ) )
     822             :     {
     823          13 :         adaptPointCache( index );
     824          13 :         if (!m_apSymbolProperties_AttributedPoint)
     825             :             m_apSymbolProperties_AttributedPoint.reset(
     826          13 :                 getSymbolPropertiesFromPropertySet(this->getPropertiesOfPoint(index)));
     827          13 :         pRet = m_apSymbolProperties_AttributedPoint.get();
     828             :         //if a single data point does not have symbols but the dataseries itself has symbols
     829             :         //we create an invisible symbol shape to enable selection of that point
     830          13 :         if( !pRet || pRet->Style == SymbolStyle_NONE )
     831             :         {
     832          13 :             if (!m_apSymbolProperties_Series)
     833             :                 m_apSymbolProperties_Series.reset(
     834           0 :                     getSymbolPropertiesFromPropertySet(this->getPropertiesOfSeries()));
     835          13 :             if( m_apSymbolProperties_Series.get() && m_apSymbolProperties_Series->Style != SymbolStyle_NONE )
     836             :             {
     837           0 :                 if (!m_apSymbolProperties_InvisibleSymbolForSelection)
     838             :                 {
     839           0 :                     m_apSymbolProperties_InvisibleSymbolForSelection.reset(new Symbol);
     840           0 :                     m_apSymbolProperties_InvisibleSymbolForSelection->Style = SymbolStyle_STANDARD;
     841           0 :                     m_apSymbolProperties_InvisibleSymbolForSelection->StandardSymbol = 0;//square
     842           0 :                     m_apSymbolProperties_InvisibleSymbolForSelection->Size = m_apSymbolProperties_Series->Size;
     843           0 :                     m_apSymbolProperties_InvisibleSymbolForSelection->BorderColor = 0xff000000;//invisible
     844           0 :                     m_apSymbolProperties_InvisibleSymbolForSelection->FillColor = 0xff000000;//invisible
     845             :                 }
     846           0 :                 pRet = m_apSymbolProperties_InvisibleSymbolForSelection.get();
     847             :             }
     848             :         }
     849             :     }
     850             :     else
     851             :     {
     852        1136 :         if (!m_apSymbolProperties_Series)
     853             :             m_apSymbolProperties_Series.reset(
     854         151 :                 getSymbolPropertiesFromPropertySet(this->getPropertiesOfSeries()));
     855        1136 :         pRet = m_apSymbolProperties_Series.get();
     856             :     }
     857             : 
     858        1149 :     if( pRet && pRet->Style == SymbolStyle_AUTO )
     859             :     {
     860           0 :         pRet->Style = SymbolStyle_STANDARD;
     861             : 
     862           0 :         sal_Int32 nIndex = m_nGlobalSeriesIndex;
     863           0 :         if(m_aValues_X.is())
     864           0 :             nIndex++;
     865           0 :         pRet->StandardSymbol = nIndex;
     866             :     }
     867             : 
     868        1149 :     return pRet;
     869             : }
     870             : 
     871        1116 : uno::Reference< beans::XPropertySet > VDataSeries::getXErrorBarProperties( sal_Int32 index ) const
     872             : {
     873        1116 :     uno::Reference< beans::XPropertySet > xErrorBarProp;
     874             : 
     875        2232 :     uno::Reference< beans::XPropertySet > xPointProp( this->getPropertiesOfPoint( index ));
     876        1116 :     if( xPointProp.is() )
     877        1116 :         xPointProp->getPropertyValue("ErrorBarX") >>= xErrorBarProp;
     878        2232 :     return xErrorBarProp;
     879             : }
     880             : 
     881        8124 : uno::Reference< beans::XPropertySet > VDataSeries::getYErrorBarProperties( sal_Int32 index ) const
     882             : {
     883        8124 :     uno::Reference< beans::XPropertySet > xErrorBarProp;
     884             : 
     885       16248 :     uno::Reference< beans::XPropertySet > xPointProp( this->getPropertiesOfPoint( index ));
     886        8124 :     if( xPointProp.is() )
     887        8124 :         xPointProp->getPropertyValue("ErrorBarY") >>= xErrorBarProp;
     888       16248 :     return xErrorBarProp;
     889             : }
     890             : 
     891         155 : bool VDataSeries::hasPointOwnColor( sal_Int32 index ) const
     892             : {
     893         155 :     if( !isAttributedDataPoint(index) )
     894         134 :         return false;
     895             : 
     896             :     try
     897             :     {
     898          21 :         uno::Reference< beans::XPropertyState > xPointState( this->getPropertiesOfPoint(index), uno::UNO_QUERY_THROW );
     899          21 :         return (xPointState->getPropertyState("Color") != beans::PropertyState_DEFAULT_VALUE );
     900             :     }
     901           0 :     catch(const uno::Exception& e)
     902             :     {
     903             :         ASSERT_EXCEPTION( e );
     904             :     }
     905           0 :     return false;
     906             : }
     907             : 
     908       41917 : bool VDataSeries::isAttributedDataPoint( sal_Int32 index ) const
     909             : {
     910             :     //returns true if the data point assigned by the given index has set it's own properties
     911       41917 :     if( index>=m_nPointCount || m_nPointCount==0)
     912           0 :         return false;
     913       86272 :     for(sal_Int32 nN=m_aAttributedDataPointIndexList.getLength();nN--;)
     914             :     {
     915        4203 :         if(index==m_aAttributedDataPointIndexList[nN])
     916        1765 :             return true;
     917             :     }
     918       40152 :     return false;
     919             : }
     920             : 
     921        2492 : bool VDataSeries::isVaryColorsByPoint() const
     922             : {
     923        2492 :     bool bVaryColorsByPoint = false;
     924        2492 :     Reference< beans::XPropertySet > xSeriesProp( this->getPropertiesOfSeries() );
     925        2492 :     if( xSeriesProp.is() )
     926        2492 :         xSeriesProp->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint;
     927        2492 :     return bVaryColorsByPoint;
     928             : }
     929             : 
     930       22228 : uno::Reference< beans::XPropertySet > VDataSeries::getPropertiesOfPoint( sal_Int32 index ) const
     931             : {
     932       22228 :     if( isAttributedDataPoint( index ) )
     933        1166 :         return m_xDataSeries->getDataPointByIndex(index);
     934       21062 :     return this->getPropertiesOfSeries();
     935             : }
     936             : 
     937       26074 : uno::Reference< beans::XPropertySet > VDataSeries::getPropertiesOfSeries() const
     938             : {
     939       26074 :     return  uno::Reference<beans::XPropertySet>(m_xDataSeries, uno::UNO_QUERY );
     940             : }
     941             : 
     942        2092 : DataPointLabel* getDataPointLabelFromPropertySet( const uno::Reference< beans::XPropertySet >& xProp )
     943             : {
     944             :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
     945        2092 :     ::std::auto_ptr< DataPointLabel > apLabel( new DataPointLabel() );
     946             :     SAL_WNODEPRECATED_DECLARATIONS_POP
     947             :     try
     948             :     {
     949        2092 :         if( !(xProp->getPropertyValue("Label") >>= *apLabel) )
     950           0 :             apLabel.reset();
     951             :     }
     952           0 :     catch(const uno::Exception &e)
     953             :     {
     954             :         ASSERT_EXCEPTION( e );
     955             :     }
     956        2092 :     return apLabel.release();
     957             : }
     958             : 
     959         428 : void VDataSeries::adaptPointCache( sal_Int32 nNewPointIndex ) const
     960             : {
     961         428 :     if( m_nCurrentAttributedPoint != nNewPointIndex )
     962             :     {
     963         157 :         m_apLabel_AttributedPoint.reset();
     964         157 :         m_apLabelPropNames_AttributedPoint.reset();
     965         157 :         m_apLabelPropValues_AttributedPoint.reset();
     966         157 :         m_apSymbolProperties_AttributedPoint.reset();
     967         157 :         m_nCurrentAttributedPoint = nNewPointIndex;
     968             :     }
     969         428 : }
     970             : 
     971        9504 : DataPointLabel* VDataSeries::getDataPointLabel( sal_Int32 index ) const
     972             : {
     973        9504 :     DataPointLabel* pRet = NULL;
     974        9504 :     if( isAttributedDataPoint( index ) )
     975             :     {
     976         286 :         adaptPointCache( index );
     977         286 :         if( !m_apLabel_AttributedPoint.get() )
     978             :             m_apLabel_AttributedPoint.reset(
     979         157 :                 getDataPointLabelFromPropertySet(this->getPropertiesOfPoint(index)));
     980         286 :         pRet = m_apLabel_AttributedPoint.get();
     981             :     }
     982             :     else
     983             :     {
     984        9218 :         if (!m_apLabel_Series)
     985             :             m_apLabel_Series.reset(
     986        1935 :                 getDataPointLabelFromPropertySet(this->getPropertiesOfPoint(index)));
     987        9218 :         pRet = m_apLabel_Series.get();
     988             :     }
     989        9504 :     if( !m_bAllowPercentValueInDataLabel )
     990             :     {
     991          89 :         if( pRet )
     992          89 :             pRet->ShowNumberInPercent = false;
     993             :     }
     994        9504 :     return pRet;
     995             : }
     996             : 
     997        9504 : DataPointLabel* VDataSeries::getDataPointLabelIfLabel( sal_Int32 index ) const
     998             : {
     999        9504 :     DataPointLabel* pLabel = this->getDataPointLabel( index );
    1000        9504 :     if( !pLabel || (!pLabel->ShowNumber && !pLabel->ShowNumberInPercent
    1001        7257 :         && !pLabel->ShowCategoryName ) )
    1002        7211 :         return 0;
    1003        2293 :     return pLabel;
    1004             : }
    1005             : 
    1006         893 : bool VDataSeries::getTextLabelMultiPropertyLists( sal_Int32 index
    1007             :     , tNameSequence*& pPropNames
    1008             :     , tAnySequence*& pPropValues ) const
    1009             : {
    1010         893 :     pPropNames = NULL; pPropValues = NULL;
    1011         893 :     uno::Reference< beans::XPropertySet > xTextProp;
    1012         893 :     bool bDoDynamicFontResize = false;
    1013         893 :     if( isAttributedDataPoint( index ) )
    1014             :     {
    1015         129 :         adaptPointCache( index );
    1016         129 :         if (!m_apLabelPropValues_AttributedPoint)
    1017             :         {
    1018         129 :             m_apLabelPropNames_AttributedPoint.reset(new tNameSequence);
    1019         129 :             m_apLabelPropValues_AttributedPoint.reset(new tAnySequence);
    1020         129 :             xTextProp.set( this->getPropertiesOfPoint( index ));
    1021             :             PropertyMapper::getTextLabelMultiPropertyLists(
    1022         129 :                 xTextProp, *m_apLabelPropNames_AttributedPoint, *m_apLabelPropValues_AttributedPoint);
    1023         129 :             bDoDynamicFontResize = true;
    1024             :         }
    1025         129 :         pPropNames = m_apLabelPropNames_AttributedPoint.get();
    1026         129 :         pPropValues = m_apLabelPropValues_AttributedPoint.get();
    1027             :     }
    1028             :     else
    1029             :     {
    1030         764 :         if (!m_apLabelPropValues_Series)
    1031             :         {
    1032          63 :             m_apLabelPropNames_Series.reset(new tNameSequence);
    1033          63 :             m_apLabelPropValues_Series.reset(new tAnySequence);
    1034          63 :             xTextProp.set( this->getPropertiesOfPoint( index ));
    1035             :             PropertyMapper::getTextLabelMultiPropertyLists(
    1036          63 :                 xTextProp, *m_apLabelPropNames_Series, *m_apLabelPropValues_Series);
    1037          63 :             bDoDynamicFontResize = true;
    1038             :         }
    1039         764 :         pPropNames = m_apLabelPropNames_Series.get();
    1040         764 :         pPropValues = m_apLabelPropValues_Series.get();
    1041             :     }
    1042             : 
    1043        1085 :     if( bDoDynamicFontResize &&
    1044        1277 :         pPropNames && pPropValues &&
    1045         192 :         xTextProp.is())
    1046             :     {
    1047         192 :         LabelPositionHelper::doDynamicFontResize( *pPropValues, *pPropNames, xTextProp, m_aReferenceSize );
    1048             :     }
    1049         893 :     if(pPropNames&&pPropValues)
    1050         893 :         return true;
    1051           0 :     return false;
    1052             : }
    1053             : 
    1054        1980 : void VDataSeries::setMissingValueTreatment( sal_Int32 nMissingValueTreatment )
    1055             : {
    1056        1980 :     m_nMissingValueTreatment = nMissingValueTreatment;
    1057        1980 : }
    1058             : 
    1059       66865 : sal_Int32 VDataSeries::getMissingValueTreatment() const
    1060             : {
    1061       66865 :     return m_nMissingValueTreatment;
    1062             : }
    1063             : 
    1064           0 : VDataSeries::VDataSeries()
    1065             :     : m_nPolygonIndex(0)
    1066             :     , m_fLogicMinX(0)
    1067             :     , m_fLogicMaxX(0)
    1068             :     , m_fLogicZPos(0)
    1069             :     , m_nPointCount(0)
    1070             :     , m_fXMeanValue(0)
    1071             :     , m_fYMeanValue(0)
    1072             :     , m_eStackingDirection(chart2::StackingDirection_NO_STACKING)
    1073             :     , m_nAxisIndex(0)
    1074             :     , m_bConnectBars(false)
    1075             :     , m_bGroupBarsPerAxis(false)
    1076             :     , m_nStartingAngle(0)
    1077             :     , m_nGlobalSeriesIndex(0)
    1078             :     , m_nCurrentAttributedPoint(0)
    1079             :     , m_nMissingValueTreatment(0)
    1080             :     , m_bAllowPercentValueInDataLabel(false)
    1081             :     , mpOldSeries(NULL)
    1082           0 :     , mnPercent(0)
    1083             : {
    1084           0 : }
    1085             : 
    1086           0 : void VDataSeries::setOldTimeBased( VDataSeries* pOldSeries, double nPercent )
    1087             : {
    1088           0 :     mnPercent = nPercent;
    1089           0 :     mpOldSeries = pOldSeries;
    1090           0 :     mpOldSeries->mpOldSeries = NULL;
    1091           0 : }
    1092             : 
    1093           0 : VDataSeries* VDataSeries::createCopyForTimeBased() const
    1094             : {
    1095           0 :     VDataSeries* pNew = new VDataSeries();
    1096           0 :     pNew->m_aValues_X = m_aValues_X;
    1097           0 :     pNew->m_aValues_Y = m_aValues_Y;
    1098           0 :     pNew->m_aValues_Z = m_aValues_Z;
    1099           0 :     pNew->m_aValues_Y_Min = m_aValues_Y_Min;
    1100           0 :     pNew->m_aValues_Y_Max = m_aValues_Y_Max;
    1101           0 :     pNew->m_aValues_Y_First = m_aValues_Y_First;
    1102           0 :     pNew->m_aValues_Y_Last = m_aValues_Y_Last;
    1103           0 :     pNew->m_aValues_Bubble_Size = m_aValues_Bubble_Size;
    1104           0 :     pNew->maPropertyMap = maPropertyMap;
    1105             : 
    1106           0 :     pNew->m_nPointCount = m_nPointCount;
    1107             : 
    1108           0 :     return pNew;
    1109             : }
    1110             : 
    1111           0 : double VDataSeries::getValueByProperty( sal_Int32 nIndex, const OUString& rPropName ) const
    1112             : {
    1113             :     boost::ptr_map<OUString, VDataSequence>::const_iterator itr =
    1114           0 :         maPropertyMap.find(rPropName);
    1115           0 :     if(itr == maPropertyMap.end())
    1116             :     {
    1117             :         double fNan;
    1118           0 :         ::rtl::math::setNan( & fNan );
    1119           0 :         return fNan;
    1120             :     }
    1121             : 
    1122           0 :     const VDataSequence* pData = itr->second;
    1123           0 :     double fValue = pData->getValue(nIndex);
    1124           0 :     if(mpOldSeries && mpOldSeries->hasPropertyMapping(rPropName))
    1125             :     {
    1126           0 :         double fOldValue = mpOldSeries->getValueByProperty( nIndex, rPropName );
    1127           0 :         if(rPropName.endsWith("Color"))
    1128             :         {
    1129             :             //optimized interpolation for color values
    1130           0 :             Color aColor(static_cast<sal_uInt32>(fValue));
    1131           0 :             Color aOldColor(static_cast<sal_uInt32>(fOldValue));
    1132           0 :             sal_uInt8 r = aOldColor.GetRed() + (aColor.GetRed() - aOldColor.GetRed()) * mnPercent;
    1133           0 :             sal_uInt8 g = aOldColor.GetGreen() + (aColor.GetGreen() - aOldColor.GetGreen()) * mnPercent;
    1134           0 :             sal_uInt8 b = aOldColor.GetBlue() + (aColor.GetBlue() - aOldColor.GetBlue()) * mnPercent;
    1135           0 :             sal_uInt8 t = aOldColor.GetTransparency() + (aColor.GetTransparency() - aOldColor.GetTransparency()) * mnPercent;
    1136           0 :             Color aRet(t, r, g, b);
    1137           0 :             return aRet.GetColor();
    1138             :         }
    1139           0 :         return fOldValue + (fValue - fOldValue) * mnPercent;
    1140             :     }
    1141           0 :     return fValue;
    1142             : }
    1143             : 
    1144        6938 : bool VDataSeries::hasPropertyMapping(const OUString& rPropName ) const
    1145             : {
    1146        6938 :     return maPropertyMap.find(rPropName) != maPropertyMap.end();
    1147             : }
    1148             : 
    1149             : } //namespace chart
    1150             : 
    1151             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10