[Libreoffice-commits] core.git: chart2/qa chart2/source

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 19 12:43:55 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 c66cb6d6e4a843dc7c7d06e1c2c0723a6ff85fc5
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Tue Jun 16 12:07:45 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri Jun 19 14:43:20 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>

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 804f154333e8..6e78a08d67d1 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -2521,7 +2521,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