vcl/source/filter/graphicfilter2.cxx | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)
New commits: commit 416168c01097563fc1773b9f1986dee7e43e5d9c Author: offtkp <[email protected]> AuthorDate: Fri Aug 12 18:48:45 2022 +0300 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Fri Aug 19 10:26:04 2022 +0200 Remove code duplication in GraphicDescriptor for PCD GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for PCD files Change-Id: Ic49f9b7ebfbe4e756d7c4f1067958bd7a2ac0154 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138207 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 3ffe27991dd9..1d08776f0b83 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -417,27 +417,12 @@ bool GraphicDescriptor::ImpDetectJPG( SvStream& rStm, bool bExtendedInfo ) bool GraphicDescriptor::ImpDetectPCD( SvStream& rStm, bool ) { - bool bRet = false; - sal_Int32 nStmPos = rStm.Tell(); - rStm.SetEndian( SvStreamEndian::LITTLE ); - - sal_uInt32 nTemp32 = 0; - sal_uInt16 nTemp16 = 0; - sal_uInt8 cByte = 0; - - rStm.SeekRel( 2048 ); - rStm.ReadUInt32( nTemp32 ); - rStm.ReadUInt16( nTemp16 ); - rStm.ReadUChar( cByte ); - - if ( ( nTemp32 == 0x5f444350 ) && - ( nTemp16 == 0x5049 ) && - ( cByte == 0x49 ) ) - { - aMetadata.mnFormat = GraphicFileFormat::PCD; - bRet = true; - } + vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /*bExtendedInfo*/ ); + bool bRet = aDetector.detect(); + bRet &= aDetector.checkPCD(); + if ( bRet ) + aMetadata = aDetector.getMetadata(); rStm.Seek( nStmPos ); return bRet; }
