summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorAron Budea <aron.budea@collabora.com>2018-04-22 16:10:28 +0200
committerAron Budea <aron.budea@collabora.com>2018-05-17 12:40:36 +0200
commit4e207c2e17d75a3cb7b6b72690375279be40d64a (patch)
treebc95d36a7809ff0a969fd4126f832073acc96a5c /sd
parentea955e2f2bfcf05c276b7f7598c7136c732a8542 (diff)
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) Change-Id: I67a3b83f1f1832fade5df7908c58032bcb9b73ce Reviewed-on: https://gerrit.libreoffice.org/53284 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Aron Budea <aron.budea@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/qa/unit/data/ppt/tdf116899.pptbin0 -> 113152 bytes
-rw-r--r--sd/qa/unit/import-tests.cxx25
-rw-r--r--sd/source/filter/ppt/pptinanimations.cxx15
3 files changed, 37 insertions, 3 deletions
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
--- /dev/null
+++ b/sd/qa/unit/data/ppt/tdf116899.ppt
Binary files differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index c92ef5f7782c..28474a88d4bb 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -180,6 +180,7 @@ public:
void testTdf115394PPT();
void testTdf51340();
void testTdf115639();
+ void testTdf116899();
void testTdf77747();
void testTdf116266();
@@ -263,6 +264,7 @@ public:
CPPUNIT_TEST(testTdf115394PPT);
CPPUNIT_TEST(testTdf51340);
CPPUNIT_TEST(testTdf115639);
+ CPPUNIT_TEST(testTdf116899);
CPPUNIT_TEST(testTdf77747);
CPPUNIT_TEST(testTdf116266);
@@ -2519,6 +2521,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::testTdf77747()
{
sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/tdf77747.ppt"), PPT);
diff --git a/sd/source/filter/ppt/pptinanimations.cxx b/sd/source/filter/ppt/pptinanimations.cxx
index 1a8ab6ea6ebf..d1e00b043f7a 100644
--- a/sd/source/filter/ppt/pptinanimations.cxx
+++ b/sd/source/filter/ppt/pptinanimations.cxx
@@ -2384,15 +2384,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 = static_cast<double>(nTemp) / 1000.0;
aKeyTimes[nKeyTime] = fTemp;
+ if( fTemp == -1 )
+ bToNormalize = true;
const Atom* pValue = Atom::findNextChildAtom(pIter);
if( pValue && pValue->getType() == DFF_msofbtAnimAttributeValue )
@@ -2489,7 +2491,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 );