From d67cd0efbc08c92492f3b5fd7ffe35556052d52f Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 5 Aug 2020 15:50:31 +0100 Subject: tdf#135438 Paragraph styles preview in sidebar are clipped MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit since... commit fe9a13dc0e6d1384416c2a2343223b33925fc925 Author: Caolán McNamara Date: Sun Apr 26 15:43:25 2020 +0100 weld SfxTemplatePanelControl getRenderSize used to be called after recalculate and before render to change maSizePixel Change-Id: Ifc1b6b0b3399c7de61d5f4d46f8346d13e72a4d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100069 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- svx/inc/CommonStylePreviewRenderer.hxx | 2 ++ svx/source/styles/CommonStylePreviewRenderer.cxx | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/svx/inc/CommonStylePreviewRenderer.hxx b/svx/inc/CommonStylePreviewRenderer.hxx index 55391327533e..5dfd41faa39a 100644 --- a/svx/inc/CommonStylePreviewRenderer.hxx +++ b/svx/inc/CommonStylePreviewRenderer.hxx @@ -31,6 +31,8 @@ class CommonStylePreviewRenderer final : public sfx2::StylePreviewRenderer Size maPixelSize; OUString maStyleName; + Size getRenderSize() const; + public: CommonStylePreviewRenderer(const SfxObjectShell& rShell, OutputDevice& rOutputDev, SfxStyleSheetBase* pStyle, long nMaxHeight); diff --git a/svx/source/styles/CommonStylePreviewRenderer.cxx b/svx/source/styles/CommonStylePreviewRenderer.cxx index d677a135461e..9920903df469 100644 --- a/svx/source/styles/CommonStylePreviewRenderer.cxx +++ b/svx/source/styles/CommonStylePreviewRenderer.cxx @@ -168,9 +168,21 @@ bool CommonStylePreviewRenderer::recalculate() } m_pFont = std::move(pFont); + maPixelSize = getRenderSize(); return true; } +Size CommonStylePreviewRenderer::getRenderSize() const +{ + assert(m_pFont); + Size aPixelSize = m_pFont->GetTextSize(&mrOutputDev, maStyleName); + + if (aPixelSize.Height() > mnMaxHeight) + aPixelSize.setHeight( mnMaxHeight ); + + return aPixelSize; +} + bool CommonStylePreviewRenderer::render(const tools::Rectangle& aRectangle, RenderAlign eRenderAlign) { const OUString& rText = maStyleName; -- cgit