Kaydet (Commit) fa85592c authored tarafından Szymon Kłos's avatar Szymon Kłos

tdf#115394 export custom transition time in PPTX

Change-Id: Ib8f4cef713895029dc18f68a07baa4b65e4260c0
Reviewed-on: https://gerrit.libreoffice.org/49245Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarSzymon Kłos <szymon.klos@collabora.com>
üst a8a3e6a7
...@@ -128,6 +128,7 @@ public: ...@@ -128,6 +128,7 @@ public:
void testTdf90626(); void testTdf90626();
void testTdf107608(); void testTdf107608();
void testTdf111786(); void testTdf111786();
void testTdf115394();
CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
...@@ -181,6 +182,7 @@ public: ...@@ -181,6 +182,7 @@ public:
CPPUNIT_TEST(testTdf90626); CPPUNIT_TEST(testTdf90626);
CPPUNIT_TEST(testTdf107608); CPPUNIT_TEST(testTdf107608);
CPPUNIT_TEST(testTdf111786); CPPUNIT_TEST(testTdf111786);
CPPUNIT_TEST(testTdf115394);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -1402,6 +1404,40 @@ void SdOOXMLExportTest2::testTdf111786() ...@@ -1402,6 +1404,40 @@ void SdOOXMLExportTest2::testTdf111786()
xDocShRef->DoClose(); 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_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -650,7 +650,42 @@ void PowerPointExport::WriteTransition(const FSHelperPtr& pFS) ...@@ -650,7 +650,42 @@ void PowerPointExport::WriteTransition(const FSHelperPtr& pFS)
sal_Int32 advanceTiming = -1; sal_Int32 advanceTiming = -1;
sal_Int32 changeType = 0; 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; mAny >>= animationSpeed;
...@@ -670,50 +705,12 @@ void PowerPointExport::WriteTransition(const FSHelperPtr& pFS) ...@@ -670,50 +705,12 @@ void PowerPointExport::WriteTransition(const FSHelperPtr& pFS)
if (GETA(Change)) if (GETA(Change))
mAny >>= changeType; 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 // 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)) if (changeType == 1 && GETA(Duration))
mAny >>= advanceTiming; 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) if (!bOOXmlSpecificTransition)
{ {
switch (nPPTTransitionType) switch (nPPTTransitionType)
...@@ -807,6 +804,77 @@ void PowerPointExport::WriteTransition(const FSHelperPtr& pFS) ...@@ -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) if (nTransition)
{ {
pFS->singleElementNS(XML_p, nTransition, pFS->singleElementNS(XML_p, nTransition,
...@@ -819,7 +887,7 @@ void PowerPointExport::WriteTransition(const FSHelperPtr& pFS) ...@@ -819,7 +887,7 @@ void PowerPointExport::WriteTransition(const FSHelperPtr& pFS)
pFS->endElementNS(XML_p, XML_transition); 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_Fallback));
pFS->endElement(FSNS(XML_mc, XML_AlternateContent)); pFS->endElement(FSNS(XML_mc, XML_AlternateContent));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment