chart2/qa/extras/chart2dump/chart2dump.cxx | 3 + chart2/qa/extras/chart2dump/data/pie_chart_100_and_0.ods |binary chart2/qa/extras/chart2dump/reference/piecharttest/pie_chart_100_and_0.txt | 20 ++++++++++ chart2/source/view/main/PlottingPositionHelper.cxx | 17 +++++--- chart2/source/view/main/PolarLabelPositionHelper.cxx | 8 ++-- chart2/source/view/main/ShapeFactory.cxx | 11 ++++- 6 files changed, 46 insertions(+), 13 deletions(-)
New commits: commit 166a4989a0d1e5a6271c66bceb73a27970afc882 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Tue Mar 19 21:27:20 2019 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Tue Mar 19 22:28:59 2019 +0100 tdf#123504: 0 and 360 are different angles in charts This partly reverts commit 81302f33073e7629d724ed269f1fa21dad29e141. Change-Id: I40cbe739eb4497b8217aca56a2c3661ed1e491f4 Reviewed-on: https://gerrit.libreoffice.org/69440 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/chart2/qa/extras/chart2dump/chart2dump.cxx b/chart2/qa/extras/chart2dump/chart2dump.cxx index 030fb92e9918..4e91eeb9aa96 100644 --- a/chart2/qa/extras/chart2dump/chart2dump.cxx +++ b/chart2/qa/extras/chart2dump/chart2dump.cxx @@ -855,7 +855,8 @@ DECLARE_DUMP_TEST(PieChartTest, Chart2DumpTest, false) "rotated_pie_chart.ods", "exploded_pie_chart.ods", "donut_chart.ods", - "pie_chart_many_slices.ods" + "pie_chart_many_slices.ods", + "pie_chart_100_and_0.ods", }; for (const OUString& sTestFile : aTestFiles) diff --git a/chart2/qa/extras/chart2dump/data/pie_chart_100_and_0.ods b/chart2/qa/extras/chart2dump/data/pie_chart_100_and_0.ods new file mode 100644 index 000000000000..a6ff5d6aa0e1 Binary files /dev/null and b/chart2/qa/extras/chart2dump/data/pie_chart_100_and_0.ods differ diff --git a/chart2/qa/extras/chart2dump/reference/piecharttest/pie_chart_100_and_0.txt b/chart2/qa/extras/chart2dump/reference/piecharttest/pie_chart_100_and_0.txt new file mode 100644 index 000000000000..40db143f4881 --- /dev/null +++ b/chart2/qa/extras/chart2dump/reference/piecharttest/pie_chart_100_and_0.txt @@ -0,0 +1,20 @@ +// nSeriesCount +1 +/// Series 0 slices +// nSlicesCountInSeries +1 +/// /D=0:CS=0:CT=0:Series=0:Point=0 +// aSlicePosition.X +3210 +// aSlicePosition.Y +180 +// aSliceSize.Height +8639 +// aSliceSize.Width +8639 +// aSliceTransformation +8639;0;3210;0;8639;180;0;0;1 +// static_cast<sal_Int32>(aSliceFillStyle) +1 +// static_cast<sal_Int32>(aSliceFillColor) +17798 \ No newline at end of file diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx index 2382894e383a..c2c2d25b4c9c 100644 --- a/chart2/source/view/main/PlottingPositionHelper.cxx +++ b/chart2/source/view/main/PlottingPositionHelper.cxx @@ -32,7 +32,6 @@ #include <com/sun/star/drawing/XShapes.hpp> #include <rtl/math.hxx> -#include <tools/helpers.hxx> namespace chart { @@ -417,10 +416,11 @@ double PolarPlottingPositionHelper::getWidthAngleDegree( double& fStartLogicValu && !::rtl::math::approxEqual( fStartLogicValueOnAngleAxis, fEndLogicValueOnAngleAxis ) ) fWidthAngleDegree = 360.0; - while(fWidthAngleDegree<0.0) - fWidthAngleDegree+=360.0; - while(fWidthAngleDegree>360.0) - fWidthAngleDegree-=360.0; + // tdf#123504: both 0 and 360 are valid and different values here! + while (fWidthAngleDegree < 0.0) + fWidthAngleDegree += 360.0; + while (fWidthAngleDegree > 360.0) + fWidthAngleDegree -= 360.0; return fWidthAngleDegree; } @@ -473,7 +473,12 @@ double PolarPlottingPositionHelper::transformToAngleDegree( double fLogicValueOn fRet = m_fAngleDegreeOffset + fAxisAngleScaleDirection*(fScaledLogicAngleValue-MinAngleValue)*360.0 /fabs(MaxAngleValue-MinAngleValue); - return NormAngle360(fRet); + // tdf#123504: both 0 and 360 are valid and different values here! + while (fRet > 360.0) + fRet -= 360.0; + while (fRet < 0) + fRet += 360.0; + return fRet; } /** diff --git a/chart2/source/view/main/PolarLabelPositionHelper.cxx b/chart2/source/view/main/PolarLabelPositionHelper.cxx index 6cea12f672cc..a3e9a7cd9778 100644 --- a/chart2/source/view/main/PolarLabelPositionHelper.cxx +++ b/chart2/source/view/main/PolarLabelPositionHelper.cxx @@ -24,8 +24,6 @@ #include <com/sun/star/chart/DataLabelPlacement.hpp> -#include <tools/helpers.hxx> - namespace chart { using namespace ::com::sun::star; @@ -123,7 +121,11 @@ awt::Point PolarLabelPositionHelper::getLabelScreenPositionAndAlignmentForUnitCi //set LabelAlignment if( !bCenter ) { - fAngleDegree = NormAngle360(fAngleDegree); + // tdf#123504: both 0 and 360 are valid and different values here! + while (fAngleDegree > 360.0) + fAngleDegree -= 360.0; + while (fAngleDegree < 0.0) + fAngleDegree += 360.0; bool bOutside = nLabelPlacement == css::chart::DataLabelPlacement::OUTSIDE; diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx index 76db6791d2d8..a297f3c14295 100644 --- a/chart2/source/view/main/ShapeFactory.cxx +++ b/chart2/source/view/main/ShapeFactory.cxx @@ -870,7 +870,11 @@ uno::Reference< drawing::XShape > if( !xTarget.is() ) return nullptr; - fUnitCircleWidthAngleDegree = NormAngle360(fUnitCircleWidthAngleDegree); + // tdf#123504: both 0 and 360 are valid and different values here! + while (fUnitCircleWidthAngleDegree > 360) + fUnitCircleWidthAngleDegree -= 360.0; + while (fUnitCircleWidthAngleDegree < 0) + fUnitCircleWidthAngleDegree += 360.0; //create shape uno::Reference< drawing::XShape > xShape( @@ -919,9 +923,10 @@ uno::Reference< drawing::XShape > if( !xTarget.is() ) return nullptr; - while(fUnitCircleWidthAngleDegree>360) + // tdf#123504: both 0 and 360 are valid and different values here! + while (fUnitCircleWidthAngleDegree > 360) fUnitCircleWidthAngleDegree -= 360.0; - while(fUnitCircleWidthAngleDegree<0) + while (fUnitCircleWidthAngleDegree < 0) fUnitCircleWidthAngleDegree += 360.0; //create shape _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits