summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2019-01-23 19:59:45 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2019-01-25 19:03:55 +0100
commit8d7435aa72af7fd0b454d7314c6c79f61f112679 (patch)
tree2146ba9fc325c4c5f7a2e40c23c59afe7e57a28d
parentd33998a2851eef17ccd0a85f24df587302df7c9c (diff)
Assert missing SalGraphics font on GetTextLayout
Trying to layout text without a font can't work. Without a font, currently the text is simply not painted, but this is still a programming error, so warn the developer. And we can get rid of all the intermediate OutputDevice font and gpahics checks, as everything now uses Harfbuzz and there won't be any layout which can't use the cached runs, so just generate them directly. Change-Id: Iae1fab0afeefec1cb1ca82c4e5d8dcbe9919859d Reviewed-on: https://gerrit.libreoffice.org/66818 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
-rw-r--r--include/vcl/outdev.hxx2
-rw-r--r--include/vcl/vcllayout.hxx2
-rw-r--r--sc/source/ui/view/output2.cxx4
-rw-r--r--sw/source/core/text/inftxt.cxx2
-rw-r--r--vcl/inc/sallayout.hxx2
-rw-r--r--vcl/qt5/Qt5Graphics_Text.cxx1
-rw-r--r--vcl/quartz/salgdi.cxx1
-rw-r--r--vcl/source/gdi/CommonSalLayout.cxx9
-rw-r--r--vcl/source/gdi/sallayout.cxx6
-rw-r--r--vcl/source/outdev/text.cxx10
-rw-r--r--vcl/unx/generic/gdi/cairotextrender.cxx1
-rw-r--r--vcl/unx/generic/print/genpspgraphics.cxx1
-rw-r--r--vcl/win/gdi/winlayout.cxx1
13 files changed, 16 insertions, 26 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 3fa9d2167d27..6c499307a7f1 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1155,7 +1155,7 @@ public:
sal_Int32 nIndex, sal_Int32 nLen,
long nCharExtra,
vcl::TextLayoutCache const* = nullptr) const;
- std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&) const;
+ static std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&);
protected:
SAL_DLLPRIVATE void ImplInitTextLineSize();
diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx
index 44752b6e4e06..0c32b71d5197 100644
--- a/include/vcl/vcllayout.hxx
+++ b/include/vcl/vcllayout.hxx
@@ -101,8 +101,6 @@ public:
virtual bool GetOutline(basegfx::B2DPolyPolygonVector&) const;
bool GetBoundRect(tools::Rectangle&) const;
- virtual std::shared_ptr<vcl::TextLayoutCache>
- CreateTextLayoutCache(OUString const&) const;
virtual const SalLayoutGlyphs* GetGlyphs() const;
protected:
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 808aae367f94..5fecb743df94 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -2070,7 +2070,7 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co
if (aDX.size() < nLen)
aDX.resize(nLen, 0);
- pFmtDevice->GetTextArray(aShort, &aDX[0]);
+ pFmtDevice->GetTextArray(aShort, aDX.data());
if ( !mpRefDevice->GetConnectMetaFile() ||
mpRefDevice->GetOutDevType() == OUTDEV_PRINTER )
@@ -2081,7 +2081,7 @@ tools::Rectangle ScOutputData::LayoutStrings(bool bPixelToLogic, bool bPaint, co
}
if (bPaint)
- mpDev->DrawTextArray(aDrawTextPos, aShort, &aDX[0]);
+ mpDev->DrawTextArray(aDrawTextPos, aShort, aDX.data());
}
else
{
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index ab89e4c6f38d..cb3668dbb710 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -1412,7 +1412,7 @@ void SwTextFormatInfo::CtorInitTextFormatInfo( OutputDevice* pRenderContext, SwT
// set digit mode to what will be used later to get same results
SwDigitModeModifier const m(*m_pRef, LANGUAGE_NONE /*dummy*/);
assert(m_pRef->GetDigitLanguage() != LANGUAGE_NONE);
- SetCachedVclData(m_pRef->CreateTextLayoutCache(*m_pText));
+ SetCachedVclData(OutputDevice::CreateTextLayoutCache(*m_pText));
}
Init();
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 7e94242b4808..373b8e93695f 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -169,7 +169,7 @@ public:
void AdjustLayout(ImplLayoutArgs&) final override;
bool LayoutText(ImplLayoutArgs&, const SalLayoutGlyphs*) final override;
void DrawText(SalGraphics&) const final override;
- std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&) const final override;
+ static std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&);
const SalLayoutGlyphs* GetGlyphs() const final override;
bool IsKashidaPosValid(int nCharPos) const final override;
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 53f12b8b4401..87bdb054655f 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -187,6 +187,7 @@ public:
std::unique_ptr<GenericSalLayout> Qt5Graphics::GetTextLayout(int nFallbackLevel)
{
+ assert(m_pTextStyle[nFallbackLevel]);
if (!m_pTextStyle[nFallbackLevel])
return nullptr;
return o3tl::make_unique<Qt5CommonSalLayout>(*m_pTextStyle[nFallbackLevel]);
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index b17c17e3c676..8a7a69890cd5 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -508,6 +508,7 @@ void AquaSalGraphics::SetFont(LogicalFontInstance* pReqFont, int nFallbackLevel)
std::unique_ptr<GenericSalLayout> AquaSalGraphics::GetTextLayout(int nFallbackLevel)
{
+ assert(mpTextStyle[nFallbackLevel]);
if (!mpTextStyle[nFallbackLevel])
return nullptr;
return o3tl::make_unique<GenericSalLayout>(*mpTextStyle[nFallbackLevel]);
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index 291178af2c6e..fad1000d880f 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -164,7 +164,7 @@ namespace {
} // namespace
-std::shared_ptr<vcl::TextLayoutCache> GenericSalLayout::CreateTextLayoutCache(OUString const& rString) const
+std::shared_ptr<vcl::TextLayoutCache> GenericSalLayout::CreateTextLayoutCache(OUString const& rString)
{
return std::make_shared<vcl::TextLayoutCache>(rString.getStr(), rString.getLength());
}
@@ -409,9 +409,9 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs, const SalLayoutGlyphs*
{
hb_buffer_clear_contents(pHbBuffer);
- int nMinRunPos = aSubRun.mnMin;
- int nEndRunPos = aSubRun.mnEnd;
- int nRunLen = nEndRunPos - nMinRunPos;
+ const int nMinRunPos = aSubRun.mnMin;
+ const int nEndRunPos = aSubRun.mnEnd;
+ const int nRunLen = nEndRunPos - nMinRunPos;
OString sLanguage = msLanguage;
if (sLanguage.isEmpty())
@@ -637,7 +637,6 @@ void GenericSalLayout::ApplyDXArray(const ImplLayoutArgs& rArgs)
pNewCharWidths[i] = rArgs.mpDXArray[i] - rArgs.mpDXArray[i - 1];
}
-
bool bKashidaJustify = false;
DeviceCoordinate nKashidaWidth = 0;
hb_codepoint_t nKashidaIndex = 0;
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index aad45b39e73e..e6ef73d28882 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -1574,12 +1574,6 @@ bool MultiSalLayout::IsKashidaPosValid(int nCharPos) const
return bValid;
}
-std::shared_ptr<vcl::TextLayoutCache> SalLayout::CreateTextLayoutCache(
- OUString const&) const
-{
- return nullptr; // by default, nothing to cache
-}
-
const SalLayoutGlyphs* SalLayout::GetGlyphs() const
{
// No access to the glyphs by default.
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 2082ce74fe17..054c92d068e8 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1346,15 +1346,9 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr,
}
std::shared_ptr<vcl::TextLayoutCache> OutputDevice::CreateTextLayoutCache(
- OUString const& rString) const
+ OUString const& rString)
{
- if (!mpGraphics) // can happen in e.g Insert Index/Table dialog
- return nullptr;
-
- std::unique_ptr<GenericSalLayout> pSalLayout = mpGraphics->GetTextLayout(0);
- if (!pSalLayout)
- return nullptr;
- return pSalLayout->CreateTextLayoutCache(rString);
+ return GenericSalLayout::CreateTextLayoutCache(rString);
}
bool OutputDevice::GetTextIsRTL( const OUString& rString, sal_Int32 nIndex, sal_Int32 nLen ) const
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index bac446d76dbe..30ec4d19f7e0 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -444,6 +444,7 @@ void CairoTextRender::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nF
std::unique_ptr<GenericSalLayout> CairoTextRender::GetTextLayout(int nFallbackLevel)
{
+ assert(mpFreetypeFont[nFallbackLevel]);
if (!mpFreetypeFont[nFallbackLevel])
return nullptr;
return o3tl::make_unique<GenericSalLayout>(*mpFreetypeFont[nFallbackLevel]->GetFontInstance());
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index bb27e1efcf2f..59f62c00c57a 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -735,6 +735,7 @@ void GenPspGraphics::GetFontMetric(ImplFontMetricDataRef& rxFontMetric, int nFal
std::unique_ptr<GenericSalLayout> GenPspGraphics::GetTextLayout(int nFallbackLevel)
{
+ assert(m_pFreetypeFont[nFallbackLevel]);
if (!m_pFreetypeFont[nFallbackLevel])
return nullptr;
return o3tl::make_unique<PspSalLayout>(*m_pPrinterGfx, *m_pFreetypeFont[nFallbackLevel]);
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 35ceee40ca2e..4ae496f2d5f4 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -288,6 +288,7 @@ bool ExTextOutRenderer::operator ()(GenericSalLayout const &rLayout,
std::unique_ptr<GenericSalLayout> WinSalGraphics::GetTextLayout(int nFallbackLevel)
{
+ assert(mpWinFontEntry[nFallbackLevel]);
if (!mpWinFontEntry[nFallbackLevel])
return nullptr;