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