Kaydet (Commit) 4ca556d0 authored tarafından Regina Henschel's avatar Regina Henschel

tdf#115813 unit test for handle position of OOXML shapes

The patch contains some additions to tdf#115813 and a unit test.
The test covers nearly all OOXML preset shapes with handles. Only
some shapes do not fit to the test pattern: swooshArrow and polar
handle shapes arc, blockArc, chord, circularArror, mathNotEqual,
pie, leftCircularArrow, leftRightCicularArrow.
The shapes star24 and star32 are excluded because of tdf#125181.
The shapes gear6 and gear9 are excluded because a correct handle
movement is not yet implemented.
Connector shapes are inserted as ordinary shapes to prevent
converting.
The error string is designed to identify the affected shape.

Change-Id: Icd3358f3701ac2db2cc61eb045ae10bc4b72b9ca
Reviewed-on: https://gerrit.libreoffice.org/72229
Tested-by: Jenkins
Reviewed-by: 's avatarRegina Henschel <rb.henschel@t-online.de>
üst 2719821c
...@@ -98,11 +98,11 @@ public: ...@@ -98,11 +98,11 @@ public:
css::uno::Reference< css::drawing::XCustomShapeEngine > const & GetCustomShapeEngine() const; css::uno::Reference< css::drawing::XCustomShapeEngine > const & GetCustomShapeEngine() const;
SVX_DLLPRIVATE std::vector< SdrCustomShapeInteraction > GetInteractionHandles() const; std::vector< SdrCustomShapeInteraction > GetInteractionHandles() const; // needed in unit test
SVX_DLLPRIVATE void DragCreateObject( SdrDragStat& rDrag ); SVX_DLLPRIVATE void DragCreateObject( SdrDragStat& rDrag );
SVX_DLLPRIVATE void DragResizeCustomShape( const tools::Rectangle& rNewRect ); SVX_DLLPRIVATE void DragResizeCustomShape( const tools::Rectangle& rNewRect );
SVX_DLLPRIVATE void DragMoveCustomShapeHdl( const Point& rDestination, void DragMoveCustomShapeHdl( const Point& rDestination,
const sal_uInt16 nCustomShapeHdlNum, bool bMoveCalloutRectangle ); const sal_uInt16 nCustomShapeHdlNum, bool bMoveCalloutRectangle ); // needed in unit test
// #i37011# centralize throw-away of render geometry // #i37011# centralize throw-away of render geometry
void InvalidateRenderGeometry(); void InvalidateRenderGeometry();
......
...@@ -38,6 +38,7 @@ protected: ...@@ -38,6 +38,7 @@ protected:
uno::Reference<lang::XComponent> mxComponent; uno::Reference<lang::XComponent> mxComponent;
// get shape nShapeIndex from page 0 // get shape nShapeIndex from page 0
uno::Reference<drawing::XShape> getShape(sal_uInt8 nShapeIndex); uno::Reference<drawing::XShape> getShape(sal_uInt8 nShapeIndex);
sal_uInt8 countShapes();
public: public:
virtual void setUp() override virtual void setUp() override
...@@ -69,6 +70,17 @@ uno::Reference<drawing::XShape> CustomshapesTest::getShape(sal_uInt8 nShapeIndex ...@@ -69,6 +70,17 @@ uno::Reference<drawing::XShape> CustomshapesTest::getShape(sal_uInt8 nShapeIndex
return xShape; return xShape;
} }
sal_uInt8 CustomshapesTest::countShapes()
{
uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier.is());
uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_MESSAGE("Could not get xDrawPage", xDrawPage.is());
return xDrawPage->getCount();
}
CPPUNIT_TEST_FIXTURE(CustomshapesTest, testViewBoxLeftTop) CPPUNIT_TEST_FIXTURE(CustomshapesTest, testViewBoxLeftTop)
{ {
// tdf#121890 formula values "left" and "top" are wrongly calculated // tdf#121890 formula values "left" and "top" are wrongly calculated
...@@ -318,6 +330,69 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf124740_handle_path_coordsystem) ...@@ -318,6 +330,69 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf124740_handle_path_coordsystem)
// tolerance for rounding to integer // tolerance for rounding to integer
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("handle X coordinate", 8000.0, fX, 2.0); CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("handle X coordinate", 8000.0, fX, 2.0);
} }
CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf115813_OOXML_XY_handle)
{
// The test covers all preset shapes with handles. Only these ones are
// excluded: arc, blockArc, chord, circularArrow, gear6, gear9, mathNotEqual, pie,
// leftCircularArrow, leftRightCircularArrow, star24, star32, swooshArrow.
// Connectors are included as ordinary shapes to prevent converting.
// Error was, that the handle movement and the changes to the shape did not follow
// the mouse movement.
const OUString sFileName("tdf115813_HandleMovementOOXMLPresetShapes.pptx");
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());
OUString sErrors;
// values in vector InteractionsHandles are in 1/100 mm and refer to page
for (sal_uInt8 i = 0; i < countShapes(); i++)
{
uno::Reference<drawing::XShape> xShape(getShape(i));
SdrObjCustomShape& rSdrObjCustomShape(
static_cast<SdrObjCustomShape&>(*GetSdrObjectFromXShape(xShape)));
OUString sShapeType("non-primitive"); // default for ODF
const SdrCustomShapeGeometryItem& rGeometryItem(
rSdrObjCustomShape.GetMergedItem(SDRATTR_CUSTOMSHAPE_GEOMETRY));
const uno::Any* pAny = rGeometryItem.GetPropertyValueByName("Type");
if (pAny)
*pAny >>= sShapeType;
sal_uInt8 nHandlesCount = rSdrObjCustomShape.GetInteractionHandles().size();
for (sal_uInt8 j = 0; j < nHandlesCount; j++)
{
css::awt::Point aInitialPosition(
rSdrObjCustomShape.GetInteractionHandles()[j].aPosition);
// The handles are initialized in the test document, so that if the handle is moveable in
// that direction at all, then it can move at least with an amount of 100.
Point aDesiredPosition(aInitialPosition.X + 100, aInitialPosition.Y + 100);
rSdrObjCustomShape.DragMoveCustomShapeHdl(aDesiredPosition, j, false);
css::awt::Point aObservedPosition(
rSdrObjCustomShape.GetInteractionHandles()[j].aPosition);
sal_Int32 nDesiredX(aDesiredPosition.X()); // tools::Point
sal_Int32 nDesiredY(aDesiredPosition.Y());
sal_Int32 nObservedX(aObservedPosition.X); // css::awt::Point
sal_Int32 nObservedY(aObservedPosition.Y);
// If a handle only moves in one direction, the difference is 100 for the other direction.
// There exists some rounding differences, therefore '<= 1' instead of '== 0'.
// The condition has the form '!(good cases)'.
if (!((abs(nDesiredX - nObservedX) <= 1 && abs(nDesiredY - nObservedY) == 100)
|| (abs(nDesiredX - nObservedX) == 100 && abs(nDesiredY - nObservedY) <= 1)
|| (abs(nDesiredX - nObservedX) <= 1 && abs(nDesiredY - nObservedY) <= 1)))
{
sErrors += "\n";
//sErrors += OUString(sal_Unicode(10));
sErrors
= sErrors + OUString::number(i) + " " + sShapeType + ": " + OUString::number(j);
sErrors = sErrors + " X " + OUString::number(nDesiredX) + "|"
+ OUString::number(nObservedX);
sErrors = sErrors + " Y " + OUString::number(nDesiredY) + "|"
+ OUString::number(nObservedY);
}
}
}
CPPUNIT_ASSERT_EQUAL(OUString(), sErrors);
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -1206,6 +1206,7 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa ...@@ -1206,6 +1206,7 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
if ((rShapeType == "ooxml-bentArrow" && nHandleIndex == 2) || (rShapeType == "ooxml-chevron") if ((rShapeType == "ooxml-bentArrow" && nHandleIndex == 2) || (rShapeType == "ooxml-chevron")
|| (rShapeType == "ooxml-curvedRightArrow") || (rShapeType == "ooxml-foldedCorner") || (rShapeType == "ooxml-curvedRightArrow") || (rShapeType == "ooxml-foldedCorner")
|| (rShapeType == "ooxml-homePlate") || (rShapeType == "ooxml-notchedRightArrow") || (rShapeType == "ooxml-homePlate") || (rShapeType == "ooxml-notchedRightArrow")
|| (rShapeType == "ooxml-nonIsoscelesTrapezoid" && nHandleIndex == 1)
|| (rShapeType == "ooxml-rightArrow") || (rShapeType == "ooxml-rightArrow")
|| (rShapeType == "ooxml-rightArrowCallout" && nHandleIndex == 2) || (rShapeType == "ooxml-rightArrowCallout" && nHandleIndex == 2)
|| (rShapeType == "ooxml-round1Rect") || (rShapeType == "ooxml-round1Rect")
...@@ -1215,7 +1216,7 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa ...@@ -1215,7 +1216,7 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
|| (rShapeType == "ooxml-snip2DiagRect" && nHandleIndex == 1) || (rShapeType == "ooxml-snip2DiagRect" && nHandleIndex == 1)
|| (rShapeType == "ooxml-snip2SameRect" && nHandleIndex == 0) || (rShapeType == "ooxml-snip2SameRect" && nHandleIndex == 0)
|| (rShapeType == "ooxml-snipRoundRect" && nHandleIndex == 1) || (rShapeType == "ooxml-snipRoundRect" && nHandleIndex == 1)
|| (rShapeType == "ooxml-stripedRightArrow")) || (rShapeType == "ooxml-swooshArrow") || (rShapeType == "ooxml-stripedRightArrow"))
return (fW - fX) / std::min(fW, fH) * 100000.0; return (fW - fX) / std::min(fW, fH) * 100000.0;
// pattern x / ss * 100000 or (x - l) / ss * 100000 // pattern x / ss * 100000 or (x - l) / ss * 100000
...@@ -1226,6 +1227,8 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa ...@@ -1226,6 +1227,8 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
|| (rShapeType == "ooxml-leftArrowCallout" && nHandleIndex == 2) || (rShapeType == "ooxml-leftArrowCallout" && nHandleIndex == 2)
|| (rShapeType == "ooxml-leftRightArrow") || (rShapeType == "ooxml-leftRightArrow")
|| (rShapeType == "ooxml-leftRightArrowCallout" && nHandleIndex == 2) || (rShapeType == "ooxml-leftRightArrowCallout" && nHandleIndex == 2)
|| (rShapeType == "ooxml-leftRightRibbon")
|| (rShapeType == "ooxml-nonIsoscelesTrapezoid" && nHandleIndex == 0)
|| (rShapeType == "ooxml-round2DiagRect" && nHandleIndex == 0) || (rShapeType == "ooxml-round2DiagRect" && nHandleIndex == 0)
|| (rShapeType == "ooxml-round2SameRect" && nHandleIndex == 1) || (rShapeType == "ooxml-round2SameRect" && nHandleIndex == 1)
|| (rShapeType == "ooxml-roundRect") || (rShapeType == "ooxml-roundRect")
...@@ -1241,7 +1244,8 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa ...@@ -1241,7 +1244,8 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
|| (rShapeType == "ooxml-leftRightUpArrow" && nHandleIndex == 0) || (rShapeType == "ooxml-leftRightUpArrow" && nHandleIndex == 0)
|| (rShapeType == "ooxml-quadArrow" && nHandleIndex == 0) || (rShapeType == "ooxml-quadArrow" && nHandleIndex == 0)
|| (rShapeType == "ooxml-quadArrowCallout" && nHandleIndex == 0) || (rShapeType == "ooxml-quadArrowCallout" && nHandleIndex == 0)
|| (rShapeType == "ooxml-upArrowCallout" && nHandleIndex == 0)) || (rShapeType == "ooxml-upArrowCallout" && nHandleIndex == 0)
|| (rShapeType == "ooxml-upDownArrowCallout" && nHandleIndex == 0))
return (fW / 2.0 - fX) / std::min(fW, fH) * 200000.0; return (fW / 2.0 - fX) / std::min(fW, fH) * 200000.0;
// pattern (hc - x) / ss * 100000 // pattern (hc - x) / ss * 100000
...@@ -1249,7 +1253,8 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa ...@@ -1249,7 +1253,8 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
|| (rShapeType == "ooxml-leftRightUpArrow" && nHandleIndex == 1) || (rShapeType == "ooxml-leftRightUpArrow" && nHandleIndex == 1)
|| (rShapeType == "ooxml-quadArrow" && nHandleIndex == 1) || (rShapeType == "ooxml-quadArrow" && nHandleIndex == 1)
|| (rShapeType == "ooxml-quadArrowCallout" && nHandleIndex == 1) || (rShapeType == "ooxml-quadArrowCallout" && nHandleIndex == 1)
|| (rShapeType == "ooxml-upArrowCallout" && nHandleIndex == 1)) || (rShapeType == "ooxml-upArrowCallout" && nHandleIndex == 1)
|| (rShapeType == "ooxml-upDownArrowCallout" && nHandleIndex == 1))
return (fW / 2.0 - fX) / std::min(fW, fH) * 100000.0; return (fW / 2.0 - fX) / std::min(fW, fH) * 100000.0;
// pattern (w - x) / ss * 50000 or (r - x) / ss * 50000 // pattern (w - x) / ss * 50000 or (r - x) / ss * 50000
...@@ -1257,6 +1262,10 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa ...@@ -1257,6 +1262,10 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
|| (rShapeType == "ooxml-uturnArrow" && nHandleIndex == 1)) || (rShapeType == "ooxml-uturnArrow" && nHandleIndex == 1))
return (fW - fX) / std::min(fW, fH) * 50000.0; return (fW - fX) / std::min(fW, fH) * 50000.0;
// pattern x / ss * 200000
if (rShapeType == "ooxml-nonIsoscelesTrapezoid" && nHandleIndex == 0)
return fX / std::min(fW, fH) * 200000.0;
// pattern (hc - x) / w * 200000 // pattern (hc - x) / w * 200000
if ((rShapeType == "ooxml-downArrow" && nHandleIndex == 0) if ((rShapeType == "ooxml-downArrow" && nHandleIndex == 0)
|| (rShapeType == "ooxml-ellipseRibbon") || (rShapeType == "ooxml-ellipseRibbon2") || (rShapeType == "ooxml-ellipseRibbon") || (rShapeType == "ooxml-ellipseRibbon2")
...@@ -1326,13 +1335,20 @@ static double lcl_getYAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa ...@@ -1326,13 +1335,20 @@ static double lcl_getYAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
// pattern y / ss * 100000 or (y - t) / ss * 100000 // pattern y / ss * 100000 or (y - t) / ss * 100000
if ((rShapeType == "ooxml-bentUpArrow" && nHandleIndex == 2) if ((rShapeType == "ooxml-bentUpArrow" && nHandleIndex == 2)
|| (rShapeType == "ooxml-curvedUpArrow") || (rShapeType == "ooxml-leftRightUpArrow") || (rShapeType == "ooxml-bracePair") || (rShapeType == "ooxml-bracketPair")
|| (rShapeType == "ooxml-can") || (rShapeType == "ooxml-cube")
|| (rShapeType == "ooxml-curvedUpArrow") || (rShapeType == "ooxml-halfFrame")
|| (rShapeType == "ooxml-leftBrace" && nHandleIndex == 0)
|| (rShapeType == "ooxml-leftBracket") || (rShapeType == "ooxml-leftRightUpArrow")
|| (rShapeType == "ooxml-leftUpArrow" && nHandleIndex == 2) || (rShapeType == "ooxml-leftUpArrow" && nHandleIndex == 2)
|| (rShapeType == "ooxml-mathMultiply") || (rShapeType == "ooxml-quadArrow") || (rShapeType == "ooxml-mathMultiply") || (rShapeType == "ooxml-quadArrow")
|| (rShapeType == "ooxml-quadArrowCallout" && nHandleIndex == 2) || (rShapeType == "ooxml-quadArrowCallout" && nHandleIndex == 2)
|| (rShapeType == "ooxml-upArrow") || (rShapeType == "ooxml-rightBrace" && nHandleIndex == 0)
|| (rShapeType == "ooxml-rightBracket") || (rShapeType == "ooxml-upArrow")
|| (rShapeType == "ooxml-upArrowCallout" && nHandleIndex == 2) || (rShapeType == "ooxml-upArrowCallout" && nHandleIndex == 2)
|| (rShapeType == "ooxml-upDownArrow")) || (rShapeType == "ooxml-upDownArrow")
|| (rShapeType == "ooxml-upDownArrowCallout" && nHandleIndex == 2)
|| (rShapeType == "ooxml-verticalScroll"))
return fY / std::min(fW, fH) * 100000.0; return fY / std::min(fW, fH) * 100000.0;
// pattern y / ss * 50000 // pattern y / ss * 50000
...@@ -1356,7 +1372,8 @@ static double lcl_getYAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa ...@@ -1356,7 +1372,8 @@ static double lcl_getYAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
|| (rShapeType == "ooxml-mathMinus") || (rShapeType == "ooxml-notchedRightArrow") || (rShapeType == "ooxml-mathMinus") || (rShapeType == "ooxml-notchedRightArrow")
|| (rShapeType == "ooxml-mathNotEqual" && nHandleIndex == 2) || (rShapeType == "ooxml-mathNotEqual" && nHandleIndex == 2)
|| (rShapeType == "ooxml-quadArrowCallout" && nHandleIndex == 3) || (rShapeType == "ooxml-quadArrowCallout" && nHandleIndex == 3)
|| (rShapeType == "ooxml-rightArrow") || (rShapeType == "ooxml-stripedRightArrow")) || (rShapeType == "ooxml-rightArrow") || (rShapeType == "ooxml-stripedRightArrow")
|| (rShapeType == "ooxml-upDownArrowCallout" && nHandleIndex == 3))
return (fH / 2.0 - fY) / fH * 200000.0; return (fH / 2.0 - fY) / fH * 200000.0;
// pattern (y - vc) / h * 100000 // pattern (y - vc) / h * 100000
...@@ -1374,7 +1391,7 @@ static double lcl_getYAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa ...@@ -1374,7 +1391,7 @@ static double lcl_getYAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
// special pattern smiley // special pattern smiley
if (rShapeType == "ooxml-smileyFace") if (rShapeType == "ooxml-smileyFace")
return (fY - fH * 16515.0 / 21600.0) / fY * 100000.0; return (fY - fH * 16515.0 / 21600.0) / fH * 100000.0;
// special pattern for star with odd number of tips, because center of star not center of shape // special pattern for star with odd number of tips, because center of star not center of shape
if (rShapeType == "ooxml-star5") if (rShapeType == "ooxml-star5")
...@@ -1382,9 +1399,17 @@ static double lcl_getYAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa ...@@ -1382,9 +1399,17 @@ static double lcl_getYAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
if (rShapeType == "ooxml-star7") if (rShapeType == "ooxml-star7")
return (fH / 2.0 - fY * 100000.0 / 105210.0) / fH * 100000.0; return (fH / 2.0 - fY * 100000.0 / 105210.0) / fH * 100000.0;
// special pattern swooshArrow
if (rShapeType == "ooxml-swooshArrow")
return (fY - std::min(fW, fH) / 8.0) / fH * 100000.0;
// special pattern leftRightRibbon
if (rShapeType == "ooxml-leftRightRibbon")
return fY / fH * 200000 - 100000;
// pattern y / h * 100000, simple scaling // pattern y / h * 100000, simple scaling
if (rShapeType.startsWith("ooxml-")) if (rShapeType.startsWith("ooxml-"))
return fY / fH * 100000; return fY / fH * 100000.0;
return fY; // method is unknown return fY; // method is unknown
} }
...@@ -1749,6 +1774,7 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex ...@@ -1749,6 +1774,7 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex
} }
} }
} }
if (aHandle.nFlags & HandleFlags::REFY) if (aHandle.nFlags & HandleFlags::REFY)
{ {
nSecondAdjustmentValue = aHandle.nRefY; nSecondAdjustmentValue = aHandle.nRefY;
...@@ -1802,6 +1828,13 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex ...@@ -1802,6 +1828,13 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex
fAdjustY += fHeight / fss * (fadj5 - 100000.0); fAdjustY += fHeight / fss * (fadj5 - 100000.0);
} }
} }
else if (sShapeType == "ooxml-leftRightRibbon")
{
if (nIndex == 0)
fAdjustY = GetAdjustValueAsDouble(2) - fAdjustY;
else // nIndex == 2
fAdjustY = GetAdjustValueAsDouble(0) + fAdjustY;
}
} }
if ( nFirstAdjustmentValue >= 0 ) if ( nFirstAdjustmentValue >= 0 )
......
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