cache also failures in SalLayoutGlyphsCache

This is what 3f69ec9ab4236de13d229f675943123aeb42ea29 did in Writer.

Change-Id: I40fb49ce83fd24f16050318c523d87603300b06d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131392
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index 0d8c224..1fefe68 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -99,8 +99,15 @@ SalLayoutGlyphsCache::GetLayoutGlyphs(const OUString& text, VclPtr<OutputDevice>
{
    const CachedGlyphsKey key(text, outputDevice);
    auto it = mCachedGlyphs.find(key);
    if (it != mCachedGlyphs.end() && it->second.IsValid())
        return &it->second;
    if (it != mCachedGlyphs.end())
    {
        if (it->second.IsValid())
            return &it->second;
        // Do not try to create the layout here. If a cache item exists, it's already
        // been attempted and the layout was invalid (this happens with MultiSalLayout).
        // So in that case this is a cached failure.
        return nullptr;
    }
    std::unique_ptr<SalLayout> layout = outputDevice->ImplLayout(
        text, 0, text.getLength(), Point(0, 0), 0, {}, SalLayoutFlags::GlyphItemsOnly);
    if (layout)