vcl/source/filter/ipdf/pdfread.cxx | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
New commits: commit 32ace69e0e449d63bf11f2955c18a22ddd0482c7 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Jun 15 14:01:49 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon Jun 29 20:36:11 2020 +0200 vcl: use pdfium c++ wraper classes in ImportPDFUnloaded Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96754 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 4fa45de60601d34b3a821b35b5aca72f494a7487) Change-Id: I1d0d97f4b981fa62aa38dc5ceaf89d3976bbccbe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97436 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx index fac5667219c1..049a51a84257 100644 --- a/vcl/source/filter/ipdf/pdfread.cxx +++ b/vcl/source/filter/ipdf/pdfread.cxx @@ -247,29 +247,23 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<std::pair<Graphic, Si auto pPdfium = vcl::pdf::PDFiumLibrary::get(); // Load the buffer using pdfium. - FPDF_DOCUMENT pPdfDocument - = FPDF_LoadMemDocument(pGfxLink->GetData(), pGfxLink->GetDataSize(), /*password=*/nullptr); + auto pPdfDocument = pPdfium->openDocument(pGfxLink->GetData(), pGfxLink->GetDataSize()); + if (!pPdfDocument) return 0; - const int nPageCount = FPDF_GetPageCount(pPdfDocument); + const int nPageCount = pPdfDocument->getPageCount(); if (nPageCount <= 0) return 0; for (int nPageIndex = 0; nPageIndex < nPageCount; ++nPageIndex) { - double fPageWidth = 0; - double fPageHeight = 0; - if (FPDF_GetPageSizeByIndex(pPdfDocument, nPageIndex, &fPageWidth, &fPageHeight) == 0) + basegfx::B2DSize aPageSize = pPdfDocument->getPageSize(nPageIndex); + if (aPageSize.getX() <= 0.0 || aPageSize.getY() <= 0.0) continue; - // 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; + long nPageWidth = convertPointToMm100(aPageSize.getX()); + long nPageHeight = convertPointToMm100(aPageSize.getY()); auto aVectorGraphicDataPtr = std::make_shared<VectorGraphicData>( aPdfDataArray, OUString(), VectorGraphicDataType::Pdf, nPageIndex); @@ -283,8 +277,6 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<std::pair<Graphic, Si rGraphics.emplace_back(std::move(aGraphic), Size(nPageWidth, nPageHeight)); } - FPDF_CloseDocument(pPdfDocument); - return rGraphics.size(); #else (void)rURL; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits