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"
23 #include "RegressionCurveHelper.hxx"
24 #include "ItemPropertyMap.hxx"
25 #include "ErrorBar.hxx"
26 #include "PropertyHelper.hxx"
27 #include "ChartModelHelper.hxx"
28 #include "ChartTypeHelper.hxx"
29 #include "StatisticsHelper.hxx"
31 #include "GraphicPropertyItemConverter.hxx"
32 #include <unonames.hxx>
34 #include <svl/stritem.hxx>
35 #include <svx/chrtitem.hxx>
36 #include <svl/intitem.hxx>
37 #include <rtl/math.hxx>
39 #include <com/sun/star/chart2/DataPointLabel.hpp>
40 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
41 #include <com/sun/star/chart/ErrorBarStyle.hpp>
42 #include <com/sun/star/lang/XServiceName.hpp>
48 using namespace ::com::sun::star
;
53 uno::Reference
< beans::XPropertySet
> lcl_GetErrorBar(
54 const uno::Reference
< beans::XPropertySet
> & xProp
, bool bYError
)
56 uno::Reference
< beans::XPropertySet
> xResult
;
61 ( xProp
->getPropertyValue( bYError
? OUString(CHART_UNONAME_ERRORBAR_Y
) : OUString(CHART_UNONAME_ERRORBAR_X
) ) >>= xResult
);
63 catch( const uno::Exception
& ex
)
65 ASSERT_EXCEPTION( ex
);
71 uno::Reference
< beans::XPropertySet
> lcl_GetDefaultErrorBar()
73 // todo: use a valid context
74 return uno::Reference
< beans::XPropertySet
>(
75 ::chart::createErrorBar( uno::Reference
< uno::XComponentContext
>()));
78 void lcl_getErrorValues( const uno::Reference
< beans::XPropertySet
> & xErrorBarProp
,
79 double & rOutPosError
, double & rOutNegError
)
81 if( ! xErrorBarProp
.is())
86 xErrorBarProp
->getPropertyValue( "PositiveError" ) >>= rOutPosError
;
87 xErrorBarProp
->getPropertyValue( "NegativeError" ) >>= rOutNegError
;
89 catch( const uno::Exception
& ex
)
91 ASSERT_EXCEPTION( ex
);
95 void lcl_getErrorIndicatorValues(
96 const uno::Reference
< beans::XPropertySet
> & xErrorBarProp
,
97 bool & rOutShowPosError
, bool & rOutShowNegError
)
99 if( ! xErrorBarProp
.is())
104 xErrorBarProp
->getPropertyValue( "ShowPositiveError" ) >>= rOutShowPosError
;
105 xErrorBarProp
->getPropertyValue( "ShowNegativeError" ) >>= rOutShowNegError
;
107 catch( const uno::Exception
& ex
)
109 ASSERT_EXCEPTION( ex
);
113 uno::Reference
< beans::XPropertySet
> lcl_getEquationProperties(
114 const uno::Reference
< beans::XPropertySet
> & xSeriesPropSet
, const SfxItemSet
* pItemSet
)
116 bool bEquationExists
= true;
118 // ensure that a trendline is on
121 SvxChartRegress eRegress
= CHREGRESS_NONE
;
122 const SfxPoolItem
*pPoolItem
= NULL
;
123 if( pItemSet
->GetItemState( SCHATTR_REGRESSION_TYPE
, true, &pPoolItem
) == SfxItemState::SET
)
125 eRegress
= static_cast< const SvxChartRegressItem
* >( pPoolItem
)->GetValue();
126 bEquationExists
= ( eRegress
!= CHREGRESS_NONE
);
130 if( bEquationExists
)
132 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCnt( xSeriesPropSet
, uno::UNO_QUERY
);
133 uno::Reference
< chart2::XRegressionCurve
> xCurve(
134 ::chart::RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt
));
137 return xCurve
->getEquationProperties();
141 return uno::Reference
< beans::XPropertySet
>();
144 uno::Reference
< beans::XPropertySet
> lcl_getCurveProperties(
145 const uno::Reference
< beans::XPropertySet
> & xSeriesPropSet
, const SfxItemSet
* pItemSet
)
149 // ensure that a trendline is on
152 SvxChartRegress eRegress
= CHREGRESS_NONE
;
153 const SfxPoolItem
*pPoolItem
= NULL
;
154 if( pItemSet
->GetItemState( SCHATTR_REGRESSION_TYPE
, true, &pPoolItem
) == SfxItemState::SET
)
156 eRegress
= static_cast< const SvxChartRegressItem
* >( pPoolItem
)->GetValue();
157 bExists
= ( eRegress
!= CHREGRESS_NONE
);
163 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCnt( xSeriesPropSet
, uno::UNO_QUERY
);
164 uno::Reference
< chart2::XRegressionCurve
> xCurve(
165 ::chart::RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt
));
168 uno::Reference
< beans::XPropertySet
> xProperties( xCurve
, uno::UNO_QUERY
);
173 return uno::Reference
< beans::XPropertySet
>();
176 template <class T
, class D
>
177 bool lclConvertToPropertySet(const SfxItemSet
& rItemSet
, sal_uInt16 nWhichId
, uno::Reference
<beans::XPropertySet
> xProperties
, const OUString
& aPropertyID
)
179 OSL_ASSERT(xProperties
.is());
180 if( xProperties
.is() )
182 T aValue
= static_cast<T
>(static_cast<const D
&>(rItemSet
.Get( nWhichId
)).GetValue());
183 T aOldValue
= aValue
;
184 bool aSuccess
= xProperties
->getPropertyValue( aPropertyID
) >>= aOldValue
;
185 if (!aSuccess
|| aOldValue
!= aValue
)
187 xProperties
->setPropertyValue( aPropertyID
, uno::makeAny( aValue
));
194 template <class T
, class D
>
195 void lclConvertToItemSet(SfxItemSet
& rItemSet
, sal_uInt16 nWhichId
, uno::Reference
<beans::XPropertySet
> xProperties
, const OUString
& aPropertyID
)
197 OSL_ASSERT(xProperties
.is());
198 if( xProperties
.is() )
200 T aValue
= static_cast<T
>(static_cast<const D
&>(rItemSet
.Get( nWhichId
)).GetValue());
201 if(xProperties
->getPropertyValue( aPropertyID
) >>= aValue
)
203 rItemSet
.Put(D( nWhichId
, aValue
));
208 void lclConvertToItemSetDouble(SfxItemSet
& rItemSet
, sal_uInt16 nWhichId
, uno::Reference
<beans::XPropertySet
> xProperties
, const OUString
& aPropertyID
)
210 OSL_ASSERT(xProperties
.is());
211 if( xProperties
.is() )
213 double aValue
= static_cast<double>(static_cast<const SvxDoubleItem
&>(rItemSet
.Get( nWhichId
)).GetValue());
214 if(xProperties
->getPropertyValue( aPropertyID
) >>= aValue
)
216 rItemSet
.Put(SvxDoubleItem( aValue
, nWhichId
));
221 } // anonymous namespace
228 StatisticsItemConverter::StatisticsItemConverter(
229 const uno::Reference
< frame::XModel
> & xModel
,
230 const uno::Reference
< beans::XPropertySet
> & rPropertySet
,
231 SfxItemPool
& rItemPool
) :
232 ItemConverter( rPropertySet
, rItemPool
),
237 StatisticsItemConverter::~StatisticsItemConverter()
241 const sal_uInt16
* StatisticsItemConverter::GetWhichPairs() const
243 // must span all used items!
244 return nStatWhichPairs
;
247 bool StatisticsItemConverter::GetItemProperty(
248 tWhichIdType
/* nWhichId */,
249 tPropertyNameWithMemberId
& /* rOutProperty */ ) const
254 bool StatisticsItemConverter::ApplySpecialItem(
255 sal_uInt16 nWhichId
, const SfxItemSet
& rItemSet
)
256 throw( uno::Exception
)
258 bool bChanged
= false;
262 case SCHATTR_STAT_AVERAGE
:
264 uno::Reference
< chart2::XRegressionCurveContainer
> xRegCnt(
265 GetPropertySet(), uno::UNO_QUERY
);
266 bool bOldHasMeanValueLine
= RegressionCurveHelper::hasMeanValueLine( xRegCnt
);
268 bool bNewHasMeanValueLine
=
269 static_cast< const SfxBoolItem
& >( rItemSet
.Get( nWhichId
)).GetValue();
271 if( bOldHasMeanValueLine
!= bNewHasMeanValueLine
)
273 if( ! bNewHasMeanValueLine
)
274 RegressionCurveHelper::removeMeanValueLine( xRegCnt
);
276 RegressionCurveHelper::addMeanValueLine(
277 xRegCnt
, uno::Reference
< uno::XComponentContext
>(), GetPropertySet() );
283 // Attention !!! This case must be passed before SCHATTR_STAT_PERCENT,
284 // SCHATTR_STAT_BIGERROR, SCHATTR_STAT_CONSTPLUS,
285 // SCHATTR_STAT_CONSTMINUS and SCHATTR_STAT_INDICATE
286 case SCHATTR_STAT_KIND_ERROR
:
289 static_cast<const SfxBoolItem
&>(rItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
)).GetValue();
291 uno::Reference
< beans::XPropertySet
> xErrorBarProp(
292 lcl_GetErrorBar( GetPropertySet(), bYError
));
294 SvxChartKindError eErrorKind
=
295 static_cast< const SvxChartKindErrorItem
& >(
296 rItemSet
.Get( nWhichId
)).GetValue();
298 if( !xErrorBarProp
.is() && eErrorKind
== CHERROR_NONE
)
304 sal_Int32 nStyle
= ::com::sun::star::chart::ErrorBarStyle::NONE
;
309 nStyle
= ::com::sun::star::chart::ErrorBarStyle::NONE
; break;
310 case CHERROR_VARIANT
:
311 nStyle
= ::com::sun::star::chart::ErrorBarStyle::VARIANCE
; break;
313 nStyle
= ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION
; break;
314 case CHERROR_PERCENT
:
315 nStyle
= ::com::sun::star::chart::ErrorBarStyle::RELATIVE
; break;
316 case CHERROR_BIGERROR
:
317 nStyle
= ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN
; break;
319 nStyle
= ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE
; break;
320 case CHERROR_STDERROR
:
321 nStyle
= ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR
; break;
323 nStyle
= ::com::sun::star::chart::ErrorBarStyle::FROM_DATA
; break;
326 if( !xErrorBarProp
.is() )
328 xErrorBarProp
= lcl_GetDefaultErrorBar();
329 GetPropertySet()->setPropertyValue( bYError
? OUString(CHART_UNONAME_ERRORBAR_Y
) : OUString(CHART_UNONAME_ERRORBAR_X
),
330 uno::makeAny( xErrorBarProp
));
333 xErrorBarProp
->setPropertyValue( "ErrorBarStyle" , uno::makeAny( nStyle
));
339 case SCHATTR_STAT_PERCENT
:
340 case SCHATTR_STAT_BIGERROR
:
342 OSL_FAIL( "Deprecated item" );
344 static_cast<const SfxBoolItem
&>(rItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
)).GetValue();
346 uno::Reference
< beans::XPropertySet
> xErrorBarProp(
347 lcl_GetErrorBar( GetPropertySet(), bYError
));
348 bool bOldHasErrorBar
= xErrorBarProp
.is();
351 static_cast< const SvxDoubleItem
& >(
352 rItemSet
.Get( nWhichId
)).GetValue();
353 double fPos(0.0), fNeg(0.0);
354 lcl_getErrorValues( xErrorBarProp
, fPos
, fNeg
);
356 if( bOldHasErrorBar
&&
357 ! ( ::rtl::math::approxEqual( fPos
, fValue
) &&
358 ::rtl::math::approxEqual( fNeg
, fValue
)))
360 xErrorBarProp
->setPropertyValue( "PositiveError" , uno::makeAny( fValue
));
361 xErrorBarProp
->setPropertyValue( "NegativeError" , uno::makeAny( fValue
));
367 case SCHATTR_STAT_CONSTPLUS
:
370 static_cast<const SfxBoolItem
&>(rItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
)).GetValue();
372 uno::Reference
< beans::XPropertySet
> xErrorBarProp(
373 lcl_GetErrorBar( GetPropertySet(),bYError
));
374 bool bOldHasErrorBar
= xErrorBarProp
.is();
377 static_cast< const SvxDoubleItem
& >(
378 rItemSet
.Get( nWhichId
)).GetValue();
379 double fPos(0.0), fNeg(0.0);
380 lcl_getErrorValues( xErrorBarProp
, fPos
, fNeg
);
382 if( bOldHasErrorBar
&&
383 ! ::rtl::math::approxEqual( fPos
, fValue
))
385 xErrorBarProp
->setPropertyValue( "PositiveError" , uno::makeAny( fValue
));
391 case SCHATTR_STAT_CONSTMINUS
:
394 static_cast<const SfxBoolItem
&>(rItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
)).GetValue();
395 uno::Reference
< beans::XPropertySet
> xErrorBarProp(
396 lcl_GetErrorBar( GetPropertySet(),bYError
));
397 bool bOldHasErrorBar
= xErrorBarProp
.is();
400 static_cast< const SvxDoubleItem
& >(
401 rItemSet
.Get( nWhichId
)).GetValue();
402 double fPos(0.0), fNeg(0.0);
403 lcl_getErrorValues( xErrorBarProp
, fPos
, fNeg
);
405 if( bOldHasErrorBar
&&
406 ! ::rtl::math::approxEqual( fNeg
, fValue
))
408 xErrorBarProp
->setPropertyValue( "NegativeError" , uno::makeAny( fValue
));
414 case SCHATTR_REGRESSION_TYPE
:
416 SvxChartRegress eRegress
=
417 static_cast< const SvxChartRegressItem
& >(
418 rItemSet
.Get( nWhichId
)).GetValue();
420 uno::Reference
< chart2::XRegressionCurve
> xCurve( GetPropertySet(), uno::UNO_QUERY
);
421 uno::Reference
< chart2::XRegressionCurveContainer
> xContainer( GetPropertySet(), uno::UNO_QUERY
);
423 if( eRegress
== CHREGRESS_NONE
)
425 if ( xContainer
.is() )
427 xContainer
->removeRegressionCurve( xCurve
);
435 SvxChartRegress
eOldRegress(
436 RegressionCurveHelper::getRegressionType(xCurve
));
438 if( eOldRegress
!= eRegress
)
440 xCurve
= RegressionCurveHelper::changeRegressionCurveType(
444 uno::Reference
< uno::XComponentContext
>());
445 uno::Reference
< beans::XPropertySet
> xProperties( xCurve
, uno::UNO_QUERY
);
446 resetPropertySet( xProperties
);
454 case SCHATTR_REGRESSION_DEGREE
:
456 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
457 bChanged
= lclConvertToPropertySet
<sal_Int32
, SfxInt32Item
>(rItemSet
, nWhichId
, xProperties
, "PolynomialDegree");
461 case SCHATTR_REGRESSION_PERIOD
:
463 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
464 bChanged
= lclConvertToPropertySet
<sal_Int32
, SfxInt32Item
>(rItemSet
, nWhichId
, xProperties
, "MovingAveragePeriod");
468 case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD
:
470 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
471 bChanged
= lclConvertToPropertySet
<double, SvxDoubleItem
>(rItemSet
, nWhichId
, xProperties
, "ExtrapolateForward");
475 case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD
:
477 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
478 bChanged
= lclConvertToPropertySet
<double, SvxDoubleItem
>(rItemSet
, nWhichId
, xProperties
, "ExtrapolateBackward");
482 case SCHATTR_REGRESSION_SET_INTERCEPT
:
484 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
485 bChanged
= lclConvertToPropertySet
<sal_Bool
, SfxBoolItem
>(rItemSet
, nWhichId
, xProperties
, "ForceIntercept");
489 case SCHATTR_REGRESSION_INTERCEPT_VALUE
:
491 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
492 bChanged
= lclConvertToPropertySet
<double, SvxDoubleItem
>(rItemSet
, nWhichId
, xProperties
, "InterceptValue");
496 case SCHATTR_REGRESSION_CURVE_NAME
:
498 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet
));
499 bChanged
= lclConvertToPropertySet
<OUString
, SfxStringItem
>(rItemSet
, nWhichId
, xProperties
, "CurveName");
503 case SCHATTR_REGRESSION_SHOW_EQUATION
:
505 uno::Reference
< beans::XPropertySet
> xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet
));
506 bChanged
= lclConvertToPropertySet
<sal_Bool
, SfxBoolItem
>(rItemSet
, nWhichId
, xEqProp
, "ShowEquation");
510 case SCHATTR_REGRESSION_SHOW_COEFF
:
512 uno::Reference
< beans::XPropertySet
> xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet
));
513 bChanged
= lclConvertToPropertySet
<sal_Bool
, SfxBoolItem
>(rItemSet
, nWhichId
, xEqProp
, "ShowCorrelationCoefficient");
517 case SCHATTR_STAT_INDICATE
:
520 static_cast<const SfxBoolItem
&>(rItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
)).GetValue();
521 uno::Reference
< beans::XPropertySet
> xErrorBarProp(
522 lcl_GetErrorBar( GetPropertySet(),bYError
));
523 bool bOldHasErrorBar
= xErrorBarProp
.is();
525 SvxChartIndicate eIndicate
=
526 static_cast< const SvxChartIndicateItem
& >(
527 rItemSet
.Get( nWhichId
)).GetValue();
529 bool bNewIndPos
= (eIndicate
== CHINDICATE_BOTH
|| eIndicate
== CHINDICATE_UP
);
530 bool bNewIndNeg
= (eIndicate
== CHINDICATE_BOTH
|| eIndicate
== CHINDICATE_DOWN
);
532 bool bShowPos(false), bShowNeg(false);
533 lcl_getErrorIndicatorValues( xErrorBarProp
, bShowPos
, bShowNeg
);
535 if( bOldHasErrorBar
&&
536 ( bShowPos
!= bNewIndPos
||
537 bShowNeg
!= bNewIndNeg
))
539 xErrorBarProp
->setPropertyValue( "ShowPositiveError" , uno::makeAny( bNewIndPos
));
540 xErrorBarProp
->setPropertyValue( "ShowNegativeError" , uno::makeAny( bNewIndNeg
));
546 case SCHATTR_STAT_RANGE_POS
:
547 case SCHATTR_STAT_RANGE_NEG
:
550 static_cast<const SfxBoolItem
&>(rItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
)).GetValue();
551 uno::Reference
< chart2::data::XDataSource
> xErrorBarSource( lcl_GetErrorBar( GetPropertySet(), bYError
),
553 uno::Reference
< chart2::XChartDocument
> xChartDoc( m_xModel
, uno::UNO_QUERY
);
554 uno::Reference
< chart2::data::XDataProvider
> xDataProvider
;
557 xDataProvider
.set( xChartDoc
->getDataProvider());
558 if( xErrorBarSource
.is() && xDataProvider
.is())
560 OUString
aNewRange( static_cast< const SfxStringItem
& >( rItemSet
.Get( nWhichId
)).GetValue());
561 bool bApplyNewRange
= false;
563 bool bIsPositiveValue( nWhichId
== SCHATTR_STAT_RANGE_POS
);
564 if( xChartDoc
->hasInternalDataProvider())
566 if( !aNewRange
.isEmpty())
568 uno::Reference
< chart2::data::XDataSequence
> xSeq(
569 StatisticsHelper::getErrorDataSequenceFromDataSource(
570 xErrorBarSource
, bIsPositiveValue
, bYError
));
573 // no data range for error bars yet => create
574 uno::Reference
< chart2::XInternalDataProvider
> xIntDataProvider( xDataProvider
, uno::UNO_QUERY
);
575 OSL_ASSERT( xIntDataProvider
.is());
576 if( xIntDataProvider
.is())
578 xIntDataProvider
->appendSequence();
580 bApplyNewRange
= true;
587 uno::Reference
< chart2::data::XDataSequence
> xSeq(
588 StatisticsHelper::getErrorDataSequenceFromDataSource(
589 xErrorBarSource
, bIsPositiveValue
, bYError
));
591 ! ( xSeq
.is() && (aNewRange
== xSeq
->getSourceRangeRepresentation()));
595 StatisticsHelper::setErrorDataSequence(
596 xErrorBarSource
, xDataProvider
, aNewRange
, bIsPositiveValue
, bYError
);
605 void StatisticsItemConverter::FillSpecialItem(
606 sal_uInt16 nWhichId
, SfxItemSet
& rOutItemSet
) const
607 throw( uno::Exception
)
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 static_cast<const SfxBoolItem
&>(rOutItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
)).GetValue();
623 SvxChartKindError eErrorKind
= CHERROR_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( "ErrorBarStyle" ) >>= nStyle
)
633 case ::com::sun::star::chart::ErrorBarStyle::NONE
:
635 case ::com::sun::star::chart::ErrorBarStyle::VARIANCE
:
636 eErrorKind
= CHERROR_VARIANT
; break;
637 case ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION
:
638 eErrorKind
= CHERROR_SIGMA
; break;
639 case ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE
:
640 eErrorKind
= CHERROR_CONST
; break;
641 case ::com::sun::star::chart::ErrorBarStyle::RELATIVE
:
642 eErrorKind
= CHERROR_PERCENT
; break;
643 case ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN
:
644 eErrorKind
= CHERROR_BIGERROR
; break;
645 case ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR
:
646 eErrorKind
= CHERROR_STDERROR
; break;
647 case ::com::sun::star::chart::ErrorBarStyle::FROM_DATA
:
648 eErrorKind
= CHERROR_RANGE
; break;
652 rOutItemSet
.Put( SvxChartKindErrorItem( eErrorKind
, SCHATTR_STAT_KIND_ERROR
));
656 case SCHATTR_STAT_PERCENT
:
659 static_cast<const SfxBoolItem
&>(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, nWhichId
));
670 case SCHATTR_STAT_BIGERROR
:
673 static_cast<const SfxBoolItem
&>(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, nWhichId
));
684 case SCHATTR_STAT_CONSTPLUS
:
687 static_cast<const SfxBoolItem
&>(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
, nWhichId
));
698 case SCHATTR_STAT_CONSTMINUS
:
701 static_cast<const SfxBoolItem
&>(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
, nWhichId
));
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(), 0 ));
726 lclConvertToItemSet
<sal_Int32
, SfxInt32Item
>(rOutItemSet
, nWhichId
, xProperties
, "PolynomialDegree");
730 case SCHATTR_REGRESSION_PERIOD
:
732 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
733 lclConvertToItemSet
<sal_Int32
, SfxInt32Item
>(rOutItemSet
, nWhichId
, xProperties
, "MovingAveragePeriod");
737 case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD
:
739 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
740 lclConvertToItemSetDouble(rOutItemSet
, nWhichId
, xProperties
, "ExtrapolateForward");
744 case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD
:
746 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
747 lclConvertToItemSetDouble(rOutItemSet
, nWhichId
, xProperties
, "ExtrapolateBackward");
751 case SCHATTR_REGRESSION_SET_INTERCEPT
:
753 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
754 lclConvertToItemSet
<sal_Bool
, SfxBoolItem
>(rOutItemSet
, nWhichId
, xProperties
, "ForceIntercept");
758 case SCHATTR_REGRESSION_INTERCEPT_VALUE
:
760 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
761 lclConvertToItemSetDouble(rOutItemSet
, nWhichId
, xProperties
, "InterceptValue");
765 case SCHATTR_REGRESSION_CURVE_NAME
:
767 uno::Reference
< beans::XPropertySet
> xProperties( lcl_getCurveProperties( GetPropertySet(), 0 ));
768 lclConvertToItemSet
<OUString
, SfxStringItem
>(rOutItemSet
, nWhichId
, xProperties
, "CurveName");
772 case SCHATTR_REGRESSION_SHOW_EQUATION
:
774 uno::Reference
< beans::XPropertySet
> xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 ));
775 lclConvertToItemSet
<sal_Bool
, SfxBoolItem
>(rOutItemSet
, nWhichId
, xEqProp
, "ShowEquation");
779 case SCHATTR_REGRESSION_SHOW_COEFF
:
781 uno::Reference
< beans::XPropertySet
> xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 ));
782 lclConvertToItemSet
<sal_Bool
, SfxBoolItem
>(rOutItemSet
, nWhichId
, xEqProp
, "ShowCorrelationCoefficient");
786 case SCHATTR_STAT_INDICATE
:
789 static_cast<const SfxBoolItem
&>(rOutItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
)).GetValue();
790 uno::Reference
< beans::XPropertySet
> xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError
));
791 SvxChartIndicate eIndicate
= CHINDICATE_BOTH
;
792 if( xErrorBarProp
.is())
794 bool bShowPos(false), bShowNeg(false);
795 lcl_getErrorIndicatorValues( xErrorBarProp
, bShowPos
, bShowNeg
);
800 eIndicate
= CHINDICATE_BOTH
;
802 eIndicate
= CHINDICATE_UP
;
807 eIndicate
= CHINDICATE_DOWN
;
809 eIndicate
= CHINDICATE_NONE
;
812 rOutItemSet
.Put( SvxChartIndicateItem( eIndicate
, SCHATTR_STAT_INDICATE
));
816 case SCHATTR_STAT_RANGE_POS
:
817 case SCHATTR_STAT_RANGE_NEG
:
820 static_cast<const SfxBoolItem
&>(rOutItemSet
.Get(SCHATTR_STAT_ERRORBAR_TYPE
)).GetValue();
821 uno::Reference
< chart2::data::XDataSource
> xErrorBarSource( lcl_GetErrorBar( GetPropertySet(),bYError
),
823 if( xErrorBarSource
.is())
825 uno::Reference
< chart2::data::XDataSequence
> xSeq(
826 StatisticsHelper::getErrorDataSequenceFromDataSource(
827 xErrorBarSource
, (nWhichId
== SCHATTR_STAT_RANGE_POS
), bYError
));
829 rOutItemSet
.Put( SfxStringItem( nWhichId
, xSeq
->getSourceRangeRepresentation()));
836 } // namespace wrapper
839 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */