vcl/source/filter/graphicfilter2.cxx | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-)
New commits: commit e956091ad8ebfa77294e130bf2b5cf0200578fdb Author: offtkp <parisop...@gmail.com> AuthorDate: Fri Aug 12 21:27:16 2022 +0300 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Aug 19 10:26:33 2022 +0200 Remove code duplication in GraphicDescriptor for EPS GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for EPS files Change-Id: I108aefc56a0e9215eaeef3ae2a7b4d884f0a5373 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138208 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/vcl/source/filter/graphicfilter2.cxx b/vcl/source/filter/graphicfilter2.cxx index 1d08776f0b83..01741afa7ec2 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -918,24 +918,12 @@ bool GraphicDescriptor::ImpDetectPSD( SvStream& rStm, bool bExtendedInfo ) bool GraphicDescriptor::ImpDetectEPS( SvStream& rStm, bool ) { - // check the EPS preview and the file extension - sal_uInt32 nFirstLong = 0; - sal_uInt8 nFirstBytes[20] = {}; - bool bRet = false; - sal_Int32 nStmPos = rStm.Tell(); - rStm.SetEndian( SvStreamEndian::BIG ); - rStm.ReadUInt32( nFirstLong ); - rStm.SeekRel( -4 ); - rStm.ReadBytes( &nFirstBytes, 20 ); - - if ( ( nFirstLong == 0xC5D0D3C6 ) || aPathExt.startsWith( "eps" ) || - ( ImplSearchEntry( nFirstBytes, reinterpret_cast<sal_uInt8 const *>("%!PS-Adobe"), 10, 10 ) - && ImplSearchEntry( &nFirstBytes[15], reinterpret_cast<sal_uInt8 const *>("EPS"), 3, 3 ) ) ) - { - aMetadata.mnFormat = GraphicFileFormat::EPS; - bRet = true; - } + vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /*bExtendedInfo*/ ); + bool bRet = aDetector.detect(); + bRet &= aDetector.checkEPS(); + if ( bRet ) + aMetadata = aDetector.getMetadata(); rStm.Seek( nStmPos ); return bRet; }