summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2019-03-19 20:10:12 +0100
committerRegina Henschel <rb.henschel@t-online.de>2019-03-21 15:42:34 +0100
commit1ee8547003e50e212c00df1f8d2ec3f6fc50f819 (patch)
treef17c373e8ce4fe97d8fe118981d83186b93ec158 /svx
parent05f5c18959cb86c7893b4a2bb45cce52f1f58c53 (diff)
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.henschel@t-online.de>
Diffstat (limited to 'svx')
-rw-r--r--svx/qa/unit/customshapes.cxx26
-rw-r--r--svx/qa/unit/data/tdf124212_handle_position.odgbin0 -> 10108 bytes
-rwxr-xr-x[-rw-r--r--]svx/source/customshapes/EnhancedCustomShape2d.cxx3
3 files changed, 29 insertions, 0 deletions
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
--- /dev/null
+++ b/svx/qa/unit/data/tdf124212_handle_position.odg
Binary files differ
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index bc143c47c971..b8b859f7b82e 100644..100755
--- 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;