Update ooo320-m1
[ooovba.git] / chart2 / source / controller / itemsetwrapper / StatisticsItemConverter.cxx
blobf078ebc915b55a2cb1ac004e6cb601086b25f5a9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: StatisticsItemConverter.cxx,v $
10 * $Revision: 1.22 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
33 #include "StatisticsItemConverter.hxx"
34 #include "SchWhichPairs.hxx"
35 #include "macros.hxx"
36 #include "RegressionCurveHelper.hxx"
37 #include "ItemPropertyMap.hxx"
38 #include "ErrorBar.hxx"
39 #include "PropertyHelper.hxx"
40 #include "ChartModelHelper.hxx"
41 #include "ChartTypeHelper.hxx"
42 #include "StatisticsHelper.hxx"
44 #include "GraphicPropertyItemConverter.hxx"
46 #include <svtools/stritem.hxx>
47 #include <svx/chrtitem.hxx>
48 #include <svtools/intitem.hxx>
49 #include <rtl/math.hxx>
51 #include <com/sun/star/chart2/DataPointLabel.hpp>
52 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
53 #include <com/sun/star/chart/ErrorBarStyle.hpp>
54 #include <com/sun/star/lang/XServiceName.hpp>
56 #include <functional>
57 #include <algorithm>
58 #include <vector>
60 using namespace ::com::sun::star;
62 namespace
65 uno::Reference< beans::XPropertySet > lcl_GetYErrorBar(
66 const uno::Reference< beans::XPropertySet > & xProp )
68 uno::Reference< beans::XPropertySet > xResult;
70 if( xProp.is())
71 try
73 ( xProp->getPropertyValue( C2U( "ErrorBarY" )) >>= xResult );
75 catch( uno::Exception & ex )
77 ASSERT_EXCEPTION( ex );
80 return xResult;
83 ::chart::RegressionCurveHelper::tRegressionType lcl_convertRegressionType( SvxChartRegress eRegress )
85 ::chart::RegressionCurveHelper::tRegressionType eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_NONE;
86 switch( eRegress )
88 case CHREGRESS_LINEAR:
89 eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LINEAR;
90 break;
91 case CHREGRESS_LOG:
92 eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LOG;
93 break;
94 case CHREGRESS_EXP:
95 eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_EXP;
96 break;
97 case CHREGRESS_POWER:
98 eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POWER;
99 break;
100 case CHREGRESS_NONE:
101 break;
103 return eType;
107 uno::Reference< beans::XPropertySet > lcl_GetDefaultErrorBar()
109 // todo: use a valid context
110 return uno::Reference< beans::XPropertySet >(
111 ::chart::createErrorBar( uno::Reference< uno::XComponentContext >()));
114 void lcl_getErrorValues( const uno::Reference< beans::XPropertySet > & xErrorBarProp,
115 double & rOutPosError, double & rOutNegError )
117 if( ! xErrorBarProp.is())
118 return;
122 xErrorBarProp->getPropertyValue( C2U( "PositiveError" )) >>= rOutPosError;
123 xErrorBarProp->getPropertyValue( C2U( "NegativeError" )) >>= rOutNegError;
125 catch( uno::Exception & ex )
127 ASSERT_EXCEPTION( ex );
131 void lcl_getErrorIndicatorValues(
132 const uno::Reference< beans::XPropertySet > & xErrorBarProp,
133 bool & rOutShowPosError, bool & rOutShowNegError )
135 if( ! xErrorBarProp.is())
136 return;
140 xErrorBarProp->getPropertyValue( C2U( "ShowPositiveError" )) >>= rOutShowPosError;
141 xErrorBarProp->getPropertyValue( C2U( "ShowNegativeError" )) >>= rOutShowNegError;
143 catch( uno::Exception & ex )
145 ASSERT_EXCEPTION( ex );
149 uno::Reference< beans::XPropertySet > lcl_getEquationProperties(
150 const uno::Reference< beans::XPropertySet > & xSeriesPropSet, const SfxItemSet * pItemSet )
152 bool bEquationExists = true;
154 // ensure that a trendline is on
155 if( pItemSet )
157 SvxChartRegress eRegress = CHREGRESS_NONE;
158 const SfxPoolItem *pPoolItem = NULL;
159 if( pItemSet->GetItemState( SCHATTR_REGRESSION_TYPE, TRUE, &pPoolItem ) == SFX_ITEM_SET )
161 eRegress = static_cast< const SvxChartRegressItem * >( pPoolItem )->GetValue();
162 bEquationExists = ( eRegress != CHREGRESS_NONE );
166 if( bEquationExists )
168 uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropSet, uno::UNO_QUERY );
169 uno::Reference< chart2::XRegressionCurve > xCurve(
170 ::chart::RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt ));
171 if( xCurve.is())
173 return xCurve->getEquationProperties();
177 return uno::Reference< beans::XPropertySet >();
180 } // anonymous namespace
182 namespace chart
184 namespace wrapper
187 StatisticsItemConverter::StatisticsItemConverter(
188 const uno::Reference< frame::XModel > & xModel,
189 const uno::Reference< beans::XPropertySet > & rPropertySet,
190 SfxItemPool& rItemPool ) :
191 ItemConverter( rPropertySet, rItemPool ),
192 m_xModel( xModel )
194 OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_NONE ) ==
195 static_cast< int >( CHREGRESS_NONE ));
196 OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_LINEAR ) ==
197 static_cast< int >( CHREGRESS_LINEAR ));
198 OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_LOG ) ==
199 static_cast< int >( CHREGRESS_LOG ));
200 OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_EXP ) ==
201 static_cast< int >( CHREGRESS_EXP ));
202 OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_POWER ) ==
203 static_cast< int >( CHREGRESS_POWER ));
206 StatisticsItemConverter::~StatisticsItemConverter()
209 const USHORT * StatisticsItemConverter::GetWhichPairs() const
211 // must span all used items!
212 return nStatWhichPairs;
215 bool StatisticsItemConverter::GetItemProperty(
216 tWhichIdType /* nWhichId */,
217 tPropertyNameWithMemberId & /* rOutProperty */ ) const
219 return false;
222 bool StatisticsItemConverter::ApplySpecialItem(
223 USHORT nWhichId, const SfxItemSet & rItemSet )
224 throw( uno::Exception )
226 bool bChanged = false;
227 uno::Any aValue;
229 switch( nWhichId )
231 case SCHATTR_STAT_AVERAGE:
233 uno::Reference< chart2::XRegressionCurveContainer > xRegCnt(
234 GetPropertySet(), uno::UNO_QUERY );
235 bool bOldHasMeanValueLine = RegressionCurveHelper::hasMeanValueLine( xRegCnt );
237 bool bNewHasMeanValueLine =
238 static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
240 if( bOldHasMeanValueLine != bNewHasMeanValueLine )
242 if( ! bNewHasMeanValueLine )
243 RegressionCurveHelper::removeMeanValueLine( xRegCnt );
244 else
245 RegressionCurveHelper::addMeanValueLine(
246 xRegCnt, uno::Reference< uno::XComponentContext >(), GetPropertySet() );
247 bChanged = true;
250 break;
252 // Attention !!! This case must be passed before SCHATTR_STAT_PERCENT,
253 // SCHATTR_STAT_BIGERROR, SCHATTR_STAT_CONSTPLUS,
254 // SCHATTR_STAT_CONSTMINUS and SCHATTR_STAT_INDICATE
255 case SCHATTR_STAT_KIND_ERROR:
257 uno::Reference< beans::XPropertySet > xErrorBarProp(
258 lcl_GetYErrorBar( GetPropertySet() ));
260 SvxChartKindError eErrorKind =
261 static_cast< const SvxChartKindErrorItem & >(
262 rItemSet.Get( nWhichId )).GetValue();
264 if( !xErrorBarProp.is() && eErrorKind == CHERROR_NONE)
266 //nothing to do
268 else
270 sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
272 switch( eErrorKind )
274 case CHERROR_NONE:
275 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; break;
276 case CHERROR_VARIANT:
277 nStyle = ::com::sun::star::chart::ErrorBarStyle::VARIANCE; break;
278 case CHERROR_SIGMA:
279 nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION; break;
280 case CHERROR_PERCENT:
281 nStyle = ::com::sun::star::chart::ErrorBarStyle::RELATIVE; break;
282 case CHERROR_BIGERROR:
283 nStyle = ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN; break;
284 case CHERROR_CONST:
285 nStyle = ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE; break;
286 case CHERROR_STDERROR:
287 nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR; break;
288 case CHERROR_RANGE:
289 nStyle = ::com::sun::star::chart::ErrorBarStyle::FROM_DATA; break;
292 if( !xErrorBarProp.is() )
294 xErrorBarProp = lcl_GetDefaultErrorBar();
295 GetPropertySet()->setPropertyValue(
296 C2U( "ErrorBarY" ), uno::makeAny( xErrorBarProp ));
299 xErrorBarProp->setPropertyValue( C2U( "ErrorBarStyle" ),
300 uno::makeAny( nStyle ));
301 bChanged = true;
304 break;
306 case SCHATTR_STAT_PERCENT:
307 case SCHATTR_STAT_BIGERROR:
309 OSL_ENSURE( false, "Deprectaed item" );
310 uno::Reference< beans::XPropertySet > xErrorBarProp(
311 lcl_GetYErrorBar( GetPropertySet()));
312 bool bOldHasErrorBar = xErrorBarProp.is();
314 double fValue =
315 static_cast< const SvxDoubleItem & >(
316 rItemSet.Get( nWhichId )).GetValue();
317 double fPos, fNeg;
318 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
320 if( bOldHasErrorBar &&
321 ! ( ::rtl::math::approxEqual( fPos, fValue ) &&
322 ::rtl::math::approxEqual( fNeg, fValue )))
324 xErrorBarProp->setPropertyValue( C2U( "PositiveError" ),
325 uno::makeAny( fValue ));
326 xErrorBarProp->setPropertyValue( C2U( "NegativeError" ),
327 uno::makeAny( fValue ));
328 bChanged = true;
331 break;
333 case SCHATTR_STAT_CONSTPLUS:
335 uno::Reference< beans::XPropertySet > xErrorBarProp(
336 lcl_GetYErrorBar( GetPropertySet()));
337 bool bOldHasErrorBar = xErrorBarProp.is();
339 double fValue =
340 static_cast< const SvxDoubleItem & >(
341 rItemSet.Get( nWhichId )).GetValue();
342 double fPos, fNeg;
343 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
345 if( bOldHasErrorBar &&
346 ! ::rtl::math::approxEqual( fPos, fValue ))
348 xErrorBarProp->setPropertyValue( C2U( "PositiveError" ), uno::makeAny( fValue ));
349 bChanged = true;
352 break;
354 case SCHATTR_STAT_CONSTMINUS:
356 uno::Reference< beans::XPropertySet > xErrorBarProp(
357 lcl_GetYErrorBar( GetPropertySet()));
358 bool bOldHasErrorBar = xErrorBarProp.is();
360 double fValue =
361 static_cast< const SvxDoubleItem & >(
362 rItemSet.Get( nWhichId )).GetValue();
363 double fPos, fNeg;
364 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
366 if( bOldHasErrorBar &&
367 ! ::rtl::math::approxEqual( fNeg, fValue ))
369 xErrorBarProp->setPropertyValue( C2U( "NegativeError" ), uno::makeAny( fValue ));
370 bChanged = true;
373 break;
375 case SCHATTR_REGRESSION_TYPE:
377 SvxChartRegress eRegress =
378 static_cast< const SvxChartRegressItem & >(
379 rItemSet.Get( nWhichId )).GetValue();
381 uno::Reference< chart2::XRegressionCurveContainer > xRegCnt(
382 GetPropertySet(), uno::UNO_QUERY );
384 if( eRegress == CHREGRESS_NONE )
386 bChanged = RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCnt );
388 else
390 SvxChartRegress eOldRegress(
391 static_cast< SvxChartRegress >(
392 static_cast< sal_Int32 >(
393 RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( xRegCnt ))));
394 if( eOldRegress != eRegress )
396 RegressionCurveHelper::replaceOrAddCurveAndReduceToOne(
397 lcl_convertRegressionType( eRegress ), xRegCnt,
398 uno::Reference< uno::XComponentContext >());
399 bChanged = true;
403 break;
405 case SCHATTR_REGRESSION_SHOW_EQUATION:
407 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
408 if( xEqProp.is())
410 bool bShowEq = false;
411 xEqProp->getPropertyValue( C2U("ShowEquation")) >>= bShowEq;
412 bool bNewShowEq =
413 static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
414 if( bShowEq != bNewShowEq )
416 xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( bNewShowEq ));
417 bChanged = true;
421 break;
423 case SCHATTR_REGRESSION_SHOW_COEFF:
425 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
426 if( xEqProp.is())
428 bool bShowCoeff = false;
429 xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCoeff;
430 bool bNewShowCoeff =
431 static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
432 if( bShowCoeff != bNewShowCoeff )
434 xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bNewShowCoeff ));
435 bChanged = true;
439 break;
441 case SCHATTR_STAT_INDICATE:
443 uno::Reference< beans::XPropertySet > xErrorBarProp(
444 lcl_GetYErrorBar( GetPropertySet()));
445 bool bOldHasErrorBar = xErrorBarProp.is();
447 SvxChartIndicate eIndicate =
448 static_cast< const SvxChartIndicateItem & >(
449 rItemSet.Get( nWhichId )).GetValue();
451 bool bNewIndPos = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_UP );
452 bool bNewIndNeg = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_DOWN );
454 bool bShowPos, bShowNeg;
455 lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg );
457 if( bOldHasErrorBar &&
458 ( bShowPos != bNewIndPos ||
459 bShowNeg != bNewIndNeg ))
461 xErrorBarProp->setPropertyValue( C2U( "ShowPositiveError" ), uno::makeAny( bNewIndPos ));
462 xErrorBarProp->setPropertyValue( C2U( "ShowNegativeError" ), uno::makeAny( bNewIndNeg ));
463 bChanged = true;
466 break;
468 case SCHATTR_STAT_RANGE_POS:
469 case SCHATTR_STAT_RANGE_NEG:
471 // @todo: also be able to deal with x-error bars
472 const bool bYError = true;
473 uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetYErrorBar( GetPropertySet()), uno::UNO_QUERY );
474 uno::Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY );
475 uno::Reference< chart2::data::XDataProvider > xDataProvider;
477 if( xChartDoc.is())
478 xDataProvider.set( xChartDoc->getDataProvider());
479 if( xErrorBarSource.is() && xDataProvider.is())
481 ::rtl::OUString aNewRange( static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue());
482 bool bApplyNewRange = false;
484 bool bIsPositiveValue( nWhichId == SCHATTR_STAT_RANGE_POS );
485 if( xChartDoc->hasInternalDataProvider())
487 if( aNewRange.getLength())
489 uno::Reference< chart2::data::XDataSequence > xSeq(
490 StatisticsHelper::getErrorDataSequenceFromDataSource(
491 xErrorBarSource, bIsPositiveValue, bYError ));
492 if( ! xSeq.is())
494 // no data range for error bars yet => create
495 uno::Reference< chart2::XInternalDataProvider > xIntDataProvider( xDataProvider, uno::UNO_QUERY );
496 OSL_ASSERT( xIntDataProvider.is());
497 if( xIntDataProvider.is())
499 xIntDataProvider->appendSequence();
500 aNewRange = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("last"));
501 bApplyNewRange = true;
506 else
508 uno::Reference< chart2::data::XDataSequence > xSeq(
509 StatisticsHelper::getErrorDataSequenceFromDataSource(
510 xErrorBarSource, bIsPositiveValue, bYError ));
511 bApplyNewRange =
512 ! ( xSeq.is() && aNewRange.equals( xSeq->getSourceRangeRepresentation()));
515 if( bApplyNewRange )
516 StatisticsHelper::setErrorDataSequence(
517 xErrorBarSource, xDataProvider, aNewRange, bIsPositiveValue, bYError );
520 break;
523 return bChanged;
526 void StatisticsItemConverter::FillSpecialItem(
527 USHORT nWhichId, SfxItemSet & rOutItemSet ) const
528 throw( uno::Exception )
530 switch( nWhichId )
532 case SCHATTR_STAT_AVERAGE:
533 rOutItemSet.Put(
534 SfxBoolItem( nWhichId,
535 RegressionCurveHelper::hasMeanValueLine(
536 uno::Reference< chart2::XRegressionCurveContainer >(
537 GetPropertySet(), uno::UNO_QUERY ))));
538 break;
540 case SCHATTR_STAT_KIND_ERROR:
542 SvxChartKindError eErrorKind = CHERROR_NONE;
543 uno::Reference< beans::XPropertySet > xErrorBarProp(
544 lcl_GetYErrorBar( GetPropertySet()));
545 if( xErrorBarProp.is() )
547 sal_Int32 nStyle = 0;
548 if( xErrorBarProp->getPropertyValue( C2U( "ErrorBarStyle" )) >>= nStyle )
550 switch( nStyle )
552 case ::com::sun::star::chart::ErrorBarStyle::NONE:
553 break;
554 case ::com::sun::star::chart::ErrorBarStyle::VARIANCE:
555 eErrorKind = CHERROR_VARIANT; break;
556 case ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION:
557 eErrorKind = CHERROR_SIGMA; break;
558 case ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE:
559 eErrorKind = CHERROR_CONST; break;
560 case ::com::sun::star::chart::ErrorBarStyle::RELATIVE:
561 eErrorKind = CHERROR_PERCENT; break;
562 case ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN:
563 eErrorKind = CHERROR_BIGERROR; break;
564 case ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR:
565 eErrorKind = CHERROR_STDERROR; break;
566 case ::com::sun::star::chart::ErrorBarStyle::FROM_DATA:
567 eErrorKind = CHERROR_RANGE; break;
571 rOutItemSet.Put( SvxChartKindErrorItem( eErrorKind, SCHATTR_STAT_KIND_ERROR ));
573 break;
575 case SCHATTR_STAT_PERCENT:
577 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
578 if( xErrorBarProp.is())
580 double fPos, fNeg;
581 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
582 rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId ));
585 break;
587 case SCHATTR_STAT_BIGERROR:
589 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
590 if( xErrorBarProp.is())
592 double fPos, fNeg;
593 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
594 rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId ));
597 break;
599 case SCHATTR_STAT_CONSTPLUS:
601 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
602 if( xErrorBarProp.is())
604 double fPos, fNeg;
605 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
606 rOutItemSet.Put( SvxDoubleItem( fPos, nWhichId ));
609 break;
611 case SCHATTR_STAT_CONSTMINUS:
613 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
614 if( xErrorBarProp.is())
616 double fPos, fNeg;
617 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
618 rOutItemSet.Put( SvxDoubleItem( fNeg, nWhichId ));
621 break;
623 case SCHATTR_REGRESSION_TYPE:
625 SvxChartRegress eRegress = static_cast< SvxChartRegress >(
626 static_cast< sal_Int32 >(
627 RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine(
628 uno::Reference< chart2::XRegressionCurveContainer >(
629 GetPropertySet(), uno::UNO_QUERY ) )));
630 rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE ));
632 break;
634 case SCHATTR_REGRESSION_SHOW_EQUATION:
636 bool bShowEq = false;
637 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 ));
638 if( xEqProp.is())
639 xEqProp->getPropertyValue( C2U("ShowEquation")) >>= bShowEq;
640 rOutItemSet.Put( SfxBoolItem( nWhichId, bShowEq ));
642 break;
644 case SCHATTR_REGRESSION_SHOW_COEFF:
646 bool bShowCoeff = false;
647 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 ));
648 if( xEqProp.is())
649 xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCoeff;
650 rOutItemSet.Put( SfxBoolItem( nWhichId, bShowCoeff ));
652 break;
654 case SCHATTR_STAT_INDICATE:
656 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
657 SvxChartIndicate eIndicate = CHINDICATE_BOTH;
658 if( xErrorBarProp.is())
660 bool bShowPos, bShowNeg;
661 lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg );
663 if( bShowPos )
665 if( bShowNeg )
666 eIndicate = CHINDICATE_BOTH;
667 else
668 eIndicate = CHINDICATE_UP;
670 else
672 if( bShowNeg )
673 eIndicate = CHINDICATE_DOWN;
674 else
675 eIndicate = CHINDICATE_NONE;
678 rOutItemSet.Put( SvxChartIndicateItem( eIndicate, SCHATTR_STAT_INDICATE ));
680 break;
682 case SCHATTR_STAT_RANGE_POS:
683 case SCHATTR_STAT_RANGE_NEG:
685 uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetYErrorBar( GetPropertySet()), uno::UNO_QUERY );
686 if( xErrorBarSource.is())
688 uno::Reference< chart2::data::XDataSequence > xSeq(
689 StatisticsHelper::getErrorDataSequenceFromDataSource(
690 xErrorBarSource, (nWhichId == SCHATTR_STAT_RANGE_POS) /*, true */ /* y */ ));
691 if( xSeq.is())
692 rOutItemSet.Put( SfxStringItem( nWhichId, String( xSeq->getSourceRangeRepresentation())));
695 break;
699 } // namespace wrapper
700 } // namespace chart