summaryrefslogtreecommitdiff
path: root/vcl/source/filter
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 /vcl/source/filter
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 'vcl/source/filter')
-rw-r--r--vcl/source/filter/ipdf/pdfread.cxx14
1 files changed, 8 insertions, 6 deletions
diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx
index b734a7bc4420..091b4cd37850 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -234,8 +234,7 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
return true;
}
-size_t ImportPDFUnloaded(const OUString& rURL, std::vector<std::pair<Graphic, Size>>& rGraphics,
- const double fResolutionDPI)
+size_t ImportPDFUnloaded(const OUString& rURL, std::vector<std::pair<Graphic, Size>>& rGraphics)
{
#if HAVE_FEATURE_PDFIUM
std::unique_ptr<SvStream> xStream(
@@ -279,9 +278,13 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<std::pair<Graphic, Si
if (FPDF_GetPageSizeByIndex(pPdfDocument, nPageIndex, &fPageWidth, &fPageHeight) == 0)
continue;
- // Returned unit is points, convert that to pixel.
- const size_t nPageWidth = pointToPixel(fPageWidth, fResolutionDPI);
- const size_t nPageHeight = pointToPixel(fPageHeight, fResolutionDPI);
+ // Returned unit is points, convert that to 100th mm (hmm).
+ // 1 pt = 20 twips, 1 twip = 1.7638888888888889 hmm
+ // TODO: use some conversion class for that
+ constexpr double pointToHMMconversionRatio = 20.0 * 1.7638888888888889;
+
+ long nPageWidth = fPageWidth * pointToHMMconversionRatio;
+ long nPageHeight = fPageHeight * pointToHMMconversionRatio;
auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>(
aPdfDataArray, OUString(), VectorGraphicDataType::Pdf, nPageIndex);
@@ -302,7 +305,6 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<std::pair<Graphic, Si
#else
(void)rURL;
(void)rGraphics;
- (void)fResolutionDPI;
return 0;
#endif // HAVE_FEATURE_PDFIUM
}