diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2022-10-23 17:56:50 -0400 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-10-25 08:22:14 +0200 |
commit | 77f9b14071fd5361f3c2d7eba8a9799d41bf3159 (patch) | |
tree | aedaf1281f84344c6b518b26a58465f76268cf2c /filter | |
parent | 05bdae6e949d91277978af88212a646d1bd715c3 (diff) |
svg: export embedded video
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
Change-Id: Ie5dcd1fb4abbaf53f48107e7def0f42daad24596
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141690
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/svg/svgwriter.cxx | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index e43ff6fce264..1cb2076f4480 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -37,6 +37,7 @@ #include <xmloff/namespacemap.hxx> #include <xmloff/unointerfacetouniqueidentifiermapper.hxx> #include <i18nlangtag/languagetag.hxx> +#include <svx/svdomedia.hxx> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/container/XIndexReplace.hpp> @@ -2995,12 +2996,49 @@ void SVGActionWriter::ImplWriteBmp( const BitmapEx& rBmpEx, mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, OUString::number( aSz.Width() ) ); mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, OUString::number( aSz.Height() ) ); - // the image must be scaled to aSz in a non-uniform way - mrExport.AddAttribute( XML_NAMESPACE_NONE, "preserveAspectRatio", "none" ); + // If we have a media object (a video), export the video. + // Also, use the image generated above as the video poster (thumbnail). + SdrMediaObj* pMediaObj + = pShape ? dynamic_cast<SdrMediaObj*>(SdrObject::getSdrObjectFromXShape(*pShape)) : nullptr; + const bool embedVideo = (pMediaObj && !pMediaObj->getTempURL().isEmpty()); - mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, aBuffer.makeStringAndClear() ); + if (!embedVideo) { - SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, "image", true, true ); + // the image must be scaled to aSz in a non-uniform way + mrExport.AddAttribute(XML_NAMESPACE_NONE, "preserveAspectRatio", "none"); + + mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrXLinkHRef, aBuffer.makeStringAndClear()); + + SvXMLElementExport aElem(mrExport, XML_NAMESPACE_NONE, "image", true, true); + } + else + { + // <foreignObject xmlns="http://www.w3.org/2000/svg" overflow="visible" width="499.6" height="374.33333333333337" x="705" y="333"> + // <body xmlns="http://www.w3.org/1999/xhtml"> + // <video controls="controls" width="499.6" height="374.33333333333337"> + // <source src="file:///tmp/abcdef.mp4" type="video/mp4"> + // </video> + // </body> + // </foreignObject> + mrExport.AddAttribute(XML_NAMESPACE_NONE, "xmlns", "http://www.w3.org/2000/svg"); + mrExport.AddAttribute(XML_NAMESPACE_NONE, "overflow", "visible"); + SvXMLElementExport aForeignObject(mrExport, XML_NAMESPACE_NONE, "foreignObject", true, + true); + mrExport.AddAttribute(XML_NAMESPACE_NONE, "xmlns", "http://www.w3.org/1999/xhtml"); + SvXMLElementExport aBody(mrExport, XML_NAMESPACE_NONE, "body", true, true); + + mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrWidth, OUString::number(aSz.Width())); + mrExport.AddAttribute(XML_NAMESPACE_NONE, aXMLAttrHeight, OUString::number(aSz.Height())); + mrExport.AddAttribute(XML_NAMESPACE_NONE, "autoplay", "autoplay"); + mrExport.AddAttribute(XML_NAMESPACE_NONE, "controls", "controls"); + mrExport.AddAttribute(XML_NAMESPACE_NONE, "loop", "loop"); + mrExport.AddAttribute(XML_NAMESPACE_NONE, "preload", "auto"); + mrExport.AddAttribute(XML_NAMESPACE_NONE, "poster", aBuffer.makeStringAndClear()); + SvXMLElementExport aVideo(mrExport, XML_NAMESPACE_NONE, "video", true, true); + + mrExport.AddAttribute(XML_NAMESPACE_NONE, "src", pMediaObj->getTempURL()); + mrExport.AddAttribute(XML_NAMESPACE_NONE, "type", "video/mp4"); //FIXME: set mime type. + SvXMLElementExport aSource(mrExport, XML_NAMESPACE_NONE, "source", true, true); } } |