Kaydet (Commit) a2aceeb0 authored tarafından Caolán McNamara's avatar Caolán McNamara

return earlier, no logic change intended

Change-Id: Icd75c46eb57c059fb60fd9701e6bb1fb651d8f3f
üst b560dc89
...@@ -1520,86 +1520,87 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic ) ...@@ -1520,86 +1520,87 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic) void WriteImpGraphic(SvStream& rOStm, const ImpGraphic& rImpGraphic)
{ {
if( !rOStm.GetError() ) if (rOStm.GetError())
return;
if (rImpGraphic.ImplIsSwapOut())
{ {
if( !rImpGraphic.ImplIsSwapOut() ) rOStm.SetError( SVSTREAM_GENERALERROR );
{ return;
if( ( rOStm.GetVersion() >= SOFFICE_FILEFORMAT_50 ) && }
( rOStm.GetCompressMode() & SvStreamCompressFlags::NATIVE ) &&
rImpGraphic.mpGfxLink && rImpGraphic.mpGfxLink->IsNative() &&
!rImpGraphic.maPdfData.hasElements())
{
// native format
rOStm.WriteUInt32( NATIVE_FORMAT_50 );
// write compat info if( ( rOStm.GetVersion() >= SOFFICE_FILEFORMAT_50 ) &&
std::unique_ptr<VersionCompat> pCompat(new VersionCompat( rOStm, StreamMode::WRITE, 1 )); ( rOStm.GetCompressMode() & SvStreamCompressFlags::NATIVE ) &&
pCompat.reset(); // destructor writes stuff into the header rImpGraphic.mpGfxLink && rImpGraphic.mpGfxLink->IsNative() &&
!rImpGraphic.maPdfData.hasElements())
{
// native format
rOStm.WriteUInt32( NATIVE_FORMAT_50 );
rImpGraphic.mpGfxLink->SetPrefMapMode( rImpGraphic.ImplGetPrefMapMode() ); // write compat info
rImpGraphic.mpGfxLink->SetPrefSize( rImpGraphic.ImplGetPrefSize() ); std::unique_ptr<VersionCompat> pCompat(new VersionCompat( rOStm, StreamMode::WRITE, 1 ));
WriteGfxLink( rOStm, *rImpGraphic.mpGfxLink ); pCompat.reset(); // destructor writes stuff into the header
}
else
{
// own format
const SvStreamEndian nOldFormat = rOStm.GetEndian();
rOStm.SetEndian( SvStreamEndian::LITTLE );
switch( rImpGraphic.ImplGetType() ) rImpGraphic.mpGfxLink->SetPrefMapMode( rImpGraphic.ImplGetPrefMapMode() );
{ rImpGraphic.mpGfxLink->SetPrefSize( rImpGraphic.ImplGetPrefSize() );
case GraphicType::NONE: WriteGfxLink( rOStm, *rImpGraphic.mpGfxLink );
case GraphicType::Default: }
break; else
{
// own format
const SvStreamEndian nOldFormat = rOStm.GetEndian();
rOStm.SetEndian( SvStreamEndian::LITTLE );
case GraphicType::Bitmap: switch( rImpGraphic.ImplGetType() )
{ {
if(rImpGraphic.getSvgData().get()) case GraphicType::NONE:
{ case GraphicType::Default:
// stream out Svg defining data (length, byte array and evtl. path) break;
// this is used e.g. in swapping out graphic data and in transporting it over UNO API
// as sequence of bytes, but AFAIK not written anywhere to any kind of file, so it should be
// no problem to extend it; only used at runtime
const sal_uInt32 nSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0'));
rOStm.WriteUInt32( nSvgMagic );
rOStm.WriteUInt32( rImpGraphic.getSvgData()->getSvgDataArrayLength() );
rOStm.WriteBytes(rImpGraphic.getSvgData()->getSvgDataArray().getConstArray(),
rImpGraphic.getSvgData()->getSvgDataArrayLength());
rOStm.WriteUniOrByteString(rImpGraphic.getSvgData()->getPath(),
rOStm.GetStreamCharSet());
}
else if( rImpGraphic.ImplIsAnimated())
{
WriteAnimation( rOStm, *rImpGraphic.mpAnimation );
}
else
{
WriteDIBBitmapEx(rImpGraphic.maEx, rOStm);
}
}
break;
default: case GraphicType::Bitmap:
{ {
if (rImpGraphic.maPdfData.hasElements()) if(rImpGraphic.getSvgData().get())
{ {
// Stream out PDF data. // stream out Svg defining data (length, byte array and evtl. path)
rOStm.WriteUInt32(nPdfMagic); // this is used e.g. in swapping out graphic data and in transporting it over UNO API
rOStm.WriteUInt32(rImpGraphic.maPdfData.getLength()); // as sequence of bytes, but AFAIK not written anywhere to any kind of file, so it should be
rOStm.WriteBytes(rImpGraphic.maPdfData.getConstArray(), rImpGraphic.maPdfData.getLength()); // no problem to extend it; only used at runtime
} const sal_uInt32 nSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') << 16) | (sal_uInt32('g') << 8) | sal_uInt32('0'));
if( rImpGraphic.ImplIsSupportedGraphic() )
WriteGDIMetaFile( rOStm, rImpGraphic.maMetaFile ); rOStm.WriteUInt32( nSvgMagic );
} rOStm.WriteUInt32( rImpGraphic.getSvgData()->getSvgDataArrayLength() );
break; rOStm.WriteBytes(rImpGraphic.getSvgData()->getSvgDataArray().getConstArray(),
rImpGraphic.getSvgData()->getSvgDataArrayLength());
rOStm.WriteUniOrByteString(rImpGraphic.getSvgData()->getPath(),
rOStm.GetStreamCharSet());
}
else if( rImpGraphic.ImplIsAnimated())
{
WriteAnimation( rOStm, *rImpGraphic.mpAnimation );
}
else
{
WriteDIBBitmapEx(rImpGraphic.maEx, rOStm);
} }
}
break;
rOStm.SetEndian( nOldFormat ); default:
{
if (rImpGraphic.maPdfData.hasElements())
{
// Stream out PDF data.
rOStm.WriteUInt32(nPdfMagic);
rOStm.WriteUInt32(rImpGraphic.maPdfData.getLength());
rOStm.WriteBytes(rImpGraphic.maPdfData.getConstArray(), rImpGraphic.maPdfData.getLength());
}
if( rImpGraphic.ImplIsSupportedGraphic() )
WriteGDIMetaFile( rOStm, rImpGraphic.maMetaFile );
} }
break;
} }
else
rOStm.SetError( SVSTREAM_GENERALERROR ); rOStm.SetEndian( nOldFormat );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment