[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sd/inc sd/qa sd/source
Michael Stahl
mstahl at redhat.com
Thu Jul 28 14:34:52 UTC 2016
sd/inc/EffectMigration.hxx | 2 ++
sd/qa/unit/data/sxi/ooo41061-1.sxi |binary
sd/qa/unit/export-tests.cxx | 26 ++++++++++++++++++++++++++
sd/qa/unit/sdmodeltestbase.hxx | 3 +++
sd/source/core/EffectMigration.cxx | 25 +++++++++++++++++++++++++
sd/source/ui/docshell/docshel4.cxx | 3 +++
6 files changed, 59 insertions(+)
New commits:
commit e36acbf3aae7c92c2724b9f3c801735f2321cf05
Author: Michael Stahl <mstahl at redhat.com>
Date: Sun Jul 24 00:02:23 2016 +0200
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 at libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
(cherry picked from commit 4ca12100ef036c6005d799e26801970118f591f4)
Change-Id: I9881cb9bf2ae6ccc5fcf06602343f2d0e0704699
Reviewed-on: https://gerrit.libreoffice.org/27538
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/sd/inc/EffectMigration.hxx b/sd/inc/EffectMigration.hxx
index 033e4ed..f1702b1 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 0000000..4c2482a
Binary files /dev/null and b/sd/qa/unit/data/sxi/ooo41061-1.sxi differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 2c26340..53a83b0 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -120,6 +120,7 @@ public:
void testFdo83751();
void testFdo79731();
void testSwappedOutImageExport();
+ void testOOoXMLAnimations();
void testTdf80020();
void testLinkedGraphicRT();
void testImageWithSpecialID();
@@ -164,6 +165,7 @@ public:
CPPUNIT_TEST(testFdo83751);
CPPUNIT_TEST(testFdo79731);
CPPUNIT_TEST(testSwappedOutImageExport);
+ CPPUNIT_TEST(testOOoXMLAnimations);
CPPUNIT_TEST(testTdf80020);
CPPUNIT_TEST(testLinkedGraphicRT);
CPPUNIT_TEST(testImageWithSpecialID);
@@ -198,10 +200,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" },
@@ -714,6 +718,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 136ebc0..804d56a 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 7b1ab2e..a839037 100644
--- a/sd/source/core/EffectMigration.cxx
+++ b/sd/source/core/EffectMigration.cxx
@@ -1435,4 +1435,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 badc20b..e5b2830 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
More information about the Libreoffice-commits
mailing list