summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-05-01 17:10:21 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-05-01 17:19:52 +0100
commitb44ca2f45e86abb62718534fad43cdd3741101ba (patch)
treea015f157b62049cccb2345b567565a381426663a
parentd5e89e0573bb92819c20b808b07347d57f6e6a0d (diff)
Resolves: fdo#78128 go back to using an interim metafile
this time we know that the other varient of "Move" doesn't handle pixel drawing stuff like the dpi-using one does. and the move values have to be in 100TH_MM_MAP and with the true numbers of the write page size Change-Id: I15fdb78797d8744702bec649024fedbf3e39b342
-rw-r--r--sw/source/core/view/vprint.cxx68
1 files changed, 48 insertions, 20 deletions
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index f6a5c69b1236..5898fbd6c2ed 100644
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -455,6 +455,28 @@ bool SwViewShell::PrintOrPDFExport(
// output device is now provided by a call from outside the Writer)
pOutDev->Push();
+ // fdo#36815 for comments in margins print to a metafile
+ // and then scale that metafile down so that the comments
+ // will fit on the real page, and replay that scaled
+ // output to the real outputdevice
+ GDIMetaFile *pOrigRecorder(NULL);
+ GDIMetaFile *pMetaFile(NULL);
+ sal_Int16 nPostItMode = rPrintData.GetPrintPostIts();
+ if (nPostItMode == POSTITS_INMARGINS)
+ {
+ //get and disable the existing recorder
+ pOrigRecorder = pOutDev->GetConnectMetaFile();
+ pOutDev->SetConnectMetaFile(NULL);
+ // turn off output to the device
+ pOutDev->EnableOutput(false);
+ // just record the rendering commands to the metafile
+ // instead
+ pMetaFile = new GDIMetaFile;
+ pMetaFile->SetPrefSize(pOutDev->GetOutputSize());
+ pMetaFile->SetPrefMapMode(pOutDev->GetMapMode());
+ pMetaFile->Record(pOutDev);
+ }
+
// Print/PDF export for (multi-)selection has already generated a
// temporary document with the selected text.
// (see XRenderable implementation in unotxdoc.cxx)
@@ -470,8 +492,6 @@ bool SwViewShell::PrintOrPDFExport(
pDrawView->SetBufferedOverlayAllowed( false );
}
- sal_Int16 nPostItMode = rPrintData.GetPrintPostIts();
-
{ // additional scope so that the CurrShell is reset before destroying the shell
SET_CURR_SHELL( pShell );
@@ -519,6 +539,32 @@ bool SwViewShell::PrintOrPDFExport(
pPostItManager->CalcRects();
pPostItManager->LayoutPostIts();
pPostItManager->DrawNotesForPage(pOutDev, nPage-1);
+
+ //Stop recording now
+ pMetaFile->Stop();
+ pMetaFile->WindStart();
+ //Enable output to the device again
+ pOutDev->EnableOutput(true);
+ //Restore the original recorder
+ pOutDev->SetConnectMetaFile(pOrigRecorder);
+
+ //Now scale the recorded page down so the notes
+ //will fit in the final page
+ double fScale = 0.75;
+ long nOrigHeight = pStPage->Frm().Height();
+ long nNewHeight = nOrigHeight*fScale;
+ long nShiftY = (nOrigHeight-nNewHeight)/2;
+ pMetaFile->Scale( fScale, fScale );
+ pMetaFile->WindStart();
+ //Move the scaled page down to center it
+ //the other variant of Move does not map pixels
+ //back to the logical units correctly
+ pMetaFile->Move(0, convertTwipToMm100(nShiftY), pOutDev->GetDPIX(), pOutDev->GetDPIY());
+ pMetaFile->WindStart();
+
+ //play back the scaled page
+ pMetaFile->Play(pOutDev);
+ delete pMetaFile;
}
}
@@ -528,24 +574,6 @@ bool SwViewShell::PrintOrPDFExport(
// output device is now provided by a call from outside the Writer)
pOutDev->Pop();
- // fdo#36815 for comments in margins get the metafile we are printing to
- // and then scale and vertically center that metafile down so that the
- // comments will fit on the real page
- GDIMetaFile *pRecorder = pOutDev->GetConnectMetaFile();
- if (nPostItMode == POSTITS_INMARGINS && pRecorder)
- {
- pRecorder->Stop();
- pRecorder->WindStart();
- double fScale = 0.75;
- long nOrigHeight = pOutDev->GetOutputSize().Height();
- long nNewHeight = nOrigHeight*fScale;
- long nShiftY = (nOrigHeight-nNewHeight)/2;
- pRecorder->Scale(fScale, fScale);
- pRecorder->WindStart();
- pRecorder->Move(0, nShiftY, pOutDev->GetDPIX(), pOutDev->GetDPIY());
- pRecorder->WindStart();
- }
-
return true;
}