summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2006-07-31 05:14:59 +0000
committergouldtj <gouldtj@users.sourceforge.net>2006-07-31 05:14:59 +0000
commit8044020060a805250b1cb764bee140461bbb6eb8 (patch)
treed8388eaa4c61ca13071d09380645c82d58bf822b /src
parentr13107@tres: ted | 2006-07-30 11:47:41 -0700 (diff)
downloadinkscape-8044020060a805250b1cb764bee140461bbb6eb8.tar.gz
inkscape-8044020060a805250b1cb764bee140461bbb6eb8.zip
r13108@tres: ted | 2006-07-30 12:27:51 -0700
Builds and links. Doesn't work, but builds and links. (bzr r1525)
Diffstat (limited to 'src')
-rw-r--r--src/extension/init.cpp2
-rw-r--r--src/extension/internal/Makefile_insert2
-rw-r--r--src/extension/internal/wpg-input.cpp112
-rw-r--r--src/extension/internal/wpg-input.h43
4 files changed, 127 insertions, 32 deletions
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index 48ebeff78..affa3bcd0 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -45,6 +45,7 @@
#include "internal/bluredge.h"
#include "internal/gimpgrad.h"
#include "internal/grid.h"
+#include "internal/wpg-input.h"
#include "prefs-utils.h"
#include "io/sys.h"
@@ -121,6 +122,7 @@ init()
Internal::OdfOutput::init();
Internal::PrintLatex::init();
Internal::LatexOutput::init();
+ Internal::WpgInput::init();
/* Effects */
Internal::BlurEdge::init();
diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert
index 57fd17b36..f39317374 100644
--- a/src/extension/internal/Makefile_insert
+++ b/src/extension/internal/Makefile_insert
@@ -48,5 +48,7 @@ extension_internal_libinternal_a_SOURCES = \
extension/internal/latex-pstricks.h \
extension/internal/latex-pstricks-out.cpp \
extension/internal/latex-pstricks-out.h \
+ extension/internal/wpg-input.cpp \
+ extension/internal/wpg-input.h \
$(extension_internal_gnome_print_sources)
diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp
index 4f296f2ab..13335cf79 100644
--- a/src/extension/internal/wpg-input.cpp
+++ b/src/extension/internal/wpg-input.cpp
@@ -1,3 +1,18 @@
+/*
+ * This file came from libwpg as a source, their utility wpg2svg
+ * specifically. It has been modified to work as an Inkscape extension.
+ * The Inkscape extension code is covered by this copyright, but the
+ * rest is covered by the one bellow.
+ *
+ * Authors:
+ * Ted Gould <ted@gould.cx>
+ *
+ * Copyright (C) 2006 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ *
+ */
+
/* libwpg
* Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
* Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
@@ -25,11 +40,19 @@
#include <stdio.h>
+#include "wpg-input.h"
+#include "extension/system.h"
+#include "extension/input.h"
+
#include "libwpg/libwpg.h"
#include "libwpg/WPGStreamImplementation.h"
using namespace libwpg;
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
class InkscapePainter : public libwpg::WPGPaintInterface {
public:
InkscapePainter();
@@ -54,6 +77,9 @@ private:
FillRule m_fillRule;
int m_gradientIndex;
void writeStyle();
+
+public:
+ std::string document;
};
InkscapePainter::InkscapePainter(): m_fillRule(AlternatingFill), m_gradientIndex(1)
@@ -66,7 +92,7 @@ void InkscapePainter::startDocument(double width, double height)
printf("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"");
printf(" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
- printf("<!-- Created with wpg2svg/libwpg %s -->\n", LIBWPG_VERSION_STRING);
+// printf("<!-- Created with wpg2svg/libwpg %s -->\n", LIBWPG_VERSION_STRING);
printf("<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" ");
printf("xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
@@ -264,35 +290,57 @@ void InkscapePainter::writeStyle()
printf("\""); // style
}
-
-int main(int argc, char *argv[])
-{
- if (argc < 2)
- {
- printf("usage: wpg2svg <WordPerfect Graphic>\n");
- return -1;
- }
-
- const char* filename = argv[1];
- WPGInputStream* input = new WPGFileStream(filename);
- if (input->isOle())
- {
- WPGInputStream* olestream = input->getWPGOleStream();
- if (olestream)
- {
- delete input;
- input = olestream;
- }
- }
-
- if (!WPGraphics::isSupported(input))
- {
- fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n");
- return 1;
- }
-
- InkscapePainter painter;
- WPGraphics::parse(input, &painter);
-
- return 0;
+SPDocument *
+WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) {
+ WPGInputStream* input = new WPGFileStream(uri);
+ if (input->isOle()) {
+ WPGInputStream* olestream = input->getWPGOleStream();
+ if (olestream) {
+ delete input;
+ input = olestream;
+ }
+ }
+
+ if (!WPGraphics::isSupported(input)) {
+ //! \todo Dialog here
+ // fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n");
+ return NULL;
+ }
+
+ InkscapePainter painter;
+ WPGraphics::parse(input, &painter);
+
+ return 0;
}
+
+#include "clear-n_.h"
+
+void
+WpgInput::init(void) {
+ Inkscape::Extension::Extension * ext;
+
+ ext = Inkscape::Extension::build_from_mem(
+ "<inkscape-extension>\n"
+ "<name>" N_("WPG Input") "</name>\n"
+ "<id>org.inkscape.input.wpg</id>\n"
+ "<input>\n"
+ "<extension>.wpg</extension>\n"
+ "<mimetype>image/x-wpg</mimetype>\n"
+ "<filetypename>" N_("WordPerfect Graphics (*.wpg)") "</filetypename>\n"
+ "<filetypetooltip>" N_("Vector graphics format used by Corel WordPerfect") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new WpgInput());
+} // init
+
+} } } /* namespace Inkscape, Extension, Implementation */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/internal/wpg-input.h b/src/extension/internal/wpg-input.h
new file mode 100644
index 000000000..0be4c8d23
--- /dev/null
+++ b/src/extension/internal/wpg-input.h
@@ -0,0 +1,43 @@
+/*
+ * This code abstracts the libwpg interfaces into the Inkscape
+ * input extension interface.
+ *
+ * Authors:
+ * Ted Gould <ted@gould.cx>
+ *
+ * Copyright (C) 2006 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef __EXTENSION_INTERNAL_WPGOUTPUT_H__
+#define __EXTENSION_INTERNAL_WPGOUTPUT_H__
+
+#include "../implementation/implementation.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+class WpgInput : public Inkscape::Extension::Implementation::Implementation {
+ WpgInput () { };
+public:
+ SPDocument *open( Inkscape::Extension::Input *mod,
+ const gchar *uri );
+ static void init( void );
+
+};
+
+} } } /* namespace Inkscape, Extension, Implementation */
+#endif /* __EXTENSION_INTERNAL_WPGOUTPUT_H__ */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :