sc/qa/unit/data/xlsx/tdf142881.xlsx    |binary
 sc/qa/unit/subsequent_export-test2.cxx |   37 +++++++++++++++++++++++++++++++++
 sc/source/filter/xcl97/xcl97rec.cxx    |    2 -
 3 files changed, 38 insertions(+), 1 deletion(-)

New commits:
commit 30128c2fea22ccd08678744c9501ab052a1fb074
Author:     Daniel Arato (NISZ) <arato.dan...@nisz.hu>
AuthorDate: Mon Aug 30 14:13:52 2021 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Sep 1 11:31:53 2021 +0200

    tdf#142881 XLSX import: fix shapes rotated exactly 45°,
    
    135°, 225° and 315° by correcting their cell anchor points,
    like MSO does. Previously the XLSX export with the bad
    anchor points messed up the rotation of the shapes, resulting
    also broken text content in LO and MSO.
    
    Thanks to Regina Henschel for analyzing the problem.
    
    Co-authored-by: Szabolcs Tóth <toth.szabo...@nisz.hu>
    
    Change-Id: Ica625545a22a74ed027ac0fa2bbf38804611c172
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121307
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121407
    Tested-by: Jenkins

diff --git a/sc/qa/unit/data/xlsx/tdf142881.xlsx 
b/sc/qa/unit/data/xlsx/tdf142881.xlsx
new file mode 100644
index 000000000000..a25dfec68551
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf142881.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test2.cxx 
b/sc/qa/unit/subsequent_export-test2.cxx
index c467b19196aa..77e4bc37673e 100644
--- a/sc/qa/unit/subsequent_export-test2.cxx
+++ b/sc/qa/unit/subsequent_export-test2.cxx
@@ -153,6 +153,7 @@ public:
     void testTdf91634XLSX();
     void testTdf115159();
     void testTdf112567();
+    void testTdf142881();
     void testTdf112567b();
     void testTdf123645XLSX();
     void testTdf125173XLSX();
@@ -254,6 +255,7 @@ public:
     CPPUNIT_TEST(testTdf91634XLSX);
     CPPUNIT_TEST(testTdf115159);
     CPPUNIT_TEST(testTdf112567);
+    CPPUNIT_TEST(testTdf142881);
     CPPUNIT_TEST(testTdf112567b);
     CPPUNIT_TEST(testTdf123645XLSX);
     CPPUNIT_TEST(testTdf125173XLSX);
@@ -1365,6 +1367,41 @@ void ScExportTest2::testTdf112567()
     xDocSh->DoClose();
 }
 
+void ScExportTest2::testTdf142881()
+{
+    ScDocShellRef xDocSh = loadDoc(u"tdf142881.", FORMAT_XLSX);
+    CPPUNIT_ASSERT_MESSAGE("Failed to load tdf142881.xlsx", xDocSh.is());
+
+    std::shared_ptr<utl::TempFile> pXPathFile
+        = ScBootstrapFixture::exportTo(&(*xDocSh), FORMAT_XLSX);
+    xmlDocUniquePtr pDrawing1
+        = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/drawings/drawing1.xml");
+    CPPUNIT_ASSERT(pDrawing1);
+
+    // Verify that the shapes are rotated and positioned in the expected way
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[1]/xdr:from/xdr:col", "11");
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[1]/xdr:from/xdr:row", "0");
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[1]/xdr:to/xdr:col", "12");
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[1]/xdr:to/xdr:row", "19");
+
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[2]/xdr:from/xdr:col", "2");
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[2]/xdr:from/xdr:row", "8");
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[2]/xdr:to/xdr:col", "7");
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[2]/xdr:to/xdr:row", "10");
+
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[3]/xdr:from/xdr:col", "10");
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[3]/xdr:from/xdr:row", "9");
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[3]/xdr:to/xdr:col", "11");
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[3]/xdr:to/xdr:row", "26");
+
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[4]/xdr:from/xdr:col", "2");
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[4]/xdr:from/xdr:row", "17");
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[4]/xdr:to/xdr:col", "8");
+    assertXPathContent(pDrawing1, 
"/xdr:wsDr/xdr:twoCellAnchor[4]/xdr:to/xdr:row", "19");
+
+    xDocSh->DoClose();
+}
+
 void ScExportTest2::testTdf112567b()
 {
     // Set the system locale to Hungarian (a language with different range 
separator)
diff --git a/sc/source/filter/xcl97/xcl97rec.cxx 
b/sc/source/filter/xcl97/xcl97rec.cxx
index 4cde52e362f1..b88604fb306d 100644
--- a/sc/source/filter/xcl97/xcl97rec.cxx
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
@@ -1108,7 +1108,7 @@ void XclObjAny::WriteFromTo( XclExpXmlStream& rStrm, 
const Reference< XShape >&
             // 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 >= 4500_deg100 && nRotation < 13500_deg100) || 
(nRotation >= 22500_deg100 && nRotation < 31500_deg100))
+            if ((nRotation > 4500_deg100 && nRotation <= 13500_deg100) || 
(nRotation > 22500_deg100 && nRotation <= 31500_deg100))
             {
                 aTopLeft.X = aTopLeft.X - nHalfHeight + nHalfWidth;
                 aTopLeft.Y = aTopLeft.Y - nHalfWidth + nHalfHeight;

Reply via email to