summaryrefslogtreecommitdiff
path: root/svx/source
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-05-14 08:15:30 -0400
committerJan Holesovsky <kendy@collabora.com>2018-06-01 08:59:11 +0200
commit396e8bb3f0406c36bf0428c3e220aba7c5ab5f12 (patch)
treeed2daf2b170f12c0c27919c0f290a8d5659d79e8 /svx/source
parent52a0b46bfdc32e5c37b3d7343a42c6388f3d569d (diff)
svx: share PDF stream when saving imported PDF as images
Change-Id: I05dd9ccb8f61c795212f8c587ee0a69c3cd75cf6
Diffstat (limited to 'svx/source')
-rw-r--r--svx/source/xml/xmlgrhlp.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 62491105c116..b04af09f9734 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -40,6 +40,7 @@
#include <vcl/cvtgrf.hxx>
#include <vcl/gfxlink.hxx>
#include <vcl/metaact.hxx>
+#include <tools/stream.hxx>
#include <tools/zcodec.hxx>
#include <vcl/graphicfilter.hxx>
@@ -545,15 +546,22 @@ bool SvXMLGraphicHelper::ImplWriteGraphic( const OUString& rPictureStorageName,
std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream( aStream.xStream ));
if( bUseGfxLink && aGfxLink.GetDataSize() && aGfxLink.GetData() )
{
- const std::shared_ptr<uno::Sequence<sal_Int8>>& rPdfData = aGraphic.getPdfData();
- if (rPdfData && rPdfData->hasElements())
+ if (aGraphic.hasPdfData())
{
+ // See if we have this PDF already, and avoid duplicate storage.
+ auto aIt = maExportPdf.find(aGraphic.getPdfData().get());
+ if (aIt != maExportPdf.end())
+ return true;
+
// The graphic has PDF data attached to it, use that.
// vcl::ImportPDF() possibly downgraded the PDF data from a
// higher PDF version, while aGfxLink still contains the
// original data provided by the user.
- pStream->WriteBytes(rPdfData->getConstArray(), rPdfData.getLength());
- bRet = (pStream->GetError() == ERRCODE_NONE);
+ std::shared_ptr<uno::Sequence<sal_Int8>> pPdfData = aGraphic.getPdfData();
+ pStream->WriteBytes(pPdfData->getConstArray(), pPdfData->getLength());
+
+ // put into cache
+ maExportPdf[aGraphic.getPdfData().get()] = std::make_pair(rPictureStreamName, aMimeType);
}
else
pStream->WriteBytes(aGfxLink.GetData(), aGfxLink.GetDataSize());