summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-05-24 06:59:39 -0400
committerJan Holesovsky <kendy@collabora.com>2018-06-06 12:49:23 +0200
commitdaca240109325b424ea2090c1939f5959fa746aa (patch)
tree3909a2a22b77bf460649eea3ae1befef2e3a3548
parent41f4be673ec70e12ac1ebce371ec17d8596048bc (diff)
sd: make the imported PDF page exactly as original
i.e. no borders or larger page than rendered PDF Change-Id: I1f356cceeec1d5d9f1728f0e29160fdd9241a221 Reviewed-on: https://gerrit.libreoffice.org/54764 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r--sd/source/filter/pdf/sdpdffilter.cxx37
1 files changed, 6 insertions, 31 deletions
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index 9ad401287131..a52a6aea3353 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -129,37 +129,12 @@ bool SdPdfFilter::Import()
// Create the page and insert the Graphic.
SdPage* pPage = mrDocument.GetSdPage(nPageNumber++, PageKind::Standard);
- Size aGrfSize(OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(),
- MapMode(MapUnit::Map100thMM)));
-
- Size aPagSize(pPage->GetSize());
- aPagSize.AdjustWidth(-(pPage->GetLeftBorder() + pPage->GetRightBorder()));
- aPagSize.AdjustHeight(-(pPage->GetUpperBorder() + pPage->GetLowerBorder()));
-
- // scale to fit page
- if (((aGrfSize.Height() > aPagSize.Height()) || (aGrfSize.Width() > aPagSize.Width()))
- && aGrfSize.Height() && aPagSize.Height())
- {
- const double fGrfWH = static_cast<double>(aGrfSize.Width()) / aGrfSize.Height();
- const double fWinWH = static_cast<double>(aPagSize.Width()) / aPagSize.Height();
-
- // adjust graphic to page size (scales)
- if (fGrfWH < fWinWH)
- {
- aGrfSize.setWidth(static_cast<long>(aPagSize.Height() * fGrfWH));
- aGrfSize.setHeight(aPagSize.Height());
- }
- else if (fGrfWH > 0.F)
- {
- aGrfSize.setWidth(aPagSize.Width());
- aGrfSize.setHeight(static_cast<long>(aPagSize.Width() / fGrfWH));
- }
- }
-
- // set output rectangle for graphic
- Point aPos;
- aPos.setX(((aPagSize.Width() - aGrfSize.Width()) >> 1) + pPage->GetLeftBorder());
- aPos.setY(((aPagSize.Height() - aGrfSize.Height()) >> 1) + pPage->GetUpperBorder());
+ const Size aGrfSize(OutputDevice::LogicToLogic(
+ aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)));
+
+ // Make the page size match the rendered image.
+ pPage->SetSize(aGrfSize);
+ Point aPos(0, 0);
pPage->InsertObject(new SdrGrafObj(pPage->getSdrModelFromSdrPage(), aGraphic,
::tools::Rectangle(aPos, aGrfSize)));