oox/source/drawingml/misccontexts.cxx | 6 +++++- sd/qa/unit/export-tests.cxx | 15 +++++++++++++-- sw/qa/extras/globalfilter/globalfilter.cxx | 17 +++++++++++++---- 3 files changed, 31 insertions(+), 7 deletions(-)
New commits: commit a010567c2cdb8ea0fe059b0b64fd5d1f2fd99a03 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Dec 6 16:55:01 2023 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Dec 8 03:55:42 2023 +0100 tdf#126084 document OOXML SVG tests and import Change-Id: Ief29d04f2f0693a4cdfa44c7c100ac6164da38f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160378 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/oox/source/drawingml/misccontexts.cxx b/oox/source/drawingml/misccontexts.cxx index 244d17d9fc62..93d2c8ee411b 100644 --- a/oox/source/drawingml/misccontexts.cxx +++ b/oox/source/drawingml/misccontexts.cxx @@ -619,20 +619,24 @@ ContextHandlerRef BlipExtensionContext::onCreateContext(sal_Int32 nElement, cons case OOX_TOKEN(a14, imgProps): return new ArtisticEffectContext(*this, mrBlipProps.maEffect); + // Import the SVG Blip case OOX_TOKEN(asvg, svgBlip): { if (rAttribs.hasAttribute(R_TOKEN(embed))) { - // internal picture URL OUString aFragmentPath = getFragmentPathFromRelId(rAttribs.getStringDefaulted(R_TOKEN(embed))); if (!aFragmentPath.isEmpty()) { + // Read the graphic from the fragment path auto xGraphic = getFilter().getGraphicHelper().importEmbeddedGraphic(aFragmentPath); + + // Overwrite the fill graphic with the one contining SVG mrBlipProps.mxFillGraphic = xGraphic; if (mpBlipFill) mpBlipFill->mxGraphic = xGraphic; } } + // TODO - link } break; } diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 92b36ecacce7..428b09e983a1 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -1933,10 +1933,12 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testSvgImageSupport) { // Load the original file createSdImpressDoc("odp/SvgImageTest.odp"); - const OString sFailedMessage = "Failed on filter: " + rFormat.toUtf8(); + // Save into the target format saveAndReload(rFormat); - // Check whether graphic was exported well + const OString sFailedMessage = "Failed on filter: " + 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), @@ -1944,15 +1946,24 @@ CPPUNIT_TEST_FIXTURE(SdExportTest, testSvgImageSupport) 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()); } diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx index 3eda6b6354e8..9d7c28b83ff8 100644 --- a/sw/qa/extras/globalfilter/globalfilter.cxx +++ b/sw/qa/extras/globalfilter/globalfilter.cxx @@ -2225,28 +2225,37 @@ void Test::testSvgImageSupport() for (OUString const & rFilterName : aFilterNames) { - // Check whether the export code swaps in the image which was swapped out before by auto mechanism + // Use case to import a document containing a SVG image, export in target format, import and check if the + // SVG image is present and as expected in the document + // Import ODT file createSwDoc("SvgImageTest.odt"); - // Export the document and import again for a check + // Export the document in target format and import again saveAndReload(rFilterName); - // Check whether graphic exported well after it was swapped out + // Prepare fail message (writing which import/export filter was used) const OString sFailedMessage = "Failed on filter: "_ostr + rFilterName.toUtf8(); CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), 1, getShapes()); - // First image + // Get the image uno::Reference<drawing::XShape> xImage(getShape(1), 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()); } }