vcl/source/filter/graphicfilter2.cxx |   26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

New commits:
commit 735c6412deb4934e28ded552466be034a7b7b3fe
Author:     offtkp <[email protected]>
AuthorDate: Wed Aug 10 01:01:45 2022 +0300
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Fri Aug 19 10:25:29 2022 +0200

    Remove code duplication in GraphicDescriptor for XPM
    
    GraphicFormatDetector and GraphicDescriptor have duplicate format
    detection code so now GraphicDescriptor uses GraphicFormatDetector
    functions instead to detect the format for XPM files
    
    Change-Id: I9a5919cb4144edf70edc71ed89ab2cb0d605158a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138070
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/vcl/source/filter/graphicfilter2.cxx 
b/vcl/source/filter/graphicfilter2.cxx
index 331cf12f0feb..5ad698169dad 100644
--- a/vcl/source/filter/graphicfilter2.cxx
+++ b/vcl/source/filter/graphicfilter2.cxx
@@ -773,12 +773,15 @@ bool GraphicDescriptor::ImpDetectXBM( SvStream& rStm, 
bool )
     return bRet;
 }
 
-bool GraphicDescriptor::ImpDetectXPM( SvStream&, bool )
+bool GraphicDescriptor::ImpDetectXPM( SvStream& rStm, bool )
 {
-    bool bRet = aPathExt.startsWith( "xpm" );
-    if (bRet)
-        aMetadata.mnFormat = GraphicFileFormat::XPM;
-
+    sal_Int32 nStmPos = rStm.Tell();
+    vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /* 
bExtendedInfo */ );
+    bool bRet = aDetector.detect();
+    bRet &= aDetector.checkXPM();
+    if ( bRet )
+        aMetadata = aDetector.getMetadata();
+    rStm.Seek( nStmPos );
     return bRet;
 }
 
commit ca5e7672d6f0d149373aae00db082758bf3d1715
Author:     offtkp <[email protected]>
AuthorDate: Wed Aug 10 00:34:06 2022 +0300
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Fri Aug 19 10:25:18 2022 +0200

    Remove code duplication in GraphicDescriptor for XBM
    
    GraphicFormatDetector and GraphicDescriptor have duplicate format
    detection code so now GraphicDescriptor uses GraphicFormatDetector
    functions instead to detect the format for XBM files
    
    Change-Id: Id3cf1e573ec3125830299e49f0a99aab7b3fe77e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138069
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/vcl/source/filter/graphicfilter2.cxx 
b/vcl/source/filter/graphicfilter2.cxx
index ea9e5a9480d7..331cf12f0feb 100644
--- a/vcl/source/filter/graphicfilter2.cxx
+++ b/vcl/source/filter/graphicfilter2.cxx
@@ -761,12 +761,15 @@ bool GraphicDescriptor::ImpDetectTIF( SvStream& rStm, 
bool bExtendedInfo )
     return bRet;
 }
 
-bool GraphicDescriptor::ImpDetectXBM( SvStream&, bool )
+bool GraphicDescriptor::ImpDetectXBM( SvStream& rStm, bool )
 {
-    bool bRet = aPathExt.startsWith( "xbm" );
-    if (bRet)
-        aMetadata.mnFormat = GraphicFileFormat::XBM;
-
+    sal_Int32 nStmPos = rStm.Tell();
+    vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false /* 
bExtendedInfo */ );
+    bool bRet = aDetector.detect();
+    bRet &= aDetector.checkXBM();
+    if ( bRet )
+        aMetadata = aDetector.getMetadata();
+    rStm.Seek( nStmPos );
     return bRet;
 }
 

Reply via email to