summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2018-06-21 21:33:56 +0200
committerJan Holesovsky <kendy@collabora.com>2019-03-26 12:01:58 +0100
commit62654a8c29b945d00afe9f32e87b44ba0d8b84a2 (patch)
tree83c14b6dc38acdaa24958f567c24e9160f41e428 /vcl
parentc8f81dbb30e89a19bb7a82f8b52cc02b9049e717 (diff)
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 <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com> Change-Id: Id7e8c4543368b0caf3e459abaff8c53997779c83 Reviewed-on: https://gerrit.libreoffice.org/69625 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/impgraph.hxx3
-rw-r--r--vcl/source/gdi/graph.cxx6
-rw-r--r--vcl/source/gdi/impgraph.cxx31
3 files changed, 36 insertions, 4 deletions
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();