1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <StatisticsItemConverter.hxx>
21 #include "SchWhichPairs.hxx"
22 #include <RegressionCurveHelper.hxx>
23 #include <RegressionCurveModel.hxx>
24 #include <ErrorBar.hxx>
25 #include <StatisticsHelper.hxx>
26 #include <ChartModel.hxx>
27 #include <unonames.hxx>
29 #include <svl/stritem.hxx>
30 #include <svx/chrtitem.hxx>
31 #include <svl/intitem.hxx>
32 #include <rtl/math.hxx>
34 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
35 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
36 #include <com/sun/star/chart/ErrorBarStyle.hpp>
38 #include <comphelper/diagnose_ex.hxx>
40 using namespace ::com::sun::star
;
45 uno::Reference
< beans::XPropertySet
> lcl_GetErrorBar(
46 const uno::Reference
< beans::XPropertySet
> & xProp
, bool bYError
)
48 uno::Reference
< beans::XPropertySet
> xResult
;
53 ( xProp
->getPropertyValue( bYError
? CHART_UNONAME_ERRORBAR_Y
: CHART_UNONAME_ERRORBAR_X
) >>= xResult
);
55 catch( const uno::Exception
& )
57 DBG_UNHANDLED_EXCEPTION("chart2");
63 uno::Reference
< beans::XPropertySet
> lcl_GetDefaultErrorBar()
65 return uno::Reference
< beans::XPropertySet
>( new ::chart::ErrorBar
);
68 void lcl_getErrorValues( const uno::Reference
< beans::XPropertySet
> & xErrorBarProp
,
69 double & rOutPosError
, double & rOutNegError
)
71 if( ! xErrorBarProp
.is())
76 xErrorBarProp
->getPropertyValue( u
"PositiveError"_ustr
) >>= rOutPosError
;
77 xErrorBarProp
->getPropertyValue( u
"NegativeError"_ustr
) >>= rOutNegError
;
79 catch( const uno::Exception
& )
81 DBG_UNHANDLED_EXCEPTION("chart2");
85 void lcl_getErrorIndicatorValues(
86 const uno::Reference
< beans::XPropertySet
> & xErrorBarProp
,
87 bool & rOutShowPosError
, bool & rOutShowNegError
)
89 if( ! xErrorBarProp
.is())
94 xErrorBarProp
->getPropertyValue( u
"ShowPositiveError"_ustr
) >>= rOutShowPosError
;
95 xErrorBarProp
->getPropertyValue( u
"ShowNegativeError"_ustr
) >>= rOutShowNegError
;
97 catch( const uno::Exception
& )
99 DBG_UNHANDLED_EXCEPTION("chart2");
103 uno::Reference
< beans::XPropertySet
> lcl_getEquationProperties(
104 const uno::Reference
< beans::XPropertySet
> & xSeriesPropSet
, const SfxItemSet
* pItemSet
)
106 bool bEquationExists
= true;
108 // ensure that a trendline is on
111 if( const SvxChartRegressItem
* pRegressionItem
= pItemSet
->GetItemIfSet( SCHATTR_REGRESSION_TYPE
) )
113 SvxChartRegress eRegress
= pRegressionItem
->GetValue();
114 bEquationExists
= ( eRegress
!= SvxChartRegress::NONE
);
118 if( bEquationExists
)
120 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCnt( xSeriesPropSet
, uno::UNO_QUERY
);
121 rtl::Reference
< ::chart::RegressionCurveModel
> xCurve
=
122 ::chart::RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt
);
125 return xCurve
->getEquationProperties();
129 return uno::Reference
< beans::XPropertySet
>();
132 uno::Reference
< beans::XPropertySet
> lcl_getCurveProperties(
133 const uno::Reference
< beans::XPropertySet
> & xSeriesPropSet
, const SfxItemSet
* pItemSet
)
137 // ensure that a trendline is on
140 if( const SvxChartRegressItem
* pRegressionItem
= pItemSet
->GetItemIfSet( SCHATTR_REGRESSION_TYPE
) )
142 SvxChartRegress eRegress
= pRegressionItem
->GetValue();
143 bExists
= ( eRegress
!= SvxChartRegress::NONE
);
149 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCnt( xSeriesPropSet
, uno::UNO_QUERY
);
150 uno::Reference
< chart2::XRegressionCurve
> xCurve(
151 ::chart::RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt
));
154 uno::Reference
< beans::XPropertySet
> xProperties( xCurve
, uno::UNO_QUERY
);
159 return uno::Reference
< beans::XPropertySet
>();
162 template <class T
, class D
>
163 bool lclConvertToPropertySet(const SfxItemSet
& rItemSet
, sal_uInt16 nWhichId
, const uno::Reference
<beans::XPropertySet
>& xProperties
, const OUString
& aPropertyID
)
165 OSL_ASSERT(xProperties
.is());
166 if( xProperties
.is() )
168 T aValue
= static_cast<T
>(static_cast<const D
&>(rItemSet
.Get( nWhichId
)).GetValue());
169 T aOldValue
= aValue
;
170 bool aSuccess
= xProperties
->getPropertyValue( aPropertyID
) >>= aOldValue
;
171 if (!aSuccess
|| aOldValue
!= aValue
)
173 xProperties
->setPropertyValue( aPropertyID
, uno::Any( aValue
));
180 template <class T
, class D
>
181 void lclConvertToItemSet(SfxItemSet
& rItemSet
, sal_uInt16 nWhichId
, const uno::Reference
<beans::XPropertySet
>& xProperties
, const OUString
& aPropertyID
)
183 OSL_ASSERT(xProperties
.is());
184 if( xProperties
.is() )
186 T aValue
= static_cast<T
>(static_cast<const D
&>(rItemSet
.Get( nWhichId
)).GetValue());
187 if(xProperties
->getPropertyValue( aPropertyID
) >>= aValue
)
189 rItemSet
.Put(D( nWhichId
, aValue
));
194 void lclConvertToItemSetDouble(SfxItemSet
& rItemSet
, TypedWhichId
<SvxDoubleItem
> nWhichId
, const uno::Reference
<beans::XPropertySet
>& xProperties
, const OUString
& aPropertyID
)
196 OSL_ASSERT(xProperties
.is());
197 if( xProperties
.is() )
199 double aValue
= rItemSet
.Get( nWhichId
).GetValue();
200 if(xProperties
->getPropertyValue( aPropertyID
) >>= aValue
)
202 rItemSet
.Put(SvxDoubleItem( aValue
, nWhichId
));
207 } // anonymous namespace
209 namespace chart::wrapper
212 StatisticsItemConverter::StatisticsItemConverter(
213 rtl::Reference
<::chart::ChartModel
> xModel
,
214 const uno::Reference
< beans::XPropertySet
> & rPropertySet
,
215 SfxItemPool
& rItemPool
) :
216 ItemConverter( rPropertySet
, rItemPool
),
217 m_xModel(std::move( xModel
))
221 StatisticsItemConverter::~StatisticsItemConverter()
225 const WhichRangesContainer
& StatisticsItemConverter::GetWhichPairs() const
227 // must span all used items!
228 return nStatWhichPairs
;
231 bool StatisticsItemConverter::GetItemProperty(
232 tWhichIdType
/* nWhichId */,
233 tPropertyNameWithMemberId
& /* rOutProperty */ ) const
238 bool StatisticsItemConverter::ApplySpecialItem(
239 sal_uInt16 nWhichId
, const SfxItemSet
& rItemSet
)
241 bool bChanged
= false;
245 case SCHATTR_STAT_AVERAGE
:
247 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCnt(
248 GetPropertySet(), uno::UNO_QUERY
);
249 bool bOldHasMeanValueLine
= RegressionCurveHelper::hasMeanValueLine( xRegCnt
);
251 bool bNewHasMeanValueLine
=
252 static_cast< const SfxBoolItem
& >( rItemSet
.Get( nWhichId
)).GetValue();
254 if( bOldHasMeanValueLine
!= bNewHasMeanValueLine
)
256 if( ! bNewHasMeanValueLine
)
257 RegressionCurveHelper::removeMeanValueLine( xRegCnt
);
259 RegressionCurveHelper::addMeanValueLine( xRegCnt
, GetPropertySet() );
265 // Attention !!! This case must be passed before SCHATTR_STAT_PERCENT,
266 // SCHATTR_STAT_BIGERROR, SCHATTR_STAT_CONSTPLUS,
267 // SCHATTR_STAT_CONSTMINUS and SCHATTR_STAT_INDICATE
268 case SCHATTR_STAT_KIND_ERROR
:
271 rItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
).GetValue();
273 uno::Reference
< beans::XPropertySet
> xErrorBarProp(
274 lcl_GetErrorBar( GetPropertySet(), bYError
));
276 SvxChartKindError eErrorKind
=
277 static_cast< const SvxChartKindErrorItem
& >(
278 rItemSet
.Get( nWhichId
)).GetValue();
280 if( !xErrorBarProp
.is() && eErrorKind
== SvxChartKindError::NONE
)
286 sal_Int32 nStyle
= css::chart::ErrorBarStyle::NONE
;
290 case SvxChartKindError::NONE
:
291 nStyle
= css::chart::ErrorBarStyle::NONE
; break;
292 case SvxChartKindError::Variant
:
293 nStyle
= css::chart::ErrorBarStyle::VARIANCE
; break;
294 case SvxChartKindError::Sigma
:
295 nStyle
= css::chart::ErrorBarStyle::STANDARD_DEVIATION
; break;
296 case SvxChartKindError::Percent
:
297 nStyle
= css::chart::ErrorBarStyle::RELATIVE
; break;
298 case SvxChartKindError::BigError
:
299 nStyle
= css::chart::ErrorBarStyle::ERROR_MARGIN
; break;
300 case SvxChartKindError::Const
:
301 nStyle
= css::chart::ErrorBarStyle::ABSOLUTE
; break;
302 case SvxChartKindError::StdError
:
303 nStyle
= css::chart::ErrorBarStyle::STANDARD_ERROR
; break;
304 case SvxChartKindError::Range
:
305 nStyle
= css::chart::ErrorBarStyle::FROM_DATA
; break;
308 if( !xErrorBarProp
.is() )
310 xErrorBarProp
= lcl_GetDefaultErrorBar();
311 GetPropertySet()->setPropertyValue( bYError
? CHART_UNONAME_ERRORBAR_Y
: CHART_UNONAME_ERRORBAR_X
,
312 uno::Any( xErrorBarProp
));
315 xErrorBarProp
->setPropertyValue( u
"ErrorBarStyle"_ustr
, uno::Any( nStyle
));
321 case SCHATTR_STAT_PERCENT
:
322 case SCHATTR_STAT_BIGERROR
:
324 OSL_FAIL( "Deprecated item" );
326 rItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
).GetValue();
328 uno::Reference
< beans::XPropertySet
> xErrorBarProp(
329 lcl_GetErrorBar( GetPropertySet(), bYError
));
330 bool bOldHasErrorBar
= xErrorBarProp
.is();
333 static_cast< const SvxDoubleItem
& >(
334 rItemSet
.Get( nWhichId
)).GetValue();
335 double fPos(0.0), fNeg(0.0);
336 lcl_getErrorValues( xErrorBarProp
, fPos
, fNeg
);
338 if( bOldHasErrorBar
&&
339 ! ( ::rtl::math::approxEqual( fPos
, fValue
) &&
340 ::rtl::math::approxEqual( fNeg
, fValue
)))
342 xErrorBarProp
->setPropertyValue( u
"PositiveError"_ustr
, uno::Any( fValue
));
343 xErrorBarProp
->setPropertyValue( u
"NegativeError"_ustr
, uno::Any( fValue
));
349 case SCHATTR_STAT_CONSTPLUS
:
352 rItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
).GetValue();
354 uno::Reference
< beans::XPropertySet
> xErrorBarProp(
355 lcl_GetErrorBar( GetPropertySet(),bYError
));
356 bool bOldHasErrorBar
= xErrorBarProp
.is();
359 static_cast< const SvxDoubleItem
& >(
360 rItemSet
.Get( nWhichId
)).GetValue();
361 double fPos(0.0), fNeg(0.0);
362 lcl_getErrorValues( xErrorBarProp
, fPos
, fNeg
);
364 if( bOldHasErrorBar
&&
365 ! ::rtl::math::approxEqual( fPos
, fValue
))
367 xErrorBarProp
->setPropertyValue( u
"PositiveError"_ustr
, uno::Any( fValue
));
373 case SCHATTR_STAT_CONSTMINUS
:
376 rItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
).GetValue();
377 uno::Reference
< beans::XPropertySet
> xErrorBarProp(
378 lcl_GetErrorBar( GetPropertySet(),bYError
));
379 bool bOldHasErrorBar
= xErrorBarProp
.is();
382 static_cast< const SvxDoubleItem
& >(
383 rItemSet
.Get( nWhichId
)).GetValue();
384 double fPos(0.0), fNeg(0.0);
385 lcl_getErrorValues( xErrorBarProp
, fPos
, fNeg
);
387 if( bOldHasErrorBar
&&
388 ! ::rtl::math::approxEqual( fNeg
, fValue
))
390 xErrorBarProp
->setPropertyValue( u
"NegativeError"_ustr
, uno::Any( fValue
));
396 case SCHATTR_REGRESSION_TYPE
:
398 SvxChartRegress eRegress
=
399 static_cast< const SvxChartRegressItem
& >(
400 rItemSet
.Get( nWhichId
)).GetValue();
402 uno::Reference
< chart2::XRegressionCurve
> xCurve( GetPropertySet(), uno::UNO_QUERY
);
403 uno::Reference
< chart2::XRegressionCurveContainer
> xContainer( GetPropertySet(), uno::UNO_QUERY
);
405 if( eRegress
== SvxChartRegress::NONE
)
407 if ( xContainer
.is() )
409 xContainer
->removeRegressionCurve( xCurve
);
417 SvxChartRegress
eOldRegress(
418 RegressionCurveHelper::getRegressionType(xCurve
));
420 if( eOldRegress
!= eRegress
)
422 xCurve
= RegressionCurveHelper::changeRegressionCurveType(
426 uno::Reference
< beans::XPropertySet
> xProperties( xCurve
, uno::UNO_QUERY
);
427 resetPropertySet( xProperties
);
435 case SCHATTR_REGRESSION_DEGREE
:
437 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
438 bChanged
= lclConvertToPropertySet
<sal_Int32
, SfxInt32Item
>(rItemSet
, nWhichId
, xProperties
, u
"PolynomialDegree"_ustr
);
442 case SCHATTR_REGRESSION_PERIOD
:
444 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
445 bChanged
= lclConvertToPropertySet
<sal_Int32
, SfxInt32Item
>(rItemSet
, nWhichId
, xProperties
, u
"MovingAveragePeriod"_ustr
);
449 case SCHATTR_REGRESSION_MOVING_TYPE
:
451 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
452 bChanged
= lclConvertToPropertySet
<sal_Int32
, SfxInt32Item
>(rItemSet
, nWhichId
, xProperties
, u
"MovingAverageType"_ustr
);
456 case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD
:
458 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
459 bChanged
= lclConvertToPropertySet
<double, SvxDoubleItem
>(rItemSet
, nWhichId
, xProperties
, u
"ExtrapolateForward"_ustr
);
463 case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD
:
465 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
466 bChanged
= lclConvertToPropertySet
<double, SvxDoubleItem
>(rItemSet
, nWhichId
, xProperties
, u
"ExtrapolateBackward"_ustr
);
470 case SCHATTR_REGRESSION_SET_INTERCEPT
:
472 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
473 bChanged
= lclConvertToPropertySet
<bool, SfxBoolItem
>(rItemSet
, nWhichId
, xProperties
, u
"ForceIntercept"_ustr
);
477 case SCHATTR_REGRESSION_INTERCEPT_VALUE
:
479 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
480 bChanged
= lclConvertToPropertySet
<double, SvxDoubleItem
>(rItemSet
, nWhichId
, xProperties
, u
"InterceptValue"_ustr
);
484 case SCHATTR_REGRESSION_CURVE_NAME
:
486 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
487 bChanged
= lclConvertToPropertySet
<OUString
, SfxStringItem
>(rItemSet
, nWhichId
, xProperties
, u
"CurveName"_ustr
);
491 case SCHATTR_REGRESSION_SHOW_EQUATION
:
493 uno::Reference
< beans::XPropertySet
> xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet
));
494 bChanged
= lclConvertToPropertySet
<bool, SfxBoolItem
>(rItemSet
, nWhichId
, xEqProp
, u
"ShowEquation"_ustr
);
498 case SCHATTR_REGRESSION_XNAME
:
500 uno::Reference
< beans::XPropertySet
> xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet
));
501 bChanged
= lclConvertToPropertySet
<OUString
, SfxStringItem
>(rItemSet
, nWhichId
, xEqProp
, u
"XName"_ustr
);
505 case SCHATTR_REGRESSION_YNAME
:
507 uno::Reference
< beans::XPropertySet
> xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet
));
508 bChanged
= lclConvertToPropertySet
<OUString
, SfxStringItem
>(rItemSet
, nWhichId
, xEqProp
, u
"YName"_ustr
);
512 case SCHATTR_REGRESSION_SHOW_COEFF
:
514 uno::Reference
< beans::XPropertySet
> xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet
));
515 bChanged
= lclConvertToPropertySet
<bool, SfxBoolItem
>(rItemSet
, nWhichId
, xEqProp
, u
"ShowCorrelationCoefficient"_ustr
);
519 case SCHATTR_STAT_INDICATE
:
522 rItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
).GetValue();
523 uno::Reference
< beans::XPropertySet
> xErrorBarProp(
524 lcl_GetErrorBar( GetPropertySet(),bYError
));
525 bool bOldHasErrorBar
= xErrorBarProp
.is();
527 SvxChartIndicate eIndicate
=
528 static_cast< const SvxChartIndicateItem
& >(
529 rItemSet
.Get( nWhichId
)).GetValue();
531 bool bNewIndPos
= (eIndicate
== SvxChartIndicate::Both
|| eIndicate
== SvxChartIndicate::Up
);
532 bool bNewIndNeg
= (eIndicate
== SvxChartIndicate::Both
|| eIndicate
== SvxChartIndicate::Down
);
534 bool bShowPos(false), bShowNeg(false);
535 lcl_getErrorIndicatorValues( xErrorBarProp
, bShowPos
, bShowNeg
);
537 if( bOldHasErrorBar
&&
538 ( bShowPos
!= bNewIndPos
||
539 bShowNeg
!= bNewIndNeg
))
541 xErrorBarProp
->setPropertyValue( u
"ShowPositiveError"_ustr
, uno::Any( bNewIndPos
));
542 xErrorBarProp
->setPropertyValue( u
"ShowNegativeError"_ustr
, uno::Any( bNewIndNeg
));
548 case SCHATTR_STAT_RANGE_POS
:
549 case SCHATTR_STAT_RANGE_NEG
:
552 rItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
).GetValue();
553 uno::Reference
< chart2::data::XDataSource
> xErrorBarSource( lcl_GetErrorBar( GetPropertySet(), bYError
),
555 uno::Reference
< chart2::data::XDataProvider
> xDataProvider
;
558 xDataProvider
.set( m_xModel
->getDataProvider());
559 if( xErrorBarSource
.is() && xDataProvider
.is())
561 OUString
aNewRange( static_cast< const SfxStringItem
& >( rItemSet
.Get( nWhichId
)).GetValue());
562 bool bApplyNewRange
= false;
564 bool bIsPositiveValue( nWhichId
== SCHATTR_STAT_RANGE_POS
);
565 if( m_xModel
->hasInternalDataProvider())
567 if( !aNewRange
.isEmpty())
569 uno::Reference
< chart2::data::XDataSequence
> xSeq(
570 StatisticsHelper::getErrorDataSequenceFromDataSource(
571 xErrorBarSource
, bIsPositiveValue
, bYError
));
574 // no data range for error bars yet => create
575 uno::Reference
< chart2::XInternalDataProvider
> xIntDataProvider( xDataProvider
, uno::UNO_QUERY
);
576 OSL_ASSERT( xIntDataProvider
.is());
577 if( xIntDataProvider
.is())
579 xIntDataProvider
->appendSequence();
581 bApplyNewRange
= true;
588 uno::Reference
< chart2::data::XDataSequence
> xSeq(
589 StatisticsHelper::getErrorDataSequenceFromDataSource(
590 xErrorBarSource
, bIsPositiveValue
, bYError
));
592 ! ( xSeq
.is() && (aNewRange
== xSeq
->getSourceRangeRepresentation()));
596 StatisticsHelper::setErrorDataSequence(
597 xErrorBarSource
, xDataProvider
, aNewRange
, bIsPositiveValue
, bYError
);
606 void StatisticsItemConverter::FillSpecialItem(
607 sal_uInt16 nWhichId
, SfxItemSet
& rOutItemSet
) const
611 case SCHATTR_STAT_AVERAGE
:
613 SfxBoolItem( nWhichId
,
614 RegressionCurveHelper::hasMeanValueLine(
615 uno::Reference
< chart2::XRegressionCurveContainer
>(
616 GetPropertySet(), uno::UNO_QUERY
))));
619 case SCHATTR_STAT_KIND_ERROR
:
622 rOutItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
).GetValue();
623 SvxChartKindError eErrorKind
= SvxChartKindError::NONE
;
624 uno::Reference
< beans::XPropertySet
> xErrorBarProp(
625 lcl_GetErrorBar( GetPropertySet(), bYError
));
626 if( xErrorBarProp
.is() )
628 sal_Int32 nStyle
= 0;
629 if( xErrorBarProp
->getPropertyValue( u
"ErrorBarStyle"_ustr
) >>= nStyle
)
633 case css::chart::ErrorBarStyle::NONE
:
635 case css::chart::ErrorBarStyle::VARIANCE
:
636 eErrorKind
= SvxChartKindError::Variant
; break;
637 case css::chart::ErrorBarStyle::STANDARD_DEVIATION
:
638 eErrorKind
= SvxChartKindError::Sigma
; break;
639 case css::chart::ErrorBarStyle::ABSOLUTE
:
640 eErrorKind
= SvxChartKindError::Const
; break;
641 case css::chart::ErrorBarStyle::RELATIVE
:
642 eErrorKind
= SvxChartKindError::Percent
; break;
643 case css::chart::ErrorBarStyle::ERROR_MARGIN
:
644 eErrorKind
= SvxChartKindError::BigError
; break;
645 case css::chart::ErrorBarStyle::STANDARD_ERROR
:
646 eErrorKind
= SvxChartKindError::StdError
; break;
647 case css::chart::ErrorBarStyle::FROM_DATA
:
648 eErrorKind
= SvxChartKindError::Range
; break;
652 rOutItemSet
.Put( SvxChartKindErrorItem( eErrorKind
, SCHATTR_STAT_KIND_ERROR
));
656 case SCHATTR_STAT_PERCENT
:
659 rOutItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
).GetValue();
660 uno::Reference
< beans::XPropertySet
> xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError
));
661 if( xErrorBarProp
.is())
663 double fPos(0.0), fNeg(0.0);
664 lcl_getErrorValues( xErrorBarProp
, fPos
, fNeg
);
665 rOutItemSet
.Put( SvxDoubleItem( ( fPos
+ fNeg
) / 2.0, SCHATTR_STAT_PERCENT
));
670 case SCHATTR_STAT_BIGERROR
:
673 rOutItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
).GetValue();
674 uno::Reference
< beans::XPropertySet
> xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError
));
675 if( xErrorBarProp
.is())
677 double fPos(0.0), fNeg(0.0);
678 lcl_getErrorValues( xErrorBarProp
, fPos
, fNeg
);
679 rOutItemSet
.Put( SvxDoubleItem( ( fPos
+ fNeg
) / 2.0, SCHATTR_STAT_BIGERROR
));
684 case SCHATTR_STAT_CONSTPLUS
:
687 rOutItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
).GetValue();
688 uno::Reference
< beans::XPropertySet
> xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError
));
689 if( xErrorBarProp
.is())
691 double fPos(0.0), fNeg(0.0);
692 lcl_getErrorValues( xErrorBarProp
, fPos
, fNeg
);
693 rOutItemSet
.Put( SvxDoubleItem( fPos
, SCHATTR_STAT_CONSTPLUS
));
698 case SCHATTR_STAT_CONSTMINUS
:
701 rOutItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
).GetValue();
702 uno::Reference
< beans::XPropertySet
> xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError
));
703 if( xErrorBarProp
.is())
705 double fPos(0.0), fNeg(0.0);
706 lcl_getErrorValues( xErrorBarProp
, fPos
, fNeg
);
707 rOutItemSet
.Put( SvxDoubleItem( fNeg
, SCHATTR_STAT_CONSTMINUS
));
712 case SCHATTR_REGRESSION_TYPE
:
714 SvxChartRegress eRegress
=
715 RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine(
716 uno::Reference
< chart2::XRegressionCurveContainer
>(
717 GetPropertySet(), uno::UNO_QUERY
) );
718 rOutItemSet
.Put( SvxChartRegressItem( eRegress
, SCHATTR_REGRESSION_TYPE
));
722 case SCHATTR_REGRESSION_DEGREE
:
725 uno::Reference
<beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
726 lclConvertToItemSet
<sal_Int32
, SfxInt32Item
>(rOutItemSet
, nWhichId
, xProperties
, u
"PolynomialDegree"_ustr
);
730 case SCHATTR_REGRESSION_PERIOD
:
732 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
733 lclConvertToItemSet
<sal_Int32
, SfxInt32Item
>(rOutItemSet
, nWhichId
, xProperties
, u
"MovingAveragePeriod"_ustr
);
737 case SCHATTR_REGRESSION_MOVING_TYPE
:
739 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
740 lclConvertToItemSet
<sal_Int32
, SfxInt32Item
>(rOutItemSet
, nWhichId
, xProperties
, u
"MovingAverageType"_ustr
);
744 case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD
:
746 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
747 lclConvertToItemSetDouble(rOutItemSet
, SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD
, xProperties
, u
"ExtrapolateForward"_ustr
);
751 case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD
:
753 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
754 lclConvertToItemSetDouble(rOutItemSet
, SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD
, xProperties
, u
"ExtrapolateBackward"_ustr
);
758 case SCHATTR_REGRESSION_SET_INTERCEPT
:
760 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
761 lclConvertToItemSet
<bool, SfxBoolItem
>(rOutItemSet
, nWhichId
, xProperties
, u
"ForceIntercept"_ustr
);
765 case SCHATTR_REGRESSION_INTERCEPT_VALUE
:
767 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
768 lclConvertToItemSetDouble(rOutItemSet
, SCHATTR_REGRESSION_INTERCEPT_VALUE
, xProperties
, u
"InterceptValue"_ustr
);
772 case SCHATTR_REGRESSION_CURVE_NAME
:
774 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
775 lclConvertToItemSet
<OUString
, SfxStringItem
>(rOutItemSet
, nWhichId
, xProperties
, u
"CurveName"_ustr
);
779 case SCHATTR_REGRESSION_SHOW_EQUATION
:
781 uno::Reference
< beans::XPropertySet
> xEqProp( lcl_getEquationProperties( GetPropertySet(), nullptr ));
782 lclConvertToItemSet
<bool, SfxBoolItem
>(rOutItemSet
, nWhichId
, xEqProp
, u
"ShowEquation"_ustr
);
786 case SCHATTR_REGRESSION_XNAME
:
788 uno::Reference
< beans::XPropertySet
> xEqProp( lcl_getEquationProperties( GetPropertySet(), nullptr ));
789 lclConvertToItemSet
<OUString
, SfxStringItem
>(rOutItemSet
, nWhichId
, xEqProp
, u
"XName"_ustr
);
793 case SCHATTR_REGRESSION_YNAME
:
795 uno::Reference
< beans::XPropertySet
> xEqProp( lcl_getEquationProperties( GetPropertySet(), nullptr ));
796 lclConvertToItemSet
<OUString
, SfxStringItem
>(rOutItemSet
, nWhichId
, xEqProp
, u
"YName"_ustr
);
800 case SCHATTR_REGRESSION_SHOW_COEFF
:
802 uno::Reference
< beans::XPropertySet
> xEqProp( lcl_getEquationProperties( GetPropertySet(), nullptr ));
803 lclConvertToItemSet
<bool, SfxBoolItem
>(rOutItemSet
, nWhichId
, xEqProp
, u
"ShowCorrelationCoefficient"_ustr
);
807 case SCHATTR_STAT_INDICATE
:
810 rOutItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
).GetValue();
811 uno::Reference
< beans::XPropertySet
> xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError
));
812 SvxChartIndicate eIndicate
= SvxChartIndicate::Both
;
813 if( xErrorBarProp
.is())
815 bool bShowPos(false), bShowNeg(false);
816 lcl_getErrorIndicatorValues( xErrorBarProp
, bShowPos
, bShowNeg
);
821 eIndicate
= SvxChartIndicate::Both
;
823 eIndicate
= SvxChartIndicate::Up
;
828 eIndicate
= SvxChartIndicate::Down
;
830 eIndicate
= SvxChartIndicate::NONE
;
833 rOutItemSet
.Put( SvxChartIndicateItem( eIndicate
, SCHATTR_STAT_INDICATE
));
837 case SCHATTR_STAT_RANGE_POS
:
838 case SCHATTR_STAT_RANGE_NEG
:
841 rOutItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
).GetValue();
842 uno::Reference
< chart2::data::XDataSource
> xErrorBarSource( lcl_GetErrorBar( GetPropertySet(),bYError
),
844 if( xErrorBarSource
.is())
846 uno::Reference
< chart2::data::XDataSequence
> xSeq(
847 StatisticsHelper::getErrorDataSequenceFromDataSource(
848 xErrorBarSource
, (nWhichId
== SCHATTR_STAT_RANGE_POS
), bYError
));
850 rOutItemSet
.Put( SfxStringItem( nWhichId
, xSeq
->getSourceRangeRepresentation()));
859 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */