~ubuntu-branches/ubuntu/trusty/libwpd/trusty

« back to all changes in this revision

Viewing changes to src/conv/html/wpd2html.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Rene Engelhard
  • Date: 2008-02-12 15:22:12 UTC
  • mfrom: (1.2.1 upstream) (10.1.5 gutsy)
  • Revision ID: james.westby@ubuntu.com-20080212152212-beh3l4ahg9b4o3lj
Tags: 0.8.14-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* libwpd
 
2
 * Copyright (C) 2002-2003 William Lachance (wrlach@gmail.com)
 
3
 * Copyright (C) 2002-2004 Marc Maurer (uwog@uwog.net)
 
4
 *  
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 *
 
19
 * For further information visit http://libwpd.sourceforge.net
 
20
 */
 
21
 
 
22
#include <stdio.h>
 
23
#include "HtmlListenerImpl.h"
 
24
#include "WPXStreamImplementation.h"
 
25
#include "WPDocument.h"
 
26
 
 
27
int main(int argc, char *argv[])
 
28
{
 
29
        if (argc < 2)
 
30
        {
 
31
                printf("Usage: wpd2html <WordPerfect Document>\n");
 
32
                return 1;
 
33
        }
 
34
        
 
35
        WPXInputStream* input = new WPXFileStream(argv[1]);
 
36
 
 
37
        WPDConfidence confidence = WPDocument::isFileFormatSupported(input, false);
 
38
        if (confidence == WPD_CONFIDENCE_NONE || confidence == WPD_CONFIDENCE_POOR)
 
39
        {
 
40
                printf("ERROR: Unsupported file format!\n");
 
41
                delete input;
 
42
                return 1;
 
43
        }
 
44
 
 
45
        HtmlListenerImpl listenerImpl;
 
46
        WPDResult error = WPDocument::parse(input, static_cast<WPXHLListenerImpl *>(&listenerImpl));
 
47
 
 
48
        if (error == WPD_FILE_ACCESS_ERROR)
 
49
                fprintf(stderr, "ERROR: File Exception!\n");
 
50
        else if (error == WPD_PARSE_ERROR)
 
51
                fprintf(stderr, "ERROR: Parse Exception!\n");
 
52
        else if (error == WPD_UNSUPPORTED_ENCRYPTION_ERROR)
 
53
                fprintf(stderr, "ERROR: File is password protected!\n");
 
54
        else if (error == WPD_OLE_ERROR)
 
55
                fprintf(stderr, "ERROR: File is an OLE document, but does not contain a WordPerfect stream!\n");
 
56
        else if (error != WPD_OK)
 
57
                fprintf(stderr, "ERROR: Unknown Error!\n");
 
58
 
 
59
        delete input;
 
60
 
 
61
        if (error != WPD_OK)
 
62
                return 1;
 
63
 
 
64
        return 0;
 
65
}