diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2019-04-09 16:12:35 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-04-15 09:12:59 +0200 |
commit | 11473832b5717cb3222ce72baee885bc9e8e2386 (patch) | |
tree | 2285cd4abdf37f14b7c6f14fd2528607e96abefe /oox/source | |
parent | e21bc3267776d89e26368b62963fc57dc792f743 (diff) |
tdf#114181 XLSX combined chart: fix swapped primary and secondary axes etc.
In combined charts, now X category axis crosses the Y axis at the right
place, all data series are attached to the right Y axis, and the
Y major grid isn't lost.
Note: Let's check which axis is attached to the first charttype
(in case of combined chart, the first one is a column chart) and create
that axis first. In OOXML standard, the first CT_valAx tag contains the
axID of the primary axis and the second CT_valAx tag contains the axID
of the secondary axis.
Change-Id: Ib123f95ec41ef5dbbf0599efd7a646f4640a9b70
Reviewed-on: https://gerrit.libreoffice.org/70464
Reviewed-by: László Németh <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox/source')
-rw-r--r-- | oox/source/drawingml/chart/plotareaconverter.cxx | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/oox/source/drawingml/chart/plotareaconverter.cxx b/oox/source/drawingml/chart/plotareaconverter.cxx index f3a4b8ebe493..8afdfda365ea 100644 --- a/oox/source/drawingml/chart/plotareaconverter.cxx +++ b/oox/source/drawingml/chart/plotareaconverter.cxx @@ -335,12 +335,36 @@ void PlotAreaConverter::convertFromModel( View3DModel& rView3DModel ) // store all axis models in a map, keyed by axis identifier typedef ModelMap< sal_Int32, AxisModel > AxisMap; AxisMap aAxisMap; + std::vector<sal_Int32>rValAxisIds; + std::vector<sal_Int32>rRealValAxisIds; + + for (auto const& atypeGroup : mrModel.maTypeGroups) + { + if (atypeGroup->maAxisIds.size() > 1) + { + // let's collect which axId belongs to the Y Axis according to maTypeGroups + rRealValAxisIds.push_back(atypeGroup->maAxisIds[1]); + } + } + for (auto const& axis : mrModel.maAxes) { OSL_ENSURE( axis->mnAxisId >= 0, "PlotAreaConverter::convertFromModel - invalid axis identifier" ); OSL_ENSURE( !aAxisMap.has( axis->mnAxisId ), "PlotAreaConverter::convertFromModel - axis identifiers not unique" ); if( axis->mnAxisId != -1 ) aAxisMap[ axis->mnAxisId ] = axis; + + if ( axis->mnAxisId != -1 && axis->mnTypeId == C_TOKEN(valAx) ) + { + for (size_t i = 0; i < rRealValAxisIds.size(); i++) + { + if (axis->mnAxisId == rRealValAxisIds[i]) + { + // let's collect which axId belongs to the Y Axis according to maAxes + rValAxisIds.push_back(axis->mnAxisId); + } + } + } } // group the type group models into different axes sets @@ -390,13 +414,15 @@ void PlotAreaConverter::convertFromModel( View3DModel& rView3DModel ) // varying point colors only for single series in single chart type bool bSupportsVaryColorsByPoint = mrModel.maTypeGroups.size() == 1; - // convert all axes sets - sal_Int32 nAxesSetIdx = 0; + // convert all axes sets, and check which axis is attached to the first maTypeGroups + sal_Int32 nStartAxesSetIdx = (rValAxisIds.size() > 1 && aAxesSets[0]->maAxes[1]->mnAxisId != rValAxisIds[0] ) ? 1 : 0; + sal_Int32 nAxesSetIdx = nStartAxesSetIdx; + for (auto const& axesSet : aAxesSets) { AxesSetConverter aAxesSetConv(*this, *axesSet); aAxesSetConv.convertFromModel( xDiagram, rView3DModel, nAxesSetIdx, bSupportsVaryColorsByPoint ); - if( nAxesSetIdx == 0 ) + if(nAxesSetIdx == nStartAxesSetIdx) { maAutoTitle = aAxesSetConv.getAutomaticTitle(); mb3dChart = aAxesSetConv.is3dChart(); @@ -407,7 +433,7 @@ void PlotAreaConverter::convertFromModel( View3DModel& rView3DModel ) { maAutoTitle.clear(); } - ++nAxesSetIdx; + nAxesSetIdx = 1 - nAxesSetIdx; } DataTableConverter dataTableConverter (*this, mrModel.mxDataTable.getOrCreate()); |