summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-01-01 20:59:56 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-01-01 20:59:56 +0000
commit8332bc39f507b659b07fe01a31164c0805175dd6 (patch)
treecc4afd60732615e677169076159eebfe51645e2e /vcl
parenta3eaeff2db210f3bfe36148a438a3cb593b28c55 (diff)
return earlier, no logic change intended
Change-Id: I39679d1c24ffa6f11c067a8fc3957c6a870f7403
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/impgraph.cxx255
1 files changed, 127 insertions, 128 deletions
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 29775ea8eda7..2d3d85cbc0d3 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1358,166 +1358,165 @@ bool ImpGraphic::ImplExportNative( SvStream& rOStm ) const
SvStream& ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
{
- if( !rIStm.GetError() )
- {
- const sal_uLong nStmPos1 = rIStm.Tell();
- sal_uInt32 nTmp;
+ if (rIStm.GetError())
+ return rIStm;
- if ( !rImpGraphic.mbSwapUnderway )
- rImpGraphic.ImplClear();
+ const sal_uLong nStmPos1 = rIStm.Tell();
+ sal_uInt32 nTmp;
- // read Id
- rIStm.ReadUInt32( nTmp );
+ if ( !rImpGraphic.mbSwapUnderway )
+ rImpGraphic.ImplClear();
- // if there is no more data, avoid further expensive
- // reading which will create VDevs and other stuff, just to
- // read nothing. CAUTION: Eof is only true AFTER reading another
- // byte, a speciality of SvMemoryStream (!)
- if(!rIStm.GetError() && !rIStm.IsEof())
- {
- if( NATIVE_FORMAT_50 == nTmp )
- {
- Graphic aGraphic;
- GfxLink aLink;
+ // read Id
+ rIStm.ReadUInt32( nTmp );
- // read compat info
- std::unique_ptr<VersionCompat> pCompat(new VersionCompat( rIStm, StreamMode::READ ));
- pCompat.reset(); // destructor writes stuff into the header
+ // if there is no more data, avoid further expensive
+ // reading which will create VDevs and other stuff, just to
+ // read nothing. CAUTION: Eof is only true AFTER reading another
+ // byte, a speciality of SvMemoryStream (!)
+ if (rIStm.GetError() || rIStm.IsEof())
+ return rIStm;
- ReadGfxLink( rIStm, aLink );
+ if (NATIVE_FORMAT_50 == nTmp)
+ {
+ Graphic aGraphic;
+ GfxLink aLink;
- // set dummy link to avoid creation of additional link after filtering;
- // we set a default link to avoid unnecessary swapping of native data
- aGraphic.SetLink( GfxLink() );
+ // read compat info
+ std::unique_ptr<VersionCompat> pCompat(new VersionCompat( rIStm, StreamMode::READ ));
+ pCompat.reset(); // destructor writes stuff into the header
- if( !rIStm.GetError() && aLink.LoadNative( aGraphic ) )
- {
- // set link only, if no other link was set
- const bool bSetLink = ( !rImpGraphic.mpGfxLink );
+ ReadGfxLink( rIStm, aLink );
- // assign graphic
- rImpGraphic = *aGraphic.ImplGetImpGraphic();
+ // set dummy link to avoid creation of additional link after filtering;
+ // we set a default link to avoid unnecessary swapping of native data
+ aGraphic.SetLink( GfxLink() );
- if( aLink.IsPrefMapModeValid() )
- rImpGraphic.ImplSetPrefMapMode( aLink.GetPrefMapMode() );
+ if( !rIStm.GetError() && aLink.LoadNative( aGraphic ) )
+ {
+ // set link only, if no other link was set
+ const bool bSetLink = ( !rImpGraphic.mpGfxLink );
- if( aLink.IsPrefSizeValid() )
- rImpGraphic.ImplSetPrefSize( aLink.GetPrefSize() );
+ // assign graphic
+ rImpGraphic = *aGraphic.ImplGetImpGraphic();
- if( bSetLink )
- rImpGraphic.ImplSetLink( aLink );
- }
- else
- {
- rIStm.Seek( nStmPos1 );
- rIStm.SetError( ERRCODE_IO_WRONGFORMAT );
- }
- }
- else
- {
- BitmapEx aBmpEx;
- const SvStreamEndian nOldFormat = rIStm.GetEndian();
+ if( aLink.IsPrefMapModeValid() )
+ rImpGraphic.ImplSetPrefMapMode( aLink.GetPrefMapMode() );
- rIStm.SeekRel( -4 );
- rIStm.SetEndian( SvStreamEndian::LITTLE );
- ReadDIBBitmapEx(aBmpEx, rIStm);
+ if( aLink.IsPrefSizeValid() )
+ rImpGraphic.ImplSetPrefSize( aLink.GetPrefSize() );
- if( !rIStm.GetError() )
- {
- sal_uInt32 nMagic1(0), nMagic2(0);
- sal_uLong nActPos = rIStm.Tell();
+ if( bSetLink )
+ rImpGraphic.ImplSetLink( aLink );
+ }
+ else
+ {
+ rIStm.Seek( nStmPos1 );
+ rIStm.SetError( ERRCODE_IO_WRONGFORMAT );
+ }
+ return rIStm;
+ }
- rIStm.ReadUInt32( nMagic1 ).ReadUInt32( nMagic2 );
- rIStm.Seek( nActPos );
+ BitmapEx aBmpEx;
+ const SvStreamEndian nOldFormat = rIStm.GetEndian();
- rImpGraphic = ImpGraphic( aBmpEx );
+ rIStm.SeekRel( -4 );
+ rIStm.SetEndian( SvStreamEndian::LITTLE );
+ ReadDIBBitmapEx(aBmpEx, rIStm);
- if( !rIStm.GetError() && ( 0x5344414e == nMagic1 ) && ( 0x494d4931 == nMagic2 ) )
- {
- rImpGraphic.mpAnimation = o3tl::make_unique<Animation>();
- ReadAnimation( rIStm, *rImpGraphic.mpAnimation );
+ if( !rIStm.GetError() )
+ {
+ sal_uInt32 nMagic1(0), nMagic2(0);
+ sal_uLong nActPos = rIStm.Tell();
- // #108077# manually set loaded BmpEx to Animation
- // (which skips loading its BmpEx if already done)
- rImpGraphic.mpAnimation->SetBitmapEx(aBmpEx);
- }
- else
- rIStm.ResetError();
- }
- else
- {
- GDIMetaFile aMtf;
+ rIStm.ReadUInt32( nMagic1 ).ReadUInt32( nMagic2 );
+ rIStm.Seek( nActPos );
- rIStm.Seek( nStmPos1 );
- rIStm.ResetError();
- ReadGDIMetaFile( rIStm, aMtf );
+ rImpGraphic = ImpGraphic( aBmpEx );
- if( !rIStm.GetError() )
- {
- rImpGraphic = aMtf;
- }
- else
- {
- sal_uInt32 nOrigError = rIStm.GetErrorCode();
- // try to stream in Svg defining data (length, byte array and evtl. path)
- // See below (operator<<) for more information
- const sal_uInt32 nSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0'));
- sal_uInt32 nMagic;
- rIStm.Seek(nStmPos1);
- rIStm.ResetError();
- rIStm.ReadUInt32( nMagic );
-
- if (nSvgMagic == nMagic)
- {
- sal_uInt32 nSvgDataArrayLength(0);
- rIStm.ReadUInt32(nSvgDataArrayLength);
+ if( !rIStm.GetError() && ( 0x5344414e == nMagic1 ) && ( 0x494d4931 == nMagic2 ) )
+ {
+ rImpGraphic.mpAnimation = o3tl::make_unique<Animation>();
+ ReadAnimation( rIStm, *rImpGraphic.mpAnimation );
- if (nSvgDataArrayLength)
- {
- SvgDataArray aNewData(nSvgDataArrayLength);
+ // #108077# manually set loaded BmpEx to Animation
+ // (which skips loading its BmpEx if already done)
+ rImpGraphic.mpAnimation->SetBitmapEx(aBmpEx);
+ }
+ else
+ rIStm.ResetError();
+ }
+ else
+ {
+ GDIMetaFile aMtf;
- rIStm.ReadBytes(aNewData.getArray(), nSvgDataArrayLength);
- OUString aPath = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet());
+ rIStm.Seek( nStmPos1 );
+ rIStm.ResetError();
+ ReadGDIMetaFile( rIStm, aMtf );
- if (!rIStm.GetError())
- {
- SvgDataPtr aSvgDataPtr(
- new SvgData(
- aNewData,
- OUString(aPath)));
+ if( !rIStm.GetError() )
+ {
+ rImpGraphic = aMtf;
+ }
+ else
+ {
+ sal_uInt32 nOrigError = rIStm.GetErrorCode();
+ // try to stream in Svg defining data (length, byte array and evtl. path)
+ // See below (operator<<) for more information
+ const sal_uInt32 nSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0'));
+ sal_uInt32 nMagic;
+ rIStm.Seek(nStmPos1);
+ rIStm.ResetError();
+ rIStm.ReadUInt32( nMagic );
+
+ if (nSvgMagic == nMagic)
+ {
+ sal_uInt32 nSvgDataArrayLength(0);
+ rIStm.ReadUInt32(nSvgDataArrayLength);
- rImpGraphic = aSvgDataPtr;
- }
- }
- }
- else if (nMagic == nPdfMagic)
- {
- // Stream in PDF data.
- sal_uInt32 nPdfDataLength = 0;
- rIStm.ReadUInt32(nPdfDataLength);
+ if (nSvgDataArrayLength)
+ {
+ SvgDataArray aNewData(nSvgDataArrayLength);
- if (nPdfDataLength)
- {
- uno::Sequence<sal_Int8> aPdfData(nPdfDataLength);
- rIStm.ReadBytes(aPdfData.getArray(), nPdfDataLength);
- if (!rIStm.GetError())
- rImpGraphic.maPdfData = aPdfData;
- }
- }
- else
- {
- rIStm.SetError(nOrigError);
- }
+ rIStm.ReadBytes(aNewData.getArray(), nSvgDataArrayLength);
+ OUString aPath = rIStm.ReadUniOrByteString(rIStm.GetStreamCharSet());
- rIStm.Seek(nStmPos1);
+ if (!rIStm.GetError())
+ {
+ SvgDataPtr aSvgDataPtr(
+ new SvgData(
+ aNewData,
+ OUString(aPath)));
+
+ rImpGraphic = aSvgDataPtr;
}
}
+ }
+ else if (nMagic == nPdfMagic)
+ {
+ // Stream in PDF data.
+ sal_uInt32 nPdfDataLength = 0;
+ rIStm.ReadUInt32(nPdfDataLength);
- rIStm.SetEndian( nOldFormat );
+ if (nPdfDataLength)
+ {
+ uno::Sequence<sal_Int8> aPdfData(nPdfDataLength);
+ rIStm.ReadBytes(aPdfData.getArray(), nPdfDataLength);
+ if (!rIStm.GetError())
+ rImpGraphic.maPdfData = aPdfData;
+ }
+ }
+ else
+ {
+ rIStm.SetError(nOrigError);
}
+
+ rIStm.Seek(nStmPos1);
}
}
+ rIStm.SetEndian( nOldFormat );
+
return rIStm;
}