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

Aron Budea aron.budea at collabora.com
Wed May 23 09:12:44 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 c703c934d3f9d6ad7cba620c76520d80cc0e2be7
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)
    
    Change-Id: I67a3b83f1f1832fade5df7908c58032bcb9b73ce
    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>

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 0dca601168b1..574447f60a79 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -173,6 +173,7 @@ public:
     void testTdf115394();
     void testTdf115394PPT();
     void testTdf115639();
+    void testTdf116899();
     void testTdf116266();
 
     bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
@@ -252,6 +253,7 @@ public:
     CPPUNIT_TEST(testTdf115394);
     CPPUNIT_TEST(testTdf115394PPT);
     CPPUNIT_TEST(testTdf115639);
+    CPPUNIT_TEST(testTdf116899);
     CPPUNIT_TEST(testTdf116266);
 
     CPPUNIT_TEST_SUITE_END();
@@ -2470,6 +2472,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] );
+}
+
 void SdImportTest::testTdf116266()
 {
     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/tdf116266.odp"), ODP);
diff --git a/sd/source/filter/ppt/pptinanimations.cxx b/sd/source/filter/ppt/pptinanimations.cxx
index 361d723b5f98..6414800b6599 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