Blame SOURCES/0001-Related-fdo-36815-center-scaled-comment-page-vertica.patch

f085be
From 9fd97266ce7dbeac33c93b6dace69d64c02d222c Mon Sep 17 00:00:00 2001
f085be
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
f085be
Date: Wed, 23 Apr 2014 15:22:13 +0100
f085be
Subject: [PATCH] Related: fdo#36815 center scaled comment page vertically
f085be
f085be
so comments at the top of the page don't get clipped
f085be
off the true printable area
f085be
f085be
Change-Id: Icb796c901372437b276e7ce4e31c08e0bf2ec250
f085be
---
f085be
 sw/source/core/view/vprint.cxx | 56 +++++++++++++++---------------------------
f085be
 1 file changed, 20 insertions(+), 36 deletions(-)
f085be
f085be
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
f085be
index b680e52..0022fff 100644
f085be
--- a/sw/source/core/view/vprint.cxx
f085be
+++ b/sw/source/core/view/vprint.cxx
f085be
@@ -455,26 +455,6 @@ sal_Bool SwViewShell::PrintOrPDFExport(
f085be
     // output device is now provided by a call from outside the Writer)
f085be
     pOutDev->Push();
f085be
 
f085be
-    // fdo#36815 for comments in margins print to a metafile
f085be
-    // and then scale that metafile down so that the comments
f085be
-    // will fit on the real page, and replay that scaled
f085be
-    // output to the real outputdevice
f085be
-    GDIMetaFile *pOrigRecorder(NULL);
f085be
-    GDIMetaFile *pMetaFile(NULL);
f085be
-    sal_Int16 nPostItMode = rPrintData.GetPrintPostIts();
f085be
-    if (nPostItMode == POSTITS_INMARGINS)
f085be
-    {
f085be
-        //get and disable the existing recorder
f085be
-        pOrigRecorder = pOutDev->GetConnectMetaFile();
f085be
-        pOutDev->SetConnectMetaFile(NULL);
f085be
-        // turn off output to the device
f085be
-        pOutDev->EnableOutput(false);
f085be
-        // just record the rendering commands to the metafile
f085be
-        // instead
f085be
-        pMetaFile = new GDIMetaFile;
f085be
-        pMetaFile->Record(pOutDev);
f085be
-    }
f085be
-
f085be
     // Print/PDF export for (multi-)selection has already generated a
f085be
     // temporary document with the selected text.
f085be
     // (see XRenderable implementation in unotxdoc.cxx)
f085be
@@ -490,6 +470,8 @@ sal_Bool SwViewShell::PrintOrPDFExport(
f085be
         pDrawView->SetBufferedOverlayAllowed( false );
f085be
     }
f085be
 
f085be
+    sal_Int16 nPostItMode = rPrintData.GetPrintPostIts();
f085be
+
f085be
     {   // additional scope so that the CurrShell is reset before destroying the shell
f085be
 
f085be
         SET_CURR_SHELL( pShell );
f085be
@@ -537,22 +519,6 @@ sal_Bool SwViewShell::PrintOrPDFExport(
f085be
             pPostItManager->CalcRects();
f085be
             pPostItManager->LayoutPostIts();
f085be
             pPostItManager->DrawNotesForPage(pOutDev, nPage-1);
f085be
-
f085be
-            //Now scale the recorded page down so the notes
f085be
-            //will fit in the final page
f085be
-            pMetaFile->Stop();
f085be
-            pMetaFile->WindStart();
f085be
-            double fScale = 0.75;
f085be
-            pMetaFile->Scale( fScale, fScale );
f085be
-            pMetaFile->WindStart();
f085be
-
f085be
-            //Enable output the the device again
f085be
-            pOutDev->EnableOutput(true);
f085be
-            //Restore the original recorder
f085be
-            pOutDev->SetConnectMetaFile(pOrigRecorder);
f085be
-            //play back the scaled page
f085be
-            pMetaFile->Play(pOutDev);
f085be
-            delete pMetaFile;
f085be
         }
f085be
     }
f085be
 
f085be
@@ -562,6 +528,24 @@ sal_Bool SwViewShell::PrintOrPDFExport(
f085be
     // output device is now provided by a call from outside the Writer)
f085be
     pOutDev->Pop();
f085be
 
f085be
+    // fdo#36815 for comments in margins get the metafile we are printing to
f085be
+    // and then scale and vertically center that metafile down so that the
f085be
+    // comments will fit on the real page
f085be
+    GDIMetaFile *pRecorder = pOutDev->GetConnectMetaFile();
f085be
+    if (nPostItMode == POSTITS_INMARGINS && pRecorder)
f085be
+    {
f085be
+        pRecorder->Stop();
f085be
+        pRecorder->WindStart();
f085be
+        double fScale = 0.75;
f085be
+        long nOrigHeight = pOutDev->GetOutputSize().Height();
f085be
+        long nNewHeight = nOrigHeight*fScale;
f085be
+        long nShiftY = (nOrigHeight-nNewHeight)/2;
f085be
+        pRecorder->Scale(fScale, fScale);
f085be
+        pRecorder->WindStart();
f085be
+        pRecorder->Move(0, nShiftY, pOutDev->ImplGetDPIX(), pOutDev->ImplGetDPIY());
f085be
+        pRecorder->WindStart();
f085be
+    }
f085be
+
f085be
     return sal_True;
f085be
 }
f085be
 
f085be
-- 
f085be
1.9.0
f085be