graphicfilter: store the funky animated GIF in a PNG as a GIF
MS had a really bad idea to store an animated GIF inside a PNG for some reason. This situation was handled correctly in LO but we still pretended that this was a PNG file, which was causing confusion for some users that wanted to extract the image from the document. With this change we extract the animated GIF from the PNG and store just the GIF in the document. Change-Id: I4c70d118e8decd7aa1b108b6b1d725301904a35b
This commit is contained in:
parent
f5e68baec6
commit
5ae10ae4df
@ -1458,18 +1458,25 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPat
|
||||
const std::vector<vcl::PNGReader::ChunkData>& rChunkData = aPNGReader.GetChunks();
|
||||
std::vector<vcl::PNGReader::ChunkData>::const_iterator aIter(rChunkData.begin());
|
||||
std::vector<vcl::PNGReader::ChunkData>::const_iterator aEnd(rChunkData.end());
|
||||
|
||||
while (aIter != aEnd)
|
||||
{
|
||||
// Microsoft Office is storing Animated GIFs in following chunk
|
||||
if (aIter->nType == PMGCHUNG_msOG)
|
||||
{
|
||||
sal_uInt32 nChunkSize = aIter->aData.size();
|
||||
|
||||
if (nChunkSize > 11)
|
||||
{
|
||||
const std::vector<sal_uInt8>& rData = aIter->aData;
|
||||
SvMemoryStream aIStrm( (void*)&rData[ 11 ], nChunkSize - 11, StreamMode::READ );
|
||||
nGraphicContentSize = nChunkSize - 11;
|
||||
SvMemoryStream aIStrm(const_cast<sal_uInt8*>(&rData[11]), nGraphicContentSize, StreamMode::READ);
|
||||
pGraphicContent = new sal_uInt8[nGraphicContentSize];
|
||||
sal_uInt64 aCurrentPosition = aIStrm.Tell();
|
||||
aIStrm.Read(pGraphicContent, nGraphicContentSize);
|
||||
aIStrm.Seek(aCurrentPosition);
|
||||
ImportGIF(aIStrm, rGraphic);
|
||||
eLinkType = GFX_LINK_TYPE_NATIVE_PNG;
|
||||
eLinkType = GFX_LINK_TYPE_NATIVE_GIF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1520,6 +1527,7 @@ sal_uInt16 GraphicFilter::ImportGraphic( Graphic& rGraphic, const OUString& rPat
|
||||
rIStream.Seek(nStreamPosition);
|
||||
rIStream.Read(&aTwoBytes[0], 2);
|
||||
rIStream.Seek(nStreamPosition);
|
||||
|
||||
if(aTwoBytes[0] == 0x1F && aTwoBytes[1] == 0x8B)
|
||||
{
|
||||
SvMemoryStream aMemStream;
|
||||
|
Loading…
x
Reference in New Issue
Block a user