diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-05-26 17:46:53 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-05-26 19:01:26 +0200 |
commit | 0e459bb3eb840ac1cab14c070973fb3b79bc13d8 (patch) | |
tree | 3e4ae97576f838606d972cda5c4ef48857f3aa9a /sw/qa | |
parent | f75549b4169f327faca88d5ce9d544bc6885bef1 (diff) |
sw XHTML / reqif export, RTF markup of images: write WMF in \pict
Some consumers (e.g. IBM Doors) can only consume the RTF snippet if it's
an OLE object and can't deal with plain images.
Wrap \pict inside \object and unconditionally use WMF as the RTF-level
preview format. The actual \objdata is not yet written.
Change-Id: I203fcd8709b25a4dd543047bd804af8181df9940
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116207
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 9a08d06b48cd..1fba03321840 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -61,12 +61,14 @@ public: bool WriteObjectData(SvStream& rOLE); tools::Long GetObjw() const { return m_nObjw; } tools::Long GetObjh() const { return m_nObjh; } + int getWmetafile() const { return m_nWmetafile; } private: bool m_bInObjData = false; OStringBuffer m_aHex; tools::Long m_nObjw = 0; tools::Long m_nObjh = 0; + int m_nWmetafile = 0; }; TestReqIfRtfReader::TestReqIfRtfReader(SvStream& rStream) @@ -94,6 +96,9 @@ void TestReqIfRtfReader::NextToken(int nToken) case RTF_OBJH: m_nObjh = nTokenValue; break; + case RTF_WMETAFILE: + m_nWmetafile = nTokenValue; + break; } } @@ -1448,6 +1453,32 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testBlockQuoteNoMargin) "string"); } +CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifImageToOle) +{ + // Given a document with an image: + loadURL("private:factory/swriter", nullptr); + OUString aImageURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "ole2.png"; + uno::Sequence<beans::PropertyValue> aArgs = { + comphelper::makePropertyValue("FileName", aImageURL), + }; + dispatchCommand(mxComponent, ".uno:InsertGraphic", aArgs); + + // When exporting to XHTML: + ExportToReqif(); + + // Then make sure we export that PNG as WMF in ReqIF mode: + OUString aRtfUrl = GetOlePath(); + SvMemoryStream aRtf; + HtmlExportTest::wrapRtfFragment(aRtfUrl, aRtf); + tools::SvRef<TestReqIfRtfReader> xReader(new TestReqIfRtfReader(aRtf)); + CPPUNIT_ASSERT(xReader->CallParser() != SvParserState::Error); + // Without the accompanying fix in place, this test would have failed: + // - Expected: 8 + // - Actual : 0 + // i.e. the image was exported as PNG, not as WMF (with a version). + CPPUNIT_ASSERT_EQUAL(8, xReader->getWmetafile()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |