summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRegina Henschel <rb.henschel@t-online.de>2019-05-13 14:21:05 +0200
committerRegina Henschel <rb.henschel@t-online.de>2019-05-17 21:16:24 +0200
commit4ca556d041b3e27c4aeebf7434814eb8a4350203 (patch)
tree2aaeed00ac02afdbaa4a9ecd10931500dbdb6b6d
parentdrop now unused SFX_IMPL_MODELESSDIALOG_WITHID (diff)
downloadcore-4ca556d041b3e27c4aeebf7434814eb8a4350203.tar.gz
core-4ca556d041b3e27c4aeebf7434814eb8a4350203.zip
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: Regina Henschel <rb.henschel@t-online.de>
-rw-r--r--include/svx/svdoashp.hxx6
-rw-r--r--svx/qa/unit/customshapes.cxx75
-rw-r--r--svx/qa/unit/data/tdf115813_HandleMovementOOXMLPresetShapes.pptxbin0 -> 34536 bytes
-rw-r--r--svx/source/customshapes/EnhancedCustomShape2d.cxx51
4 files changed, 120 insertions, 12 deletions
diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx
index e7f915992eae..662ddb5d446b 100644
--- a/include/svx/svdoashp.hxx
+++ b/include/svx/svdoashp.hxx
@@ -98,11 +98,11 @@ public:
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 DragResizeCustomShape( const tools::Rectangle& rNewRect );
- SVX_DLLPRIVATE void DragMoveCustomShapeHdl( const Point& rDestination,
- const sal_uInt16 nCustomShapeHdlNum, bool bMoveCalloutRectangle );
+ void DragMoveCustomShapeHdl( const Point& rDestination,
+ const sal_uInt16 nCustomShapeHdlNum, bool bMoveCalloutRectangle ); // needed in unit test
// #i37011# centralize throw-away of render geometry
void InvalidateRenderGeometry();
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index 526721d1a6c3..470d838cda3b 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -38,6 +38,7 @@ protected:
uno::Reference<lang::XComponent> mxComponent;
// get shape nShapeIndex from page 0
uno::Reference<drawing::XShape> getShape(sal_uInt8 nShapeIndex);
+ sal_uInt8 countShapes();
public:
virtual void setUp() override
@@ -69,6 +70,17 @@ uno::Reference<drawing::XShape> CustomshapesTest::getShape(sal_uInt8 nShapeIndex
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)
{
// tdf#121890 formula values "left" and "top" are wrongly calculated
@@ -318,6 +330,69 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf124740_handle_path_coordsystem)
// tolerance for rounding to integer
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: */
diff --git a/svx/qa/unit/data/tdf115813_HandleMovementOOXMLPresetShapes.pptx b/svx/qa/unit/data/tdf115813_HandleMovementOOXMLPresetShapes.pptx
new file mode 100644
index 000000000000..a16826e23419
--- /dev/null
+++ b/svx/qa/unit/data/tdf115813_HandleMovementOOXMLPresetShapes.pptx
Binary files differ
diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx
index fdeac2f6ddb2..483f1796b901 100644
--- a/svx/source/customshapes/EnhancedCustomShape2d.cxx
+++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx
@@ -1206,6 +1206,7 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
if ((rShapeType == "ooxml-bentArrow" && nHandleIndex == 2) || (rShapeType == "ooxml-chevron")
|| (rShapeType == "ooxml-curvedRightArrow") || (rShapeType == "ooxml-foldedCorner")
|| (rShapeType == "ooxml-homePlate") || (rShapeType == "ooxml-notchedRightArrow")
+ || (rShapeType == "ooxml-nonIsoscelesTrapezoid" && nHandleIndex == 1)
|| (rShapeType == "ooxml-rightArrow")
|| (rShapeType == "ooxml-rightArrowCallout" && nHandleIndex == 2)
|| (rShapeType == "ooxml-round1Rect")
@@ -1215,7 +1216,7 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
|| (rShapeType == "ooxml-snip2DiagRect" && nHandleIndex == 1)
|| (rShapeType == "ooxml-snip2SameRect" && nHandleIndex == 0)
|| (rShapeType == "ooxml-snipRoundRect" && nHandleIndex == 1)
- || (rShapeType == "ooxml-stripedRightArrow"))
+ || (rShapeType == "ooxml-swooshArrow") || (rShapeType == "ooxml-stripedRightArrow"))
return (fW - fX) / std::min(fW, fH) * 100000.0;
// pattern x / ss * 100000 or (x - l) / ss * 100000
@@ -1226,6 +1227,8 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
|| (rShapeType == "ooxml-leftArrowCallout" && nHandleIndex == 2)
|| (rShapeType == "ooxml-leftRightArrow")
|| (rShapeType == "ooxml-leftRightArrowCallout" && nHandleIndex == 2)
+ || (rShapeType == "ooxml-leftRightRibbon")
+ || (rShapeType == "ooxml-nonIsoscelesTrapezoid" && nHandleIndex == 0)
|| (rShapeType == "ooxml-round2DiagRect" && nHandleIndex == 0)
|| (rShapeType == "ooxml-round2SameRect" && nHandleIndex == 1)
|| (rShapeType == "ooxml-roundRect")
@@ -1241,7 +1244,8 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
|| (rShapeType == "ooxml-leftRightUpArrow" && nHandleIndex == 0)
|| (rShapeType == "ooxml-quadArrow" && 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;
// pattern (hc - x) / ss * 100000
@@ -1249,7 +1253,8 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
|| (rShapeType == "ooxml-leftRightUpArrow" && nHandleIndex == 1)
|| (rShapeType == "ooxml-quadArrow" && 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;
// pattern (w - x) / ss * 50000 or (r - x) / ss * 50000
@@ -1257,6 +1262,10 @@ static double lcl_getXAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
|| (rShapeType == "ooxml-uturnArrow" && nHandleIndex == 1))
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
if ((rShapeType == "ooxml-downArrow" && nHandleIndex == 0)
|| (rShapeType == "ooxml-ellipseRibbon") || (rShapeType == "ooxml-ellipseRibbon2")
@@ -1326,13 +1335,20 @@ static double lcl_getYAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
// pattern y / ss * 100000 or (y - t) / ss * 100000
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-mathMultiply") || (rShapeType == "ooxml-quadArrow")
|| (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-upDownArrow"))
+ || (rShapeType == "ooxml-upDownArrow")
+ || (rShapeType == "ooxml-upDownArrowCallout" && nHandleIndex == 2)
+ || (rShapeType == "ooxml-verticalScroll"))
return fY / std::min(fW, fH) * 100000.0;
// pattern y / ss * 50000
@@ -1356,7 +1372,8 @@ static double lcl_getYAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
|| (rShapeType == "ooxml-mathMinus") || (rShapeType == "ooxml-notchedRightArrow")
|| (rShapeType == "ooxml-mathNotEqual" && nHandleIndex == 2)
|| (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;
// pattern (y - vc) / h * 100000
@@ -1374,7 +1391,7 @@ static double lcl_getYAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
// special pattern smiley
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
if (rShapeType == "ooxml-star5")
@@ -1382,9 +1399,17 @@ static double lcl_getYAdjustmentValue(OUString& rShapeType, const sal_uInt32 nHa
if (rShapeType == "ooxml-star7")
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
if (rShapeType.startsWith("ooxml-"))
- return fY / fH * 100000;
+ return fY / fH * 100000.0;
return fY; // method is unknown
}
@@ -1749,6 +1774,7 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex
}
}
}
+
if (aHandle.nFlags & HandleFlags::REFY)
{
nSecondAdjustmentValue = aHandle.nRefY;
@@ -1802,6 +1828,13 @@ bool EnhancedCustomShape2d::SetHandleControllerPosition( const sal_uInt32 nIndex
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 )