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 0 : Any lcl_getRegressionDefault()
52 : {
53 0 : Any aRet;
54 0 : aRet <<= ::com::sun::star::chart::ChartRegressionCurveType_NONE;
55 0 : 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 0 : sal_Int32 lcl_getErrorBarStyle( const uno::Reference< beans::XPropertySet >& xErrorBarProperties )
115 : {
116 0 : sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
117 0 : if(xErrorBarProperties.is())
118 0 : xErrorBarProperties->getPropertyValue( "ErrorBarStyle" ) >>= nStyle;
119 0 : return nStyle;
120 : }
121 :
122 0 : uno::Reference< chart2::data::XDataProvider > lcl_getDataProviderFromContact(
123 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
124 : {
125 0 : uno::Reference< chart2::data::XDataProvider > xResult;
126 0 : if( spChart2ModelContact.get())
127 : {
128 : uno::Reference< chart2::XChartDocument > xChartDoc(
129 0 : spChart2ModelContact->getChart2Document());
130 0 : if( xChartDoc.is())
131 0 : xResult.set( xChartDoc->getDataProvider());
132 : }
133 0 : return xResult;
134 : }
135 :
136 0 : void lcl_ConvertRangeFromXML(
137 : OUString & rInOutRange,
138 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
139 : {
140 0 : if( !rInOutRange.isEmpty())
141 : {
142 : uno::Reference< chart2::data::XRangeXMLConversion > xConverter(
143 0 : lcl_getDataProviderFromContact( spChart2ModelContact ), uno::UNO_QUERY );
144 0 : if( xConverter.is())
145 : {
146 0 : OUString aResult = xConverter->convertRangeFromXML( rInOutRange );
147 0 : rInOutRange = aResult;
148 0 : }
149 : }
150 0 : }
151 :
152 0 : void lcl_ConvertRangeToXML(
153 : OUString & rInOutRange,
154 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
155 : {
156 0 : if( !rInOutRange.isEmpty())
157 : {
158 : uno::Reference< chart2::data::XRangeXMLConversion > xConverter(
159 0 : lcl_getDataProviderFromContact( spChart2ModelContact ), uno::UNO_QUERY );
160 0 : if( xConverter.is())
161 : {
162 0 : OUString aResult = xConverter->convertRangeToXML( rInOutRange );
163 0 : rInOutRange = aResult;
164 0 : }
165 : }
166 0 : }
167 :
168 : }//anonymous namespace
169 :
170 : template< typename PROPERTYTYPE >
171 : class WrappedStatisticProperty : public WrappedSeriesOrDiagramProperty< PROPERTYTYPE >
172 : {
173 : public:
174 0 : explicit WrappedStatisticProperty( const OUString& rName, const Any& rDefaulValue
175 : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact
176 : , tSeriesOrDiagramPropertyType ePropertyType )
177 0 : : WrappedSeriesOrDiagramProperty< PROPERTYTYPE >(rName,rDefaulValue,spChart2ModelContact,ePropertyType)
178 0 : {}
179 0 : virtual ~WrappedStatisticProperty() {};
180 :
181 : protected:
182 0 : uno::Reference< beans::XPropertySet > getOrCreateErrorBarProperties( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
183 : {
184 0 : if(!xSeriesPropertySet.is())
185 0 : return 0;
186 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties;
187 0 : xSeriesPropertySet->getPropertyValue( "ErrorBarY" ) >>= xErrorBarProperties;
188 0 : if( !xErrorBarProperties.is() )
189 : {
190 : // todo: use a valid context
191 0 : xErrorBarProperties = ::chart::createErrorBar( uno::Reference< uno::XComponentContext >() );
192 : //default in new and old api are different
193 0 : xErrorBarProperties->setPropertyValue( "ShowPositiveError" , uno::makeAny(sal_Bool(sal_False)) );
194 0 : xErrorBarProperties->setPropertyValue( "ShowNegativeError" , uno::makeAny(sal_Bool(sal_False)) );
195 0 : xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::makeAny(::com::sun::star::chart::ErrorBarStyle::NONE) );
196 0 : xSeriesPropertySet->setPropertyValue( "ErrorBarY" , uno::makeAny( xErrorBarProperties ) );
197 : }
198 0 : 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 0 : WrappedConstantErrorLowProperty::WrappedConstantErrorLowProperty(
219 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
220 : tSeriesOrDiagramPropertyType ePropertyType )
221 : : WrappedStatisticProperty< double >( "ConstantErrorLow"
222 0 : , uno::makeAny( double(0.0) ), spChart2ModelContact, ePropertyType )
223 : {
224 0 : }
225 0 : WrappedConstantErrorLowProperty::~WrappedConstantErrorLowProperty()
226 : {
227 0 : }
228 :
229 0 : double WrappedConstantErrorLowProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
230 : {
231 0 : double aRet = 0.0;
232 0 : m_aDefaultValue >>= aRet;
233 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties;
234 0 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( "ErrorBarY" ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
235 : {
236 0 : if( ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE == lcl_getErrorBarStyle( xErrorBarProperties ) )
237 0 : xErrorBarProperties->getPropertyValue( "NegativeError" ) >>= aRet;
238 : else
239 0 : m_aOuterValue >>= aRet;
240 : }
241 0 : return aRet;
242 : }
243 :
244 0 : void WrappedConstantErrorLowProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const
245 : {
246 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
247 0 : if( xErrorBarProperties.is() )
248 : {
249 0 : m_aOuterValue = uno::makeAny( aNewValue );
250 0 : if( ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE == lcl_getErrorBarStyle( xErrorBarProperties ) )
251 : {
252 0 : xErrorBarProperties->setPropertyValue( "NegativeError", m_aOuterValue );
253 : }
254 0 : }
255 0 : }
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 0 : WrappedConstantErrorHighProperty::WrappedConstantErrorHighProperty(
273 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
274 : tSeriesOrDiagramPropertyType ePropertyType )
275 : : WrappedStatisticProperty< double >( "ConstantErrorHigh"
276 0 : , uno::makeAny( double(0.0) ), spChart2ModelContact, ePropertyType )
277 : {
278 0 : }
279 0 : WrappedConstantErrorHighProperty::~WrappedConstantErrorHighProperty()
280 : {
281 0 : }
282 :
283 0 : double WrappedConstantErrorHighProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
284 : {
285 0 : double aRet = 0.0;
286 0 : m_aDefaultValue >>= aRet;
287 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties;
288 0 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( "ErrorBarY" ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
289 : {
290 0 : if( ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE == lcl_getErrorBarStyle( xErrorBarProperties ) )
291 0 : xErrorBarProperties->getPropertyValue( "PositiveError" ) >>= aRet;
292 : else
293 0 : m_aOuterValue >>= aRet;
294 : }
295 0 : return aRet;
296 : }
297 :
298 0 : void WrappedConstantErrorHighProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const
299 : {
300 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
301 0 : if( xErrorBarProperties.is() )
302 : {
303 0 : m_aOuterValue = uno::makeAny( aNewValue );
304 0 : if( ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE == lcl_getErrorBarStyle( xErrorBarProperties ) )
305 : {
306 0 : xErrorBarProperties->setPropertyValue( "PositiveError" , m_aOuterValue );
307 : }
308 0 : }
309 0 : }
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 0 : WrappedMeanValueProperty::WrappedMeanValueProperty(
324 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
325 : tSeriesOrDiagramPropertyType ePropertyType )
326 0 : : WrappedStatisticProperty< sal_Bool >( "MeanValue", uno::makeAny( sal_False ), spChart2ModelContact, ePropertyType )
327 : {
328 0 : }
329 0 : WrappedMeanValueProperty::~WrappedMeanValueProperty()
330 : {
331 0 : }
332 :
333 0 : sal_Bool WrappedMeanValueProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
334 : {
335 0 : sal_Bool bRet = sal_False;
336 0 : uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY );
337 0 : if( xRegCnt.is() )
338 0 : bRet = RegressionCurveHelper::hasMeanValueLine( xRegCnt );
339 0 : return bRet;
340 : }
341 :
342 0 : void WrappedMeanValueProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Bool& aNewValue ) const
343 : {
344 0 : uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY );
345 0 : if( xRegCnt.is() )
346 : {
347 0 : if(aNewValue)
348 0 : RegressionCurveHelper::addMeanValueLine( xRegCnt, 0, 0 );
349 : else
350 0 : RegressionCurveHelper::removeMeanValueLine( xRegCnt );
351 0 : }
352 0 : }
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 0 : WrappedErrorCategoryProperty::WrappedErrorCategoryProperty(
368 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
369 : tSeriesOrDiagramPropertyType ePropertyType )
370 : : WrappedStatisticProperty< ::com::sun::star::chart::ChartErrorCategory >( "ErrorCategory"
371 0 : , uno::makeAny( ::com::sun::star::chart::ChartErrorCategory_NONE ), spChart2ModelContact, ePropertyType )
372 : {
373 0 : }
374 0 : WrappedErrorCategoryProperty::~WrappedErrorCategoryProperty()
375 : {
376 0 : }
377 :
378 0 : ::com::sun::star::chart::ChartErrorCategory WrappedErrorCategoryProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
379 : {
380 0 : ::com::sun::star::chart::ChartErrorCategory aRet = ::com::sun::star::chart::ChartErrorCategory_NONE;
381 0 : m_aDefaultValue >>= aRet;
382 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties;
383 0 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( "ErrorBarY" ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
384 : {
385 0 : sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
386 0 : xErrorBarProperties->getPropertyValue( "ErrorBarStyle" ) >>= nStyle;
387 0 : switch(nStyle)
388 : {
389 : case ::com::sun::star::chart::ErrorBarStyle::NONE:
390 0 : aRet = ::com::sun::star::chart::ChartErrorCategory_NONE;
391 0 : 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 0 : aRet = ::com::sun::star::chart::ChartErrorCategory_PERCENT;
403 0 : 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 0 : return aRet;
416 : }
417 0 : void WrappedErrorCategoryProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const ::com::sun::star::chart::ChartErrorCategory& aNewValue ) const
418 : {
419 0 : if( !xSeriesPropertySet.is() )
420 0 : return;
421 :
422 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
423 0 : if( xErrorBarProperties.is() )
424 : {
425 0 : sal_Int32 nNewStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
426 0 : 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 0 : nNewStyle = ::com::sun::star::chart::ErrorBarStyle::RELATIVE;
442 0 : 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 0 : xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::makeAny(nNewStyle) );
450 0 : }
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 0 : WrappedPercentageErrorProperty::WrappedPercentageErrorProperty(
469 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
470 : tSeriesOrDiagramPropertyType ePropertyType )
471 : : WrappedStatisticProperty< double >( "PercentageError"
472 0 : , uno::makeAny( double(0.0) ), spChart2ModelContact, ePropertyType )
473 : {
474 0 : }
475 0 : WrappedPercentageErrorProperty::~WrappedPercentageErrorProperty()
476 : {
477 0 : }
478 :
479 0 : double WrappedPercentageErrorProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
480 : {
481 0 : double aRet = 0.0;
482 0 : m_aDefaultValue >>= aRet;
483 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties;
484 0 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( "ErrorBarY" ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
485 : {
486 0 : if( ::com::sun::star::chart::ErrorBarStyle::RELATIVE == lcl_getErrorBarStyle( xErrorBarProperties ) )
487 0 : xErrorBarProperties->getPropertyValue( "PositiveError" ) >>= aRet;
488 : else
489 0 : m_aOuterValue >>= aRet;
490 : }
491 0 : return aRet;
492 : }
493 0 : void WrappedPercentageErrorProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const
494 : {
495 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
496 0 : if( xErrorBarProperties.is() )
497 : {
498 0 : m_aOuterValue = uno::makeAny( aNewValue );
499 0 : if( ::com::sun::star::chart::ErrorBarStyle::RELATIVE == lcl_getErrorBarStyle( xErrorBarProperties ) )
500 : {
501 0 : xErrorBarProperties->setPropertyValue( "PositiveError" , m_aOuterValue );
502 0 : xErrorBarProperties->setPropertyValue( "NegativeError" , m_aOuterValue );
503 : }
504 0 : }
505 0 : }
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 0 : WrappedErrorMarginProperty::WrappedErrorMarginProperty(
523 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
524 : tSeriesOrDiagramPropertyType ePropertyType )
525 : : WrappedStatisticProperty< double >( "ErrorMargin"
526 0 : , uno::makeAny( double(0.0) ), spChart2ModelContact, ePropertyType )
527 : {
528 0 : }
529 0 : WrappedErrorMarginProperty::~WrappedErrorMarginProperty()
530 : {
531 0 : }
532 :
533 0 : double WrappedErrorMarginProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
534 : {
535 0 : double aRet = 0.0;
536 0 : m_aDefaultValue >>= aRet;
537 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties;
538 0 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( "ErrorBarY" ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
539 : {
540 0 : if( ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN == lcl_getErrorBarStyle( xErrorBarProperties ) )
541 0 : xErrorBarProperties->getPropertyValue( "PositiveError" ) >>= aRet;
542 : else
543 0 : m_aOuterValue >>= aRet;
544 : }
545 0 : return aRet;
546 : }
547 0 : void WrappedErrorMarginProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const double& aNewValue ) const
548 : {
549 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
550 0 : if( xErrorBarProperties.is() )
551 : {
552 0 : m_aOuterValue = uno::makeAny( aNewValue );
553 0 : 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 0 : }
559 0 : }
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 0 : WrappedErrorIndicatorProperty::WrappedErrorIndicatorProperty(
574 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
575 : tSeriesOrDiagramPropertyType ePropertyType )
576 : : WrappedStatisticProperty< ::com::sun::star::chart::ChartErrorIndicatorType >( "ErrorIndicator"
577 0 : , uno::makeAny( ::com::sun::star::chart::ChartErrorIndicatorType_NONE ), spChart2ModelContact, ePropertyType )
578 : {
579 0 : }
580 0 : WrappedErrorIndicatorProperty::~WrappedErrorIndicatorProperty()
581 : {
582 0 : }
583 :
584 0 : ::com::sun::star::chart::ChartErrorIndicatorType WrappedErrorIndicatorProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
585 : {
586 0 : ::com::sun::star::chart::ChartErrorIndicatorType aRet = ::com::sun::star::chart::ChartErrorIndicatorType_NONE;
587 0 : m_aDefaultValue >>= aRet;
588 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties;
589 0 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( "ErrorBarY" ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
590 : {
591 0 : sal_Bool bPositive = sal_False;
592 0 : sal_Bool bNegative = sal_False;
593 0 : xErrorBarProperties->getPropertyValue( "ShowPositiveError" ) >>= bPositive;
594 0 : xErrorBarProperties->getPropertyValue( "ShowNegativeError" ) >>= bNegative;
595 :
596 0 : if( bPositive && bNegative )
597 0 : aRet = ::com::sun::star::chart::ChartErrorIndicatorType_TOP_AND_BOTTOM;
598 0 : else if( bPositive && !bNegative )
599 0 : aRet = ::com::sun::star::chart::ChartErrorIndicatorType_UPPER;
600 0 : else if( !bPositive && bNegative )
601 0 : aRet = ::com::sun::star::chart::ChartErrorIndicatorType_LOWER;
602 : }
603 0 : return aRet;
604 : }
605 0 : void WrappedErrorIndicatorProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const ::com::sun::star::chart::ChartErrorIndicatorType& aNewValue ) const
606 : {
607 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
608 0 : if( xErrorBarProperties.is() )
609 : {
610 0 : sal_Bool bPositive = sal_False;
611 0 : sal_Bool bNegative = sal_False;
612 0 : switch( aNewValue )
613 : {
614 : case ::com::sun::star::chart::ChartErrorIndicatorType_TOP_AND_BOTTOM:
615 0 : bPositive = sal_True;
616 0 : bNegative = sal_True;
617 0 : 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 0 : xErrorBarProperties->setPropertyValue( "ShowPositiveError" , uno::makeAny(bPositive) );
629 0 : xErrorBarProperties->setPropertyValue( "ShowNegativeError" , uno::makeAny(bNegative) );
630 0 : }
631 0 : }
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 0 : WrappedErrorBarStyleProperty::WrappedErrorBarStyleProperty(
647 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
648 : tSeriesOrDiagramPropertyType ePropertyType )
649 : : WrappedStatisticProperty< sal_Int32 >( "ErrorBarStyle"
650 0 : , uno::makeAny( ::com::sun::star::chart::ErrorBarStyle::NONE ), spChart2ModelContact, ePropertyType )
651 : {
652 0 : }
653 0 : WrappedErrorBarStyleProperty::~WrappedErrorBarStyleProperty()
654 : {
655 0 : }
656 :
657 0 : sal_Int32 WrappedErrorBarStyleProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
658 : {
659 0 : sal_Int32 nRet = ::com::sun::star::chart::ErrorBarStyle::NONE;
660 0 : m_aDefaultValue >>= nRet;
661 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties;
662 0 : if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( "ErrorBarY" ) >>= xErrorBarProperties ) && xErrorBarProperties.is())
663 : {
664 0 : xErrorBarProperties->getPropertyValue( "ErrorBarStyle" ) >>= nRet;
665 : }
666 0 : return nRet;
667 : }
668 0 : void WrappedErrorBarStyleProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const sal_Int32& nNewValue ) const
669 : {
670 0 : if( !xSeriesPropertySet.is() )
671 0 : return;
672 :
673 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
674 0 : if( xErrorBarProperties.is() )
675 : {
676 0 : xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::makeAny( nNewValue ));
677 0 : }
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 0 : WrappedErrorBarRangePositiveProperty::WrappedErrorBarRangePositiveProperty(
696 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
697 : tSeriesOrDiagramPropertyType ePropertyType )
698 : : WrappedStatisticProperty< OUString >( "ErrorBarRangePositive"
699 0 : , uno::makeAny( OUString() ), spChart2ModelContact, ePropertyType )
700 : {
701 0 : }
702 0 : WrappedErrorBarRangePositiveProperty::~WrappedErrorBarRangePositiveProperty()
703 : {
704 0 : }
705 :
706 0 : OUString WrappedErrorBarRangePositiveProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
707 : {
708 0 : OUString aRet;
709 0 : m_aDefaultValue >>= aRet;
710 0 : uno::Reference< chart2::data::XDataSource > xErrorBarDataSource;
711 0 : if( xSeriesPropertySet.is() &&
712 0 : ( xSeriesPropertySet->getPropertyValue( "ErrorBarY" ) >>= xErrorBarDataSource ) &&
713 0 : xErrorBarDataSource.is())
714 : {
715 : uno::Reference< chart2::data::XDataSequence > xSeq(
716 : StatisticsHelper::getErrorDataSequenceFromDataSource(
717 0 : xErrorBarDataSource, true /* positive */, true /* y-error */ ));
718 0 : if( xSeq.is())
719 0 : aRet = xSeq->getSourceRangeRepresentation();
720 : else
721 0 : m_aOuterValue >>= aRet;
722 : }
723 0 : lcl_ConvertRangeToXML( aRet, m_spChart2ModelContact );
724 0 : return aRet;
725 : }
726 :
727 0 : void WrappedErrorBarRangePositiveProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewValue ) const
728 : {
729 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
730 0 : if( xErrorBarProperties.is() )
731 : {
732 : uno::Reference< chart2::data::XDataProvider > xDataProvider(
733 0 : lcl_getDataProviderFromContact( m_spChart2ModelContact ));
734 0 : uno::Reference< chart2::data::XDataSource > xDataSource( xErrorBarProperties, uno::UNO_QUERY );
735 0 : if( xDataSource.is() && xDataProvider.is())
736 : {
737 0 : OUString aTmp( aNewValue );
738 0 : OUString aXMLRange( aNewValue );
739 0 : lcl_ConvertRangeFromXML( aTmp, m_spChart2ModelContact );
740 : StatisticsHelper::setErrorDataSequence(
741 0 : xDataSource, xDataProvider, aTmp, true /* positive */, true /* y-error */, &aXMLRange );
742 0 : m_aOuterValue <<= aTmp;
743 0 : }
744 0 : }
745 0 : }
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 0 : WrappedErrorBarRangeNegativeProperty::WrappedErrorBarRangeNegativeProperty(
763 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
764 : tSeriesOrDiagramPropertyType ePropertyType )
765 : : WrappedStatisticProperty< OUString >( "ErrorBarRangeNegative"
766 0 : , uno::makeAny( OUString() ), spChart2ModelContact, ePropertyType )
767 : {
768 0 : }
769 0 : WrappedErrorBarRangeNegativeProperty::~WrappedErrorBarRangeNegativeProperty()
770 : {
771 0 : }
772 :
773 0 : OUString WrappedErrorBarRangeNegativeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
774 : {
775 0 : OUString aRet;
776 0 : m_aDefaultValue >>= aRet;
777 0 : uno::Reference< chart2::data::XDataSource > xErrorBarDataSource;
778 0 : if( xSeriesPropertySet.is() &&
779 0 : ( xSeriesPropertySet->getPropertyValue( "ErrorBarY" ) >>= xErrorBarDataSource ) &&
780 0 : xErrorBarDataSource.is())
781 : {
782 : uno::Reference< chart2::data::XDataSequence > xSeq(
783 : StatisticsHelper::getErrorDataSequenceFromDataSource(
784 0 : xErrorBarDataSource, false /* positive */, true /* y-error */ ));
785 0 : if( xSeq.is())
786 0 : aRet = xSeq->getSourceRangeRepresentation();
787 : else
788 0 : m_aOuterValue >>= aRet;
789 : }
790 0 : lcl_ConvertRangeToXML( aRet, m_spChart2ModelContact );
791 0 : return aRet;
792 : }
793 :
794 0 : void WrappedErrorBarRangeNegativeProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const OUString& aNewValue ) const
795 : {
796 0 : uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) );
797 0 : if( xErrorBarProperties.is() )
798 : {
799 : uno::Reference< chart2::data::XDataProvider > xDataProvider(
800 0 : lcl_getDataProviderFromContact( m_spChart2ModelContact ));
801 0 : uno::Reference< chart2::data::XDataSource > xDataSource( xErrorBarProperties, uno::UNO_QUERY );
802 0 : if( xDataSource.is() && xDataProvider.is())
803 : {
804 0 : OUString aTmp( aNewValue );
805 0 : OUString aXMLRange( aNewValue );
806 0 : lcl_ConvertRangeFromXML( aTmp, m_spChart2ModelContact );
807 : StatisticsHelper::setErrorDataSequence(
808 0 : xDataSource, xDataProvider, aTmp, false /* positive */, true /* y-error */, &aXMLRange );
809 0 : m_aOuterValue <<= aTmp;
810 0 : }
811 0 : }
812 0 : }
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 0 : WrappedRegressionCurvesProperty::WrappedRegressionCurvesProperty(
827 : ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact,
828 : tSeriesOrDiagramPropertyType ePropertyType )
829 : : WrappedStatisticProperty< ::com::sun::star::chart::ChartRegressionCurveType >( "RegressionCurves"
830 0 : , lcl_getRegressionDefault(), spChart2ModelContact, ePropertyType )
831 : {
832 0 : }
833 0 : WrappedRegressionCurvesProperty::~WrappedRegressionCurvesProperty()
834 : {
835 0 : }
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 0 : void WrappedRegressionCurvesProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const ::com::sun::star::chart::ChartRegressionCurveType& aNewValue ) const
850 : {
851 0 : uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( xSeriesPropertySet, uno::UNO_QUERY );
852 0 : uno::Reference< chart2::XRegressionCurve > xRegressionCurve( xSeriesPropertySet, uno::UNO_QUERY );
853 :
854 0 : 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 0 : }
864 0 : }
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 0 : 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 0 : , m_eType( ePropertySetType )
904 : {
905 0 : }
906 0 : WrappedStatisticPropertySetProperty::~WrappedStatisticPropertySetProperty()
907 : {
908 0 : }
909 :
910 0 : Reference< beans::XPropertySet > WrappedStatisticPropertySetProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const
911 : {
912 0 : Reference< beans::XPropertySet > xResult;
913 0 : uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY );
914 :
915 0 : 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 0 : if( xSeriesPropertySet.is())
923 0 : xSeriesPropertySet->getPropertyValue( "ErrorBarY" ) >>= xResult;
924 0 : break;
925 : case PROPERTY_SET_TYPE_MEAN_VALUE:
926 0 : if( xRegCnt.is() )
927 0 : xResult.set( RegressionCurveHelper::getMeanValueLine( xRegCnt ), uno::UNO_QUERY );
928 0 : break;
929 : }
930 :
931 0 : 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 0 : void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList
966 : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact
967 : , tSeriesOrDiagramPropertyType ePropertyType )
968 : {
969 0 : rList.push_back( new WrappedConstantErrorLowProperty( spChart2ModelContact, ePropertyType ) );
970 0 : rList.push_back( new WrappedConstantErrorHighProperty( spChart2ModelContact, ePropertyType ) );
971 0 : rList.push_back( new WrappedMeanValueProperty( spChart2ModelContact, ePropertyType ) );
972 0 : rList.push_back( new WrappedErrorCategoryProperty( spChart2ModelContact, ePropertyType ) );
973 0 : rList.push_back( new WrappedErrorBarStyleProperty( spChart2ModelContact, ePropertyType ) );
974 0 : rList.push_back( new WrappedPercentageErrorProperty( spChart2ModelContact, ePropertyType ) );
975 0 : rList.push_back( new WrappedErrorMarginProperty( spChart2ModelContact, ePropertyType ) );
976 0 : rList.push_back( new WrappedErrorIndicatorProperty( spChart2ModelContact, ePropertyType ) );
977 0 : rList.push_back( new WrappedErrorBarRangePositiveProperty( spChart2ModelContact, ePropertyType ) );
978 0 : rList.push_back( new WrappedErrorBarRangeNegativeProperty( spChart2ModelContact, ePropertyType ) );
979 0 : rList.push_back( new WrappedRegressionCurvesProperty( spChart2ModelContact, ePropertyType ) );
980 : rList.push_back( new WrappedStatisticPropertySetProperty(
981 0 : WrappedStatisticPropertySetProperty::PROPERTY_SET_TYPE_REGRESSION, spChart2ModelContact, ePropertyType ) );
982 : rList.push_back( new WrappedStatisticPropertySetProperty(
983 0 : WrappedStatisticPropertySetProperty::PROPERTY_SET_TYPE_ERROR_BAR, spChart2ModelContact, ePropertyType ) );
984 : rList.push_back( new WrappedStatisticPropertySetProperty(
985 0 : WrappedStatisticPropertySetProperty::PROPERTY_SET_TYPE_MEAN_VALUE, spChart2ModelContact, ePropertyType ) );
986 0 : }
987 :
988 : }//anonymous namespace
989 :
990 0 : void WrappedStatisticProperties::addProperties( ::std::vector< Property > & rOutProperties )
991 : {
992 : rOutProperties.push_back(
993 : Property( "ConstantErrorLow",
994 : PROP_CHART_STATISTIC_CONST_ERROR_LOW,
995 0 : ::getCppuType( reinterpret_cast< double * >(0)),
996 : beans::PropertyAttribute::BOUND
997 0 : | beans::PropertyAttribute::MAYBEDEFAULT ));
998 : rOutProperties.push_back(
999 : Property( "ConstantErrorHigh",
1000 : PROP_CHART_STATISTIC_CONST_ERROR_HIGH,
1001 0 : ::getCppuType( reinterpret_cast< double * >(0)),
1002 : beans::PropertyAttribute::BOUND
1003 0 : | beans::PropertyAttribute::MAYBEDEFAULT ));
1004 : rOutProperties.push_back(
1005 : Property( "MeanValue",
1006 : PROP_CHART_STATISTIC_MEAN_VALUE,
1007 0 : ::getBooleanCppuType(),
1008 : beans::PropertyAttribute::BOUND
1009 0 : | beans::PropertyAttribute::MAYBEDEFAULT ));
1010 : rOutProperties.push_back(
1011 : Property( "ErrorCategory",
1012 : PROP_CHART_STATISTIC_ERROR_CATEGORY,
1013 0 : ::getCppuType( reinterpret_cast< ::com::sun::star::chart::ChartErrorCategory * >(0)),
1014 : beans::PropertyAttribute::BOUND
1015 0 : | beans::PropertyAttribute::MAYBEDEFAULT ));
1016 : rOutProperties.push_back(
1017 : Property( "ErrorBarStyle",
1018 : PROP_CHART_STATISTIC_ERROR_BAR_STYLE,
1019 0 : ::getCppuType( reinterpret_cast< sal_Int32 * >(0)),
1020 : beans::PropertyAttribute::BOUND
1021 0 : | beans::PropertyAttribute::MAYBEDEFAULT ));
1022 : rOutProperties.push_back(
1023 : Property( "PercentageError",
1024 : PROP_CHART_STATISTIC_PERCENT_ERROR,
1025 0 : ::getCppuType( reinterpret_cast< double * >(0)),
1026 : beans::PropertyAttribute::BOUND
1027 0 : | beans::PropertyAttribute::MAYBEDEFAULT ));
1028 : rOutProperties.push_back(
1029 : Property( "ErrorMargin",
1030 : PROP_CHART_STATISTIC_ERROR_MARGIN,
1031 0 : ::getCppuType( reinterpret_cast< double * >(0)),
1032 : beans::PropertyAttribute::BOUND
1033 0 : | beans::PropertyAttribute::MAYBEDEFAULT ));
1034 : rOutProperties.push_back(
1035 : Property( "ErrorIndicator",
1036 : PROP_CHART_STATISTIC_ERROR_INDICATOR,
1037 0 : ::getCppuType( reinterpret_cast< ::com::sun::star::chart::ChartErrorIndicatorType * >(0)),
1038 : beans::PropertyAttribute::BOUND
1039 0 : | beans::PropertyAttribute::MAYBEDEFAULT ));
1040 : rOutProperties.push_back(
1041 : Property( "ErrorBarRangePositive",
1042 : PROP_CHART_STATISTIC_ERROR_RANGE_POSITIVE,
1043 0 : ::getCppuType( reinterpret_cast< OUString * >(0)),
1044 : beans::PropertyAttribute::BOUND
1045 0 : | beans::PropertyAttribute::MAYBEDEFAULT ));
1046 : rOutProperties.push_back(
1047 : Property( "ErrorBarRangeNegative",
1048 : PROP_CHART_STATISTIC_ERROR_RANGE_NEGATIVE,
1049 0 : ::getCppuType( reinterpret_cast< OUString * >(0)),
1050 : beans::PropertyAttribute::BOUND
1051 0 : | beans::PropertyAttribute::MAYBEDEFAULT ));
1052 : rOutProperties.push_back(
1053 : Property( "RegressionCurves",
1054 : PROP_CHART_STATISTIC_REGRESSION_CURVES,
1055 0 : ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartRegressionCurveType * >(0)),
1056 : beans::PropertyAttribute::BOUND
1057 0 : | beans::PropertyAttribute::MAYBEDEFAULT ));
1058 :
1059 : rOutProperties.push_back(
1060 : Property( "DataRegressionProperties",
1061 : PROP_CHART_STATISTIC_REGRESSION_PROPERTIES,
1062 0 : ::getCppuType( reinterpret_cast< const Reference< beans::XPropertySet > * >(0)),
1063 : beans::PropertyAttribute::BOUND
1064 : | beans::PropertyAttribute::READONLY
1065 0 : | beans::PropertyAttribute::MAYBEVOID ));
1066 : rOutProperties.push_back(
1067 : Property( "DataErrorProperties",
1068 : PROP_CHART_STATISTIC_ERROR_PROPERTIES,
1069 0 : ::getCppuType( reinterpret_cast< const Reference< beans::XPropertySet > * >(0)),
1070 : beans::PropertyAttribute::BOUND
1071 : | beans::PropertyAttribute::READONLY
1072 0 : | beans::PropertyAttribute::MAYBEVOID ));
1073 : rOutProperties.push_back(
1074 : Property( "DataMeanValueProperties",
1075 : PROP_CHART_STATISTIC_MEAN_VALUE_PROPERTIES,
1076 0 : ::getCppuType( reinterpret_cast< const Reference< beans::XPropertySet > * >(0)),
1077 : beans::PropertyAttribute::BOUND
1078 : | beans::PropertyAttribute::READONLY
1079 0 : | beans::PropertyAttribute::MAYBEVOID ));
1080 0 : }
1081 :
1082 0 : void WrappedStatisticProperties::addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList
1083 : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
1084 : {
1085 0 : lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES );
1086 0 : }
1087 :
1088 0 : void WrappedStatisticProperties::addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList
1089 : , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact )
1090 : {
1091 0 : lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM );
1092 0 : }
1093 :
1094 : } //namespace wrapper
1095 : } //namespace chart
1096 :
1097 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|