From 1ebe3004d6e9372ef5419d456b3c29059b539bc9 Mon Sep 17 00:00:00 2001 From: László Németh Date: Fri, 26 Jun 2015 17:28:01 +0200 Subject: fix style preview rendering Change-Id: I10d3791a8d95b5db94af33690de57f3c443bc8fb --- sfx2/source/dialog/templdlg.cxx | 52 +++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'sfx2/source') diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx index 308f58129083..6bc67fb9e5c8 100644 --- a/sfx2/source/dialog/templdlg.cxx +++ b/sfx2/source/dialog/templdlg.cxx @@ -79,7 +79,7 @@ namespace class StyleLBoxString : public SvLBoxString { SfxStyleFamily meStyleFamily; - std::unique_ptr mpStylePreviewRenderer; + SvViewDataItem* mpViewData; public: StyleLBoxString(SvTreeListEntry* pEntry, @@ -115,6 +115,16 @@ void StyleLBoxString::InitViewData(SvTreeListBox* pView, SvTreeListEntry* pEntry { pViewData = pView->GetViewDataItem(pEntry, this); } + mpViewData = pViewData; +} + +void StyleLBoxString::Paint( + const Point& aPos, SvTreeListBox& rDevice, vcl::RenderContext& rRenderContext, + const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) +{ + std::unique_ptr pStylePreviewRenderer; + + bool bResult = false; SfxObjectShell* pShell = SfxObjectShell::Current(); if (!pShell) @@ -122,37 +132,29 @@ void StyleLBoxString::InitViewData(SvTreeListBox* pView, SvTreeListEntry* pEntry sfx2::StyleManager* pStyleManager = pShell->GetStyleManager(); - if (!pStyleManager) + if (pStyleManager) { - return; - } - mpStylePreviewRenderer.reset(pStyleManager->CreateStylePreviewRenderer(*pView, GetText(), meStyleFamily, 32 * pView->GetDPIScaleFactor())); + bool bInit = (!pStylePreviewRenderer); - if (!mpStylePreviewRenderer) - { - return; - } + pStylePreviewRenderer.reset(pStyleManager->CreateStylePreviewRenderer(rRenderContext, GetText(), meStyleFamily, 32 * rRenderContext.GetDPIScaleFactor())); - if (mpStylePreviewRenderer->recalculate()) - { - pViewData->maSize = mpStylePreviewRenderer->getRenderSize(); - } - else - { - SvLBoxString::InitViewData(pView, pEntry, pViewData); + if (pStylePreviewRenderer) + { + if (pStylePreviewRenderer->recalculate()) + { + mpViewData->maSize = pStylePreviewRenderer->getRenderSize(); + } + else if (bInit) + { + SvLBoxString::InitViewData( const_cast(&rDevice), const_cast(&rEntry), mpViewData); + } + } } -} - -void StyleLBoxString::Paint( - const Point& aPos, SvTreeListBox& /*rDevice*/, vcl::RenderContext& rRenderContext, - const SvViewDataEntry* pView, const SvTreeListEntry& /*rEntry*/) -{ - bool bResult = false; - if (mpStylePreviewRenderer) + if (pStylePreviewRenderer) { Rectangle aPaintRectangle = pView->GetPaintRectangle(); - bResult = mpStylePreviewRenderer->render(aPaintRectangle); + bResult = pStylePreviewRenderer->render(aPaintRectangle); } if (!bResult) -- cgit