diff options
Diffstat (limited to 'sd/qa/unit/export-tests.cxx')
-rw-r--r-- | sd/qa/unit/export-tests.cxx | 44 |
1 files changed, 44 insertions, 0 deletions
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(); |