diff options
author | Tünde Tóth <toth.tunde@nisz.hu> | 2020-11-16 11:57:44 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-11-17 10:10:04 +0100 |
commit | 3c7d0c8a32f71d597f33c9219fe8099e5381ca35 (patch) | |
tree | 39911424c00dee8f50f30e7757e3f66dfe16987f | |
parent | 8ef6067596cf4b2c52fbce94b44bf7af9fefa643 (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>
-rw-r--r-- | chart2/source/view/charttypes/PieChart.cxx | 38 | ||||
-rw-r--r-- | sw/qa/extras/layout/data/tdf138018.docx | bin | 0 -> 27131 bytes | |||
-rw-r--r-- | sw/qa/extras/layout/layout2.cxx | 17 |
3 files changed, 40 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; diff --git a/sw/qa/extras/layout/data/tdf138018.docx b/sw/qa/extras/layout/data/tdf138018.docx Binary files differnew file mode 100644 index 000000000000..96183f94946f --- /dev/null +++ b/sw/qa/extras/layout/data/tdf138018.docx diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 271087fbbad3..86bc9f43688c 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -893,6 +893,23 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf134121) assertXPath(pXmlDoc, "//polyline", 1); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf138018) +{ + SwDoc* pDoc = createDoc("tdf138018.docx"); + SwDocShell* pShell = pDoc->GetDocShell(); + + // Dump the rendering of the first page as an XML file. + std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 2 + // - Actual : 3 + // i.e. the leader line was visible. + assertXPath(pXmlDoc, "//polyline", 2); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf130380) { SwDoc* pDoc = createDoc("tdf130380.docx"); |