Kaydet (Commit) 1ee85470 authored tarafından Regina Henschel's avatar Regina Henschel

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: 's avatarRegina Henschel <rb.henschel@t-online.de>
üst 05f5c189
......@@ -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: */
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment