diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2017-10-24 22:39:08 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-10-31 17:47:30 +0100 |
commit | 8d366246234e5df784e7596e4c5b21891ae463c1 (patch) | |
tree | 0dc2ea67d6d734d381d0e3b0d6bfad3e80316d71 | |
parent | c344d74a6961ec39685d718fbb7c29dd186ca0a4 (diff) |
PPTX export: correct position of rotated groups
* added testcase for tdf#113263
Change-Id: I7abf68d8fb4ffd8b883cfbf4d69916912add8182
Reviewed-on: https://gerrit.libreoffice.org/43794
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/44082
Reviewed-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r-- | oox/source/export/drawingml.cxx | 17 | ||||
-rwxr-xr-x | sd/qa/unit/data/pptx/group-rot.pptx | bin | 0 -> 39796 bytes | |||
-rwxr-xr-x | sd/qa/unit/data/pptx/group.pptx | bin | 0 -> 69168 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml2.cxx | 30 |
4 files changed, 47 insertions, 0 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index e33dca9f5fe6..40e0c7abe7d2 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -1174,11 +1174,17 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa awt::Point aPos = rXShape->getPosition(); awt::Size aSize = rXShape->getSize(); + bool bPositiveY = true; + bool bPositiveX = true; + if (m_xParent.is()) { awt::Point aParentPos = m_xParent->getPosition(); aPos.X -= aParentPos.X; aPos.Y -= aParentPos.Y; + + bPositiveX = aParentPos.X > 0; + bPositiveY = aParentPos.Y > 0; } if ( aSize.Width < 0 ) @@ -1196,6 +1202,17 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa aPos.X-=(1-faccos*cos(nRotation*F_PI18000))*aSize.Width/2-facsin*sin(nRotation*F_PI18000)*aSize.Height/2; aPos.Y-=(1-faccos*cos(nRotation*F_PI18000))*aSize.Height/2+facsin*sin(nRotation*F_PI18000)*aSize.Width/2; } + else if(nRotation == 18000) + { + if (!bFlipV && bPositiveX) + { + aPos.X -= aSize.Width; + } + if (!bFlipH && bPositiveY) + { + aPos.Y -= aSize.Height; + } + } // The RotateAngle property's value is independent from any flipping, and that's exactly what we need here. uno::Reference<beans::XPropertySet> xPropertySet(rXShape, uno::UNO_QUERY); diff --git a/sd/qa/unit/data/pptx/group-rot.pptx b/sd/qa/unit/data/pptx/group-rot.pptx Binary files differnew file mode 100755 index 000000000000..11b2d6367da0 --- /dev/null +++ b/sd/qa/unit/data/pptx/group-rot.pptx diff --git a/sd/qa/unit/data/pptx/group.pptx b/sd/qa/unit/data/pptx/group.pptx Binary files differnew file mode 100755 index 000000000000..8895fe2a2203 --- /dev/null +++ b/sd/qa/unit/data/pptx/group.pptx diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index edac049c2ba7..9bad50abbdab 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -109,6 +109,8 @@ public: void testTdf112552(); void testTdf112647(); void testSmartartRotation2(); + void testGroupsPosition(); + void testGroupsRotatedPosition(); void testAccentColor(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); @@ -140,6 +142,8 @@ public: CPPUNIT_TEST(testTdf112552); CPPUNIT_TEST(testTdf112647); CPPUNIT_TEST(testSmartartRotation2); + CPPUNIT_TEST(testGroupsPosition); + CPPUNIT_TEST(testGroupsRotatedPosition); CPPUNIT_TEST(testAccentColor); CPPUNIT_TEST_SUITE_END(); @@ -842,6 +846,32 @@ void SdOOXMLExportTest2::testSmartartRotation2() assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:txBody/a:bodyPr", "rot", "10800000"); } +void SdOOXMLExportTest2::testGroupsPosition() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/group.pptx"), PPTX); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + xDocShRef->DoClose(); + + xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:spPr/a:xfrm/a:off", "x", "4817880"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:spPr/a:xfrm/a:off", "y", "1810440"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:spPr/a:xfrm/a:off", "x", "457200"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:spPr/a:xfrm/a:off", "y", "1798560"); +} + +void SdOOXMLExportTest2::testGroupsRotatedPosition() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/group-rot.pptx"), PPTX); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + xDocShRef->DoClose(); + + xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:spPr/a:xfrm/a:off", "x", "2857320"); + assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:spPr/a:xfrm/a:off", "y", "4026960"); +} + void SdOOXMLExportTest2::testAccentColor() { ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/accent-color.pptx"), PPTX); |