oox/source/ppt/timenode.cxx         |   57 ++++++++++++++++++++++++++++++------
 sd/qa/unit/data/pptx/tdf128550.pptx |binary
 sd/qa/unit/export-tests.cxx         |   14 ++++++++
 3 files changed, 63 insertions(+), 8 deletions(-)

New commits:
commit 742b699335ca81626e79c937389efd6b5fdc15ed
Author:     Mark Hung <mark...@gmail.com>
AuthorDate: Sat Jan 16 23:48:56 2021 +0800
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Jan 21 10:35:46 2021 +0100

    tdf#128550 set sub item on the ancestor node.
    
    The target of a animation node may resolved to
    a subitem. However it only has effect on a
    iterate container or animate node, not on any
    other containers. Subitem setting like background
    and paragraph got ignored, so everything were shown
    together.  The patch find the ancestor node
    that is iterate container or animate, and set
    the subitem on it.
    
    Change-Id: Iaaa52aed3a34eb2d70b3b318b8336246e17e1e98
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109444
    Tested-by: Jenkins
    Reviewed-by: Mark Hung <mark...@gmail.com>
    (cherry picked from commit 9b19bf0283b569a5c134de6b5cce1d72d8f37879)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109679
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/oox/source/ppt/timenode.cxx b/oox/source/ppt/timenode.cxx
index 3e08a6716d74..132c54b79f4a 100644
--- a/oox/source/ppt/timenode.cxx
+++ b/oox/source/ppt/timenode.cxx
@@ -51,8 +51,37 @@ using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::animations;
 using namespace ::com::sun::star::presentation;
 
-namespace oox::ppt {
+namespace {
+
+void lcl_setAncestorSubItem( const Reference<XAnimationNode>& xParent, 
sal_Int16 nSubItem )
+{
+
+    Reference<XAnimationNode> xNode = xParent;
+
+    while ( xNode.is() )
+    {
+        if ( xNode->getType() == AnimationNodeType::ANIMATE )
+        {
+            Reference<XAnimate> xAnimate( xNode, UNO_QUERY );
+            if ( xAnimate.is() )
+                xAnimate->setSubItem( nSubItem );
+            break;
+        }
+        else if ( xNode->getType() == AnimationNodeType::ITERATE )
+        {
+            Reference<XIterateContainer> xIterateContainer( xNode, UNO_QUERY );
+            if ( xIterateContainer.is() )
+                xIterateContainer->setSubItem( nSubItem );
+            break;
+        }
+
+        xNode.set( xNode->getParent(), UNO_QUERY );
+    }
+}
+
+}
 
+namespace oox::ppt {
         OUString TimeNode::getServiceName( sal_Int16 nNodeType )
         {
             OUString sServiceName;
@@ -225,11 +254,17 @@ namespace oox::ppt {
 
             if( mpTarget )
             {
-                sal_Int16 nSubType(0);
-                maNodeProperties[ NP_TARGET ] = mpTarget->convert( pSlide, 
nSubType );
+                sal_Int16 nSubItem(0);
+                maNodeProperties[ NP_TARGET ] = mpTarget->convert( pSlide, 
nSubItem );
                 if( mpTarget->mnType == XML_spTgt )
                 {
-                    maNodeProperties[ NP_SUBITEM ] <<= nSubType;
+                    if ( xNode->getType() == AnimationNodeType::ANIMATE ||
+                            xNode->getType() == AnimationNodeType::ITERATE )
+                    {
+                        maNodeProperties[ NP_SUBITEM ] <<= nSubItem;
+                    }
+                    else
+                        lcl_setAncestorSubItem( xParent, nSubItem );
                 }
             }
 
@@ -320,15 +355,21 @@ namespace oox::ppt {
                         }
                         break;
                     case NP_SUBITEM:
-                        if( xAnimate.is() )
+                        if( aValue >>= nInt16 )
                         {
-                            if( aValue >>= nInt16 )
+                            if( xAnimate.is() )
+                            {
                                 xAnimate->setSubItem( nInt16 );
-                            else
+                            }
+                            else if ( xIterateContainer.is() )
                             {
-                                SAL_INFO("oox.ppt","any >>= failed " << 
__LINE__ );
+                                xIterateContainer->setSubItem( nInt16 );
                             }
                         }
+                        else
+                        {
+                            SAL_INFO("oox.ppt","any >>= failed " << __LINE__ );
+                        }
                         break;
                     case NP_ATTRIBUTENAME:
                         if( xAnimate.is() )
diff --git a/sd/qa/unit/data/pptx/tdf128550.pptx 
b/sd/qa/unit/data/pptx/tdf128550.pptx
new file mode 100755
index 000000000000..e2be342b2e51
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf128550.pptx differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index e54e02ddecd5..96022e2fc118 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -78,6 +78,7 @@ public:
     void testSoftEdges();
     void testShadowBlur();
     void testRhbz1870501();
+    void testTdf128550();
 
     CPPUNIT_TEST_SUITE(SdExportTest);
 
@@ -116,6 +117,7 @@ public:
     CPPUNIT_TEST(testSoftEdges);
     CPPUNIT_TEST(testShadowBlur);
     CPPUNIT_TEST(testRhbz1870501);
+    CPPUNIT_TEST(testTdf128550);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -1341,6 +1343,18 @@ void SdExportTest::testRhbz1870501()
     xDocShRef = saveAndReload( xDocShRef.get(), ODG );
 }
 
+void SdExportTest::testTdf128550()
+{
+    utl::TempFile tempFile;
+    sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf128550.pptx"), 
PPTX);
+    xDocShRef = saveAndReload(xDocShRef.get(), ODP, &tempFile);
+    xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "content.xml");
+    assertXPath( pXmlDoc, "//anim:iterate[@anim:sub-item='background']", 1);
+    assertXPath( pXmlDoc, "//anim:iterate[@anim:sub-item='text']", 4);
+    xDocShRef->DoClose();
+
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to