1 |
From 834c9363f67198e33880c2ee7bdd136b5558599d Mon Sep 17 00:00:00 2001 |
2 |
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com> |
3 |
Date: Thu, 1 May 2014 17:10:21 +0100 |
4 |
Subject: [PATCH] Resolves: fdo#78128 go back to using an interim metafile |
5 |
|
6 |
this time we know that the other varient of "Move" doesn't |
7 |
handle pixel drawing stuff like the dpi-using one does. |
8 |
|
9 |
and the move values have to be in 100TH_MM_MAP and |
10 |
with the true numbers of the write page size |
11 |
|
12 |
Change-Id: I15fdb78797d8744702bec649024fedbf3e39b342 |
13 |
--- |
14 |
sw/source/core/view/vprint.cxx | 68 +++++++++++++++++++++++++++++------------- |
15 |
1 file changed, 48 insertions(+), 20 deletions(-) |
16 |
|
17 |
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx |
18 |
index c9c7e42..6bc53e8 100644 |
19 |
--- a/sw/source/core/view/vprint.cxx |
20 |
+++ b/sw/source/core/view/vprint.cxx |
21 |
@@ -455,6 +455,28 @@ sal_Bool SwViewShell::PrintOrPDFExport( |
22 |
// output device is now provided by a call from outside the Writer) |
23 |
pOutDev->Push(); |
24 |
|
25 |
+ // fdo#36815 for comments in margins print to a metafile |
26 |
+ // and then scale that metafile down so that the comments |
27 |
+ // will fit on the real page, and replay that scaled |
28 |
+ // output to the real outputdevice |
29 |
+ GDIMetaFile *pOrigRecorder(NULL); |
30 |
+ GDIMetaFile *pMetaFile(NULL); |
31 |
+ sal_Int16 nPostItMode = rPrintData.GetPrintPostIts(); |
32 |
+ if (nPostItMode == POSTITS_INMARGINS) |
33 |
+ { |
34 |
+ //get and disable the existing recorder |
35 |
+ pOrigRecorder = pOutDev->GetConnectMetaFile(); |
36 |
+ pOutDev->SetConnectMetaFile(NULL); |
37 |
+ // turn off output to the device |
38 |
+ pOutDev->EnableOutput(false); |
39 |
+ // just record the rendering commands to the metafile |
40 |
+ // instead |
41 |
+ pMetaFile = new GDIMetaFile; |
42 |
+ pMetaFile->SetPrefSize(pOutDev->GetOutputSize()); |
43 |
+ pMetaFile->SetPrefMapMode(pOutDev->GetMapMode()); |
44 |
+ pMetaFile->Record(pOutDev); |
45 |
+ } |
46 |
+ |
47 |
// Print/PDF export for (multi-)selection has already generated a |
48 |
// temporary document with the selected text. |
49 |
// (see XRenderable implementation in unotxdoc.cxx) |
50 |
@@ -470,8 +492,6 @@ sal_Bool SwViewShell::PrintOrPDFExport( |
51 |
pDrawView->SetBufferedOverlayAllowed( false ); |
52 |
} |
53 |
|
54 |
- sal_Int16 nPostItMode = rPrintData.GetPrintPostIts(); |
55 |
- |
56 |
{ // additional scope so that the CurrShell is reset before destroying the shell |
57 |
|
58 |
SET_CURR_SHELL( pShell ); |
59 |
@@ -519,6 +539,32 @@ sal_Bool SwViewShell::PrintOrPDFExport( |
60 |
pPostItManager->CalcRects(); |
61 |
pPostItManager->LayoutPostIts(); |
62 |
pPostItManager->DrawNotesForPage(pOutDev, nPage-1); |
63 |
+ |
64 |
+ //Stop recording now |
65 |
+ pMetaFile->Stop(); |
66 |
+ pMetaFile->WindStart(); |
67 |
+ //Enable output to the device again |
68 |
+ pOutDev->EnableOutput(true); |
69 |
+ //Restore the original recorder |
70 |
+ pOutDev->SetConnectMetaFile(pOrigRecorder); |
71 |
+ |
72 |
+ //Now scale the recorded page down so the notes |
73 |
+ //will fit in the final page |
74 |
+ double fScale = 0.75; |
75 |
+ long nOrigHeight = pStPage->Frm().Height(); |
76 |
+ long nNewHeight = nOrigHeight*fScale; |
77 |
+ long nShiftY = (nOrigHeight-nNewHeight)/2; |
78 |
+ pMetaFile->Scale( fScale, fScale ); |
79 |
+ pMetaFile->WindStart(); |
80 |
+ //Move the scaled page down to center it |
81 |
+ //the other variant of Move does not map pixels |
82 |
+ //back to the logical units correctly |
83 |
+ pMetaFile->Move(0, convertTwipToMm100(nShiftY), pOutDev->GetDPIX(), pOutDev->GetDPIY()); |
84 |
+ pMetaFile->WindStart(); |
85 |
+ |
86 |
+ //play back the scaled page |
87 |
+ pMetaFile->Play(pOutDev); |
88 |
+ delete pMetaFile; |
89 |
} |
90 |
} |
91 |
|
92 |
@@ -528,24 +574,6 @@ sal_Bool SwViewShell::PrintOrPDFExport( |
93 |
// output device is now provided by a call from outside the Writer) |
94 |
pOutDev->Pop(); |
95 |
|
96 |
- // fdo#36815 for comments in margins get the metafile we are printing to |
97 |
- // and then scale and vertically center that metafile down so that the |
98 |
- // comments will fit on the real page |
99 |
- GDIMetaFile *pRecorder = pOutDev->GetConnectMetaFile(); |
100 |
- if (nPostItMode == POSTITS_INMARGINS && pRecorder) |
101 |
- { |
102 |
- pRecorder->Stop(); |
103 |
- pRecorder->WindStart(); |
104 |
- double fScale = 0.75; |
105 |
- long nOrigHeight = pOutDev->GetOutputSize().Height(); |
106 |
- long nNewHeight = nOrigHeight*fScale; |
107 |
- long nShiftY = (nOrigHeight-nNewHeight)/2; |
108 |
- pRecorder->Scale(fScale, fScale); |
109 |
- pRecorder->WindStart(); |
110 |
- pRecorder->Move(0, nShiftY, pOutDev->ImplGetDPIX(), pOutDev->ImplGetDPIY()); |
111 |
- pRecorder->WindStart(); |
112 |
- } |
113 |
- |
114 |
return sal_True; |
115 |
} |
116 |
|
117 |
-- |
118 |
1.9.0 |
119 |
|