summaryrefslogtreecommitdiff
path: root/src/conv
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2011-05-17 10:59:34 +0200
committerFridrich Štrba <fridrich.strba@bluewin.ch>2011-05-17 10:59:34 +0200
commitb30ffe08194f5b1573ba7ce101dea356bb9fdb54 (patch)
treeac53b1e725aa41ee81489c3aa0053f897f8106f8 /src/conv
Initial skeleton of libvisio
Diffstat (limited to 'src/conv')
-rw-r--r--src/conv/Makefile.am6
-rw-r--r--src/conv/raw/Makefile.am30
-rw-r--r--src/conv/raw/vsd2raw.cpp268
-rw-r--r--src/conv/raw/vsd2raw.rc.in31
-rw-r--r--src/conv/svg/Makefile.am30
-rw-r--r--src/conv/svg/vsd2svg.cpp91
-rw-r--r--src/conv/svg/vsd2svg.rc.in31
7 files changed, 487 insertions, 0 deletions
diff --git a/src/conv/Makefile.am b/src/conv/Makefile.am
new file mode 100644
index 0000000..c872294
--- /dev/null
+++ b/src/conv/Makefile.am
@@ -0,0 +1,6 @@
+AUTOMAKE_OPTIONS = gnu 1.4
+
+pkgconfigdir = $(libdir)/pkgconfig
+
+SUBDIRS = raw svg
+
diff --git a/src/conv/raw/Makefile.am b/src/conv/raw/Makefile.am
new file mode 100644
index 0000000..aa57adf
--- /dev/null
+++ b/src/conv/raw/Makefile.am
@@ -0,0 +1,30 @@
+bin_PROGRAMS = vsd2raw
+
+AM_CXXFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib $(LIBVISIO_CXXFLAGS) $(DEBUG_CXXFLAGS)
+
+vsd2raw_DEPENDENCIES = @WPG2RAW_WIN32_RESOURCE@
+
+if STATIC_TOOLS
+vsd2raw_LDADD = ../../lib/@WPG_OBJDIR@/libvisio-@WPG_MAJOR_VERSION@.@WPG_MINOR_VERSION@.a $(LIBVISIO_LIBS) @WPG2RAW_WIN32_RESOURCE@
+vsd2raw_LDFLAGS = -all-static
+else
+vsd2raw_LDADD = ../../lib/libvisio-@WPG_MAJOR_VERSION@.@WPG_MINOR_VERSION@.la $(LIBVISIO_LIBS) @WPG2RAW_WIN32_RESOURCE@
+endif
+
+vsd2raw_SOURCES = \
+ vsd2raw.cpp
+
+if OS_WIN32
+
+@WPG2RAW_WIN32_RESOURCE@ : vsd2raw.rc $(vsd2raw_OBJECTS)
+ chmod +x $(top_srcdir)/build/win32/*compile-resource
+ WINDRES=@WINDRES@ $(top_srcdir)/build/win32/lt-compile-resource vsd2raw.rc @WPG2RAW_WIN32_RESOURCE@
+endif
+
+EXTRA_DIST = \
+ $(vsd2raw_SOURCES) \
+ vsd2raw.rc.in
+
+# These may be in the builddir too
+BUILD_EXTRA_DIST = \
+ vsd2raw.rc
diff --git a/src/conv/raw/vsd2raw.cpp b/src/conv/raw/vsd2raw.cpp
new file mode 100644
index 0000000..b7e0877
--- /dev/null
+++ b/src/conv/raw/vsd2raw.cpp
@@ -0,0 +1,268 @@
+/* libwpg
+ * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
+ * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
+ * Copyright (C) 2004 Marc Oude Kotte (marc@solcon.nl)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02111-1301 USA
+ *
+ * For further information visit http://libwpg.sourceforge.net
+ */
+
+/* "This product is not manufactured, approved, or supported by
+ * Corel Corporation or Corel Corporation Limited."
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "libwpg.h"
+#include <libwpd-stream/libwpd-stream.h>
+#include <libwpd/libwpd.h>
+
+class RawPainter : public libwpg::WPGPaintInterface {
+public:
+ RawPainter();
+
+ void startGraphics(const ::WPXPropertyList &propList);
+ void endGraphics();
+ void startLayer(const ::WPXPropertyList& propList);
+ void endLayer();
+ void startEmbeddedGraphics(const ::WPXPropertyList& propList);
+ void endEmbeddedGraphics();
+
+ void setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector& gradient);
+
+ void drawRectangle(const ::WPXPropertyList &propList);
+ void drawEllipse(const ::WPXPropertyList& propList);
+ void drawPolyline(const ::WPXPropertyListVector& vertices);
+ void drawPolygon(const ::WPXPropertyListVector& vertices);
+ void drawPath(const ::WPXPropertyListVector& path);
+ void drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData& binaryData);
+ void startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path);
+ void endTextObject();
+ void startTextLine(const ::WPXPropertyList &propList);
+ void endTextLine();
+ void startTextSpan(const ::WPXPropertyList &propList);
+ void endTextSpan();
+ void insertText(const ::WPXString &str);
+};
+
+WPXString getPropString(const WPXPropertyList &propList)
+{
+ WPXString propString;
+ WPXPropertyList::Iter i(propList);
+ if (!i.last())
+ {
+ propString.append(i.key());
+ propString.append(": ");
+ propString.append(i()->getStr().cstr());
+ for (; i.next(); )
+ {
+ propString.append(", ");
+ propString.append(i.key());
+ propString.append(": ");
+ propString.append(i()->getStr().cstr());
+ }
+ }
+
+ return propString;
+}
+
+WPXString getPropString(const WPXPropertyListVector &itemList)
+{
+ WPXString propString;
+
+ propString.append("(");
+ WPXPropertyListVector::Iter i(itemList);
+
+ if (!i.last())
+ {
+ propString.append("(");
+ propString.append(getPropString(i()));
+ propString.append(")");
+
+ for (; i.next();)
+ {
+ propString.append(", (");
+ propString.append(getPropString(i()));
+ propString.append(")");
+ }
+
+ }
+ propString.append(")");
+
+ return propString;
+}
+
+RawPainter::RawPainter(): libwpg::WPGPaintInterface()
+{
+}
+
+void RawPainter::startGraphics(const ::WPXPropertyList &propList)
+{
+ printf("RawPainter::startGraphics(%s)\n", getPropString(propList).cstr());
+}
+
+void RawPainter::endGraphics()
+{
+ printf("RawPainter::endGraphics\n");
+}
+
+void RawPainter::startLayer(const ::WPXPropertyList& propList)
+{
+ printf("RawPainter::startLayer (%s)\n", getPropString(propList).cstr());
+}
+
+void RawPainter::endLayer()
+{
+ printf("RawPainter::endLayer\n");
+}
+
+void RawPainter::startEmbeddedGraphics(const ::WPXPropertyList& propList)
+{
+ printf("RawPainter::startEmbeddedGraphics (%s)\n", getPropString(propList).cstr());
+}
+
+void RawPainter::endEmbeddedGraphics()
+{
+ printf("RawPainter::endEmbeddedGraphics \n");
+}
+
+void RawPainter::setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector& gradient)
+{
+ printf("RawPainter::setStyle(%s, gradient: (%s))\n", getPropString(propList).cstr(), getPropString(gradient).cstr());
+}
+
+void RawPainter::drawRectangle(const ::WPXPropertyList &propList)
+{
+ printf("RawPainter::drawRectangle (%s)\n", getPropString(propList).cstr());
+}
+
+void RawPainter::drawEllipse(const ::WPXPropertyList& propList)
+{
+ printf("RawPainter::drawEllipse (%s)\n", getPropString(propList).cstr());
+}
+
+void RawPainter::drawPolyline(const ::WPXPropertyListVector& vertices)
+{
+ printf("RawPainter::drawPolyline (%s)\n", getPropString(vertices).cstr());
+}
+
+void RawPainter::drawPolygon(const ::WPXPropertyListVector& vertices)
+{
+ printf("RawPainter::drawPolygon (%s)\n", getPropString(vertices).cstr());
+}
+
+void RawPainter::drawPath(const ::WPXPropertyListVector& path)
+{
+ printf("RawPainter::drawPath (%s)\n", getPropString(path).cstr());
+}
+
+void RawPainter::drawGraphicObject(const ::WPXPropertyList& propList, const ::WPXBinaryData& /*binaryData*/)
+{
+ printf("RawPainter::drawGraphicObject (%s)\n", getPropString(propList).cstr());
+}
+
+void RawPainter::startTextObject(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &path)
+{
+ printf("RawPainter::startTextObject (%s, path: (%s))\n", getPropString(propList).cstr(), getPropString(path).cstr());
+}
+
+void RawPainter::endTextObject()
+{
+ printf("RawPainter::endTextObject\n");
+}
+
+void RawPainter::startTextLine(const ::WPXPropertyList &propList)
+{
+ printf("RawPainter::startTextLine (%s)\n", getPropString(propList).cstr());
+}
+
+void RawPainter::endTextLine()
+{
+ printf("RawPainter::endTextLine\n");
+}
+
+void RawPainter::startTextSpan(const ::WPXPropertyList &propList)
+{
+ printf("RawPainter::startTextSpan (%s)\n", getPropString(propList).cstr());
+}
+
+void RawPainter::endTextSpan()
+{
+ printf("RawPainter::endTextSpan\n");
+}
+
+void RawPainter::insertText(const ::WPXString &str)
+{
+ printf("RawPainter::insertText (%s)\n", str.cstr());
+}
+
+
+namespace {
+
+int printUsage()
+{
+ printf("Usage: wpg2raw [OPTION] <WordPerfect Graphics File>\n");
+ printf("\n");
+ printf("Options:\n");
+ printf("--help Shows this help message\n");
+ printf("--version Output wpg2raw version \n");
+ return -1;
+}
+
+int printVersion()
+{
+ printf("wpg2raw %s\n", LIBWPG_VERSION_STRING);
+ return 0;
+}
+
+} // anonymous namespace
+
+int main(int argc, char *argv[])
+{
+ if (argc < 2)
+ return printUsage();
+
+ char *file = 0;
+
+ for (int i = 1; i < argc; i++)
+ {
+ if (!strcmp(argv[i], "--version"))
+ return printVersion();
+ else if (!file && strncmp(argv[i], "--", 2))
+ file = argv[i];
+ else
+ return printUsage();
+ }
+
+ if (!file)
+ return printUsage();
+
+ WPXFileStream input(file);
+
+ if (!libwpg::WPGraphics::isSupported(&input))
+ {
+ fprintf(stderr, "ERROR: Unsupported file format (unsupported version) or file is encrypted!\n");
+ return 1;
+ }
+
+ RawPainter painter;
+ libwpg::WPGraphics::parse(&input, &painter);
+
+ return 0;
+}
+
diff --git a/src/conv/raw/vsd2raw.rc.in b/src/conv/raw/vsd2raw.rc.in
new file mode 100644
index 0000000..dded1ee
--- /dev/null
+++ b/src/conv/raw/vsd2raw.rc.in
@@ -0,0 +1,31 @@
+#include <winver.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @WPG_MAJOR_VERSION@,@WPG_MINOR_VERSION@,@WPG_MICRO_VERSION@,BUILDNUMBER
+ PRODUCTVERSION @WPG_MAJOR_VERSION@,@WPG_MINOR_VERSION@,@WPG_MICRO_VERSION@,0
+ FILEFLAGSMASK 0
+ FILEFLAGS 0
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_APP
+ FILESUBTYPE VFT2_UNKNOWN
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", "The libwpg developer community"
+ VALUE "FileDescription", "wpg2raw"
+ VALUE "FileVersion", "@WPG_MAJOR_VERSION@.@WPG_MINOR_VERSION@.@WPG_MICRO_VERSION@.BUILDNUMBER"
+ VALUE "InternalName", "wpg2raw"
+ VALUE "LegalCopyright", "Copyright (C) 2004 Marc Oude Kotte, other contributers"
+ VALUE "OriginalFilename", "wpg2raw.exe"
+ VALUE "ProductName", "libwpg"
+ VALUE "ProductVersion", "@WPG_MAJOR_VERSION@.@WPG_MINOR_VERSION@.@WPG_MICRO_VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
+
diff --git a/src/conv/svg/Makefile.am b/src/conv/svg/Makefile.am
new file mode 100644
index 0000000..b5c3535
--- /dev/null
+++ b/src/conv/svg/Makefile.am
@@ -0,0 +1,30 @@
+bin_PROGRAMS = vsd2svg
+
+AM_CXXFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib $(LIBVISIO_CXXFLAGS) $(DEBUG_CXXFLAGS)
+
+vsd2svg_DEPENDENCIES = @WPG2SVG_WIN32_RESOURCE@
+
+if STATIC_TOOLS
+vsd2svg_LDADD = ../../lib/@WPG_OBJDIR@/libvisio-@WPG_MAJOR_VERSION@.@WPG_MINOR_VERSION@.a $(LIBVISIO_LIBS) @WPG2SVG_WIN32_RESOURCE@
+vsd2svg_LDFLAGS = -all-static
+else
+vsd2svg_LDADD = ../../lib/libvisio-@WPG_MAJOR_VERSION@.@WPG_MINOR_VERSION@.la $(LIBVISIO_LIBS) @WPG2SVG_WIN32_RESOURCE@
+endif
+
+vsd2svg_SOURCES = \
+ vsd2svg.cpp
+
+if OS_WIN32
+
+@WPG2SVG_WIN32_RESOURCE@ : vsd2svg.rc $(vsd2svg_OBJECTS)
+ chmod +x $(top_srcdir)/build/win32/*compile-resource
+ WINDRES=@WINDRES@ $(top_srcdir)/build/win32/lt-compile-resource vsd2svg.rc @WPG2SVG_WIN32_RESOURCE@
+endif
+
+EXTRA_DIST = \
+ $(vsd2svg_SOURCES) \
+ vsd2svg.rc.in
+
+# These may be in the builddir too
+BUILD_EXTRA_DIST = \
+ vsd2svg.rc
diff --git a/src/conv/svg/vsd2svg.cpp b/src/conv/svg/vsd2svg.cpp
new file mode 100644
index 0000000..d307ff1
--- /dev/null
+++ b/src/conv/svg/vsd2svg.cpp
@@ -0,0 +1,91 @@
+/* libvisio
+ * Copyright (C) 2006 Ariya Hidayat (ariya@kde.org)
+ * Copyright (C) 2005 Fridrich Strba (fridrich.strba@bluewin.ch)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * For further information visit http://libvisio.sourceforge.net
+ */
+
+/* "This product is not manufactured, approved, or supported by
+ * Corel Corporation or Corel Corporation Limited."
+ */
+
+#include <iostream>
+#include <sstream>
+#include <stdio.h>
+#include <string.h>
+#include "libvisio.h"
+#include <libwpd-stream/libwpd-stream.h>
+#include <libwpd/libwpd.h>
+
+namespace {
+
+int printUsage()
+{
+ printf("Usage: vsd2svg [OPTION] <WordPerfect Graphics File>\n");
+ printf("\n");
+ printf("Options:\n");
+ printf("--help Shows this help message\n");
+ printf("--version Output vsd2svg version \n");
+ return -1;
+}
+
+int printVersion()
+{
+ printf("vsd2svg %s\n", LIBVISIO_VERSION_STRING);
+ return 0;
+}
+
+} // anonymous namespace
+
+int main(int argc, char *argv[])
+{
+ if (argc < 2)
+ return printUsage();
+
+ char *file = 0;
+
+ for (int i = 1; i < argc; i++)
+ {
+ if (!strcmp(argv[i], "--version"))
+ return printVersion();
+ else if (!file && strncmp(argv[i], "--", 2))
+ file = argv[i];
+ else
+ return printUsage();
+ }
+
+ if (!file)
+ return printUsage();
+
+ WPXFileStream input(file);
+
+ if (!libvisio::WPGraphics::isSupported(&input))
+ {
+ std::cerr << "ERROR: Unsupported file format (unsupported version) or file is encrypted!" << std::endl;
+ return 1;
+ }
+
+ ::WPXString output;
+ if (!libvisio::WPGraphics::generateSVG(&input, output))
+ {
+ std::cerr << "ERROR: SVG Generation failed!" << std::endl;
+ return 1;
+ }
+
+ std::cout << output.cstr() << std::endl;
+ return 0;
+}
diff --git a/src/conv/svg/vsd2svg.rc.in b/src/conv/svg/vsd2svg.rc.in
new file mode 100644
index 0000000..1ee5f20
--- /dev/null
+++ b/src/conv/svg/vsd2svg.rc.in
@@ -0,0 +1,31 @@
+#include <winver.h>
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @WPG_MAJOR_VERSION@,@WPG_MINOR_VERSION@,@WPG_MICRO_VERSION@,BUILDNUMBER
+ PRODUCTVERSION @WPG_MAJOR_VERSION@,@WPG_MINOR_VERSION@,@WPG_MICRO_VERSION@,0
+ FILEFLAGSMASK 0
+ FILEFLAGS 0
+ FILEOS VOS__WINDOWS32
+ FILETYPE VFT_APP
+ FILESUBTYPE VFT2_UNKNOWN
+ BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", "The libvisio developer community"
+ VALUE "FileDescription", "vsd2svg"
+ VALUE "FileVersion", "@WPG_MAJOR_VERSION@.@WPG_MINOR_VERSION@.@WPG_MICRO_VERSION@.BUILDNUMBER"
+ VALUE "InternalName", "vsd2svg"
+ VALUE "LegalCopyright", "Copyright (C) 2004 Marc Oude Kotte, other contributers"
+ VALUE "OriginalFilename", "vsd2svg.exe"
+ VALUE "ProductName", "libvisio"
+ VALUE "ProductVersion", "@WPG_MAJOR_VERSION@.@WPG_MINOR_VERSION@.@WPG_MICRO_VERSION@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+ END
+