This is similar to commit 8780fa41dc
(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