kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0001-Resolves-fdo-78128-go-back-to-using-an-interim-metaf.patch

f085be
From 834c9363f67198e33880c2ee7bdd136b5558599d Mon Sep 17 00:00:00 2001
f085be
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
f085be
Date: Thu, 1 May 2014 17:10:21 +0100
f085be
Subject: [PATCH] Resolves: fdo#78128 go back to using an interim metafile
f085be
f085be
this time we know that the other varient of "Move" doesn't
f085be
handle pixel drawing stuff like the dpi-using one does.
f085be
f085be
and the move values have to be in 100TH_MM_MAP and
f085be
with the true numbers of the write page size
f085be
f085be
Change-Id: I15fdb78797d8744702bec649024fedbf3e39b342
f085be
---
f085be
 sw/source/core/view/vprint.cxx | 68 +++++++++++++++++++++++++++++-------------
f085be
 1 file changed, 48 insertions(+), 20 deletions(-)
f085be
f085be
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
f085be
index c9c7e42..6bc53e8 100644
f085be
--- a/sw/source/core/view/vprint.cxx
f085be
+++ b/sw/source/core/view/vprint.cxx
f085be
@@ -455,6 +455,28 @@ 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->SetPrefSize(pOutDev->GetOutputSize());
f085be
+        pMetaFile->SetPrefMapMode(pOutDev->GetMapMode());
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
@@ -470,8 +492,6 @@ 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
@@ -519,6 +539,32 @@ sal_Bool SwViewShell::PrintOrPDFExport(
f085be
             pPostItManager->CalcRects();
f085be
             pPostItManager->LayoutPostIts();
f085be
             pPostItManager->DrawNotesForPage(pOutDev, nPage-1);
f085be
+
f085be
+            //Stop recording now
f085be
+            pMetaFile->Stop();
f085be
+            pMetaFile->WindStart();
f085be
+            //Enable output to the device again
f085be
+            pOutDev->EnableOutput(true);
f085be
+            //Restore the original recorder
f085be
+            pOutDev->SetConnectMetaFile(pOrigRecorder);
f085be
+
f085be
+            //Now scale the recorded page down so the notes
f085be
+            //will fit in the final page
f085be
+            double fScale = 0.75;
f085be
+            long nOrigHeight = pStPage->Frm().Height();
f085be
+            long nNewHeight = nOrigHeight*fScale;
f085be
+            long nShiftY = (nOrigHeight-nNewHeight)/2;
f085be
+            pMetaFile->Scale( fScale, fScale );
f085be
+            pMetaFile->WindStart();
f085be
+            //Move the scaled page down to center it
f085be
+            //the other variant of Move does not map pixels
f085be
+            //back to the logical units correctly
f085be
+            pMetaFile->Move(0, TWIP_TO_MM100(nShiftY), pOutDev->ImplGetDPIX(), pOutDev->ImplGetDPIY());
f085be
+            pMetaFile->WindStart();
f085be
+
f085be
+            //play back the scaled page
f085be
+            pMetaFile->Play(pOutDev);
f085be
+            delete pMetaFile;
f085be
         }
f085be
     }
f085be
 
f085be
@@ -528,24 +574,6 @@ 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