Kaydet (Commit) cbcffbae authored tarafından Jan Holesovsky's avatar Jan Holesovsky

tdf#106867: Export videos in PPTX.

Change-Id: I7f4f389a72aa7ecef65d87f07bb69ba8f3374a14
Reviewed-on: https://gerrit.libreoffice.org/41979Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJan Holesovsky <kendy@collabora.com>
üst f2c29539
......@@ -135,6 +135,10 @@ 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);
void WriteStyleProperties( sal_Int32 nTokenId, const css::uno::Sequence< css::beans::PropertyValue >& aProperties );
const char* GetComponentDir();
......
......@@ -53,6 +53,7 @@ enum class Relationship
STYLES,
THEME,
VBAPROJECT,
VIDEO,
VMLDRAWING,
WORDVBADATA,
WORKSHEET
......
......@@ -35,6 +35,7 @@ endif
endif
$(eval $(call gb_CppunitTest_use_libraries,oox_tokenmap,\
avmedia \
basegfx \
comphelper \
cppu \
......
......@@ -38,6 +38,7 @@ $(eval $(call gb_Library_use_api,oox,\
))
$(eval $(call gb_Library_use_libraries,oox,\
avmedia \
basegfx \
comphelper \
cppu \
......@@ -47,7 +48,7 @@ $(eval $(call gb_Library_use_libraries,oox,\
drawinglayer \
msfilter \
sal \
i18nlangtag \
i18nlangtag \
sax \
sfx \
svl \
......
......@@ -43,6 +43,7 @@
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/document/XStorageBasedDocument.hpp>
#include <com/sun/star/drawing/BitmapMode.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
......@@ -58,6 +59,7 @@
#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include <com/sun/star/drawing/XShape.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/style/LineSpacing.hpp>
......@@ -70,6 +72,8 @@
#include <com/sun/star/text/XTextField.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/style/CaseMap.hpp>
#include <comphelper/storagehelper.hxx>
#include <o3tl/any.hxx>
#include <tools/stream.hxx>
#include <unotools/fontdefs.hxx>
......@@ -88,6 +92,7 @@
#include <editeng/flditem.hxx>
#include <svx/sdtfsitm.hxx>
#include <svx/svdoashp.hxx>
#include <svx/svdomedia.hxx>
#include <svx/unoapi.hxx>
#include <svx/unoshape.hxx>
#include <android/compatibility.hxx>
......@@ -946,6 +951,55 @@ OUString DrawingML::WriteImage( const Graphic& rGraphic , bool bRelPathToMedia )
return sRelId;
}
OUString DrawingML::WriteMedia(const css::uno::Reference<css::drawing::XShape>& xShape, bool bRelPathToMedia)
{
SdrMediaObj* pMediaObj = dynamic_cast<SdrMediaObj*>(GetSdrObjectFromXShape(xShape));
if (!pMediaObj)
return OUString();
// extension
OUString aExtension;
const OUString& rURL(pMediaObj->getURL());
int nLastDot = rURL.lastIndexOf('.');
if (nLastDot >= 0)
aExtension = rURL.copy(nLastDot);
// 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();
Reference<XOutputStream> xOutStream = mpFB->openFragmentStream(OUStringBuffer()
.appendAscii(GetComponentDir())
.append("/media/media")
.append((sal_Int32) mnImageCounter)
.append(aExtension)
.makeStringAndClear(),
aMimeType);
uno::Reference<io::XInputStream> xInputStream(pMediaObj->GetInputStream());
comphelper::OStorageHelper::CopyInputToOutput(xInputStream, xOutStream);
xOutStream->closeOutput();
// create the relation
OString sRelPathToMedia = "media/media";
if (bRelPathToMedia)
sRelPathToMedia = "../" + sRelPathToMedia;
return mpFB->addRelation(mpFS->getOutputStream(),
oox::getRelationship(Relationship::VIDEO),
OUStringBuffer()
.appendAscii(GetRelationCompPrefix())
.appendAscii(sRelPathToMedia.getStr())
.append((sal_Int32) mnImageCounter++)
.append(aExtension)
.makeStringAndClear());
}
OUString DrawingML::WriteBlip( const Reference< XPropertySet >& rXPropSet, const OUString& rURL, bool bRelPathToMedia, const Graphic *pGraphic )
{
OUString sRelId;
......
......@@ -60,6 +60,7 @@
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <com/sun/star/embed/XEmbedPersist.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
......@@ -80,6 +81,7 @@
#include <tools/globname.hxx>
#include <comphelper/classids.hxx>
#include <comphelper/propertysequence.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/storagehelper.hxx>
#include <sot/exchange.hxx>
#include <utility>
......@@ -1096,10 +1098,22 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape
SAL_INFO("oox.shape", "graphicObject without text");
OUString sGraphicURL;
OUString sMediaURL;
Reference< XPropertySet > xShapeProps( xShape, UNO_QUERY );
if( !pGraphic && ( !xShapeProps.is() || !( xShapeProps->getPropertyValue( "GraphicURL" ) >>= sGraphicURL ) ) )
bool bHasGraphicURL = xShapeProps.is() && xShapeProps->getPropertySetInfo()->hasPropertyByName("GraphicURL") && (xShapeProps->getPropertyValue("GraphicURL") >>= sGraphicURL);
bool bHasMediaURL = xShapeProps.is() && xShapeProps->getPropertySetInfo()->hasPropertyByName("MediaURL") && (xShapeProps->getPropertyValue("MediaURL") >>= sMediaURL);
if (!pGraphic && !bHasGraphicURL && !bHasMediaURL)
{
SAL_INFO("oox.shape", "no graphic or media URL found");
return;
}
// TODO FIXME currently we support only embedded video
if (bHasMediaURL && !sMediaURL.startsWith("vnd.sun.star.Package:"))
{
SAL_INFO("oox.shape", "no graphic URL found");
SAL_INFO("oox.shape", "external media URL not exported");
return;
}
......@@ -1123,26 +1137,57 @@ void ShapeExport::WriteGraphicObjectShapePart( const Reference< XShape >& xShape
if ( ( bHaveDesc = GetProperty( xShapeProps, "Description" ) ) )
mAny >>= sDescr;
pFS->singleElementNS( mnXmlNamespace, XML_cNvPr,
pFS->startElementNS( mnXmlNamespace, XML_cNvPr,
XML_id, I32S( GetNewShapeID( xShape ) ),
XML_name, bHaveName ? USS( sName ) : OString( "Picture " + OString::number( mnPictureIdMax++ )).getStr(),
XML_descr, bHaveDesc ? USS( sDescr ) : nullptr,
FSEND );
// OOXTODO: //cNvPr children: XML_extLst, XML_hlinkClick, XML_hlinkHover
if (bHasMediaURL)
pFS->singleElementNS(XML_a, XML_hlinkClick,
FSNS(XML_r, XML_id), "",
XML_action, "ppaction://media",
FSEND);
pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
pFS->singleElementNS( mnXmlNamespace, XML_cNvPicPr,
// OOXTODO: XML_preferRelativeSize
FSEND );
WriteNonVisualProperties( xShape );
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);
}
else
WriteNonVisualProperties( xShape );
pFS->endElementNS( mnXmlNamespace, XML_nvPicPr );
pFS->startElementNS( mnXmlNamespace, XML_blipFill, FSEND );
WriteBlip( xShapeProps, sGraphicURL, false, pGraphic );
if (pGraphic || bHasGraphicURL)
WriteBlip(xShapeProps, sGraphicURL, false, pGraphic);
else if (bHasMediaURL)
{
Reference<graphic::XGraphic> rGraphic;
if (xShapeProps->getPropertySetInfo()->hasPropertyByName("FallbackGraphic"))
xShapeProps->getPropertyValue("FallbackGraphic") >>= rGraphic;
Graphic aGraphic(rGraphic);
WriteBlip(xShapeProps, sMediaURL, false, &aGraphic);
}
WriteSrcRect( xShapeProps, sGraphicURL );
if (bHasGraphicURL)
WriteSrcRect(xShapeProps, sGraphicURL);
// now we stretch always when we get pGraphic (when changing that
// behavior, test n#780830 for regression, where the OLE sheet might get tiled
......@@ -1418,6 +1463,7 @@ static const NameToConvertMapType& lcl_GetConverters()
shape_converters[ "com.sun.star.drawing.GroupShape" ] = &ShapeExport::WriteGroupShape;
shape_converters[ "com.sun.star.presentation.GraphicObjectShape" ] = &ShapeExport::WriteGraphicObjectShape;
shape_converters[ "com.sun.star.presentation.MediaShape" ] = &ShapeExport::WriteGraphicObjectShape;
shape_converters[ "com.sun.star.presentation.OLE2Shape" ] = &ShapeExport::WriteOLE2Shape;
shape_converters[ "com.sun.star.presentation.TableShape" ] = &ShapeExport::WriteTableShape;
shape_converters[ "com.sun.star.presentation.TextShape" ] = &ShapeExport::WriteTextShape;
......
......@@ -36,6 +36,7 @@
{Relationship::STYLES, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"},
{Relationship::THEME, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"},
{Relationship::VBAPROJECT, "http://schemas.microsoft.com/office/2006/relationships/vbaProject"},
{Relationship::VIDEO, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video"},
{Relationship::VMLDRAWING, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"},
{Relationship::WORDVBADATA, "http://schemas.microsoft.com/office/2006/relationships/wordVbaData"},
{Relationship::WORKSHEET, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"}
......@@ -323,6 +323,8 @@ ShapeExport& PowerPointShapeExport::WriteUnknownShape(const Reference< XShape >&
if (!WritePlaceholder(xShape, Subtitle, mbMaster))
ShapeExport::WriteTextShape(xShape);
}
else
SAL_WARN("sd.eppt", "unknown shape not handled: " << USS(sShapeType));
return *this;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment