Kaydet (Commit) 6c5557c6 authored tarafından Jacobo Aragunde Pérez's avatar Jacobo Aragunde Pérez Kaydeden (comit) Miklos Vajna

fdo#70838: Fix position issue when exporting shapes to docx.

Fixed an error at ImplEESdrWriter::ImplFlipBoundingBox implementation.
I've also tried to simplify and explain the calculations done there.

Change-Id: I41c6c6e1a045803524479c92ef807913db38167a
Reviewed-on: https://gerrit.libreoffice.org/6433Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst cc8c94b3
......@@ -98,10 +98,11 @@ void ImplEESdrWriter::ImplFlipBoundingBox( ImplEESdrObject& rObj, EscherProperty
sal_Int32 nAngle = rObj.GetAngle();
Rectangle aRect( rObj.GetRect() );
// for position calculations, we normalize the angle between 0 and 90 degrees
if ( nAngle < 0 )
nAngle = ( 36000 + nAngle ) % 36000;
else
nAngle = ( 36000 - ( nAngle % 36000 ) );
while ( nAngle > 9000 )
nAngle = ( 18000 - ( nAngle % 18000 ) );
double fVal = (double)nAngle * F_PI18000;
double fCos = cos( fVal );
......@@ -110,10 +111,24 @@ void ImplEESdrWriter::ImplFlipBoundingBox( ImplEESdrObject& rObj, EscherProperty
double nWidthHalf = (double) aRect.GetWidth() / 2;
double nHeightHalf = (double) aRect.GetHeight() / 2;
double nXDiff = fCos * nWidthHalf + fSin * (-nHeightHalf);
double nYDiff = - ( fSin * nWidthHalf - fCos * ( -nHeightHalf ) );
// fdo#70838:
// when you rotate an object, the top-left corner of its bounding box is moved
// nXDiff and nYDiff pixels. To get their values we use these equations:
//
// fSin * nHeightHalf + fCos * nWidthHalf == nXDiff + nWidthHalf
// fSin * nWidthHalf + fCos * nHeightHalf == nYDiff + nHeightHalf
double nXDiff = fSin * nHeightHalf + fCos * nWidthHalf - nWidthHalf;
double nYDiff = fSin * nWidthHalf + fCos * nHeightHalf - nHeightHalf;
aRect.Move( (sal_Int32) nXDiff, (sal_Int32) nYDiff );
aRect.Move( (sal_Int32)( -( nWidthHalf - nXDiff ) ), (sal_Int32)( - ( nHeightHalf + nYDiff ) ) );
// calculate the proper angle value to be saved
nAngle = rObj.GetAngle();
if ( nAngle < 0 )
nAngle = ( 36000 + nAngle ) % 36000;
else
nAngle = ( 36000 - ( nAngle % 36000 ) );
nAngle *= 655;
nAngle += 0x8000;
......
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