4b6703
From 127777fe3298bcdfe45d74b36f77b8238ebb6937 Mon Sep 17 00:00:00 2001
4b6703
From: David Tardon <dtardon@redhat.com>
4b6703
Date: Tue, 27 May 2014 16:47:39 +0200
4b6703
Subject: [PATCH] switch to librevenge-based import libs
4b6703
4b6703
---
4b6703
 configure.ac                         | 19 ++---------------
4b6703
 src/extension/internal/wpg-input.cpp | 41 ++++++++++++------------------------
4b6703
 2 files changed, 15 insertions(+), 45 deletions(-)
4b6703
4b6703
diff --git a/configure.ac b/configure.ac
4b6703
index fcff879..4bce58c 100644
4b6703
--- a/configure.ac
4b6703
+++ b/configure.ac
4b6703
@@ -676,23 +676,8 @@ dnl ******************************
4b6703
 
4b6703
 with_libwpg=no
4b6703
 
4b6703
-PKG_CHECK_MODULES(LIBWPG01, libwpg-0.1 libwpg-stream-0.1, with_libwpg01=yes, with_libwpg01=no)
4b6703
-if test "x$with_libwpg01" = "xyes"; then
4b6703
-	AC_DEFINE(WITH_LIBWPG01,1,[Build in libwpg 0.1.x])
4b6703
-	with_libwpg=yes
4b6703
-	AC_SUBST(LIBWPG_LIBS, $LIBWPG01_LIBS)
4b6703
-	AC_SUBST(LIBWPG_CFLAGS, $LIBWPG01_CFLAGS)
4b6703
-fi
4b6703
-AM_CONDITIONAL(WITH_LIBWPG01, test "x$with_libwpg01" = "xyes")
4b6703
-
4b6703
-PKG_CHECK_MODULES(LIBWPG02, libwpg-0.2 libwpd-0.9 libwpd-stream-0.9, with_libwpg02=yes, with_libwpg02=no)
4b6703
-if test "x$with_libwpg02" = "xyes"; then
4b6703
-	AC_DEFINE(WITH_LIBWPG02,1,[Build in libwpg 0.2.x])
4b6703
-	with_libwpg=yes
4b6703
-	AC_SUBST(LIBWPG_LIBS, $LIBWPG02_LIBS)
4b6703
-	AC_SUBST(LIBWPG_CFLAGS, $LIBWPG02_CFLAGS)
4b6703
-fi
4b6703
-AM_CONDITIONAL(WITH_LIBWPG02, test "x$with_libwpg02" = "xyes")
4b6703
+PKG_CHECK_MODULES(LIBWPG, libwpg-0.3 librevenge-0.0 librevenge-stream-0.0, with_libwpg=yes, with_libwpg=no)
4b6703
+AM_CONDITIONAL(WITH_LIBWPG01, test "x$with_libwpg" = "xyes")
4b6703
 
4b6703
 if test "x$with_libwpg" = "xyes"; then
4b6703
 	AC_DEFINE(WITH_LIBWPG,1,[Build in libwpg])
4b6703
diff --git a/src/extension/internal/wpg-input.cpp b/src/extension/internal/wpg-input.cpp
4b6703
index 5c5cb65..71c7b44 100644
4b6703
--- a/src/extension/internal/wpg-input.cpp
4b6703
+++ b/src/extension/internal/wpg-input.cpp
4b6703
@@ -48,17 +48,8 @@
4b6703
 #include "extension/input.h"
4b6703
 #include "document.h"
4b6703
 
4b6703
-// Take a guess and fallback to 0.1.x if no configure has run
4b6703
-#if !defined(WITH_LIBWPG01) && !defined(WITH_LIBWPG02)
4b6703
-#define WITH_LIBWPG01 1
4b6703
-#endif
4b6703
-
4b6703
 #include "libwpg/libwpg.h"
4b6703
-#if WITH_LIBWPG01
4b6703
-#include "libwpg/WPGStreamImplementation.h"
4b6703
-#elif WITH_LIBWPG02
4b6703
-#include "libwpd-stream/libwpd-stream.h"
4b6703
-#endif
4b6703
+#include "librevenge-stream/librevenge-stream.h"
4b6703
 
4b6703
 using namespace libwpg;
4b6703
 
4b6703
@@ -69,17 +60,9 @@ namespace Internal {
4b6703
 
4b6703
 SPDocument *
4b6703
 WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) {
4b6703
-#if WITH_LIBWPG01
4b6703
-    WPXInputStream* input = new libwpg::WPGFileStream(uri);
4b6703
-#elif WITH_LIBWPG02
4b6703
-    WPXInputStream* input = new WPXFileStream(uri);
4b6703
-#endif
4b6703
-    if (input->isOLEStream()) {
4b6703
-#if WITH_LIBWPG01
4b6703
-        WPXInputStream* olestream = input->getDocumentOLEStream();
4b6703
-#elif WITH_LIBWPG02
4b6703
-        WPXInputStream* olestream = input->getDocumentOLEStream("PerfectOffice_MAIN");
4b6703
-#endif
4b6703
+    librevenge::RVNGInputStream* input = new librevenge::RVNGFileStream(uri);
4b6703
+    if (input->isStructured()) {
4b6703
+        librevenge::RVNGInputStream* olestream = input->getSubStreamByName("PerfectOffice_MAIN");
4b6703
         if (olestream) {
4b6703
             delete input;
4b6703
             input = olestream;
4b6703
@@ -94,15 +77,17 @@ WpgInput::open(Inkscape::Extension::Input * mod, const gchar * uri) {
4b6703
         return NULL;
4b6703
     }
4b6703
 
4b6703
-#if WITH_LIBWPG01
4b6703
-    libwpg::WPGString output;
4b6703
-#elif WITH_LIBWPG02
4b6703
-    WPXString output;
4b6703
-#endif
4b6703
-    if (!libwpg::WPGraphics::generateSVG(input, output)) {
4b6703
+	librevenge::RVNGStringVector vec;
4b6703
+	librevenge::RVNGSVGDrawingGenerator generator(vec, "");
4b6703
+
4b6703
+	if (!libwpg::WPGraphics::parse(input, &generator) || vec.empty() || vec[0].empty())
4b6703
+ 	{
4b6703
         delete input;
4b6703
         return NULL;
4b6703
-    }
4b6703
+ 	}
4b6703
+
4b6703
+    librevenge::RVNGString output("\n\n");
4b6703
+	output.append(vec[0]);
4b6703
 
4b6703
     //printf("I've got a doc: \n%s", painter.document.c_str());
4b6703
 
4b6703
-- 
4b6703
1.9.3
4b6703