[Libreoffice-commits] core.git: Branch 'distro/vector/vector-5.4' - svtools/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Oct 30 16:56:42 UTC 2018
svtools/source/misc/embedhlp.cxx | 12 ++++++++++++
1 file changed, 12 insertions(+)
New commits:
commit 13162d054d628380bf488acd7971170212af005e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Tue Oct 30 12:23:36 2018 +0100
Commit: Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Tue Oct 30 17:07:56 2018 +0100
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.
Reviewed-on: https://gerrit.libreoffice.org/62549
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins
(cherry picked from commit 8780fa41dcd164af244742461f4e57a4bcf4c7a4)
Change-Id: I624c372baea56a85fb949bd99046f3af1f258c36
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index ec7eb7a87146..f4447bb1d5b1 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -403,8 +403,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 );
@@ -429,6 +434,13 @@ void EmbeddedObjectRef::GetReplacement( bool bUpdate )
rGF.ImportGraphic( *mpImpl->pGraphic, OUString(), *pGraphicStream );
mpImpl->mnGraphicVersion++;
}
+
+ if (bUpdate && mpImpl->pGraphic->GetType() == GraphicType::NONE && aOldGraphic.GetType() != GraphicType::NONE)
+ // 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
More information about the Libreoffice-commits
mailing list