summaryrefslogtreecommitdiffstats
path: root/svx
diff options
context:
space:
mode:
Diffstat (limited to 'svx')
-rw-r--r--svx/qa/unit/data/video-snapshot.pptxbin40194 -> 40759 bytes
-rw-r--r--svx/qa/unit/svdraw.cxx6
-rw-r--r--svx/source/svdraw/svdomedia.cxx21
-rw-r--r--svx/source/unodraw/unoprov.cxx1
-rw-r--r--svx/source/unodraw/unoshap4.cxx28
5 files changed, 54 insertions, 2 deletions
diff --git a/svx/qa/unit/data/video-snapshot.pptx b/svx/qa/unit/data/video-snapshot.pptx
index 9a0ec9ebd867..a212f105200f 100644
--- a/svx/qa/unit/data/video-snapshot.pptx
+++ b/svx/qa/unit/data/video-snapshot.pptx
Binary files differ
diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx
index 1bb9a6dab4db..a2bee4a8d30d 100644
--- a/svx/qa/unit/svdraw.cxx
+++ b/svx/qa/unit/svdraw.cxx
@@ -505,6 +505,12 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testVideoSnapshot)
// i.e. the preview was black, not red; since we seeked 3 secs into the video, while PowerPoint
// doesn't do that.
CPPUNIT_ASSERT_EQUAL(Color(0xff, 0x0, 0x0), rBitmap.GetPixelColor(0, 0));
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 321
+ // - Actual : 640
+ // i.e. ~25% crop from left and right should result in half width, but it was not reduced.
+ CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(321), rBitmap.GetSizePixel().getWidth());
}
}
diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx
index 15a0e1179098..1dd55f057991 100644
--- a/svx/source/svdraw/svdomedia.cxx
+++ b/svx/source/svdraw/svdomedia.cxx
@@ -21,6 +21,8 @@
#include <svx/svdomedia.hxx>
+#include <com/sun/star/text/GraphicCrop.hpp>
+
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
@@ -154,6 +156,20 @@ uno::Reference< graphic::XGraphic > const & SdrMediaObj::getSnapshot() const
Graphic aGraphic = m_xImpl->m_MediaProperties.getGraphic();
if (!aGraphic.IsNone())
{
+ Size aPref = aGraphic.GetPrefSize();
+ Size aPixel = aGraphic.GetSizePixel();
+ const text::GraphicCrop& rCrop = m_xImpl->m_MediaProperties.getCrop();
+ if (rCrop.Bottom > 0 || rCrop.Left > 0 || rCrop.Right > 0 || rCrop.Top > 0)
+ {
+ tools::Long nLeft = aPixel.getWidth() * rCrop.Left / aPref.getWidth();
+ tools::Long nTop = aPixel.getHeight() * rCrop.Top / aPref.getHeight();
+ tools::Long nRight = aPixel.getWidth() * rCrop.Right / aPref.getWidth();
+ tools::Long nBottom = aPixel.getHeight() * rCrop.Bottom / aPref.getHeight();
+ BitmapEx aBitmapEx = aGraphic.GetBitmapEx();
+ aBitmapEx.Crop({nLeft, nTop, aPixel.getWidth() - nRight, aPixel.getHeight() - nBottom});
+ aGraphic = aBitmapEx;
+ }
+
// We have an explicit graphic for this media object, then go with that instead of
// generating our own one.
m_xImpl->m_xCachedSnapshot = aGraphic.GetXGraphic();
@@ -363,6 +379,11 @@ void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProper
m_xImpl->m_MediaProperties.setGraphic(rNewProperties.getGraphic());
}
+ if (nMaskSet & AVMediaSetMask::CROP)
+ {
+ m_xImpl->m_MediaProperties.setCrop(rNewProperties.getCrop());
+ }
+
if( ( AVMediaSetMask::URL & nMaskSet ) &&
( rNewProperties.getURL() != getURL() ))
{
diff --git a/svx/source/unodraw/unoprov.cxx b/svx/source/unodraw/unoprov.cxx
index faebaf224213..074d584566db 100644
--- a/svx/source/unodraw/unoprov.cxx
+++ b/svx/source/unodraw/unoprov.cxx
@@ -713,6 +713,7 @@ static o3tl::span<SfxItemPropertyMapEntry const> ImplGetSvxMediaShapePropertyMap
{ 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},
{ UNO_NAME_GRAPHOBJ_GRAPHIC, OWN_ATTR_VALUE_GRAPHIC , cppu::UnoType<css::graphic::XGraphic>::get(), 0, 0},
+ { UNO_NAME_GRAPHIC_GRAPHICCROP, SDRATTR_GRAFCROP , cppu::UnoType<css::text::GraphicCrop>::get(), 0, 0},
};
return aMediaShapePropertyMap_Impl;
diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
index aee99b3841d3..482efb826117 100644
--- a/svx/source/unodraw/unoshap4.cxx
+++ b/svx/source/unodraw/unoshap4.cxx
@@ -784,7 +784,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_VALUE_GRAPHIC))
+ || (pProperty->nWID == OWN_ATTR_VALUE_GRAPHIC)
+ || (pProperty->nWID == SDRATTR_GRAFCROP))
{
#if HAVE_FEATURE_AVMEDIA
SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( GetSdrObject() );
@@ -889,6 +890,19 @@ bool SvxMediaShape::setPropertyValueImpl( const OUString& rName, const SfxItemPr
#endif
break;
+ case SDRATTR_GRAFCROP:
+#if HAVE_FEATURE_AVMEDIA
+ {
+ text::GraphicCrop aCrop;
+ if (rValue >>= aCrop)
+ {
+ bOk = true;
+ aItem.setCrop(aCrop);
+ }
+ }
+#endif
+ break;
+
case OWN_ATTR_MEDIA_STREAM:
#if HAVE_FEATURE_AVMEDIA
try
@@ -947,7 +961,8 @@ bool SvxMediaShape::getPropertyValueImpl( const OUString& rName, const SfxItemPr
|| (pProperty->nWID == OWN_ATTR_MEDIA_TEMPFILEURL)
|| (pProperty->nWID == OWN_ATTR_MEDIA_MIMETYPE)
|| (pProperty->nWID == OWN_ATTR_FALLBACK_GRAPHIC)
- || (pProperty->nWID == OWN_ATTR_VALUE_GRAPHIC))
+ || (pProperty->nWID == OWN_ATTR_VALUE_GRAPHIC)
+ || (pProperty->nWID == SDRATTR_GRAFCROP))
{
SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( GetSdrObject() );
#if HAVE_FEATURE_AVMEDIA
@@ -1032,6 +1047,15 @@ bool SvxMediaShape::getPropertyValueImpl( const OUString& rName, const SfxItemPr
#endif
break;
+ case SDRATTR_GRAFCROP:
+#if HAVE_FEATURE_AVMEDIA
+ {
+ text::GraphicCrop aCrop = aItem.getCrop();
+ rValue <<= aCrop;
+ }
+#endif
+ break;
+
case OWN_ATTR_FALLBACK_GRAPHIC:
rValue <<= pMedia->getSnapshot();
break;