LCOV - code coverage report
Current view: top level - chart2/source/controller/chartapiwrapper - WrappedStatisticProperties.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 370 451 82.0 %
Date: 2015-06-13 12:38:46 Functions: 88 100 88.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 "WrappedStatisticProperties.hxx"
      21             : #include "WrappedSeriesOrDiagramProperty.hxx"
      22             : #include "macros.hxx"
      23             : #include "FastPropertyIdRanges.hxx"
      24             : #include "RegressionCurveHelper.hxx"
      25             : #include "DiagramHelper.hxx"
      26             : #include "ErrorBar.hxx"
      27             : #include "StatisticsHelper.hxx"
      28             : #include <unonames.hxx>
      29             : 
      30             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      31             : #include <com/sun/star/chart/ChartErrorCategory.hpp>
      32             : #include <com/sun/star/chart/ErrorBarStyle.hpp>
      33             : #include <com/sun/star/chart/ChartErrorIndicatorType.hpp>
      34             : #include <com/sun/star/chart/ChartRegressionCurveType.hpp>
      35             : #include <com/sun/star/chart2/data/XDataProvider.hpp>
      36             : #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
      37             : 
      38             : using namespace ::com::sun::star;
      39             : using ::com::sun::star::uno::Any;
      40             : using ::com::sun::star::uno::Reference;
      41             : using ::com::sun::star::uno::Sequence;
      42             : using ::com::sun::star::beans::Property;
      43             : 
      44             : namespace chart
      45             : {
      46             : namespace wrapper
      47             : {
      48             : 
      49             : namespace
      50             : {
      51             : 
      52        1789 : Any lcl_getRegressionDefault()
      53             : {
      54        1789 :     Any aRet;
      55        1789 :     aRet <<= ::com::sun::star::chart::ChartRegressionCurveType_NONE;
      56        1789 :     return aRet;
      57             : }
      58             : 
      59           0 : ::com::sun::star::chart::ChartRegressionCurveType lcl_getRegressionCurveType(SvxChartRegress eRegressionType)
      60             : {
      61           0 :     ::com::sun::star::chart::ChartRegressionCurveType eRet = ::com::sun::star::chart::ChartRegressionCurveType_NONE;
      62           0 :     switch(eRegressionType)
      63             :     {
      64             :         case CHREGRESS_LINEAR:
      65           0 :             eRet = ::com::sun::star::chart::ChartRegressionCurveType_LINEAR;
      66           0 :             break;
      67             :         case CHREGRESS_LOG:
      68           0 :             eRet = ::com::sun::star::chart::ChartRegressionCurveType_LOGARITHM;
      69           0 :             break;
      70             :         case CHREGRESS_EXP:
      71           0 :             eRet = ::com::sun::star::chart::ChartRegressionCurveType_EXPONENTIAL;
      72           0 :             break;
      73             :         case CHREGRESS_POWER:
      74           0 :             eRet = ::com::sun::star::chart::ChartRegressionCurveType_POWER;
      75           0 :             break;
      76             :         case CHREGRESS_POLYNOMIAL:
      77           0 :             eRet = ::com::sun::star::chart::ChartRegressionCurveType_POLYNOMIAL;
      78           0 :             break;
      79             :         /*case CHREGRESS_MOVING_AVERAGE:
      80             :             eRet = ::com::sun::star::chart::ChartRegressionCurveType_MOVING_AVERAGE;
      81             :             break;*/
      82             :         default:
      83           0 :             eRet = ::com::sun::star::chart::ChartRegressionCurveType_NONE;
      84           0 :             break;
      85             :     }
      86           0 :     return eRet;
      87             : }
      88             : 
      89           0 : SvxChartRegress lcl_getRegressionType( ::com::sun::star::chart::ChartRegressionCurveType eRegressionCurveType )
      90             : {
      91             :     SvxChartRegress eRet;
      92           0 :     switch (eRegressionCurveType)
      93             :     {
      94             :         case ::com::sun::star::chart::ChartRegressionCurveType_LINEAR:
      95           0 :             eRet = CHREGRESS_LINEAR;
      96           0 :             break;
      97             :         case ::com::sun::star::chart::ChartRegressionCurveType_LOGARITHM:
      98           0 :             eRet = CHREGRESS_LOG;
      99           0 :             break;
     100             :         case ::com::sun::star::chart::ChartRegressionCurveType_EXPONENTIAL:
     101           0 :             eRet = CHREGRESS_EXP;
     102           0 :             break;
     103             :         case ::com::sun::star::chart::ChartRegressionCurveType_POLYNOMIAL:
     104             :         //case ::com::sun::star::chart::ChartRegressionCurveType_MOVING_AVERAGE:
     105             :         case ::com::sun::star::chart::ChartRegressionCurveType_POWER:
     106           0 :             eRet = CHREGRESS_POWER;
     107           0 :             break;
     108             :         default:
     109           0 :             eRet = CHREGRESS_NONE;
     110           0 :             break;
     111             :     }
     112           0 :     return eRet;
     113             : }
     114             : 
     115          71 : sal_Int32 lcl_getErrorBarStyle( const uno::Reference< beans::XPropertySet >& xErrorBarProperties )
     116             : {
     117          71 :     sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
     118          71 :     if(xErrorBarProperties.is())
     119          71 :         xErrorBarProperties->getPropertyValue( "ErrorBarStyle" ) >>= nStyle;
     120          71 :     return nStyle;
     121             : }
     122             : 
     123          28 : uno::Reference< chart2::data::XDataProvider > lcl_getDataProviderFromContact(
     124             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     125             : {
     126          28 :     uno::Reference< chart2::data::XDataProvider > xResult;
     127          28 :     if( spChart2ModelContact.get())
     128             :     {
     129             :         uno::Reference< chart2::XChartDocument > xChartDoc(
     130          28 :             spChart2ModelContact->getChart2Document());
     131          28 :         if( xChartDoc.is())
     132          28 :             xResult.set( xChartDoc->getDataProvider());
     133             :     }
     134          28 :     return xResult;
     135             : }
     136             : 
     137           6 : void lcl_ConvertRangeFromXML(
     138             :     OUString & rInOutRange,
     139             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     140             : {
     141           6 :     if( !rInOutRange.isEmpty())
     142             :     {
     143             :         uno::Reference< chart2::data::XRangeXMLConversion > xConverter(
     144           6 :             lcl_getDataProviderFromContact( spChart2ModelContact ), uno::UNO_QUERY );
     145           6 :         if( xConverter.is())
     146             :         {
     147           6 :             OUString aResult = xConverter->convertRangeFromXML( rInOutRange );
     148           6 :             rInOutRange = aResult;
     149           6 :         }
     150             :     }
     151           6 : }
     152             : 
     153        4824 : void lcl_ConvertRangeToXML(
     154             :     OUString & rInOutRange,
     155             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
     156             : {
     157        4824 :     if( !rInOutRange.isEmpty())
     158             :     {
     159             :         uno::Reference< chart2::data::XRangeXMLConversion > xConverter(
     160          16 :             lcl_getDataProviderFromContact( spChart2ModelContact ), uno::UNO_QUERY );
     161          16 :         if( xConverter.is())
     162             :         {
     163          16 :             OUString aResult = xConverter->convertRangeToXML( rInOutRange );
     164          16 :             rInOutRange = aResult;
     165          16 :         }
     166             :     }
     167        4824 : }
     168             : 
     169             : }//anonymous namespace
     170             : 
     171             : template< typename PROPERTYTYPE >
     172             : class WrappedStatisticProperty : public WrappedSeriesOrDiagramProperty< PROPERTYTYPE >
     173             : {
     174             : public:
     175       25046 :     explicit WrappedStatisticProperty( const OUString& rName, const Any& rDefaulValue
     176             :                               , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact
     177             :                               , tSeriesOrDiagramPropertyType ePropertyType )
     178       25046 :             : WrappedSeriesOrDiagramProperty< PROPERTYTYPE >(rName,rDefaulValue,spChart2ModelContact,ePropertyType)
     179       25046 :     {}
     180       25046 :     virtual ~WrappedStatisticProperty() {};
     181             : 
     182             : protected:
     183          75 :     static uno::Reference< beans::XPropertySet > getOrCreateErrorBarProperties( const Reference< beans::XPropertySet >& xSeriesPropertySet )
     184             :     {
     185          75 :         if(!xSeriesPropertySet.is())
     186           0 :             return 0;
     187          75 :         uno::Reference< beans::XPropertySet > xErrorBarProperties;
     188          75 :         xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties;
     189          75 :         if( !xErrorBarProperties.is() )
     190             :         {
     191             :             // todo: use a valid context
     192          18 :             xErrorBarProperties = ::chart::createErrorBar( uno::Reference< uno::XComponentContext >() );
     193             :             //default in new and old api are different
     194          18 :             xErrorBarProperties->setPropertyValue( "ShowPositiveError" , uno::makeAny(false) );
     195          18 :             xErrorBarProperties->setPropertyValue( "ShowNegativeError" , uno::makeAny(false) );
     196          18 :             xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::makeAny(::com::sun::star::chart::ErrorBarStyle::NONE) );
     197          18 :             xSeriesPropertySet->setPropertyValue( CHART_UNONAME_ERRORBAR_Y , uno::makeAny( xErrorBarProperties ) );
     198             :         }
     199          75 :         return xErrorBarProperties;
     200             :     }
     201             : 
     202             : };
     203             : 
     204             : //PROP_CHART_STATISTIC_CONST_ERROR_LOW
     205             : class WrappedConstantErrorLowProperty : public WrappedStatisticProperty< double >
     206             : {
     207             : public:
     208             :     virtual double getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const SAL_OVERRIDE;
     209             :     virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const SAL_OVERRIDE;
     210             : 
     211             :     explicit WrappedConstantErrorLowProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     212             :                                               tSeriesOrDiagramPropertyType ePropertyType );
     213             :     virtual ~WrappedConstantErrorLowProperty();
     214             : 
     215             : private:
     216             :     mutable Any m_aOuterValue;
     217             : };
     218             : 
     219        1789 : WrappedConstantErrorLowProperty::WrappedConstantErrorLowProperty(
     220             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     221             :     tSeriesOrDiagramPropertyType ePropertyType )
     222             :         : WrappedStatisticProperty< double >( "ConstantErrorLow"
     223        1789 :             , uno::makeAny( double(0.0) ), spChart2ModelContact, ePropertyType  )
     224             : {
     225        1789 : }
     226        3578 : WrappedConstantErrorLowProperty::~WrappedConstantErrorLowProperty()
     227             : {
     228        3578 : }
     229             : 
     230           9 : double WrappedConstantErrorLowProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
     231             : {
     232           9 :     double aRet = 0.0;
     233           9 :     m_aDefaultValue >>= aRet;
     234           9 :     uno::Reference< beans::XPropertySet > xErrorBarProperties;
     235           9 :     if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
     236             :     {
     237           3 :         if( ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE == lcl_getErrorBarStyle( xErrorBarProperties ) )
     238           0 :             xErrorBarProperties->getPropertyValue( "NegativeError" ) >>= aRet;
     239             :         else
     240           3 :             m_aOuterValue >>= aRet;
     241             :     }
     242           9 :     return aRet;
     243             : }
     244             : 
     245           3 : void WrappedConstantErrorLowProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const
     246             : {
     247           3 :     uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
     248           3 :     if( xErrorBarProperties.is() )
     249             :     {
     250           3 :         m_aOuterValue = uno::makeAny( aNewValue );
     251           3 :         if( ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE == lcl_getErrorBarStyle( xErrorBarProperties ) )
     252             :         {
     253           0 :             xErrorBarProperties->setPropertyValue( "NegativeError", m_aOuterValue );
     254             :         }
     255           3 :     }
     256           3 : }
     257             : 
     258             : //PROP_CHART_STATISTIC_CONST_ERROR_HIGH
     259             : class WrappedConstantErrorHighProperty : public WrappedStatisticProperty< double >
     260             : {
     261             : public:
     262             :     virtual double getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const SAL_OVERRIDE;
     263             :     virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const SAL_OVERRIDE;
     264             : 
     265             :     explicit WrappedConstantErrorHighProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     266             :                                                tSeriesOrDiagramPropertyType ePropertyType );
     267             :     virtual ~WrappedConstantErrorHighProperty();
     268             : 
     269             : private:
     270             :     mutable Any m_aOuterValue;
     271             : };
     272             : 
     273        1789 : WrappedConstantErrorHighProperty::WrappedConstantErrorHighProperty(
     274             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     275             :     tSeriesOrDiagramPropertyType ePropertyType )
     276             :         : WrappedStatisticProperty< double >( "ConstantErrorHigh"
     277        1789 :             , uno::makeAny( double(0.0) ), spChart2ModelContact, ePropertyType  )
     278             : {
     279        1789 : }
     280        3578 : WrappedConstantErrorHighProperty::~WrappedConstantErrorHighProperty()
     281             : {
     282        3578 : }
     283             : 
     284           9 : double WrappedConstantErrorHighProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
     285             : {
     286           9 :     double aRet = 0.0;
     287           9 :     m_aDefaultValue >>= aRet;
     288           9 :     uno::Reference< beans::XPropertySet > xErrorBarProperties;
     289           9 :     if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
     290             :     {
     291           9 :         if( ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE == lcl_getErrorBarStyle( xErrorBarProperties ) )
     292           0 :             xErrorBarProperties->getPropertyValue( "PositiveError" ) >>= aRet;
     293             :         else
     294           9 :             m_aOuterValue >>= aRet;
     295             :     }
     296           9 :     return aRet;
     297             : }
     298             : 
     299           3 : void WrappedConstantErrorHighProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const
     300             : {
     301           3 :     uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
     302           3 :     if( xErrorBarProperties.is() )
     303             :     {
     304           3 :         m_aOuterValue = uno::makeAny( aNewValue );
     305           3 :         if( ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE == lcl_getErrorBarStyle( xErrorBarProperties ) )
     306             :         {
     307           0 :             xErrorBarProperties->setPropertyValue( "PositiveError" , m_aOuterValue );
     308             :         }
     309           3 :     }
     310           3 : }
     311             : 
     312             : //PROP_CHART_STATISTIC_MEAN_VALUE
     313             : class WrappedMeanValueProperty : public WrappedStatisticProperty< sal_Bool >
     314             : {
     315             : public:
     316             :     virtual sal_Bool getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const SAL_OVERRIDE;
     317             :     virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Bool& aNewValue ) const SAL_OVERRIDE;
     318             : 
     319             :     explicit WrappedMeanValueProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     320             :                                        tSeriesOrDiagramPropertyType ePropertyType );
     321             :     virtual ~WrappedMeanValueProperty();
     322             : };
     323             : 
     324        1789 : WrappedMeanValueProperty::WrappedMeanValueProperty(
     325             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     326             :     tSeriesOrDiagramPropertyType ePropertyType )
     327        1789 :         : WrappedStatisticProperty< sal_Bool >( "MeanValue", uno::makeAny( sal_False ), spChart2ModelContact, ePropertyType  )
     328             : {
     329        1789 : }
     330        3578 : WrappedMeanValueProperty::~WrappedMeanValueProperty()
     331             : {
     332        3578 : }
     333             : 
     334        3615 : sal_Bool WrappedMeanValueProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
     335             : {
     336        3615 :     bool bRet = false;
     337        3615 :     uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY );
     338        3615 :     if( xRegCnt.is() )
     339        3615 :         bRet = RegressionCurveHelper::hasMeanValueLine( xRegCnt );
     340        3615 :     return bRet;
     341             : }
     342             : 
     343         175 : void WrappedMeanValueProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Bool& aNewValue ) const
     344             : {
     345         175 :     uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY );
     346         175 :     if( xRegCnt.is() )
     347             :     {
     348         175 :         if(aNewValue)
     349           4 :             RegressionCurveHelper::addMeanValueLine( xRegCnt, 0, 0 );
     350             :         else
     351         171 :             RegressionCurveHelper::removeMeanValueLine( xRegCnt );
     352         175 :     }
     353         175 : }
     354             : 
     355             : //PROP_CHART_STATISTIC_ERROR_CATEGORY
     356             : // deprecated, replaced by ErrorBarStyle
     357             : class WrappedErrorCategoryProperty : public WrappedStatisticProperty< ::com::sun::star::chart::ChartErrorCategory >
     358             : {
     359             : public:
     360             :     virtual ::com::sun::star::chart::ChartErrorCategory getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const SAL_OVERRIDE;
     361             :     virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const ::com::sun::star::chart::ChartErrorCategory& aNewValue ) const SAL_OVERRIDE;
     362             : 
     363             :     explicit WrappedErrorCategoryProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     364             :                                            tSeriesOrDiagramPropertyType ePropertyType );
     365             :     virtual ~WrappedErrorCategoryProperty();
     366             : };
     367             : 
     368        1789 : WrappedErrorCategoryProperty::WrappedErrorCategoryProperty(
     369             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     370             :     tSeriesOrDiagramPropertyType ePropertyType )
     371             :         : WrappedStatisticProperty< ::com::sun::star::chart::ChartErrorCategory >( "ErrorCategory"
     372        1789 :             , uno::makeAny( ::com::sun::star::chart::ChartErrorCategory_NONE ), spChart2ModelContact, ePropertyType  )
     373             : {
     374        1789 : }
     375        3578 : WrappedErrorCategoryProperty::~WrappedErrorCategoryProperty()
     376             : {
     377        3578 : }
     378             : 
     379           9 : ::com::sun::star::chart::ChartErrorCategory WrappedErrorCategoryProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
     380             : {
     381           9 :     ::com::sun::star::chart::ChartErrorCategory aRet = ::com::sun::star::chart::ChartErrorCategory_NONE;
     382           9 :     m_aDefaultValue >>= aRet;
     383           9 :     uno::Reference< beans::XPropertySet > xErrorBarProperties;
     384           9 :     if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
     385             :     {
     386           9 :         sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
     387           9 :         xErrorBarProperties->getPropertyValue( "ErrorBarStyle" ) >>= nStyle;
     388           9 :         switch(nStyle)
     389             :         {
     390             :             case ::com::sun::star::chart::ErrorBarStyle::NONE:
     391           6 :                 aRet = ::com::sun::star::chart::ChartErrorCategory_NONE;
     392           6 :                 break;
     393             :             case ::com::sun::star::chart::ErrorBarStyle::VARIANCE:
     394           0 :                 aRet = ::com::sun::star::chart::ChartErrorCategory_VARIANCE;
     395           0 :                 break;
     396             :             case ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION:
     397           0 :                 aRet = ::com::sun::star::chart::ChartErrorCategory_STANDARD_DEVIATION;
     398           0 :                 break;
     399             :             case ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE:
     400           0 :                 aRet = ::com::sun::star::chart::ChartErrorCategory_CONSTANT_VALUE;
     401           0 :                 break;
     402             :             case ::com::sun::star::chart::ErrorBarStyle::RELATIVE:
     403           3 :                 aRet = ::com::sun::star::chart::ChartErrorCategory_PERCENT;
     404           3 :                 break;
     405             :             case ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN:
     406           0 :                 aRet = ::com::sun::star::chart::ChartErrorCategory_ERROR_MARGIN;
     407           0 :                 break;
     408             :             case ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR:
     409           0 :                 break;
     410             :             case ::com::sun::star::chart::ErrorBarStyle::FROM_DATA:
     411           0 :                 break;
     412             :             default:
     413           0 :                 break;
     414             :         }
     415             :     }
     416           9 :     return aRet;
     417             : }
     418           3 : void WrappedErrorCategoryProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const ::com::sun::star::chart::ChartErrorCategory& aNewValue ) const
     419             : {
     420           3 :     if( !xSeriesPropertySet.is() )
     421           3 :         return;
     422             : 
     423           3 :     uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
     424           3 :     if( xErrorBarProperties.is() )
     425             :     {
     426           3 :         sal_Int32 nNewStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
     427           3 :         switch(aNewValue)
     428             :         {
     429             :             case ::com::sun::star::chart::ChartErrorCategory_NONE:
     430           0 :                 nNewStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
     431           0 :                 break;
     432             :             case ::com::sun::star::chart::ChartErrorCategory_VARIANCE:
     433           0 :                 nNewStyle = ::com::sun::star::chart::ErrorBarStyle::VARIANCE;
     434           0 :                 break;
     435             :             case ::com::sun::star::chart::ChartErrorCategory_STANDARD_DEVIATION:
     436           0 :                 nNewStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION;
     437           0 :                 break;
     438             :             case ::com::sun::star::chart::ChartErrorCategory_CONSTANT_VALUE:
     439           0 :                 nNewStyle = ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE;
     440           0 :                 break;
     441             :             case ::com::sun::star::chart::ChartErrorCategory_PERCENT:
     442           3 :                 nNewStyle = ::com::sun::star::chart::ErrorBarStyle::RELATIVE;
     443           3 :                 break;
     444             :             case ::com::sun::star::chart::ChartErrorCategory_ERROR_MARGIN:
     445           0 :                 nNewStyle = ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN;
     446           0 :                 break;
     447             :             default:
     448           0 :                 break;
     449             :         }
     450           3 :         xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::makeAny(nNewStyle) );
     451           3 :     }
     452             : }
     453             : 
     454             : //PROP_CHART_STATISTIC_PERCENT_ERROR
     455             : class WrappedPercentageErrorProperty : public WrappedStatisticProperty< double >
     456             : {
     457             : public:
     458             :     virtual double getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const SAL_OVERRIDE;
     459             :     virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const SAL_OVERRIDE;
     460             : 
     461             :     explicit WrappedPercentageErrorProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     462             :                                              tSeriesOrDiagramPropertyType ePropertyType );
     463             :     virtual ~WrappedPercentageErrorProperty();
     464             : 
     465             : private:
     466             :     mutable Any m_aOuterValue;
     467             : };
     468             : 
     469        1789 : WrappedPercentageErrorProperty::WrappedPercentageErrorProperty(
     470             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     471             :     tSeriesOrDiagramPropertyType ePropertyType )
     472             :         : WrappedStatisticProperty< double >( "PercentageError"
     473        1789 :             , uno::makeAny( double(0.0) ), spChart2ModelContact, ePropertyType  )
     474             : {
     475        1789 : }
     476        3578 : WrappedPercentageErrorProperty::~WrappedPercentageErrorProperty()
     477             : {
     478        3578 : }
     479             : 
     480        2417 : double WrappedPercentageErrorProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
     481             : {
     482        2417 :     double aRet = 0.0;
     483        2417 :     m_aDefaultValue >>= aRet;
     484        2417 :     uno::Reference< beans::XPropertySet > xErrorBarProperties;
     485        2417 :     if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
     486             :     {
     487          13 :         if( ::com::sun::star::chart::ErrorBarStyle::RELATIVE == lcl_getErrorBarStyle( xErrorBarProperties ) )
     488           9 :             xErrorBarProperties->getPropertyValue( "PositiveError" ) >>= aRet;
     489             :         else
     490           4 :             m_aOuterValue >>= aRet;
     491             :     }
     492        2417 :     return aRet;
     493             : }
     494          15 : void WrappedPercentageErrorProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const
     495             : {
     496          15 :     uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
     497          15 :     if( xErrorBarProperties.is() )
     498             :     {
     499          15 :         m_aOuterValue = uno::makeAny( aNewValue );
     500          15 :         if( ::com::sun::star::chart::ErrorBarStyle::RELATIVE == lcl_getErrorBarStyle( xErrorBarProperties ) )
     501             :         {
     502           6 :             xErrorBarProperties->setPropertyValue( "PositiveError" , m_aOuterValue );
     503           6 :             xErrorBarProperties->setPropertyValue( "NegativeError" , m_aOuterValue );
     504             :         }
     505          15 :     }
     506          15 : }
     507             : 
     508             : //PROP_CHART_STATISTIC_ERROR_MARGIN
     509             : class WrappedErrorMarginProperty : public WrappedStatisticProperty< double >
     510             : {
     511             : public:
     512             :     virtual double getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const SAL_OVERRIDE;
     513             :     virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const SAL_OVERRIDE;
     514             : 
     515             :     explicit WrappedErrorMarginProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     516             :                                          tSeriesOrDiagramPropertyType ePropertyType );
     517             :     virtual ~WrappedErrorMarginProperty();
     518             : 
     519             : private:
     520             :     mutable Any m_aOuterValue;
     521             : };
     522             : 
     523        1789 : WrappedErrorMarginProperty::WrappedErrorMarginProperty(
     524             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     525             :     tSeriesOrDiagramPropertyType ePropertyType )
     526             :         : WrappedStatisticProperty< double >( "ErrorMargin"
     527        1789 :             , uno::makeAny( double(0.0) ), spChart2ModelContact, ePropertyType  )
     528             : {
     529        1789 : }
     530        3578 : WrappedErrorMarginProperty::~WrappedErrorMarginProperty()
     531             : {
     532        3578 : }
     533             : 
     534        2417 : double WrappedErrorMarginProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
     535             : {
     536        2417 :     double aRet = 0.0;
     537        2417 :     m_aDefaultValue >>= aRet;
     538        2417 :     uno::Reference< beans::XPropertySet > xErrorBarProperties;
     539        2417 :     if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
     540             :     {
     541          13 :         if( ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN == lcl_getErrorBarStyle( xErrorBarProperties ) )
     542           0 :             xErrorBarProperties->getPropertyValue( "PositiveError" ) >>= aRet;
     543             :         else
     544          13 :             m_aOuterValue >>= aRet;
     545             :     }
     546        2417 :     return aRet;
     547             : }
     548          12 : void WrappedErrorMarginProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const
     549             : {
     550          12 :     uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
     551          12 :     if( xErrorBarProperties.is() )
     552             :     {
     553          12 :         m_aOuterValue = uno::makeAny( aNewValue );
     554          12 :         if( ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN == lcl_getErrorBarStyle( xErrorBarProperties ) )
     555             :         {
     556           0 :             xErrorBarProperties->setPropertyValue( "PositiveError" , m_aOuterValue );
     557           0 :             xErrorBarProperties->setPropertyValue( "NegativeError" , m_aOuterValue );
     558             :         }
     559          12 :     }
     560          12 : }
     561             : 
     562             : //PROP_CHART_STATISTIC_ERROR_INDICATOR
     563             : class WrappedErrorIndicatorProperty : public WrappedStatisticProperty< ::com::sun::star::chart::ChartErrorIndicatorType >
     564             : {
     565             : public:
     566             :     virtual ::com::sun::star::chart::ChartErrorIndicatorType getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const SAL_OVERRIDE;
     567             :     virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const ::com::sun::star::chart::ChartErrorIndicatorType& aNewValue ) const SAL_OVERRIDE;
     568             : 
     569             :     explicit WrappedErrorIndicatorProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     570             :                                             tSeriesOrDiagramPropertyType ePropertyType );
     571             :     virtual ~WrappedErrorIndicatorProperty();
     572             : };
     573             : 
     574        1789 : WrappedErrorIndicatorProperty::WrappedErrorIndicatorProperty(
     575             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     576             :     tSeriesOrDiagramPropertyType ePropertyType )
     577             :         : WrappedStatisticProperty< ::com::sun::star::chart::ChartErrorIndicatorType >( "ErrorIndicator"
     578        1789 :             , uno::makeAny( ::com::sun::star::chart::ChartErrorIndicatorType_NONE ), spChart2ModelContact, ePropertyType  )
     579             : {
     580        1789 : }
     581        3578 : WrappedErrorIndicatorProperty::~WrappedErrorIndicatorProperty()
     582             : {
     583        3578 : }
     584             : 
     585           9 : ::com::sun::star::chart::ChartErrorIndicatorType WrappedErrorIndicatorProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
     586             : {
     587           9 :     ::com::sun::star::chart::ChartErrorIndicatorType aRet = ::com::sun::star::chart::ChartErrorIndicatorType_NONE;
     588           9 :     m_aDefaultValue >>= aRet;
     589           9 :     uno::Reference< beans::XPropertySet > xErrorBarProperties;
     590           9 :     if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
     591             :     {
     592           9 :         bool bPositive = false;
     593           9 :         bool bNegative = false;
     594           9 :         xErrorBarProperties->getPropertyValue( "ShowPositiveError" ) >>= bPositive;
     595           9 :         xErrorBarProperties->getPropertyValue( "ShowNegativeError" ) >>= bNegative;
     596             : 
     597           9 :         if( bPositive && bNegative )
     598           3 :             aRet = ::com::sun::star::chart::ChartErrorIndicatorType_TOP_AND_BOTTOM;
     599           6 :         else if( bPositive && !bNegative )
     600           0 :             aRet = ::com::sun::star::chart::ChartErrorIndicatorType_UPPER;
     601           6 :         else if( !bPositive && bNegative )
     602           0 :             aRet = ::com::sun::star::chart::ChartErrorIndicatorType_LOWER;
     603             :     }
     604           9 :     return aRet;
     605             : }
     606           3 : void WrappedErrorIndicatorProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const ::com::sun::star::chart::ChartErrorIndicatorType& aNewValue ) const
     607             : {
     608           3 :     uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
     609           3 :     if( xErrorBarProperties.is() )
     610             :     {
     611           3 :         bool bPositive = false;
     612           3 :         bool bNegative = false;
     613           3 :         switch( aNewValue )
     614             :         {
     615             :             case ::com::sun::star::chart::ChartErrorIndicatorType_TOP_AND_BOTTOM:
     616           3 :                 bPositive = true;
     617           3 :                 bNegative = true;
     618           3 :                 break;
     619             :             case ::com::sun::star::chart::ChartErrorIndicatorType_UPPER:
     620           0 :                 bPositive = true;
     621           0 :                 break;
     622             :             case ::com::sun::star::chart::ChartErrorIndicatorType_LOWER:
     623           0 :                 bNegative = true;
     624           0 :                 break;
     625             :             default:
     626           0 :                 break;
     627             :         }
     628             : 
     629           3 :         xErrorBarProperties->setPropertyValue( "ShowPositiveError" , uno::makeAny(bPositive) );
     630           3 :         xErrorBarProperties->setPropertyValue( "ShowNegativeError" , uno::makeAny(bNegative) );
     631           3 :     }
     632           3 : }
     633             : 
     634             : //PROP_CHART_STATISTIC_ERROR_BAR_STYLE
     635             : // this is the new constant group that replaces the deprecated enum ChartErrorCategory
     636             : class WrappedErrorBarStyleProperty : public WrappedStatisticProperty< sal_Int32 >
     637             : {
     638             : public:
     639             :     virtual sal_Int32 getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const SAL_OVERRIDE;
     640             :     virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& nNewValue ) const SAL_OVERRIDE;
     641             : 
     642             :     explicit WrappedErrorBarStyleProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact1,
     643             :                                            tSeriesOrDiagramPropertyType ePropertyType );
     644             :     virtual ~WrappedErrorBarStyleProperty();
     645             : };
     646             : 
     647        1789 : WrappedErrorBarStyleProperty::WrappedErrorBarStyleProperty(
     648             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     649             :     tSeriesOrDiagramPropertyType ePropertyType )
     650             :         : WrappedStatisticProperty< sal_Int32 >( "ErrorBarStyle"
     651        1789 :             , uno::makeAny( ::com::sun::star::chart::ErrorBarStyle::NONE ), spChart2ModelContact, ePropertyType  )
     652             : {
     653        1789 : }
     654        3578 : WrappedErrorBarStyleProperty::~WrappedErrorBarStyleProperty()
     655             : {
     656        3578 : }
     657             : 
     658        2412 : sal_Int32 WrappedErrorBarStyleProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
     659             : {
     660        2412 :     sal_Int32 nRet = ::com::sun::star::chart::ErrorBarStyle::NONE;
     661        2412 :     m_aDefaultValue >>= nRet;
     662        2412 :     uno::Reference< beans::XPropertySet > xErrorBarProperties;
     663        2412 :     if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
     664             :     {
     665           8 :         xErrorBarProperties->getPropertyValue( "ErrorBarStyle" ) >>= nRet;
     666             :     }
     667        2412 :     return nRet;
     668             : }
     669          30 : void WrappedErrorBarStyleProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& nNewValue ) const
     670             : {
     671          30 :     if( !xSeriesPropertySet.is() )
     672          30 :         return;
     673             : 
     674          30 :     uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
     675          30 :     if( xErrorBarProperties.is() )
     676             :     {
     677          30 :         xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::makeAny( nNewValue ));
     678          30 :     }
     679             : }
     680             : 
     681             : //PROP_CHART_STATISTIC_ERROR_RANGE_POSITIVE
     682             : class WrappedErrorBarRangePositiveProperty : public WrappedStatisticProperty< OUString >
     683             : {
     684             : public:
     685             :     virtual OUString getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const SAL_OVERRIDE;
     686             :     virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewValue ) const SAL_OVERRIDE;
     687             : 
     688             :     explicit WrappedErrorBarRangePositiveProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     689             :                                                    tSeriesOrDiagramPropertyType ePropertyType );
     690             :     virtual ~WrappedErrorBarRangePositiveProperty();
     691             : 
     692             : private:
     693             :     mutable Any m_aOuterValue;
     694             : };
     695             : 
     696        1789 : WrappedErrorBarRangePositiveProperty::WrappedErrorBarRangePositiveProperty(
     697             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     698             :     tSeriesOrDiagramPropertyType ePropertyType )
     699             :         : WrappedStatisticProperty< OUString >( "ErrorBarRangePositive"
     700        1789 :             , uno::makeAny( OUString() ), spChart2ModelContact, ePropertyType  )
     701             : {
     702        1789 : }
     703        3578 : WrappedErrorBarRangePositiveProperty::~WrappedErrorBarRangePositiveProperty()
     704             : {
     705        3578 : }
     706             : 
     707        2412 : OUString WrappedErrorBarRangePositiveProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
     708             : {
     709        2412 :     OUString aRet;
     710        2412 :     m_aDefaultValue >>= aRet;
     711        4824 :     uno::Reference< chart2::data::XDataSource > xErrorBarDataSource;
     712       12060 :     if( xSeriesPropertySet.is() &&
     713       14472 :         ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarDataSource ) &&
     714        2412 :         xErrorBarDataSource.is())
     715             :     {
     716             :         uno::Reference< chart2::data::XDataSequence > xSeq(
     717             :             StatisticsHelper::getErrorDataSequenceFromDataSource(
     718           8 :                 xErrorBarDataSource, true /* positive */, true /* y-error */ ));
     719           8 :         if( xSeq.is())
     720           8 :             aRet = xSeq->getSourceRangeRepresentation();
     721             :         else
     722           0 :             m_aOuterValue >>= aRet;
     723             :     }
     724        2412 :     lcl_ConvertRangeToXML( aRet, m_spChart2ModelContact );
     725        4824 :     return aRet;
     726             : }
     727             : 
     728           3 : void WrappedErrorBarRangePositiveProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewValue ) const
     729             : {
     730           3 :     uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
     731           3 :     if( xErrorBarProperties.is() )
     732             :     {
     733             :         uno::Reference< chart2::data::XDataProvider > xDataProvider(
     734           3 :             lcl_getDataProviderFromContact( m_spChart2ModelContact ));
     735           6 :         uno::Reference< chart2::data::XDataSource > xDataSource( xErrorBarProperties, uno::UNO_QUERY );
     736           3 :         if( xDataSource.is() && xDataProvider.is())
     737             :         {
     738           3 :             OUString aTmp( aNewValue );
     739           6 :             OUString aXMLRange( aNewValue );
     740           3 :             lcl_ConvertRangeFromXML( aTmp, m_spChart2ModelContact );
     741             :             StatisticsHelper::setErrorDataSequence(
     742           3 :                 xDataSource, xDataProvider, aTmp, true /* positive */, true /* y-error */, &aXMLRange );
     743           6 :             m_aOuterValue <<= aTmp;
     744           3 :         }
     745           3 :     }
     746           3 : }
     747             : 
     748             : //PROP_CHART_STATISTIC_ERROR_RANGE_NEGATIVE
     749             : class WrappedErrorBarRangeNegativeProperty : public WrappedStatisticProperty< OUString >
     750             : {
     751             : public:
     752             :     virtual OUString getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const SAL_OVERRIDE;
     753             :     virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewValue ) const SAL_OVERRIDE;
     754             : 
     755             :     explicit WrappedErrorBarRangeNegativeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     756             :                                                    tSeriesOrDiagramPropertyType ePropertyType );
     757             :     virtual ~WrappedErrorBarRangeNegativeProperty();
     758             : 
     759             : private:
     760             :     mutable Any m_aOuterValue;
     761             : };
     762             : 
     763        1789 : WrappedErrorBarRangeNegativeProperty::WrappedErrorBarRangeNegativeProperty(
     764             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     765             :     tSeriesOrDiagramPropertyType ePropertyType )
     766             :         : WrappedStatisticProperty< OUString >( "ErrorBarRangeNegative"
     767        1789 :             , uno::makeAny( OUString() ), spChart2ModelContact, ePropertyType  )
     768             : {
     769        1789 : }
     770        3578 : WrappedErrorBarRangeNegativeProperty::~WrappedErrorBarRangeNegativeProperty()
     771             : {
     772        3578 : }
     773             : 
     774        2412 : OUString WrappedErrorBarRangeNegativeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
     775             : {
     776        2412 :     OUString aRet;
     777        2412 :     m_aDefaultValue >>= aRet;
     778        4824 :     uno::Reference< chart2::data::XDataSource > xErrorBarDataSource;
     779       12060 :     if( xSeriesPropertySet.is() &&
     780       14472 :         ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarDataSource ) &&
     781        2412 :         xErrorBarDataSource.is())
     782             :     {
     783             :         uno::Reference< chart2::data::XDataSequence > xSeq(
     784             :             StatisticsHelper::getErrorDataSequenceFromDataSource(
     785           8 :                 xErrorBarDataSource, false /* positive */, true /* y-error */ ));
     786           8 :         if( xSeq.is())
     787           8 :             aRet = xSeq->getSourceRangeRepresentation();
     788             :         else
     789           0 :             m_aOuterValue >>= aRet;
     790             :     }
     791        2412 :     lcl_ConvertRangeToXML( aRet, m_spChart2ModelContact );
     792        4824 :     return aRet;
     793             : }
     794             : 
     795           3 : void WrappedErrorBarRangeNegativeProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewValue ) const
     796             : {
     797           3 :     uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
     798           3 :     if( xErrorBarProperties.is() )
     799             :     {
     800             :         uno::Reference< chart2::data::XDataProvider > xDataProvider(
     801           3 :             lcl_getDataProviderFromContact( m_spChart2ModelContact ));
     802           6 :         uno::Reference< chart2::data::XDataSource > xDataSource( xErrorBarProperties, uno::UNO_QUERY );
     803           3 :         if( xDataSource.is() && xDataProvider.is())
     804             :         {
     805           3 :             OUString aTmp( aNewValue );
     806           6 :             OUString aXMLRange( aNewValue );
     807           3 :             lcl_ConvertRangeFromXML( aTmp, m_spChart2ModelContact );
     808             :             StatisticsHelper::setErrorDataSequence(
     809           3 :                 xDataSource, xDataProvider, aTmp, false /* positive */, true /* y-error */, &aXMLRange );
     810           6 :             m_aOuterValue <<= aTmp;
     811           3 :         }
     812           3 :     }
     813           3 : }
     814             : 
     815             : //PROP_CHART_STATISTIC_REGRESSION_CURVES
     816             : class WrappedRegressionCurvesProperty : public WrappedStatisticProperty< ::com::sun::star::chart::ChartRegressionCurveType >
     817             : {
     818             : public:
     819             :     virtual ::com::sun::star::chart::ChartRegressionCurveType getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const SAL_OVERRIDE;
     820             :     virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const ::com::sun::star::chart::ChartRegressionCurveType & aNewValue ) const SAL_OVERRIDE;
     821             : 
     822             :     explicit WrappedRegressionCurvesProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     823             :                                               tSeriesOrDiagramPropertyType ePropertyType );
     824             :     virtual ~WrappedRegressionCurvesProperty();
     825             : };
     826             : 
     827        1789 : WrappedRegressionCurvesProperty::WrappedRegressionCurvesProperty(
     828             :     ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     829             :     tSeriesOrDiagramPropertyType ePropertyType )
     830             :         : WrappedStatisticProperty< ::com::sun::star::chart::ChartRegressionCurveType >( "RegressionCurves"
     831        1789 :         , lcl_getRegressionDefault(), spChart2ModelContact, ePropertyType  )
     832             : {
     833        1789 : }
     834             : 
     835        3578 : WrappedRegressionCurvesProperty::~WrappedRegressionCurvesProperty()
     836             : {
     837        3578 : }
     838             : 
     839           0 : ::com::sun::star::chart::ChartRegressionCurveType WrappedRegressionCurvesProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
     840             : {
     841             :     ::com::sun::star::chart::ChartRegressionCurveType aRet;
     842           0 :     m_aDefaultValue >>= aRet;
     843           0 :     uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY );
     844           0 :     if( xRegCnt.is() )
     845             :     {
     846             :         aRet = lcl_getRegressionCurveType(
     847           0 :             RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( xRegCnt ) );
     848             :     }
     849           0 :     return aRet;
     850             : }
     851         162 : void WrappedRegressionCurvesProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const ::com::sun::star::chart::ChartRegressionCurveType& aNewValue ) const
     852             : {
     853         162 :     uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( xSeriesPropertySet, uno::UNO_QUERY );
     854         324 :     uno::Reference< chart2::XRegressionCurve > xRegressionCurve( xSeriesPropertySet, uno::UNO_QUERY );
     855             : 
     856         162 :     if( xRegressionCurveContainer.is() && xRegressionCurve.is() )
     857             :     {
     858           0 :         SvxChartRegress eNewRegressionType = lcl_getRegressionType( aNewValue );
     859             : 
     860             :         RegressionCurveHelper::changeRegressionCurveType(
     861             :                         eNewRegressionType,
     862             :                         xRegressionCurveContainer,
     863             :                         xRegressionCurve,
     864           0 :                         uno::Reference< uno::XComponentContext >());
     865         162 :     }
     866         162 : }
     867             : 
     868             : //PROP_CHART_STATISTIC_REGRESSION_PROPERTIES
     869             : //PROP_CHART_STATISTIC_ERROR_PROPERTIES
     870             : //PROP_CHART_STATISTIC_MEAN_VALUE_PROPERTIES
     871             : class WrappedStatisticPropertySetProperty : public WrappedStatisticProperty< Reference< beans::XPropertySet > >
     872             : {
     873             : public:
     874             :     virtual Reference< beans::XPropertySet > getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const SAL_OVERRIDE;
     875             :     // properties are read-only, so this method should never be called
     876             :     virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const Reference< beans::XPropertySet > & xNewValue ) const SAL_OVERRIDE;
     877             : 
     878             :     enum PropertySetType
     879             :     {
     880             :         PROPERTY_SET_TYPE_REGRESSION,
     881             :         PROPERTY_SET_TYPE_ERROR_BAR,
     882             :         PROPERTY_SET_TYPE_MEAN_VALUE
     883             :     };
     884             : 
     885             :     explicit WrappedStatisticPropertySetProperty(
     886             :         PropertySetType ePropertySetType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
     887             :         tSeriesOrDiagramPropertyType ePropertyType );
     888             :     virtual ~WrappedStatisticPropertySetProperty();
     889             : 
     890             : private:
     891             :     PropertySetType m_eType;
     892             : };
     893             : 
     894        5367 : WrappedStatisticPropertySetProperty::WrappedStatisticPropertySetProperty(
     895             :     PropertySetType ePropertySetType
     896             :     , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact
     897             :     , tSeriesOrDiagramPropertyType ePropertyType )
     898             :         : WrappedStatisticProperty< Reference< beans::XPropertySet > >(
     899             :             (ePropertySetType == PROPERTY_SET_TYPE_REGRESSION)
     900             :             ? OUString("DataRegressionProperties")
     901             :             : (ePropertySetType == PROPERTY_SET_TYPE_ERROR_BAR)
     902             :               ? OUString("DataErrorProperties")
     903             :               : OUString("DataMeanValueProperties")
     904             :             , uno::Any(), spChart2ModelContact, ePropertyType  )
     905        5367 :         , m_eType( ePropertySetType )
     906             : {
     907        5367 : }
     908       10734 : WrappedStatisticPropertySetProperty::~WrappedStatisticPropertySetProperty()
     909             : {
     910       10734 : }
     911             : 
     912           7 : Reference< beans::XPropertySet > WrappedStatisticPropertySetProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
     913             : {
     914           7 :     Reference< beans::XPropertySet > xResult;
     915          14 :     uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY );
     916             : 
     917           7 :     switch( m_eType )
     918             :     {
     919             :         case PROPERTY_SET_TYPE_REGRESSION:
     920           0 :             if( xRegCnt.is() )
     921           0 :                 xResult.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt ), uno::UNO_QUERY );
     922           0 :             break;
     923             :         case PROPERTY_SET_TYPE_ERROR_BAR:
     924           6 :             if( xSeriesPropertySet.is())
     925           6 :                 xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xResult;
     926           6 :             break;
     927             :         case PROPERTY_SET_TYPE_MEAN_VALUE:
     928           1 :             if( xRegCnt.is() )
     929           1 :                 xResult.set( RegressionCurveHelper::getMeanValueLine( xRegCnt ), uno::UNO_QUERY );
     930           1 :             break;
     931             :     }
     932             : 
     933          14 :     return xResult;
     934             : }
     935             : 
     936           0 : void WrappedStatisticPropertySetProperty::setValueToSeries(
     937             :     const Reference< beans::XPropertySet >& /* xSeriesPropertySet */
     938             :     , const Reference< beans::XPropertySet >& /* xNewValue */ ) const
     939             : {
     940           0 : }
     941             : 
     942             : namespace
     943             : {
     944             : enum
     945             : {
     946             :     //statistic properties
     947             :     PROP_CHART_STATISTIC_CONST_ERROR_LOW = FAST_PROPERTY_ID_START_CHART_STATISTIC_PROP,
     948             :     PROP_CHART_STATISTIC_CONST_ERROR_HIGH,
     949             :     PROP_CHART_STATISTIC_MEAN_VALUE,
     950             :     PROP_CHART_STATISTIC_ERROR_CATEGORY,
     951             :     PROP_CHART_STATISTIC_ERROR_BAR_STYLE,
     952             :     PROP_CHART_STATISTIC_PERCENT_ERROR,
     953             :     PROP_CHART_STATISTIC_ERROR_MARGIN,
     954             :     PROP_CHART_STATISTIC_ERROR_INDICATOR,
     955             :     PROP_CHART_STATISTIC_ERROR_RANGE_POSITIVE,
     956             :     PROP_CHART_STATISTIC_ERROR_RANGE_NEGATIVE,
     957             :     PROP_CHART_STATISTIC_REGRESSION_CURVES,
     958             :     PROP_CHART_STATISTIC_REGRESSION_PROPERTIES,
     959             :     PROP_CHART_STATISTIC_ERROR_PROPERTIES,
     960             :     PROP_CHART_STATISTIC_MEAN_VALUE_PROPERTIES
     961             : };
     962             : 
     963             : /** @parameter bDataSeriesProperty if true, this property is for a single data
     964             :                series, if false, it is for the whole diagram, i.e. for all
     965             :                series
     966             :  */
     967        1789 : void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList
     968             :             , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact
     969             :             , tSeriesOrDiagramPropertyType ePropertyType )
     970             : {
     971        1789 :     rList.push_back( new WrappedConstantErrorLowProperty( spChart2ModelContact, ePropertyType ) );
     972        1789 :     rList.push_back( new WrappedConstantErrorHighProperty( spChart2ModelContact, ePropertyType ) );
     973        1789 :     rList.push_back( new WrappedMeanValueProperty( spChart2ModelContact, ePropertyType ) );
     974        1789 :     rList.push_back( new WrappedErrorCategoryProperty( spChart2ModelContact, ePropertyType ) );
     975        1789 :     rList.push_back( new WrappedErrorBarStyleProperty( spChart2ModelContact, ePropertyType ) );
     976        1789 :     rList.push_back( new WrappedPercentageErrorProperty( spChart2ModelContact, ePropertyType ) );
     977        1789 :     rList.push_back( new WrappedErrorMarginProperty( spChart2ModelContact, ePropertyType ) );
     978        1789 :     rList.push_back( new WrappedErrorIndicatorProperty( spChart2ModelContact, ePropertyType ) );
     979        1789 :     rList.push_back( new WrappedErrorBarRangePositiveProperty( spChart2ModelContact, ePropertyType ) );
     980        1789 :     rList.push_back( new WrappedErrorBarRangeNegativeProperty( spChart2ModelContact, ePropertyType ) );
     981        1789 :     rList.push_back( new WrappedRegressionCurvesProperty( spChart2ModelContact, ePropertyType ) );
     982             :     rList.push_back( new WrappedStatisticPropertySetProperty(
     983        1789 :                          WrappedStatisticPropertySetProperty::PROPERTY_SET_TYPE_REGRESSION, spChart2ModelContact, ePropertyType ) );
     984             :     rList.push_back( new WrappedStatisticPropertySetProperty(
     985        1789 :                          WrappedStatisticPropertySetProperty::PROPERTY_SET_TYPE_ERROR_BAR,  spChart2ModelContact, ePropertyType ) );
     986             :     rList.push_back( new WrappedStatisticPropertySetProperty(
     987        1789 :                          WrappedStatisticPropertySetProperty::PROPERTY_SET_TYPE_MEAN_VALUE, spChart2ModelContact, ePropertyType ) );
     988        1789 : }
     989             : 
     990             : }//anonymous namespace
     991             : 
     992          24 : void WrappedStatisticProperties::addProperties( ::std::vector< Property > & rOutProperties )
     993             : {
     994             :     rOutProperties.push_back(
     995             :         Property( "ConstantErrorLow",
     996             :                   PROP_CHART_STATISTIC_CONST_ERROR_LOW,
     997          24 :                   cppu::UnoType<double>::get(),
     998             :                   beans::PropertyAttribute::BOUND
     999          48 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
    1000             :     rOutProperties.push_back(
    1001             :         Property( "ConstantErrorHigh",
    1002             :                   PROP_CHART_STATISTIC_CONST_ERROR_HIGH,
    1003          24 :                   cppu::UnoType<double>::get(),
    1004             :                   beans::PropertyAttribute::BOUND
    1005          48 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
    1006             :     rOutProperties.push_back(
    1007             :         Property( "MeanValue",
    1008             :                   PROP_CHART_STATISTIC_MEAN_VALUE,
    1009          24 :                   cppu::UnoType<bool>::get(),
    1010             :                   beans::PropertyAttribute::BOUND
    1011          48 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
    1012             :     rOutProperties.push_back(
    1013             :         Property( "ErrorCategory",
    1014             :                   PROP_CHART_STATISTIC_ERROR_CATEGORY,
    1015          24 :                   cppu::UnoType<com::sun::star::chart::ChartErrorCategory>::get(),
    1016             :                   beans::PropertyAttribute::BOUND
    1017          48 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
    1018             :     rOutProperties.push_back(
    1019             :         Property( "ErrorBarStyle",
    1020             :                   PROP_CHART_STATISTIC_ERROR_BAR_STYLE,
    1021          24 :                   cppu::UnoType<sal_Int32>::get(),
    1022             :                   beans::PropertyAttribute::BOUND
    1023          48 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
    1024             :     rOutProperties.push_back(
    1025             :         Property( "PercentageError",
    1026             :                   PROP_CHART_STATISTIC_PERCENT_ERROR,
    1027          24 :                   cppu::UnoType<double>::get(),
    1028             :                   beans::PropertyAttribute::BOUND
    1029          48 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
    1030             :     rOutProperties.push_back(
    1031             :         Property( "ErrorMargin",
    1032             :                   PROP_CHART_STATISTIC_ERROR_MARGIN,
    1033          24 :                   cppu::UnoType<double>::get(),
    1034             :                   beans::PropertyAttribute::BOUND
    1035          48 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
    1036             :     rOutProperties.push_back(
    1037             :         Property( "ErrorIndicator",
    1038             :                   PROP_CHART_STATISTIC_ERROR_INDICATOR,
    1039          24 :                   cppu::UnoType<com::sun::star::chart::ChartErrorIndicatorType>::get(),
    1040             :                   beans::PropertyAttribute::BOUND
    1041          48 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
    1042             :     rOutProperties.push_back(
    1043             :         Property( "ErrorBarRangePositive",
    1044             :                   PROP_CHART_STATISTIC_ERROR_RANGE_POSITIVE,
    1045          24 :                   cppu::UnoType<OUString>::get(),
    1046             :                   beans::PropertyAttribute::BOUND
    1047          48 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
    1048             :     rOutProperties.push_back(
    1049             :         Property( "ErrorBarRangeNegative",
    1050             :                   PROP_CHART_STATISTIC_ERROR_RANGE_NEGATIVE,
    1051          24 :                   cppu::UnoType<OUString>::get(),
    1052             :                   beans::PropertyAttribute::BOUND
    1053          48 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
    1054             :     rOutProperties.push_back(
    1055             :         Property( "RegressionCurves",
    1056             :                   PROP_CHART_STATISTIC_REGRESSION_CURVES,
    1057          24 :                   cppu::UnoType<com::sun::star::chart::ChartRegressionCurveType>::get(),
    1058             :                   beans::PropertyAttribute::BOUND
    1059          48 :                   | beans::PropertyAttribute::MAYBEDEFAULT ));
    1060             : 
    1061             :     rOutProperties.push_back(
    1062             :         Property( "DataRegressionProperties",
    1063             :                   PROP_CHART_STATISTIC_REGRESSION_PROPERTIES,
    1064          24 :                   cppu::UnoType<beans::XPropertySet>::get(),
    1065             :                   beans::PropertyAttribute::BOUND
    1066             :                   | beans::PropertyAttribute::READONLY
    1067          48 :                   | beans::PropertyAttribute::MAYBEVOID ));
    1068             :     rOutProperties.push_back(
    1069             :         Property( "DataErrorProperties",
    1070             :                   PROP_CHART_STATISTIC_ERROR_PROPERTIES,
    1071          24 :                   cppu::UnoType<beans::XPropertySet>::get(),
    1072             :                   beans::PropertyAttribute::BOUND
    1073             :                   | beans::PropertyAttribute::READONLY
    1074          48 :                   | beans::PropertyAttribute::MAYBEVOID ));
    1075             :     rOutProperties.push_back(
    1076             :         Property( "DataMeanValueProperties",
    1077             :                   PROP_CHART_STATISTIC_MEAN_VALUE_PROPERTIES,
    1078          24 :                   cppu::UnoType<beans::XPropertySet>::get(),
    1079             :                   beans::PropertyAttribute::BOUND
    1080             :                   | beans::PropertyAttribute::READONLY
    1081          48 :                   | beans::PropertyAttribute::MAYBEVOID ));
    1082          24 : }
    1083             : 
    1084        1482 : void WrappedStatisticProperties::addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList
    1085             :                                     , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
    1086             : {
    1087        1482 :     lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES );
    1088        1482 : }
    1089             : 
    1090         307 : void WrappedStatisticProperties::addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList
    1091             :                                     , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
    1092             : {
    1093         307 :     lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM  );
    1094         307 : }
    1095             : 
    1096             : } //namespace wrapper
    1097             : } //namespace chart
    1098             : 
    1099             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11