[Libreoffice-commits] core.git: Branch 'feature/RotGrfFlyFrame' - svx/source
Armin Le Grand
Armin.Le.Grand at cib.de
Thu Sep 28 11:09:46 UTC 2017
svx/source/svdraw/svddrgmt.cxx | 52 ++++++++++++++++-------------------------
1 file changed, 21 insertions(+), 31 deletions(-)
New commits:
commit 51528194d58339ebcf17a0293cf752b6184e1f2f
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date: Thu Sep 28 13:08:35 2017 +0200
RotGrfFlyFrame: Encapsulated matrix decomposes
Change-Id: I432766970ef06c7d85a0056d3f24280cf2acd47d
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index 67efd4b9da5a..5790e0280c59 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -595,21 +595,20 @@ void SdrDragMethod::applyCurrentTransformationToSdrObject(SdrObject& rTarget)
{
// do something special since the object size is in the polygon
// break up matrix to get the scale
- basegfx::B2DTuple aScale;
- basegfx::B2DTuple aTranslate;
- double fRotate, fShearX;
- aObjectTransform.decompose(aScale, aTranslate, fRotate, fShearX);
+ const basegfx::tools::B2DHomMatrixBufferedDecompose aDecomp(aObjectTransform);
// get polygon's position and size
const basegfx::B2DRange aPolyRange(aObjectPolyPolygon.getB2DRange());
// get the scaling factors (do not mirror, this is in the object transformation)
- const double fScaleX(fabs(aScale.getX()) / (basegfx::fTools::equalZero(aPolyRange.getWidth()) ? 1.0 : aPolyRange.getWidth()));
- const double fScaleY(fabs(aScale.getY()) / (basegfx::fTools::equalZero(aPolyRange.getHeight()) ? 1.0 : aPolyRange.getHeight()));
+ const double fScaleX(fabs(aDecomp.getScale().getX()) / (basegfx::fTools::equalZero(aPolyRange.getWidth()) ? 1.0 : aPolyRange.getWidth()));
+ const double fScaleY(fabs(aDecomp.getScale().getY()) / (basegfx::fTools::equalZero(aPolyRange.getHeight()) ? 1.0 : aPolyRange.getHeight()));
// prepare transform matrix for polygon
- basegfx::B2DHomMatrix aPolyTransform(basegfx::tools::createTranslateB2DHomMatrix(
- -aPolyRange.getMinX(), -aPolyRange.getMinY()));
+ basegfx::B2DHomMatrix aPolyTransform(
+ basegfx::tools::createTranslateB2DHomMatrix(
+ -aPolyRange.getMinX(),
+ -aPolyRange.getMinY()));
aPolyTransform.scale(fScaleX, fScaleY);
// transform the polygon
@@ -3658,18 +3657,16 @@ bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/)
pObj->TRGetBaseGeometry(aOriginalMatrix, aPolyPolygon);
{ // correct shear, it comes currently mirrored from TRGetBaseGeometry, can be removed with aw080
- basegfx::B2DTuple aScale, aTranslate;
- double fRotate(0.0), fShearX(0.0);
- aOriginalMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+ const basegfx::tools::B2DHomMatrixBufferedDecompose aDecomp(aOriginalMatrix);
- if(!basegfx::fTools::equalZero(fShearX))
+ if(!basegfx::fTools::equalZero(aDecomp.getShearX()))
{
bShearCorrected = true;
aOriginalMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
- aScale,
- -fShearX,
- fRotate,
- aTranslate);
+ aDecomp.getScale(),
+ -aDecomp.getShearX(),
+ aDecomp.getRotate(),
+ aDecomp.getTranslate());
}
}
@@ -3743,17 +3740,13 @@ bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/)
// aDiscreteChangeMatrix, go to concrete sizes now.
// Create the unrotated original rectangle and the unrotated modified
// rectangle as Ranges
- basegfx::B2DTuple aScale, aTranslate;
- double fRotate, fShearX;
-
- // get access to scale and translate
- aOriginalMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+ const basegfx::tools::B2DHomMatrixBufferedDecompose aDecomp(aOriginalMatrix);
// prepare unsheared/unrotated versions of the old and new transformation
const basegfx::B2DHomMatrix aOriginalMatrixNoShearNoRotate(
basegfx::tools::createScaleTranslateB2DHomMatrix(
- basegfx::absolute(aScale),
- aTranslate));
+ basegfx::absolute(aDecomp.getScale()),
+ aDecomp.getTranslate()));
// create the ranges for these
basegfx::B2DRange aRangeOriginalNoShearNoRotate(0.0, 0.0, 1.0, 1.0);
@@ -3791,16 +3784,13 @@ bool SdrDragCrop::EndSdrDrag(bool /*bCopy*/)
if(bShearCorrected)
{
// back-correct shear
- basegfx::B2DTuple aScale;
- basegfx::B2DTuple aTranslate;
- double fRotate(0.0), fShearX(0.0);
+ const basegfx::tools::B2DHomMatrixBufferedDecompose aDecomp(aNewObjectMatrix);
- aNewObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
aNewObjectMatrix = basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
- aScale,
- -fShearX,
- fRotate,
- aTranslate);
+ aDecomp.getScale(),
+ -aDecomp.getShearX(),
+ aDecomp.getRotate(),
+ aDecomp.getTranslate());
}
// apply change to object by applying the unit coordinate change followed
More information about the Libreoffice-commits
mailing list