diff options
author | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-04-14 18:53:34 +0200 |
---|---|---|
committer | Jacobo Aragunde Pérez <jaragunde@igalia.com> | 2014-04-15 11:35:49 +0200 |
commit | 1393ba60b1eb43b55820f74c393da04308221d97 (patch) | |
tree | 1aafe1d3ac8e3e370aaaaef63a3c260654355b3b | |
parent | b65de36ecb839ec4d7a8f40f9ffe67956e9bc79d (diff) |
fdo#70838: fix rotation transformation in DML exporter
This patch fixes an error in commit
c6ff03f37a6898f50a5ca07152168fb4fe911e05.
And now that fdo#75722 is fixed, I completed the existing unit test
for this bug with absolute position checks.
Change-Id: I76b4fa046db9b946fd23194e91686ffa4fcb5362
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 35 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 8 |
2 files changed, 31 insertions, 12 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx index 5f5ecf9e25da..674b496821b8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx @@ -503,16 +503,16 @@ DECLARE_OOXMLEXPORT_TEST(testFdo70838, "fdo70838.docx") aYPos[2] = getXPathContent(pXmlDocument, "/w:document/w:body/w:p/w:r/mc:AlternateContent[3]/mc:Choice/w:drawing/wp:anchor/wp:positionV/wp:posOffset").toInt32(); aYPos[3] = getXPathContent(pXmlDocument, "/w:document/w:body/w:p/w:r/mc:AlternateContent[4]/mc:Choice/w:drawing/wp:anchor/wp:positionV/wp:posOffset").toInt32(); - // TODO: compare values with a reference value extracted from the original document - // depends on fdo#75722 // certain degree of error is tolerated due to rounding in unit conversions - CPPUNIT_ASSERT(abs(aXPos[0] - aXPos[1]) < 1000); - CPPUNIT_ASSERT(abs(aXPos[1] - aXPos[2]) < 1000); - CPPUNIT_ASSERT(abs(aXPos[2] - aXPos[3]) < 1000); + CPPUNIT_ASSERT(abs(1239520 - aXPos[0]) < 1000); + CPPUNIT_ASSERT(abs(1239520 - aXPos[1]) < 1000); + CPPUNIT_ASSERT(abs(1238250 - aXPos[2]) < 1000); + CPPUNIT_ASSERT(abs(1238885 - aXPos[3]) < 1000); - CPPUNIT_ASSERT(abs(aYPos[0] - aYPos[1]) < 1000); - CPPUNIT_ASSERT(abs(aYPos[1] - aYPos[2]) < 1000); - CPPUNIT_ASSERT(abs(aYPos[2] - aYPos[3]) < 1000); + CPPUNIT_ASSERT(abs(2095500 - aYPos[0]) < 1000); + CPPUNIT_ASSERT(abs(2094865 - aYPos[1]) < 1000); + CPPUNIT_ASSERT(abs(2094230 - aYPos[2]) < 1000); + CPPUNIT_ASSERT(abs(2094865 - aYPos[3]) < 1000); sal_Int32 aHSize[4], aVSize[4]; aHSize[0] = getXPath(pXmlDocument, "/w:document/w:body/w:p/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/wp:extent", "cx").toInt32(); @@ -586,6 +586,25 @@ DECLARE_OOXMLEXPORT_TEST(testFdo70838, "fdo70838.docx") } while( nextTokenPos != -1 ); } + + // Check shape objects + + awt::Point aPos[4]; + aPos[0] = getShape(1)->getPosition(); + aPos[1] = getShape(2)->getPosition(); + aPos[2] = getShape(3)->getPosition(); + aPos[3] = getShape(4)->getPosition(); + + // certain degree of error is tolerated due to rounding in unit conversions + CPPUNIT_ASSERT(abs(4734 - aPos[0].X) < 10); + CPPUNIT_ASSERT(abs(4734 - aPos[1].X) < 10); + CPPUNIT_ASSERT(abs(4731 - aPos[2].X) < 10); + CPPUNIT_ASSERT(abs(4733 - aPos[3].X) < 10); + + CPPUNIT_ASSERT(abs(2845 - aPos[0].Y) < 10); + CPPUNIT_ASSERT(abs(2843 - aPos[1].Y) < 10); + CPPUNIT_ASSERT(abs(2842 - aPos[2].Y) < 10); + CPPUNIT_ASSERT(abs(2843 - aPos[3].Y) < 10); } DECLARE_OOXMLEXPORT_TEST(testFdo73215, "fdo73215.docx") diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index c80cce040c2e..a2cb1092da11 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -85,7 +85,7 @@ OUString lclGetAnchorIdFromGrabBag(const SdrObject* pObj) return aResult; } -void lclMovePositionWithRotation(awt::Point& aPos, sal_Int64 nRotation) +void lclMovePositionWithRotation(awt::Point& aPos, const Size& rSize, sal_Int64 nRotation) { // code from ImplEESdrWriter::ImplFlipBoundingBox (filter/source/msfilter/eschesdo.cxx) // TODO: refactor @@ -104,8 +104,8 @@ void lclMovePositionWithRotation(awt::Point& aPos, sal_Int64 nRotation) double fCos = cos(fVal); double fSin = sin(fVal); - double nWidthHalf = (double) aPos.X / 2; - double nHeightHalf = (double) aPos.Y / 2; + double nWidthHalf = (double) rSize.Width() / 2; + double nHeightHalf = (double) rSize.Height() / 2; double nXDiff = fSin * nHeightHalf + fCos * nWidthHalf - nWidthHalf; double nYDiff = fSin * nWidthHalf + fCos * nHeightHalf - nHeightHalf; @@ -303,7 +303,7 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrmFmt* pFrmFmt, const Size& rS // SdrObjects know their layer, consider that instead of the frame format. bOpaque = pObj->GetLayer() != pFrmFmt->GetDoc()->GetHellId() && pObj->GetLayer() != pFrmFmt->GetDoc()->GetInvisibleHellId(); - lclMovePositionWithRotation(aPos, pObj->GetRotateAngle()); + lclMovePositionWithRotation(aPos, rSize, pObj->GetRotateAngle()); } attrList->add(XML_behindDoc, bOpaque ? "0" : "1"); attrList->add(XML_distT, OString::number(TwipsToEMU(pULSpaceItem.GetUpper())).getStr()); |