summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--avmedia/source/framework/mediaitem.cxx13
-rw-r--r--include/avmedia/mediaitem.hxx8
-rw-r--r--sd/qa/unit/export-tests-ooxml1.cxx23
-rw-r--r--svx/source/svdraw/svdomedia.cxx5
-rw-r--r--svx/source/unodraw/unoprov.cxx1
-rw-r--r--svx/source/unodraw/unoshap4.cxx31
6 files changed, 77 insertions, 4 deletions
diff --git a/avmedia/source/framework/mediaitem.cxx b/avmedia/source/framework/mediaitem.cxx
index f42065e8e81e..54db2e3bc6bf 100644
--- a/avmedia/source/framework/mediaitem.cxx
+++ b/avmedia/source/framework/mediaitem.cxx
@@ -40,6 +40,7 @@
#include <mediamisc.hxx>
#include <osl/file.hxx>
#include <tools/diagnose_ex.h>
+#include <vcl/graph.hxx>
using namespace ::com::sun::star;
@@ -62,6 +63,7 @@ struct MediaItem::Impl
bool m_bLoop;
bool m_bMute;
css::media::ZoomLevel m_eZoom;
+ Graphic m_aGraphic;
explicit Impl(AVMediaSetMask nMaskSet)
: m_nMaskSet( nMaskSet )
@@ -104,6 +106,7 @@ bool MediaItem::operator==( const SfxPoolItem& rItem ) const
&& m_pImpl->m_URL == rOther.m_pImpl->m_URL
&& m_pImpl->m_Referer == rOther.m_pImpl->m_Referer
&& m_pImpl->m_sMimeType == rOther.m_pImpl->m_sMimeType
+ && m_pImpl->m_aGraphic == rOther.m_pImpl->m_aGraphic
&& m_pImpl->m_eState == rOther.m_pImpl->m_eState
&& m_pImpl->m_fDuration == rOther.m_pImpl->m_fDuration
&& m_pImpl->m_fTime == rOther.m_pImpl->m_fTime
@@ -188,6 +191,9 @@ void MediaItem::merge( const MediaItem& rMediaItem )
if( AVMediaSetMask::MIME_TYPE & nMaskSet )
setMimeType( rMediaItem.getMimeType() );
+ if (nMaskSet & AVMediaSetMask::GRAPHIC)
+ setGraphic(rMediaItem.getGraphic());
+
if( AVMediaSetMask::STATE & nMaskSet )
setState( rMediaItem.getState() );
@@ -256,6 +262,13 @@ OUString MediaItem::getMimeType() const
return !m_pImpl->m_sMimeType.isEmpty() ? m_pImpl->m_sMimeType : AVMEDIA_MIMETYPE_COMMON;
}
+void MediaItem::setGraphic(const Graphic& rGraphic)
+{
+ m_pImpl->m_nMaskSet |= AVMediaSetMask::GRAPHIC;
+ m_pImpl->m_aGraphic = rGraphic;
+}
+
+Graphic MediaItem::getGraphic() const { return m_pImpl->m_aGraphic; }
void MediaItem::setState( MediaState eState )
{
diff --git a/include/avmedia/mediaitem.hxx b/include/avmedia/mediaitem.hxx
index 7246c9e7e2a1..9e3fb4cd4530 100644
--- a/include/avmedia/mediaitem.hxx
+++ b/include/avmedia/mediaitem.hxx
@@ -32,6 +32,7 @@ namespace com::sun::star::embed { class XStorage; }
namespace com::sun::star::frame { class XModel; }
namespace com::sun::star::io { class XInputStream; }
namespace com::sun::star::io { class XStream; }
+class Graphic;
enum class AVMediaSetMask
{
@@ -45,11 +46,12 @@ enum class AVMediaSetMask
ZOOM = 0x040,
URL = 0x080,
MIME_TYPE = 0x100,
- ALL = 0x1ff,
+ GRAPHIC = 0x200,
+ ALL = 0x3ff,
};
namespace o3tl
{
- template<> struct typed_flags<AVMediaSetMask> : is_typed_flags<AVMediaSetMask, 0x1ff> {};
+ template<> struct typed_flags<AVMediaSetMask> : is_typed_flags<AVMediaSetMask, 0x3ff> {};
}
@@ -115,6 +117,8 @@ public:
void setMimeType( const OUString& rMimeType );
OUString getMimeType() const;
+ void setGraphic(const Graphic& rGraphic);
+ Graphic getGraphic() const;
const OUString& getTempURL() const;
const OUString& getReferer() const;
diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx
index 5784d00d112d..91ce68e20a50 100644
--- a/sd/qa/unit/export-tests-ooxml1.cxx
+++ b/sd/qa/unit/export-tests-ooxml1.cxx
@@ -53,6 +53,8 @@
#include <svx/svdotable.hxx>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <rtl/uri.hxx>
+#include <vcl/pngread.hxx>
using namespace css;
@@ -1313,6 +1315,27 @@ void SdOOXMLExportTest1::testNarrationMimeType()
assertXPath(pXmlDoc,
"/ContentType:Types/ContentType:Override[@PartName='/ppt/media/media1.m4a']",
"ContentType", "audio/mp4");
+
+ // Check if the bitmap of the media shape is exported correctly.
+ xmlDocUniquePtr pSlideDoc = parseExport(aTempFile, "ppt/slides/slide1.xml");
+ OUString aImageId = getXPath(pSlideDoc, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip", "embed");
+ xmlDocUniquePtr pRelsDoc = parseExport(aTempFile, "ppt/slides/_rels/slide1.xml.rels");
+ OUString aImagePath = "/rels:Relationships/rels:Relationship[@Id='" + aImageId + "']";
+ // Something like ../media/image2.png.
+ OUString aImageStreamName = getXPath(pRelsDoc, aImagePath.toUtf8(), "Target");
+ OUString aImageAbsName = rtl::Uri::convertRelToAbs("file:///ppt/slides/", aImageStreamName);
+ // Something like ppt/media/image2.png.
+ OUString aImageRelName;
+ CPPUNIT_ASSERT(aImageAbsName.startsWith("file:///", &aImageRelName));
+ std::unique_ptr<SvStream> pImageStream = parseExportStream(aTempFile, aImageRelName);
+ vcl::PNGReader aReader(*pImageStream);
+ BitmapEx aBitmapEx = aReader.Read();
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 256
+ // - Actual : 120
+ // i.e. the bitmap of the narration was lost, some default placeholder was exported instead.
+ CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(256), aBitmapEx.GetSizePixel().Height());
+
xDocShRef->DoClose();
}
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index 47e30a1049ac..923be7d451ba 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -330,6 +330,11 @@ void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProper
if( AVMediaSetMask::MIME_TYPE & nMaskSet )
m_xImpl->m_MediaProperties.setMimeType( rNewProperties.getMimeType() );
+ if (nMaskSet & AVMediaSetMask::GRAPHIC)
+ {
+ m_xImpl->m_MediaProperties.setGraphic(rNewProperties.getGraphic());
+ }
+
if( ( AVMediaSetMask::URL & nMaskSet ) &&
( rNewProperties.getURL() != getURL() ))
{
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index 0531cff10bb9..865380d2a0c8 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -729,6 +729,7 @@ static SfxItemPropertyMapEntry const * ImplGetSvxMediaShapePropertyMap()
{u"PrivateTempFileURL", OWN_ATTR_MEDIA_TEMPFILEURL, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY, 0},
{ u"MediaMimeType", OWN_ATTR_MEDIA_MIMETYPE, cppu::UnoType<OUString>::get(), 0, 0},
{ u"FallbackGraphic", OWN_ATTR_FALLBACK_GRAPHIC, cppu::UnoType<css::graphic::XGraphic>::get(), css::beans::PropertyAttribute::READONLY, 0},
+ { u"" UNO_NAME_GRAPHOBJ_GRAPHIC, OWN_ATTR_VALUE_GRAPHIC , cppu::UnoType<css::graphic::XGraphic>::get(), 0, 0},
{ u"", 0, css::uno::Type(), 0, 0 }
};
diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
index 658cb2c8fd6c..17daf3f5a1ed 100644
--- a/svx/source/unodraw/unoshap4.cxx
+++ b/svx/source/unodraw/unoshap4.cxx
@@ -779,7 +779,8 @@ bool SvxMediaShape::setPropertyValueImpl( const OUString& rName, const SfxItemPr
{
if( ((pProperty->nWID >= OWN_ATTR_MEDIA_URL) && (pProperty->nWID <= OWN_ATTR_MEDIA_ZOOM))
|| (pProperty->nWID == OWN_ATTR_MEDIA_STREAM)
- || (pProperty->nWID == OWN_ATTR_MEDIA_MIMETYPE) )
+ || (pProperty->nWID == OWN_ATTR_MEDIA_MIMETYPE)
+ || (pProperty->nWID == OWN_ATTR_VALUE_GRAPHIC))
{
SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( GetSdrObject() );
::avmedia::MediaItem aItem;
@@ -869,6 +870,19 @@ bool SvxMediaShape::setPropertyValueImpl( const OUString& rName, const SfxItemPr
#endif
break;
+ case OWN_ATTR_VALUE_GRAPHIC:
+#if HAVE_FEATURE_AVMEDIA
+ {
+ uno::Reference<graphic::XGraphic> xGraphic(rValue, uno::UNO_QUERY);
+ if (xGraphic.is())
+ {
+ bOk = true;
+ aItem.setGraphic(Graphic(xGraphic));
+ }
+ }
+#endif
+ break;
+
case OWN_ATTR_MEDIA_STREAM:
#if HAVE_FEATURE_AVMEDIA
try
@@ -924,7 +938,8 @@ bool SvxMediaShape::getPropertyValueImpl( const OUString& rName, const SfxItemPr
|| (pProperty->nWID == OWN_ATTR_MEDIA_STREAM)
|| (pProperty->nWID == OWN_ATTR_MEDIA_TEMPFILEURL)
|| (pProperty->nWID == OWN_ATTR_MEDIA_MIMETYPE)
- || (pProperty->nWID == OWN_ATTR_FALLBACK_GRAPHIC))
+ || (pProperty->nWID == OWN_ATTR_FALLBACK_GRAPHIC)
+ || (pProperty->nWID == OWN_ATTR_VALUE_GRAPHIC))
{
SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( GetSdrObject() );
const ::avmedia::MediaItem aItem( pMedia->getMediaProperties() );
@@ -995,6 +1010,18 @@ bool SvxMediaShape::getPropertyValueImpl( const OUString& rName, const SfxItemPr
#endif
break;
+ case OWN_ATTR_VALUE_GRAPHIC:
+#if HAVE_FEATURE_AVMEDIA
+ {
+ Graphic aGraphic = aItem.getGraphic();
+ if (!aGraphic.IsNone())
+ {
+ rValue <<= aGraphic.GetXGraphic();
+ }
+ }
+#endif
+ break;
+
case OWN_ATTR_FALLBACK_GRAPHIC:
rValue <<= pMedia->getSnapshot();
break;