diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-03-11 16:42:22 +0100 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2017-04-12 13:57:03 +0200 |
commit | 676dcf204ac7e1326a48be30a2a5f825a2a8eb26 (patch) | |
tree | 0d55a9b4d02165ff73eb9e399919c4e0c69aa78c | |
parent | 9e43f32b19df707a68307a693014df10f4645d98 (diff) |
tdf#106217: Wrong size and position of a shape inside chart
Same code which was added to the method
DrawingFragment::onEndElement() in
d178d7bef193565a7d6aacbc37a58dfc4bd7b316
A shape's size and position inside a chart object
are primarily defined by <cdr:from> and <cdr:to> tags in
drawing.xml, but in the same file we also have
an <a:xfrm> tag which is used for the same thing
(defining size and postion) in general. Testing with
MSO it seems it ignores what values are set to <a:xfrm> and
uses only the <cdr:from> and <cdr:to> values.
The test document showing this problem must be created
an earlier version of MSO, becuase <a:xfrm> is set to some
random values. Editing the chart and saving it with MSO
2013 the <a:xfrm> values are set consistently with
<cdr:from> and <cdr:to> pair.
Reviewed-on: https://gerrit.libreoffice.org/35069
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit aa204f1c09a760d6753c408376ab7307fb13ad91)
Change-Id: Icbaff78e5a6fcea36678c3b3755c97f57976b626
Reviewed-on: https://gerrit.libreoffice.org/35076
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r-- | chart2/qa/extras/chart2import.cxx | 25 | ||||
-rwxr-xr-x | chart2/qa/extras/data/pptx/tdf106217.pptx | bin | 0 -> 47976 bytes | |||
-rw-r--r-- | oox/source/drawingml/chart/chartdrawingfragment.cxx | 5 |
3 files changed, 30 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 75b0f9c474c4..e43fa1fedde8 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/chart/XTwoAxisXSupplier.hpp> #include <com/sun/star/chart/MissingValueTreatment.hpp> #include <com/sun/star/chart2/TickmarkStyle.hpp> +#include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/util/Color.hpp> @@ -60,6 +61,7 @@ public: void testFdo54361(); void testFdo54361_1(); void testTdf86624(); // manually placed legends + void testTdf106217(); void testAutoBackgroundXLSX(); void testChartAreaStyleBackgroundXLSX(); void testAxisTextRotationXLSX(); @@ -117,6 +119,7 @@ public: CPPUNIT_TEST(testFdo54361); CPPUNIT_TEST(testFdo54361_1); CPPUNIT_TEST(testTdf86624); + CPPUNIT_TEST(testTdf106217); CPPUNIT_TEST(testAutoBackgroundXLSX); CPPUNIT_TEST(testChartAreaStyleBackgroundXLSX); CPPUNIT_TEST(testAxisTextRotationXLSX); @@ -685,6 +688,28 @@ void Chart2ImportTest::testTdf86624() CPPUNIT_ASSERT(aPos.Y > 4000); // real value for ms is above 7000 } +void Chart2ImportTest::testTdf106217() +{ + load("/chart2/qa/extras/data/pptx/", "tdf106217.pptx"); + uno::Reference< chart::XChartDocument > xChartDoc = getChartDocFromDrawImpress(0, 0); + CPPUNIT_ASSERT(xChartDoc.is()); + + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, uno::UNO_QUERY); + uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); + uno::Reference<drawing::XShape> xCircle(xDrawPage->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT(xCircle.is()); + + uno::Reference<container::XNamed> xNamedShape(xCircle, uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(xNamedShape->getName(), OUString("Oval 1")); + + awt::Point aPosition = xCircle->getPosition(); + CPPUNIT_ASSERT_EQUAL(aPosition.X, sal_Int32(6870)); + CPPUNIT_ASSERT_EQUAL(aPosition.Y, sal_Int32(7261)); + awt::Size aSize = xCircle->getSize(); + CPPUNIT_ASSERT_EQUAL(aSize.Width, sal_Int32(2701)); + CPPUNIT_ASSERT_EQUAL(aSize.Height, sal_Int32(2700)); +} + void Chart2ImportTest::testTransparentBackground(OUString const & filename) { load("/chart2/qa/extras/data/xlsx/", filename); diff --git a/chart2/qa/extras/data/pptx/tdf106217.pptx b/chart2/qa/extras/data/pptx/tdf106217.pptx Binary files differnew file mode 100755 index 000000000000..64fb968b8a15 --- /dev/null +++ b/chart2/qa/extras/data/pptx/tdf106217.pptx diff --git a/oox/source/drawingml/chart/chartdrawingfragment.cxx b/oox/source/drawingml/chart/chartdrawingfragment.cxx index de8d3f2303bf..00bc99f7bd8e 100644 --- a/oox/source/drawingml/chart/chartdrawingfragment.cxx +++ b/oox/source/drawingml/chart/chartdrawingfragment.cxx @@ -216,6 +216,11 @@ void ChartDrawingFragment::onEndElement() getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Y, 0, SAL_MAX_INT32 ), getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Width, 0, SAL_MAX_INT32 ), getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Height, 0, SAL_MAX_INT32 ) ); + + // Set the position and size before calling addShape(). + mxShape->setPosition(awt::Point(aShapeRectEmu32.X, aShapeRectEmu32.Y)); + mxShape->setSize(awt::Size(aShapeRectEmu32.Width, aShapeRectEmu32.Height)); + basegfx::B2DHomMatrix aMatrix; mxShape->addShape( getFilter(), getFilter().getCurrentTheme(), mxDrawPage, aMatrix, mxShape->getFillProperties(), &aShapeRectEmu32 ); } |