svx/qa/unit/data/video-snapshot.pptx |binary svx/qa/unit/svdraw.cxx | 23 +++++++++++++++++++++++ svx/source/svdraw/svdomedia.cxx | 9 +++++++++ 3 files changed, 32 insertions(+)
New commits: commit 8fa1d453c94cdbb03dac646fb8db2ebd1a0e84bd Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Aug 24 13:53:38 2022 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Aug 24 15:45:12 2022 +0200 Related: tdf#149971 svx: support explicitly provided snapshots for media shapes Snapshots / previews for media objects are used when the shape's video is not playing. This is generated by seeking to the 3rd second in the video, probably to avoid initial black frames. The trouble is that PowerPoint takes the initial frame (at least in case of the bugdoc), so our snapshot doesn't match the reference. We already import a bitmap snapshot from PPTX files since commit e2d46da076f43a7c0d56fc486b9f15339243f7c9 (avmedia: add doc model for bitmap fill of slide narrations, 2021-01-21), fix the problem by changing the snapshot generation to prefer this bitmap over generating one from the video. The crop properties of this bitmap / the video are still not yet handled from PPTX. Change-Id: Id985eaaaad5e4222d9a98203d054e08a0f97a0f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138763 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/svx/qa/unit/data/video-snapshot.pptx b/svx/qa/unit/data/video-snapshot.pptx new file mode 100644 index 000000000000..9a0ec9ebd867 Binary files /dev/null and b/svx/qa/unit/data/video-snapshot.pptx differ diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx index 9ad02060d68e..1bb9a6dab4db 100644 --- a/svx/qa/unit/svdraw.cxx +++ b/svx/qa/unit/svdraw.cxx @@ -36,6 +36,7 @@ #include <comphelper/propertyvalue.hxx> #include <sfx2/viewsh.hxx> #include <svl/itempool.hxx> +#include <svx/svdomedia.hxx> #include <sdr/contact/objectcontactofobjlistpainter.hxx> @@ -483,6 +484,28 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testMaterialSpecular) // The first light is harsh, the second light soft. So the 3D scene should have 6 lights (1+1+4). assertXPath(pXmlDoc, "//light", 6); } + +CPPUNIT_TEST_FIXTURE(SvdrawTest, testVideoSnapshot) +{ + // Given a slide with a media shape, containing a 4 sec video, red-green-blue-black being the 4 + // seconds: + OUString aURL = m_directories.getURLFromSrc(u"svx/qa/unit/data/video-snapshot.pptx"); + mxComponent = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument"); + SdrPage* pSdrPage = getFirstDrawPageWithAssert(); + auto pSdrMediaObj = dynamic_cast<SdrMediaObj*>(pSdrPage->GetObj(0)); + + // When getting the red snapshot of the video: + Graphic aSnapshot(pSdrMediaObj->getSnapshot()); + + // Then make sure the color is correct: + const BitmapEx& rBitmap = aSnapshot.GetBitmapExRef(); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: rgba[ff0000ff] + // - Actual : rgba[000000ff] + // 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)); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx index f36e8aaa92e8..15a0e1179098 100644 --- a/svx/source/svdraw/svdomedia.cxx +++ b/svx/source/svdraw/svdomedia.cxx @@ -151,6 +151,15 @@ uno::Reference< graphic::XGraphic > const & SdrMediaObj::getSnapshot() const #if HAVE_FEATURE_AVMEDIA if( !m_xImpl->m_xCachedSnapshot.is() ) { + Graphic aGraphic = m_xImpl->m_MediaProperties.getGraphic(); + if (!aGraphic.IsNone()) + { + // 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(); + return m_xImpl->m_xCachedSnapshot; + } + OUString aRealURL = m_xImpl->m_MediaProperties.getTempURL(); if( aRealURL.isEmpty() ) aRealURL = m_xImpl->m_MediaProperties.getURL();