1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_chart2.hxx" 30*cdf0e10cSrcweir #include "ErrorBarItemConverter.hxx" 31*cdf0e10cSrcweir #include "SchWhichPairs.hxx" 32*cdf0e10cSrcweir #include "macros.hxx" 33*cdf0e10cSrcweir #include "ItemPropertyMap.hxx" 34*cdf0e10cSrcweir #include "ErrorBar.hxx" 35*cdf0e10cSrcweir #include "PropertyHelper.hxx" 36*cdf0e10cSrcweir #include "ChartModelHelper.hxx" 37*cdf0e10cSrcweir #include "ChartTypeHelper.hxx" 38*cdf0e10cSrcweir #include "StatisticsHelper.hxx" 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir #include "GraphicPropertyItemConverter.hxx" 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir #include <svl/stritem.hxx> 43*cdf0e10cSrcweir #include <svx/chrtitem.hxx> 44*cdf0e10cSrcweir #include <svl/intitem.hxx> 45*cdf0e10cSrcweir #include <rtl/math.hxx> 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir #include <com/sun/star/chart2/DataPointLabel.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/chart2/XInternalDataProvider.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/chart/ErrorBarStyle.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp> 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir #include <functional> 53*cdf0e10cSrcweir #include <algorithm> 54*cdf0e10cSrcweir #include <vector> 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir using namespace ::com::sun::star; 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir namespace 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir void lcl_getErrorValues( const uno::Reference< beans::XPropertySet > & xErrorBarProp, 62*cdf0e10cSrcweir double & rOutPosError, double & rOutNegError ) 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir if( ! xErrorBarProp.is()) 65*cdf0e10cSrcweir return; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir try 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir xErrorBarProp->getPropertyValue( C2U( "PositiveError" )) >>= rOutPosError; 70*cdf0e10cSrcweir xErrorBarProp->getPropertyValue( C2U( "NegativeError" )) >>= rOutNegError; 71*cdf0e10cSrcweir } 72*cdf0e10cSrcweir catch( uno::Exception & ex ) 73*cdf0e10cSrcweir { 74*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir void lcl_getErrorIndicatorValues( 79*cdf0e10cSrcweir const uno::Reference< beans::XPropertySet > & xErrorBarProp, 80*cdf0e10cSrcweir bool & rOutShowPosError, bool & rOutShowNegError ) 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir if( ! xErrorBarProp.is()) 83*cdf0e10cSrcweir return; 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir try 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir xErrorBarProp->getPropertyValue( C2U( "ShowPositiveError" )) >>= rOutShowPosError; 88*cdf0e10cSrcweir xErrorBarProp->getPropertyValue( C2U( "ShowNegativeError" )) >>= rOutShowNegError; 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir catch( uno::Exception & ex ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir ASSERT_EXCEPTION( ex ); 93*cdf0e10cSrcweir } 94*cdf0e10cSrcweir } 95*cdf0e10cSrcweir 96*cdf0e10cSrcweir } // anonymous namespace 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir namespace chart 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir namespace wrapper 101*cdf0e10cSrcweir { 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir ErrorBarItemConverter::ErrorBarItemConverter( 104*cdf0e10cSrcweir const uno::Reference< frame::XModel > & xModel, 105*cdf0e10cSrcweir const uno::Reference< beans::XPropertySet > & rPropertySet, 106*cdf0e10cSrcweir SfxItemPool& rItemPool, 107*cdf0e10cSrcweir SdrModel& rDrawModel, 108*cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) : 109*cdf0e10cSrcweir ItemConverter( rPropertySet, rItemPool ), 110*cdf0e10cSrcweir m_spGraphicConverter( new GraphicPropertyItemConverter( 111*cdf0e10cSrcweir rPropertySet, rItemPool, rDrawModel, 112*cdf0e10cSrcweir xNamedPropertyContainerFactory, 113*cdf0e10cSrcweir GraphicPropertyItemConverter::LINE_PROPERTIES )), 114*cdf0e10cSrcweir m_xModel( xModel ) 115*cdf0e10cSrcweir {} 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir ErrorBarItemConverter::~ErrorBarItemConverter() 118*cdf0e10cSrcweir {} 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir void ErrorBarItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const 121*cdf0e10cSrcweir { 122*cdf0e10cSrcweir m_spGraphicConverter->FillItemSet( rOutItemSet ); 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir // own items 125*cdf0e10cSrcweir ItemConverter::FillItemSet( rOutItemSet ); 126*cdf0e10cSrcweir } 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir bool ErrorBarItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir bool bResult = m_spGraphicConverter->ApplyItemSet( rItemSet ); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir // own items 133*cdf0e10cSrcweir return ItemConverter::ApplyItemSet( rItemSet ) || bResult; 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir const sal_uInt16 * ErrorBarItemConverter::GetWhichPairs() const 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir // must span all used items! 139*cdf0e10cSrcweir return nErrorBarWhichPairs; 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir bool ErrorBarItemConverter::GetItemProperty( 143*cdf0e10cSrcweir tWhichIdType /* nWhichId */, 144*cdf0e10cSrcweir tPropertyNameWithMemberId & /* rOutProperty */ ) const 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir return false; 147*cdf0e10cSrcweir } 148*cdf0e10cSrcweir 149*cdf0e10cSrcweir bool ErrorBarItemConverter::ApplySpecialItem( 150*cdf0e10cSrcweir sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) 151*cdf0e10cSrcweir throw( uno::Exception ) 152*cdf0e10cSrcweir { 153*cdf0e10cSrcweir bool bChanged = false; 154*cdf0e10cSrcweir uno::Any aValue; 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir switch( nWhichId ) 157*cdf0e10cSrcweir { 158*cdf0e10cSrcweir // Attention !!! This case must be passed before SCHATTR_STAT_PERCENT, 159*cdf0e10cSrcweir // SCHATTR_STAT_BIGERROR, SCHATTR_STAT_CONSTPLUS, 160*cdf0e10cSrcweir // SCHATTR_STAT_CONSTMINUS and SCHATTR_STAT_INDICATE 161*cdf0e10cSrcweir case SCHATTR_STAT_KIND_ERROR: 162*cdf0e10cSrcweir { 163*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet()); 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir SvxChartKindError eErrorKind = 166*cdf0e10cSrcweir static_cast< const SvxChartKindErrorItem & >( 167*cdf0e10cSrcweir rItemSet.Get( nWhichId )).GetValue(); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir if( !xErrorBarProp.is() && eErrorKind == CHERROR_NONE) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir //nothing to do 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir else 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir switch( eErrorKind ) 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir case CHERROR_NONE: 180*cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; break; 181*cdf0e10cSrcweir case CHERROR_VARIANT: 182*cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::VARIANCE; break; 183*cdf0e10cSrcweir case CHERROR_SIGMA: 184*cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION; break; 185*cdf0e10cSrcweir case CHERROR_PERCENT: 186*cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::RELATIVE; break; 187*cdf0e10cSrcweir case CHERROR_BIGERROR: 188*cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN; break; 189*cdf0e10cSrcweir case CHERROR_CONST: 190*cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE; break; 191*cdf0e10cSrcweir case CHERROR_STDERROR: 192*cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR; break; 193*cdf0e10cSrcweir case CHERROR_RANGE: 194*cdf0e10cSrcweir nStyle = ::com::sun::star::chart::ErrorBarStyle::FROM_DATA; break; 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir xErrorBarProp->setPropertyValue( C2U( "ErrorBarStyle" ), 198*cdf0e10cSrcweir uno::makeAny( nStyle )); 199*cdf0e10cSrcweir bChanged = true; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir break; 203*cdf0e10cSrcweir 204*cdf0e10cSrcweir case SCHATTR_STAT_PERCENT: 205*cdf0e10cSrcweir case SCHATTR_STAT_BIGERROR: 206*cdf0e10cSrcweir { 207*cdf0e10cSrcweir OSL_ENSURE( false, "Deprectaed item" ); 208*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet()); 209*cdf0e10cSrcweir 210*cdf0e10cSrcweir double fValue = 211*cdf0e10cSrcweir static_cast< const SvxDoubleItem & >( 212*cdf0e10cSrcweir rItemSet.Get( nWhichId )).GetValue(); 213*cdf0e10cSrcweir double fPos, fNeg; 214*cdf0e10cSrcweir lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir if( ! ( ::rtl::math::approxEqual( fPos, fValue ) && 217*cdf0e10cSrcweir ::rtl::math::approxEqual( fNeg, fValue ))) 218*cdf0e10cSrcweir { 219*cdf0e10cSrcweir xErrorBarProp->setPropertyValue( C2U( "PositiveError" ), 220*cdf0e10cSrcweir uno::makeAny( fValue )); 221*cdf0e10cSrcweir xErrorBarProp->setPropertyValue( C2U( "NegativeError" ), 222*cdf0e10cSrcweir uno::makeAny( fValue )); 223*cdf0e10cSrcweir bChanged = true; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir break; 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir case SCHATTR_STAT_CONSTPLUS: 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir double fValue = 231*cdf0e10cSrcweir static_cast< const SvxDoubleItem & >( 232*cdf0e10cSrcweir rItemSet.Get( nWhichId )).GetValue(); 233*cdf0e10cSrcweir double fPos, fNeg; 234*cdf0e10cSrcweir lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); 235*cdf0e10cSrcweir 236*cdf0e10cSrcweir if( ! ::rtl::math::approxEqual( fPos, fValue )) 237*cdf0e10cSrcweir { 238*cdf0e10cSrcweir GetPropertySet()->setPropertyValue( C2U( "PositiveError" ), uno::makeAny( fValue )); 239*cdf0e10cSrcweir bChanged = true; 240*cdf0e10cSrcweir } 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir break; 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir case SCHATTR_STAT_CONSTMINUS: 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet()); 247*cdf0e10cSrcweir 248*cdf0e10cSrcweir double fValue = 249*cdf0e10cSrcweir static_cast< const SvxDoubleItem & >( 250*cdf0e10cSrcweir rItemSet.Get( nWhichId )).GetValue(); 251*cdf0e10cSrcweir double fPos, fNeg; 252*cdf0e10cSrcweir lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir if( ! ::rtl::math::approxEqual( fNeg, fValue )) 255*cdf0e10cSrcweir { 256*cdf0e10cSrcweir xErrorBarProp->setPropertyValue( C2U( "NegativeError" ), uno::makeAny( fValue )); 257*cdf0e10cSrcweir bChanged = true; 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir break; 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir case SCHATTR_STAT_INDICATE: 263*cdf0e10cSrcweir { 264*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet()); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir SvxChartIndicate eIndicate = 267*cdf0e10cSrcweir static_cast< const SvxChartIndicateItem & >( 268*cdf0e10cSrcweir rItemSet.Get( nWhichId )).GetValue(); 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir bool bNewIndPos = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_UP ); 271*cdf0e10cSrcweir bool bNewIndNeg = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_DOWN ); 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir bool bShowPos, bShowNeg; 274*cdf0e10cSrcweir lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg ); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir if( ( bShowPos != bNewIndPos || 277*cdf0e10cSrcweir bShowNeg != bNewIndNeg )) 278*cdf0e10cSrcweir { 279*cdf0e10cSrcweir xErrorBarProp->setPropertyValue( C2U( "ShowPositiveError" ), uno::makeAny( bNewIndPos )); 280*cdf0e10cSrcweir xErrorBarProp->setPropertyValue( C2U( "ShowNegativeError" ), uno::makeAny( bNewIndNeg )); 281*cdf0e10cSrcweir bChanged = true; 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir } 284*cdf0e10cSrcweir break; 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir case SCHATTR_STAT_RANGE_POS: 287*cdf0e10cSrcweir case SCHATTR_STAT_RANGE_NEG: 288*cdf0e10cSrcweir { 289*cdf0e10cSrcweir // @todo: also be able to deal with x-error bars 290*cdf0e10cSrcweir const bool bYError = true; 291*cdf0e10cSrcweir uno::Reference< chart2::data::XDataSource > xErrorBarSource( GetPropertySet(), uno::UNO_QUERY ); 292*cdf0e10cSrcweir uno::Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY ); 293*cdf0e10cSrcweir uno::Reference< chart2::data::XDataProvider > xDataProvider; 294*cdf0e10cSrcweir 295*cdf0e10cSrcweir if( xChartDoc.is()) 296*cdf0e10cSrcweir xDataProvider.set( xChartDoc->getDataProvider()); 297*cdf0e10cSrcweir if( xErrorBarSource.is() && xDataProvider.is()) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir ::rtl::OUString aNewRange( static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue()); 300*cdf0e10cSrcweir bool bApplyNewRange = false; 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir bool bIsPositiveValue( nWhichId == SCHATTR_STAT_RANGE_POS ); 303*cdf0e10cSrcweir if( xChartDoc->hasInternalDataProvider()) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir if( aNewRange.getLength()) 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir uno::Reference< chart2::data::XDataSequence > xSeq( 308*cdf0e10cSrcweir StatisticsHelper::getErrorDataSequenceFromDataSource( 309*cdf0e10cSrcweir xErrorBarSource, bIsPositiveValue, bYError )); 310*cdf0e10cSrcweir if( ! xSeq.is()) 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir // no data range for error bars yet => create 313*cdf0e10cSrcweir uno::Reference< chart2::XInternalDataProvider > xIntDataProvider( xDataProvider, uno::UNO_QUERY ); 314*cdf0e10cSrcweir OSL_ASSERT( xIntDataProvider.is()); 315*cdf0e10cSrcweir if( xIntDataProvider.is()) 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir xIntDataProvider->appendSequence(); 318*cdf0e10cSrcweir aNewRange = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("last")); 319*cdf0e10cSrcweir bApplyNewRange = true; 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir } 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir else 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir uno::Reference< chart2::data::XDataSequence > xSeq( 327*cdf0e10cSrcweir StatisticsHelper::getErrorDataSequenceFromDataSource( 328*cdf0e10cSrcweir xErrorBarSource, bIsPositiveValue, bYError )); 329*cdf0e10cSrcweir bApplyNewRange = 330*cdf0e10cSrcweir ! ( xSeq.is() && aNewRange.equals( xSeq->getSourceRangeRepresentation())); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir if( bApplyNewRange ) 334*cdf0e10cSrcweir StatisticsHelper::setErrorDataSequence( 335*cdf0e10cSrcweir xErrorBarSource, xDataProvider, aNewRange, bIsPositiveValue, bYError ); 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir break; 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir return bChanged; 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir void ErrorBarItemConverter::FillSpecialItem( 345*cdf0e10cSrcweir sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const 346*cdf0e10cSrcweir throw( uno::Exception ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir switch( nWhichId ) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir case SCHATTR_STAT_KIND_ERROR: 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir SvxChartKindError eErrorKind = CHERROR_NONE; 353*cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet()); 354*cdf0e10cSrcweir 355*cdf0e10cSrcweir sal_Int32 nStyle = 0; 356*cdf0e10cSrcweir if( xErrorBarProp->getPropertyValue( C2U( "ErrorBarStyle" )) >>= nStyle ) 357*cdf0e10cSrcweir { 358*cdf0e10cSrcweir switch( nStyle ) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::NONE: 361*cdf0e10cSrcweir break; 362*cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::VARIANCE: 363*cdf0e10cSrcweir eErrorKind = CHERROR_VARIANT; break; 364*cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION: 365*cdf0e10cSrcweir eErrorKind = CHERROR_SIGMA; break; 366*cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE: 367*cdf0e10cSrcweir eErrorKind = CHERROR_CONST; break; 368*cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::RELATIVE: 369*cdf0e10cSrcweir eErrorKind = CHERROR_PERCENT; break; 370*cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN: 371*cdf0e10cSrcweir eErrorKind = CHERROR_BIGERROR; break; 372*cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR: 373*cdf0e10cSrcweir eErrorKind = CHERROR_STDERROR; break; 374*cdf0e10cSrcweir case ::com::sun::star::chart::ErrorBarStyle::FROM_DATA: 375*cdf0e10cSrcweir eErrorKind = CHERROR_RANGE; break; 376*cdf0e10cSrcweir } 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir rOutItemSet.Put( SvxChartKindErrorItem( eErrorKind, SCHATTR_STAT_KIND_ERROR )); 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir break; 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir case SCHATTR_STAT_PERCENT: 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir double fPos, fNeg; 385*cdf0e10cSrcweir lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); 386*cdf0e10cSrcweir rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId )); 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir break; 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir case SCHATTR_STAT_BIGERROR: 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir double fPos, fNeg; 393*cdf0e10cSrcweir lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); 394*cdf0e10cSrcweir rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId )); 395*cdf0e10cSrcweir } 396*cdf0e10cSrcweir break; 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir case SCHATTR_STAT_CONSTPLUS: 399*cdf0e10cSrcweir { 400*cdf0e10cSrcweir double fPos, fNeg; 401*cdf0e10cSrcweir lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); 402*cdf0e10cSrcweir rOutItemSet.Put( SvxDoubleItem( fPos, nWhichId )); 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir break; 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir case SCHATTR_STAT_CONSTMINUS: 407*cdf0e10cSrcweir { 408*cdf0e10cSrcweir double fPos, fNeg; 409*cdf0e10cSrcweir lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); 410*cdf0e10cSrcweir rOutItemSet.Put( SvxDoubleItem( fNeg, nWhichId )); 411*cdf0e10cSrcweir } 412*cdf0e10cSrcweir break; 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir case SCHATTR_STAT_INDICATE: 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir SvxChartIndicate eIndicate = CHINDICATE_BOTH; 417*cdf0e10cSrcweir bool bShowPos, bShowNeg; 418*cdf0e10cSrcweir lcl_getErrorIndicatorValues( GetPropertySet(), bShowPos, bShowNeg ); 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir if( bShowPos ) 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir if( bShowNeg ) 423*cdf0e10cSrcweir eIndicate = CHINDICATE_BOTH; 424*cdf0e10cSrcweir else 425*cdf0e10cSrcweir eIndicate = CHINDICATE_UP; 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir else 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir if( bShowNeg ) 430*cdf0e10cSrcweir eIndicate = CHINDICATE_DOWN; 431*cdf0e10cSrcweir else 432*cdf0e10cSrcweir eIndicate = CHINDICATE_NONE; 433*cdf0e10cSrcweir } 434*cdf0e10cSrcweir rOutItemSet.Put( SvxChartIndicateItem( eIndicate, SCHATTR_STAT_INDICATE )); 435*cdf0e10cSrcweir } 436*cdf0e10cSrcweir break; 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir case SCHATTR_STAT_RANGE_POS: 439*cdf0e10cSrcweir case SCHATTR_STAT_RANGE_NEG: 440*cdf0e10cSrcweir { 441*cdf0e10cSrcweir uno::Reference< chart2::data::XDataSource > xErrorBarSource( GetPropertySet(), uno::UNO_QUERY ); 442*cdf0e10cSrcweir if( xErrorBarSource.is()) 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir uno::Reference< chart2::data::XDataSequence > xSeq( 445*cdf0e10cSrcweir StatisticsHelper::getErrorDataSequenceFromDataSource( 446*cdf0e10cSrcweir xErrorBarSource, (nWhichId == SCHATTR_STAT_RANGE_POS) /*, true */ /* y */ )); 447*cdf0e10cSrcweir if( xSeq.is()) 448*cdf0e10cSrcweir rOutItemSet.Put( SfxStringItem( nWhichId, String( xSeq->getSourceRangeRepresentation()))); 449*cdf0e10cSrcweir } 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir break; 452*cdf0e10cSrcweir } 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir 455*cdf0e10cSrcweir } // namespace wrapper 456*cdf0e10cSrcweir } // namespace chart 457