1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
30 #include "StatisticsItemConverter.hxx"
31 #include "SchWhichPairs.hxx"
32 #include "macros.hxx"
33 #include "RegressionCurveHelper.hxx"
34 #include "ItemPropertyMap.hxx"
35 #include "ErrorBar.hxx"
36 #include "PropertyHelper.hxx"
37 #include "ChartModelHelper.hxx"
38 #include "ChartTypeHelper.hxx"
39 #include "StatisticsHelper.hxx"
40 
41 #include "GraphicPropertyItemConverter.hxx"
42 
43 #include <svl/stritem.hxx>
44 #include <svx/chrtitem.hxx>
45 #include <svl/intitem.hxx>
46 #include <rtl/math.hxx>
47 
48 #include <com/sun/star/chart2/DataPointLabel.hpp>
49 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
50 #include <com/sun/star/chart/ErrorBarStyle.hpp>
51 #include <com/sun/star/lang/XServiceName.hpp>
52 
53 #include <functional>
54 #include <algorithm>
55 #include <vector>
56 
57 using namespace ::com::sun::star;
58 
59 namespace
60 {
61 
62 uno::Reference< beans::XPropertySet > lcl_GetYErrorBar(
63     const uno::Reference< beans::XPropertySet > & xProp )
64 {
65     uno::Reference< beans::XPropertySet > xResult;
66 
67     if( xProp.is())
68         try
69         {
70             ( xProp->getPropertyValue( C2U( "ErrorBarY" )) >>= xResult );
71         }
72         catch( uno::Exception & ex )
73         {
74             ASSERT_EXCEPTION( ex );
75         }
76 
77     return xResult;
78 }
79 
80 ::chart::RegressionCurveHelper::tRegressionType lcl_convertRegressionType( SvxChartRegress eRegress )
81 {
82     ::chart::RegressionCurveHelper::tRegressionType eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_NONE;
83     switch( eRegress )
84     {
85         case CHREGRESS_LINEAR:
86             eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LINEAR;
87             break;
88         case CHREGRESS_LOG:
89             eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LOG;
90             break;
91         case CHREGRESS_EXP:
92             eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_EXP;
93             break;
94         case CHREGRESS_POWER:
95             eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POWER;
96             break;
97         case CHREGRESS_NONE:
98             break;
99     }
100     return eType;
101 }
102 
103 
104 uno::Reference< beans::XPropertySet > lcl_GetDefaultErrorBar()
105 {
106     // todo: use a valid context
107     return uno::Reference< beans::XPropertySet >(
108         ::chart::createErrorBar( uno::Reference< uno::XComponentContext >()));
109 }
110 
111 void lcl_getErrorValues( const uno::Reference< beans::XPropertySet > & xErrorBarProp,
112                     double & rOutPosError, double & rOutNegError )
113 {
114     if( ! xErrorBarProp.is())
115         return;
116 
117     try
118     {
119         xErrorBarProp->getPropertyValue( C2U( "PositiveError" )) >>= rOutPosError;
120         xErrorBarProp->getPropertyValue( C2U( "NegativeError" )) >>= rOutNegError;
121     }
122     catch( uno::Exception & ex )
123     {
124         ASSERT_EXCEPTION( ex );
125     }
126 }
127 
128 void lcl_getErrorIndicatorValues(
129     const uno::Reference< beans::XPropertySet > & xErrorBarProp,
130     bool & rOutShowPosError, bool & rOutShowNegError )
131 {
132     if( ! xErrorBarProp.is())
133         return;
134 
135     try
136     {
137         xErrorBarProp->getPropertyValue( C2U( "ShowPositiveError" )) >>= rOutShowPosError;
138         xErrorBarProp->getPropertyValue( C2U( "ShowNegativeError" )) >>= rOutShowNegError;
139     }
140     catch( uno::Exception & ex )
141     {
142         ASSERT_EXCEPTION( ex );
143     }
144 }
145 
146 uno::Reference< beans::XPropertySet > lcl_getEquationProperties(
147     const uno::Reference< beans::XPropertySet > & xSeriesPropSet, const SfxItemSet * pItemSet )
148 {
149     bool bEquationExists = true;
150 
151     // ensure that a trendline is on
152     if( pItemSet )
153     {
154         SvxChartRegress eRegress = CHREGRESS_NONE;
155         const SfxPoolItem *pPoolItem = NULL;
156         if( pItemSet->GetItemState( SCHATTR_REGRESSION_TYPE, sal_True, &pPoolItem ) == SFX_ITEM_SET )
157         {
158             eRegress = static_cast< const SvxChartRegressItem * >( pPoolItem )->GetValue();
159             bEquationExists = ( eRegress != CHREGRESS_NONE );
160         }
161     }
162 
163     if( bEquationExists )
164     {
165         uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropSet, uno::UNO_QUERY );
166         uno::Reference< chart2::XRegressionCurve > xCurve(
167             ::chart::RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt ));
168         if( xCurve.is())
169         {
170             return xCurve->getEquationProperties();
171         }
172     }
173 
174     return uno::Reference< beans::XPropertySet >();
175 }
176 
177 } // anonymous namespace
178 
179 namespace chart
180 {
181 namespace wrapper
182 {
183 
184 StatisticsItemConverter::StatisticsItemConverter(
185     const uno::Reference< frame::XModel > & xModel,
186     const uno::Reference< beans::XPropertySet > & rPropertySet,
187     SfxItemPool& rItemPool ) :
188         ItemConverter( rPropertySet, rItemPool ),
189         m_xModel( xModel )
190 {
191     OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_NONE ) ==
192                 static_cast< int >( CHREGRESS_NONE ));
193     OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_LINEAR ) ==
194                 static_cast< int >( CHREGRESS_LINEAR ));
195     OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_LOG ) ==
196                 static_cast< int >( CHREGRESS_LOG ));
197     OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_EXP ) ==
198                 static_cast< int >( CHREGRESS_EXP ));
199     OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_POWER ) ==
200                 static_cast< int >( CHREGRESS_POWER ));
201 }
202 
203 StatisticsItemConverter::~StatisticsItemConverter()
204 {}
205 
206 const sal_uInt16 * StatisticsItemConverter::GetWhichPairs() const
207 {
208     // must span all used items!
209     return nStatWhichPairs;
210 }
211 
212 bool StatisticsItemConverter::GetItemProperty(
213     tWhichIdType /* nWhichId */,
214     tPropertyNameWithMemberId & /* rOutProperty */ ) const
215 {
216     return false;
217 }
218 
219 bool StatisticsItemConverter::ApplySpecialItem(
220     sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
221     throw( uno::Exception )
222 {
223     bool bChanged = false;
224     uno::Any aValue;
225 
226     switch( nWhichId )
227     {
228         case SCHATTR_STAT_AVERAGE:
229         {
230             uno::Reference< chart2::XRegressionCurveContainer > xRegCnt(
231                 GetPropertySet(), uno::UNO_QUERY );
232             bool bOldHasMeanValueLine = RegressionCurveHelper::hasMeanValueLine( xRegCnt );
233 
234             bool bNewHasMeanValueLine =
235                 static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
236 
237             if( bOldHasMeanValueLine != bNewHasMeanValueLine )
238             {
239                 if( ! bNewHasMeanValueLine )
240                     RegressionCurveHelper::removeMeanValueLine( xRegCnt );
241                 else
242                     RegressionCurveHelper::addMeanValueLine(
243                         xRegCnt, uno::Reference< uno::XComponentContext >(), GetPropertySet() );
244                 bChanged = true;
245             }
246         }
247         break;
248 
249         // Attention !!! This case must be passed before SCHATTR_STAT_PERCENT,
250         // SCHATTR_STAT_BIGERROR, SCHATTR_STAT_CONSTPLUS,
251         // SCHATTR_STAT_CONSTMINUS and SCHATTR_STAT_INDICATE
252         case SCHATTR_STAT_KIND_ERROR:
253         {
254             uno::Reference< beans::XPropertySet > xErrorBarProp(
255                 lcl_GetYErrorBar( GetPropertySet() ));
256 
257             SvxChartKindError eErrorKind =
258                 static_cast< const SvxChartKindErrorItem & >(
259                     rItemSet.Get( nWhichId )).GetValue();
260 
261             if( !xErrorBarProp.is() && eErrorKind == CHERROR_NONE)
262             {
263                 //nothing to do
264             }
265             else
266             {
267                 sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE;
268 
269                 switch( eErrorKind )
270                 {
271                     case CHERROR_NONE:
272                         nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; break;
273                     case CHERROR_VARIANT:
274                         nStyle = ::com::sun::star::chart::ErrorBarStyle::VARIANCE; break;
275                     case CHERROR_SIGMA:
276                         nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION; break;
277                     case CHERROR_PERCENT:
278                         nStyle = ::com::sun::star::chart::ErrorBarStyle::RELATIVE; break;
279                     case CHERROR_BIGERROR:
280                         nStyle = ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN; break;
281                     case CHERROR_CONST:
282                         nStyle = ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE; break;
283                     case CHERROR_STDERROR:
284                         nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR; break;
285                     case CHERROR_RANGE:
286                         nStyle = ::com::sun::star::chart::ErrorBarStyle::FROM_DATA; break;
287                 }
288 
289                 if( !xErrorBarProp.is() )
290                 {
291                     xErrorBarProp = lcl_GetDefaultErrorBar();
292                     GetPropertySet()->setPropertyValue(
293                         C2U( "ErrorBarY" ), uno::makeAny( xErrorBarProp ));
294                 }
295 
296                 xErrorBarProp->setPropertyValue( C2U( "ErrorBarStyle" ),
297                                                     uno::makeAny( nStyle ));
298                 bChanged = true;
299             }
300         }
301         break;
302 
303         case SCHATTR_STAT_PERCENT:
304         case SCHATTR_STAT_BIGERROR:
305         {
306             OSL_ENSURE( false, "Deprectaed item" );
307             uno::Reference< beans::XPropertySet > xErrorBarProp(
308                 lcl_GetYErrorBar( GetPropertySet()));
309             bool bOldHasErrorBar = xErrorBarProp.is();
310 
311             double fValue =
312                 static_cast< const SvxDoubleItem & >(
313                     rItemSet.Get( nWhichId )).GetValue();
314             double fPos, fNeg;
315             lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
316 
317             if( bOldHasErrorBar &&
318                 ! ( ::rtl::math::approxEqual( fPos, fValue ) &&
319                     ::rtl::math::approxEqual( fNeg, fValue )))
320             {
321                 xErrorBarProp->setPropertyValue( C2U( "PositiveError" ),
322                                                     uno::makeAny( fValue ));
323                 xErrorBarProp->setPropertyValue( C2U( "NegativeError" ),
324                                                     uno::makeAny( fValue ));
325                 bChanged = true;
326             }
327         }
328         break;
329 
330         case SCHATTR_STAT_CONSTPLUS:
331         {
332             uno::Reference< beans::XPropertySet > xErrorBarProp(
333                 lcl_GetYErrorBar( GetPropertySet()));
334             bool bOldHasErrorBar = xErrorBarProp.is();
335 
336             double fValue =
337                 static_cast< const SvxDoubleItem & >(
338                     rItemSet.Get( nWhichId )).GetValue();
339             double fPos, fNeg;
340             lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
341 
342             if( bOldHasErrorBar &&
343                 ! ::rtl::math::approxEqual( fPos, fValue ))
344             {
345                 xErrorBarProp->setPropertyValue( C2U( "PositiveError" ), uno::makeAny( fValue ));
346                 bChanged = true;
347             }
348         }
349         break;
350 
351         case SCHATTR_STAT_CONSTMINUS:
352         {
353             uno::Reference< beans::XPropertySet > xErrorBarProp(
354                 lcl_GetYErrorBar( GetPropertySet()));
355             bool bOldHasErrorBar = xErrorBarProp.is();
356 
357             double fValue =
358                 static_cast< const SvxDoubleItem & >(
359                     rItemSet.Get( nWhichId )).GetValue();
360             double fPos, fNeg;
361             lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
362 
363             if( bOldHasErrorBar &&
364                 ! ::rtl::math::approxEqual( fNeg, fValue ))
365             {
366                 xErrorBarProp->setPropertyValue( C2U( "NegativeError" ), uno::makeAny( fValue ));
367                 bChanged = true;
368             }
369         }
370         break;
371 
372         case SCHATTR_REGRESSION_TYPE:
373         {
374             SvxChartRegress eRegress =
375                 static_cast< const SvxChartRegressItem & >(
376                     rItemSet.Get( nWhichId )).GetValue();
377 
378             uno::Reference< chart2::XRegressionCurveContainer > xRegCnt(
379                 GetPropertySet(), uno::UNO_QUERY );
380 
381             if( eRegress == CHREGRESS_NONE )
382             {
383                 bChanged = RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCnt );
384             }
385             else
386             {
387                 SvxChartRegress eOldRegress(
388                     static_cast< SvxChartRegress >(
389                         static_cast< sal_Int32 >(
390                             RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( xRegCnt ))));
391                 if( eOldRegress != eRegress )
392                 {
393                     RegressionCurveHelper::replaceOrAddCurveAndReduceToOne(
394                         lcl_convertRegressionType( eRegress ), xRegCnt,
395                         uno::Reference< uno::XComponentContext >());
396                     bChanged = true;
397                 }
398             }
399         }
400         break;
401 
402         case SCHATTR_REGRESSION_SHOW_EQUATION:
403         {
404             uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
405             if( xEqProp.is())
406             {
407                 bool bShowEq = false;
408                 xEqProp->getPropertyValue( C2U("ShowEquation")) >>= bShowEq;
409                 bool bNewShowEq =
410                     static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
411                 if( bShowEq != bNewShowEq )
412                 {
413                     xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( bNewShowEq ));
414                     bChanged = true;
415                 }
416             }
417         }
418         break;
419 
420         case SCHATTR_REGRESSION_SHOW_COEFF:
421         {
422             uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
423             if( xEqProp.is())
424             {
425                 bool bShowCoeff = false;
426                 xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCoeff;
427                 bool bNewShowCoeff =
428                     static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
429                 if( bShowCoeff != bNewShowCoeff )
430                 {
431                     xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bNewShowCoeff ));
432                     bChanged = true;
433                 }
434             }
435         }
436         break;
437 
438         case SCHATTR_STAT_INDICATE:
439         {
440             uno::Reference< beans::XPropertySet > xErrorBarProp(
441                 lcl_GetYErrorBar( GetPropertySet()));
442             bool bOldHasErrorBar = xErrorBarProp.is();
443 
444             SvxChartIndicate eIndicate =
445                 static_cast< const SvxChartIndicateItem & >(
446                     rItemSet.Get( nWhichId )).GetValue();
447 
448             bool bNewIndPos = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_UP );
449             bool bNewIndNeg = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_DOWN );
450 
451             bool bShowPos, bShowNeg;
452             lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg );
453 
454             if( bOldHasErrorBar &&
455                 ( bShowPos != bNewIndPos ||
456                   bShowNeg != bNewIndNeg ))
457             {
458                 xErrorBarProp->setPropertyValue( C2U( "ShowPositiveError" ), uno::makeAny( bNewIndPos ));
459                 xErrorBarProp->setPropertyValue( C2U( "ShowNegativeError" ), uno::makeAny( bNewIndNeg ));
460                 bChanged = true;
461             }
462         }
463         break;
464 
465         case SCHATTR_STAT_RANGE_POS:
466         case SCHATTR_STAT_RANGE_NEG:
467         {
468             // @todo: also be able to deal with x-error bars
469             const bool bYError = true;
470             uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetYErrorBar( GetPropertySet()), uno::UNO_QUERY );
471             uno::Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY );
472             uno::Reference< chart2::data::XDataProvider > xDataProvider;
473 
474             if( xChartDoc.is())
475                 xDataProvider.set( xChartDoc->getDataProvider());
476             if( xErrorBarSource.is() && xDataProvider.is())
477             {
478                 ::rtl::OUString aNewRange( static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue());
479                 bool bApplyNewRange = false;
480 
481                 bool bIsPositiveValue( nWhichId == SCHATTR_STAT_RANGE_POS );
482                 if( xChartDoc->hasInternalDataProvider())
483                 {
484                     if( aNewRange.getLength())
485                     {
486                         uno::Reference< chart2::data::XDataSequence > xSeq(
487                             StatisticsHelper::getErrorDataSequenceFromDataSource(
488                                 xErrorBarSource, bIsPositiveValue, bYError ));
489                         if( ! xSeq.is())
490                         {
491                             // no data range for error bars yet => create
492                             uno::Reference< chart2::XInternalDataProvider > xIntDataProvider( xDataProvider, uno::UNO_QUERY );
493                             OSL_ASSERT( xIntDataProvider.is());
494                             if( xIntDataProvider.is())
495                             {
496                                 xIntDataProvider->appendSequence();
497                                 aNewRange = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("last"));
498                                 bApplyNewRange = true;
499                             }
500                         }
501                     }
502                 }
503                 else
504                 {
505                     uno::Reference< chart2::data::XDataSequence > xSeq(
506                         StatisticsHelper::getErrorDataSequenceFromDataSource(
507                             xErrorBarSource, bIsPositiveValue, bYError ));
508                     bApplyNewRange =
509                         ! ( xSeq.is() && aNewRange.equals( xSeq->getSourceRangeRepresentation()));
510                 }
511 
512                 if( bApplyNewRange )
513                     StatisticsHelper::setErrorDataSequence(
514                         xErrorBarSource, xDataProvider, aNewRange, bIsPositiveValue, bYError );
515             }
516         }
517         break;
518     }
519 
520     return bChanged;
521 }
522 
523 void StatisticsItemConverter::FillSpecialItem(
524     sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
525     throw( uno::Exception )
526 {
527     switch( nWhichId )
528     {
529         case SCHATTR_STAT_AVERAGE:
530             rOutItemSet.Put(
531                 SfxBoolItem( nWhichId,
532                              RegressionCurveHelper::hasMeanValueLine(
533                                  uno::Reference< chart2::XRegressionCurveContainer >(
534                                      GetPropertySet(), uno::UNO_QUERY ))));
535             break;
536 
537         case SCHATTR_STAT_KIND_ERROR:
538         {
539             SvxChartKindError eErrorKind = CHERROR_NONE;
540             uno::Reference< beans::XPropertySet > xErrorBarProp(
541                 lcl_GetYErrorBar( GetPropertySet()));
542             if( xErrorBarProp.is() )
543             {
544                 sal_Int32 nStyle = 0;
545                 if( xErrorBarProp->getPropertyValue( C2U( "ErrorBarStyle" )) >>= nStyle )
546                 {
547                     switch( nStyle )
548                     {
549                         case ::com::sun::star::chart::ErrorBarStyle::NONE:
550                             break;
551                         case ::com::sun::star::chart::ErrorBarStyle::VARIANCE:
552                             eErrorKind = CHERROR_VARIANT; break;
553                         case ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION:
554                             eErrorKind = CHERROR_SIGMA; break;
555                         case ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE:
556                             eErrorKind = CHERROR_CONST; break;
557                         case ::com::sun::star::chart::ErrorBarStyle::RELATIVE:
558                             eErrorKind = CHERROR_PERCENT; break;
559                         case ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN:
560                             eErrorKind = CHERROR_BIGERROR; break;
561                         case ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR:
562                             eErrorKind = CHERROR_STDERROR; break;
563                         case ::com::sun::star::chart::ErrorBarStyle::FROM_DATA:
564                             eErrorKind = CHERROR_RANGE; break;
565                     }
566                 }
567             }
568             rOutItemSet.Put( SvxChartKindErrorItem( eErrorKind, SCHATTR_STAT_KIND_ERROR ));
569         }
570         break;
571 
572         case SCHATTR_STAT_PERCENT:
573         {
574             uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
575             if( xErrorBarProp.is())
576             {
577                 double fPos, fNeg;
578                 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
579                 rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId ));
580             }
581         }
582         break;
583 
584         case SCHATTR_STAT_BIGERROR:
585         {
586             uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
587             if( xErrorBarProp.is())
588             {
589                 double fPos, fNeg;
590                 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
591                 rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId ));
592             }
593         }
594         break;
595 
596         case SCHATTR_STAT_CONSTPLUS:
597         {
598             uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
599             if( xErrorBarProp.is())
600             {
601                 double fPos, fNeg;
602                 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
603                 rOutItemSet.Put( SvxDoubleItem( fPos, nWhichId ));
604             }
605         }
606         break;
607 
608         case SCHATTR_STAT_CONSTMINUS:
609         {
610             uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
611             if( xErrorBarProp.is())
612             {
613                 double fPos, fNeg;
614                 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
615                 rOutItemSet.Put( SvxDoubleItem( fNeg, nWhichId ));
616             }
617         }
618         break;
619 
620         case SCHATTR_REGRESSION_TYPE:
621         {
622             SvxChartRegress eRegress = static_cast< SvxChartRegress >(
623                 static_cast< sal_Int32 >(
624                     RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine(
625                         uno::Reference< chart2::XRegressionCurveContainer >(
626                             GetPropertySet(), uno::UNO_QUERY ) )));
627             rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE ));
628         }
629         break;
630 
631         case SCHATTR_REGRESSION_SHOW_EQUATION:
632         {
633             bool bShowEq = false;
634             uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 ));
635             if( xEqProp.is())
636                 xEqProp->getPropertyValue( C2U("ShowEquation")) >>= bShowEq;
637             rOutItemSet.Put( SfxBoolItem( nWhichId, bShowEq ));
638         }
639         break;
640 
641         case SCHATTR_REGRESSION_SHOW_COEFF:
642         {
643             bool bShowCoeff = false;
644             uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 ));
645             if( xEqProp.is())
646                 xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCoeff;
647             rOutItemSet.Put( SfxBoolItem( nWhichId, bShowCoeff ));
648         }
649         break;
650 
651         case SCHATTR_STAT_INDICATE:
652         {
653             uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet()));
654             SvxChartIndicate eIndicate = CHINDICATE_BOTH;
655             if( xErrorBarProp.is())
656             {
657                 bool bShowPos, bShowNeg;
658                 lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg );
659 
660                 if( bShowPos )
661                 {
662                     if( bShowNeg )
663                         eIndicate = CHINDICATE_BOTH;
664                     else
665                         eIndicate = CHINDICATE_UP;
666                 }
667                 else
668                 {
669                     if( bShowNeg )
670                         eIndicate = CHINDICATE_DOWN;
671                     else
672                         eIndicate = CHINDICATE_NONE;
673                 }
674             }
675             rOutItemSet.Put( SvxChartIndicateItem( eIndicate, SCHATTR_STAT_INDICATE ));
676         }
677         break;
678 
679         case SCHATTR_STAT_RANGE_POS:
680         case SCHATTR_STAT_RANGE_NEG:
681         {
682             uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetYErrorBar( GetPropertySet()), uno::UNO_QUERY );
683             if( xErrorBarSource.is())
684             {
685                 uno::Reference< chart2::data::XDataSequence > xSeq(
686                     StatisticsHelper::getErrorDataSequenceFromDataSource(
687                         xErrorBarSource, (nWhichId == SCHATTR_STAT_RANGE_POS) /*, true */ /* y */ ));
688                 if( xSeq.is())
689                     rOutItemSet.Put( SfxStringItem( nWhichId, String( xSeq->getSourceRangeRepresentation())));
690             }
691         }
692         break;
693    }
694 }
695 
696 } //  namespace wrapper
697 } //  namespace chart
698