[Libreoffice-commits] core.git: sd/qa sd/source

Szymon Kłos szymon.klos at collabora.com
Wed Feb 7 09:29:03 UTC 2018


 sd/qa/unit/export-tests-ooxml2.cxx       |   36 +++++++
 sd/source/filter/eppt/pptx-epptooxml.cxx |  150 ++++++++++++++++++++++---------
 2 files changed, 145 insertions(+), 41 deletions(-)

New commits:
commit fa85592c0efba65f4a1b09fea950ec1c311bdd4c
Author: Szymon Kłos <szymon.klos at collabora.com>
Date:   Mon Feb 5 12:41:58 2018 +0100

    tdf#115394 export custom transition time in PPTX
    
    Change-Id: Ib8f4cef713895029dc18f68a07baa4b65e4260c0
    Reviewed-on: https://gerrit.libreoffice.org/49245
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index b530790b038a..6b2f34f49a05 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -128,6 +128,7 @@ public:
     void testTdf90626();
     void testTdf107608();
     void testTdf111786();
+    void testTdf115394();
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
@@ -181,6 +182,7 @@ public:
     CPPUNIT_TEST(testTdf90626);
     CPPUNIT_TEST(testTdf107608);
     CPPUNIT_TEST(testTdf111786);
+    CPPUNIT_TEST(testTdf115394);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -1402,6 +1404,40 @@ void SdOOXMLExportTest2::testTdf111786()
     xDocShRef->DoClose();
 }
 
+void SdOOXMLExportTest2::testTdf115394()
+{
+    sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf115394.pptx"), PPTX);
+    utl::TempFile tempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+    double fTransitionDuration;
+
+    // Slow in MS formats
+    SdPage* pPage1 = xDocShRef->GetDoc()->GetSdPage(0, PageKind::Standard);
+    fTransitionDuration = pPage1->getTransitionDuration();
+    CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration);
+
+    // Medium in MS formats
+    SdPage* pPage2 = xDocShRef->GetDoc()->GetSdPage(1, PageKind::Standard);
+    fTransitionDuration = pPage2->getTransitionDuration();
+    CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration);
+
+    // Fast in MS formats
+    SdPage* pPage3 = xDocShRef->GetDoc()->GetSdPage(2, PageKind::Standard);
+    fTransitionDuration = pPage3->getTransitionDuration();
+    CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration);
+
+    // Custom values
+    SdPage* pPage4 = xDocShRef->GetDoc()->GetSdPage(3, PageKind::Standard);
+    fTransitionDuration = pPage4->getTransitionDuration();
+    CPPUNIT_ASSERT_EQUAL(0.25, fTransitionDuration);
+
+    SdPage* pPage5 = xDocShRef->GetDoc()->GetSdPage(4, PageKind::Standard);
+    fTransitionDuration = pPage5->getTransitionDuration();
+    CPPUNIT_ASSERT_EQUAL(4.25, fTransitionDuration);
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index 6b0c8fc5d0d5..bcf9b0e145ea 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -650,7 +650,42 @@ void PowerPointExport::WriteTransition(const FSHelperPtr& pFS)
     sal_Int32 advanceTiming = -1;
     sal_Int32 changeType = 0;
 
-    if (GETA(Speed))
+    sal_Int32 nTransitionDuration = -1;
+    bool isTransitionDurationSet = false;
+
+    // try to use TransitionDuration instead of old Speed property
+    if (GETA(TransitionDuration))
+    {
+        double fTransitionDuration = -1.0;
+        mAny >>= fTransitionDuration;
+        if (fTransitionDuration >= 0)
+        {
+            nTransitionDuration = fTransitionDuration * 1000.0;
+
+            // override values because in MS formats meaning of fast/medium/slow is different
+            if (nTransitionDuration <= 500)
+            {
+                // fast is default
+                speed = nullptr;
+            }
+            else if (nTransitionDuration >= 1000)
+            {
+                speed = "slow";
+            }
+            else
+            {
+                speed = "med";
+            }
+
+            bool isStandardValue = nTransitionDuration == 500
+                || nTransitionDuration == 750
+                || nTransitionDuration == 1000;
+
+            if(!isStandardValue)
+                isTransitionDurationSet = true;
+        }
+    }
+    else if (GETA(Speed))
     {
         mAny >>= animationSpeed;
 
@@ -670,50 +705,12 @@ void PowerPointExport::WriteTransition(const FSHelperPtr& pFS)
 
     if (GETA(Change))
         mAny >>= changeType;
+    bool isAdvanceTimingSet = advanceTiming != -1;
 
     // 1 means automatic, 2 half automatic - not sure what it means - at least I don't see it in UI
     if (changeType == 1 && GETA(Duration))
         mAny >>= advanceTiming;
 
-    if (nTransition14 || pPresetTransition)
-    {
-        const char* pRequiresNS = nTransition14 ? "p14" : "p15";
-
-        pFS->startElement(FSNS(XML_mc, XML_AlternateContent), FSEND);
-        pFS->startElement(FSNS(XML_mc, XML_Choice), XML_Requires, pRequiresNS, FSEND);
-
-
-        pFS->startElementNS(XML_p, XML_transition,
-                            XML_spd, speed,
-                            XML_advTm, advanceTiming != -1 ? I32S(advanceTiming*1000) : nullptr,
-                            FSEND);
-
-        if (nTransition14)
-        {
-            pFS->singleElementNS(XML_p14, nTransition14,
-                                 XML_isInverted, pInverted,
-                                 XML_dir, pDirection14,
-                                 XML_pattern, pPattern,
-                                 FSEND);
-        }
-        else if (pPresetTransition)
-        {
-            pFS->singleElementNS(XML_p15, XML_prstTrans,
-                                 XML_prst, pPresetTransition,
-                                 FSEND);
-        }
-
-        pFS->endElement(FSNS(XML_p, XML_transition));
-
-        pFS->endElement(FSNS(XML_mc, XML_Choice));
-        pFS->startElement(FSNS(XML_mc, XML_Fallback), FSEND);
-    }
-
-    pFS->startElementNS(XML_p, XML_transition,
-                        XML_spd, speed,
-                        XML_advTm, advanceTiming != -1 ? I32S(advanceTiming*1000) : nullptr,
-                        FSEND);
-
     if (!bOOXmlSpecificTransition)
     {
         switch (nPPTTransitionType)
@@ -807,6 +804,77 @@ void PowerPointExport::WriteTransition(const FSHelperPtr& pFS)
         }
     }
 
+    if (nTransition14 || pPresetTransition || isTransitionDurationSet)
+    {
+        const char* pRequiresNS = (nTransition14 || isTransitionDurationSet) ? "p14" : "p15";
+
+        pFS->startElement(FSNS(XML_mc, XML_AlternateContent), FSEND);
+        pFS->startElement(FSNS(XML_mc, XML_Choice), XML_Requires, pRequiresNS, FSEND);
+
+        if(isTransitionDurationSet && isAdvanceTimingSet)
+        {
+            pFS->startElementNS(XML_p, XML_transition,
+                XML_spd, speed,
+                XML_advTm, I32S(advanceTiming * 1000),
+                FSNS(XML_p14, XML_dur), I32S(nTransitionDuration),
+                FSEND);
+        }
+        else if(isTransitionDurationSet)
+        {
+            pFS->startElementNS(XML_p, XML_transition,
+                XML_spd, speed,
+                FSNS(XML_p14, XML_dur), I32S(nTransitionDuration),
+                FSEND);
+        }
+        else if(isAdvanceTimingSet)
+        {
+            pFS->startElementNS(XML_p, XML_transition,
+                XML_spd, speed,
+                XML_advTm, I32S(advanceTiming * 1000),
+                FSEND);
+        }
+        else
+        {
+            pFS->startElementNS(XML_p, XML_transition,
+                XML_spd, speed,
+                FSEND);
+        }
+
+        if (nTransition14)
+        {
+            pFS->singleElementNS(XML_p14, nTransition14,
+                XML_isInverted, pInverted,
+                XML_dir, pDirection14,
+                XML_pattern, pPattern,
+                FSEND);
+        }
+        else if (pPresetTransition)
+        {
+            pFS->singleElementNS(XML_p15, XML_prstTrans,
+                XML_prst, pPresetTransition,
+                FSEND);
+        }
+        else if (isTransitionDurationSet && nTransition)
+        {
+            pFS->singleElementNS(XML_p, nTransition,
+                XML_dir, pDirection,
+                XML_orient, pOrientation,
+                XML_spokes, pSpokes,
+                XML_thruBlk, pThruBlk,
+                FSEND);
+        }
+
+        pFS->endElement(FSNS(XML_p, XML_transition));
+
+        pFS->endElement(FSNS(XML_mc, XML_Choice));
+        pFS->startElement(FSNS(XML_mc, XML_Fallback), FSEND);
+    }
+
+    pFS->startElementNS(XML_p, XML_transition,
+        XML_spd, speed,
+        XML_advTm, isAdvanceTimingSet ? I32S(advanceTiming * 1000) : nullptr,
+        FSEND);
+
     if (nTransition)
     {
         pFS->singleElementNS(XML_p, nTransition,
@@ -819,7 +887,7 @@ void PowerPointExport::WriteTransition(const FSHelperPtr& pFS)
 
     pFS->endElementNS(XML_p, XML_transition);
 
-    if (nTransition14 || pPresetTransition)
+    if (nTransition14 || pPresetTransition || isTransitionDurationSet)
     {
         pFS->endElement(FSNS(XML_mc, XML_Fallback));
         pFS->endElement(FSNS(XML_mc, XML_AlternateContent));


More information about the Libreoffice-commits mailing list