[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - chart2/qa chart2/source
Balazs Varga (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 25 10:19:20 UTC 2020
chart2/qa/extras/chart2import.cxx | 2 -
chart2/source/view/charttypes/PieChart.cxx | 45 ++++++++++++++---------------
2 files changed, 23 insertions(+), 24 deletions(-)
New commits:
commit 2bb5d9624911eb78ce5a3cd0aa122f9307c50a5c
Author: Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Tue Jun 16 12:07:45 2020 +0200
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Thu Jun 25 12:18:50 2020 +0200
tdf#134029 Chart view: enable to move data label
if the position is 'Best Fit' and the data label is
outside from the pie chart.
To check the functionality of the patch: open the attached file
http://bugs.documentfoundation.org/attachment.cgi?id=162039 and
move the data label.
Change-Id: I88546c64dd62ab40b35400b0330f7899ba09123f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96452
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit c66cb6d6e4a843dc7c7d06e1c2c0723a6ff85fc5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97000
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 4a6f07d5f310..3e0704c876ae 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -2523,7 +2523,7 @@ void Chart2ImportTest::testTdf133376()
CPPUNIT_ASSERT(xDataPointLabel.is());
// Check the position of the 3rd data point label, which is out from the pie slice
awt::Point aLabelPosition = xDataPointLabel->getPosition();
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1466, aLabelPosition.X, 30);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1071, aLabelPosition.X, 30);
CPPUNIT_ASSERT_DOUBLES_EQUAL(5269, aLabelPosition.Y, 30);
}
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index 03e928a85c23..9032b40977f1 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -1581,16 +1581,10 @@ void PieChart::performLabelBestFit(ShapeParam& rShapeParam, PieLabelInfo const &
return;
// If it does not fit inside, let's put it outside
- PolarLabelPositionHelper aPolarPosHelper(m_pPosHelper.get(),m_nDimension,m_xLogicTarget,m_pShapeFactory);
- auto eAlignment = LABEL_ALIGN_CENTER;
- awt::Point aScreenPosition2D(
- aPolarPosHelper.getLabelScreenPositionAndAlignmentForUnitCircleValues(eAlignment, css::chart::DataLabelPlacement::OUTSIDE
- , rShapeParam.mfUnitCircleStartAngleDegree, rShapeParam.mfUnitCircleWidthAngleDegree
- , rShapeParam.mfUnitCircleInnerRadius, rShapeParam.mfUnitCircleOuterRadius, rShapeParam.mfLogicZ+0.5, 0 ));
+ awt::Point aOldPos(rPieLabelInfo.xLabelGroupShape->getPosition());
basegfx::B2IVector aTranslationVector = rPieLabelInfo.aFirstPosition - rPieLabelInfo.aOrigin;
- aTranslationVector.setLength(150);
- aScreenPosition2D.X += aTranslationVector.getX();
- aScreenPosition2D.Y += aTranslationVector.getY();
+ awt::Point aScreenPosition2D(aOldPos.X + aTranslationVector.getX(),
+ aOldPos.Y + aTranslationVector.getY());
double fAngleDegree = rShapeParam.mfUnitCircleStartAngleDegree + rShapeParam.mfUnitCircleWidthAngleDegree / 2.0;
::basegfx::B2IRectangle aBb(lcl_getRect(rPieLabelInfo.xLabelGroupShape));
@@ -1602,29 +1596,34 @@ void PieChart::performLabelBestFit(ShapeParam& rShapeParam, PieLabelInfo const &
while (fAngleDegree < 0.0)
fAngleDegree += 360.0;
- if( fAngleDegree <= 22.5 || fAngleDegree >= 337.5 )
- aScreenPosition2D.Y -= fLabelHeight / 2;
- else if( fAngleDegree < 67.5 )
- aScreenPosition2D.Y -= fLabelHeight;
- else if( fAngleDegree < 112.5 )
+ if (fAngleDegree <= 22.5 || fAngleDegree >= 337.5)
+ aScreenPosition2D.X += fLabelWidth / 2;
+ else if (fAngleDegree < 67.5)
{
- aScreenPosition2D.X -= fLabelWidth / 2;
- aScreenPosition2D.Y -= fLabelHeight;
+ aScreenPosition2D.X += fLabelWidth / 2;
+ aScreenPosition2D.Y -= fLabelHeight / 2;
}
+ else if (fAngleDegree < 112.5)
+ aScreenPosition2D.Y -= fLabelHeight / 2;
else if (fAngleDegree <= 157.5)
{
- aScreenPosition2D.X -= fLabelWidth;
- aScreenPosition2D.Y -= fLabelHeight;
+ aScreenPosition2D.X -= fLabelWidth / 2;
+ aScreenPosition2D.Y -= fLabelHeight / 2;
}
else if (fAngleDegree <= 202.5)
+ aScreenPosition2D.X -= fLabelWidth / 2;
+ else if (fAngleDegree < 247.5)
{
- aScreenPosition2D.X -= fLabelWidth;
- aScreenPosition2D.Y -= fLabelHeight / 2;
+ aScreenPosition2D.X -= fLabelWidth / 2;
+ aScreenPosition2D.Y += fLabelHeight / 2;
}
- else if (fAngleDegree < 247.5)
- aScreenPosition2D.X -= fLabelWidth;
else if (fAngleDegree < 292.5)
- aScreenPosition2D.X -= fLabelWidth / 2;
+ aScreenPosition2D.Y += fLabelHeight / 2;
+ else
+ {
+ aScreenPosition2D.X += fLabelWidth / 2;
+ aScreenPosition2D.Y += fLabelHeight / 2;
+ }
rPieLabelInfo.xLabelGroupShape->setPosition(aScreenPosition2D);
}
More information about the Libreoffice-commits
mailing list