summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-04-09 01:06:43 -0400
committerJan Holesovsky <kendy@collabora.com>2018-06-06 12:48:27 +0200
commitf38c6917c0c3f2c8d3be4f422eff65cabc493d96 (patch)
tree9b8b3f5918b9baf73c9bde3a3a4926e7c25e2998
parent3fdaadbf8c63c68a1de0043e3f0ea9e336d0470e (diff)
svx: share PDF stream when saving imported PDF as images
Still needs work, incomplete. Change-Id: Ide0c3f0792e816d64a81922a653a8afd77c7511a
-rw-r--r--include/svx/xmlgrhlp.hxx1
-rw-r--r--svx/source/xml/xmlgrhlp.cxx11
2 files changed, 12 insertions, 0 deletions
diff --git a/include/svx/xmlgrhlp.hxx b/include/svx/xmlgrhlp.hxx
index 7cea0279bab0..d6973104f72e 100644
--- a/include/svx/xmlgrhlp.hxx
+++ b/include/svx/xmlgrhlp.hxx
@@ -58,6 +58,7 @@ private:
std::unordered_map<OUString, css::uno::Reference<css::graphic::XGraphic>> maGraphicObjects;
std::unordered_map<Graphic, std::pair<OUString, OUString>> maExportGraphics;
+ std::unordered_map<void*, std::pair<OUString, OUString>> maExportPdf;
SvXMLGraphicHelperMode meCreateMode;
OUString maOutputMimeType;
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 718703487559..238b8dda3c91 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -766,6 +766,15 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::X
{
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())
+ {
+ auto const& aURLAndMimePair = aIt->second;
+ rOutSavedMimeType = aURLAndMimePair.second;
+ return aURLAndMimePair.first;
+ }
+
// 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
@@ -844,6 +853,8 @@ OUString SvXMLGraphicHelper::implSaveGraphic(css::uno::Reference<css::graphic::X
// put into cache
maExportGraphics[aGraphic] = std::make_pair(aStoragePath, rOutSavedMimeType);
+ if (aGraphic.hasPdfData())
+ maExportPdf[aGraphic.getPdfData().get()] = std::make_pair(aStoragePath, rOutSavedMimeType);
return aStoragePath;
}