vcl/source/filter/graphicfilter2.cxx |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

New commits:
commit 45705461d4597b736c44e006360f9072eed3fe85
Author:     offtkp <parisop...@gmail.com>
AuthorDate: Sun Aug 7 22:24:39 2022 +0300
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Fri Aug 19 10:23:47 2022 +0200

    Remove code duplication in GraphicDescriptor for DXF
    
    GraphicFormatDetector and GraphicDescriptor have duplicate format
    detection code so now GraphicDescriptor uses GraphicFormatDetector
    functions instead to detect the format for DXF files
    
    Change-Id: I13a3c40ee35259b6b61aa323f4fa5af73290e94b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137935
    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 0a58f03a98ea..8ce85ee1f9df 100644
--- a/vcl/source/filter/graphicfilter2.cxx
+++ b/vcl/source/filter/graphicfilter2.cxx
@@ -954,12 +954,15 @@ bool GraphicDescriptor::ImpDetectEPS( SvStream& rStm, 
bool )
     return bRet;
 }
 
-bool GraphicDescriptor::ImpDetectDXF( SvStream&, bool )
+bool GraphicDescriptor::ImpDetectDXF( SvStream& rStm, bool )
 {
-    bool bRet = aPathExt.startsWith( "dxf" );
-    if (bRet)
-        aMetadata.mnFormat = GraphicFileFormat::DXF;
-
+    sal_Int32 nStmPos = rStm.Tell();
+    vcl::GraphicFormatDetector aDetector( rStm, aPathExt, false 
/*bExtendedInfo*/ );
+    bool bRet = aDetector.detect();
+    bRet &= aDetector.checkDXF();
+    if ( bRet )
+        aMetadata = aDetector.getMetadata();
+    rStm.Seek( nStmPos );
     return bRet;
 }
 

Reply via email to