[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3-desktop' - sd/qa sd/source

Aron Budea aron.budea at collabora.com
Wed May 23 11:55:24 UTC 2018


 sd/qa/unit/data/ppt/tdf116899.ppt        |binary
 sd/qa/unit/import-tests.cxx              |   25 +++++++++++++++++++++++++
 sd/source/filter/ppt/pptinanimations.cxx |   15 ++++++++++++---
 3 files changed, 37 insertions(+), 3 deletions(-)

New commits:
commit f0370fbab11afe5a601e49061b2e3be5fac50745
Author: Aron Budea <aron.budea at collabora.com>
Date:   Sun Apr 22 16:10:28 2018 +0200

    tdf#116899: normalize key times during PPT import if needed
    
    If TimeAnimationValueListEntry contains time with -1000,
    key times have to be distributed evenly between 0 and 1.
    ([MS-PPT] 2.8.31)
    
    Reviewed-on: https://gerrit.libreoffice.org/53284
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    (cherry picked from commit 4e207c2e17d75a3cb7b6b72690375279be40d64a)
    
    Reviewed-on: https://gerrit.libreoffice.org/54663
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>
    (cherry picked from commit c703c934d3f9d6ad7cba620c76520d80cc0e2be7)
    
    Change-Id: I67a3b83f1f1832fade5df7908c58032bcb9b73ce
    Reviewed-on: https://gerrit.libreoffice.org/54700
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>
    (cherry picked from commit 37af3939b768be09b6c5671fc8ae89f4e5fc38b6)

diff --git a/sd/qa/unit/data/ppt/tdf116899.ppt b/sd/qa/unit/data/ppt/tdf116899.ppt
new file mode 100644
index 000000000000..edad3356d36f
Binary files /dev/null and b/sd/qa/unit/data/ppt/tdf116899.ppt differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index c66134291e05..2e24756b80c4 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -158,6 +158,7 @@ public:
     void testTdf114821();
     void testTdf51340();
     void testTdf115639();
+    void testTdf116899();
 
     bool checkPattern(sd::DrawDocShellRef& rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
     void testPatternImport();
@@ -232,6 +233,7 @@ public:
     CPPUNIT_TEST(testTdf114821);
     CPPUNIT_TEST(testTdf51340);
     CPPUNIT_TEST(testTdf115639);
+    CPPUNIT_TEST(testTdf116899);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -2442,6 +2444,29 @@ void SdImportTest::testTdf115639()
     }
 }
 
+void SdImportTest::testTdf116899()
+{
+    // This is a PPT created in Impress and roundtripped in PP, the key times become [1, -1] in PP,
+    //  a time of -1 (-1000) in PPT means key times have to be distributed evenly between 0 and 1
+    sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/tdf116899.ppt"), PPT);
+
+    uno::Reference< drawing::XDrawPagesSupplier > xDoc(
+        xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
+    uno::Reference< drawing::XDrawPage > xPage(
+        xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
+    uno::Reference< animations::XAnimationNodeSupplier > xAnimNodeSupplier(
+        xPage, uno::UNO_QUERY_THROW );
+    uno::Reference< animations::XAnimationNode > xRootNode(
+        xAnimNodeSupplier->getAnimationNode() );
+    std::vector< uno::Reference< animations::XAnimationNode > > aAnimVector;
+    anim::create_deep_vector(xRootNode, aAnimVector);
+    uno::Reference< animations::XAnimate > xNode(
+        aAnimVector[8], uno::UNO_QUERY_THROW );
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of key times in the animation node isn't 2.", xNode->getKeyTimes().getLength(), static_cast<sal_Int32>(2) );
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "First key time in the animation node isn't 0, key times aren't normalized.", 0., xNode->getKeyTimes()[0] );
+    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second key time in the animation node isn't 1, key times aren't normalized.", 1., xNode->getKeyTimes()[1] );
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/filter/ppt/pptinanimations.cxx b/sd/source/filter/ppt/pptinanimations.cxx
index 2c3574f93d52..c0788f5f9b71 100644
--- a/sd/source/filter/ppt/pptinanimations.cxx
+++ b/sd/source/filter/ppt/pptinanimations.cxx
@@ -2391,15 +2391,17 @@ void AnimationImporter::importAnimateKeyPoints( const Atom* pAtom, const Referen
         OUString aFormula;
 
         pIter = pAtom->findFirstChildAtom(DFF_msofbtAnimKeyTime);
-        int nKeyTime;
         sal_Int32 nTemp;
-        for( nKeyTime = 0; (nKeyTime < nKeyTimes) && pIter; nKeyTime++ )
+        bool bToNormalize = false;
+        for( int nKeyTime = 0; (nKeyTime < nKeyTimes) && pIter; nKeyTime++ )
         {
             if( pIter->seekToContent() )
             {
                 mrStCtrl.ReadInt32( nTemp );
                 double fTemp = (double)nTemp / 1000.0;
                 aKeyTimes[nKeyTime] = fTemp;
+                if( fTemp == -1 )
+                    bToNormalize = true;
 
                 const Atom* pValue = Atom::findNextChildAtom(pIter);
                 if( pValue && pValue->getType() == DFF_msofbtAnimAttributeValue )
@@ -2496,7 +2498,14 @@ void AnimationImporter::importAnimateKeyPoints( const Atom* pAtom, const Referen
         }
         dump( "\"" );
 #endif
-
+        if( bToNormalize && nKeyTimes >= 2 )
+        {
+            // if TimeAnimationValueList contains time -1000, key points must be evenly distributed between 0 and 1 ([MS-PPT] 2.8.31)
+            for( int nKeyTime = 0; nKeyTime < nKeyTimes; ++nKeyTime )
+            {
+                aKeyTimes[nKeyTime] = static_cast<double>(nKeyTime) / static_cast<double>(nKeyTimes - 1);
+            }
+        }
         xAnim->setKeyTimes( aKeyTimes );
         xAnim->setValues( aValues );
         xAnim->setFormula( aFormula );


More information about the Libreoffice-commits mailing list