include/vcl/graph.hxx | 1 + sd/source/filter/pdf/sdpdffilter.cxx | 2 +- vcl/inc/impgraph.hxx | 3 ++- vcl/source/gdi/graph.cxx | 6 ++++++ vcl/source/gdi/impgraph.cxx | 31 ++++++++++++++++++++++++++++--- 5 files changed, 38 insertions(+), 5 deletions(-)
New commits: commit 62654a8c29b945d00afe9f32e87b44ba0d8b84a2 Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Thu Jun 21 21:33:56 2018 +0200 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Tue Mar 26 12:01:58 2019 +0100 pdfium: Share the GfxLink for PDF files. Partially based on work by Ashod Nakashian, thanks! Reviewed-on: https://gerrit.libreoffice.org/56265 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> Change-Id: Id7e8c4543368b0caf3e459abaff8c53997779c83 Reviewed-on: https://gerrit.libreoffice.org/69625 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx index 45268462155a..881abda221e4 100644 --- a/include/vcl/graph.hxx +++ b/include/vcl/graph.hxx @@ -216,6 +216,7 @@ private: public: void SetLink( const GfxLink& ); + void SetSharedLink(const std::shared_ptr<GfxLink>& pGfxLink); GfxLink GetLink() const; bool IsLink() const; diff --git a/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx index a4747456123b..95daaeb479f1 100644 --- a/sd/source/filter/pdf/sdpdffilter.cxx +++ b/sd/source/filter/pdf/sdpdffilter.cxx @@ -128,7 +128,7 @@ bool SdPdfFilter::Import() Graphic aGraphic(aBitmap); aGraphic.setPdfData(pPdfData); aGraphic.setPageNumber(nPageNumber); - aGraphic.SetLink(aGfxLink); + aGraphic.SetSharedLink(pGfxLink); aGraphic.setOriginURL(aFileName); // Create the page and insert the Graphic. diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx index c462dc2c67ac..3d998ec94ac5 100644 --- a/vcl/inc/impgraph.hxx +++ b/vcl/inc/impgraph.hxx @@ -160,7 +160,8 @@ private: bool ImplIsSwapOut() const { return mbSwapOut;} bool ImplIsDummyContext() const { return mbDummyContext; } - void ImplSetLink( const std::shared_ptr<GfxLink>& ); + void ImplSetLink( const GfxLink& ); + void ImplSetSharedLink(const std::shared_ptr<GfxLink>& pGfxLink); GfxLink ImplGetLink(); bool ImplIsLink() const; diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx index 1fc7897ac90b..04e567e44d5d 100644 --- a/vcl/source/gdi/graph.cxx +++ b/vcl/source/gdi/graph.cxx @@ -569,6 +569,12 @@ void Graphic::SetLink( const GfxLink& rGfxLink ) mxImpGraphic->ImplSetLink( rGfxLink ); } +void Graphic::SetSharedLink(const std::shared_ptr<GfxLink>& pGfxLink) +{ + ImplTestRefCount(); + mxImpGraphic->ImplSetSharedLink(pGfxLink); +} + GfxLink Graphic::GetLink() const { return mxImpGraphic->ImplGetLink(); diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx index 2d73357ec43d..6e837c979e78 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -125,6 +125,14 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic) , maGraphicExternalLink(rImpGraphic.maGraphicExternalLink) , mnPageNumber(rImpGraphic.mnPageNumber) { + if( rImpGraphic.mpGfxLink ) + { + if (rImpGraphic.mpGfxLink->GetType() == GfxLinkType::NativePdf) + mpGfxLink = rImpGraphic.mpGfxLink; + else + mpGfxLink = std::make_shared<GfxLink>(*rImpGraphic.mpGfxLink); + } + if( rImpGraphic.mpAnimation ) { mpAnimation = o3tl::make_unique<Animation>( *rImpGraphic.mpAnimation ); @@ -237,9 +245,18 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic ) mbSwapOut = rImpGraphic.mbSwapOut; mpSwapFile = rImpGraphic.mpSwapFile; - mpGfxLink = rImpGraphic.mpGfxLink; + if (rImpGraphic.mpGfxLink) + { + if (rImpGraphic.mpGfxLink->GetType() == GfxLinkType::NativePdf) + mpGfxLink = rImpGraphic.mpGfxLink; + else + { + mpGfxLink.reset(); + + mpGfxLink = std::make_shared<GfxLink>(*rImpGraphic.mpGfxLink); + } + } - maVectorGraphicData = rImpGraphic.maVectorGraphicData; mpPdfData = rImpGraphic.mpPdfData; } @@ -1367,7 +1384,15 @@ bool ImpGraphic::ImplSwapIn( SvStream* xIStm ) void ImpGraphic::ImplSetLink(const GfxLink& rGfxLink) { - mpGfxLink = rGfxLink; + mpGfxLink = std::make_shared<GfxLink>( rGfxLink ); + + if( mpGfxLink->IsNative() ) + mpGfxLink->SwapOut(); +} + +void ImpGraphic::ImplSetSharedLink(const std::shared_ptr<GfxLink>& pGfxLink) +{ + mpGfxLink = pGfxLink; if (mpGfxLink && mpGfxLink->IsNative()) mpGfxLink->SwapOut(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits