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