summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-03-19 21:27:20 +0300
committerXisco Faulí <xiscofauli@libreoffice.org>2019-03-20 16:59:57 +0100
commit94fab68485601f4879f3fd0cfff8df5e37a088d8 (patch)
tree9220850c958db27109d22c5fc67f6eef3f620a31 /chart2
parent8a749b96fc4ff288d33a47c7de5ba2d8f5b7960c (diff)
tdf#123504: 0 and 360 are different angles in charts
This partly reverts commit 81302f33073e7629d724ed269f1fa21dad29e141. Reviewed-on: https://gerrit.libreoffice.org/69440 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> (cherry picked from commit 166a4989a0d1e5a6271c66bceb73a27970afc882) Change-Id: I40cbe739eb4497b8217aca56a2c3661ed1e491f4 Reviewed-on: https://gerrit.libreoffice.org/69447 Tested-by: Jenkins Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/chart2import.cxx33
-rw-r--r--chart2/qa/extras/data/ods/pie_chart_100_and_0.odsbin0 -> 11354 bytes
-rw-r--r--chart2/source/view/main/PlottingPositionHelper.cxx17
-rw-r--r--chart2/source/view/main/PolarLabelPositionHelper.cxx8
-rw-r--r--chart2/source/view/main/ShapeFactory.cxx11
5 files changed, 57 insertions, 12 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index b429a3e7f20f..85d6a9e652eb 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -118,6 +118,7 @@ public:
void testTdf121205();
void testTdf114179();
+ void testTdf123504();
CPPUNIT_TEST_SUITE(Chart2ImportTest);
CPPUNIT_TEST(Fdo60083);
@@ -190,6 +191,7 @@ public:
CPPUNIT_TEST(testTdf121205);
CPPUNIT_TEST(testTdf114179);
+ CPPUNIT_TEST(testTdf123504);
CPPUNIT_TEST_SUITE_END();
@@ -1699,6 +1701,37 @@ void Chart2ImportTest::testTdf114179()
CPPUNIT_ASSERT( aSize.Height > 0);
}
+void Chart2ImportTest::testTdf123504()
+{
+ load("/chart2/qa/extras/data/ods/", "pie_chart_100_and_0.ods");
+ Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent),
+ UNO_QUERY_THROW);
+
+ Reference<chart2::XChartDocument> xChartDoc2(xChartDoc, UNO_QUERY_THROW);
+ Reference<chart2::XChartType> xChartType(getChartTypeFromDoc(xChartDoc2, 0), UNO_SET_THROW);
+ auto aDataSeriesYValues = getDataSeriesYValuesFromChartType(xChartType);
+ CPPUNIT_ASSERT_EQUAL(size_t(1), aDataSeriesYValues.size());
+
+ Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW);
+ Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW);
+ Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(0), UNO_QUERY_THROW);
+ Reference<drawing::XShape> xSeriesSlices(getShapeByName(xShapes, "CID/D=0:CS=0:CT=0:Series=0"),
+ UNO_SET_THROW);
+
+ Reference<container::XIndexAccess> xIndexAccess(xSeriesSlices, UNO_QUERY_THROW);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
+ Reference<drawing::XShape> xSlice(xIndexAccess->getByIndex(0), UNO_QUERY_THROW);
+
+ // Check size and position of the only slice in the chart (100%)
+ // In the regressed state, it used to be 0-sized at position 0,0
+ awt::Point aSlicePosition = xSlice->getPosition();
+ CPPUNIT_ASSERT_GREATER(sal_Int32(3000), aSlicePosition.X);
+ CPPUNIT_ASSERT_GREATER(sal_Int32(150), aSlicePosition.Y);
+ awt::Size aSliceSize = xSlice->getSize();
+ CPPUNIT_ASSERT_GREATER(sal_Int32(8500), aSliceSize.Height);
+ CPPUNIT_ASSERT_GREATER(sal_Int32(8500), aSliceSize.Width);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/ods/pie_chart_100_and_0.ods b/chart2/qa/extras/data/ods/pie_chart_100_and_0.ods
new file mode 100644
index 000000000000..a6ff5d6aa0e1
--- /dev/null
+++ b/chart2/qa/extras/data/ods/pie_chart_100_and_0.ods
Binary files differ
diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx
index 164f0a8d5f64..5c25ddd49079 100644
--- a/chart2/source/view/main/PlottingPositionHelper.cxx
+++ b/chart2/source/view/main/PlottingPositionHelper.cxx
@@ -35,7 +35,6 @@
#include <o3tl/make_unique.hxx>
#include <rtl/math.hxx>
-#include <tools/helpers.hxx>
namespace chart
{
@@ -420,10 +419,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;
}
@@ -476,7 +476,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 aca4a2b6f0c1..98c52d97288a 100644
--- a/chart2/source/view/main/PolarLabelPositionHelper.cxx
+++ b/chart2/source/view/main/PolarLabelPositionHelper.cxx
@@ -25,8 +25,6 @@
#include <com/sun/star/chart/DataLabelPlacement.hpp>
-#include <tools/helpers.hxx>
-
namespace chart
{
using namespace ::com::sun::star;
@@ -124,7 +122,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 548ecef28ccf..28f981635529 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -877,7 +877,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(
@@ -926,9 +930,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