From 8044020060a805250b1cb764bee140461bbb6eb8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 31 Jul 2006 05:14:59 +0000 Subject: r13108@tres: ted | 2006-07-30 12:27:51 -0700 Builds and links. Doesn't work, but builds and links. (bzr r1525) --- src/extension/internal/wpg-input.cpp | 112 +++++++++++++++++++++++++---------- 1 file changed, 80 insertions(+), 32 deletions(-) (limited to 'src/extension/internal/wpg-input.cpp') 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 + * + * 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 +#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("\n"); - printf("\n", LIBWPG_VERSION_STRING); +// printf("\n", LIBWPG_VERSION_STRING); printf("\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( + "\n" + "" N_("WPG Input") "\n" + "org.inkscape.input.wpg\n" + "\n" + "", 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 : -- cgit v1.2.3