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