sd/source/filter/pdf/sdpdffilter.cxx | 10 ++++++++-- vcl/source/filter/ipdf/pdfread.cxx | 11 ++++++++--- vcl/source/gdi/impgraph.cxx | 10 ++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-)
New commits: commit 53a2ff7260b61242c7e29af11c2e24c89857c233 Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Fri Jun 22 12:58:12 2018 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sat Mar 21 15:50:09 2020 +0100 pdfium: Delay the swap out. If we swap out too early, the constructor of GraphicObject forces a swap in, so we'd render everything during the load anyway. Change-Id: I0ea1a755242fd57ef28d082ce4bf534a32199f87 Reviewed-on: https://gerrit.libreoffice.org/56286 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> (cherry picked from commit 242c7663e275a712430a8c4ac8eeacbb8b3bd440) Reviewed-on: https://gerrit.libreoffice.org/77690 Tested-by: Jenkins (cherry picked from commit 81f73f1c1706d790c010e8fc0abcb2a0e9e86ace) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90840 Tested-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx index 9274cb3b3730..e40bd98b5799 100644 --- a/sd/source/filter/pdf/sdpdffilter.cxx +++ b/sd/source/filter/pdf/sdpdffilter.cxx @@ -135,8 +135,14 @@ bool SdPdfFilter::Import() pPage->SetSize(aGrfSize); Point aPos(0, 0); - pPage->InsertObject(new SdrGrafObj(pPage->getSdrModelFromSdrPage(), rGraphic, - tools::Rectangle(aPos, aGrfSize))); + SdrGrafObj* pSdrGrafObj = new SdrGrafObj(pPage->getSdrModelFromSdrPage(), rGraphic, + tools::Rectangle(aPos, aGrfSize)); + pPage->InsertObject(pSdrGrafObj); + + // we know that the initial bitmap we provided was just a placeholder, + // we need to swap it out, so that on the next swap in, we render the + // correct one + // const_cast<GraphicObject&>(pSdrGrafObj->GetGraphicObject()).SwapOut(); } return true; diff --git a/vcl/source/filter/ipdf/pdfread.cxx b/vcl/source/filter/ipdf/pdfread.cxx index 3687f301b2e9..b7b43c1d0d4d 100644 --- a/vcl/source/filter/ipdf/pdfread.cxx +++ b/vcl/source/filter/ipdf/pdfread.cxx @@ -312,6 +312,9 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<std::pair<Graphic, Si if (nPageCount <= 0) return 0; + // dummy Bitmap + Bitmap aBitmap(Size(1, 1), 24); + for (size_t nPageIndex = 0; nPageIndex < static_cast<size_t>(nPageCount); ++nPageIndex) { double fPageWidth = 0; @@ -323,9 +326,11 @@ size_t ImportPDFUnloaded(const OUString& rURL, std::vector<std::pair<Graphic, Si const size_t nPageWidth = pointToPixel(fPageWidth, fResolutionDPI); const size_t nPageHeight = pointToPixel(fPageHeight, fResolutionDPI); - // Create the Graphic and link the original PDF stream. - Graphic aGraphic; - aGraphic.setPdfData(pPdfData); // TODO: Skip if unchanged. + // Create the Graphic with a dummy Bitmap and link the original PDF stream. + // We swap out this Graphic as soon as possible, and a later swap in + // actually renders the correct Bitmap on demand. + Graphic aGraphic(aBitmap); + aGraphic.setPdfData(pPdfData); aGraphic.setPageNumber(nPageIndex); aGraphic.SetGfxLink(pGfxLink); diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 4e3d6c6b4be9..f3806ae06a53 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -124,6 +124,16 @@ GraphicID::GraphicID(ImpGraphic const & rGraphic) mnID3 = basegfx::fround(rRange.getHeight()); mnID4 = vcl_get_checksum(0, rVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(), rVectorGraphicDataPtr->getVectorGraphicDataArrayLength()); } + else if (rGraphic.hasPdfData()) + { + std::shared_ptr<css::uno::Sequence<sal_Int8>> pPdfData = rGraphic.getPdfData(); + const BitmapEx& rBmpEx = rGraphic.ImplGetBitmapExRef(); + + mnID1 |= (rGraphic.mnPageNumber & 0x0fffffff); + mnID2 = rBmpEx.GetSizePixel().Width(); + mnID3 = rBmpEx.GetSizePixel().Height(); + mnID4 = vcl_get_checksum(0, pPdfData->getConstArray(), pPdfData->getLength()); + } else if (rGraphic.ImplIsAnimated()) { const Animation aAnimation(rGraphic.ImplGetAnimation()); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits