summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-12-18 11:17:53 +0100
committerMiklos Vajna <vmiklos@collabora.com>2021-01-18 09:14:00 +0100
commitf22b4c63cfb09bd38c502a650775b0d27b50b480 (patch)
tree43bc37fd0cd17241bd28f162e53cbcc305d0118d /oox
parentf55352d5e79980c358653d18008ac047dc3e0118 (diff)
do not preload all images in the pptx importer
Now with my GraphicFilter::MakeGraphicsAvailableThreaded() patches for Impress images will be loaded in parallel as they are needed, which should usually be more efficient than loading all of them immediately. This basically reverts commits: b1319842a49cdf6512bbd9e81081e2a9edbd6089 04e27df3c162f1df02f061b94434a38d1eaa3a46 9eb8e2737d3a4d52ce1b0cc44091a3b7ecf59e3b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107945 Tested-by: Luboš Luňák <l.lunak@collabora.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com> (cherry picked from commit afa3dff9c7b963f1d312ef8c2efcbc8ab7271e62) Change-Id: I46bb0d6d93fb69f03f464308f6fce1603aafdfd8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109393 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/helper/graphichelper.cxx67
-rw-r--r--oox/source/ppt/pptimport.cxx40
2 files changed, 0 insertions, 107 deletions
diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx
index e43f7ee655fa..7473b2bdc60f 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -39,7 +39,6 @@
#include <vcl/svapp.hxx>
#include <vcl/outdev.hxx>
#include <tools/gen.hxx>
-#include <comphelper/propertysequence.hxx>
#include <comphelper/sequence.hxx>
#include <oox/helper/containerhelper.hxx>
#include <oox/helper/propertyset.hxx>
@@ -281,27 +280,6 @@ Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStrea
return xGraphic;
}
-std::vector< uno::Reference<graphic::XGraphic> > GraphicHelper::importGraphics(const std::vector< uno::Reference<io::XInputStream> >& rStreams) const
-{
- std::vector< uno::Sequence<beans::PropertyValue> > aArgsVec;
-
- for (const auto& rStream : rStreams)
- {
- uno::Sequence<beans::PropertyValue > aArgs = comphelper::InitPropertySequence(
- {
- {"InputStream", uno::makeAny(rStream)}
- });
- aArgsVec.push_back(aArgs);
- }
-
- std::vector< uno::Reference<graphic::XGraphic> > aRet;
-
- if (mxGraphicProvider.is())
- aRet = comphelper::sequenceToContainer< std::vector< uno::Reference<graphic::XGraphic> > >(mxGraphicProvider->queryGraphics(comphelper::containerToSequence(aArgsVec)));
-
- return aRet;
-}
-
Reference< XGraphic > GraphicHelper::importGraphic( const StreamDataSequence& rGraphicData ) const
{
Reference< XGraphic > xGraphic;
@@ -313,51 +291,6 @@ 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.
-
- // Stream names and streams to be imported.
- std::vector<OUString> aMissingStreamNames;
- std::vector< uno::Reference<io::XInputStream> > aMissingStreams;
-
- initializeGraphicMapperIfNeeded();
-
- SAL_WARN_IF(!mxGraphicMapper.is(), "oox", "GraphicHelper::importEmbeddedGraphic - graphic mapper not available");
-
- for (const auto& rStreamName : rStreamNames)
- {
-
- if (rStreamName.isEmpty())
- {
- SAL_WARN("oox", "GraphicHelper::importEmbeddedGraphics - empty stream name");
- continue;
- }
-
- Reference<XGraphic> xGraphic;
-
- xGraphic = mxGraphicMapper->findGraphic(rStreamName);
-
- if (!xGraphic.is())
- {
- aMissingStreamNames.push_back(rStreamName);
- aMissingStreams.push_back(mxStorage->openInputStream(rStreamName));
- }
- }
-
- std::vector< uno::Reference<graphic::XGraphic> > aGraphics = importGraphics(aMissingStreams);
-
-
- assert(aGraphics.size() == aMissingStreamNames.size());
- for (size_t i = 0; i < aGraphics.size(); ++i)
- {
- if (aGraphics[i].is())
- {
- mxGraphicMapper->putGraphic(aMissingStreamNames[i], aGraphics[i]);
- }
- }
-}
-
Reference< XGraphic > GraphicHelper::importEmbeddedGraphic( const OUString& rStreamName, const WmfExternal* pExtHeader ) const
{
Reference< XGraphic > xGraphic;
diff --git a/oox/source/ppt/pptimport.cxx b/oox/source/ppt/pptimport.cxx
index 99c528071226..a6233c22b88b 100644
--- a/oox/source/ppt/pptimport.cxx
+++ b/oox/source/ppt/pptimport.cxx
@@ -73,36 +73,6 @@ PowerPointImport::~PowerPointImport()
maPPTShapes.clear();
}
-/// Visits the relations from pRelations which are of type rType.
-static void visitRelations(PowerPointImport& rImport, const core::RelationsRef& pRelations, const OUString& rType, std::vector<OUString>& rImageFragments)
-{
- if (core::RelationsRef pRelationsOfType = pRelations->getRelationsFromTypeFromOfficeDoc(rType))
- {
- for (const auto& rRelation : *pRelationsOfType)
- {
- OUString aFragment = pRelationsOfType->getFragmentPathFromRelation(rRelation.second);
- if (core::RelationsRef pFragmentRelations = rImport.importRelations(aFragment))
- {
- // See if the fragment has images.
- if (core::RelationsRef pImages = pFragmentRelations->getRelationsFromTypeFromOfficeDoc("image"))
- {
- for (const auto& rImage : *pImages)
- {
- 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.
- visitRelations(rImport, pFragmentRelations, "slideLayout", rImageFragments);
- }
- }
- }
-}
-
bool PowerPointImport::importDocument()
{
/* to activate the PPTX dumper, define the environment variable
@@ -131,16 +101,6 @@ bool PowerPointImport::importDocument()
const OUString sPresPropsPath
= xPresentationFragmentHandler->getFragmentPathFromFirstTypeFromOfficeDoc("presProps");
- // importRelations() is cheap, it will do an actual import for the first time only.
- if (core::RelationsRef pFragmentRelations = importRelations(aFragmentPath))
- {
- std::vector<OUString> aImageFragments;
- visitRelations(*this, pFragmentRelations, "slide", aImageFragments);
- visitRelations(*this, pFragmentRelations, "slideMaster", aImageFragments);
-
- getGraphicHelper().importEmbeddedGraphics(aImageFragments);
- }
-
bool bRet = importFragment(xPresentationFragmentHandler);
if (bRet && !sPresPropsPath.isEmpty())
{