Kaydet (Commit) ae0e830f authored tarafından Mike Kaganski's avatar Mike Kaganski Kaydeden (comit) Mike Kaganski

tdf#95970: Don't loose mirroring in SdrTextObj::TRSetBaseGeometry

Currently, negative scaling (mirroring) is lost in
SdrTextObj::NbcSetSnapRect, when rect is justified.
This patch cares for this.

Possibly it's better to make these changes directly in
SdrTextObj::NbcSetSnapRect?

Change-Id: I353ff01626e15b398de95e28eae78572991dfdc3
Reviewed-on: https://gerrit.libreoffice.org/20109Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarArmin Le Grand <Armin.Le.Grand@cib.de>
üst ccd04a5f
...@@ -1722,6 +1722,9 @@ void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b ...@@ -1722,6 +1722,9 @@ void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b
aScale.setY(fabs(aScale.getY())); aScale.setY(fabs(aScale.getY()));
fRotate = fmod(fRotate + F_PI, F_2PI); fRotate = fmod(fRotate + F_PI, F_2PI);
} }
// flip?
bool bFlipX = basegfx::fTools::less(aScale.getX(), 0.0),
bFlipY = basegfx::fTools::less(aScale.getY(), 0.0);
// reset object shear and rotations // reset object shear and rotations
aGeo.nRotationAngle = 0; aGeo.nRotationAngle = 0;
...@@ -1769,6 +1772,16 @@ void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b ...@@ -1769,6 +1772,16 @@ void SdrTextObj::TRSetBaseGeometry(const basegfx::B2DHomMatrix& rMatrix, const b
Rectangle aBaseRect(aPoint, aSize); Rectangle aBaseRect(aPoint, aSize);
SetSnapRect(aBaseRect); SetSnapRect(aBaseRect);
// flip?
if (bFlipX)
{
Mirror(Point(), Point(0, 1));
}
if (bFlipY)
{
Mirror(Point(), Point(1, 0));
}
// shear? // shear?
if(!basegfx::fTools::equalZero(fShearX)) if(!basegfx::fTools::equalZero(fShearX))
{ {
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
#include <oox/drawingml/drawingmltypes.hxx> #include <oox/drawingml/drawingmltypes.hxx>
#include <unotools/streamwrap.hxx> #include <unotools/streamwrap.hxx>
#include <comphelper/propertysequence.hxx> #include <comphelper/propertysequence.hxx>
#include <com/sun/star/drawing/HomogenMatrix3.hpp>
#include <bordertest.hxx> #include <bordertest.hxx>
...@@ -2961,6 +2962,33 @@ DECLARE_OOXMLIMPORT_TEST(testTdf60351, "tdf60351.docx") ...@@ -2961,6 +2962,33 @@ DECLARE_OOXMLIMPORT_TEST(testTdf60351, "tdf60351.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPolygon[5].Y); CPPUNIT_ASSERT_EQUAL(sal_Int32(0), aPolygon[5].Y);
} }
DECLARE_OOXMLIMPORT_TEST(testTdf95970, "tdf95970.docx")
{
// First shape: the rotation should be -12.94 deg, it should be mirrored.
// Proper color order of image on test doc (left->right):
// top row: green->red
// bottom row: yellow->blue
uno::Reference<drawing::XShape> xShape(getShape(1), uno::UNO_QUERY_THROW);
uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY_THROW);
sal_Int32 aRotate = 0;
xPropertySet->getPropertyValue("RotateAngle") >>= aRotate;
CPPUNIT_ASSERT_EQUAL(sal_Int32(34706), aRotate);
bool bIsMirrored = false;
xPropertySet->getPropertyValue("IsMirrored") >>= bIsMirrored;
CPPUNIT_ASSERT(bIsMirrored);
drawing::HomogenMatrix3 aTransform;
xPropertySet->getPropertyValue("Transformation") >>= aTransform;
CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line1.Column1, 4767.0507250872988));
CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line1.Column2, -1269.0985325236848));
CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line1.Column3, 696.73611111111109));
CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line2.Column1, 1095.3035265135941));
CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line2.Column2, 5523.4525711162969));
CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line2.Column3, 672.04166666666663));
CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line3.Column1, 0.0));
CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line3.Column2, 0.0));
CPPUNIT_ASSERT(basegfx::fTools::equal(aTransform.Line3.Column3, 1.0));
}
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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