Kaydet (Commit) 4e207c2e authored tarafından Aron Budea's avatar Aron Budea

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/53284Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarAron Budea <aron.budea@collabora.com>
üst ea955e2f
......@@ -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);
......
......@@ -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 );
......
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