[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sc/qa sc/source

Szabolcs Toth (via logerrit) logerrit at kemper.freedesktop.org
Fri Dec 11 16:48:26 UTC 2020


 sc/qa/unit/subsequent_export-test.cxx |   16 ++++++++++++----
 sc/source/filter/xcl97/xcl97rec.cxx   |   10 ++++++++++
 2 files changed, 22 insertions(+), 4 deletions(-)

New commits:
commit 8f7c26f166df33589f3522b43dbea4169a9ffd1e
Author:     Szabolcs Toth <toth.szabolcs at nisz.hu>
AuthorDate: Tue Dec 8 16:21:25 2020 +0100
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Fri Dec 11 17:47:54 2020 +0100

    tdf#123613 XLSX export: fix position of rotated shapes
    
    based on the bounding box of the custom shape.
    
    Change-Id: I63a2a4380ae0c6c0eb37d3e5e4dcbfc839b410a3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107424
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    Signed-off-by: Xisco Fauli <xiscofauli at libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107599
    Tested-by: Jenkins

diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 03d63baeeabd..6f3e4d3d36e5 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -5409,8 +5409,9 @@ void ScExportTest::testHeaderFontStyleXLSX()
 
 void ScExportTest::testTdf135828_Shape_Rect()
 {
-    // tdf#135828 Check that the width and the height of rectangle of the shape
-    // is correct.
+    // tdf#135828 Check that the width and the height of rectangle of the shape is correct.
+    // tdf#123613 Check the positioning, and allow massive rounding errors because of the back and
+    // forth conversion between emu and hmm.
     ScDocShellRef xShell = loadDoc("tdf135828_Shape_Rect.", FORMAT_XLSX);
     CPPUNIT_ASSERT(xShell.is());
 
@@ -5422,8 +5423,15 @@ void ScExportTest::testTdf135828_Shape_Rect()
     xmlDocUniquePtr pDrawing = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/drawing1.xml");
     CPPUNIT_ASSERT(pDrawing);
 
-    assertXPath(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:sp/xdr:spPr/a:xfrm/a:ext", "cx", "294480"); // width
-    assertXPath(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:sp/xdr:spPr/a:xfrm/a:ext", "cy", "1990440"); // height
+    double nXPosOfTopleft = getXPath(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:sp/xdr:spPr/a:xfrm/a:off", "x" ).toDouble();
+    double nYPosOfTopleft = getXPath(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:sp/xdr:spPr/a:xfrm/a:off", "y" ).toDouble();
+    double nWidth         = getXPath(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:sp/xdr:spPr/a:xfrm/a:ext", "cx").toDouble();
+    double nHeight        = getXPath(pDrawing, "/xdr:wsDr/xdr:twoCellAnchor/xdr:sp/xdr:spPr/a:xfrm/a:ext", "cy").toDouble();
+
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(  854640, nXPosOfTopleft, 10000);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL( -570600, nYPosOfTopleft, 10000);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(  294840,         nWidth, 10000);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL( 1988280,        nHeight, 10000);
 }
 
 void ScExportTest::testTdf123353()
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx b/sc/source/filter/xcl97/xcl97rec.cxx
index a095a599c58a..ed4dbf5da31e 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -1100,6 +1100,16 @@ 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
+    SdrObject* pObj = SdrObject::getSdrObjectFromXShape(rShape.get());
+    sal_Int32 nRotation = pObj->GetRotateAngle();
+    if ( pObj && nRotation != 0 && pObj->GetObjIdentifier() == OBJ_CUSTOMSHAPE )
+    {
+        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::Reference<beans::XPropertySetInfo> xPropertySetInfo = xShapeProperties->getPropertySetInfo();
     if (xPropertySetInfo->hasPropertyByName("RotateAngle"))


More information about the Libreoffice-commits mailing list