LibreOffice Module chart2 (master) 1
StatisticsItemConverter.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
21#include "SchWhichPairs.hxx"
24#include <ErrorBar.hxx>
25#include <StatisticsHelper.hxx>
26#include <ChartModel.hxx>
27#include <unonames.hxx>
28
29#include <svl/stritem.hxx>
30#include <svx/chrtitem.hxx>
31#include <svl/intitem.hxx>
32#include <rtl/math.hxx>
33
34#include <com/sun/star/chart2/XInternalDataProvider.hpp>
35#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
36#include <com/sun/star/chart/ErrorBarStyle.hpp>
37#include <utility>
39
40using namespace ::com::sun::star;
41
42namespace
43{
44
45uno::Reference< beans::XPropertySet > lcl_GetErrorBar(
46 const uno::Reference< beans::XPropertySet > & xProp, bool bYError )
47{
48 uno::Reference< beans::XPropertySet > xResult;
49
50 if( xProp.is())
51 try
52 {
53 ( xProp->getPropertyValue( bYError ? OUString(CHART_UNONAME_ERRORBAR_Y) : OUString(CHART_UNONAME_ERRORBAR_X) ) >>= xResult );
54 }
55 catch( const uno::Exception & )
56 {
58 }
59
60 return xResult;
61}
62
63uno::Reference< beans::XPropertySet > lcl_GetDefaultErrorBar()
64{
65 return uno::Reference< beans::XPropertySet >( new ::chart::ErrorBar );
66}
67
68void lcl_getErrorValues( const uno::Reference< beans::XPropertySet > & xErrorBarProp,
69 double & rOutPosError, double & rOutNegError )
70{
71 if( ! xErrorBarProp.is())
72 return;
73
74 try
75 {
76 xErrorBarProp->getPropertyValue( "PositiveError" ) >>= rOutPosError;
77 xErrorBarProp->getPropertyValue( "NegativeError" ) >>= rOutNegError;
78 }
79 catch( const uno::Exception & )
80 {
82 }
83}
84
85void lcl_getErrorIndicatorValues(
86 const uno::Reference< beans::XPropertySet > & xErrorBarProp,
87 bool & rOutShowPosError, bool & rOutShowNegError )
88{
89 if( ! xErrorBarProp.is())
90 return;
91
92 try
93 {
94 xErrorBarProp->getPropertyValue( "ShowPositiveError" ) >>= rOutShowPosError;
95 xErrorBarProp->getPropertyValue( "ShowNegativeError" ) >>= rOutShowNegError;
96 }
97 catch( const uno::Exception & )
98 {
100 }
101}
102
103uno::Reference< beans::XPropertySet > lcl_getEquationProperties(
104 const uno::Reference< beans::XPropertySet > & xSeriesPropSet, const SfxItemSet * pItemSet )
105{
106 bool bEquationExists = true;
107
108 // ensure that a trendline is on
109 if( pItemSet )
110 {
111 if( const SvxChartRegressItem* pRegressionItem = pItemSet->GetItemIfSet( SCHATTR_REGRESSION_TYPE ) )
112 {
113 SvxChartRegress eRegress = pRegressionItem->GetValue();
114 bEquationExists = ( eRegress != SvxChartRegress::NONE );
115 }
116 }
117
118 if( bEquationExists )
119 {
120 uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropSet, uno::UNO_QUERY );
123 if( xCurve.is())
124 {
125 return xCurve->getEquationProperties();
126 }
127 }
128
129 return uno::Reference< beans::XPropertySet >();
130}
131
132uno::Reference< beans::XPropertySet > lcl_getCurveProperties(
133 const uno::Reference< beans::XPropertySet > & xSeriesPropSet, const SfxItemSet * pItemSet )
134{
135 bool bExists = true;
136
137 // ensure that a trendline is on
138 if( pItemSet )
139 {
140 if( const SvxChartRegressItem* pRegressionItem = pItemSet->GetItemIfSet( SCHATTR_REGRESSION_TYPE ) )
141 {
142 SvxChartRegress eRegress = pRegressionItem->GetValue();
143 bExists = ( eRegress != SvxChartRegress::NONE );
144 }
145 }
146
147 if( bExists )
148 {
149 uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropSet, uno::UNO_QUERY );
150 uno::Reference< chart2::XRegressionCurve > xCurve(
152 if( xCurve.is())
153 {
154 uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
155 return xProperties;
156 }
157 }
158
159 return uno::Reference< beans::XPropertySet >();
160}
161
162template <class T, class D>
163bool lclConvertToPropertySet(const SfxItemSet& rItemSet, sal_uInt16 nWhichId, const uno::Reference<beans::XPropertySet>& xProperties, const OUString& aPropertyID)
164{
165 OSL_ASSERT(xProperties.is());
166 if( xProperties.is() )
167 {
168 T aValue = static_cast<T>(static_cast<const D&>(rItemSet.Get( nWhichId )).GetValue());
169 T aOldValue = aValue;
170 bool aSuccess = xProperties->getPropertyValue( aPropertyID ) >>= aOldValue;
171 if (!aSuccess || aOldValue != aValue)
172 {
173 xProperties->setPropertyValue( aPropertyID , uno::Any( aValue ));
174 return true;
175 }
176 }
177 return false;
178}
179
180template <class T, class D>
181void lclConvertToItemSet(SfxItemSet& rItemSet, sal_uInt16 nWhichId, const uno::Reference<beans::XPropertySet>& xProperties, const OUString& aPropertyID)
182{
183 OSL_ASSERT(xProperties.is());
184 if( xProperties.is() )
185 {
186 T aValue = static_cast<T>(static_cast<const D&>(rItemSet.Get( nWhichId )).GetValue());
187 if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
188 {
189 rItemSet.Put(D( nWhichId, aValue ));
190 }
191 }
192}
193
194void lclConvertToItemSetDouble(SfxItemSet& rItemSet, TypedWhichId<SvxDoubleItem> nWhichId, const uno::Reference<beans::XPropertySet>& xProperties, const OUString& aPropertyID)
195{
196 OSL_ASSERT(xProperties.is());
197 if( xProperties.is() )
198 {
199 double aValue = rItemSet.Get( nWhichId ).GetValue();
200 if(xProperties->getPropertyValue( aPropertyID ) >>= aValue)
201 {
202 rItemSet.Put(SvxDoubleItem( aValue, nWhichId ));
203 }
204 }
205}
206
207} // anonymous namespace
208
209namespace chart::wrapper
210{
211
214 const uno::Reference< beans::XPropertySet > & rPropertySet,
215 SfxItemPool& rItemPool ) :
216 ItemConverter( rPropertySet, rItemPool ),
217 m_xModel(std::move( xModel ))
218{
219}
220
222{
223}
224
226{
227 // must span all used items!
228 return nStatWhichPairs;
229}
230
232 tWhichIdType /* nWhichId */,
233 tPropertyNameWithMemberId & /* rOutProperty */ ) const
234{
235 return false;
236}
237
239 sal_uInt16 nWhichId, const SfxItemSet & rItemSet )
240{
241 bool bChanged = false;
242
243 switch( nWhichId )
244 {
246 {
248 GetPropertySet(), uno::UNO_QUERY );
249 bool bOldHasMeanValueLine = RegressionCurveHelper::hasMeanValueLine( xRegCnt );
250
251 bool bNewHasMeanValueLine =
252 static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue();
253
254 if( bOldHasMeanValueLine != bNewHasMeanValueLine )
255 {
256 if( ! bNewHasMeanValueLine )
258 else
260 bChanged = true;
261 }
262 }
263 break;
264
265 // Attention !!! This case must be passed before SCHATTR_STAT_PERCENT,
266 // SCHATTR_STAT_BIGERROR, SCHATTR_STAT_CONSTPLUS,
267 // SCHATTR_STAT_CONSTMINUS and SCHATTR_STAT_INDICATE
269 {
270 bool bYError =
271 rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
272
274 lcl_GetErrorBar( GetPropertySet(), bYError ));
275
276 SvxChartKindError eErrorKind =
277 static_cast< const SvxChartKindErrorItem & >(
278 rItemSet.Get( nWhichId )).GetValue();
279
280 if( !xErrorBarProp.is() && eErrorKind == SvxChartKindError::NONE)
281 {
282 //nothing to do
283 }
284 else
285 {
286 sal_Int32 nStyle = css::chart::ErrorBarStyle::NONE;
287
288 switch( eErrorKind )
289 {
290 case SvxChartKindError::NONE:
291 nStyle = css::chart::ErrorBarStyle::NONE; break;
292 case SvxChartKindError::Variant:
293 nStyle = css::chart::ErrorBarStyle::VARIANCE; break;
294 case SvxChartKindError::Sigma:
295 nStyle = css::chart::ErrorBarStyle::STANDARD_DEVIATION; break;
296 case SvxChartKindError::Percent:
297 nStyle = css::chart::ErrorBarStyle::RELATIVE; break;
298 case SvxChartKindError::BigError:
299 nStyle = css::chart::ErrorBarStyle::ERROR_MARGIN; break;
300 case SvxChartKindError::Const:
301 nStyle = css::chart::ErrorBarStyle::ABSOLUTE; break;
302 case SvxChartKindError::StdError:
303 nStyle = css::chart::ErrorBarStyle::STANDARD_ERROR; break;
304 case SvxChartKindError::Range:
305 nStyle = css::chart::ErrorBarStyle::FROM_DATA; break;
306 }
307
308 if( !xErrorBarProp.is() )
309 {
310 xErrorBarProp = lcl_GetDefaultErrorBar();
311 GetPropertySet()->setPropertyValue( bYError ? OUString(CHART_UNONAME_ERRORBAR_Y) : OUString(CHART_UNONAME_ERRORBAR_X),
312 uno::Any( xErrorBarProp ));
313 }
314
315 xErrorBarProp->setPropertyValue( "ErrorBarStyle" , uno::Any( nStyle ));
316 bChanged = true;
317 }
318 }
319 break;
320
323 {
324 OSL_FAIL( "Deprecated item" );
325 bool bYError =
326 rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
327
329 lcl_GetErrorBar( GetPropertySet(), bYError));
330 bool bOldHasErrorBar = xErrorBarProp.is();
331
332 double fValue =
333 static_cast< const SvxDoubleItem & >(
334 rItemSet.Get( nWhichId )).GetValue();
335 double fPos(0.0), fNeg(0.0);
336 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
337
338 if( bOldHasErrorBar &&
339 ! ( ::rtl::math::approxEqual( fPos, fValue ) &&
340 ::rtl::math::approxEqual( fNeg, fValue )))
341 {
342 xErrorBarProp->setPropertyValue( "PositiveError" , uno::Any( fValue ));
343 xErrorBarProp->setPropertyValue( "NegativeError" , uno::Any( fValue ));
344 bChanged = true;
345 }
346 }
347 break;
348
350 {
351 bool bYError =
352 rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
353
355 lcl_GetErrorBar( GetPropertySet(),bYError));
356 bool bOldHasErrorBar = xErrorBarProp.is();
357
358 double fValue =
359 static_cast< const SvxDoubleItem & >(
360 rItemSet.Get( nWhichId )).GetValue();
361 double fPos(0.0), fNeg(0.0);
362 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
363
364 if( bOldHasErrorBar &&
365 ! ::rtl::math::approxEqual( fPos, fValue ))
366 {
367 xErrorBarProp->setPropertyValue( "PositiveError" , uno::Any( fValue ));
368 bChanged = true;
369 }
370 }
371 break;
372
374 {
375 bool bYError =
376 rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
378 lcl_GetErrorBar( GetPropertySet(),bYError));
379 bool bOldHasErrorBar = xErrorBarProp.is();
380
381 double fValue =
382 static_cast< const SvxDoubleItem & >(
383 rItemSet.Get( nWhichId )).GetValue();
384 double fPos(0.0), fNeg(0.0);
385 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
386
387 if( bOldHasErrorBar &&
388 ! ::rtl::math::approxEqual( fNeg, fValue ))
389 {
390 xErrorBarProp->setPropertyValue( "NegativeError" , uno::Any( fValue ));
391 bChanged = true;
392 }
393 }
394 break;
395
397 {
398 SvxChartRegress eRegress =
399 static_cast< const SvxChartRegressItem& >(
400 rItemSet.Get( nWhichId )).GetValue();
401
404
405 if( eRegress == SvxChartRegress::NONE )
406 {
407 if ( xContainer.is() )
408 {
409 xContainer->removeRegressionCurve( xCurve );
410 bChanged = true;
411 }
412 }
413 else
414 {
415 if ( xCurve.is() )
416 {
417 SvxChartRegress eOldRegress(
419
420 if( eOldRegress != eRegress )
421 {
423 eRegress,
424 xContainer,
425 xCurve);
426 uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY );
427 resetPropertySet( xProperties );
428 bChanged = true;
429 }
430 }
431 }
432 }
433 break;
434
436 {
437 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
438 bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "PolynomialDegree");
439 }
440 break;
441
443 {
444 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
445 bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAveragePeriod");
446 }
447 break;
448
450 {
451 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
452 bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAverageType");
453 }
454 break;
455
457 {
458 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
459 bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateForward");
460 }
461 break;
462
464 {
465 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
466 bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateBackward");
467 }
468 break;
469
471 {
472 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
473 bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xProperties, "ForceIntercept");
474 }
475 break;
476
478 {
479 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
480 bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "InterceptValue");
481 }
482 break;
483
485 {
486 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet ));
487 bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xProperties, "CurveName");
488 }
489 break;
490
492 {
493 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
494 bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowEquation");
495 }
496 break;
497
499 {
500 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
501 bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xEqProp, "XName");
502 }
503 break;
504
506 {
507 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
508 bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xEqProp, "YName");
509 }
510 break;
511
513 {
514 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet ));
515 bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowCorrelationCoefficient");
516 }
517 break;
518
520 {
521 bool bYError =
522 rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
524 lcl_GetErrorBar( GetPropertySet(),bYError));
525 bool bOldHasErrorBar = xErrorBarProp.is();
526
527 SvxChartIndicate eIndicate =
528 static_cast< const SvxChartIndicateItem & >(
529 rItemSet.Get( nWhichId )).GetValue();
530
531 bool bNewIndPos = (eIndicate == SvxChartIndicate::Both || eIndicate == SvxChartIndicate::Up );
532 bool bNewIndNeg = (eIndicate == SvxChartIndicate::Both || eIndicate == SvxChartIndicate::Down );
533
534 bool bShowPos(false), bShowNeg(false);
535 lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg );
536
537 if( bOldHasErrorBar &&
538 ( bShowPos != bNewIndPos ||
539 bShowNeg != bNewIndNeg ))
540 {
541 xErrorBarProp->setPropertyValue( "ShowPositiveError" , uno::Any( bNewIndPos ));
542 xErrorBarProp->setPropertyValue( "ShowNegativeError" , uno::Any( bNewIndNeg ));
543 bChanged = true;
544 }
545 }
546 break;
547
550 {
551 const bool bYError =
552 rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
553 uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetErrorBar( GetPropertySet(), bYError),
554 uno::UNO_QUERY );
556
557 if( m_xModel.is())
558 xDataProvider.set( m_xModel->getDataProvider());
559 if( xErrorBarSource.is() && xDataProvider.is())
560 {
561 OUString aNewRange( static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue());
562 bool bApplyNewRange = false;
563
564 bool bIsPositiveValue( nWhichId == SCHATTR_STAT_RANGE_POS );
565 if( m_xModel->hasInternalDataProvider())
566 {
567 if( !aNewRange.isEmpty())
568 {
571 xErrorBarSource, bIsPositiveValue, bYError ));
572 if( ! xSeq.is())
573 {
574 // no data range for error bars yet => create
575 uno::Reference< chart2::XInternalDataProvider > xIntDataProvider( xDataProvider, uno::UNO_QUERY );
576 OSL_ASSERT( xIntDataProvider.is());
577 if( xIntDataProvider.is())
578 {
579 xIntDataProvider->appendSequence();
580 aNewRange = "last";
581 bApplyNewRange = true;
582 }
583 }
584 }
585 }
586 else
587 {
590 xErrorBarSource, bIsPositiveValue, bYError ));
591 bApplyNewRange =
592 ! ( xSeq.is() && (aNewRange == xSeq->getSourceRangeRepresentation()));
593 }
594
595 if( bApplyNewRange )
597 xErrorBarSource, xDataProvider, aNewRange, bIsPositiveValue, bYError );
598 }
599 }
600 break;
601 }
602
603 return bChanged;
604}
605
607 sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const
608{
609 switch( nWhichId )
610 {
612 rOutItemSet.Put(
613 SfxBoolItem( nWhichId,
616 GetPropertySet(), uno::UNO_QUERY ))));
617 break;
618
620 {
621 bool bYError =
622 rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
623 SvxChartKindError eErrorKind = SvxChartKindError::NONE;
625 lcl_GetErrorBar( GetPropertySet(), bYError));
626 if( xErrorBarProp.is() )
627 {
628 sal_Int32 nStyle = 0;
629 if( xErrorBarProp->getPropertyValue( "ErrorBarStyle" ) >>= nStyle )
630 {
631 switch( nStyle )
632 {
633 case css::chart::ErrorBarStyle::NONE:
634 break;
635 case css::chart::ErrorBarStyle::VARIANCE:
636 eErrorKind = SvxChartKindError::Variant; break;
637 case css::chart::ErrorBarStyle::STANDARD_DEVIATION:
638 eErrorKind = SvxChartKindError::Sigma; break;
639 case css::chart::ErrorBarStyle::ABSOLUTE:
640 eErrorKind = SvxChartKindError::Const; break;
641 case css::chart::ErrorBarStyle::RELATIVE:
642 eErrorKind = SvxChartKindError::Percent; break;
643 case css::chart::ErrorBarStyle::ERROR_MARGIN:
644 eErrorKind = SvxChartKindError::BigError; break;
645 case css::chart::ErrorBarStyle::STANDARD_ERROR:
646 eErrorKind = SvxChartKindError::StdError; break;
647 case css::chart::ErrorBarStyle::FROM_DATA:
648 eErrorKind = SvxChartKindError::Range; break;
649 }
650 }
651 }
652 rOutItemSet.Put( SvxChartKindErrorItem( eErrorKind, SCHATTR_STAT_KIND_ERROR ));
653 }
654 break;
655
657 {
658 bool bYError =
659 rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
660 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError));
661 if( xErrorBarProp.is())
662 {
663 double fPos(0.0), fNeg(0.0);
664 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
665 rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, SCHATTR_STAT_PERCENT ));
666 }
667 }
668 break;
669
671 {
672 bool bYError =
673 rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
674 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError));
675 if( xErrorBarProp.is())
676 {
677 double fPos(0.0), fNeg(0.0);
678 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
679 rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, SCHATTR_STAT_BIGERROR ));
680 }
681 }
682 break;
683
685 {
686 bool bYError =
687 rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
688 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError));
689 if( xErrorBarProp.is())
690 {
691 double fPos(0.0), fNeg(0.0);
692 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
693 rOutItemSet.Put( SvxDoubleItem( fPos, SCHATTR_STAT_CONSTPLUS ));
694 }
695 }
696 break;
697
699 {
700 bool bYError =
701 rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
702 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError));
703 if( xErrorBarProp.is())
704 {
705 double fPos(0.0), fNeg(0.0);
706 lcl_getErrorValues( xErrorBarProp, fPos, fNeg );
707 rOutItemSet.Put( SvxDoubleItem( fNeg, SCHATTR_STAT_CONSTMINUS ));
708 }
709 }
710 break;
711
713 {
714 SvxChartRegress eRegress =
717 GetPropertySet(), uno::UNO_QUERY ) );
718 rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE ));
719 }
720 break;
721
723 {
724
725 uno::Reference<beans::XPropertySet> xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
726 lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "PolynomialDegree");
727 }
728 break;
729
731 {
732 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
733 lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAveragePeriod");
734 }
735 break;
736
738 {
739 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
740 lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAverageType");
741 }
742 break;
743
745 {
746 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
747 lclConvertToItemSetDouble(rOutItemSet, SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD, xProperties, "ExtrapolateForward");
748 }
749 break;
750
752 {
753 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
754 lclConvertToItemSetDouble(rOutItemSet, SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD, xProperties, "ExtrapolateBackward");
755 }
756 break;
757
759 {
760 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
761 lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xProperties, "ForceIntercept");
762 }
763 break;
764
766 {
767 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
768 lclConvertToItemSetDouble(rOutItemSet, SCHATTR_REGRESSION_INTERCEPT_VALUE, xProperties, "InterceptValue");
769 }
770 break;
771
773 {
774 uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr ));
775 lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xProperties, "CurveName");
776 }
777 break;
778
780 {
781 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), nullptr ));
782 lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xEqProp, "ShowEquation");
783 }
784 break;
785
787 {
788 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), nullptr ));
789 lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xEqProp, "XName");
790 }
791 break;
792
794 {
795 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), nullptr ));
796 lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xEqProp, "YName");
797 }
798 break;
799
801 {
802 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), nullptr ));
803 lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xEqProp, "ShowCorrelationCoefficient");
804 }
805 break;
806
808 {
809 bool bYError =
810 rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
811 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError));
812 SvxChartIndicate eIndicate = SvxChartIndicate::Both;
813 if( xErrorBarProp.is())
814 {
815 bool bShowPos(false), bShowNeg(false);
816 lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg );
817
818 if( bShowPos )
819 {
820 if( bShowNeg )
821 eIndicate = SvxChartIndicate::Both;
822 else
823 eIndicate = SvxChartIndicate::Up;
824 }
825 else
826 {
827 if( bShowNeg )
828 eIndicate = SvxChartIndicate::Down;
829 else
830 eIndicate = SvxChartIndicate::NONE;
831 }
832 }
833 rOutItemSet.Put( SvxChartIndicateItem( eIndicate, SCHATTR_STAT_INDICATE ));
834 }
835 break;
836
839 {
840 bool bYError =
841 rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue();
842 uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetErrorBar( GetPropertySet(),bYError),
843 uno::UNO_QUERY );
844 if( xErrorBarSource.is())
845 {
848 xErrorBarSource, (nWhichId == SCHATTR_STAT_RANGE_POS), bYError ));
849 if( xSeq.is())
850 rOutItemSet.Put( SfxStringItem( nWhichId, xSeq->getSourceRangeRepresentation()));
851 }
852 }
853 break;
854 }
855}
856
857} // namespace chart
858
859/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr TypedWhichId< SfxStringItem > SCHATTR_STAT_RANGE_POS(SCHATTR_STAT_START+7)
constexpr TypedWhichId< SvxChartRegressItem > SCHATTR_REGRESSION_TYPE(SCHATTR_REGRESSION_START)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD(SCHATTR_REGRESSION_START+5)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_REGRESSION_SHOW_EQUATION(SCHATTR_REGRESSION_START+1)
constexpr TypedWhichId< SvxChartIndicateItem > SCHATTR_STAT_INDICATE(SCHATTR_STAT_START+6)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_REGRESSION_SET_INTERCEPT(SCHATTR_REGRESSION_START+7)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_STAT_ERRORBAR_TYPE(SCHATTR_STAT_START+9)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_STAT_BIGERROR(SCHATTR_STAT_START+3)
constexpr TypedWhichId< SfxInt32Item > SCHATTR_REGRESSION_MOVING_TYPE(SCHATTR_REGRESSION_START+12)
constexpr TypedWhichId< SfxStringItem > SCHATTR_REGRESSION_CURVE_NAME(SCHATTR_REGRESSION_START+9)
constexpr TypedWhichId< SfxStringItem > SCHATTR_REGRESSION_YNAME(SCHATTR_REGRESSION_START+11)
constexpr TypedWhichId< SvxChartKindErrorItem > SCHATTR_STAT_KIND_ERROR(SCHATTR_STAT_START+1)
constexpr TypedWhichId< SfxInt32Item > SCHATTR_REGRESSION_DEGREE(SCHATTR_REGRESSION_START+3)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_REGRESSION_SHOW_COEFF(SCHATTR_REGRESSION_START+2)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD(SCHATTR_REGRESSION_START+6)
constexpr TypedWhichId< SfxStringItem > SCHATTR_STAT_RANGE_NEG(SCHATTR_STAT_START+8)
constexpr TypedWhichId< SfxBoolItem > SCHATTR_STAT_AVERAGE(SCHATTR_STAT_START)
constexpr TypedWhichId< SfxStringItem > SCHATTR_REGRESSION_XNAME(SCHATTR_REGRESSION_START+10)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_STAT_CONSTPLUS(SCHATTR_STAT_START+4)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_REGRESSION_INTERCEPT_VALUE(SCHATTR_REGRESSION_START+8)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_STAT_CONSTMINUS(SCHATTR_STAT_START+5)
constexpr TypedWhichId< SvxDoubleItem > SCHATTR_STAT_PERCENT(SCHATTR_STAT_START+2)
constexpr TypedWhichId< SfxInt32Item > SCHATTR_REGRESSION_PERIOD(SCHATTR_REGRESSION_START+4)
const WhichRangesContainer nStatWhichPairs(svl::Items< SCHATTR_STAT_START, SCHATTR_STAT_END, SCHATTR_REGRESSION_START, SCHATTR_REGRESSION_END >)
SvxChartRegress
SvxChartIndicate
SvxChartKindError
const OUString & GetValue() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
This class serves for conversion between properties of an XPropertySet and SfxItems in SfxItemSets.
void resetPropertySet(const css::uno::Reference< css::beans::XPropertySet > &xPropSet)
sets a new property set, that you get with GetPropertySet().
std::pair< tPropertyNameType, tMemberIdType > tPropertyNameWithMemberId
const css::uno::Reference< css::beans::XPropertySet > & GetPropertySet() const
Returns the XPropertySet that was given in the CTOR and is used to apply items in ApplyItemSet().
virtual bool GetItemProperty(tWhichIdType nWhichId, tPropertyNameWithMemberId &rOutProperty) const override
implement this method to return a Property object for a given which id.
rtl::Reference<::chart::ChartModel > m_xModel
StatisticsItemConverter(rtl::Reference<::chart::ChartModel > xChartModel, const css::uno::Reference< css::beans::XPropertySet > &rPropertySet, SfxItemPool &rItemPool)
virtual const WhichRangesContainer & GetWhichPairs() const override
implement this method to provide an array of which-ranges
virtual bool ApplySpecialItem(sal_uInt16 nWhichId, const SfxItemSet &rItemSet) override
for items that can not be mapped directly to a property.
virtual void FillSpecialItem(sal_uInt16 nWhichId, SfxItemSet &rOutItemSet) const override
for items that can not be mapped directly to a property.
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< frame::XModel > m_xModel
OOO_DLLPUBLIC_CHARTTOOLS SvxChartRegress getFirstRegressTypeNotMeanValueLine(const css::uno::Reference< css::chart2::XRegressionCurveContainer > &xCurveContainer)
Returns the type of the first regression curve found that is not of type mean-value line.
OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel > getFirstCurveNotMeanValueLine(const css::uno::Reference< css::chart2::XRegressionCurveContainer > &xCurveContainer)
Returns the first regression curve found that is not of type mean-value line.
OOO_DLLPUBLIC_CHARTTOOLS bool hasMeanValueLine(const css::uno::Reference< css::chart2::XRegressionCurveContainer > &xRegCnt)
OOO_DLLPUBLIC_CHARTTOOLS rtl::Reference<::chart::RegressionCurveModel > changeRegressionCurveType(SvxChartRegress eType, css::uno::Reference< css::chart2::XRegressionCurveContainer > const &xRegressionCurveContainer, css::uno::Reference< css::chart2::XRegressionCurve > const &xRegressionCurve)
OOO_DLLPUBLIC_CHARTTOOLS void removeMeanValueLine(css::uno::Reference< css::chart2::XRegressionCurveContainer > const &xRegCnt)
OOO_DLLPUBLIC_CHARTTOOLS SvxChartRegress getRegressionType(const css::uno::Reference< css::chart2::XRegressionCurve > &xCurve)
OOO_DLLPUBLIC_CHARTTOOLS void addMeanValueLine(css::uno::Reference< css::chart2::XRegressionCurveContainer > const &xRegCnt, const css::uno::Reference< css::beans::XPropertySet > &xSeriesProp)
creates a mean-value line and adds it to the container.
OOO_DLLPUBLIC_CHARTTOOLS css::uno::Reference< css::chart2::data::XDataSequence > getErrorDataSequenceFromDataSource(const css::uno::Reference< css::chart2::data::XDataSource > &xDataSource, bool bPositiveValue, bool bYError=true)
OOO_DLLPUBLIC_CHARTTOOLS void setErrorDataSequence(const css::uno::Reference< css::chart2::data::XDataSource > &xDataSource, const css::uno::Reference< css::chart2::data::XDataProvider > &xDataProvider, const OUString &rNewRange, bool bPositiveValue, bool bYError=true, OUString const *pXMLRange=nullptr)
const char GetValue[]
Reference< XModel > xModel
constexpr OUStringLiteral CHART_UNONAME_ERRORBAR_Y
Definition: unonames.hxx:23
constexpr OUStringLiteral CHART_UNONAME_ERRORBAR_X
Definition: unonames.hxx:22