diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-08-29 09:23:22 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-08-29 16:51:26 +0200 |
commit | 3b88c304dce2e9d64b9d19b25ed57df5b581e834 (patch) | |
tree | 2dd809e7cd95843a8e3fdcc8261bbe2daf5c5ecb /xmloff/qa/unit | |
parent | 6894da107db06c66356e52844c4a8d263e0a64d8 (diff) |
avmedia: implement video crop support in the ODP filter
And also import/export the video preview as well. The naming follows the
style used for table shape previews.
The preview is important, since the cropping is relative to the bitmap's
preferred logic size.
(cherry picked from commit cbc6e67d3c88fb6ae39c304604a98eaa504f19cc)
Conflicts:
xmloff/qa/unit/draw.cxx
xmloff/source/draw/shapeexport.cxx
Change-Id: I6115284c1f4cf342b3296cd0ac3beb70a809fd1b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138970
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'xmloff/qa/unit')
-rw-r--r-- | xmloff/qa/unit/data/video-snapshot.odp | bin | 0 -> 17605 bytes | |||
-rw-r--r-- | xmloff/qa/unit/draw.cxx | 50 |
2 files changed, 50 insertions, 0 deletions
diff --git a/xmloff/qa/unit/data/video-snapshot.odp b/xmloff/qa/unit/data/video-snapshot.odp Binary files differnew file mode 100644 index 000000000000..ca3b7f21dc6c --- /dev/null +++ b/xmloff/qa/unit/data/video-snapshot.odp diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index 0b7c93c89073..a31c98be5a02 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -21,10 +21,14 @@ #include <com/sun/star/drawing/XDrawPagesSupplier.hpp> #include <com/sun/star/drawing/XMasterPageTarget.hpp> #include <com/sun/star/util/Color.hpp> +#include <com/sun/star/text/GraphicCrop.hpp> #include <unotools/mediadescriptor.hxx> #include <unotools/tempfile.hxx> #include <unotools/ucbstreamhelper.hxx> +#include <svx/unopage.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdomedia.hxx> using namespace ::com::sun::star; @@ -155,6 +159,52 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeExport) assertXPath(pXmlDoc, "//style:master-page/loext:theme/loext:color-table/loext:color", 12); } +CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testVideoSnapshot) +{ + // Execute ODP import: + OUString aURL = m_directories.getURLFromSrc(u"xmloff/qa/unit/data/video-snapshot.odp"); + getComponent() = loadFromDesktop(aURL, "com.sun.star.presentation.PresentationDocument"); + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(getComponent(), + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xDrawPagesSupplier.is()); + uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages()); + uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xDrawPage.is()); + auto pUnoPage = dynamic_cast<SvxDrawPage*>(xDrawPage.get()); + SdrPage* pSdrPage = pUnoPage->GetSdrPage(); + auto pMedia = dynamic_cast<SdrMediaObj*>(pSdrPage->GetObj(0)); + + // Check that the preview was imported: + const avmedia::MediaItem& rItem = pMedia->getMediaProperties(); + const Graphic& rGraphic = rItem.getGraphic(); + CPPUNIT_ASSERT(!rGraphic.IsNone()); + + // Check that the crop was imported: + const text::GraphicCrop& rCrop = rItem.getCrop(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), rCrop.Top); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), rCrop.Bottom); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1356), rCrop.Left); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1356), rCrop.Right); + + // Execute ODP export: + utl::TempFile aTempFile; + save("impress8", aTempFile); + + std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, "content.xml"); + xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); + // Check that the preview was exported: + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 + // - Actual : 0 + // - XPath '//draw:frame[@draw:style-name='gr1']/draw:image' number of nodes is incorrect + // i.e. the preview wasn't exported to ODP. + assertXPath(pXmlDoc, "//draw:frame[@draw:style-name='gr1']/draw:image", "href", + "Pictures/MediaPreview1.png"); + // Check that the crop was exported: + assertXPath(pXmlDoc, "//style:style[@style:name='gr1']/style:graphic-properties", "clip", + "rect(0cm, 1.356cm, 0cm, 1.356cm)"); +} + CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeImport) { // Given a document that has a master page with a theme associated: |