summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2018-02-05 12:41:58 +0100
committerAndras Timar <andras.timar@collabora.com>2018-02-12 20:26:05 +0100
commit67ad5a0d25f12ddb5cc95f7226601f54a1074696 (patch)
tree920dafb9e649fe834c23f0764de17a917dc4e4f3 /sd
parentd7763fb35f7556acffa5543f7b2a8eda47862fd1 (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> Reviewed-on: https://gerrit.libreoffice.org/49522 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/export-tests-ooxml2.cxx36
-rw-r--r--sd/source/filter/eppt/pptx-epptooxml.cxx151
2 files changed, 146 insertions, 41 deletions
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 3d1ad4f28b78..59d1d0e7f424 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -125,6 +125,7 @@ public:
void testGroupsRotatedPosition();
void testAccentColor();
void testTdf114848();
+ void testTdf115394();
CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
@@ -171,6 +172,7 @@ public:
CPPUNIT_TEST(testGroupsRotatedPosition);
CPPUNIT_TEST(testAccentColor);
CPPUNIT_TEST(testTdf114848);
+ CPPUNIT_TEST(testTdf115394);
CPPUNIT_TEST_SUITE_END();
@@ -1130,6 +1132,40 @@ void SdOOXMLExportTest2::testGroupRotation()
assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[2]/p:spPr/a:xfrm", "rot", "20400000");
}
+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 f61d7017382e..07c290895970 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -643,7 +643,43 @@ 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;
switch( animationSpeed ) {
@@ -666,45 +702,6 @@ void PowerPointExport::WriteTransition( const FSHelperPtr& pFS )
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)
@@ -797,6 +794,78 @@ void PowerPointExport::WriteTransition( const FSHelperPtr& pFS )
}
}
+ bool isAdvanceTimingSet = advanceTiming != -1;
+ 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,
@@ -809,7 +878,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));