diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-10-30 12:23:36 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-10-30 13:52:23 +0100 |
commit | 8780fa41dcd164af244742461f4e57a4bcf4c7a4 (patch) | |
tree | 18e3a948601ed7fc59eb3c4a8176b6ff01ffceeb /svtools/source | |
parent | b0c475a00ced9ec1e4ef1efb9d184ee8e2a3eaab (diff) |
svtools: fix lost replacement grpahic 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 i
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) Load the ODT file in hidden mode, e.g. connect to a
./soffice "--accept=socket,host=localhost,port=9999;urp;StarOffice.ServiceManager"
process from remote Java, load the file with Hidden=true in the
Arguments parameter of loadComponentFromURL().
4) Save it in a format that reads the replacement graphic of OLE
objects, like HTML or DOC.
Expected result: the replacement graphic is there.
Actual result: the <img> tag has no src attribute (HTML case).
The root cause is that in case the document is loaded in hidden mode
then the IDataObject::GetData() call in OleComponent::getTransferData()
fails, so the OLE objects enters a state where it no longer has its old
replacement graphic, but it doesn't have a new one, either.
Fix the problem by making this update more transactional in
svt::EmbeddedObjectRef::GetReplacement(), so the "document conversion"
scenario (load in one format in hidden frame, save in other format)
works.
Change-Id: I624c372baea56a85fb949bd99046f3af1f258c36
Reviewed-on: https://gerrit.libreoffice.org/62549
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'svtools/source')
-rw-r--r-- | svtools/source/misc/embedhlp.cxx | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx index 1b3c87c2332c..f321f0ed4b1a 100644 --- a/svtools/source/misc/embedhlp.cxx +++ b/svtools/source/misc/embedhlp.cxx @@ -399,8 +399,13 @@ bool EmbeddedObjectRef::IsLocked() const void EmbeddedObjectRef::GetReplacement( bool bUpdate ) { + Graphic aOldGraphic; + if ( bUpdate ) { + if (mpImpl->pGraphic) + aOldGraphic = Graphic(*mpImpl->pGraphic); + mpImpl->pGraphic.reset(); mpImpl->aMediaType.clear(); mpImpl->pGraphic.reset( new Graphic ); @@ -425,6 +430,13 @@ void EmbeddedObjectRef::GetReplacement( bool bUpdate ) rGF.ImportGraphic( *mpImpl->pGraphic, OUString(), *pGraphicStream ); mpImpl->mnGraphicVersion++; } + + if (bUpdate && !*mpImpl->pGraphic && aOldGraphic) + // We used to have an old graphic, tried to update and the update + // failed. Go back to the old graphic instead of having no graphic at + // all. + (*mpImpl->pGraphic) = aOldGraphic; + SAL_WARN("svtools.misc", "EmbeddedObjectRef::GetReplacement: update failed"); } const Graphic* EmbeddedObjectRef::GetGraphic() const |