summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-05-03 14:02:12 +0200
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2022-05-04 16:31:29 +0200
commitcb6f462b193c1e3f740dae4fd269b7e91b638d05 (patch)
treef4d0176219ded1201451754371217a921a9a12fe
parente3cca5bb02c52f92b8fc7b4b87ca2fc2b9615ead (diff)
do not allow reusing already used SalLayoutGlyphs (tdf#148477)
If the glyphs have already been used, the AdjustLayout() call in OutputDevice::ImplLayout might have altered them, since MultiSalLayout::ImplAdjustMultiLayout() drops glyphs that need falllback from the base layout. And then then GenericSalLayout::LayoutText() would not know to call SetNeedFallback(). Change-Id: I2f79d26c8b861f20d7d52abaa0d917aaeefb37a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133758 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com> (cherry picked from commit 22191901bc91535121a5e8dc7ee6137233824d36) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133726 Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r--vcl/source/outdev/text.cxx17
-rw-r--r--vcl/source/window/status.cxx8
2 files changed, 22 insertions, 3 deletions
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index b8b599cbc5ba..accbc2cfa0d7 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1309,6 +1309,23 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr,
SAL_WARN("vcl", "Trying to setup invalid cached glyphs - falling back to relayout!");
pGlyphs = nullptr;
}
+#ifdef DBG_UTIL
+ if (pGlyphs)
+ {
+ for( int level = 0;; ++level )
+ {
+ SalLayoutGlyphsImpl* glyphsImpl = pGlyphs->Impl(level);
+ if(glyphsImpl == nullptr)
+ break;
+ // It is allowed to reuse only glyphs created with SalLayoutFlags::GlyphItemsOnly.
+ // If the glyphs have already been used, the AdjustLayout() call below might have
+ // altered them (MultiSalLayout::ImplAdjustMultiLayout() drops glyphs that need
+ // fallback from the base layout, but then GenericSalLayout::LayoutText()
+ // would not know to call SetNeedFallback()).
+ assert(glyphsImpl->GetFlags() & SalLayoutFlags::GlyphItemsOnly);
+ }
+ }
+#endif
if (!InitFont())
return nullptr;
diff --git a/vcl/source/window/status.cxx b/vcl/source/window/status.cxx
index 755bf9643585..42ffb05ea5ae 100644
--- a/vcl/source/window/status.cxx
+++ b/vcl/source/window/status.cxx
@@ -394,7 +394,7 @@ void StatusBar::ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen
if(!pLayoutCache)
{
// update cache
- pItem->mxLayoutCache = rRenderContext.ImplLayout(pItem->maText, 0, -1);
+ pItem->mxLayoutCache = rRenderContext.ImplLayout(pItem->maText, 0, -1, Point(0, 0), 0, {}, SalLayoutFlags::GlyphItemsOnly);
pLayoutCache = pItem->mxLayoutCache.get();
}
@@ -1139,14 +1139,16 @@ void StatusBar::SetItemText( sal_uInt16 nItemId, const OUString& rText, int nCha
tools::Long nWidth;
if (nCharsWidth != -1)
{
- std::unique_ptr<SalLayout> pSalLayout = GetOutDev()->ImplLayout("0",0,-1);
+ std::unique_ptr<SalLayout> pSalLayout = GetOutDev()->ImplLayout("0",0,-1,
+ Point(0, 0), 0, {}, SalLayoutFlags::GlyphItemsOnly);
const SalLayoutGlyphs glyphs = pSalLayout ? pSalLayout->GetGlyphs() : SalLayoutGlyphs();
nWidth = GetTextWidth("0",0,-1,nullptr,pSalLayout ? &glyphs : nullptr);
nWidth = nWidth * nCharsWidth + nFudge;
}
else
{
- std::unique_ptr<SalLayout> pSalLayout = GetOutDev()->ImplLayout(pItem->maText,0,-1);
+ std::unique_ptr<SalLayout> pSalLayout = GetOutDev()->ImplLayout(pItem->maText,0,-1,
+ Point(0, 0), 0, {}, SalLayoutFlags::GlyphItemsOnly);
const SalLayoutGlyphs glyphs = pSalLayout ? pSalLayout->GetGlyphs() : SalLayoutGlyphs();
nWidth = GetTextWidth( pItem->maText,0,-1,nullptr,pSalLayout ? &glyphs : nullptr) + nFudge;
// Store the calculated layout.