Kaydet (Commit) 04e27df3 authored tarafından Miklos Vajna's avatar Miklos Vajna

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/37938Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst ea224bbc
......@@ -124,6 +124,9 @@ public:
const OUString& rStreamName,
const WMF_EXTERNALHEADER* pExtHeader = nullptr ) const;
/** Imports graphics from the storage with the passed stream names. */
void importEmbeddedGraphics(const std::vector<OUString>& rStreamNames) const;
/** Creates a persistent graphic object from the passed graphic.
@return The URL of the created and internally cached graphic object. */
OUString createGraphicObject(
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment