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

Generated by: LCOV version 1.10