[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - chart2/qa oox/source
Balazs Varga (via logerrit)
logerrit at kemper.freedesktop.org
Thu Apr 22 09:21:58 UTC 2021
chart2/qa/extras/chart2import.cxx | 31 ++++++++++++++------
chart2/qa/extras/data/docx/testcustomshapepos.docx |binary
oox/source/drawingml/chart/chartdrawingfragment.cxx | 9 +++++
3 files changed, 31 insertions(+), 9 deletions(-)
New commits:
commit 3a4918d90c4e9bca335637fd6ece714bcb4fdda0
Author: Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Sun Dec 13 14:08:38 2020 +0100
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Thu Apr 22 11:21:26 2021 +0200
tdf#138889 OOXML chart: fix import of rotated shapes
in charts, resulted e.g. distorted arrows.
Change-Id: I2d25aeeef8aed9fccacf3cc9f735123e8d891de5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107670
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit fbe77e5d61ca63a688c12be721e760935d78e780)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107801
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
(cherry picked from commit 277b22981baae33ab7969538f00a5bb85e1be474)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114424
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index cfd5b87c6f34..4ba8c2b487d3 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -32,6 +32,8 @@
#include <com/sun/star/chart/DataLabelPlacement.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <iterator>
+#include <vcl/outdev.hxx>
+#include <vcl/svapp.hxx>
#include <com/sun/star/util/Color.hpp>
#include <com/sun/star/awt/Gradient.hpp>
@@ -2645,15 +2647,26 @@ void Chart2ImportTest::testTdfCustomShapePos()
Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), UNO_QUERY_THROW);
Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(xChartDoc, UNO_QUERY_THROW);
Reference<drawing::XDrawPage> xDrawPage(xDrawPageSupplier->getDrawPage(), UNO_SET_THROW);
- Reference<drawing::XShape> xCustomShape(xDrawPage->getByIndex(0), UNO_QUERY_THROW);
-
- // test position and size of a custom shape within a chart
- awt::Point aPosition = xCustomShape->getPosition();
- CPPUNIT_ASSERT_DOUBLES_EQUAL(8845, aPosition.X, 300);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(855, aPosition.Y, 300);
- awt::Size aSize = xCustomShape->getSize();
- CPPUNIT_ASSERT_DOUBLES_EQUAL(4831, aSize.Width, 300);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1550, aSize.Height, 300);
+ // test position and size of a custom shape within a chart, rotated by 0 degree.
+ {
+ Reference<drawing::XShape> xCustomShape(xDrawPage->getByIndex(0), UNO_QUERY_THROW);
+ awt::Point aPosition = xCustomShape->getPosition();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(8845, aPosition.X, 300);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(855, aPosition.Y, 300);
+ awt::Size aSize = xCustomShape->getSize();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(4831, aSize.Width, 300);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1550, aSize.Height, 300);
+ }
+ // test position and size of a custom shape within a chart, rotated by 90 degree.
+ {
+ Reference<drawing::XShape> xCustomShape(xDrawPage->getByIndex(1), UNO_QUERY_THROW);
+ awt::Point aPosition = xCustomShape->getPosition();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1658, aPosition.X, 300);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(6119, aPosition.Y, 300);
+ awt::Size aSize = xCustomShape->getSize();
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(4165, aSize.Width, 300);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1334, aSize.Height, 300);
+ }
}
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
diff --git a/chart2/qa/extras/data/docx/testcustomshapepos.docx b/chart2/qa/extras/data/docx/testcustomshapepos.docx
index 31c5284e11b9..640c48ea4627 100644
Binary files a/chart2/qa/extras/data/docx/testcustomshapepos.docx and b/chart2/qa/extras/data/docx/testcustomshapepos.docx differ
diff --git a/oox/source/drawingml/chart/chartdrawingfragment.cxx b/oox/source/drawingml/chart/chartdrawingfragment.cxx
index 85eeb2986bcc..c41e2db49821 100644
--- a/oox/source/drawingml/chart/chartdrawingfragment.cxx
+++ b/oox/source/drawingml/chart/chartdrawingfragment.cxx
@@ -209,6 +209,15 @@ void ChartDrawingFragment::onEndElement()
EmuRectangle aShapeRectEmu = mxAnchor->calcAnchorRectEmu( maChartRectEmu );
if( (aShapeRectEmu.X >= 0) && (aShapeRectEmu.Y >= 0) && (aShapeRectEmu.Width >= 0) && (aShapeRectEmu.Height >= 0) )
{
+ const sal_Int32 aRotation = mxShape->getRotation();
+ if( (aRotation >= 45 * PER_DEGREE && aRotation < 135 * PER_DEGREE) || (aRotation >= 225 * PER_DEGREE && aRotation < 315 * PER_DEGREE) )
+ {
+ sal_Int64 nHalfWidth = aShapeRectEmu.Width / 2;
+ sal_Int64 nHalfHeight = aShapeRectEmu.Height / 2;
+ aShapeRectEmu.X = aShapeRectEmu.X + nHalfWidth - nHalfHeight;
+ aShapeRectEmu.Y = aShapeRectEmu.Y + nHalfHeight - nHalfWidth;
+ std::swap(aShapeRectEmu.Width, aShapeRectEmu.Height);
+ }
// TODO: DrawingML implementation expects 32-bit coordinates for EMU rectangles (change that to EmuRectangle)
awt::Rectangle aShapeRectEmu32(
getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.X, 0, SAL_MAX_INT32 ),
More information about the Libreoffice-commits
mailing list