[Libreoffice-commits] core.git: svtools/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Oct 30 12:52:49 UTC 2018


 svtools/source/misc/embedhlp.cxx |   12 ++++++++++++
 1 file changed, 12 insertions(+)

New commits:
commit 8780fa41dcd164af244742461f4e57a4bcf4c7a4
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 13:52:23 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.
    
    Change-Id: I624c372baea56a85fb949bd99046f3af1f258c36
    Reviewed-on: https://gerrit.libreoffice.org/62549
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins

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


More information about the Libreoffice-commits mailing list