Kaydet (Commit) 94fab684 authored tarafından Mike Kaganski's avatar Mike Kaganski Kaydeden (comit) Xisco Faulí

tdf#123504: 0 and 360 are different angles in charts

This partly reverts commit 81302f33.

Reviewed-on: https://gerrit.libreoffice.org/69440
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 166a4989)

Change-Id: I40cbe739eb4497b8217aca56a2c3661ed1e491f4
Reviewed-on: https://gerrit.libreoffice.org/69447
Tested-by: Jenkins
Reviewed-by: 's avatarXisco Faulí <xiscofauli@libreoffice.org>
üst 8a749b96
...@@ -118,6 +118,7 @@ public: ...@@ -118,6 +118,7 @@ public:
void testTdf121205(); void testTdf121205();
void testTdf114179(); void testTdf114179();
void testTdf123504();
CPPUNIT_TEST_SUITE(Chart2ImportTest); CPPUNIT_TEST_SUITE(Chart2ImportTest);
CPPUNIT_TEST(Fdo60083); CPPUNIT_TEST(Fdo60083);
...@@ -190,6 +191,7 @@ public: ...@@ -190,6 +191,7 @@ public:
CPPUNIT_TEST(testTdf121205); CPPUNIT_TEST(testTdf121205);
CPPUNIT_TEST(testTdf114179); CPPUNIT_TEST(testTdf114179);
CPPUNIT_TEST(testTdf123504);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -1699,6 +1701,37 @@ void Chart2ImportTest::testTdf114179() ...@@ -1699,6 +1701,37 @@ void Chart2ImportTest::testTdf114179()
CPPUNIT_ASSERT( aSize.Height > 0); 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_TEST_SUITE_REGISTRATION(Chart2ImportTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <o3tl/make_unique.hxx> #include <o3tl/make_unique.hxx>
#include <rtl/math.hxx> #include <rtl/math.hxx>
#include <tools/helpers.hxx>
namespace chart namespace chart
{ {
...@@ -420,10 +419,11 @@ double PolarPlottingPositionHelper::getWidthAngleDegree( double& fStartLogicValu ...@@ -420,10 +419,11 @@ double PolarPlottingPositionHelper::getWidthAngleDegree( double& fStartLogicValu
&& !::rtl::math::approxEqual( fStartLogicValueOnAngleAxis, fEndLogicValueOnAngleAxis ) ) && !::rtl::math::approxEqual( fStartLogicValueOnAngleAxis, fEndLogicValueOnAngleAxis ) )
fWidthAngleDegree = 360.0; fWidthAngleDegree = 360.0;
while(fWidthAngleDegree<0.0) // tdf#123504: both 0 and 360 are valid and different values here!
fWidthAngleDegree+=360.0; while (fWidthAngleDegree < 0.0)
while(fWidthAngleDegree>360.0) fWidthAngleDegree += 360.0;
fWidthAngleDegree-=360.0; while (fWidthAngleDegree > 360.0)
fWidthAngleDegree -= 360.0;
return fWidthAngleDegree; return fWidthAngleDegree;
} }
...@@ -476,7 +476,12 @@ double PolarPlottingPositionHelper::transformToAngleDegree( double fLogicValueOn ...@@ -476,7 +476,12 @@ double PolarPlottingPositionHelper::transformToAngleDegree( double fLogicValueOn
fRet = m_fAngleDegreeOffset fRet = m_fAngleDegreeOffset
+ fAxisAngleScaleDirection*(fScaledLogicAngleValue-MinAngleValue)*360.0 + fAxisAngleScaleDirection*(fScaledLogicAngleValue-MinAngleValue)*360.0
/fabs(MaxAngleValue-MinAngleValue); /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;
} }
/** /**
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#include <com/sun/star/chart/DataLabelPlacement.hpp> #include <com/sun/star/chart/DataLabelPlacement.hpp>
#include <tools/helpers.hxx>
namespace chart namespace chart
{ {
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -124,7 +122,11 @@ awt::Point PolarLabelPositionHelper::getLabelScreenPositionAndAlignmentForUnitCi ...@@ -124,7 +122,11 @@ awt::Point PolarLabelPositionHelper::getLabelScreenPositionAndAlignmentForUnitCi
//set LabelAlignment //set LabelAlignment
if( !bCenter ) 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; bool bOutside = nLabelPlacement == css::chart::DataLabelPlacement::OUTSIDE;
......
...@@ -877,7 +877,11 @@ uno::Reference< drawing::XShape > ...@@ -877,7 +877,11 @@ uno::Reference< drawing::XShape >
if( !xTarget.is() ) if( !xTarget.is() )
return nullptr; 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 //create shape
uno::Reference< drawing::XShape > xShape( uno::Reference< drawing::XShape > xShape(
...@@ -926,9 +930,10 @@ uno::Reference< drawing::XShape > ...@@ -926,9 +930,10 @@ uno::Reference< drawing::XShape >
if( !xTarget.is() ) if( !xTarget.is() )
return nullptr; return nullptr;
while(fUnitCircleWidthAngleDegree>360) // tdf#123504: both 0 and 360 are valid and different values here!
while (fUnitCircleWidthAngleDegree > 360)
fUnitCircleWidthAngleDegree -= 360.0; fUnitCircleWidthAngleDegree -= 360.0;
while(fUnitCircleWidthAngleDegree<0) while (fUnitCircleWidthAngleDegree < 0)
fUnitCircleWidthAngleDegree += 360.0; fUnitCircleWidthAngleDegree += 360.0;
//create shape //create shape
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment