summaryrefslogtreecommitdiff
path: root/sw/source/filter/html
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-09-02 17:44:19 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-09-02 20:10:10 +0200
commit0d027abbc5609b096d2a954e77aa7354a55928ab (patch)
tree64211b90a0971fe42773bb1e0b3395480d0495e8 /sw/source/filter/html
parenta66e19a12f78882b053f8fa53ce1b6f1ce172d01 (diff)
sw reqif-xhtml export, embedded objects: take OLE1 pres data from rtf if needed
Next to the native data of an embedded object, the presentation data / replacement is included at several layers: - the OLE2 container may have it - the OLE1 container may have it - the RTF container may have it - the PNG file next to the RTF container may have it Given that various consumers pick one of the above, we try to provide presentation data in all layers. We already had code to generate the OLE1 presentation data from the OLE2 container, but we gave up for OLE1 in case the OLE2 container didn't have it. This means that in case the RTF container is wrapped in a proper RTF file, Word refuses the edit the embedded object. Fix the problem by taking the presentation data from RTF for OLE1 purposes, in case it's missing from the OLE2 container. Change-Id: I158db1c87044a3895d0c64a6e5a5384686627d96 (cherry picked from commit 5c37f5713a5b9e14fcc378d91e5ed8d40edc40a4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101946 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source/filter/html')
-rw-r--r--sw/source/filter/html/htmlreqifreader.cxx65
1 files changed, 39 insertions, 26 deletions
diff --git a/sw/source/filter/html/htmlreqifreader.cxx b/sw/source/filter/html/htmlreqifreader.cxx
index 87368da014bd..26119adfed46 100644
--- a/sw/source/filter/html/htmlreqifreader.cxx
+++ b/sw/source/filter/html/htmlreqifreader.cxx
@@ -229,10 +229,15 @@ OString InsertOLE1HeaderFromOle10NativeStream(tools::SvRef<SotStorage>& xStorage
return aClassName;
}
-/// Inserts an OLE1 header before an OLE2 storage.
+/**
+ * Writes an OLE1 header and data from rOle2 to rOle1.
+ *
+ * In case rOle2 has presentation data, then its size is written to nWidth/nHeight. Otherwise
+ * nWidth/nHeight/pPresentationData/nPresentationData is used for the presentation data.
+ */
OString InsertOLE1Header(SvStream& rOle2, SvStream& rOle1, sal_uInt32& nWidth, sal_uInt32& nHeight,
- SwOLENode& rOLENode, const sal_uInt8* /*pPresentationData*/,
- sal_uInt64 /*nPresentationData*/)
+ SwOLENode& rOLENode, const sal_uInt8* pPresentationData,
+ sal_uInt64 nPresentationData)
{
rOle2.Seek(0);
tools::SvRef<SotStorage> xStorage(new SotStorage(rOle2));
@@ -278,33 +283,41 @@ OString InsertOLE1Header(SvStream& rOle2, SvStream& rOle1, sal_uInt32& nWidth, s
// Write Presentation.
SvMemoryStream aPresentationData;
+ // OLEVersion.
+ rOle1.WriteUInt32(0x00000501);
+ // FormatID: constant means the ClassName field is present.
+ rOle1.WriteUInt32(0x00000005);
+ // ClassName: null terminated pascal string.
+ OString aPresentationClassName("METAFILEPICT");
+ rOle1.WriteUInt32(aPresentationClassName.getLength() + 1);
+ rOle1.WriteOString(aPresentationClassName);
+ rOle1.WriteChar(0);
+ const sal_uInt8* pBytes = nullptr;
+ sal_uInt64 nBytes = 0;
if (ParseOLE2Presentation(rOle2, nWidth, nHeight, aPresentationData))
{
// Take presentation data for OLE1 from OLE2.
- // OLEVersion.
- rOle1.WriteUInt32(0x00000501);
- // FormatID: constant means the ClassName field is present.
- rOle1.WriteUInt32(0x00000005);
- // ClassName: null terminated pascal string.
- OString aPresentationClassName("METAFILEPICT");
- rOle1.WriteUInt32(aPresentationClassName.getLength() + 1);
- rOle1.WriteOString(aPresentationClassName);
- rOle1.WriteChar(0);
- // Width.
- rOle1.WriteUInt32(nWidth);
- // Height.
- rOle1.WriteUInt32(nHeight * -1);
- // PresentationDataSize
- sal_uInt32 nPresentationData = aPresentationData.Tell();
- rOle1.WriteUInt32(8 + nPresentationData);
- // Reserved1-4.
- rOle1.WriteUInt16(0x0008);
- rOle1.WriteUInt16(0x31b1);
- rOle1.WriteUInt16(0x1dd9);
- rOle1.WriteUInt16(0x0000);
- aPresentationData.Seek(0);
- rOle1.WriteStream(aPresentationData, nPresentationData);
+ pBytes = static_cast<const sal_uInt8*>(aPresentationData.GetData());
+ nBytes = aPresentationData.Tell();
+ }
+ else
+ {
+ // Take presentation data for OLE1 from RTF.
+ pBytes = pPresentationData;
+ nBytes = nPresentationData;
}
+ // Width.
+ rOle1.WriteUInt32(nWidth);
+ // Height.
+ rOle1.WriteUInt32(nHeight * -1);
+ // PresentationDataSize
+ rOle1.WriteUInt32(8 + nPresentationData);
+ // Reserved1-4.
+ rOle1.WriteUInt16(0x0008);
+ rOle1.WriteUInt16(0x31b1);
+ rOle1.WriteUInt16(0x1dd9);
+ rOle1.WriteUInt16(0x0000);
+ rOle1.WriteBytes(pBytes, nBytes);
return aClassName;
}