[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - include/oox oox/source sd/qa

Justin Luth justin.luth at collabora.com
Tue Jul 10 18:15:11 UTC 2018


 include/oox/export/drawingml.hxx                |    2 +
 oox/source/export/drawingml.cxx                 |   29 +++++++++++++++++++-----
 sd/qa/unit/data/pptx/tdf114845_rotateShape.pptx |binary
 sd/qa/unit/export-tests-ooxml2.cxx              |   16 +++++++++++++
 4 files changed, 42 insertions(+), 5 deletions(-)

New commits:
commit 3fdff39af3b793f68f9c72d940590948dbb840e2
Author: Justin Luth <justin.luth at collabora.com>
Date:   Mon Jun 25 13:43:11 2018 +0300

    tdf#114845 sd: only shift rotated group items
    
    fixes 6.0 commit 9ae1e094d5a8a5b4432c88ebea0ca9fc1c79f602
    > PPTX export: correct position of rotated groups
    
    However, there was nothing excluding the re-positioning
    to only group items.
    
    Change-Id: I62e36b46c0d2ac3e41f8d7d4ed82df11e6eb1ee5
    Reviewed-on: https://gerrit.libreoffice.org/56386
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/56542
    Reviewed-by: Justin Luth <justin_luth at sil.org>
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>

diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 627bcc983706..f281d7f7ccc4 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -226,6 +226,8 @@ public:
     void WriteShape3DEffects( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
     void WriteArtisticEffect( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
     OString WriteWdpPicture( const OUString& rFileId, const css::uno::Sequence< sal_Int8 >& rPictureData );
+    bool IsInGroupShape() const;
+    bool IsGroupShape( const css::uno::Reference< css::drawing::XShape >& rXShape, bool bOrChildShape = false ) const;
     sal_Int32 getBulletMarginIndentation (const css::uno::Reference< css::beans::XPropertySet >& rXPropSet,sal_Int16 nLevel, const OUString& propName);
 
     static void ResetCounters();
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index d243a4f99d13..d83f9165656f 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1322,7 +1322,7 @@ 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)
+        else if ( nRotation == 18000 && IsGroupShape( rXShape, /*bOrChildShape=*/true ) )
         {
             if (!bFlipV && bPositiveX)
             {
@@ -1348,11 +1348,8 @@ void DrawingML::WriteShapeTransformation( const Reference< XShape >& rXShape, sa
     if(bSuppressFlipping)
         bFlipH = bFlipV = false;
 
-    uno::Reference<lang::XServiceInfo> xServiceInfo(rXShape, uno::UNO_QUERY_THROW);
-    bool bIsGroupShape = (xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.drawing.GroupShape"));
-
     WriteTransformation(tools::Rectangle(Point(aPos.X, aPos.Y), Size(aSize.Width, aSize.Height)), nXmlNamespace,
-            bFlipH, bFlipV, OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY(nRotation), bIsGroupShape);
+            bFlipH, bFlipV, OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY(nRotation), IsGroupShape( rXShape ));
 }
 
 void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool bIsField, sal_Int32 nElement, bool bCheckDirect,
@@ -2024,6 +2021,28 @@ void DrawingML::WriteParagraphNumbering( const Reference< XPropertySet >& rXProp
     }
 }
 
+bool DrawingML::IsInGroupShape () const
+{
+    bool bRet = m_xParent.is();
+    if ( bRet )
+    {
+        uno::Reference<lang::XServiceInfo> xServiceInfo(m_xParent, uno::UNO_QUERY_THROW);
+        bRet = xServiceInfo->supportsService("com.sun.star.drawing.GroupShape");
+    }
+    return bRet;
+}
+
+bool DrawingML::IsGroupShape( const Reference< XShape >& rXShape, bool bOrChildShape ) const
+{
+    bool bRet = bOrChildShape && IsInGroupShape();
+    if ( !bRet )
+    {
+        uno::Reference<lang::XServiceInfo> xServiceInfo(rXShape, uno::UNO_QUERY_THROW);
+        bRet = xServiceInfo->supportsService("com.sun.star.drawing.GroupShape");
+    }
+    return bRet;
+}
+
 sal_Int32 DrawingML::getBulletMarginIndentation (const Reference< XPropertySet >& rXPropSet,sal_Int16 nLevel, const OUString& propName)
 {
     if( nLevel < 0 || !GETA( NumberingRules ) )
diff --git a/sd/qa/unit/data/pptx/tdf114845_rotateShape.pptx b/sd/qa/unit/data/pptx/tdf114845_rotateShape.pptx
new file mode 100644
index 000000000000..e9fcb92d80e0
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf114845_rotateShape.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index bf06019ddb8f..b1f8b63cc5f5 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -120,6 +120,7 @@ public:
     void testGroupRotation();
     void testTdf104788();
     void testSmartartRotation2();
+    void testTdf114845_rotateShape();
     void testGroupsPosition();
     void testGroupsRotatedPosition();
     void testAccentColor();
@@ -176,6 +177,7 @@ public:
     CPPUNIT_TEST(testGroupRotation);
     CPPUNIT_TEST(testTdf104788);
     CPPUNIT_TEST(testSmartartRotation2);
+    CPPUNIT_TEST(testTdf114845_rotateShape);
     CPPUNIT_TEST(testGroupsPosition);
     CPPUNIT_TEST(testGroupsRotatedPosition);
     CPPUNIT_TEST(testAccentColor);
@@ -1272,6 +1274,20 @@ void SdOOXMLExportTest2::testSmartartRotation2()
     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:txBody/a:bodyPr", "rot", "10800000");
 }
 
+void SdOOXMLExportTest2::testTdf114845_rotateShape()
+{
+    ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf114845_rotateShape.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[5]/p:nvSpPr/p:cNvPr", "name", "CustomShape 5");
+    assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:xfrm", "flipV", "1");
+    assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:xfrm/a:off", "x", "4059000");
+    assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:xfrm/a:off", "y", "3287520");
+}
+
 void SdOOXMLExportTest2::testGroupsPosition()
 {
     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/group.pptx"), PPTX);


More information about the Libreoffice-commits mailing list