Code

r13109@tres: ted | 2006-07-30 22:11:20 -0700
authorgouldtj <gouldtj@users.sourceforge.net>
Mon, 31 Jul 2006 05:15:25 +0000 (05:15 +0000)
committergouldtj <gouldtj@users.sourceforge.net>
Mon, 31 Jul 2006 05:15:25 +0000 (05:15 +0000)
 Making this all work with the Inkscape world view.

src/extension/internal/wpg-input.cpp

index 13335cf796d173d315a6188cb95dcd92bd201375..fc730a3ce6c03369e758d4042645dcb3206b5916 100644 (file)
@@ -43,6 +43,7 @@
 #include "wpg-input.h"\r
 #include "extension/system.h"\r
 #include "extension/input.h"\r
+#include "document.h"\r
 \r
 #include "libwpg/libwpg.h"\r
 #include "libwpg/WPGStreamImplementation.h"\r
@@ -77,9 +78,19 @@ private:
        FillRule m_fillRule;\r
        int m_gradientIndex;\r
        void writeStyle();\r
+        void printf (char * fmt, ...) {\r
+            va_list args;\r
+            va_start(args, fmt);\r
+            gchar * buf = g_strdup_vprintf(fmt, args);\r
+            va_end(args);\r
+            if (buf) {\r
+                document += buf;\r
+                g_free(buf);\r
+            }\r
+        }\r
 \r
 public:\r
-        std::string document;\r
+        Glib::ustring document;\r
 };\r
 \r
 InkscapePainter::InkscapePainter(): m_fillRule(AlternatingFill), m_gradientIndex(1)\r
@@ -88,6 +99,7 @@ InkscapePainter::InkscapePainter(): m_fillRule(AlternatingFill), m_gradientIndex
 \r
 void InkscapePainter::startDocument(double width, double height) \r
 {\r
+        document = "";\r
        printf("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");\r
        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
@@ -304,13 +316,16 @@ WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) {
     if (!WPGraphics::isSupported(input)) {\r
         //! \todo Dialog here\r
         // fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n");\r
+        // printf("I'm giving up not supported\n");\r
         return NULL;\r
     }\r
 \r
     InkscapePainter painter;\r
     WPGraphics::parse(input, &painter);\r
 \r
-    return 0;\r
+    //printf("I've got a doc: \n%s", painter.document.c_str());\r
+\r
+    return sp_document_new_from_mem(painter.document.c_str(), strlen(painter.document.c_str()), TRUE);\r
 }\r
 \r
 #include "clear-n_.h"\r