[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Apr 29 19:05:03 UTC 2021
sw/qa/extras/htmlexport/data/reqif-objdata-presentationdatasize.odt |binary
sw/qa/extras/htmlexport/htmlexport.cxx | 23 ++++++++++
sw/source/filter/html/htmlreqifreader.cxx | 4 -
3 files changed, 25 insertions(+), 2 deletions(-)
New commits:
commit 58607e1c410ee89ddfd47dcd128abfa00e0ac839
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Apr 29 17:21:54 2021 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Apr 29 21:04:07 2021 +0200
sw html/reqif export: fix size of presentation data for "real" OLE2 embedding
InsertOLE1Header() can either take its OLE1 presentation data (preview)
from OLE2 or from RTF (SwOLENode). The presentation data size we wrote
was incorrect in the OLE2 case case: nPresentationData is the RTF size,
nBytes is the actual buffer size.
In practice this made the embedded object non-editable in Word (when
trying to edit the RTF fragment).
This went wrong in commit 0d027abbc5609b096d2a954e77aa7354a55928ab (sw
reqif-xhtml export, embedded objects: take OLE1 pres data from rtf if
needed, 2020-09-02).
Change-Id: I89019202c9a8b40c1b9a21f611f1190fd50073a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114889
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/sw/qa/extras/htmlexport/data/reqif-objdata-presentationdatasize.odt b/sw/qa/extras/htmlexport/data/reqif-objdata-presentationdatasize.odt
new file mode 100644
index 000000000000..231a7c572a3a
Binary files /dev/null and b/sw/qa/extras/htmlexport/data/reqif-objdata-presentationdatasize.odt differ
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index 69dbc5b615b2..200aa3f9d3d9 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -1363,6 +1363,29 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifAscharObjsize)
CPPUNIT_ASSERT_EQUAL(static_cast<tools::Long>(4116), xReader->GetObjh());
}
+CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifObjdataPresentationDataSize)
+{
+ // Given a document with an OLE2 embedded object, containing a preview:
+ OUString aURL
+ = m_directories.getURLFromSrc(DATA_DIRECTORY) + "reqif-objdata-presentationdatasize.odt";
+ mxComponent = loadFromDesktop(aURL, "com.sun.star.text.TextDocument", {});
+
+ // When exporting to ReqIF:
+ ExportToReqif();
+
+ // Then make sure that the PresentationDataSize in the RTF's objdata blob is correct:
+ OUString aRtfUrl = GetOlePath();
+ SvMemoryStream aOle1;
+ ParseOle1FromRtfUrl(aRtfUrl, aOle1);
+ OLE1Reader aOle1Reader(aOle1);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 565994
+ // - Actual : 330240 (Linux)
+ // - Actual : 566034 (Windows, when Word is installed)
+ // because PresentationData was taken from the OLE2 stream but its size was taken from RTF.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(565994), aOle1Reader.m_nPresentationDataSize);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/html/htmlreqifreader.cxx b/sw/source/filter/html/htmlreqifreader.cxx
index 6c9155fbc556..253e3f44cb22 100644
--- a/sw/source/filter/html/htmlreqifreader.cxx
+++ b/sw/source/filter/html/htmlreqifreader.cxx
@@ -341,8 +341,8 @@ OString InsertOLE1Header(SvStream& rOle2, SvStream& rOle1, sal_uInt32& nWidth, s
rOle1.WriteUInt32(nWidth);
// Height.
rOle1.WriteUInt32(nHeight * -1);
- // PresentationDataSize
- rOle1.WriteUInt32(8 + nPresentationData);
+ // PresentationDataSize: size of (reserved fields + pBytes).
+ rOle1.WriteUInt32(8 + nBytes);
// Reserved1-4.
rOle1.WriteUInt16(0x0008);
rOle1.WriteUInt16(0x31b1);
More information about the Libreoffice-commits
mailing list