diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-09-25 09:03:54 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2023-12-10 12:37:35 +0100 |
commit | 1e7cd7da0b216557f836e3cb031bca47c2364b1e (patch) | |
tree | 48455e5397e45b20f3d6b12973d8a7279d41c0d7 /sd | |
parent | 1372b6e33d0ce3e831ca553c5148655e97615d84 (diff) |
tdf#126084 import svg image from ooxml document that use svgBlip elem.
In an OOXML document the svg image is defined in an svgBlip, which
is an OOXML extension. This change checks for the svgBlip element
and imports that instead the normal "blip" element that is still
provided as a fallback (PNG image).
Add roundtrip SVG image test for ODF and OOXML, Impress and Writer.
testGraphicBlipXLSX test failed after this change, because some
component was missing. Changed to enable use_rdb for all chart2
export tests, so issues like this won't happen anymore.
Change-Id: Idf0e754775254d7dcfd0321dfca2ed6d00c42c09
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157238
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit 1db193c6c744289139b1df2af0b8defcf974b238)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160384
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/odp/SvgImageTest.odp | bin | 0 -> 15922 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests.cxx | 44 |
2 files changed, 44 insertions, 0 deletions
diff --git a/sd/qa/unit/data/odp/SvgImageTest.odp b/sd/qa/unit/data/odp/SvgImageTest.odp Binary files differnew file mode 100644 index 000000000000..38b92df80896 --- /dev/null +++ b/sd/qa/unit/data/odp/SvgImageTest.odp diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 029ee7267054..1c4bf622876a 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -103,6 +103,7 @@ public: void testCellProperties(); void testUserTableStyles(); void testTdf153179(); + void testSvgImageSupport(); CPPUNIT_TEST_SUITE(SdExportTest); @@ -156,6 +157,7 @@ public: CPPUNIT_TEST(testCellProperties); CPPUNIT_TEST(testUserTableStyles); CPPUNIT_TEST(testTdf153179); + CPPUNIT_TEST(testSvgImageSupport); CPPUNIT_TEST_SUITE_END(); virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override @@ -1858,6 +1860,48 @@ void SdExportTest::testTdf153179() CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getPage(0)->getCount()); } +void SdExportTest::testSvgImageSupport() +{ + for (std::u16string_view rFormat : { u"impress8", u"Impress Office Open XML" }) + { + // Load the original file + createSdImpressDoc("odp/SvgImageTest.odp"); + // Save into the target format + saveAndReload(OUString(rFormat)); + + const OString sFailedMessage = "Failed on filter: " + OUString(rFormat).toUtf8(); + + // Check whether SVG graphic was exported as expected + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, + uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(1), + xDrawPagesSupplier->getDrawPages()->getCount()); + uno::Reference<drawing::XDrawPage> xDrawPage( + xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xDrawPage.is()); + + // Get the image + uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(0), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xImage, uno::UNO_QUERY_THROW); + + // Convert to a XGraphic + uno::Reference<graphic::XGraphic> xGraphic; + xPropertySet->getPropertyValue("Graphic") >>= xGraphic; + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is()); + + // Access the Graphic + Graphic aGraphic(xGraphic); + + // Check if it contian a VectorGraphicData struct + auto pVectorGraphic = aGraphic.getVectorGraphicData(); + CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pVectorGraphic); + + // Which should be of type SVG, which means we have a SVG file + CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), VectorGraphicDataType::Svg, + pVectorGraphic->getType()); + } +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); |