summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-07-24 00:02:23 +0200
committerJan Holesovsky <kendy@collabora.com>2016-07-29 20:01:27 +0200
commit44af1aa2c022278d6586c03ce8f37604f0e4f15d (patch)
tree55c4dbc7d7d6e06513cbb3b2ea715391e9508058
parent18deb1f3f04f078dc888a57a261f38be86698525 (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. (cherry picked from commit 5206929f3a125a739adb860709586a0f50cb9611) Reviewed-on: https://gerrit.libreoffice.org/27509 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> (cherry picked from commit 4ca12100ef036c6005d799e26801970118f591f4) Change-Id: I9881cb9bf2ae6ccc5fcf06602343f2d0e0704699 Reviewed-on: https://gerrit.libreoffice.org/27538 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit e36acbf3aae7c92c2724b9f3c801735f2321cf05)
-rw-r--r--sd/inc/EffectMigration.hxx2
-rw-r--r--sd/qa/unit/data/sxi/ooo41061-1.sxibin0 -> 42492 bytes
-rw-r--r--sd/qa/unit/export-tests.cxx26
-rw-r--r--sd/qa/unit/sdmodeltestbase.hxx3
-rw-r--r--sd/source/core/EffectMigration.cxx25
-rw-r--r--sd/source/ui/docshell/docshel4.cxx3
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
new file mode 100644
index 000000000000..4c2482a58650
--- /dev/null
+++ b/sd/qa/unit/data/sxi/ooo41061-1.sxi
Binary files differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 5c2e7356f7ec..10657604e251 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -119,6 +119,7 @@ public:
void testFdo83751();
void testFdo79731();
void testSwappedOutImageExport();
+ void testOOoXMLAnimations();
void testTdf80020();
void testLinkedGraphicRT();
void testImageWithSpecialID();
@@ -163,6 +164,7 @@ public:
CPPUNIT_TEST(testFdo83751);
CPPUNIT_TEST(testFdo79731);
CPPUNIT_TEST(testSwappedOutImageExport);
+ CPPUNIT_TEST(testOOoXMLAnimations);
CPPUNIT_TEST(testTdf80020);
CPPUNIT_TEST(testLinkedGraphicRT);
CPPUNIT_TEST(testImageWithSpecialID);
@@ -197,10 +199,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" },
@@ -713,6 +717,28 @@ void SdExportTest::testSwappedOutImageExport()
}
}
+void SdExportTest::testOOoXMLAnimations()
+{
+ ::sd::DrawDocShellRef xDocShRef = loadURL(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(getURLFromSrc("/sd/qa/unit/data/odp/tdf80020.odp"), ODP);
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index 136ebc0933f4..804d56ae225b 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -50,6 +50,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.
@@ -68,6 +69,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 }
};
@@ -78,6 +80,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 5ea82c0edf84..64d25b85e231 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"
@@ -293,6 +294,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