summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sfx2/source/dialog/templdlg.cxx52
1 files changed, 27 insertions, 25 deletions
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<sfx2::StylePreviewRenderer> 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<sfx2::StylePreviewRenderer> 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<SvTreeListBox*>(&rDevice), const_cast<SvTreeListEntry*>(&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)