Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- === modified file 'configure.ac'
- --- configure.ac 2012-06-12 16:12:48 +0000
- +++ configure.ac 2012-06-19 17:13:40 +0000
- @@ -660,6 +660,27 @@
- AM_CONDITIONAL(WITH_LIBWPG02, test "x$with_libwpg02" = "xyes")
- AM_CONDITIONAL(WITH_LIBWPG, test "x$with_libwpg" = "xyes")
- +dnl ********************************
- +dnl Check for libvisio for extension
- +dnl ********************************
- +
- +AC_ARG_ENABLE(wpg,
- + [ --disable-visio compile without support for Microsoft Visio Diagrams],
- + enable_visio=$enableval,enable_visio=yes)
- +
- +with_libvisio=no
- +
- +if test "x$enable_visio" = "xyes"; then
- + PKG_CHECK_MODULES(LIBVISIO, libvisio-0.0 libwpd-0.9 libwpd-stream-0.9 libwpg-0.2, with_libvisio=yes, with_libvisio=no)
- +
- + if test "x$with_libvisio" = "xyes"; then
- + AC_DEFINE(WITH_LIBVISIO,1,[Build in libvisio])
- + fi
- +fi
- +AC_SUBST(LIBVISIO_LIBS)
- +AC_SUBST(LIBVISIO_CFLAGS)
- +AM_CONDITIONAL(WITH_LIBVISIO, test "x$with_libvisio" = "xyes")
- +
- dnl ******************************
- dnl Support doing a local install
- dnl (mostly for distcheck)
- @@ -1132,6 +1153,7 @@
- Enable Poppler-Cairo: ${enable_poppler_cairo}
- ImageMagick Magick++: ${magick_ok}
- Libwpg: ${with_libwpg}
- + Libvisio: ${with_libvisio}
- Doing Local Install: ${with_localinstall}
- GTK+ backend target: ${gtk_backend_target}
- "
- === modified file 'src/Makefile.am'
- --- src/Makefile.am 2012-04-14 13:50:00 +0000
- +++ src/Makefile.am 2012-06-15 15:47:36 +0000
- @@ -51,6 +51,7 @@
- $(PYTHON_LIBS) \
- $(INKBOARD_LIBS) \
- $(LIBWPG_LIBS) \
- + $(LIBVISIO_LIBS) \
- $(DBUS_LIBS) \
- $(GDL_LIBS) \
- $(IMAGEMAGICK_LIBS)
- @@ -74,6 +75,7 @@
- $(IMAGEMAGICK_CFLAGS) \
- $(INKBOARD_CFLAGS) \
- $(LIBWPG_CFLAGS) \
- + $(LIBVISIO_CFLAGS) \
- $(DBUS_CFLAGS) \
- $(GDL_CFLAGS) \
- $(XFT_CFLAGS) \
- === modified file 'src/extension/init.cpp'
- --- src/extension/init.cpp 2012-02-25 18:49:04 +0000
- +++ src/extension/init.cpp 2012-06-15 15:45:44 +0000
- @@ -53,6 +53,9 @@
- #ifdef WITH_LIBWPG
- #include "internal/wpg-input.h"
- #endif
- +#ifdef WITH_LIBVISIO
- +#include "internal/vsd-input.h"
- +#endif
- #include "preferences.h"
- #include "io/sys.h"
- #ifdef WITH_DBUS
- @@ -183,6 +186,9 @@
- #ifdef WITH_LIBWPG
- Internal::WpgInput::init();
- #endif
- +#ifdef WITH_LIBVISIO
- + Internal::VsdInput::init();
- +#endif
- /* Effects */
- Internal::BlurEdge::init();
- === modified file 'src/extension/internal/Makefile_insert'
- --- src/extension/internal/Makefile_insert 2011-08-18 21:29:26 +0000
- +++ src/extension/internal/Makefile_insert 2012-06-19 09:26:30 +0000
- @@ -4,7 +4,12 @@
- ink_common_sources += \
- extension/internal/wpg-input.cpp \
- extension/internal/wpg-input.h
- +endif
- +if WITH_LIBVISIO
- +ink_common_sources += \
- + extension/internal/vsd-input.cpp \
- + extension/internal/vsd-input.h
- endif
- if USE_IMAGE_MAGICK
- === added file 'src/extension/internal/vsd-input.cpp'
- --- src/extension/internal/vsd-input.cpp 1970-01-01 00:00:00 +0000
- +++ src/extension/internal/vsd-input.cpp 2012-06-19 17:02:27 +0000
- @@ -0,0 +1,337 @@
- +/*
- + * 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:
- + * Fridrich Strba (fridrich.strba@bluewin.ch)
- + *
- + * Copyright (C) 2012 Authors
- + *
- + * Released under GNU GPL, read the file 'COPYING' for more information
- + *
- + */
- +
- +#include <stdio.h>
- +#include "config.h"
- +
- +#include "vsd-input.h"
- +
- +#ifdef WITH_LIBVISIO
- +
- +#include <string>
- +#include <cstring>
- +
- +#include <libvisio/libvisio.h>
- +#include <libwpd-stream/libwpd-stream.h>
- +
- +#include <gtkmm/alignment.h>
- +#include <gtkmm/comboboxtext.h>
- +#include <gtkmm/drawingarea.h>
- +#include <gtkmm/frame.h>
- +#include <gtkmm/scale.h>
- +
- +#include "extension/system.h"
- +#include "extension/input.h"
- +#include "document.h"
- +
- +#include "document-private.h"
- +#include "document-undo.h"
- +#include "inkscape.h"
- +
- +#include "dialogs/dialog-events.h"
- +#include <gtk/gtk.h>
- +#include "ui/widget/spinbutton.h"
- +#include "ui/widget/frame.h"
- +#include <glibmm/i18n.h>
- +
- +#include <gdkmm/general.h>
- +
- +#include "svg-view.h"
- +#include "svg-view-widget.h"
- +
- +namespace Inkscape {
- +namespace Extension {
- +namespace Internal {
- +
- +
- +class VsdImportDialog : public Gtk::Dialog {
- +public:
- + VsdImportDialog(const std::vector<WPXString> &vec);
- + virtual ~VsdImportDialog();
- +
- + bool showDialog();
- + unsigned getSelectedPage();
- + void getImportSettings(Inkscape::XML::Node *prefs);
- +
- +private:
- + void _setPreviewPage(unsigned page);
- +
- + // Signal handlers
- +#if !WITH_GTKMM_3_0
- + bool _onExposePreview(GdkEventExpose *event);
- +#endif
- +
- + bool _onDraw(const Cairo::RefPtr<Cairo::Context>& cr);
- + void _onPageNumberChanged();
- + void _onToggleCropping();
- + void _onPrecisionChanged();
- +
- + class Gtk::Button * cancelbutton;
- + class Gtk::Button * okbutton;
- + class Gtk::Label * _labelSelect;
- + class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
- + class Gtk::Label * _labelTotalPages;
- + class Gtk::HBox * hbox2;
- + class Gtk::VBox * vbox2;
- + class Inkscape::UI::Widget::Frame * _pageSettingsFrame;
- + class Gtk::VBox * vbox1;
- + class Gtk::Widget * _previewArea;
- + class Gtk::HBox * hbox1;
- +
- + const std::vector<WPXString> &_vec; // Document to be imported
- + unsigned _current_page; // Current selected page
- + int _preview_width, _preview_height; // Size of the preview area
- +};
- +
- +VsdImportDialog::VsdImportDialog(const std::vector<WPXString> &vec)
- + : _vec(vec), _current_page(1)
- +{
- + cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
- + okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
- + _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
- +
- + // Page number
- +#if WITH_GTKMM_3_0
- + Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
- + _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
- +#else
- + Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
- + new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
- + _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
- +#endif
- + _labelTotalPages = Gtk::manage(new class Gtk::Label());
- + hbox2 = Gtk::manage(new class Gtk::HBox(false, 0));
- + // Disable the page selector when there's only one page
- + int num_pages = _vec.size();
- + if ( num_pages == 1 ) {
- + _pageNumberSpin->set_sensitive(false);
- + } else {
- + // Display total number of pages
- + gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
- + _labelTotalPages->set_label(label_text);
- + g_free(label_text);
- + }
- +
- + vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
- + _pageSettingsFrame = Gtk::manage(new class Inkscape::UI::Widget::Frame());
- +
- + vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
- + SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
- + _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
- +
- + hbox1 = Gtk::manage(new class Gtk::HBox(false, 4));
- + cancelbutton->set_can_focus();
- + cancelbutton->set_can_default();
- + cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
- + okbutton->set_can_focus();
- + okbutton->set_can_default();
- + okbutton->set_relief(Gtk::RELIEF_NORMAL);
- + this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
- + _labelSelect->set_alignment(0.5,0.5);
- + _labelSelect->set_padding(4,0);
- + _labelSelect->set_justify(Gtk::JUSTIFY_LEFT);
- + _labelSelect->set_line_wrap(false);
- + _labelSelect->set_use_markup(false);
- + _labelSelect->set_selectable(false);
- + _pageNumberSpin->set_can_focus();
- + _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
- + _pageNumberSpin->set_numeric(true);
- + _pageNumberSpin->set_digits(0);
- + _pageNumberSpin->set_wrap(false);
- + _labelTotalPages->set_alignment(0.5,0.5);
- + _labelTotalPages->set_padding(4,0);
- + _labelTotalPages->set_justify(Gtk::JUSTIFY_LEFT);
- + _labelTotalPages->set_line_wrap(false);
- + _labelTotalPages->set_use_markup(false);
- + _labelTotalPages->set_selectable(false);
- + hbox2->pack_start(*_labelSelect, Gtk::PACK_SHRINK, 4);
- + hbox2->pack_start(*_pageNumberSpin, Gtk::PACK_SHRINK, 4);
- + hbox2->pack_start(*_labelTotalPages, Gtk::PACK_SHRINK, 4);
- + vbox2->pack_start(*hbox2);
- + _pageSettingsFrame->add(*vbox2);
- + _pageSettingsFrame->set_border_width(4);
- + vbox1->pack_start(*_pageSettingsFrame, Gtk::PACK_SHRINK, 0);
- + hbox1->pack_start(*vbox1, Gtk::PACK_EXPAND_PADDING, 0);
- + hbox1->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
- + this->get_vbox()->set_homogeneous(false);
- + this->get_vbox()->set_spacing(0);
- + this->get_vbox()->pack_start(*hbox1);
- + this->set_title(_("Page Selector"));
- + this->set_modal(true);
- + sp_transientize((GtkWidget *)this->gobj()); //Make transient
- + this->property_window_position().set_value(Gtk::WIN_POS_NONE);
- + this->set_resizable(true);
- + this->property_destroy_with_parent().set_value(false);
- + this->add_action_widget(*cancelbutton, -6);
- + this->add_action_widget(*okbutton, -5);
- + cancelbutton->show();
- + okbutton->show();
- + _labelSelect->show();
- + _pageNumberSpin->show();
- + _labelTotalPages->show();
- + hbox2->show();
- + vbox2->show();
- + _pageSettingsFrame->show();
- + vbox1->show();
- + _previewArea->show();
- + hbox1->show();
- +
- + // Connect signals
- + _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
- +}
- +
- +VsdImportDialog::~VsdImportDialog() {}
- +
- +bool VsdImportDialog::showDialog()
- +{
- + show();
- + gint b = run();
- + hide();
- + if ( b == Gtk::RESPONSE_OK ) {
- + return TRUE;
- + } else {
- + return FALSE;
- + }
- +}
- +
- +unsigned VsdImportDialog::getSelectedPage()
- +{
- + return _current_page;
- +}
- +
- +/**
- + * \brief Retrieves the current settings into a repr which SvgBuilder will use
- + * for determining the behaviour desired by the user
- + */
- +void VsdImportDialog::getImportSettings(Inkscape::XML::Node *prefs)
- +{
- +}
- +
- +/**
- + * \brief Redisplay the comment on the current approximation precision setting
- + * Evenly divides the interval of possible values between the available labels.
- + */
- +void VsdImportDialog::_onPrecisionChanged()
- +{
- +}
- +
- +void VsdImportDialog::_onToggleCropping()
- +{
- +}
- +
- +void VsdImportDialog::_onPageNumberChanged()
- +{
- + int page = _pageNumberSpin->get_value_as_int();
- + _current_page = CLAMP(page, 1, _vec.size());
- + _setPreviewPage(_current_page);
- +}
- +
- +/**
- + * \brief Renders the given page's thumbnail
- + */
- +void VsdImportDialog::_setPreviewPage(unsigned page)
- +{
- + SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
- + Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
- + std::swap(_previewArea, tmpPreviewArea);
- + if (tmpPreviewArea) {
- + _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
- + delete tmpPreviewArea;
- + }
- + hbox1->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
- + _previewArea->show_now();
- +}
- +
- +SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri)
- +{
- + WPXFileStream input(uri);
- +
- + if (!libvisio::VisioDocument::isSupported(&input)) {
- + return NULL;
- + }
- +
- + libvisio::VSDStringVector output;
- + if (!libvisio::VisioDocument::generateSVG(&input, output)) {
- + return NULL;
- + }
- +
- + if (output.empty()) {
- + return NULL;
- + }
- +
- + std::vector<WPXString> tmpSVGOutput;
- + for (unsigned i=0; i<output.size(); ++i) {
- + WPXString tmpString("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
- + tmpString.append(output[i]);
- + tmpSVGOutput.push_back(tmpString);
- + }
- +
- + unsigned page_num = 1;
- +
- + // If only one page is present, import that one without bothering user
- + if (tmpSVGOutput.size() > 1) {
- + VsdImportDialog *dlg = 0;
- + if (inkscape_use_gui()) {
- + dlg = new VsdImportDialog(tmpSVGOutput);
- + if (!dlg->showDialog()) {
- + delete dlg;
- + return NULL;
- + }
- + }
- +
- + // Get needed page
- + if (dlg) {
- + page_num = dlg->getSelectedPage();
- + if (page_num < 1)
- + page_num = 1;
- + if (page_num > tmpSVGOutput.size())
- + page_num = tmpSVGOutput.size();
- + }
- + }
- +
- + SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
- + return doc;
- +}
- +
- +#include "clear-n_.h"
- +
- +void VsdInput::init(void)
- +{
- + Inkscape::Extension::build_from_mem(
- + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- + "<name>" N_("VSD Input") "</name>\n"
- + "<id>org.inkscape.input.vsd</id>\n"
- + "<input>\n"
- + "<extension>.vsd</extension>\n"
- + "<mimetype>application/vnd.visio</mimetype>\n"
- + "<filetypename>" N_("Microsoft Visio Diagram (*.vsd)") "</filetypename>\n"
- + "<filetypetooltip>" N_("File format used by Microsoft Visio 6 and later") "</filetypetooltip>\n"
- + "</input>\n"
- + "</inkscape-extension>", new VsdInput());
- +} // init
- +
- +} } } /* namespace Inkscape, Extension, Implementation */
- +#endif /* WITH_LIBVISIO */
- +
- +/*
- + 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 :
- === added file 'src/extension/internal/vsd-input.h'
- --- src/extension/internal/vsd-input.h 1970-01-01 00:00:00 +0000
- +++ src/extension/internal/vsd-input.h 2012-06-19 16:54:25 +0000
- @@ -0,0 +1,54 @@
- +/*
- + * This code abstracts the libwpg interfaces into the Inkscape
- + * input extension interface.
- + *
- + * Authors:
- + * Fridrich Strba (fridrich.strba@bluewin.ch)
- + *
- + * Copyright (C) 2012 Authors
- + *
- + * Released under GNU GPL, read the file 'COPYING' for more information
- + */
- +
- +#ifndef __EXTENSION_INTERNAL_VSDOUTPUT_H__
- +#define __EXTENSION_INTERNAL_VSDOUTPUT_H__
- +
- +#ifdef HAVE_CONFIG_H
- +# include <config.h>
- +#endif
- +
- +#ifdef WITH_LIBVISIO
- +
- +#include <gtkmm/dialog.h>
- +
- +#include "../implementation/implementation.h"
- +
- +namespace Inkscape {
- +namespace Extension {
- +namespace Internal {
- +
- +class VsdInput : public Inkscape::Extension::Implementation::Implementation {
- + VsdInput () { };
- +public:
- + SPDocument *open( Inkscape::Extension::Input *mod,
- + const gchar *uri );
- + static void init( void );
- +
- +};
- +
- +} } } /* namespace Inkscape, Extension, Implementation */
- +
- +#endif /* WITH_LIBVISIO */
- +#endif /* __EXTENSION_INTERNAL_VSDOUTPUT_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 :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement