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

Tamás Zolnai tamas.zolnai at collabora.com
Wed Aug 2 08:24:01 UTC 2017


 include/oox/drawingml/shape.hxx     |    2 ++
 oox/source/drawingml/shape.cxx      |    6 ++++++
 sd/qa/unit/data/pptx/tdf109223.pptx |binary
 sd/qa/unit/import-tests.cxx         |   34 ++++++++++++++++++++++++++++++++++
 4 files changed, 42 insertions(+)

New commits:
commit c49f2c00067cbe5de714525807290b71aec57ea3
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Sat Jul 29 21:43:41 2017 +0200

    tdf#109223: PPTX: Vertical flip of child shape is not imported correctly
    
    Group shape level vertical flip is not handled well. Recent handling
    of group shape's transformation makes it hard to import this attribute,
    but we can import the right text direction at least.
    
    Reviewed-on: https://gerrit.libreoffice.org/40554
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit d742c0019435d0bc90c9342492583636099a057f)
    
    Change-Id: Ib9e39e3dcb28a95fabc61c13152a3f7296fbd4c3
    Reviewed-on: https://gerrit.libreoffice.org/40556
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 67f9a9b48afd..b7f1d162d7bb 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -138,6 +138,7 @@ public:
 
     void                            setRotation( sal_Int32 nRotation ) { mnRotation = nRotation; }
     void                            setFlip( bool bFlipH, bool bFlipV ) { mbFlipH = bFlipH; mbFlipV = bFlipV; }
+    void                            applyParentTextFlipV(bool bTextFlipV) { mbInheritedTextFlipV = bTextFlipV; }
     void                            addChild( const ShapePtr& rChildPtr ) { maChildren.push_back( rChildPtr ); }
     std::vector< ShapePtr >&        getChildren() { return maChildren; }
 
@@ -315,6 +316,7 @@ private:
     sal_Int32                       mnRotation;
     bool                            mbFlipH;
     bool                            mbFlipV;
+    bool                            mbInheritedTextFlipV; // Used by group shapes only
     bool                            mbHidden;
     bool                            mbHiddenMasterShape; // master shapes can be hidden in layout slides
                                                          // we need separate flag because we don't want
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index cd564964af35..2090057cb2b1 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -116,6 +116,7 @@ Shape::Shape( const sal_Char* pServiceName, bool bDefaultHeight )
 , mnRotation( 0 )
 , mbFlipH( false )
 , mbFlipV( false )
+, mbInheritedTextFlipV(false)
 , mbHidden( false )
 , mbHiddenMasterShape( false )
 , mbLockedCanvas( false )
@@ -157,6 +158,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
 , mnRotation( pSourceShape->mnRotation )
 , mbFlipH( pSourceShape->mbFlipH )
 , mbFlipV( pSourceShape->mbFlipV )
+, mbInheritedTextFlipV(pSourceShape->mbInheritedTextFlipV)
 , mbHidden( pSourceShape->mbHidden )
 , mbHiddenMasterShape( pSourceShape->mbHiddenMasterShape )
 , mbLockedCanvas( pSourceShape->mbLockedCanvas )
@@ -314,6 +316,7 @@ void Shape::applyShapeReference( const Shape& rReferencedShape, bool bUseText )
     mnRotation = rReferencedShape.mnRotation;
     mbFlipH = rReferencedShape.mbFlipH;
     mbFlipV = rReferencedShape.mbFlipV;
+    mbInheritedTextFlipV = rReferencedShape.mbInheritedTextFlipV;
     mbHidden = rReferencedShape.mbHidden;
 }
 
@@ -393,6 +396,7 @@ void Shape::addChildren(
     std::vector< ShapePtr >::iterator aIter( rMaster.maChildren.begin() );
     while( aIter != rMaster.maChildren.end() ) {
         (*aIter)->setMasterTextListStyle( mpMasterTextListStyle );
+        (*aIter)->applyParentTextFlipV(mbInheritedTextFlipV != mbFlipV);
         (*aIter++)->addShape( rFilterBase, pTheme, rxShapes, aChildTransformation, getFillProperties(), nullptr, pShapeMap );
     }
 }
@@ -1079,6 +1083,8 @@ Reference< XShape > const & Shape::createAndInsert(
             if( getTextBody() )
             {
                 sal_Int32 nTextRotateAngle = static_cast< sal_Int32 >( getTextBody()->getTextProperties().moRotation.get( 0 ) );
+                if(mbInheritedTextFlipV)
+                    nTextRotateAngle -= 180 * 60000;
                 /* OOX measures text rotation clockwise in 1/60000th degrees,
                    relative to the containing shape. setTextRotateAngle wants
                    degrees anticlockwise. */
diff --git a/sd/qa/unit/data/pptx/tdf109223.pptx b/sd/qa/unit/data/pptx/tdf109223.pptx
new file mode 100755
index 000000000000..0f68796e8e14
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf109223.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 4e62c3479cf2..aa2035ccc710 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -142,6 +142,7 @@ public:
     void testTdf104201();
     void testTdf104445();
     void testTdf108925();
+    void testTdf109223();
 
     CPPUNIT_TEST_SUITE(SdImportTest);
 
@@ -202,6 +203,7 @@ public:
     CPPUNIT_TEST(testTdf104201);
     CPPUNIT_TEST(testTdf104445);
     CPPUNIT_TEST(testTdf108925);
+    CPPUNIT_TEST(testTdf109223);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -1789,6 +1791,38 @@ void SdImportTest::testTdf108925()
     xDocShRef->DoClose();
 }
 
+void SdImportTest::testTdf109223()
+{
+    // In the test document flipV attribute is defined for a group shape
+    // This transformation is not applied on child shapes
+    // To make the text direction right at least I added an additional text rotation when parent shape is flipped.
+    sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf109223.pptx"), PPTX);
+    uno::Reference< container::XIndexAccess > xGroupShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
+    uno::Reference< beans::XPropertySet > xShape(xGroupShape->getByIndex(1), uno::UNO_QUERY);
+
+    // Check the shape text to make sure we test the right shape
+    OUString sText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getString();
+    CPPUNIT_ASSERT_EQUAL(OUString("Tested child shape"), sText);
+
+    // Check the attribute inherited from parent shape
+    bool bAttributeFound = false;
+    uno::Sequence<beans::PropertyValue> aProps;
+    CPPUNIT_ASSERT(xShape->getPropertyValue("CustomShapeGeometry") >>= aProps);
+    for (sal_Int32 i = 0; i < aProps.getLength(); ++i)
+    {
+        const beans::PropertyValue& rProp = aProps[i];
+        if (rProp.Name == "TextPreRotateAngle")
+        {
+            CPPUNIT_ASSERT_EQUAL(sal_Int32(180), rProp.Value.get<sal_Int32>());
+            bAttributeFound = true;
+            break;
+        }
+    }
+
+    CPPUNIT_ASSERT_EQUAL(true, bAttributeFound);
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list