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