tdf#50934: Try to fix wedge ordering for imported of-pie charts
Change-Id: I6e9a0d5426fb213c99ee99092596f68d688b928c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160736
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index 402857b..61583c9 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -178,6 +178,14 @@ bool PiePositionHelper::getInnerAndOuterRadius( double fCategoryX
return true;
}
bool PiePositionHelper::clockwiseWedges() const
{
const ExplicitScaleData& rAngleScale = m_bSwapXAndY ? m_aScales[1] : m_aScales[0];
return rAngleScale.Orientation == AxisOrientation_MATHEMATICAL;
}
PieChart::PieChart( const rtl::Reference<ChartType>& xChartTypeModel
, sal_Int32 nDimensionCount
, bool bExcludingPositioning )
@@ -1087,8 +1095,9 @@ void PieChart::createOneRing([[maybe_unused]]enum SubPieType eType,
// Left of-pie has the "composite" wedge (the one expanded in the right
// subgraph) facing to the right in the chart, to allow the expansion
// lines to meet it
double compositeVal = pDataSrc->getData(pSeries, nRingPtCnt - 1, eType);
return compositeVal * 360 / (ringSum * 2);
const double compositeVal = pDataSrc->getData(pSeries, nRingPtCnt - 1, eType);
const double degAng = compositeVal * 360 / (ringSum * 2);
return m_aPosHelper.clockwiseWedges() ? 360 - degAng : degAng;
} else {
/// The angle degree offset is set by the same property of the
/// data series.
diff --git a/chart2/source/view/charttypes/PieChart.hxx b/chart2/source/view/charttypes/PieChart.hxx
index a3e4519..abcf1cc 100644
--- a/chart2/source/view/charttypes/PieChart.hxx
+++ b/chart2/source/view/charttypes/PieChart.hxx
@@ -39,6 +39,10 @@ public:
bool getInnerAndOuterRadius( double fCategoryX, double& fLogicInnerRadius, double& fLogicOuterRadius, bool bUseRings, double fMaxOffset ) const;
// Determine if the pie wedges are ordered clockwise (returns true) or
// counterclockwise (returns false)
bool clockwiseWedges() const;
public:
//Distance between different category rings, seen relative to width of a ring:
double m_fRingDistance; //>=0 m_fRingDistance=1 --> distance == width
@@ -222,6 +226,9 @@ struct PieLabelInfo;
sal_Int32 n3DRelativeHeight);
private: //member
// Constants for of-pie charts. Some of these will want to become
// user-selectable values. TODO
// Radius scalings for left and right of-pie subcharts
static constexpr double m_fLeftScale = 2.0/3;
static constexpr double m_fRightScale = 1.0/3;