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_chart2.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 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 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 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 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 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 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 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 199 StatisticsItemConverter::~StatisticsItemConverter() 200 {} 201 202 const sal_uInt16 * StatisticsItemConverter::GetWhichPairs() const 203 { 204 // must span all used items! 205 return nStatWhichPairs; 206 } 207 208 bool StatisticsItemConverter::GetItemProperty( 209 tWhichIdType /* nWhichId */, 210 tPropertyNameWithMemberId & /* rOutProperty */ ) const 211 { 212 return false; 213 } 214 215 bool StatisticsItemConverter::ApplySpecialItem( 216 sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) 217 throw( uno::Exception ) 218 { 219 bool bChanged = false; 220 uno::Any aValue; 221 222 switch( nWhichId ) 223 { 224 case SCHATTR_STAT_AVERAGE: 225 { 226 uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( 227 GetPropertySet(), uno::UNO_QUERY ); 228 bool bOldHasMeanValueLine = RegressionCurveHelper::hasMeanValueLine( xRegCnt ); 229 230 bool bNewHasMeanValueLine = 231 static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); 232 233 if( bOldHasMeanValueLine != bNewHasMeanValueLine ) 234 { 235 if( ! bNewHasMeanValueLine ) 236 RegressionCurveHelper::removeMeanValueLine( xRegCnt ); 237 else 238 RegressionCurveHelper::addMeanValueLine( 239 xRegCnt, uno::Reference< uno::XComponentContext >(), GetPropertySet() ); 240 bChanged = true; 241 } 242 } 243 break; 244 245 // Attention !!! This case must be passed before SCHATTR_STAT_PERCENT, 246 // SCHATTR_STAT_BIGERROR, SCHATTR_STAT_CONSTPLUS, 247 // SCHATTR_STAT_CONSTMINUS and SCHATTR_STAT_INDICATE 248 case SCHATTR_STAT_KIND_ERROR: 249 { 250 uno::Reference< beans::XPropertySet > xErrorBarProp( 251 lcl_GetYErrorBar( GetPropertySet() )); 252 253 SvxChartKindError eErrorKind = 254 static_cast< const SvxChartKindErrorItem & >( 255 rItemSet.Get( nWhichId )).GetValue(); 256 257 if( !xErrorBarProp.is() && eErrorKind == CHERROR_NONE) 258 { 259 //nothing to do 260 } 261 else 262 { 263 sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; 264 265 switch( eErrorKind ) 266 { 267 case CHERROR_NONE: 268 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; break; 269 case CHERROR_VARIANT: 270 nStyle = ::com::sun::star::chart::ErrorBarStyle::VARIANCE; break; 271 case CHERROR_SIGMA: 272 nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION; break; 273 case CHERROR_PERCENT: 274 nStyle = ::com::sun::star::chart::ErrorBarStyle::RELATIVE; break; 275 case CHERROR_BIGERROR: 276 nStyle = ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN; break; 277 case CHERROR_CONST: 278 nStyle = ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE; break; 279 case CHERROR_STDERROR: 280 nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR; break; 281 case CHERROR_RANGE: 282 nStyle = ::com::sun::star::chart::ErrorBarStyle::FROM_DATA; break; 283 } 284 285 if( !xErrorBarProp.is() ) 286 { 287 xErrorBarProp = lcl_GetDefaultErrorBar(); 288 GetPropertySet()->setPropertyValue( 289 C2U( "ErrorBarY" ), uno::makeAny( xErrorBarProp )); 290 } 291 292 xErrorBarProp->setPropertyValue( C2U( "ErrorBarStyle" ), 293 uno::makeAny( nStyle )); 294 bChanged = true; 295 } 296 } 297 break; 298 299 case SCHATTR_STAT_PERCENT: 300 case SCHATTR_STAT_BIGERROR: 301 { 302 OSL_ENSURE( false, "Deprectaed item" ); 303 uno::Reference< beans::XPropertySet > xErrorBarProp( 304 lcl_GetYErrorBar( GetPropertySet())); 305 bool bOldHasErrorBar = xErrorBarProp.is(); 306 307 double fValue = 308 static_cast< const SvxDoubleItem & >( 309 rItemSet.Get( nWhichId )).GetValue(); 310 double fPos, fNeg; 311 lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); 312 313 if( bOldHasErrorBar && 314 ! ( ::rtl::math::approxEqual( fPos, fValue ) && 315 ::rtl::math::approxEqual( fNeg, fValue ))) 316 { 317 xErrorBarProp->setPropertyValue( C2U( "PositiveError" ), 318 uno::makeAny( fValue )); 319 xErrorBarProp->setPropertyValue( C2U( "NegativeError" ), 320 uno::makeAny( fValue )); 321 bChanged = true; 322 } 323 } 324 break; 325 326 case SCHATTR_STAT_CONSTPLUS: 327 { 328 uno::Reference< beans::XPropertySet > xErrorBarProp( 329 lcl_GetYErrorBar( GetPropertySet())); 330 bool bOldHasErrorBar = xErrorBarProp.is(); 331 332 double fValue = 333 static_cast< const SvxDoubleItem & >( 334 rItemSet.Get( nWhichId )).GetValue(); 335 double fPos, fNeg; 336 lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); 337 338 if( bOldHasErrorBar && 339 ! ::rtl::math::approxEqual( fPos, fValue )) 340 { 341 xErrorBarProp->setPropertyValue( C2U( "PositiveError" ), uno::makeAny( fValue )); 342 bChanged = true; 343 } 344 } 345 break; 346 347 case SCHATTR_STAT_CONSTMINUS: 348 { 349 uno::Reference< beans::XPropertySet > xErrorBarProp( 350 lcl_GetYErrorBar( GetPropertySet())); 351 bool bOldHasErrorBar = xErrorBarProp.is(); 352 353 double fValue = 354 static_cast< const SvxDoubleItem & >( 355 rItemSet.Get( nWhichId )).GetValue(); 356 double fPos, fNeg; 357 lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); 358 359 if( bOldHasErrorBar && 360 ! ::rtl::math::approxEqual( fNeg, fValue )) 361 { 362 xErrorBarProp->setPropertyValue( C2U( "NegativeError" ), uno::makeAny( fValue )); 363 bChanged = true; 364 } 365 } 366 break; 367 368 case SCHATTR_REGRESSION_TYPE: 369 { 370 SvxChartRegress eRegress = 371 static_cast< const SvxChartRegressItem & >( 372 rItemSet.Get( nWhichId )).GetValue(); 373 374 uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( 375 GetPropertySet(), uno::UNO_QUERY ); 376 377 if( eRegress == CHREGRESS_NONE ) 378 { 379 bChanged = RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCnt ); 380 } 381 else 382 { 383 SvxChartRegress eOldRegress( 384 static_cast< SvxChartRegress >( 385 static_cast< sal_Int32 >( 386 RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( xRegCnt )))); 387 if( eOldRegress != eRegress ) 388 { 389 RegressionCurveHelper::replaceOrAddCurveAndReduceToOne( 390 lcl_convertRegressionType( eRegress ), xRegCnt, 391 uno::Reference< uno::XComponentContext >()); 392 bChanged = true; 393 } 394 } 395 } 396 break; 397 398 case SCHATTR_REGRESSION_SHOW_EQUATION: 399 { 400 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet )); 401 if( xEqProp.is()) 402 { 403 bool bShowEq = false; 404 xEqProp->getPropertyValue( C2U("ShowEquation")) >>= bShowEq; 405 bool bNewShowEq = 406 static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); 407 if( bShowEq != bNewShowEq ) 408 { 409 xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( bNewShowEq )); 410 bChanged = true; 411 } 412 } 413 } 414 break; 415 416 case SCHATTR_REGRESSION_SHOW_COEFF: 417 { 418 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet )); 419 if( xEqProp.is()) 420 { 421 bool bShowCoeff = false; 422 xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCoeff; 423 bool bNewShowCoeff = 424 static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); 425 if( bShowCoeff != bNewShowCoeff ) 426 { 427 xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bNewShowCoeff )); 428 bChanged = true; 429 } 430 } 431 } 432 break; 433 434 case SCHATTR_STAT_INDICATE: 435 { 436 uno::Reference< beans::XPropertySet > xErrorBarProp( 437 lcl_GetYErrorBar( GetPropertySet())); 438 bool bOldHasErrorBar = xErrorBarProp.is(); 439 440 SvxChartIndicate eIndicate = 441 static_cast< const SvxChartIndicateItem & >( 442 rItemSet.Get( nWhichId )).GetValue(); 443 444 bool bNewIndPos = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_UP ); 445 bool bNewIndNeg = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_DOWN ); 446 447 bool bShowPos, bShowNeg; 448 lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg ); 449 450 if( bOldHasErrorBar && 451 ( bShowPos != bNewIndPos || 452 bShowNeg != bNewIndNeg )) 453 { 454 xErrorBarProp->setPropertyValue( C2U( "ShowPositiveError" ), uno::makeAny( bNewIndPos )); 455 xErrorBarProp->setPropertyValue( C2U( "ShowNegativeError" ), uno::makeAny( bNewIndNeg )); 456 bChanged = true; 457 } 458 } 459 break; 460 461 case SCHATTR_STAT_RANGE_POS: 462 case SCHATTR_STAT_RANGE_NEG: 463 { 464 // @todo: also be able to deal with x-error bars 465 const bool bYError = true; 466 uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetYErrorBar( GetPropertySet()), uno::UNO_QUERY ); 467 uno::Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY ); 468 uno::Reference< chart2::data::XDataProvider > xDataProvider; 469 470 if( xChartDoc.is()) 471 xDataProvider.set( xChartDoc->getDataProvider()); 472 if( xErrorBarSource.is() && xDataProvider.is()) 473 { 474 ::rtl::OUString aNewRange( static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue()); 475 bool bApplyNewRange = false; 476 477 bool bIsPositiveValue( nWhichId == SCHATTR_STAT_RANGE_POS ); 478 if( xChartDoc->hasInternalDataProvider()) 479 { 480 if( aNewRange.getLength()) 481 { 482 uno::Reference< chart2::data::XDataSequence > xSeq( 483 StatisticsHelper::getErrorDataSequenceFromDataSource( 484 xErrorBarSource, bIsPositiveValue, bYError )); 485 if( ! xSeq.is()) 486 { 487 // no data range for error bars yet => create 488 uno::Reference< chart2::XInternalDataProvider > xIntDataProvider( xDataProvider, uno::UNO_QUERY ); 489 OSL_ASSERT( xIntDataProvider.is()); 490 if( xIntDataProvider.is()) 491 { 492 xIntDataProvider->appendSequence(); 493 aNewRange = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("last")); 494 bApplyNewRange = true; 495 } 496 } 497 } 498 } 499 else 500 { 501 uno::Reference< chart2::data::XDataSequence > xSeq( 502 StatisticsHelper::getErrorDataSequenceFromDataSource( 503 xErrorBarSource, bIsPositiveValue, bYError )); 504 bApplyNewRange = 505 ! ( xSeq.is() && aNewRange.equals( xSeq->getSourceRangeRepresentation())); 506 } 507 508 if( bApplyNewRange ) 509 StatisticsHelper::setErrorDataSequence( 510 xErrorBarSource, xDataProvider, aNewRange, bIsPositiveValue, bYError ); 511 } 512 } 513 break; 514 } 515 516 return bChanged; 517 } 518 519 void StatisticsItemConverter::FillSpecialItem( 520 sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const 521 throw( uno::Exception ) 522 { 523 switch( nWhichId ) 524 { 525 case SCHATTR_STAT_AVERAGE: 526 rOutItemSet.Put( 527 SfxBoolItem( nWhichId, 528 RegressionCurveHelper::hasMeanValueLine( 529 uno::Reference< chart2::XRegressionCurveContainer >( 530 GetPropertySet(), uno::UNO_QUERY )))); 531 break; 532 533 case SCHATTR_STAT_KIND_ERROR: 534 { 535 SvxChartKindError eErrorKind = CHERROR_NONE; 536 uno::Reference< beans::XPropertySet > xErrorBarProp( 537 lcl_GetYErrorBar( GetPropertySet())); 538 if( xErrorBarProp.is() ) 539 { 540 sal_Int32 nStyle = 0; 541 if( xErrorBarProp->getPropertyValue( C2U( "ErrorBarStyle" )) >>= nStyle ) 542 { 543 switch( nStyle ) 544 { 545 case ::com::sun::star::chart::ErrorBarStyle::NONE: 546 break; 547 case ::com::sun::star::chart::ErrorBarStyle::VARIANCE: 548 eErrorKind = CHERROR_VARIANT; break; 549 case ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION: 550 eErrorKind = CHERROR_SIGMA; break; 551 case ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE: 552 eErrorKind = CHERROR_CONST; break; 553 case ::com::sun::star::chart::ErrorBarStyle::RELATIVE: 554 eErrorKind = CHERROR_PERCENT; break; 555 case ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN: 556 eErrorKind = CHERROR_BIGERROR; break; 557 case ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR: 558 eErrorKind = CHERROR_STDERROR; break; 559 case ::com::sun::star::chart::ErrorBarStyle::FROM_DATA: 560 eErrorKind = CHERROR_RANGE; break; 561 } 562 } 563 } 564 rOutItemSet.Put( SvxChartKindErrorItem( eErrorKind, SCHATTR_STAT_KIND_ERROR )); 565 } 566 break; 567 568 case SCHATTR_STAT_PERCENT: 569 { 570 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); 571 if( xErrorBarProp.is()) 572 { 573 double fPos, fNeg; 574 lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); 575 rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId )); 576 } 577 } 578 break; 579 580 case SCHATTR_STAT_BIGERROR: 581 { 582 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); 583 if( xErrorBarProp.is()) 584 { 585 double fPos, fNeg; 586 lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); 587 rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId )); 588 } 589 } 590 break; 591 592 case SCHATTR_STAT_CONSTPLUS: 593 { 594 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); 595 if( xErrorBarProp.is()) 596 { 597 double fPos, fNeg; 598 lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); 599 rOutItemSet.Put( SvxDoubleItem( fPos, nWhichId )); 600 } 601 } 602 break; 603 604 case SCHATTR_STAT_CONSTMINUS: 605 { 606 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); 607 if( xErrorBarProp.is()) 608 { 609 double fPos, fNeg; 610 lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); 611 rOutItemSet.Put( SvxDoubleItem( fNeg, nWhichId )); 612 } 613 } 614 break; 615 616 case SCHATTR_REGRESSION_TYPE: 617 { 618 SvxChartRegress eRegress = static_cast< SvxChartRegress >( 619 static_cast< sal_Int32 >( 620 RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( 621 uno::Reference< chart2::XRegressionCurveContainer >( 622 GetPropertySet(), uno::UNO_QUERY ) ))); 623 rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE )); 624 } 625 break; 626 627 case SCHATTR_REGRESSION_SHOW_EQUATION: 628 { 629 bool bShowEq = false; 630 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 )); 631 if( xEqProp.is()) 632 xEqProp->getPropertyValue( C2U("ShowEquation")) >>= bShowEq; 633 rOutItemSet.Put( SfxBoolItem( nWhichId, bShowEq )); 634 } 635 break; 636 637 case SCHATTR_REGRESSION_SHOW_COEFF: 638 { 639 bool bShowCoeff = false; 640 uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 )); 641 if( xEqProp.is()) 642 xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCoeff; 643 rOutItemSet.Put( SfxBoolItem( nWhichId, bShowCoeff )); 644 } 645 break; 646 647 case SCHATTR_STAT_INDICATE: 648 { 649 uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); 650 SvxChartIndicate eIndicate = CHINDICATE_BOTH; 651 if( xErrorBarProp.is()) 652 { 653 bool bShowPos, bShowNeg; 654 lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg ); 655 656 if( bShowPos ) 657 { 658 if( bShowNeg ) 659 eIndicate = CHINDICATE_BOTH; 660 else 661 eIndicate = CHINDICATE_UP; 662 } 663 else 664 { 665 if( bShowNeg ) 666 eIndicate = CHINDICATE_DOWN; 667 else 668 eIndicate = CHINDICATE_NONE; 669 } 670 } 671 rOutItemSet.Put( SvxChartIndicateItem( eIndicate, SCHATTR_STAT_INDICATE )); 672 } 673 break; 674 675 case SCHATTR_STAT_RANGE_POS: 676 case SCHATTR_STAT_RANGE_NEG: 677 { 678 uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetYErrorBar( GetPropertySet()), uno::UNO_QUERY ); 679 if( xErrorBarSource.is()) 680 { 681 uno::Reference< chart2::data::XDataSequence > xSeq( 682 StatisticsHelper::getErrorDataSequenceFromDataSource( 683 xErrorBarSource, (nWhichId == SCHATTR_STAT_RANGE_POS) /*, true */ /* y */ )); 684 if( xSeq.is()) 685 rOutItemSet.Put( SfxStringItem( nWhichId, String( xSeq->getSourceRangeRepresentation()))); 686 } 687 } 688 break; 689 } 690 } 691 692 } // namespace wrapper 693 } // namespace chart 694