[Libreoffice-commits] core.git: sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Jul 28 01:15:16 PDT 2015


 sw/inc/pagepreviewlayout.hxx              |    5 +++++
 sw/inc/viewsh.hxx                         |    1 +
 sw/source/core/view/pagepreviewlayout.cxx |   24 ++++++++++++++++++++++++
 sw/source/uibase/uiview/pview.cxx         |    2 ++
 4 files changed, 32 insertions(+)

New commits:
commit 46e7991be05a39a24e0a559db6ff1aea0ebc14e5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jul 28 09:57:31 2015 +0200

    tdf#92914 SwPagePreviewLayout::Paint: handle rendercontext
    
    With this, the print preview window no longer performs direct paint.
    
    Change-Id: I53f05d8a3b723bc131f21a485e0ffec71484670a

diff --git a/sw/inc/pagepreviewlayout.hxx b/sw/inc/pagepreviewlayout.hxx
index 828b1a1..c18a437 100644
--- a/sw/inc/pagepreviewlayout.hxx
+++ b/sw/inc/pagepreviewlayout.hxx
@@ -569,6 +569,11 @@ public:
         @author FME
     */
     sal_uInt16 ConvertAbsoluteToRelativePageNum( sal_uInt16 _nAbsPageNum ) const;
+
+    SwViewShell& GetParentViewShell()
+    {
+        return mrParentViewShell;
+    }
 };
 
 #endif // INCLUDED_SW_INC_PAGEPREVIEWLAYOUT_HXX
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 6695b12..6e99bc1 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -350,6 +350,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 f088700..069c07b 100644
--- a/sw/source/core/view/pagepreviewlayout.cxx
+++ b/sw/source/core/view/pagepreviewlayout.cxx
@@ -986,12 +986,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 1b89936..39ed4bc 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);
     }
 }
 


More information about the Libreoffice-commits mailing list