sw/qa/extras/htmlexport/htmlexport.cxx | 10 +++--- sw/source/filter/html/htmlreqifreader.cxx | 48 +++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 16 deletions(-)
New commits: commit 5fbd20682f34c817359156889ecbc3ad8290d72c Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri May 28 16:02:50 2021 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri May 28 20:40:21 2021 +0200 sw XHTML / reqif export, RTF markup of images: write OLE1 presentation data With this, images are exported as PBrush OLE objects, to please some consumers (e.g. IBM Doors). Change-Id: I89805cd66709d96cbe71853d65671f76a3fc871f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116348 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index 9ff771a7d43c..2dd946c03bfe 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -163,11 +163,6 @@ OLE1Reader::OLE1Reader(SvStream& rStream) rStream.ReadUInt32(m_nNativeDataSize); rStream.SeekRel(m_nNativeDataSize); - if (!rStream.remainingSize()) - { - return; - } - rStream.ReadUInt32(nData); // OLEVersion for presentation data CPPUNIT_ASSERT(rStream.good()); rStream.ReadUInt32(nData); // FormatID @@ -1490,6 +1485,11 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifImageToOle) // Without the accompanying fix in place, this test would have failed, as aOle1 was empty. OLE1Reader aOle1Reader(aOle1); CPPUNIT_ASSERT(aOle1Reader.m_nNativeDataSize); + + // Make sure that the presentation data byte array is not empty. + // Without the accompanying fix in place, this test would have failed, as aOle1 only contained + // the native data. + CPPUNIT_ASSERT(aOle1Reader.m_nPresentationDataSize); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/html/htmlreqifreader.cxx b/sw/source/filter/html/htmlreqifreader.cxx index 81f980b8ca37..8cd2728ef7c6 100644 --- a/sw/source/filter/html/htmlreqifreader.cxx +++ b/sw/source/filter/html/htmlreqifreader.cxx @@ -555,17 +555,6 @@ bool WrapGraphicInRtf(const Graphic& rGraphic, const SwFrameFormat& rFormat, SvS aNativeData.Seek(0); aOle1.WriteStream(aNativeData); - // TODO Write Presentation. - - // End objdata. - msfilter::rtfutil::WriteHex(static_cast<const sal_uInt8*>(aOle1.GetData()), aOle1.GetSize(), - &rRtf); - rRtf.WriteCharPtr("}"); - rRtf.WriteOString(SAL_NEWLINE_STRING); - - rRtf.WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_RESULT); - rRtf.WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_PICT); - // Prepare presentation data. const sal_uInt8* pPresentationData = nullptr; sal_uInt64 nPresentationData = 0; @@ -580,6 +569,43 @@ bool WrapGraphicInRtf(const Graphic& rGraphic, const SwFrameFormat& rFormat, SvS msfilter::rtfutil::StripMetafileHeader(pPresentationData, nPresentationData); } + // Write Presentation. + // OLEVersion. + aOle1.WriteUInt32(0x00000501); + // FormatID: constant means the ClassName field is present. + aOle1.WriteUInt32(0x00000005); + // ClassName: null terminated pascal string. + OString aPresentationClassName("METAFILEPICT"); + aOle1.WriteUInt32(aPresentationClassName.getLength() + 1); + aOle1.WriteOString(aPresentationClassName); + aOle1.WriteChar(0); + const sal_uInt8* pBytes = nullptr; + sal_uInt64 nBytes = 0; + // Take presentation data for OLE1 from RTF. + pBytes = pPresentationData; + nBytes = nPresentationData; + // Width. + aOle1.WriteUInt32(nWidth); + // Height. + aOle1.WriteUInt32(nHeight * -1); + // PresentationDataSize: size of (reserved fields + pBytes). + aOle1.WriteUInt32(8 + nBytes); + // Reserved1-4. + aOle1.WriteUInt16(0x0008); + aOle1.WriteUInt16(0x31b1); + aOle1.WriteUInt16(0x1dd9); + aOle1.WriteUInt16(0x0000); + aOle1.WriteBytes(pBytes, nBytes); + + // End objdata. + msfilter::rtfutil::WriteHex(static_cast<const sal_uInt8*>(aOle1.GetData()), aOle1.GetSize(), + &rRtf); + rRtf.WriteCharPtr("}"); + rRtf.WriteOString(SAL_NEWLINE_STRING); + + rRtf.WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_RESULT); + rRtf.WriteCharPtr("{" OOO_STRING_SVTOOLS_RTF_PICT); + Size aMapped(rGraphic.GetPrefSize()); rRtf.WriteCharPtr(OOO_STRING_SVTOOLS_RTF_PICW); rRtf.WriteOString(OString::number(aMapped.Width())); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits