summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorTünde Tóth <toth.tunde@nisz.hu>2020-11-16 11:57:44 +0100
committerLászló Németh <nemeth@numbertext.org>2020-11-17 10:10:04 +0100
commit3c7d0c8a32f71d597f33c9219fe8099e5381ca35 (patch)
tree39911424c00dee8f50f30e7757e3f66dfe16987f /chart2
parent8ef6067596cf4b2c52fbce94b44bf7af9fefa643 (diff)
tdf#138018 don't show leader lines inside pie chart
Show leader lines to data labels in custom position only outside of pie chart, as intended. Change-Id: I87dee2d33f4f876ffca208f69a069e1f0bcee688 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105920 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/view/charttypes/PieChart.cxx38
1 files changed, 23 insertions, 15 deletions
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index b3dd54dec86d..7bf2eaa2a89b 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -492,23 +492,31 @@ void PieChart::createTextLabelShape(
else if (nY1 > aRect.getMaxY())
nY2 = aRect.getMaxY();
- drawing::PointSequenceSequence aPoints(1);
- aPoints[0].realloc(2);
- aPoints[0][0].X = nX1;
- aPoints[0][0].Y = nY1;
- aPoints[0][1].X = nX2;
- aPoints[0][1].Y = nY2;
-
- uno::Reference<beans::XPropertySet> xProp(aPieLabelInfo.xTextShape, uno::UNO_QUERY);
- VLineProperties aVLineProperties;
- if (xProp.is())
+ sal_Int32 nSquaredDistanceFromOrigin
+ = (nX2 - aOrigin.X) * (nX2 - aOrigin.X) + (nY2 - aOrigin.Y) * (nY2 - aOrigin.Y);
+
+ // tdf#138018 Don't show leader line when custom positioned data label is inside pie chart
+ if (nSquaredDistanceFromOrigin > fSquaredPieRadius)
{
- sal_Int32 nColor = 0;
- xProp->getPropertyValue("CharColor") >>= nColor;
- if (nColor != -1) //automatic font color does not work for lines -> fallback to black
- aVLineProperties.Color <<= nColor;
+ drawing::PointSequenceSequence aPoints(1);
+ aPoints[0].realloc(2);
+ aPoints[0][0].X = nX1;
+ aPoints[0][0].Y = nY1;
+ aPoints[0][1].X = nX2;
+ aPoints[0][1].Y = nY2;
+
+ uno::Reference<beans::XPropertySet> xProp(aPieLabelInfo.xTextShape, uno::UNO_QUERY);
+ VLineProperties aVLineProperties;
+ if (xProp.is())
+ {
+ sal_Int32 nColor = 0;
+ xProp->getPropertyValue("CharColor") >>= nColor;
+ //automatic font color does not work for lines -> fallback to black
+ if (nColor != -1)
+ aVLineProperties.Color <<= nColor;
+ }
+ m_pShapeFactory->createLine2D(xTextTarget, aPoints, &aVLineProperties);
}
- m_pShapeFactory->createLine2D(xTextTarget, aPoints, &aVLineProperties);
}
aPieLabelInfo.fValue = nVal;