diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-07-07 16:38:29 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-07-07 19:06:21 -0400 |
commit | b8c444a46b2f41dae673c6118d84276be0e6c87d (patch) | |
tree | b8b0281efaf850a445274012c57f2b2cd5121105 /oox | |
parent | af5a6615dfdbe5c2cacdcacb00fc6f418b925c06 (diff) |
bnc#881025: Mark axis a percent axis only when all data series are percent.
Change-Id: I302cc1e5b164b2ce9999087293b034ec930951af
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/drawingml/chart/axisconverter.hxx | 10 | ||||
-rw-r--r-- | oox/source/drawingml/chart/axisconverter.cxx | 38 | ||||
-rw-r--r-- | oox/source/drawingml/chart/plotareaconverter.cxx | 6 |
3 files changed, 38 insertions, 16 deletions
diff --git a/oox/inc/drawingml/chart/axisconverter.hxx b/oox/inc/drawingml/chart/axisconverter.hxx index e3cb8d09b10f..fd464add9eb7 100644 --- a/oox/inc/drawingml/chart/axisconverter.hxx +++ b/oox/inc/drawingml/chart/axisconverter.hxx @@ -60,12 +60,10 @@ public: virtual ~AxisConverter(); /** Creates a chart2 axis and inserts it into the passed coordinate system. */ - void convertFromModel( - const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XCoordinateSystem >& rxCoordSystem, - TypeGroupConverter& rTypeGroup, - const AxisModel* pCrossingAxis, - sal_Int32 nAxesSetIdx, - sal_Int32 nAxisIdx ); + void convertFromModel( + const css::uno::Reference<css::chart2::XCoordinateSystem>& rxCoordSystem, + RefVector<TypeGroupConverter>& rTypeGroups, const AxisModel* pCrossingAxis, + sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx ); }; diff --git a/oox/source/drawingml/chart/axisconverter.cxx b/oox/source/drawingml/chart/axisconverter.cxx index 075f6a068736..ed74ef5ef407 100644 --- a/oox/source/drawingml/chart/axisconverter.cxx +++ b/oox/source/drawingml/chart/axisconverter.cxx @@ -103,6 +103,26 @@ sal_Int32 lclGetTickMark( sal_Int32 nToken ) return NONE; } +/** + * The groups is of percent type only when all of its members are of percent + * type. + */ +bool isPercent( const RefVector<TypeGroupConverter>& rTypeGroups ) +{ + if (rTypeGroups.empty()) + return false; + + RefVector<TypeGroupConverter>::const_iterator it = rTypeGroups.begin(), itEnd = rTypeGroups.end(); + for (; it != itEnd; ++it) + { + TypeGroupConverter& rConv = **it; + if (!rConv.isPercent()) + return false; + } + + return true; +} + } // namespace AxisConverter::AxisConverter( const ConverterRoot& rParent, AxisModel& rModel ) : @@ -114,16 +134,20 @@ AxisConverter::~AxisConverter() { } -void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCoordSystem, - TypeGroupConverter& rTypeGroup, const AxisModel* pCrossingAxis, sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx ) +void AxisConverter::convertFromModel( + const Reference< XCoordinateSystem >& rxCoordSystem, + RefVector<TypeGroupConverter>& rTypeGroups, const AxisModel* pCrossingAxis, sal_Int32 nAxesSetIdx, sal_Int32 nAxisIdx ) { + if (rTypeGroups.empty()) + return; + Reference< XAxis > xAxis; try { namespace cssc = ::com::sun::star::chart; namespace cssc2 = ::com::sun::star::chart2; - const TypeGroupInfo& rTypeInfo = rTypeGroup.getTypeInfo(); + const TypeGroupInfo& rTypeInfo = rTypeGroups.front()->getTypeInfo(); ObjectFormatter& rFormatter = getFormatter(); // create the axis object (always) @@ -183,7 +207,7 @@ void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCo currently). */ aScaleData.AxisType = (bDateAxis && !mrModel.mbAuto) ? cssc2::AxisType::DATE : cssc2::AxisType::CATEGORY; aScaleData.AutoDateAxis = mrModel.mbAuto; - aScaleData.Categories = rTypeGroup.createCategorySequence(); + aScaleData.Categories = rTypeGroups.front()->createCategorySequence(); } else { @@ -193,11 +217,11 @@ void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCo break; case API_Y_AXIS: OSL_ENSURE( mrModel.mnTypeId == C_TOKEN( valAx ), "AxisConverter::convertFromModel - unexpected axis model type (must: c:valAx)" ); - aScaleData.AxisType = rTypeGroup.isPercent() ? cssc2::AxisType::PERCENT : cssc2::AxisType::REALNUMBER; + aScaleData.AxisType = isPercent(rTypeGroups) ? cssc2::AxisType::PERCENT : cssc2::AxisType::REALNUMBER; break; case API_Z_AXIS: OSL_ENSURE( mrModel.mnTypeId == C_TOKEN( serAx ), "AxisConverter::convertFromModel - unexpected axis model type (must: c:serAx)" ); - OSL_ENSURE( rTypeGroup.isDeep3dChart(), "AxisConverter::convertFromModel - series axis not supported by this chart type" ); + OSL_ENSURE( rTypeGroups.front()->isDeep3dChart(), "AxisConverter::convertFromModel - series axis not supported by this chart type" ); aScaleData.AxisType = cssc2::AxisType::SERIES; break; } @@ -324,7 +348,7 @@ void AxisConverter::convertFromModel( const Reference< XCoordinateSystem >& rxCo // axis title --------------------------------------------------------- // in radar charts, title objects may exist, but are not shown - if( mrModel.mxTitle.is() && (rTypeGroup.getTypeInfo().meTypeCategory != TYPECATEGORY_RADAR) ) + if( mrModel.mxTitle.is() && (rTypeGroups.front()->getTypeInfo().meTypeCategory != TYPECATEGORY_RADAR) ) { Reference< XTitled > xTitled( xAxis, UNO_QUERY_THROW ); TitleConverter aTitleConv( *this, *mrModel.mxTitle ); diff --git a/oox/source/drawingml/chart/plotareaconverter.cxx b/oox/source/drawingml/chart/plotareaconverter.cxx index c8980daeb8b7..f79bab8eef55 100644 --- a/oox/source/drawingml/chart/plotareaconverter.cxx +++ b/oox/source/drawingml/chart/plotareaconverter.cxx @@ -163,15 +163,15 @@ void AxesSetConverter::convertFromModel( const Reference< XDiagram >& rxDiagram, ModelRef< AxisModel > xYAxis = lclGetOrCreateAxis( mrModel.maAxes, API_Y_AXIS, C_TOKEN( valAx ) ); AxisConverter aXAxisConv( *this, *xXAxis ); - aXAxisConv.convertFromModel( xCoordSystem, rFirstTypeGroup, xYAxis.get(), nAxesSetIdx, API_X_AXIS ); + aXAxisConv.convertFromModel( xCoordSystem, aTypeGroups, xYAxis.get(), nAxesSetIdx, API_X_AXIS ); AxisConverter aYAxisConv( *this, *xYAxis ); - aYAxisConv.convertFromModel( xCoordSystem, rFirstTypeGroup, xXAxis.get(), nAxesSetIdx, API_Y_AXIS ); + aYAxisConv.convertFromModel( xCoordSystem, aTypeGroups, xXAxis.get(), nAxesSetIdx, API_Y_AXIS ); if( rFirstTypeGroup.isDeep3dChart() ) { ModelRef< AxisModel > xZAxis = lclGetOrCreateAxis( mrModel.maAxes, API_Z_AXIS, C_TOKEN( serAx ) ); AxisConverter aZAxisConv( *this, *xZAxis ); - aZAxisConv.convertFromModel( xCoordSystem, rFirstTypeGroup, 0, nAxesSetIdx, API_Z_AXIS ); + aZAxisConv.convertFromModel( xCoordSystem, aTypeGroups, 0, nAxesSetIdx, API_Z_AXIS ); } // convert all chart type groups, this converts all series data and formatting |