1 /*
2 * This file came from libwpg as a source, their utility wpg2svg
3 * specifically. It has been modified to work as an Inkscape extension.
4 * The Inkscape extension code is covered by this copyright, but the
5 * rest is covered by the one bellow.
6 *
7 * Authors:
8 * Ted Gould <ted@gould.cx>
9 *
10 * Copyright (C) 2006 Authors
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 *
14 */
16 /* libwpg
17 * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
18 * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Library General Public
22 * License as published by the Free Software Foundation; either
23 * version 2 of the License, or (at your option) any later version.
24 *
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Library General Public License for more details.
29 *
30 * You should have received a copy of the GNU Library General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 *
34 * For further information visit http://libwpg.sourceforge.net
35 */
37 /* "This product is not manufactured, approved, or supported by
38 * Corel Corporation or Corel Corporation Limited."
39 */
41 #include <stdio.h>
43 #include "wpg-input.h"
44 #include "extension/system.h"
45 #include "extension/input.h"
46 #include "document.h"
48 #include "libwpg/libwpg.h"
49 #include "libwpg/WPGSVGGenerator.h"
51 using namespace libwpg;
53 namespace Inkscape {
54 namespace Extension {
55 namespace Internal {
58 SPDocument *
59 WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) {
60 WPGInputStream* input = new WPGFileStream(uri);
61 if (input->isOle()) {
62 WPGInputStream* olestream = input->getWPGOleStream();
63 if (olestream) {
64 delete input;
65 input = olestream;
66 }
67 }
69 if (!WPGraphics::isSupported(input)) {
70 //! \todo Dialog here
71 // fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n");
72 // printf("I'm giving up not supported\n");
73 delete input;
74 return NULL;
75 }
77 libwpg::WPGString output;
78 if (!libwpg::WPGraphics::generateSVG(input, output)) {
79 delete input;
80 return NULL;
81 }
83 //printf("I've got a doc: \n%s", painter.document.c_str());
85 SPDocument * doc = sp_document_new_from_mem(output.cstr(), strlen(output.cstr()), TRUE);
86 delete input;
87 return doc;
88 }
90 #include "clear-n_.h"
92 void
93 WpgInput::init(void) {
94 Inkscape::Extension::Extension * ext;
96 ext = Inkscape::Extension::build_from_mem(
97 "<inkscape-extension>\n"
98 "<name>" N_("WPG Input") "</name>\n"
99 "<id>org.inkscape.input.wpg</id>\n"
100 "<input>\n"
101 "<extension>.wpg</extension>\n"
102 "<mimetype>image/x-wpg</mimetype>\n"
103 "<filetypename>" N_("WordPerfect Graphics (*.wpg)") "</filetypename>\n"
104 "<filetypetooltip>" N_("Vector graphics format used by Corel WordPerfect") "</filetypetooltip>\n"
105 "</input>\n"
106 "</inkscape-extension>", new WpgInput());
107 } // init
109 } } } /* namespace Inkscape, Extension, Implementation */
111 /*
112 Local Variables:
113 mode:c++
114 c-file-style:"stroustrup"
115 c-file-offsets:((innamespace . 0)(inline-open . 0))
116 indent-tabs-mode:nil
117 fill-column:99
118 End:
119 */
120 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :