23
23
#include <string.h>
24
#include <libwpd-stream/libwpd-stream.h>
26
#include <librevenge/librevenge.h>
27
#include <librevenge-generators/librevenge-generators.h>
28
#include <librevenge-stream/librevenge-stream.h>
25
30
#include <libwps/libwps.h>
26
#include "TextDocumentGenerator.h"
32
using namespace libwps;
39
#define VERSION "UNKNOWN VERSION"
42
static int printUsage()
44
printf("Usage: wps2text [OPTION] <Works Document>\n");
47
printf("\t-h: Shows this help message\n");
48
printf("\t-v: Output wps2text version \n");
52
static int printVersion()
54
printf("wps2text %s\n", VERSION);
28
58
int main(int argc, char *argv[])
32
printf("Usage: wps2text <Works Document>\n");
63
while ((ch = getopt(argc, argv, "hv")) != -1)
76
if (argc != 1+optind || printHelp)
36
WPXFileStream input(argv[1]);
82
librevenge::RVNGFileStream input(argv[optind]);
38
WPSConfidence confidence = WPSDocument::isFileFormatSupported(&input);
39
if (confidence == WPS_CONFIDENCE_NONE || confidence == WPS_CONFIDENCE_POOR)
85
WPSConfidence confidence = WPSDocument::isFileFormatSupported(&input,kind);
86
if (confidence == WPS_CONFIDENCE_NONE || kind != WPS_TEXT)
41
88
printf("ERROR: Unsupported file format!\n");
45
TextDocumentGenerator listenerImpl;
92
librevenge::RVNGString document;
93
librevenge::RVNGTextTextGenerator listenerImpl(document);
46
94
WPSResult error = WPSDocument::parse(&input, &listenerImpl);
48
96
if (error == WPS_FILE_ACCESS_ERROR)