summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-04-20 16:32:00 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-04-20 21:04:35 +0200
commitedda1e5fc8113aa4744e32f97c96a3cc311485ca (patch)
treeb6da5a4a637a9a3ae3ed9307fe59d6f1df80b197 /oox
parente9c52f55f0cc7155d6883e4d2abf14f1638b03b3 (diff)
DOCX import: lazy-read images without external headers
So that similar to ODT, images are not loaded on file open, only when the user scrolls there. Notes: 1) GraphicDescriptor::ImpDetectJPG() would try to calculate the logic size before the pixel size is available, so the logic size would be 0x0. Also, ImpGraphic::ImplSetPrepared() would always work with a pixel map mode. Any of these two would result in a failure of testDMLShapeFillBitmapCrop in CppunitTest_sw_ooxmlexport6. 2) Lazy-loading seems to (at the moment) not recognize EMF files, so don't lazy-load in case an external header is provided. This probably has to be revisited, since the ODF import doesn't go via GraphicProvider::queryGraphic(). Change-Id: I44754e659effebca8339715df114dbaadb9b5e9f Reviewed-on: https://gerrit.libreoffice.org/53215 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.cxx15
1 files changed, 11 insertions, 4 deletions
diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx
index 7f4262de787c..002d54b946b5 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -238,11 +238,13 @@ Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStrea
Reference< XGraphic > xGraphic;
if( rxInStrm.is() && mxGraphicProvider.is() ) try
{
- Sequence< PropertyValue > aArgs( 1 );
+ Sequence< PropertyValue > aArgs( 2 );
aArgs[ 0 ].Name = "InputStream";
aArgs[ 0 ].Value <<= rxInStrm;
+ aArgs[ 1 ].Name = "LazyRead";
+ aArgs[ 1 ].Value <<= true;
- if ( pExtHeader && pExtHeader->mapMode > 0 )
+ if ( pExtHeader )
{
aArgs.realloc( aArgs.getLength() + 1 );
Sequence< PropertyValue > aFilterData( 3 );
@@ -252,8 +254,8 @@ Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStrea
aFilterData[ 1 ].Value <<= pExtHeader->yExt;
aFilterData[ 2 ].Name = "ExternalMapMode";
aFilterData[ 2 ].Value <<= pExtHeader->mapMode;
- aArgs[ 1 ].Name = "FilterData";
- aArgs[ 1 ].Value <<= aFilterData;
+ aArgs[ 2 ].Name = "FilterData";
+ aArgs[ 2 ].Value <<= aFilterData;
}
xGraphic = mxGraphicProvider->queryGraphic( aArgs );
@@ -339,6 +341,11 @@ Reference< XGraphic > GraphicHelper::importEmbeddedGraphic( const OUString& rStr
EmbeddedGraphicMap::const_iterator aIt = maEmbeddedGraphics.find( rStreamName );
if( aIt == maEmbeddedGraphics.end() )
{
+ // TODO make lazy-load work for EMF as well.
+ WmfExternal aHeader;
+ if (rStreamName.endsWith(".emf") && !pExtHeader)
+ pExtHeader = &aHeader;
+
xGraphic = importGraphic(mxStorage->openInputStream(rStreamName), pExtHeader);
if( xGraphic.is() )
maEmbeddedGraphics[ rStreamName ] = xGraphic;