sw/qa/extras/htmlexport/htmlexport.cxx | 94 ++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 42 deletions(-)
New commits: commit 014b481326f98ff9202f7c1fa9a9e2ee91c56355 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Apr 26 20:32:05 2023 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Apr 27 08:15:20 2023 +0200 CppunitTest_sw_htmlexport: avoid reqif magic in testReqIfOleImg Set the filter options explicitly, rather than inferring it from the test name. Change-Id: I5726642d932a495ff2158d3a0ed9c242a5c13278 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151073 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 92cc07213d56..c40307db7da5 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -714,50 +714,60 @@ CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfOleData) verify(); } -DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testReqIfOleImg, "reqif-ole-img.xhtml") +CPPUNIT_TEST_FIXTURE(HtmlExportTest, testReqIfOleImg) { - uno::Reference<text::XTextEmbeddedObjectsSupplier> xSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xObjects(xSupplier->getEmbeddedObjects(), - uno::UNO_QUERY); - uno::Reference<document::XEmbeddedObjectSupplier2> xObject(xObjects->getByIndex(0), - uno::UNO_QUERY); - // This failed, OLE object had no replacement image. - // And then it also failed when the export lost the replacement image. - uno::Reference<graphic::XGraphic> xGraphic = xObject->getReplacementGraphic(); - // This failed when query and fragment of file:// URLs were not ignored. - CPPUNIT_ASSERT(xGraphic.is()); - - uno::Reference<drawing::XShape> xShape(xObject, uno::UNO_QUERY); - OutputDevice* pDevice = Application::GetDefaultDevice(); - Size aPixel(64, 64); - // Expected to be 1693. - Size aLogic(pDevice->PixelToLogic(aPixel, MapMode(MapUnit::Map100thMM))); - awt::Size aSize = xShape->getSize(); - // This was only 1247, size was not set explicitly. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(aLogic.getWidth()), aSize.Width); - - // Check mime/media types. - CPPUNIT_ASSERT_EQUAL(OUString("image/png"), getProperty<OUString>(xGraphic, "MimeType")); - - uno::Reference<beans::XPropertySet> xObjectProps(xObject, uno::UNO_QUERY); - uno::Reference<io::XActiveDataStreamer> xStreamProvider( - xObjectProps->getPropertyValue("EmbeddedObject"), uno::UNO_QUERY); - uno::Reference<io::XSeekable> xStream(xStreamProvider->getStream(), uno::UNO_QUERY); - // This was empty when either import or export handling was missing. - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(37888), xStream->getLength()); - - // Check alternate text (it was empty, for export the 'alt' attribute was used). - CPPUNIT_ASSERT_EQUAL(OUString("OLE Object"), getProperty<OUString>(xObject, "Title").trim()); - - if (!isExported()) - return; + auto verify = [this]() { + uno::Reference<text::XTextEmbeddedObjectsSupplier> xSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xObjects(xSupplier->getEmbeddedObjects(), + uno::UNO_QUERY); + uno::Reference<document::XEmbeddedObjectSupplier2> xObject(xObjects->getByIndex(0), + uno::UNO_QUERY); + // This failed, OLE object had no replacement image. + // And then it also failed when the export lost the replacement image. + uno::Reference<graphic::XGraphic> xGraphic = xObject->getReplacementGraphic(); + // This failed when query and fragment of file:// URLs were not ignored. + CPPUNIT_ASSERT(xGraphic.is()); + + uno::Reference<drawing::XShape> xShape(xObject, uno::UNO_QUERY); + OutputDevice* pDevice = Application::GetDefaultDevice(); + Size aPixel(64, 64); + // Expected to be 1693. + Size aLogic(pDevice->PixelToLogic(aPixel, MapMode(MapUnit::Map100thMM))); + awt::Size aSize = xShape->getSize(); + // This was only 1247, size was not set explicitly. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(aLogic.getWidth()), aSize.Width); + + // Check mime/media types. + CPPUNIT_ASSERT_EQUAL(OUString("image/png"), getProperty<OUString>(xGraphic, "MimeType")); + + uno::Reference<beans::XPropertySet> xObjectProps(xObject, uno::UNO_QUERY); + uno::Reference<io::XActiveDataStreamer> xStreamProvider( + xObjectProps->getPropertyValue("EmbeddedObject"), uno::UNO_QUERY); + uno::Reference<io::XSeekable> xStream(xStreamProvider->getStream(), uno::UNO_QUERY); + // This was empty when either import or export handling was missing. + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int64>(37888), xStream->getLength()); + + // Check alternate text (it was empty, for export the 'alt' attribute was used). + CPPUNIT_ASSERT_EQUAL(OUString("OLE Object"), + getProperty<OUString>(xObject, "Title").trim()); + + if (!isExported()) + return; - // "type" attribute was missing for the inner <object> element. - SvStream* pStream = maTempFile.GetStream(StreamMode::READ); - CPPUNIT_ASSERT(pStream); - sal_uInt64 nLength = pStream->TellEnd(); - OString aStream(read_uInt8s_ToOString(*pStream, nLength)); - CPPUNIT_ASSERT(aStream.indexOf("type=\"image/png\"") != -1); + // "type" attribute was missing for the inner <object> element. + SvStream* pStream = maTempFile.GetStream(StreamMode::READ); + CPPUNIT_ASSERT(pStream); + sal_uInt64 nLength = pStream->TellEnd(); + OString aStream(read_uInt8s_ToOString(*pStream, nLength)); + CPPUNIT_ASSERT(aStream.indexOf("type=\"image/png\"") != -1); + }; + setImportFilterOptions("xhtmlns=reqif-xhtml"); + setImportFilterName("HTML (StarWriter)"); + createSwDoc("reqif-ole-img.xhtml"); + verify(); + setFilterOptions("xhtmlns=reqif-xhtml"); + reload(mpFilter, "reqif-ole-img.xhtml"); + verify(); } CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqIfPngImg)