summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filter/source/msfilter/msdffimp.cxx9
-rw-r--r--oox/source/helper/graphichelper.cxx7
-rw-r--r--sw/CppunitTest_sw_ww8import.mk1
-rw-r--r--sw/qa/extras/ww8import/data/image-lazy-read.docbin0 -> 26624 bytes
-rw-r--r--sw/qa/extras/ww8import/ww8import.cxx8
-rw-r--r--vcl/source/filter/graphicfilter.cxx1
-rw-r--r--vcl/source/graphic/UnoGraphicProvider.cxx6
7 files changed, 22 insertions, 10 deletions
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index f2fbc026c16d..3e80858d9275 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -6545,7 +6545,14 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool
else
{ // and unleash our filter
GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
- nRes = rGF.ImportGraphic( rData, "", *pGrStream );
+ Graphic aGraphic = rGF.ImportUnloadedGraphic(*pGrStream);
+ if (aGraphic)
+ {
+ rData = aGraphic;
+ nRes = ERRCODE_NONE;
+ }
+ else
+ nRes = rGF.ImportGraphic( rData, "", *pGrStream );
// SJ: I40472, sometimes the aspect ratio (aMtfSize100) does not match and we get scaling problems,
// then it is better to use the prefsize that is stored within the metafile. Bug #72846# for what the
diff --git a/oox/source/helper/graphichelper.cxx b/oox/source/helper/graphichelper.cxx
index 002d54b946b5..073cfe6d694f 100644
--- a/oox/source/helper/graphichelper.cxx
+++ b/oox/source/helper/graphichelper.cxx
@@ -244,7 +244,7 @@ Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStrea
aArgs[ 1 ].Name = "LazyRead";
aArgs[ 1 ].Value <<= true;
- if ( pExtHeader )
+ if ( pExtHeader && pExtHeader->mapMode > 0 )
{
aArgs.realloc( aArgs.getLength() + 1 );
Sequence< PropertyValue > aFilterData( 3 );
@@ -341,11 +341,6 @@ 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;
diff --git a/sw/CppunitTest_sw_ww8import.mk b/sw/CppunitTest_sw_ww8import.mk
index 7e40c058e722..b7102196a27f 100644
--- a/sw/CppunitTest_sw_ww8import.mk
+++ b/sw/CppunitTest_sw_ww8import.mk
@@ -22,6 +22,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ww8import, \
sal \
test \
unotest \
+ vcl \
sfx \
sw \
utl \
diff --git a/sw/qa/extras/ww8import/data/image-lazy-read.doc b/sw/qa/extras/ww8import/data/image-lazy-read.doc
new file mode 100644
index 000000000000..95017d2ac80e
--- /dev/null
+++ b/sw/qa/extras/ww8import/data/image-lazy-read.doc
Binary files differ
diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx
index 907fe47ebcff..de16cfe253e6 100644
--- a/sw/qa/extras/ww8import/ww8import.cxx
+++ b/sw/qa/extras/ww8import/ww8import.cxx
@@ -116,6 +116,14 @@ DECLARE_WW8IMPORT_TEST( testTdf105570, "tdf105570.doc" )
CPPUNIT_ASSERT_EQUAL( sal_uInt16(0), pTableNd->GetTable().GetRowsToRepeat() );
}
+DECLARE_OOXMLIMPORT_TEST(testImageLazyRead, "image-lazy-read.doc")
+{
+ auto xGraphic = getProperty<uno::Reference<graphic::XGraphic>>(getShape(1), "Graphic");
+ Graphic aGraphic(xGraphic);
+ // This failed, import loaded the graphic, it wasn't lazy-read.
+ CPPUNIT_ASSERT(!aGraphic.isAvailable());
+}
+
DECLARE_WW8IMPORT_TEST(testTdf106799, "tdf106799.doc")
{
sal_Int32 const nCellWidths[3][4] = { { 9530, 0, 0, 0 },{ 2382, 2382, 2382, 2384 },{ 2382, 2382, 2382, 2384 } };
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 023c07ecb9a2..43feef35e5e2 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1572,6 +1572,7 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream)
nGraphicContentSize = nStreamLength;
pGraphicContent.reset(new sal_uInt8[nGraphicContentSize]);
+ rIStream.Seek(nStreamBegin);
rIStream.ReadBytes(pGraphicContent.get(), nStreamLength);
if (!rIStream.GetError())
diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx b/vcl/source/graphic/UnoGraphicProvider.cxx
index 8b9ccb93bf94..7adb183f5aa8 100644
--- a/vcl/source/graphic/UnoGraphicProvider.cxx
+++ b/vcl/source/graphic/UnoGraphicProvider.cxx
@@ -355,9 +355,6 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
}
}
- if (bLazyRead && aFilterData.hasElements())
- bLazyRead = false;
-
SolarMutexGuard g;
if( xIStm.is() )
@@ -396,7 +393,10 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
aExtHeader.mapMode = nExtMapMode;
WmfExternal *pExtHeader = nullptr;
if ( nExtMapMode > 0 )
+ {
pExtHeader = &aExtHeader;
+ bLazyRead = false;
+ }
ErrCode error = ERRCODE_NONE;
if (bLazyRead)