~ubuntu-branches/ubuntu/breezy/libwpd/breezy

« back to all changes in this revision

Viewing changes to src/conv/raw/main.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:
27
27
#include <gsf/gsf-input-stdio.h>
28
28
#include <stdio.h>
29
29
#include "libwpd.h"
30
 
#include "WP6HLContentListener.h"
31
30
#include "RawListener.h"
32
31
 
33
32
int main(int argc, char *argv[])
34
33
{
 
34
        bool printIndentLevel = false;
 
35
        char *file = NULL;
 
36
        
35
37
        if (argc < 2)
36
38
        {
37
 
                printf("usage: wpd2raw <WordPerfect Document>\n");
 
39
                printf("Usage: wpd2raw [OPTION] <WordPerfect Document>\n");
38
40
                return -1;
39
41
        }
40
42
        gsf_init();
41
43
 
 
44
        if (!strcmp(argv[1], "--callgraph"))
 
45
        {
 
46
                if (argc == 2)
 
47
                {
 
48
                        printf("Usage: wpd2raw [OPTION] <WordPerfect Document>\n");
 
49
                        return -1;
 
50
                }
 
51
                        
 
52
                printIndentLevel = true;
 
53
                file = argv[2];
 
54
        }
 
55
        else if (!strcmp(argv[1], "--help"))
 
56
        {
 
57
                printf("Usage: wpd2raw [OPTION] <WordPerfect Document>\n");
 
58
                printf("\n");
 
59
                printf("Options:\n");
 
60
                printf("--callgraph                 Display the call graph nesting level\n");
 
61
                printf("--help              Shows this help message\n");
 
62
                return 0;
 
63
        }
 
64
        else
 
65
                file = argv[1];
 
66
                
 
67
        
42
68
        GError   *err;
43
 
        GsfInput * input = GSF_INPUT(gsf_input_stdio_new (argv[1], &err));
 
69
        GsfInput * input = GSF_INPUT(gsf_input_stdio_new (file, &err));
44
70
        if (input == NULL) 
45
 
                {
46
 
                        g_return_val_if_fail (err != NULL, 1);
47
 
                        
48
 
                        g_warning ("'%s' error: %s", argv[1], err->message);
49
 
                        g_error_free (err);
50
 
                        return 1;
51
 
                }
 
71
        {
 
72
                g_return_val_if_fail (err != NULL, 1);
 
73
                
 
74
                g_warning ("'%s' error: %s", file, err->message);
 
75
                g_error_free (err);
 
76
                return 1;
 
77
        }
52
78
 
53
 
        if (!WPDocument::isFileFormatSupported(input, false))
 
79
        WPDConfidence confidence = WPDocument::isFileFormatSupported(input, false);
 
80
        if (confidence == WPD_CONFIDENCE_NONE || confidence == WPD_CONFIDENCE_POOR)
54
81
        {
55
82
                printf("ERROR: Unsupported file format!\n");
56
83
                return 1;
57
84
        }
58
85
        
59
 
        RawListenerImpl listenerImpl;
 
86
        RawListenerImpl listenerImpl(printIndentLevel);
60
87
        try 
61
88
        {
62
89
                WPDocument::parse(input, static_cast<WPXHLListenerImpl *>(&listenerImpl));
82
109
            return 1;
83
110
        }
84
111
 
 
112
        g_object_unref (G_OBJECT (input));
 
113
        gsf_shutdown();
 
114
 
85
115
        return 0;
86
116
}