summaryrefslogtreecommitdiff
path: root/vcl
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 /vcl
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>
Diffstat (limited to 'vcl')
-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
9 files changed, 12 insertions, 20 deletions
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;