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."
28
#include "WPXStreamImplementation.h"
29
#include "RawListener.h"
31
int main(int argc, char *argv[])
33
bool printIndentLevel = false;
38
printf("Usage: wpd2raw [OPTION] <WordPerfect Document>\n");
42
if (!strcmp(argv[1], "--callgraph"))
46
printf("Usage: wpd2raw [OPTION] <WordPerfect Document>\n");
50
printIndentLevel = true;
53
else if (!strcmp(argv[1], "--help"))
55
printf("Usage: wpd2raw [OPTION] <WordPerfect Document>\n");
58
printf("--callgraph Display the call graph nesting level\n");
59
printf("--help Shows this help message\n");
65
WPXInputStream* input = new WPXFileStream(file);
67
WPDConfidence confidence = WPDocument::isFileFormatSupported(input, false);
68
if (confidence == WPD_CONFIDENCE_NONE || confidence == WPD_CONFIDENCE_POOR)
70
printf("ERROR: Unsupported file format!\n");
75
RawListenerImpl listenerImpl(printIndentLevel);
76
WPDResult error = WPDocument::parse(input, static_cast<WPXHLListenerImpl *>(&listenerImpl));
78
if (error == WPD_FILE_ACCESS_ERROR)
79
fprintf(stderr, "ERROR: File Exception!\n");
80
else if (error == WPD_PARSE_ERROR)
81
fprintf(stderr, "ERROR: Parse Exception!\n");
82
else if (error == WPD_UNSUPPORTED_ENCRYPTION_ERROR)
83
fprintf(stderr, "ERROR: File is password protected!\n");
84
else if (error == WPD_OLE_ERROR)
85
fprintf(stderr, "ERROR: File is an OLE document, but does not contain a WordPerfect stream!\n");
86
else if (error != WPD_OK)
87
fprintf(stderr, "ERROR: Unknown Error!\n");