diff options
author | Rafael Dominguez <venccsralph@gmail.com> | 2012-03-15 22:20:03 +0000 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-03-23 02:55:30 +0100 |
commit | 701efd06e852c7fa956205cf59154a39621b31a4 (patch) | |
tree | 56dd366f128cfc310319d3fddd229ebe2cb78f6e | |
parent | 2971651cd9d06b8ebf49323e937b78c34cd75609 (diff) |
Add chart errorbar type property.
- Make StatisticsItemConverter work with X and Y errorbars.
- Fill errorbar type property in ErrorBarResources.
- Set default value of errorbar type property to Y bar.
4 files changed, 55 insertions, 22 deletions
diff --git a/chart2/source/controller/dialogs/res_ErrorBar.cxx b/chart2/source/controller/dialogs/res_ErrorBar.cxx index 49359d456f21..823e9ad92b2b 100644 --- a/chart2/source/controller/dialogs/res_ErrorBar.cxx +++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx @@ -684,6 +684,8 @@ sal_Bool ErrorBarResources::FillItemSet(SfxItemSet& rOutAttrs) const } } + rOutAttrs.Put( SfxBoolItem( SCHATTR_STAT_ERRORBAR_TYPE , m_eErrorBarType == ERROR_BAR_Y )); + return sal_True; } diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx index a15fdda68f2a..d3df3e63b8cd 100644 --- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx @@ -58,15 +58,15 @@ using namespace ::com::sun::star; namespace { -uno::Reference< beans::XPropertySet > lcl_GetYErrorBar( - const uno::Reference< beans::XPropertySet > & xProp ) +uno::Reference< beans::XPropertySet > lcl_GetErrorBar( + const uno::Reference< beans::XPropertySet > & xProp, bool bYError ) { uno::Reference< beans::XPropertySet > xResult; if( xProp.is()) try { - ( xProp->getPropertyValue( C2U( "ErrorBarY" )) >>= xResult ); + ( xProp->getPropertyValue( bYError ? C2U( "ErrorBarY" ) : C2U("ErrorBarX") ) >>= xResult ); } catch( const uno::Exception & ex ) { @@ -250,8 +250,11 @@ bool StatisticsItemConverter::ApplySpecialItem( // SCHATTR_STAT_CONSTMINUS and SCHATTR_STAT_INDICATE case SCHATTR_STAT_KIND_ERROR: { + bool bYError = + static_cast<const SfxBoolItem&>(rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE)).GetValue(); + uno::Reference< beans::XPropertySet > xErrorBarProp( - lcl_GetYErrorBar( GetPropertySet() )); + lcl_GetErrorBar( GetPropertySet(), bYError )); SvxChartKindError eErrorKind = static_cast< const SvxChartKindErrorItem & >( @@ -288,8 +291,8 @@ bool StatisticsItemConverter::ApplySpecialItem( if( !xErrorBarProp.is() ) { xErrorBarProp = lcl_GetDefaultErrorBar(); - GetPropertySet()->setPropertyValue( - C2U( "ErrorBarY" ), uno::makeAny( xErrorBarProp )); + GetPropertySet()->setPropertyValue( bYError ? C2U( "ErrorBarY" ) : C2U("ErrorBarX"), + uno::makeAny( xErrorBarProp )); } xErrorBarProp->setPropertyValue( C2U( "ErrorBarStyle" ), @@ -303,8 +306,11 @@ bool StatisticsItemConverter::ApplySpecialItem( case SCHATTR_STAT_BIGERROR: { OSL_FAIL( "Deprectaed item" ); + bool bYError = + static_cast<const SfxBoolItem&>(rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE)).GetValue(); + uno::Reference< beans::XPropertySet > xErrorBarProp( - lcl_GetYErrorBar( GetPropertySet())); + lcl_GetErrorBar( GetPropertySet(), bYError)); bool bOldHasErrorBar = xErrorBarProp.is(); double fValue = @@ -328,8 +334,11 @@ bool StatisticsItemConverter::ApplySpecialItem( case SCHATTR_STAT_CONSTPLUS: { + bool bYError = + static_cast<const SfxBoolItem&>(rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE)).GetValue(); + uno::Reference< beans::XPropertySet > xErrorBarProp( - lcl_GetYErrorBar( GetPropertySet())); + lcl_GetErrorBar( GetPropertySet(),bYError)); bool bOldHasErrorBar = xErrorBarProp.is(); double fValue = @@ -349,8 +358,10 @@ bool StatisticsItemConverter::ApplySpecialItem( case SCHATTR_STAT_CONSTMINUS: { + bool bYError = + static_cast<const SfxBoolItem&>(rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE)).GetValue(); uno::Reference< beans::XPropertySet > xErrorBarProp( - lcl_GetYErrorBar( GetPropertySet())); + lcl_GetErrorBar( GetPropertySet(),bYError)); bool bOldHasErrorBar = xErrorBarProp.is(); double fValue = @@ -436,8 +447,10 @@ bool StatisticsItemConverter::ApplySpecialItem( case SCHATTR_STAT_INDICATE: { + bool bYError = + static_cast<const SfxBoolItem&>(rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE)).GetValue(); uno::Reference< beans::XPropertySet > xErrorBarProp( - lcl_GetYErrorBar( GetPropertySet())); + lcl_GetErrorBar( GetPropertySet(),bYError)); bool bOldHasErrorBar = xErrorBarProp.is(); SvxChartIndicate eIndicate = @@ -464,9 +477,10 @@ bool StatisticsItemConverter::ApplySpecialItem( case SCHATTR_STAT_RANGE_POS: case SCHATTR_STAT_RANGE_NEG: { - // @todo: also be able to deal with x-error bars - const bool bYError = true; - uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetYErrorBar( GetPropertySet()), uno::UNO_QUERY ); + const bool bYError = + static_cast<const SfxBoolItem&>(rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE)).GetValue(); + uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetErrorBar( GetPropertySet(), bYError), + uno::UNO_QUERY ); uno::Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY ); uno::Reference< chart2::data::XDataProvider > xDataProvider; @@ -535,9 +549,11 @@ void StatisticsItemConverter::FillSpecialItem( case SCHATTR_STAT_KIND_ERROR: { + bool bYError = + static_cast<const SfxBoolItem&>(rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE)).GetValue(); SvxChartKindError eErrorKind = CHERROR_NONE; uno::Reference< beans::XPropertySet > xErrorBarProp( - lcl_GetYErrorBar( GetPropertySet())); + lcl_GetErrorBar( GetPropertySet(), bYError)); if( xErrorBarProp.is() ) { sal_Int32 nStyle = 0; @@ -570,7 +586,9 @@ void StatisticsItemConverter::FillSpecialItem( case SCHATTR_STAT_PERCENT: { - uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); + bool bYError = + static_cast<const SfxBoolItem&>(rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE)).GetValue(); + uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError)); if( xErrorBarProp.is()) { double fPos, fNeg; @@ -582,7 +600,9 @@ void StatisticsItemConverter::FillSpecialItem( case SCHATTR_STAT_BIGERROR: { - uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); + bool bYError = + static_cast<const SfxBoolItem&>(rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE)).GetValue(); + uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError)); if( xErrorBarProp.is()) { double fPos, fNeg; @@ -594,7 +614,9 @@ void StatisticsItemConverter::FillSpecialItem( case SCHATTR_STAT_CONSTPLUS: { - uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); + bool bYError = + static_cast<const SfxBoolItem&>(rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE)).GetValue(); + uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError)); if( xErrorBarProp.is()) { double fPos, fNeg; @@ -606,7 +628,9 @@ void StatisticsItemConverter::FillSpecialItem( case SCHATTR_STAT_CONSTMINUS: { - uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); + bool bYError = + static_cast<const SfxBoolItem&>(rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE)).GetValue(); + uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError)); if( xErrorBarProp.is()) { double fPos, fNeg; @@ -649,7 +673,9 @@ void StatisticsItemConverter::FillSpecialItem( case SCHATTR_STAT_INDICATE: { - uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); + bool bYError = + static_cast<const SfxBoolItem&>(rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE)).GetValue(); + uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetErrorBar( GetPropertySet(),bYError)); SvxChartIndicate eIndicate = CHINDICATE_BOTH; if( xErrorBarProp.is()) { @@ -678,12 +704,15 @@ void StatisticsItemConverter::FillSpecialItem( case SCHATTR_STAT_RANGE_POS: case SCHATTR_STAT_RANGE_NEG: { - uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetYErrorBar( GetPropertySet()), uno::UNO_QUERY ); + bool bYError = + static_cast<const SfxBoolItem&>(rOutItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE)).GetValue(); + uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetErrorBar( GetPropertySet(),bYError), + uno::UNO_QUERY ); if( xErrorBarSource.is()) { uno::Reference< chart2::data::XDataSequence > xSeq( StatisticsHelper::getErrorDataSequenceFromDataSource( - xErrorBarSource, (nWhichId == SCHATTR_STAT_RANGE_POS) /*, true */ /* y */ )); + xErrorBarSource, (nWhichId == SCHATTR_STAT_RANGE_POS), bYError )); if( xSeq.is()) rOutItemSet.Put( SfxStringItem( nWhichId, String( xSeq->getSourceRangeRepresentation()))); } diff --git a/chart2/source/inc/chartview/ChartSfxItemIds.hxx b/chart2/source/inc/chartview/ChartSfxItemIds.hxx index 48b638ea929b..61251fe96ef3 100644 --- a/chart2/source/inc/chartview/ChartSfxItemIds.hxx +++ b/chart2/source/inc/chartview/ChartSfxItemIds.hxx @@ -71,7 +71,8 @@ #define SCHATTR_STAT_INDICATE (SCHATTR_STAT_START + 6) #define SCHATTR_STAT_RANGE_POS (SCHATTR_STAT_START + 7) #define SCHATTR_STAT_RANGE_NEG (SCHATTR_STAT_START + 8) -#define SCHATTR_STAT_END SCHATTR_STAT_RANGE_NEG +#define SCHATTR_STAT_ERRORBAR_TYPE (SCHATTR_STAT_START + 9) +#define SCHATTR_STAT_END SCHATTR_STAT_ERRORBAR_TYPE // -------------------------------------------------------- // these attributes are for replacement of enum eChartStyle diff --git a/chart2/source/view/main/ChartItemPool.cxx b/chart2/source/view/main/ChartItemPool.cxx index cbf70695acca..289b1879365a 100644 --- a/chart2/source/view/main/ChartItemPool.cxx +++ b/chart2/source/view/main/ChartItemPool.cxx @@ -83,6 +83,7 @@ ChartItemPool::ChartItemPool(): ppPoolDefaults[SCHATTR_STAT_INDICATE - SCHATTR_START] = new SvxChartIndicateItem (CHINDICATE_NONE, SCHATTR_STAT_INDICATE); ppPoolDefaults[SCHATTR_STAT_RANGE_POS - SCHATTR_START] = new SfxStringItem (SCHATTR_STAT_RANGE_POS, String()); ppPoolDefaults[SCHATTR_STAT_RANGE_NEG - SCHATTR_START] = new SfxStringItem (SCHATTR_STAT_RANGE_NEG, String()); + ppPoolDefaults[SCHATTR_STAT_ERRORBAR_TYPE - SCHATTR_START] = new SfxBoolItem(SCHATTR_STAT_ERRORBAR_TYPE, true); ppPoolDefaults[SCHATTR_STYLE_DEEP - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_DEEP, 0); ppPoolDefaults[SCHATTR_STYLE_3D - SCHATTR_START] = new SfxBoolItem (SCHATTR_STYLE_3D, 0); |