summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2019-04-16 11:19:55 +0200
committerLászló Németh <nemeth@numbertext.org>2019-04-17 14:30:17 +0200
commit9be1b6cf5b97727135c7f5e48c971edd8dc45e70 (patch)
tree09706b07954bc5a06bcae6fc90fcef0a8e261f67 /oox
parent74cd1675d80bc1c1609655148546fc960fb99af8 (diff)
tdf#123828 XLSX combined chart export: fix order of axis types
Also fix tdf#123833 and tdf#123837. In combined charts, now axis types are exported in the right order (catAx[1], valAx[1], catAx[2], valAx[2]). The Y axes are exported correctly with the correct axIDs of the chart types: the first one with the primary axId, the second one with the secondary axId. 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 doesn't disappear. Note: don't export the CrossoverPosition/CrossoverValue, if the axis is deleted and invisible, because MSO will show the secondary X axis, even if the axis doesn't exist. The problem was the unnecessary export of the axis with the default css::chart::ChartAxisPosition_END CrossoverPosition value. Change-Id: Id429e654ff0ba45b5f9db877b7c4dd6e65433408 Reviewed-on: https://gerrit.libreoffice.org/70814 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/chartexport.cxx31
1 files changed, 24 insertions, 7 deletions
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 672ae2579d99..54379188649e 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2471,9 +2471,14 @@ void ChartExport::InitPlotArea( )
void ChartExport::exportAxes( )
{
sal_Int32 nSize = maAxes.size();
- for( sal_Int32 nIdx = 0; nIdx < nSize; nIdx++ )
+ // let's export the axis types in the right order
+ for ( sal_Int32 nSortIdx = AXIS_PRIMARY_X; nSortIdx <= AXIS_SECONDARY_Y; nSortIdx++ )
{
- exportAxis( maAxes[nIdx] );
+ for ( sal_Int32 nIdx = 0; nIdx < nSize; nIdx++ )
+ {
+ if (nSortIdx == maAxes[nIdx].nAxisType)
+ exportAxis( maAxes[nIdx] );
+ }
}
}
@@ -2843,7 +2848,8 @@ void ChartExport::_exportAxis(
// crosses & crossesAt
bool bCrossesValue = false;
const char* sCrosses = nullptr;
- if(GetProperty( xAxisProp, "CrossoverPosition" ) )
+ // do not export the CrossoverPosition/CrossoverValue, if the axis is deleted and not visible
+ if( GetProperty( xAxisProp, "CrossoverPosition" ) && !bDeleted && bVisible )
{
css::chart::ChartAxisPosition ePosition( css::chart::ChartAxisPosition_ZERO );
mAny >>= ePosition;
@@ -2874,9 +2880,12 @@ void ChartExport::_exportAxis(
}
else
{
- pFS->singleElement( FSNS( XML_c, XML_crosses ),
- XML_val, sCrosses,
- FSEND );
+ if(sCrosses)
+ {
+ pFS->singleElement(FSNS(XML_c, XML_crosses),
+ XML_val, sCrosses,
+ FSEND);
+ }
}
if( ( nAxisType == XML_catAx )
@@ -3451,8 +3460,16 @@ void ChartExport::exportDataPoints(
void ChartExport::exportAxesId(bool bPrimaryAxes, bool bCheckCombinedAxes)
{
sal_Int32 nAxisIdx, nAxisIdy;
+ bool bPrimaryAxisExists = false;
+ bool bSecondaryAxisExists = false;
+ // let's check which axis already exists and which axis is attached to the actual dataseries
+ if (maAxes.size() >= 2)
+ {
+ bPrimaryAxisExists = bPrimaryAxes && maAxes[1].nAxisType == AXIS_PRIMARY_Y;
+ bSecondaryAxisExists = !bPrimaryAxes && maAxes[1].nAxisType == AXIS_SECONDARY_Y;
+ }
// tdf#114181 keep axes of combined charts
- if ( bCheckCombinedAxes && bPrimaryAxes && maAxes.size() == 2 )
+ if ( bCheckCombinedAxes && ( bPrimaryAxisExists || bSecondaryAxisExists ) )
{
nAxisIdx = maAxes[0].nAxisId;
nAxisIdy = maAxes[1].nAxisId;