summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-03-29 16:30:19 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-06-07 21:15:13 +0200
commitef4f5a6433259e441dbf0e0295a9d07644b43e2c (patch)
treea650a7cf40f20dacf629d734a29f4319efc6cc11 /sd
parent6b9992998672cf0c0e1dcedf76bc0b49ca8f5751 (diff)
pdfium: fix setting the size of the document when opening PDF
When loading the pages of PDF, the size of the document was set to the wrong value. Size returned by ImportPDFUnloaded was in pixels, which is not really useful considering the svx and sd core uses 100th mm as the unit and converting it to a device dependent pixel will just bring grief. Also we don't need to know the size in pixels until we actually render. This change removes DPI as the parameter to the ImportPDFUnloaded and changes the code to get the size of the page from the PDF as points and converts that to 100th mm. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91330 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 489b18edd6dc87287f260ba87d95abcc95d87932) Change-Id: I0c0db23d2775e2897ba7621ef6320a974c0b9275 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95641 Tested-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/filter/pdf/sdpdffilter.cxx17
1 files changed, 4 insertions, 13 deletions
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index 8980e902ec73..c1069da58233 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -40,11 +40,8 @@ bool SdPdfFilter::Import()
const OUString aFileName(
mrMedium.GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::NONE));
- // Rendering resolution.
- const double dResolutionDPI = 96.0;
-
std::vector<std::pair<Graphic, Size>> aGraphics;
- if (vcl::ImportPDFUnloaded(aFileName, aGraphics, dResolutionDPI) == 0)
+ if (vcl::ImportPDFUnloaded(aFileName, aGraphics) == 0)
return false;
// Add as many pages as we need up-front.
@@ -57,26 +54,20 @@ bool SdPdfFilter::Import()
for (const std::pair<Graphic, Size>& aPair : aGraphics)
{
const Graphic& rGraphic = aPair.first;
- const Size& aSize = aPair.second;
+ const Size& aSizeHMM = aPair.second;
const sal_Int32 nPageNumber = rGraphic.getPageNumber();
assert(nPageNumber >= 0 && static_cast<size_t>(nPageNumber) < aGraphics.size());
// Create the page and insert the Graphic.
SdPage* pPage = mrDocument.GetSdPage(nPageNumber, PageKind::Standard);
- Size aGraphicSize(OutputDevice::LogicToLogic(aSize, rGraphic.GetPrefMapMode(),
- MapMode(MapUnit::Map100thMM)));
-
- // Resize to original size based on 72 dpi to preserve page size.
- aGraphicSize = Size(aGraphicSize.Width() * 72.0 / dResolutionDPI,
- aGraphicSize.Height() * 72.0 / dResolutionDPI);
// Make the page size match the rendered image.
- pPage->SetSize(aGraphicSize);
+ pPage->SetSize(aSizeHMM);
Point aPosition(0, 0);
SdrGrafObj* pSdrGrafObj = new SdrGrafObj(pPage->getSdrModelFromSdrPage(), rGraphic,
- tools::Rectangle(aPosition, aGraphicSize));
+ tools::Rectangle(aPosition, aSizeHMM));
pPage->InsertObject(pSdrGrafObj);
}