vcl/source/filter/graphicfilter2.cxx | 35 ++++++++++++---------------- vcl/source/graphic/UnoGraphicDescriptor.cxx | 1 2 files changed, 16 insertions(+), 20 deletions(-)
New commits: commit e2043fd557200efc71ac8f014b79a40be2eaef76 Author: offtkp <parisop...@gmail.com> AuthorDate: Fri Aug 12 12:34:09 2022 +0300 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Aug 19 10:25:55 2022 +0200 Remove code duplication in GraphicDescriptor for PCT GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for PCT files Change-Id: I67b9d2ada18d5c141dd108564a4e8b632fc7299a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138189 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 2061b1a5b531..3ffe27991dd9 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -978,21 +978,13 @@ bool GraphicDescriptor::ImpDetectMET( SvStream&, bool ) bool GraphicDescriptor::ImpDetectPCT( SvStream& rStm, bool ) { - bool bRet = aPathExt.startsWith( "pct" ); - if (bRet) - aMetadata.mnFormat = GraphicFileFormat::PCT; - else - { - sal_uInt64 const nStreamPos = rStm.Tell(); - sal_uInt64 const nStreamLen = rStm.remainingSize(); - if (isPCT(rStm, nStreamPos, nStreamLen)) - { - bRet = true; - aMetadata.mnFormat = GraphicFileFormat::PCT; - } - rStm.Seek(nStreamPos); - } - + sal_Int32 nStmPos = rStm.Tell(); + vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /*bExtendedInfo*/ ); + bool bRet = aDetector.detect(); + bRet &= aDetector.checkPCT(); + if ( bRet ) + aMetadata = aDetector.getMetadata(); + rStm.Seek( nStmPos ); return bRet; } commit ea75ae547eaf69f7b4063264fe4c811d044a5798 Author: offtkp <parisop...@gmail.com> AuthorDate: Thu Aug 11 01:57:21 2022 +0300 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Aug 19 10:25:39 2022 +0200 Remove code duplication in GraphicDescriptor for SVG GraphicFormatDetector and GraphicDescriptor have duplicate format detection code so now GraphicDescriptor uses GraphicFormatDetector functions instead to detect the format for SVG files Change-Id: I5ababbd43ece4e8c08c5833895dc0b56ad467f77 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138102 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 5ad698169dad..2061b1a5b531 100644 --- a/vcl/source/filter/graphicfilter2.cxx +++ b/vcl/source/filter/graphicfilter2.cxx @@ -1096,12 +1096,15 @@ bool GraphicDescriptor::ImpDetectEMF(SvStream& rStm, bool bExtendedInfo) return bRet; } -bool GraphicDescriptor::ImpDetectSVG( SvStream& /*rStm*/, bool /*bExtendedInfo*/ ) +bool GraphicDescriptor::ImpDetectSVG( SvStream& rStm, bool /*bExtendedInfo*/ ) { - bool bRet = aPathExt.startsWith( "svg" ); - if (bRet) - aMetadata.mnFormat = GraphicFileFormat::SVG; - + sal_Int32 nStmPos = rStm.Tell(); + vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /*bExtendedInfo*/ ); + bool bRet = aDetector.detect(); + bRet &= aDetector.checkSVG(); + if ( bRet ) + aMetadata = aDetector.getMetadata(); + rStm.Seek( nStmPos ); return bRet; } diff --git a/vcl/source/graphic/UnoGraphicDescriptor.cxx b/vcl/source/graphic/UnoGraphicDescriptor.cxx index ca25e5c6d964..b9daeeab6b61 100644 --- a/vcl/source/graphic/UnoGraphicDescriptor.cxx +++ b/vcl/source/graphic/UnoGraphicDescriptor.cxx @@ -139,6 +139,7 @@ void GraphicDescriptor::implCreate( SvStream& rIStm, const OUString* pURL ) case GraphicFileFormat::EMF: pMimeType = MIMETYPE_EMF; cType = graphic::GraphicType::VECTOR; break; case GraphicFileFormat::EMZ: pMimeType = MIMETYPE_EMF; cType = graphic::GraphicType::VECTOR; break; case GraphicFileFormat::SVG: pMimeType = MIMETYPE_SVG; cType = graphic::GraphicType::VECTOR; break; + case GraphicFileFormat::SVGZ: pMimeType = MIMETYPE_SVG; cType = graphic::GraphicType::VECTOR; break; default: break;