diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2021-06-06 21:32:47 +0200 |
---|---|---|
committer | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2021-06-07 13:36:57 +0200 |
commit | 6bebaddb39849422dffa16316c543fc69305f31a (patch) | |
tree | f93360541b70127aae8268d74464276a73b97ac7 /emfio/source | |
parent | 3ffc5df4e17068319bd6ed0c854d92a702ef326a (diff) |
WMF tdf#142625 Continue read records if unimlemented features found
Most of DIB records (DIBCREATEPATTERNBRUSH, STRETCHDIB)
are implemented partially. If the unimplemted feature are inside
WMF, then the whole reading steam is interrupted and nothing
is displayed.
With this commit if DIB record used missing feature,
then the warning is displayed, and the displaying continue.
The fix allows for displaying WMF image from tdf#55058
Change-Id: I6cc88d41486c52a2b1a6ec0b89166460a78ce7d1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116763
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'emfio/source')
-rw-r--r-- | emfio/source/reader/wmfreader.cxx | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 7cd98315adef..73d059aa5df3 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -825,7 +825,7 @@ namespace emfio SAL_WARN("emfio", "\t\t Raster operation: 0x" << std::hex << nRasterOperation << std::dec); if ( nRecordSize == ( ( static_cast< sal_uInt32 >( nFunc ) >> 8 ) + 3 ) ) { - SAL_WARN("emfio", "\t\t TODO The Bitmap record detected without Bitmap. This case in not supported. Please fill a bug."); + SAL_WARN("emfio", "\t\t TODO The unsupported Bitmap record (without embedded source Bitmap). Please fill a bug."); break; } mpInputStream->ReadUInt16( nYSrc ).ReadUInt16( nXSrc ).ReadUInt16( nSye ).ReadUInt16( nSxe ); @@ -893,7 +893,7 @@ namespace emfio if ( nRecordSize == ( ( static_cast< sal_uInt32 >( nFunc ) >> 8 ) + 3 ) ) { - SAL_WARN("emfio", "\t\t TODO The Bitmap record detected without Bitmap. This case in not supported. Please fill a bug."); + SAL_WARN("emfio", "\t\t TODO The unsupported Bitmap record (without embedded source Bitmap). Please fill a bug."); break; } if( nFunc == W_META_STRETCHDIB ) @@ -922,8 +922,25 @@ namespace emfio { tools::Rectangle aDestRect( ReadYX(), aDestSize ); if ( nRasterOperation != PATCOPY ) - ReadDIB(aBmp, *mpInputStream, false); - + { + // tdf#142625 Read the DIBHeader and check if bitmap is supported + // If bitmap is not supported don't run ReadDIB, as it will interrupt image processing + const auto nOldPos(mpInputStream->Tell()); + sal_uInt32 nHeaderSize; + sal_uInt16 nBitCount; + mpInputStream->ReadUInt32( nHeaderSize ); + if ( nHeaderSize == 0xC ) // BitmapCoreHeader + mpInputStream->SeekRel( 6 ); // skip Width (16), Height (16), Planes (16) + else + mpInputStream->SeekRel( 10 ); // skip Width (32), Height (32), Planes (16) + mpInputStream->ReadUInt16( nBitCount ); + if ( nBitCount == 0 ) // TODO Undefined BitCount (JPEG/PNG), which are not supported + break; + mpInputStream->Seek(nOldPos); + + if ( !ReadDIB( aBmp, *mpInputStream, false ) ) + SAL_WARN( "emfio", "\tTODO Read DIB failed. Interrupting processing whole image. Please report bug report." ); + } // test if it is sensible to crop if ( nSrcHeight && nSrcWidth && ( nXSrc + nSrcWidth <= aBmp.GetSizePixel().Width() ) && @@ -932,6 +949,7 @@ namespace emfio tools::Rectangle aCropRect( Point( nXSrc, nYSrc ), Size( nSrcWidth, nSrcHeight ) ); aBmp.Crop( aCropRect ); } + maBmpSaveList.emplace_back(new BSaveStruct(aBmp, aDestRect, nRasterOperation)); } } @@ -942,11 +960,18 @@ namespace emfio { Bitmap aBmp; sal_uInt32 nRed = 0, nGreen = 0, nBlue = 0, nCount = 1; - sal_uInt16 nFunction = 0; + sal_uInt16 nStyle, nColorUsage; - mpInputStream->ReadUInt16( nFunction ).ReadUInt16( nFunction ); - - ReadDIB(aBmp, *mpInputStream, false); + mpInputStream->ReadUInt16( nStyle ).ReadUInt16( nColorUsage ); + SAL_INFO( "emfio", "\t\t Style:" << nStyle << ", ColorUsage: " << nColorUsage ); + if ( nStyle == BS_PATTERN ) // TODO tdf#142625 Add support for pattern + { + SAL_WARN( "emfio", "\tTODO: Pattern brush style is not supported." ); + CreateObject(); + break; + } + if ( !ReadDIB( aBmp, *mpInputStream, false ) ) + SAL_WARN( "emfio", "\tTODO Read DIB failed. Interrupting processing whole image. Please report bug report." ); if ( !aBmp.IsEmpty() ) { Bitmap::ScopedReadAccess pBmp(aBmp); |