better centering of scaled note-using pages

f41
Caolán McNamara 11 years ago
parent f3e201d7d7
commit 76aab81fb5

@ -0,0 +1,119 @@
From 834c9363f67198e33880c2ee7bdd136b5558599d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Thu, 1 May 2014 17:10:21 +0100
Subject: [PATCH] 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
---
sw/source/core/view/vprint.cxx | 68 +++++++++++++++++++++++++++++-------------
1 file changed, 48 insertions(+), 20 deletions(-)
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index c9c7e42..6bc53e8 100644
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -455,6 +455,28 @@ 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->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 @@ 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 );
@@ -519,6 +539,32 @@ sal_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 @@ 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;
}
--
1.9.0

@ -37,7 +37,7 @@ Summary: Free Software Productivity Suite
Name: libreoffice Name: libreoffice
Epoch: 1 Epoch: 1
Version: %{libo_version}.2 Version: %{libo_version}.2
Release: 1%{?libo_prerelease}%{?dist} Release: 2%{?libo_prerelease}%{?dist}
License: (MPLv1.1 or LGPLv3+) and LGPLv3 and LGPLv2+ and BSD and (MPLv1.1 or GPLv2 or LGPLv2 or Netscape) and Public Domain and ASL 2.0 and Artistic and MPLv2.0 License: (MPLv1.1 or LGPLv3+) and LGPLv3 and LGPLv2+ and BSD and (MPLv1.1 or GPLv2 or LGPLv2 or Netscape) and Public Domain and ASL 2.0 and Artistic and MPLv2.0
Group: Applications/Productivity Group: Applications/Productivity
URL: http://www.libreoffice.org/default/ URL: http://www.libreoffice.org/default/
@ -293,8 +293,9 @@ Patch32: 0001-Resolves-rhbz-1089377-crash-on-loading-a-specific-rt.patch
Patch33: 0001-add-a-format-all-comments-feature.patch Patch33: 0001-add-a-format-all-comments-feature.patch
Patch34: 0001-Resolves-fdo-37130-use-10pt-Default-style-font-for-c.patch Patch34: 0001-Resolves-fdo-37130-use-10pt-Default-style-font-for-c.patch
Patch35: 0001-Related-fdo-36815-center-scaled-comment-page-vertica.patch Patch35: 0001-Related-fdo-36815-center-scaled-comment-page-vertica.patch
Patch36: 0001-Related-rhbz-1032774-slide-restarter-should-disable-.patch Patch36: 0001-Resolves-fdo-78128-go-back-to-using-an-interim-metaf.patch
Patch37: 0001-add-X-TryExec-entries-to-desktop-files.patch Patch37: 0001-Related-rhbz-1032774-slide-restarter-should-disable-.patch
Patch38: 0001-add-X-TryExec-entries-to-desktop-files.patch
%define instdir %{_libdir} %define instdir %{_libdir}
%define baseinstdir %{instdir}/libreoffice %define baseinstdir %{instdir}/libreoffice
@ -2258,6 +2259,9 @@ update-desktop-database %{_datadir}/applications &> /dev/null || :
%endif %endif
%changelog %changelog
* Thu May 01 2014 Caolán McNamara <caolanm@redhat.com> - 1:4.2.4.2-2
- better scaling of notes-using pages
* Wed Apr 30 2014 David Tardon <dtardon@redhat.com> - 1:4.2.4.2-1 * Wed Apr 30 2014 David Tardon <dtardon@redhat.com> - 1:4.2.4.2-1
- update to 4.2.4 rc2 - update to 4.2.4 rc2

Loading…
Cancel
Save