summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--svx/qa/unit/customshapes.cxx34
-rw-r--r--svx/qa/unit/data/tdf127785_TextRotateAngle.odpbin0 -> 12841 bytes
-rw-r--r--svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx23
3 files changed, 44 insertions, 13 deletions
diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx
index c1090f87109d..4a1f3cb39c46 100644
--- a/svx/qa/unit/customshapes.cxx
+++ b/svx/qa/unit/customshapes.cxx
@@ -539,6 +539,40 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf127785_Asymmetric)
CPPUNIT_ASSERT_EQUAL(OUString(), sErrors);
}
+
+CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf127785_TextRotateAngle)
+{
+ // The document contains a shapes with vertical flip and a text frame with own
+ // rotate angle. The shape has not stroke and no fill, so that the bounding box
+ // surrounds the text and therefore equals approximately the text frame.
+ // Error was, that the compensation for the 180° rotation added for vertical
+ // flip were not made to the text box position but to the text matrix.
+ const OUString sFileName("tdf127785_TextRotateAngle.odp");
+ 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; // sErrors collects the errors and should be empty in case all is OK.
+
+ uno::Reference<drawing::XShape> xShape(getShape(0));
+ uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
+ CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeProps.is());
+ awt::Rectangle aBoundRect;
+ xShapeProps->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRect;
+ const sal_Int32 nLeft = aBoundRect.X;
+ const sal_Int32 nTop = aBoundRect.Y;
+ const sal_Int32 nRight = aBoundRect.X + aBoundRect.Width - 1;
+ const sal_Int32 nBottom = aBoundRect.Y + aBoundRect.Height - 1;
+ if (abs(nLeft - 5054) > 5)
+ sErrors += "wrong left";
+ if (abs(nRight - 6374) > 5)
+ sErrors += " wrong right";
+ if (abs(nTop - 4516) > 5)
+ sErrors += " wrong top";
+ if (abs(nBottom - 8930) > 5)
+ sErrors += " wrong bottom";
+
+ CPPUNIT_ASSERT_EQUAL(OUString(), sErrors);
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/qa/unit/data/tdf127785_TextRotateAngle.odp b/svx/qa/unit/data/tdf127785_TextRotateAngle.odp
new file mode 100644
index 000000000000..742f12d4d941
--- /dev/null
+++ b/svx/qa/unit/data/tdf127785_TextRotateAngle.odp
Binary files differ
diff --git a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
index 08771194e109..ada854fd5503 100644
--- a/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
+++ b/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx
@@ -94,6 +94,16 @@ namespace sdr
aTextRange.getMinX() + aTranslation.getX(), aTextRange.getMinY() + aTranslation.getY(),
aTextRange.getMaxX() + aTranslation.getX(), aTextRange.getMaxY() + aTranslation.getY());
}
+
+ // NbcMirror() of SdrTextObj (from which SdrObjCustomShape is derived), adds a
+ // 180deg rotation around the shape center to GeoStat.nRotationAngle. So remove here the
+ // 180° rotation, which was added by GetTextBounds().
+ if(GetCustomShapeObj().IsMirroredY())
+ {
+ basegfx::B2DHomMatrix aRotMatrix(basegfx::utils::createRotateAroundPoint(
+ aObjectRange.getCenterX(), aObjectRange.getCenterY(), F_PI));
+ aTextRange.transform(aRotMatrix);
+ }
}
return aTextRange;
@@ -168,19 +178,6 @@ namespace sdr
// give text object a size
aTextBoxMatrix.scale(aTextRange.getWidth(), aTextRange.getHeight());
- // NbcMirror() of SdrTextObj (from which SdrObjCustomShape is derived), adds a
- // 180deg rotation around the shape center to the text box. If aTextRange differs
- // from aObjectRange, that is not the position needed for mirroring. We
- // translate the text box here so, that it is at the correct position after rotation.
- if(GetCustomShapeObj().IsMirroredY())
- {
- aTextBoxMatrix.translate(
- aObjectRange.getWidth() - aTextRange.getWidth()
- - 2 * (aTextRange.getMinX() - aObjectRange.getMinimum().getX()),
- aObjectRange.getHeight() - aTextRange.getHeight()
- - 2 * (aTextRange.getMinY() - aObjectRange.getMinimum().getY()));
- }
-
// check if we have a rotation/shear at all to take care of
const double fExtraTextRotation(GetCustomShapeObj().GetExtraTextRotation());
const GeoStat& rGeoStat(GetCustomShapeObj().GetGeoStat());