summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-02-17 18:00:24 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-02-17 19:07:32 +0100
commit24231f2a336c50eac5e6a1621c57e60ebe1e1cf4 (patch)
tree873e3d0096ca7661077af6b213aea8b74cda74d0 /svtools
parentb69dc9faac1bc5409f43160228703108a002ed11 (diff)
svtools: fix lost replacement non-rendered graphic when updating it fails
This is similar to commit 8780fa41dcd164af244742461f4e57a4bcf4c7a4 (svtools: fix lost replacement grpahic when updating it via OLE fails, 2018-10-30), but that case was when we already had an old mpImpl->pGraphic, the updated failed and then we already lost the old one but didn't have a new one. Here what happened is that in case tools -> update -> update-all was used for an OLE object which had bad native data but a good preview, then the result was bad preview, depending on if you first scrolled to the OLE object to trigger rendering (good) or not (bad). The reason for this is that scrolling to the object calls GetGraphic(), which sets mpImpl->pGraphic using GetReplacement(bUpdate=false), which works, but svt::EmbeddedObjectRef::UpdateReplacement() calls GetReplacement(bUpdate=true). That explains why the update breaks the preview, but not when scrolling to it first. Fix the problem by improving svt::EmbeddedObjectRef::GetReplacement(): if getting an updated graphic fails, try to get a non-updated graphic. The result is that GetGraphic() after an UpdateReplacement() not only always return a non-nullptr Graphic, but also it's no longer of type None. Change-Id: I8e5ff4aaaefdc58e032b325bb4001f2a604ccc8a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130086 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/misc/embedhlp.cxx11
1 files changed, 10 insertions, 1 deletions
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index 4f4a5ce3e364..6e56dc3137e8 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -471,6 +471,15 @@ void EmbeddedObjectRef::GetReplacement( bool bUpdate )
}
std::unique_ptr<SvStream> pGraphicStream(GetGraphicStream( bUpdate ));
+ if (!pGraphicStream && aOldGraphic.IsNone())
+ {
+ // We have no old graphic, tried to get an updated one, but that failed. Try to get an old
+ // graphic instead of having no graphic at all.
+ pGraphicStream = GetGraphicStream(false);
+ SAL_WARN("svtools.misc",
+ "EmbeddedObjectRef::GetReplacement: failed to get updated graphic stream");
+ }
+
if ( pGraphicStream )
{
GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
@@ -487,7 +496,7 @@ void EmbeddedObjectRef::GetReplacement( bool bUpdate )
// failed. Go back to the old graphic instead of having no graphic at
// all.
mpImpl->pGraphic.reset(new Graphic(aOldGraphic));
- SAL_WARN("svtools.misc", "EmbeddedObjectRef::GetReplacement: update failed");
+ SAL_WARN("svtools.misc", "EmbeddedObjectRef::GetReplacement: failed to update graphic");
}
}