summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2018-02-05 12:41:58 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2018-02-07 10:28:38 +0100
commitfa85592c0efba65f4a1b09fea950ec1c311bdd4c (patch)
tree814acffd76bd8b16e3d692644611929b74c2db29
parenta8a3e6a7fee5ac23bc2155b9391ead9402211147 (diff)
tdf#115394 export custom transition time in PPTX
Change-Id: Ib8f4cef713895029dc18f68a07baa4b65e4260c0 Reviewed-on: https://gerrit.libreoffice.org/49245 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r--sd/qa/unit/export-tests-ooxml2.cxx36
-rw-r--r--sd/source/filter/eppt/pptx-epptooxml.cxx150
2 files changed, 145 insertions, 41 deletions
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));