diff options
author | Michael Stahl <mstahl@redhat.com> | 2016-07-24 00:02:23 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2016-07-25 12:12:53 +0200 |
commit | 5206929f3a125a739adb860709586a0f50cb9611 (patch) | |
tree | 25815723d63f1ad47b4b1b7f667a9d82a0652f64 /sd | |
parent | e32a795eee3d6b2c4c4be112674d37b39d3e315f (diff) |
sd: OOoXML import: fix loss of animations
There are 2 different animation formats, legacy one used in OOoXML
format, based on presentation:animations element, and SMIL based one
used in ODF format, based on a node hierarchy with
<anim:par presentation:node-type="timing-root"> at the top.
The problem is that when the legacy animations are imported, they are
not immediately set on the draw-page in the same way as the new
animations are imported.
"soffice --convert-to odp ooo28334-1.sxi" loses all of the animations,
whereas loading the file in the UI and storing it all animations are
converted, and if you use API load/store methods some are converted and
some not depending on timing.
The problem is that there is a necessary conversion step
MainSequence::implRebuild() that needs to happen after all the
EffectMigration calls for a particular SdPage are finished, which
is only triggered by a timer MainSequence::onTimerHdl().
Fix it by forcing a call to implRebuild() from DrawDocShell::Load().
Note: SdDrawDocument::NewOrLoadCompleted() is a horribly misleading
function name as it is actually called *before* loading the document.
Change-Id: I9881cb9bf2ae6ccc5fcf06602343f2d0e0704699
Diffstat (limited to 'sd')
-rw-r--r-- | sd/inc/EffectMigration.hxx | 2 | ||||
-rw-r--r-- | sd/qa/unit/data/sxi/ooo41061-1.sxi | bin | 0 -> 42492 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests.cxx | 26 | ||||
-rw-r--r-- | sd/qa/unit/sdmodeltestbase.hxx | 3 | ||||
-rw-r--r-- | sd/source/core/EffectMigration.cxx | 25 | ||||
-rw-r--r-- | sd/source/ui/docshell/docshel4.cxx | 3 |
6 files changed, 59 insertions, 0 deletions
diff --git a/sd/inc/EffectMigration.hxx b/sd/inc/EffectMigration.hxx index 033e4ed9a233..f1702b1d7f8f 100644 --- a/sd/inc/EffectMigration.hxx +++ b/sd/inc/EffectMigration.hxx @@ -24,6 +24,7 @@ #include <com/sun/star/presentation/AnimationSpeed.hpp> #include <com/sun/star/presentation/FadeEffect.hpp> +class SdDrawDocument; class SdPage; class SvxShape; class SdAnimationInfo; @@ -68,6 +69,7 @@ public: static void SetAnimationPath( SvxShape* pShape, SdrPathObj* pPathObj ); static void CreateAnimatedGroup(SdrObjGroup& rGroupObj, SdPage& rPage); + static void DocumentLoaded(SdDrawDocument & rDoc); }; } // end of namespace sd diff --git a/sd/qa/unit/data/sxi/ooo41061-1.sxi b/sd/qa/unit/data/sxi/ooo41061-1.sxi Binary files differnew file mode 100644 index 000000000000..4c2482a58650 --- /dev/null +++ b/sd/qa/unit/data/sxi/ooo41061-1.sxi diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 7d1cb39c8306..d24daa7f14f5 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -89,6 +89,7 @@ public: void testMediaEmbedding(); void testFdo84043(); void testSwappedOutImageExport(); + void testOOoXMLAnimations(); void testTdf80020(); void testLinkedGraphicRT(); void testImageWithSpecialID(); @@ -102,6 +103,7 @@ public: CPPUNIT_TEST(testMediaEmbedding); CPPUNIT_TEST(testFdo84043); CPPUNIT_TEST(testSwappedOutImageExport); + CPPUNIT_TEST(testOOoXMLAnimations); CPPUNIT_TEST(testTdf80020); CPPUNIT_TEST(testLinkedGraphicRT); CPPUNIT_TEST(testImageWithSpecialID); @@ -116,10 +118,12 @@ public: struct { char const * pPrefix; char const * pURI; } namespaces[] = { // ODF + { "anim", "urn:oasis:names:tc:opendocument:xmlns:animation:1.0" }, { "draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" }, { "fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" }, { "number", "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" }, { "office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" }, + { "presentation", "urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" }, { "style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0" }, { "svg", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" }, { "table", "urn:oasis:names:tc:opendocument:xmlns:table:1.0" }, @@ -340,6 +344,28 @@ void SdExportTest::testSwappedOutImageExport() } } +void SdExportTest::testOOoXMLAnimations() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/sxi/ooo41061-1.sxi"), SXI); + + uno::Reference<lang::XComponent> xComponent(xDocShRef->GetModel(), uno::UNO_QUERY); + uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY); + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OStringToOUString(OString(getFormat(ODP)->pFilterName), RTL_TEXTENCODING_UTF8); + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); + + xDocShRef->DoClose(); + + // the problem was that legacy OOoXML animations were lost if store + // immediately follows load because they were "converted" async by a timer + xmlDocPtr pXmlDoc = parseExport(aTempFile, "content.xml"); + assertXPath(pXmlDoc, "//anim:par[@presentation:node-type='timing-root']", 26); + // currently getting 52 of these without the fix (depends on timing) + assertXPath(pXmlDoc, "//anim:par", 223); +} + void SdExportTest::testTdf80020() { ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/tdf80020.odp"), ODP); diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx index 9df78373be6f..c4dcc80feb9b 100644 --- a/sd/qa/unit/sdmodeltestbase.hxx +++ b/sd/qa/unit/sdmodeltestbase.hxx @@ -52,6 +52,7 @@ struct FileFormat #define PDF_FORMAT_TYPE ( SfxFilterFlags::STARONEFILTER | SfxFilterFlags::ALIEN | SfxFilterFlags::IMPORT | SfxFilterFlags::PREFERED ) #define FODG_FORMAT_TYPE (SfxFilterFlags::STARONEFILTER | SfxFilterFlags::OWN | SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT) #define FODP_FORMAT_TYPE (SfxFilterFlags::STARONEFILTER | SfxFilterFlags::OWN | SfxFilterFlags::IMPORT | SfxFilterFlags::EXPORT) +#define SXI_FORMAT_TYPE (SfxFilterFlags::IMPORT | SfxFilterFlags::TEMPLATE | SfxFilterFlags::OWN | SfxFilterFlags::ALIEN | SfxFilterFlags::PREFERED | SfxFilterFlags::ENCRYPTION) /** List of file formats we support in Impress unit tests. @@ -70,6 +71,7 @@ FileFormat aFileFormats[] = { "pdf", "draw_pdf_import", "pdf_Portable_Document_Format", "", PDF_FORMAT_TYPE }, { "fodg", "OpenDocument Drawing Flat XML", "Flat XML ODF Drawing", "", FODG_FORMAT_TYPE }, { "fodp", "OpenDocument Presentation Flat XML", "Flat XML ODF Presentation", "", FODP_FORMAT_TYPE }, + { "sxi", "StarOffice XML (Impress)", "OpenOffice.org 1.0 Presentation", "", SXI_FORMAT_TYPE }, { nullptr, nullptr, nullptr, nullptr, SfxFilterFlags::NONE } }; @@ -80,6 +82,7 @@ FileFormat aFileFormats[] = #define PDF 4 #define FODG 5 #define FODP 6 +#define SXI 7 /// Base class for filter tests loading or roundtriping a document, and asserting the document model. class SdModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest diff --git a/sd/source/core/EffectMigration.cxx b/sd/source/core/EffectMigration.cxx index 83ca865b6f80..ab2a4615bdb1 100644 --- a/sd/source/core/EffectMigration.cxx +++ b/sd/source/core/EffectMigration.cxx @@ -1427,4 +1427,29 @@ void EffectMigration::CreateAnimatedGroup(SdrObjGroup& rGroupObj, SdPage& rPage) } } +void EffectMigration::DocumentLoaded(SdDrawDocument & rDoc) +{ + if (DOCUMENT_TYPE_DRAW == rDoc.GetDocumentType()) + return; // no animations in Draw + for (sal_uInt16 n = 0; n < rDoc.GetSdPageCount(PK_STANDARD); ++n) + { + SdPage *const pPage = rDoc.GetSdPage(n, PK_STANDARD); + if (pPage->hasAnimationNode()) + { + // this will force the equivalent of the MainSequence::onTimerHdl + // so that the animations are present in export-able representation + // *before* the import is finished + pPage->getMainSequence()->getRootNode(); + } + } + for (sal_uInt16 n = 0; n < rDoc.GetMasterSdPageCount(PK_STANDARD); ++n) + { + SdPage *const pPage = rDoc.GetMasterSdPage(n, PK_STANDARD); + if (pPage->hasAnimationNode()) + { + pPage->getMainSequence()->getRootNode(); + } + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx index 5fa120462fa4..0b9e6a2ec379 100644 --- a/sd/source/ui/docshell/docshel4.cxx +++ b/sd/source/ui/docshell/docshel4.cxx @@ -62,6 +62,7 @@ #include "ViewShell.hxx" #include "sdmod.hxx" #include "View.hxx" +#include "EffectMigration.hxx" #include "CustomAnimationEffect.hxx" #include "sdpage.hxx" #include "sdresid.hxx" @@ -300,6 +301,8 @@ bool DrawDocShell::Load( SfxMedium& rMedium ) if( bRet ) { + // for legacy markup in OOoXML filter, convert the animations now + EffectMigration::DocumentLoaded(*GetDoc()); UpdateTablePointers(); // If we're an embedded OLE object, use tight bounds |