DOC import: lazy-read images
At least JPEG files are now only loaded when the user scrolls to the relevant page. Also fix the root cause of the EMF lazy-read problem and remove the previous workarounds. Change-Id: I9699927282b99bcb71a0d271a20bbfd56a361ee8 Reviewed-on: https://gerrit.libreoffice.org/53219 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
parent
40edbce398
commit
b11188835d
@ -6545,7 +6545,14 @@ bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData, tool
|
|||||||
else
|
else
|
||||||
{ // and unleash our filter
|
{ // and unleash our filter
|
||||||
GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
|
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,
|
// 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
|
// then it is better to use the prefsize that is stored within the metafile. Bug #72846# for what the
|
||||||
|
@ -244,7 +244,7 @@ Reference< XGraphic > GraphicHelper::importGraphic( const Reference< XInputStrea
|
|||||||
aArgs[ 1 ].Name = "LazyRead";
|
aArgs[ 1 ].Name = "LazyRead";
|
||||||
aArgs[ 1 ].Value <<= true;
|
aArgs[ 1 ].Value <<= true;
|
||||||
|
|
||||||
if ( pExtHeader )
|
if ( pExtHeader && pExtHeader->mapMode > 0 )
|
||||||
{
|
{
|
||||||
aArgs.realloc( aArgs.getLength() + 1 );
|
aArgs.realloc( aArgs.getLength() + 1 );
|
||||||
Sequence< PropertyValue > aFilterData( 3 );
|
Sequence< PropertyValue > aFilterData( 3 );
|
||||||
@ -341,11 +341,6 @@ Reference< XGraphic > GraphicHelper::importEmbeddedGraphic( const OUString& rStr
|
|||||||
EmbeddedGraphicMap::const_iterator aIt = maEmbeddedGraphics.find( rStreamName );
|
EmbeddedGraphicMap::const_iterator aIt = maEmbeddedGraphics.find( rStreamName );
|
||||||
if( aIt == maEmbeddedGraphics.end() )
|
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);
|
xGraphic = importGraphic(mxStorage->openInputStream(rStreamName), pExtHeader);
|
||||||
if( xGraphic.is() )
|
if( xGraphic.is() )
|
||||||
maEmbeddedGraphics[ rStreamName ] = xGraphic;
|
maEmbeddedGraphics[ rStreamName ] = xGraphic;
|
||||||
|
@ -22,6 +22,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ww8import, \
|
|||||||
sal \
|
sal \
|
||||||
test \
|
test \
|
||||||
unotest \
|
unotest \
|
||||||
|
vcl \
|
||||||
sfx \
|
sfx \
|
||||||
sw \
|
sw \
|
||||||
utl \
|
utl \
|
||||||
|
BIN
sw/qa/extras/ww8import/data/image-lazy-read.doc
Normal file
BIN
sw/qa/extras/ww8import/data/image-lazy-read.doc
Normal file
Binary file not shown.
@ -116,6 +116,14 @@ DECLARE_WW8IMPORT_TEST( testTdf105570, "tdf105570.doc" )
|
|||||||
CPPUNIT_ASSERT_EQUAL( sal_uInt16(0), pTableNd->GetTable().GetRowsToRepeat() );
|
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")
|
DECLARE_WW8IMPORT_TEST(testTdf106799, "tdf106799.doc")
|
||||||
{
|
{
|
||||||
sal_Int32 const nCellWidths[3][4] = { { 9530, 0, 0, 0 },{ 2382, 2382, 2382, 2384 },{ 2382, 2382, 2382, 2384 } };
|
sal_Int32 const nCellWidths[3][4] = { { 9530, 0, 0, 0 },{ 2382, 2382, 2382, 2384 },{ 2382, 2382, 2382, 2384 } };
|
||||||
|
@ -1572,6 +1572,7 @@ Graphic GraphicFilter::ImportUnloadedGraphic(SvStream& rIStream)
|
|||||||
nGraphicContentSize = nStreamLength;
|
nGraphicContentSize = nStreamLength;
|
||||||
pGraphicContent.reset(new sal_uInt8[nGraphicContentSize]);
|
pGraphicContent.reset(new sal_uInt8[nGraphicContentSize]);
|
||||||
|
|
||||||
|
rIStream.Seek(nStreamBegin);
|
||||||
rIStream.ReadBytes(pGraphicContent.get(), nStreamLength);
|
rIStream.ReadBytes(pGraphicContent.get(), nStreamLength);
|
||||||
|
|
||||||
if (!rIStream.GetError())
|
if (!rIStream.GetError())
|
||||||
|
@ -355,9 +355,6 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bLazyRead && aFilterData.hasElements())
|
|
||||||
bLazyRead = false;
|
|
||||||
|
|
||||||
SolarMutexGuard g;
|
SolarMutexGuard g;
|
||||||
|
|
||||||
if( xIStm.is() )
|
if( xIStm.is() )
|
||||||
@ -396,7 +393,10 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co
|
|||||||
aExtHeader.mapMode = nExtMapMode;
|
aExtHeader.mapMode = nExtMapMode;
|
||||||
WmfExternal *pExtHeader = nullptr;
|
WmfExternal *pExtHeader = nullptr;
|
||||||
if ( nExtMapMode > 0 )
|
if ( nExtMapMode > 0 )
|
||||||
|
{
|
||||||
pExtHeader = &aExtHeader;
|
pExtHeader = &aExtHeader;
|
||||||
|
bLazyRead = false;
|
||||||
|
}
|
||||||
|
|
||||||
ErrCode error = ERRCODE_NONE;
|
ErrCode error = ERRCODE_NONE;
|
||||||
if (bLazyRead)
|
if (bLazyRead)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user