summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-05-23 09:25:37 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-05-23 10:18:03 +0200
commit04e27df3c162f1df02f061b94434a38d1eaa3a46 (patch)
treec47fcc6fe970e2950163d9fce5931f228c6ecc9a /oox
parentea224bbcdc94bd9bf6a57e57150e78c408926e7e (diff)
oox: add GraphicHelper::importEmbeddedGraphics()
Similar to GraphicHelper::importEmbeddedGraphic(), but it takes a list of image paths to import. Change-Id: I11b670a0b2c693540054c78be2cee3835477b7e6 Reviewed-on: https://gerrit.libreoffice.org/37938 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/helper/graphichelper.cxx28
-rw-r--r--oox/source/ppt/pptimport.cxx16
2 files changed, 36 insertions, 8 deletions
diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx
index f4ac89353b57..abe062cc82f4 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -274,6 +274,34 @@ Reference< XGraphic > GraphicHelper::importGraphic( const StreamDataSequence& rG
return xGraphic;
}
+void GraphicHelper::importEmbeddedGraphics(const std::vector<OUString>& rStreamNames) const
+{
+ // Don't actually return anything, just fill maEmbeddedGraphics.
+
+ // Input stream -> stream name map.
+ std::map< uno::Reference<io::XInputStream>, OUString > aStreamNames;
+
+ for (const auto& rStreamName : rStreamNames)
+ {
+ if(rStreamName.isEmpty())
+ {
+ SAL_WARN("oox", "GraphicHelper::importEmbeddedGraphics - empty stream name");
+ continue;
+ }
+
+ EmbeddedGraphicMap::const_iterator aIt = maEmbeddedGraphics.find(rStreamName);
+ if (aIt == maEmbeddedGraphics.end())
+ aStreamNames[mxStorage->openInputStream(rStreamName)] = rStreamName;
+ }
+
+ for (const auto& rStream : aStreamNames)
+ {
+ uno::Reference<graphic::XGraphic> xGraphic = importGraphic(rStream.first);
+ if (xGraphic.is())
+ maEmbeddedGraphics[rStream.second] = xGraphic;
+ }
+}
+
Reference< XGraphic > GraphicHelper::importEmbeddedGraphic( const OUString& rStreamName, const WMF_EXTERNALHEADER* pExtHeader ) const
{
Reference< XGraphic > xGraphic;
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index 74285e7dbe97..474abb6278e2 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -100,7 +100,13 @@ static void visitRelations(PowerPointImport& rImport, core::RelationsRef pRelati
if (core::RelationsRef pImages = pFragmentRelations->getRelationsFromTypeFromOfficeDoc("image"))
{
for (const auto& rImage : *pImages)
- rImageFragments.push_back(pImages->getFragmentPathFromRelation(rImage.second));
+ {
+ OUString aPath = pImages->getFragmentPathFromRelation(rImage.second);
+ // Safe subset: e.g. WMF may have an external header from the
+ // referencing fragment.
+ if (aPath.endsWith(".jpg") || aPath.endsWith(".jpeg"))
+ rImageFragments.push_back(aPath);
+ }
}
// See if the fragment has a slide layout, and recurse.
@@ -130,13 +136,7 @@ bool PowerPointImport::importDocument()
visitRelations(*this, pFragmentRelations, "slide", aImageFragments);
visitRelations(*this, pFragmentRelations, "slideMaster", aImageFragments);
- for (const auto& rImage : aImageFragments)
- {
- // Safe subset: e.g. WMF may have an external header from the
- // referencing fragment.
- if (rImage.endsWith(".jpg") || rImage.endsWith(".jpeg"))
- getGraphicHelper().importEmbeddedGraphic(rImage);
- }
+ getGraphicHelper().importEmbeddedGraphics(aImageFragments);
}
bool bRet = importFragment(xPresentationFragmentHandler);