Kaydet (Commit) 0deff904 authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Tomaž Vajngerl

tdf#92914 SwPagePreviewLayout::Paint: handle rendercontext

With this, the print preview window no longer performs direct paint.

(cherry picked from commit 46e7991b)

Conflicts:
	sw/inc/pagepreviewlayout.hxx

Change-Id: I53f05d8a3b723bc131f21a485e0ffec71484670a
Reviewed-on: https://gerrit.libreoffice.org/17394Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 022fc297
...@@ -575,6 +575,11 @@ public: ...@@ -575,6 +575,11 @@ public:
@author FME @author FME
*/ */
sal_uInt16 GetNumberOfPreviewPages() { return sal::static_int_cast< sal_uInt16 >(maPreviewPages.size()); } sal_uInt16 GetNumberOfPreviewPages() { return sal::static_int_cast< sal_uInt16 >(maPreviewPages.size()); }
SwViewShell& GetParentViewShell()
{
return mrParentViewShell;
}
}; };
#endif // INCLUDED_SW_INC_PAGEPREVIEWLAYOUT_HXX #endif // INCLUDED_SW_INC_PAGEPREVIEWLAYOUT_HXX
......
...@@ -357,6 +357,7 @@ public: ...@@ -357,6 +357,7 @@ public:
inline vcl::RenderContext* GetOut() const { return mpOut; } inline vcl::RenderContext* GetOut() const { return mpOut; }
void SetWin(vcl::Window* win) { mpWin = win; } void SetWin(vcl::Window* win) { mpWin = win; }
void SetOut(vcl::RenderContext* pOut) { mpOut = pOut; }
static inline bool IsLstEndAction() { return SwViewShell::mbLstAct; } static inline bool IsLstEndAction() { return SwViewShell::mbLstAct; }
// Change of all page descriptors. // Change of all page descriptors.
......
...@@ -984,12 +984,36 @@ SwTwips SwPagePreviewLayout::GetWinPagesScrollAmount( ...@@ -984,12 +984,36 @@ SwTwips SwPagePreviewLayout::GetWinPagesScrollAmount(
// methods to paint page preview layout // 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 /** paint prepared preview
OD 12.12.2002 #103492# OD 12.12.2002 #103492#
*/ */
bool SwPagePreviewLayout::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rOutRect) const bool SwPagePreviewLayout::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rOutRect) const
{ {
PreviewRenderContextGuard aGuard(mrParentViewShell, &rRenderContext);
// check environment and parameters // check environment and parameters
{ {
if (!mrParentViewShell.GetWin() && !mrParentViewShell.GetOut()->GetConnectMetaFile()) if (!mrParentViewShell.GetWin() && !mrParentViewShell.GetOut()->GetConnectMetaFile())
......
...@@ -234,7 +234,9 @@ void SwPagePreviewWin::Paint(vcl::RenderContext& rRenderContext, const Rectangl ...@@ -234,7 +234,9 @@ void SwPagePreviewWin::Paint(vcl::RenderContext& rRenderContext, const Rectangl
aMM.SetScaleX(maScale); aMM.SetScaleX(maScale);
aMM.SetScaleY(maScale); aMM.SetScaleY(maScale);
rRenderContext.SetMapMode(aMM); rRenderContext.SetMapMode(aMM);
mpPgPreviewLayout->GetParentViewShell().setOutputToWindow(true);
mpPgPreviewLayout->Paint(rRenderContext, rRect); mpPgPreviewLayout->Paint(rRenderContext, rRect);
mpPgPreviewLayout->GetParentViewShell().setOutputToWindow(false);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment