[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - sc/qa sc/source
Regényi Balázs (via logerrit)
logerrit at kemper.freedesktop.org
Wed Oct 14 10:27:58 UTC 2020
sc/qa/unit/data/xlsx/testShapeDisplacementOnRotationImport.xlsx |binary
sc/qa/unit/subsequent_filters-test.cxx | 19 ++++++++++
sc/source/filter/oox/drawingfragment.cxx | 8 ++--
3 files changed, 24 insertions(+), 3 deletions(-)
New commits:
commit 19bbd01b671877812928ba013d4828c213d2f68e
Author: Regényi Balázs <regenyi.balazsmiklos at nisz.hu>
AuthorDate: Wed Aug 19 15:32:54 2020 +0200
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Wed Oct 14 12:27:22 2020 +0200
tdf#135918 XLSX DrawingML shape import: fix needless displacement
Shape was displaced on rotation if it is placed next to the sheets
upper/left edges.
Co-authored-by: Szabolcs Tóth
Change-Id: I987e7b0d863b89cfb5d8154e2f0a017e21248ee1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101001
Tested-by: Jenkins
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 3e85b22769a4b02744a7006d7dc772973c0093f5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104292
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
diff --git a/sc/qa/unit/data/xlsx/testShapeDisplacementOnRotationImport.xlsx b/sc/qa/unit/data/xlsx/testShapeDisplacementOnRotationImport.xlsx
new file mode 100644
index 000000000000..a5fcd1ce2fbd
Binary files /dev/null and b/sc/qa/unit/data/xlsx/testShapeDisplacementOnRotationImport.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 99840eceaaae..149dbeb2b808 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -253,6 +253,7 @@ public:
void testXLSDefColWidth();
void testPreviewMissingObjLink();
void testShapeRotationImport();
+ void testShapeDisplacementOnRotationImport();
CPPUNIT_TEST_SUITE(ScFiltersTest);
CPPUNIT_TEST(testBooleanFormatXLSX);
@@ -396,6 +397,7 @@ public:
CPPUNIT_TEST(testXLSDefColWidth);
CPPUNIT_TEST(testPreviewMissingObjLink);
CPPUNIT_TEST(testShapeRotationImport);
+ CPPUNIT_TEST(testShapeDisplacementOnRotationImport);
CPPUNIT_TEST_SUITE_END();
@@ -4393,6 +4395,23 @@ void ScFiltersTest::testShapeRotationImport()
}
}
+void ScFiltersTest::testShapeDisplacementOnRotationImport()
+{
+ // tdf#135918 shape is displaced on rotation if it is placed next to the sheets upper/left edges
+ ScDocShellRef xDocSh = loadDoc("testShapeDisplacementOnRotationImport.", FORMAT_XLSX);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load testShapeDisplacementOnRotationImport.xlsx", xDocSh.is());
+
+ uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocSh->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW);
+ uno::Reference<drawing::XShape> xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW);
+
+ uno::Reference<beans::XPropertySet> xShapeProperties(xShape, uno::UNO_QUERY_THROW);
+ uno::Any aRectProp = xShapeProperties->getPropertyValue("FrameRect");
+ awt::Rectangle aRectangle = aRectProp.get<awt::Rectangle>();
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aRectangle.X);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aRectangle.Y);
+}
+
ScFiltersTest::ScFiltersTest()
: ScBootstrapFixture( "sc/qa/unit/data" )
{
diff --git a/sc/source/filter/oox/drawingfragment.cxx b/sc/source/filter/oox/drawingfragment.cxx
index 716c46d1f974..3ec32dcd0e42 100644
--- a/sc/source/filter/oox/drawingfragment.cxx
+++ b/sc/source/filter/oox/drawingfragment.cxx
@@ -294,9 +294,11 @@ void DrawingFragment::onEndElement()
}
// TODO: DrawingML implementation expects 32-bit coordinates for EMU rectangles (change that to EmuRectangle)
+ // tdf#135918: Negative X,Y position has to be allowed to avoid shape displacement on rotation.
+ // The negative values can exist because of previous lines where the anchor rectangle must be mirrored in some ranges.
Rectangle aShapeRectEmu32(
- getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.X, 0, SAL_MAX_INT32 ),
- getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Y, 0, SAL_MAX_INT32 ),
+ getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.X, SAL_MIN_INT32, SAL_MAX_INT32 ),
+ getLimitedValue< sal_Int32, sal_Int64 >( aShapeRectEmu.Y, SAL_MIN_INT32, 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 ) );
@@ -313,7 +315,7 @@ void DrawingFragment::onEndElement()
/* Collect all shape positions in the WorksheetHelper base
class. But first, scale EMUs to 1/100 mm. */
Rectangle aShapeRectHmm(
- convertEmuToHmm(aShapeRectEmu32.X ), convertEmuToHmm(aShapeRectEmu32.Y ),
+ convertEmuToHmm(aShapeRectEmu32.X > 0 ? aShapeRectEmu32.X : 0), convertEmuToHmm(aShapeRectEmu32.Y > 0 ? aShapeRectEmu32.Y : 0),
convertEmuToHmm(aShapeRectEmu32.Width ), convertEmuToHmm(aShapeRectEmu32.Height ) );
extendShapeBoundingBox( aShapeRectHmm );
// set cell Anchoring
More information about the Libreoffice-commits
mailing list