From b6f0fd6a2f459ead2268e07bfd86db7e303b323f Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 25 Aug 2022 14:01:43 +0200 Subject: Related: tdf#149971 avmedia: add doc model and render for crop of media objects It is possible to provide an explicit preview of media objects since commit 8fa1d453c94cdbb03dac646fb8db2ebd1a0e84bd (Related: tdf#149971 svx: support explicitly provided snapshots for media shapes, 2022-08-24), however they can't be cropped. This means that media shapes from PPTX with cropping show unexpected content and can also have a buggy aspect ratio. Extend avmedia::MediaItem to store cropping and take it into account when returning the preview bitmap in SdrMediaObj::getSnapshot(). PPTX import works out of the box, as oox/ already tried to set a cropping property on the media shape. This is just the preview, the cropping of the video itself is not yet implemented. Change-Id: I8db3e0dcf252613d56eb0e6139adf097e53b15cc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138808 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- avmedia/source/framework/mediaitem.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'avmedia') diff --git a/avmedia/source/framework/mediaitem.cxx b/avmedia/source/framework/mediaitem.cxx index 49b400084128..77b28918f545 100644 --- a/avmedia/source/framework/mediaitem.cxx +++ b/avmedia/source/framework/mediaitem.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -64,6 +65,7 @@ struct MediaItem::Impl bool m_bMute; css::media::ZoomLevel m_eZoom; Graphic m_aGraphic; + text::GraphicCrop m_aCrop; explicit Impl(AVMediaSetMask nMaskSet) : m_nMaskSet( nMaskSet ) @@ -107,6 +109,7 @@ bool MediaItem::operator==( const SfxPoolItem& rItem ) const && 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_aCrop == rOther.m_pImpl->m_aCrop && 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 @@ -193,6 +196,9 @@ bool MediaItem::merge(const MediaItem& rMediaItem) if (nMaskSet & AVMediaSetMask::GRAPHIC) bChanged |= setGraphic(rMediaItem.getGraphic()); + if (nMaskSet & AVMediaSetMask::CROP) + bChanged |= setCrop(rMediaItem.getCrop()); + if( AVMediaSetMask::STATE & nMaskSet ) bChanged |= setState( rMediaItem.getState() ); @@ -275,6 +281,17 @@ bool MediaItem::setGraphic(const Graphic& rGraphic) const Graphic & MediaItem::getGraphic() const { return m_pImpl->m_aGraphic; } +bool MediaItem::setCrop(const text::GraphicCrop& rCrop) +{ + m_pImpl->m_nMaskSet |= AVMediaSetMask::CROP; + bool bChanged = rCrop != m_pImpl->m_aCrop; + if (bChanged) + m_pImpl->m_aCrop = rCrop; + return bChanged; +} + +const text::GraphicCrop& MediaItem::getCrop() const { return m_pImpl->m_aCrop; } + bool MediaItem::setState(MediaState eState) { m_pImpl->m_nMaskSet |= AVMediaSetMask::STATE; -- cgit