summaryrefslogtreecommitdiff
path: root/sfx2/source/dialog
diff options
context:
space:
mode:
authorLászló Németh <laszlo.nemeth@collabora.com>2015-06-26 17:36:07 +0200
committerAndras Timar <andras.timar@collabora.com>2015-08-06 12:52:31 +0200
commit1ab670c57ec769e9418f7c21b64c98590f488912 (patch)
tree615e7b88f9e68e66c2a8e04c246459ef013be076 /sfx2/source/dialog
parent3452041590cea973d660a7580f44f0875abbfe53 (diff)
fix style preview rendering
(cherry-picked from 1ebe3004d6e9372ef5419d456b3c29059b539bc9) Change-Id: I9ea9cf895f3d608bd3289c1847eea2f6d47a910c Reviewed-on: https://gerrit.libreoffice.org/16521 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'sfx2/source/dialog')
-rw-r--r--sfx2/source/dialog/templdlg.cxx58
1 files changed, 30 insertions, 28 deletions
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 833a8afedae7..8747856c9ec4 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,19 @@ 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* pEntry)
+{
+ std::unique_ptr<sfx2::StylePreviewRenderer> pStylePreviewRenderer;
+
+ if (!pEntry)
+ return;
+
+ bool bResult = false;
SfxObjectShell* pShell = SfxObjectShell::Current();
if (!pShell)
@@ -122,40 +135,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*>(pEntry), mpViewData);
+ }
+ }
}
-}
-
-void StyleLBoxString::Paint(
- const Point& aPos, SvTreeListBox& /*rDevice*/, vcl::RenderContext& rRenderContext,
- const SvViewDataEntry* pView, const SvTreeListEntry* pEntry)
-{
- if (!pEntry)
- return;
-
- bool bResult = false;
- if (mpStylePreviewRenderer)
+ if (pStylePreviewRenderer)
{
Rectangle aPaintRectangle = pView->GetPaintRectangle();
- bResult = mpStylePreviewRenderer->render(aPaintRectangle);
+ bResult = pStylePreviewRenderer->render(aPaintRectangle);
}
if (!bResult)