sc/source/filter/xcl97/xcl97rec.cxx |   47 ++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

New commits:
commit 7508e997dfdbd636870bbe71cccd1dfbdfbf3421
Author:     Szabolcs Toth <[email protected]>
AuthorDate: Sat Dec 12 10:33:20 2020 +0100
Commit:     Gabor Kelemen <[email protected]>
CommitDate: Wed Mar 3 13:58:46 2021 +0100

    refactor for xlsx shape export
    
    Just a refactor, fewer lines, less computing capacity.
    
    Change-Id: I3c3446c2917e9b5d2f205dd5c0110821ecf11f56
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107613
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit 368c56144aab5794c39d5bc2082d9b3d6d7cebdb)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111886
    Tested-by: Gabor Kelemen <[email protected]>
    Reviewed-by: Gabor Kelemen <[email protected]>

diff --git a/sc/source/filter/xcl97/xcl97rec.cxx 
b/sc/source/filter/xcl97/xcl97rec.cxx
index 3bb0d2af4608..38ad870c4970 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -1094,32 +1094,33 @@ void XclObjAny::WriteFromTo( XclExpXmlStream& rStrm, 
const Reference< XShape >&
     awt::Point  aTopLeft    = rShape->getPosition();
     awt::Size   aSize       = rShape->getSize();
 
-    // size is correct, but aTopLeft needs correction for rotated shapes
+    // There are a few cases where we must adjust these values
     SdrObject* pObj = SdrObject::getSdrObjectFromXShape(rShape.get());
-    sal_Int32 nRotation = pObj->GetRotateAngle();
-    if ( pObj && nRotation != 0 && pObj->GetObjIdentifier() == OBJ_CUSTOMSHAPE 
)
+    if (pObj)
     {
-        const tools::Rectangle& aSnapRect(pObj->GetSnapRect()); // bounding 
box of the rotated shape
-        aTopLeft.X = aSnapRect.getX() + (aSnapRect.GetWidth() / 2) - 
(aSize.Width / 2);
-        aTopLeft.Y = aSnapRect.getY() + (aSnapRect.GetHeight() / 2) - 
(aSize.Height / 2);
-    }
-
-    uno::Reference< beans::XPropertySet > xShapeProperties(rShape, 
uno::UNO_QUERY_THROW);
-    uno::Any nRotProp = xShapeProperties->getPropertyValue("RotateAngle");
-    sal_Int32 nRot = nRotProp.get<sal_Int32>();
-
-    if ((nRot >= 45 * 100 && nRot < 135 * 100) || (nRot >= 225 * 100 && nRot < 
315 * 100))
-    {
-        // MSO changes the anchor positions at these angles and that does an 
extra 90 degrees
-        // rotation on our shapes, so we output it in such position that MSO
-        // can draw this shape correctly.
-
-        sal_Int16 nHalfWidth = aSize.Width / 2;
-        sal_Int16 nHalfHeight = aSize.Height / 2;
-        aTopLeft.X = aTopLeft.X - nHalfHeight + nHalfWidth;
-        aTopLeft.Y = aTopLeft.Y - nHalfWidth + nHalfHeight;
+        sal_Int32 nRotation = pObj->GetRotateAngle();
+        if (nRotation != 0)
+        {
+            sal_Int16 nHalfWidth = aSize.Width / 2;
+            sal_Int16 nHalfHeight = aSize.Height / 2;
+            // aTopLeft needs correction for rotated customshapes
+            if (pObj->GetObjIdentifier() == OBJ_CUSTOMSHAPE)
+            {
+                const tools::Rectangle& aSnapRect(pObj->GetSnapRect()); // 
bounding box of the rotated shape
+                aTopLeft.X = aSnapRect.getX() + (aSnapRect.GetWidth() / 2) - 
nHalfWidth;
+                aTopLeft.Y = aSnapRect.getY() + (aSnapRect.GetHeight() / 2) - 
nHalfHeight;
+            }
 
-        std::swap(aSize.Width, aSize.Height);
+            // MSO changes the anchor positions at these angles and that does 
an extra 90 degrees
+            // rotation on our shapes, so we output it in such position that 
MSO
+            // can draw this shape correctly.
+            if ((nRotation >= 45 * 100 && nRotation < 135 * 100) || (nRotation 
>= 225 * 100 && nRotation < 315 * 100))
+            {
+                aTopLeft.X = aTopLeft.X - nHalfHeight + nHalfWidth;
+                aTopLeft.Y = aTopLeft.Y - nHalfWidth + nHalfHeight;
+                std::swap(aSize.Width, aSize.Height);
+            }
+        }
     }
 
     tools::Rectangle   aLocation( aTopLeft.X, aTopLeft.Y, aTopLeft.X + 
aSize.Width, aTopLeft.Y + aSize.Height );
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to