Code

r13108@tres: ted | 2006-07-30 12:27:51 -0700
authorgouldtj <gouldtj@users.sourceforge.net>
Mon, 31 Jul 2006 05:14:59 +0000 (05:14 +0000)
committergouldtj <gouldtj@users.sourceforge.net>
Mon, 31 Jul 2006 05:14:59 +0000 (05:14 +0000)
 Builds and links.  Doesn't work, but builds and links.

src/extension/init.cpp
src/extension/internal/Makefile_insert
src/extension/internal/wpg-input.cpp
src/extension/internal/wpg-input.h [new file with mode: 0644]

index 48ebeff789ce0e89aa1874eee4987c3f64b97b5c..affa3bcd01e62abf09e85eacc202afe3e28ddcb6 100644 (file)
@@ -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();
index 57fd17b3670ce5a3e3eda77f97eab50e8211e2b0..f393173745d58c4c79517092e0cc719520cab623 100644 (file)
@@ -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)
 
index 4f296f2abf36e136d4e3a80aa867d55fc6e860b3..13335cf796d173d315a6188cb95dcd92bd201375 100644 (file)
@@ -1,3 +1,18 @@
+/* \r
+ *  This file came from libwpg as a source, their utility wpg2svg\r
+ *  specifically.  It has been modified to work as an Inkscape extension.\r
+ *  The Inkscape extension code is covered by this copyright, but the\r
+ *  rest is covered by the one bellow.\r
+ *\r
+ * Authors:\r
+ *   Ted Gould <ted@gould.cx>\r
+ *\r
+ * Copyright (C) 2006 Authors\r
+ *\r
+ * Released under GNU GPL, read the file 'COPYING' for more information\r
+ *\r
+ */\r
+\r
 /* libwpg\r
  * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)\r
  * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)\r
 \r
 #include <stdio.h>\r
 \r
+#include "wpg-input.h"\r
+#include "extension/system.h"\r
+#include "extension/input.h"\r
+\r
 #include "libwpg/libwpg.h"\r
 #include "libwpg/WPGStreamImplementation.h"\r
 \r
 using namespace libwpg;\r
 \r
+namespace Inkscape {\r
+namespace Extension {\r
+namespace Internal {\r
+\r
 class InkscapePainter : public libwpg::WPGPaintInterface {\r
 public:\r
        InkscapePainter();\r
@@ -54,6 +77,9 @@ private:
        FillRule m_fillRule;\r
        int m_gradientIndex;\r
        void writeStyle();\r
+\r
+public:\r
+        std::string document;\r
 };\r
 \r
 InkscapePainter::InkscapePainter(): m_fillRule(AlternatingFill), m_gradientIndex(1)\r
@@ -66,7 +92,7 @@ void InkscapePainter::startDocument(double width, double height)
        printf("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"");\r
        printf(" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");\r
 \r
-       printf("<!-- Created with wpg2svg/libwpg %s -->\n", LIBWPG_VERSION_STRING);\r
+//     printf("<!-- Created with wpg2svg/libwpg %s -->\n", LIBWPG_VERSION_STRING);\r
 \r
        printf("<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" ");\r
        printf("xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");        \r
@@ -264,35 +290,57 @@ void InkscapePainter::writeStyle()
        printf("\""); // style\r
 }\r
 \r
-\r
-int main(int argc, char *argv[])\r
-{\r
-       if (argc < 2)\r
-       {\r
-               printf("usage: wpg2svg <WordPerfect Graphic>\n");\r
-               return -1;\r
-       }\r
-\r
-       const char* filename = argv[1];\r
-       WPGInputStream* input = new WPGFileStream(filename);\r
-       if (input->isOle())\r
-       {\r
-               WPGInputStream* olestream = input->getWPGOleStream();\r
-               if (olestream)\r
-               {\r
-                       delete input;\r
-                       input = olestream;\r
-               }\r
-       }\r
-\r
-       if (!WPGraphics::isSupported(input))\r
-       {\r
-               fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n");\r
-               return 1;\r
-       }\r
-       \r
-       InkscapePainter painter;\r
-       WPGraphics::parse(input, &painter);\r
-       \r
-       return 0;\r
+SPDocument *\r
+WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) {\r
+    WPGInputStream* input = new WPGFileStream(uri);\r
+    if (input->isOle()) {\r
+        WPGInputStream* olestream = input->getWPGOleStream();\r
+        if (olestream) {\r
+            delete input;\r
+            input = olestream;\r
+        }\r
+    }\r
+\r
+    if (!WPGraphics::isSupported(input)) {\r
+        //! \todo Dialog here\r
+        // fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n");\r
+        return NULL;\r
+    }\r
+\r
+    InkscapePainter painter;\r
+    WPGraphics::parse(input, &painter);\r
+\r
+    return 0;\r
 }\r
+\r
+#include "clear-n_.h"\r
+\r
+void\r
+WpgInput::init(void) {\r
+    Inkscape::Extension::Extension * ext;\r
+\r
+    ext = Inkscape::Extension::build_from_mem(\r
+        "<inkscape-extension>\n"\r
+            "<name>" N_("WPG Input") "</name>\n"\r
+            "<id>org.inkscape.input.wpg</id>\n"\r
+            "<input>\n"\r
+                "<extension>.wpg</extension>\n"\r
+                "<mimetype>image/x-wpg</mimetype>\n"\r
+                "<filetypename>" N_("WordPerfect Graphics (*.wpg)") "</filetypename>\n"\r
+                "<filetypetooltip>" N_("Vector graphics format used by Corel WordPerfect") "</filetypetooltip>\n"\r
+            "</input>\n"\r
+        "</inkscape-extension>", new WpgInput());\r
+} // init\r
+\r
+} } }  /* namespace Inkscape, Extension, Implementation */\r
+\r
+/*\r
+  Local Variables:\r
+  mode:c++\r
+  c-file-style:"stroustrup"\r
+  c-file-offsets:((innamespace . 0)(inline-open . 0))\r
+  indent-tabs-mode:nil\r
+  fill-column:99\r
+  End:\r
+*/\r
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :\r
diff --git a/src/extension/internal/wpg-input.h b/src/extension/internal/wpg-input.h
new file mode 100644 (file)
index 0000000..0be4c8d
--- /dev/null
@@ -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 :