svx/qa/unit/customshapes.cxx | 26 ++++++++++++++++++++++ svx/qa/unit/data/tdf124212_handle_position.odg |binary svx/source/customshapes/EnhancedCustomShape2d.cxx | 3 ++ 3 files changed, 29 insertions(+)
New commits: commit 1ee8547003e50e212c00df1f8d2ec3f6fc50f819 Author: Regina Henschel <rb.hensc...@t-online.de> AuthorDate: Tue Mar 19 20:10:12 2019 +0100 Commit: Regina Henschel <rb.hensc...@t-online.de> CommitDate: Thu Mar 21 15:42:34 2019 +0100 tdf#124212 make adjustment handle work always In method SetHandleControllerPosition() all transformations are reversed to get the coordinates in shape inner coordinate system from the outer position. The error was, that the first transformation, the move in method GetPoint was forgotten. In case of default viewBox '0 0 21600 21600' it is not visible. But the error is noticeable, if left or top do not equal zero. Change-Id: Icc3f4f2c603826151c95b8b9eea5030fb5805d67 Reviewed-on: https://gerrit.libreoffice.org/69439 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.hensc...@t-online.de> diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx index 33384f56c83b..e2444b50f967 100644 --- a/svx/qa/unit/customshapes.cxx +++ b/svx/qa/unit/customshapes.cxx @@ -250,6 +250,32 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf121845_two_commands_U) CPPUNIT_ASSERT_EQUAL_MESSAGE("count polygons", static_cast<sal_uInt32>(2), aPolyPolygon.count()); } + +CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf124212_handle_position) +{ + // tdf124212 Adjustment handle reacts wrongly, if custom shape has a non + // default viewBox. Load a document with svg:viewBox="10800 0 10800 21600" + // Error was, that moving the controller results in a handle position that + // does not reflect the movement. + const OUString sFileName("tdf124212_handle_position.odg"); + OUString sURL = m_directories.getURLFromSrc(sDataDirectory) + sFileName; + mxComponent = loadFromDesktop(sURL, "com.sun.star.comp.drawing.DrawingDocument"); + CPPUNIT_ASSERT_MESSAGE("Could not load document", mxComponent.is()); + uno::Reference<drawing::XShape> xShape(getShape(0)); + // The shape has one, horizontal adjust handle. + SdrObjCustomShape& rSdrObjCustomShape( + static_cast<SdrObjCustomShape&>(*GetSdrObjectFromXShape(xShape))); + EnhancedCustomShape2d aCustomShape2d(rSdrObjCustomShape); + Point aInitialPosition; + aCustomShape2d.GetHandlePosition(0, aInitialPosition); + css::awt::Point aDesiredPosition(aInitialPosition.X() + 1000, aInitialPosition.Y()); + aCustomShape2d.SetHandleControllerPosition(0, aDesiredPosition); + Point aObservedPosition; + aCustomShape2d.GetHandlePosition(0, aObservedPosition); + sal_Int32 nDesiredX(aDesiredPosition.X); // awt::Point + sal_Int32 nObservedX(aObservedPosition.X()); // tools::Point + CPPUNIT_ASSERT_EQUAL_MESSAGE("handle X coordinate", nDesiredX, nObservedX); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/qa/unit/data/tdf124212_handle_position.odg b/svx/qa/unit/data/tdf124212_handle_position.odg new file mode 100644 index 000000000000..7a4eb05175ad Binary files /dev/null and b/svx/qa/unit/data/tdf124212_handle_position.odg differ diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx old mode 100644 new mode 100755 index bc143c47c971..b8b859f7b82e --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -1223,6 +1223,9 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex double fPos2 = aP.Y(); //( bFlipV ) ? aLogicRect.GetHeight() -aP.Y() : aP.Y(); fPos1 = !basegfx::fTools::equalZero(fXScale) ? (fPos1 / fXScale) : SAL_MAX_INT32; fPos2 = !basegfx::fTools::equalZero(fYScale) ? (fPos2 / fYScale) : SAL_MAX_INT32; + // revert -nCoordLeft and -nCoordTop aus GetPoint() + fPos1 += nCoordLeft; + fPos2 += nCoordTop; // Used for scaling the adjustment values based on handle positions double fWidth; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits