diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-07-28 09:57:31 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2015-07-29 10:34:11 +0000 |
commit | 0deff9044cd0c21a4caf1df2df13d9a1b5cecff2 (patch) | |
tree | 8e75018148973ae67eeac33d20ba6058f0e58b79 | |
parent | 022fc2973697d7d25f2b7da3744788fa15a6a477 (diff) |
tdf#92914 SwPagePreviewLayout::Paint: handle rendercontext
With this, the print preview window no longer performs direct paint.
(cherry picked from commit 46e7991be05a39a24e0a559db6ff1aea0ebc14e5)
Conflicts:
sw/inc/pagepreviewlayout.hxx
Change-Id: I53f05d8a3b723bc131f21a485e0ffec71484670a
Reviewed-on: https://gerrit.libreoffice.org/17394
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | sw/inc/pagepreviewlayout.hxx | 5 | ||||
-rw-r--r-- | sw/inc/viewsh.hxx | 1 | ||||
-rw-r--r-- | sw/source/core/view/pagepreviewlayout.cxx | 24 | ||||
-rw-r--r-- | sw/source/uibase/uiview/pview.cxx | 2 |
4 files changed, 32 insertions, 0 deletions
diff --git a/sw/inc/pagepreviewlayout.hxx b/sw/inc/pagepreviewlayout.hxx index b81afd756b5d..78fb6764fc21 100644 --- a/sw/inc/pagepreviewlayout.hxx +++ b/sw/inc/pagepreviewlayout.hxx @@ -575,6 +575,11 @@ public: @author FME */ sal_uInt16 GetNumberOfPreviewPages() { return sal::static_int_cast< sal_uInt16 >(maPreviewPages.size()); } + + SwViewShell& GetParentViewShell() + { + return mrParentViewShell; + } }; #endif // INCLUDED_SW_INC_PAGEPREVIEWLAYOUT_HXX diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx index 5f7a9cef157e..763af506b210 100644 --- a/sw/inc/viewsh.hxx +++ b/sw/inc/viewsh.hxx @@ -357,6 +357,7 @@ public: inline vcl::RenderContext* GetOut() const { return mpOut; } void SetWin(vcl::Window* win) { mpWin = win; } + void SetOut(vcl::RenderContext* pOut) { mpOut = pOut; } static inline bool IsLstEndAction() { return SwViewShell::mbLstAct; } // Change of all page descriptors. diff --git a/sw/source/core/view/pagepreviewlayout.cxx b/sw/source/core/view/pagepreviewlayout.cxx index 4baed4f7fd80..26ff858ce3ac 100644 --- a/sw/source/core/view/pagepreviewlayout.cxx +++ b/sw/source/core/view/pagepreviewlayout.cxx @@ -984,12 +984,36 @@ SwTwips SwPagePreviewLayout::GetWinPagesScrollAmount( // methods to paint page preview layout +namespace +{ +/// Similar to RenderContextGuard, but does not touch the draw view. +class PreviewRenderContextGuard +{ + VclPtr<vcl::RenderContext> m_pOriginalValue; + SwViewShell& m_rShell; + +public: + PreviewRenderContextGuard(SwViewShell& rShell, vcl::RenderContext* pValue) + : m_pOriginalValue(rShell.GetOut()), + m_rShell(rShell) + { + m_rShell.SetOut(pValue); + } + + ~PreviewRenderContextGuard() + { + m_rShell.SetOut(m_pOriginalValue); + } +}; +} + /** paint prepared preview OD 12.12.2002 #103492# */ bool SwPagePreviewLayout::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rOutRect) const { + PreviewRenderContextGuard aGuard(mrParentViewShell, &rRenderContext); // check environment and parameters { if (!mrParentViewShell.GetWin() && !mrParentViewShell.GetOut()->GetConnectMetaFile()) diff --git a/sw/source/uibase/uiview/pview.cxx b/sw/source/uibase/uiview/pview.cxx index 1d9fd38f7640..83fe02820d3e 100644 --- a/sw/source/uibase/uiview/pview.cxx +++ b/sw/source/uibase/uiview/pview.cxx @@ -234,7 +234,9 @@ void SwPagePreviewWin::Paint(vcl::RenderContext& rRenderContext, const Rectangl aMM.SetScaleX(maScale); aMM.SetScaleY(maScale); rRenderContext.SetMapMode(aMM); + mpPgPreviewLayout->GetParentViewShell().setOutputToWindow(true); mpPgPreviewLayout->Paint(rRenderContext, rRect); + mpPgPreviewLayout->GetParentViewShell().setOutputToWindow(false); } } |