summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-04-08 17:03:21 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-04-08 19:18:09 +0200
commitfb4dc0f1786e0a036fc224393e91a3f1fdbff1b3 (patch)
treef31f791e64437cde64cb6932c831abf91ebbca97 /sw
parent659d18f02ae078f8eeb7b9271f95492c8241cc9c (diff)
embeddedobj: fix lost native data when updating it via OLE fails
How to reproduce the problem: 1) Create an ODT file which has an OLE object, where the native data is an OLE2 container, containing a Package stream, containing a DOCX file. 2) Install some external application on Windows which registers itself as a handler for the DOCX CSLID [ this is where writing a testcase for this bug is challenging ]. 3) Open this document via Java, using URP. Load the document with Hidden=true and OnMainThread=true. 4) Dispatch .uno:UpdateAll 5) Save the document using XStorable.store() Expected result: the native data is there. Actual result: the native data is sometimes missing (0 bytes). Typically happens at least once if you perform the steps 4 times in a row. The root cause is that GetUserClassID() Win32 API fails in some cases, and re-trying a few times after a small sleep doesn't help. Handle this error better by detecting this situation in OleEmbeddedObject::SwitchOwnPersistence() and reusing the old native data, similar to how svt::EmbeddedObjectRef::GetReplacement() updates the preview image in a transactional way (only delete the old one when we have a one one). Finally, detect a broken OLE2 preview during reqif export, this way the reqif export result's embedded object is editable in Word, while \objdata was simply empty previously. Change-Id: I4dd34ebe6ad892a14cdcfb82acc82d9edf790fb3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113814 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/html/htmlreqifreader.cxx9
1 files changed, 9 insertions, 0 deletions
diff --git a/sw/source/filter/html/htmlreqifreader.cxx b/sw/source/filter/html/htmlreqifreader.cxx
index 40c932ad6332..c0a3196bb018 100644
--- a/sw/source/filter/html/htmlreqifreader.cxx
+++ b/sw/source/filter/html/htmlreqifreader.cxx
@@ -142,6 +142,15 @@ bool ParseOLE2Presentation(SvStream& rOle2, sal_uInt32& nWidth, sal_uInt32& nHei
// Read Data.
if (nSize > xOle2Presentation->remainingSize())
return false;
+
+ if (nSize <= 64)
+ {
+ SAL_WARN("sw.html",
+ "ParseOLE2Presentation: ignoring potentially broken small preview: size is "
+ << nSize);
+ return false;
+ }
+
std::vector<char> aBuffer(nSize);
xOle2Presentation->ReadBytes(aBuffer.data(), aBuffer.size());
rPresentationData.WriteBytes(aBuffer.data(), aBuffer.size());