summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2017-09-06 10:36:10 +0200
committerJan Holesovsky <kendy@collabora.com>2017-09-07 07:01:27 +0200
commit4d1159136ae25b437d874e0fba7f0f13651049b6 (patch)
treed97689c67420eec30d31bf37f71b57abdfd0cc3a
parentcbcffbaee204e9dfbdc2125dda73e36d77e9b844 (diff)
tdf#106867: Write also the extended markup to fully support embedded videos.
Change-Id: I33398bff32077a8a109e0addcebab039f734c1bb Reviewed-on: https://gerrit.libreoffice.org/41981 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r--include/oox/export/drawingml.hxx4
-rw-r--r--include/oox/token/relationship.hxx1
-rw-r--r--oox/source/export/drawingml.cxx77
-rw-r--r--oox/source/export/shapes.cxx20
-rw-r--r--oox/source/token/relationship.inc1
5 files changed, 59 insertions, 44 deletions
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 0e497f91a4a5..c33bb40f4306 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -136,8 +136,8 @@ protected:
/// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship
OUString WriteImage( const OUString& rURL, bool bRelPathToMedia = false);
- /// Copy a video from vnd.sun.star.Package: to the output and return RelId.
- OUString WriteMedia(const css::uno::Reference<css::drawing::XShape>& xShape, bool bRelPathToMedia = false);
+ /// Output the media (including copying a video from vnd.sun.star.Package: to the output if necessary).
+ void WriteMediaNonVisualProperties(const css::uno::Reference<css::drawing::XShape>& xShape);
void WriteStyleProperties( sal_Int32 nTokenId, const css::uno::Sequence< css::beans::PropertyValue >& aProperties );
diff --git a/include/oox/token/relationship.hxx b/include/oox/token/relationship.hxx
index 329fe7407df1..18cca8523749 100644
--- a/include/oox/token/relationship.hxx
+++ b/include/oox/token/relationship.hxx
@@ -39,6 +39,7 @@ enum class Relationship
HEADER,
HYPERLINK,
IMAGE,
+ MEDIA,
NOTESMASTER,
NOTESSLIDE,
NUMBERING,
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 32e971fa4995..fe5f4c3268da 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -951,11 +951,11 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia )
return sRelId;
}
-OUString DrawingML::WriteMedia(const css::uno::Reference<css::drawing::XShape>& xShape, bool bRelPathToMedia)
+void DrawingML::WriteMediaNonVisualProperties(const css::uno::Reference<css::drawing::XShape>& xShape)
{
SdrMediaObj* pMediaObj = dynamic_cast<SdrMediaObj*>(GetSdrObjectFromXShape(xShape));
if (!pMediaObj)
- return OUString();
+ return;
// extension
OUString aExtension;
@@ -964,6 +964,8 @@ OUString DrawingML::WriteMedia(const css::uno::Reference<css::drawing::XShape>&
if (nLastDot >= 0)
aExtension = rURL.copy(nLastDot);
+ bool bEmbed = rURL.startsWith("vnd.sun.star.Package:");
+
// mime type
// TODO add more types explicitly based on the extension (?)
OUString aMimeType;
@@ -972,32 +974,59 @@ OUString DrawingML::WriteMedia(const css::uno::Reference<css::drawing::XShape>&
else
aMimeType = pMediaObj->getMediaProperties().getMimeType();
- Reference<XOutputStream> xOutStream = mpFB->openFragmentStream(OUStringBuffer()
- .appendAscii(GetComponentDir())
- .append("/media/media")
- .append((sal_Int32) mnImageCounter)
- .append(aExtension)
- .makeStringAndClear(),
- aMimeType);
+ OUString aVideoFileRelId;
+ OUString aMediaRelId;
- uno::Reference<io::XInputStream> xInputStream(pMediaObj->GetInputStream());
- comphelper::OStorageHelper::CopyInputToOutput(xInputStream, xOutStream);
+ if (bEmbed)
+ {
+ // copy the video stream
+ Reference<XOutputStream> xOutStream = mpFB->openFragmentStream(OUStringBuffer()
+ .appendAscii(GetComponentDir())
+ .append("/media/media")
+ .append((sal_Int32) mnImageCounter)
+ .append(aExtension)
+ .makeStringAndClear(),
+ aMimeType);
- xOutStream->closeOutput();
+ uno::Reference<io::XInputStream> xInputStream(pMediaObj->GetInputStream());
+ comphelper::OStorageHelper::CopyInputToOutput(xInputStream, xOutStream);
- // create the relation
- OString sRelPathToMedia = "media/media";
- if (bRelPathToMedia)
- sRelPathToMedia = "../" + sRelPathToMedia;
+ xOutStream->closeOutput();
+
+ // create the relation
+ OUString aPath = OUStringBuffer().appendAscii(GetRelationCompPrefix())
+ .append("media/media")
+ .append((sal_Int32) mnImageCounter++)
+ .append(aExtension)
+ .makeStringAndClear();
+ aVideoFileRelId = mpFB->addRelation(mpFS->getOutputStream(), oox::getRelationship(Relationship::VIDEO), aPath);
+ aMediaRelId = mpFB->addRelation(mpFS->getOutputStream(), oox::getRelationship(Relationship::MEDIA), aPath);
+ }
+ else
+ {
+ aVideoFileRelId = mpFB->addRelation(mpFS->getOutputStream(), oox::getRelationship(Relationship::VIDEO), rURL);
+ aMediaRelId = mpFB->addRelation(mpFS->getOutputStream(), oox::getRelationship(Relationship::MEDIA), rURL);
+ }
+
+ GetFS()->startElementNS(XML_p, XML_nvPr, FSEND);
+
+ GetFS()->singleElementNS(XML_a, XML_videoFile,
+ FSNS(XML_r, XML_link), USS(aVideoFileRelId),
+ FSEND);
+
+ GetFS()->startElementNS(XML_p, XML_extLst, FSEND);
+ GetFS()->startElementNS(XML_p, XML_ext,
+ XML_uri, "{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}", // media extensions; google this ID for details
+ FSEND);
+
+ GetFS()->singleElementNS(XML_p14, XML_media,
+ bEmbed? FSNS(XML_r, XML_embed): FSNS(XML_r, XML_link), USS(aMediaRelId),
+ FSEND);
+
+ GetFS()->endElementNS(XML_p, XML_ext);
+ GetFS()->endElementNS(XML_p, XML_extLst);
- return mpFB->addRelation(mpFS->getOutputStream(),
- oox::getRelationship(Relationship::VIDEO),
- OUStringBuffer()
- .appendAscii(GetRelationCompPrefix())
- .appendAscii(sRelPathToMedia.getStr())
- .append((sal_Int32) mnImageCounter++)
- .append(aExtension)
- .makeStringAndClear());
+ GetFS()->endElementNS(XML_p, XML_nvPr);
}
OUString DrawingML::WriteBlip( const Reference< XPropertySet >& rXPropSet, const OUString& rURL, bool bRelPathToMedia, const Graphic *pGraphic )
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 88794f3b01e1..990525681c49 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1110,13 +1110,6 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape
return;
}
- // TODO FIXME currently we support only embedded video
- if (bHasMediaURL && !sMediaURL.startsWith("vnd.sun.star.Package:"))
- {
- SAL_INFO("oox.shape", "external media URL not exported");
- return;
- }
-
FSHelperPtr pFS = GetFS();
XmlFilterBase* pFB = GetFB();
@@ -1157,18 +1150,9 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape
FSEND );
if (bHasMediaURL)
- {
- GetFS()->startElementNS(XML_p, XML_nvPr, FSEND);
-
- OUString sRelId = WriteMedia(xShape, false);
- GetFS()->singleElementNS(XML_a, XML_videoFile,
- FSNS(XML_r, XML_link), USS(sRelId),
- FSEND);
-
- GetFS()->endElementNS(XML_p, XML_nvPr);
- }
+ WriteMediaNonVisualProperties(xShape);
else
- WriteNonVisualProperties( xShape );
+ WriteNonVisualProperties(xShape);
pFS->endElementNS( mnXmlNamespace, XML_nvPicPr );
diff --git a/oox/source/token/relationship.inc b/oox/source/token/relationship.inc
index 2bdf6eab7e68..128fe3626de7 100644
--- a/oox/source/token/relationship.inc
+++ b/oox/source/token/relationship.inc
@@ -22,6 +22,7 @@
{Relationship::HEADER, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"},
{Relationship::HYPERLINK, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"},
{Relationship::IMAGE, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"},
+{Relationship::MEDIA, "http://schemas.microsoft.com/office/2007/relationships/media"},
{Relationship::NOTESMASTER, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster"},
{Relationship::NOTESSLIDE, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide"},
{Relationship::NUMBERING, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"},