diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-04-23 15:22:13 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-04-24 14:12:40 +0100 |
commit | 9fd97266ce7dbeac33c93b6dace69d64c02d222c (patch) | |
tree | f4769ae442583d870b1abc48ad788fd4e8173a63 | |
parent | dc3b3e129955856012df78acb1e8e2bbbec0df51 (diff) |
Related: fdo#36815 center scaled comment page vertically
so comments at the top of the page don't get clipped
off the true printable area
Change-Id: Icb796c901372437b276e7ce4e31c08e0bf2ec250
-rw-r--r-- | sw/source/core/view/vprint.cxx | 56 |
1 files changed, 20 insertions, 36 deletions
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index b680e522f429..0022fff31c04 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -455,26 +455,6 @@ sal_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->Record(pOutDev); - } - // Print/PDF export for (multi-)selection has already generated a // temporary document with the selected text. // (see XRenderable implementation in unotxdoc.cxx) @@ -490,6 +470,8 @@ sal_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 ); @@ -537,22 +519,6 @@ sal_Bool SwViewShell::PrintOrPDFExport( pPostItManager->CalcRects(); pPostItManager->LayoutPostIts(); pPostItManager->DrawNotesForPage(pOutDev, nPage-1); - - //Now scale the recorded page down so the notes - //will fit in the final page - pMetaFile->Stop(); - pMetaFile->WindStart(); - double fScale = 0.75; - pMetaFile->Scale( fScale, fScale ); - pMetaFile->WindStart(); - - //Enable output the the device again - pOutDev->EnableOutput(true); - //Restore the original recorder - pOutDev->SetConnectMetaFile(pOrigRecorder); - //play back the scaled page - pMetaFile->Play(pOutDev); - delete pMetaFile; } } @@ -562,6 +528,24 @@ sal_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->ImplGetDPIX(), pOutDev->ImplGetDPIY()); + pRecorder->WindStart(); + } + return sal_True; } |