From 71b63586c5fe33fdf836ecb417d11f9c2d4e4b72 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 19 Dec 2011 14:48:43 +0000 Subject: Resolves: fdo#43082 can't claim its not a DXF just because didn't see SECTION typedetection doesn't know about 999 COMMENT, it should really. --- svtools/source/filter/filter.cxx | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'svtools') diff --git a/svtools/source/filter/filter.cxx b/svtools/source/filter/filter.cxx index ef07514285df..f61990b3abc3 100644 --- a/svtools/source/filter/filter.cxx +++ b/svtools/source/filter/filter.cxx @@ -497,36 +497,36 @@ static sal_Bool ImpPeekGraphicFormat( SvStream& rStream, String& rFormatExtensio //--------------------------- DXF ------------------------------------ if( !bTest || ( rFormatExtension.CompareToAscii( "DXF", 3 ) == COMPARE_EQUAL ) ) { - bSomethingTested=sal_True; + //Binary DXF File Format + if( strncmp( (const char*) sFirstBytes, "AutoCAD Binary DXF", 18 ) == 0 ) + { + rFormatExtension = UniString::CreateFromAscii( "DXF", 3 ); + return sal_True; + } + //ASCII DXF File Format i=0; while (i<256 && sFirstBytes[i]<=32) - i++; + ++i; - if (i<256) + if (i<256 && sFirstBytes[i]=='0') { - if( sFirstBytes[i]=='0' ) - i++; - else - i=256; - } - while( i<256 && sFirstBytes[i]<=32 ) - i++; + ++i; - if (i+7<256) - { - if (strncmp((char*)(sFirstBytes+i),"SECTION",7)==0) + //only now do we have sufficient data to make a judgement + //based on a '0' + 'SECTION' == DXF argument + bSomethingTested=sal_True; + + while( i<256 && sFirstBytes[i]<=32 ) + ++i; + + if (i+7<256 && (strncmp((const char*)(sFirstBytes+i),"SECTION",7)==0)) { rFormatExtension = UniString::CreateFromAscii( "DXF", 3 ); return sal_True; } } - if( strncmp( (char*) sFirstBytes, "AutoCAD Binary DXF", 18 ) == 0 ) - { - rFormatExtension = UniString::CreateFromAscii( "DXF", 3 ); - return sal_True; - } } //--------------------------- PCT ------------------------------------ -- cgit v1.2.3