From f0edf93fce53a726fec5167139513bc8420728e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Fri, 19 Oct 2018 14:31:59 +0100 Subject: [PATCH] ImpDetectPCX 2nd arg always overwritten MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0ec1e71d40c34f021003330c4dd0a8d5ee2b6ce2 Reviewed-on: https://gerrit.libreoffice.org/62018 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/vcl/graphicfilter.hxx | 2 +- vcl/source/filter/graphicfilter2.cxx | 96 +++++++++++++--------------- 2 files changed, 47 insertions(+), 51 deletions(-) diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx index d14ee7754699..fe084136ce5a 100644 --- a/include/vcl/graphicfilter.hxx +++ b/include/vcl/graphicfilter.hxx @@ -152,7 +152,7 @@ class VCL_DLLPUBLIC GraphicDescriptor final bool ImpDetectGIF( SvStream& rStm, bool bExtendedInfo ); bool ImpDetectJPG( SvStream& rStm, bool bExtendedInfo ); bool ImpDetectPCD( SvStream& rStm, bool bExtendedInfo ); - bool ImpDetectPCX( SvStream& rStm, bool bExtendedInfo ); + bool ImpDetectPCX( SvStream& rStm ); bool ImpDetectPNG( SvStream& rStm, bool bExtendedInfo ); bool ImpDetectTIF( SvStream& rStm, bool bExtendedInfo ); bool ImpDetectXBM( SvStream& rStm, bool bExtendedInfo ); diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 32ad4b51947a..17b16f69abcb 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -67,7 +67,7 @@ bool GraphicDescriptor::Detect( bool bExtendedInfo ) else if ( ImpDetectBMP( rStm, bExtendedInfo ) ) bRet = true; else if ( ImpDetectPNG( rStm, bExtendedInfo ) ) bRet = true; else if ( ImpDetectTIF( rStm, bExtendedInfo ) ) bRet = true; - else if ( ImpDetectPCX( rStm, bExtendedInfo ) ) bRet = true; + else if ( ImpDetectPCX( rStm ) ) bRet = true; else if ( ImpDetectDXF( rStm, bExtendedInfo ) ) bRet = true; else if ( ImpDetectMET( rStm, bExtendedInfo ) ) bRet = true; else if ( ImpDetectSVM( rStm, bExtendedInfo ) ) bRet = true; @@ -433,13 +433,12 @@ bool GraphicDescriptor::ImpDetectPCD( SvStream& rStm, bool ) return bRet; } -bool GraphicDescriptor::ImpDetectPCX( SvStream& rStm, bool bExtendedInfo ) +bool GraphicDescriptor::ImpDetectPCX( SvStream& rStm ) { // ! Because 0x0a can be interpreted as LF too ... // we can't be sure that this special sign represent a PCX file only. // Every Ascii file is possible here :-( // We must detect the whole header. - bExtendedInfo = true; bool bRet = false; sal_uInt8 cByte = 0; @@ -453,61 +452,58 @@ bool GraphicDescriptor::ImpDetectPCX( SvStream& rStm, bool bExtendedInfo ) nFormat = GraphicFileFormat::PCX; bRet = true; - if ( bExtendedInfo ) + sal_uInt16 nTemp16; + sal_uInt16 nXmin; + sal_uInt16 nXmax; + sal_uInt16 nYmin; + sal_uInt16 nYmax; + sal_uInt16 nDPIx; + sal_uInt16 nDPIy; + + rStm.SeekRel( 1 ); + + // compression + rStm.ReadUChar( cByte ); + + bRet = (cByte==0 || cByte ==1); + if (bRet) { - sal_uInt16 nTemp16; - sal_uInt16 nXmin; - sal_uInt16 nXmax; - sal_uInt16 nYmin; - sal_uInt16 nYmax; - sal_uInt16 nDPIx; - sal_uInt16 nDPIy; - - rStm.SeekRel( 1 ); - - // compression + // Bits/Pixel rStm.ReadUChar( cByte ); + nBitsPerPixel = cByte; - bRet = (cByte==0 || cByte ==1); - if (bRet) - { - // Bits/Pixel - rStm.ReadUChar( cByte ); - nBitsPerPixel = cByte; + // image dimensions + rStm.ReadUInt16( nTemp16 ); + nXmin = nTemp16; + rStm.ReadUInt16( nTemp16 ); + nYmin = nTemp16; + rStm.ReadUInt16( nTemp16 ); + nXmax = nTemp16; + rStm.ReadUInt16( nTemp16 ); + nYmax = nTemp16; - // image dimensions - rStm.ReadUInt16( nTemp16 ); - nXmin = nTemp16; - rStm.ReadUInt16( nTemp16 ); - nYmin = nTemp16; - rStm.ReadUInt16( nTemp16 ); - nXmax = nTemp16; - rStm.ReadUInt16( nTemp16 ); - nYmax = nTemp16; + aPixSize.setWidth( nXmax - nXmin + 1 ); + aPixSize.setHeight( nYmax - nYmin + 1 ); - aPixSize.setWidth( nXmax - nXmin + 1 ); - aPixSize.setHeight( nYmax - nYmin + 1 ); + // resolution + rStm.ReadUInt16( nTemp16 ); + nDPIx = nTemp16; + rStm.ReadUInt16( nTemp16 ); + nDPIy = nTemp16; - // resolution - rStm.ReadUInt16( nTemp16 ); - nDPIx = nTemp16; - rStm.ReadUInt16( nTemp16 ); - nDPIy = nTemp16; + // set logical size + MapMode aMap( MapUnit::MapInch, Point(), + Fraction( 1, nDPIx ), Fraction( 1, nDPIy ) ); + aLogSize = OutputDevice::LogicToLogic( aPixSize, aMap, + MapMode( MapUnit::Map100thMM ) ); - // set logical size - MapMode aMap( MapUnit::MapInch, Point(), - Fraction( 1, nDPIx ), Fraction( 1, nDPIy ) ); - aLogSize = OutputDevice::LogicToLogic( aPixSize, aMap, - MapMode( MapUnit::Map100thMM ) ); + // number of color planes + cByte = 5; // Illegal value in case of EOF. + rStm.SeekRel( 49 ); + rStm.ReadUChar( cByte ); + nPlanes = cByte; - // number of color planes - cByte = 5; // Illegal value in case of EOF. - rStm.SeekRel( 49 ); - rStm.ReadUChar( cByte ); - nPlanes = cByte; - - bRet = (nPlanes<=4); - } + bRet = (nPlanes<=4); } }