[Libreoffice-commits] core.git: oox/source sd/qa

Jan Holesovsky kendy at collabora.com
Thu Sep 7 05:02:11 UTC 2017


 oox/source/export/drawingml.cxx     |   24 ++++++++++++++++++------
 sd/qa/unit/data/pptx/tdf106867.pptx |binary
 sd/qa/unit/export-tests-ooxml2.cxx  |   33 +++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+), 6 deletions(-)

New commits:
commit 4aabc5164d2a0d84e22fb3f6f66e020a8df6899a
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Sep 6 11:54:33 2017 +0200

    tdf#106867: Unit test for the export of embedded videos.
    
    Change-Id: Ibbc3da56ace2eaaf4670e869a34ec4c1bad4bf5d
    Reviewed-on: https://gerrit.libreoffice.org/41982
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index fe5f4c3268da..44cfc48ad089 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -967,12 +967,24 @@ void DrawingML::WriteMediaNonVisualProperties(const css::uno::Reference<css::dra
     bool bEmbed = rURL.startsWith("vnd.sun.star.Package:");
 
     // mime type
-    // TODO add more types explicitly based on the extension (?)
-    OUString aMimeType;
-    if (aExtension.equalsIgnoreAsciiCase(".wmv"))
-        aMimeType = "video/x-ms-wmv";
-    else
-        aMimeType = pMediaObj->getMediaProperties().getMimeType();
+    OUString aMimeType(pMediaObj->getMediaProperties().getMimeType());
+    if (aMimeType == "application/vnd.sun.star.media")
+    {
+        // try to set something better
+        // TODO fix the importer to actually set the mimetype on import
+        if (aExtension.equalsIgnoreAsciiCase(".avi"))
+            aMimeType = "video/x-msvideo";
+        else if (aExtension.equalsIgnoreAsciiCase(".flv"))
+            aMimeType = "video/x-flv";
+        else if (aExtension.equalsIgnoreAsciiCase(".mp4"))
+            aMimeType = "video/mp4";
+        else if (aExtension.equalsIgnoreAsciiCase(".mov"))
+            aMimeType = "video/quicktime";
+        else if (aExtension.equalsIgnoreAsciiCase(".ogv"))
+            aMimeType = "video/ogg";
+        else if (aExtension.equalsIgnoreAsciiCase(".wmv"))
+            aMimeType = "video/x-ms-wmv";
+    }
 
     OUString aVideoFileRelId;
     OUString aMediaRelId;
diff --git a/sd/qa/unit/data/pptx/tdf106867.pptx b/sd/qa/unit/data/pptx/tdf106867.pptx
new file mode 100644
index 000000000000..5bf16d690ef2
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf106867.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 7f1bff9a7639..ce7c117e27c0 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -104,6 +104,7 @@ public:
     void testTdf111518();
     void testTdf100387();
     void testRotateFlip();
+    void testTdf106867();
 
     CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
 
@@ -135,6 +136,7 @@ public:
     CPPUNIT_TEST(testTdf111518);
     CPPUNIT_TEST(testTdf100387);
     CPPUNIT_TEST(testRotateFlip);
+    CPPUNIT_TEST(testTdf106867);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -153,6 +155,7 @@ public:
             { "pic", "http://schemas.openxmlformats.org/drawingml/2006/picture" },
             { "wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" },
             { "p", "http://schemas.openxmlformats.org/presentationml/2006/main" },
+            { "p14", "http://schemas.microsoft.com/office/powerpoint/2010/main" },
             { "w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main" },
             { "a14", "http://schemas.microsoft.com/office/drawing/2010/main" },
             { "wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" },
@@ -991,6 +994,36 @@ void SdOOXMLExportTest2::testRotateFlip()
     }
 }
 
+void SdOOXMLExportTest2::testTdf106867()
+{
+    ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf106867.pptx"), PPTX);
+    utl::TempFile tempFile;
+    xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+
+    const SdrPage *pPage = GetPage(1, xDocShRef.get());
+
+    // first check that we have the media object
+    const SdrMediaObj* pMediaObj = dynamic_cast<SdrMediaObj*>(pPage->GetObj(2));
+    CPPUNIT_ASSERT_MESSAGE("no media object", pMediaObj != nullptr);
+    CPPUNIT_ASSERT_EQUAL(OUString("vnd.sun.star.Package:ppt/media/media1.avi"), pMediaObj->getURL());
+
+    xDocShRef->DoClose();
+
+    // additional checks of the output file
+    uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), tempFile.GetURL());
+    // check that the document contains the video stream
+    CPPUNIT_ASSERT(xNameAccess->hasByName("ppt/media/media1.avi"));
+
+    // both the ooxml and the extended markup
+    xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
+    assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/a:videoFile");
+    assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/p:extLst/p:ext/p14:media");
+
+    // target the shape with the video in the command
+    assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:cmd/p:cBhvr/p:tgtEl/p:spTgt",
+            "spid", "42");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


More information about the Libreoffice-commits mailing list