2
* Copyright (C) 2002 William Lachance (wrlach@gmail.com)
3
* Copyright (C) 2002,2004 Marc Maurer (uwog@uwog.net)
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Library General Public License for more details.
15
* You should have received a copy of the GNU Library General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19
* For further information visit http://libwpd.sourceforge.net
22
/* "This product is not manufactured, approved, or supported by
23
* Corel Corporation or Corel Corporation Limited."
26
#include <gsf/gsf-utils.h>
27
#include <gsf/gsf-input-stdio.h>
30
#include "GSFStream.h"
31
#include "RawListener.h"
33
int main(int argc, char *argv[])
35
bool printIndentLevel = false;
40
printf("Usage: wpd2raw [OPTION] <WordPerfect Document>\n");
45
if (!strcmp(argv[1], "--callgraph"))
49
printf("Usage: wpd2raw [OPTION] <WordPerfect Document>\n");
53
printIndentLevel = true;
56
else if (!strcmp(argv[1], "--help"))
58
printf("Usage: wpd2raw [OPTION] <WordPerfect Document>\n");
61
printf("--callgraph Display the call graph nesting level\n");
62
printf("--help Shows this help message\n");
70
GsfInput * input = GSF_INPUT(gsf_input_stdio_new (file, &err));
73
g_return_val_if_fail (err != 0, 1);
75
g_warning ("'%s' error: %s", file, err->message);
81
GSFInputStream *gsfInput = new GSFInputStream(input);
83
WPDConfidence confidence = WPDocument::isFileFormatSupported(gsfInput, false);
84
if (confidence == WPD_CONFIDENCE_NONE || confidence == WPD_CONFIDENCE_POOR)
86
printf("ERROR: Unsupported file format!\n");
88
g_object_unref(input);
93
RawListenerImpl listenerImpl(printIndentLevel);
94
WPDResult error = WPDocument::parse(gsfInput, static_cast<WPXHLListenerImpl *>(&listenerImpl));
96
if (error == WPD_FILE_ACCESS_ERROR)
97
fprintf(stderr, "ERROR: File Exception!\n");
98
else if (error == WPD_PARSE_ERROR)
99
fprintf(stderr, "ERROR: Parse Exception!\n");
100
else if (error == WPD_UNSUPPORTED_ENCRYPTION_ERROR)
101
fprintf(stderr, "ERROR: File is password protected!\n");
102
else if (error == WPD_OLE_ERROR)
103
fprintf(stderr, "ERROR: File is an OLE document, but does not contain a WordPerfect stream!\n");
104
else if (error != WPD_OK)
105
fprintf(stderr, "ERROR: Unknown Error!\n");
108
g_object_unref (input);