summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-05-24 06:59:39 -0400
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-06-04 12:36:28 -0400
commite7a4f2a27ad9a6d4f7da9734f846137b50338340 (patch)
treea2102a0a8962381d74c88c6e9040bdcdd968a09a
parent01c3661b0db04911db5b7c36337f0f80d5bc6640 (diff)
sd: make the imported PDF page exactly as original
i.e. no borders or larger page than rendered PDF Reviewed-on: https://gerrit.libreoffice.org/54764 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com> (cherry picked from commit 570c9afc48526c1a85d17d2d9c7c235cba4104ed) Change-Id: I1f356cceeec1d5d9f1728f0e29160fdd9241a221
-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 cb230849d8a8..71eecabfb3b0 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -128,37 +128,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 the output rectangle of the 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)));