summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-04-09 01:06:43 -0400
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-04-09 01:06:46 -0400
commit9c2ed67ad6b9781d3c2ec28a4e38a7e48327d8dd (patch)
tree3f33b9a1fb776cbb52b1fb7a50f0658d7f0a2117
parent26ef34cda7e0404689fb30e3b345476cc0df32f7 (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--sd/source/filter/pdf/sdpdffilter.cxx1
-rw-r--r--svx/source/xml/xmlgrhlp.cxx11
3 files changed, 12 insertions, 1 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/sd/source/filter/pdf/sdpdffilter.cxx b/sd/source/filter/pdf/sdpdffilter.cxx
index b5db8b875b4d..35f2bee5a791 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -125,7 +125,6 @@ bool SdPdfFilter::Import()
aGraphic.setPdfData(std::make_shared<uno::Sequence<sal_Int8>>(aPdfData));
aGraphic.setPageNumber(nPageNumber);
aGraphic.SetLink(aGfxLink);
- aGraphic.setOriginURL(aFileName);
// Create the page and insert the Graphic.
SdPage* pPage = mrDocument.GetSdPage(nPageNumber++, PageKind::Standard);
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 645c8e923be8..a3d2b26934f6 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -762,6 +762,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
@@ -840,6 +849,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;
}