~ubuntu-branches/ubuntu/feisty/libwpd/feisty

« back to all changes in this revision

Viewing changes to src/lib/WP42Heuristics.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Masayuki Hatta (mhatta)
  • Date: 2004-08-10 00:37:47 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040810003747-5i7g92h2v88z70zo
Tags: 0.7.2-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
{
34
34
        int functionGroupCount = 0;
35
35
        
 
36
        WPD_DEBUG_MSG(("WP42Heuristics::isWP42FileFormat()\n"));
 
37
        
36
38
        gsf_input_seek(input, 0, G_SEEK_SET);
37
39
        
38
40
        while (!gsf_input_eof(input))
58
60
                        // check that the size constrains are valid, and that every group_member
59
61
                        // is properly closed at the right place
60
62
                
61
 
                        if (WP42_FUCNTION_GROUP_SIZE[readVal-0xC0] == -1)
 
63
                        if (WP42_FUNCTION_GROUP_SIZE[readVal-0xC0] == -1)
62
64
                        {
63
65
                                // variable length function group
64
66
                                
82
84
                                // fixed length function group
83
85
                                
84
86
                                // seek to the position where the closing gate should be
85
 
                                bool res = gsf_input_seek(input, WP42_FUCNTION_GROUP_SIZE[readVal-0xC0]-2, G_SEEK_CUR);
 
87
                                bool res = gsf_input_seek(input, WP42_FUNCTION_GROUP_SIZE[readVal-0xC0]-2, G_SEEK_CUR);
86
88
                                // when passed the complete file, we should be able to do that
87
89
                                if (!partialContent && res)
88
90
                                        return WPD_CONFIDENCE_NONE;
97
99
                }
98
100
        }       
99
101
 
100
 
        // when we get here, the document is in a format that we could import properly.
101
 
        
102
 
        // if we didn't entcounter a single WP4.2 function group) then be a bit more carefull.
103
 
        // this would be the case when passed a plaintext file for example
 
102
        /* When we get here, the document is in a format that we *could* import properly.
 
103
        However, if we didn't entcounter a single WP4.2 function group) we need to be more carefull:
 
104
        this would be the case when passed a plaintext file for example, which libwpd is not
 
105
        supposed to handle. */
104
106
        if (!functionGroupCount)
105
 
                return WPD_CONFIDENCE_LIKELY;
 
107
                return WPD_CONFIDENCE_POOR;
106
108
        
107
109
        return WPD_CONFIDENCE_EXCELLENT;
108
110
}