Merge lp:~inkscape.dev/inkscape/lp1015572 into lp:~inkscape.dev/inkscape/trunk

Proposed by Ted Gould
Status: Merged
Approved by: jazzynico
Approved revision: 11535
Merged at revision: 11688
Proposed branch: lp:~inkscape.dev/inkscape/lp1015572
Merge into: lp:~inkscape.dev/inkscape/trunk
Diff against target: 453 lines (+378/-0)
6 files modified
configure.ac (+22/-0)
src/Makefile.am (+2/-0)
src/extension/init.cpp (+6/-0)
src/extension/internal/Makefile_insert (+5/-0)
src/extension/internal/vsd-input.cpp (+289/-0)
src/extension/internal/vsd-input.h (+54/-0)
To merge this branch: bzr merge lp:~inkscape.dev/inkscape/lp1015572
Reviewer Review Type Date Requested Status
jazzynico (community) Approve
su_v (community) Approve
Review via email: mp+114040@code.launchpad.net

Description of the change

Imported the patch from the bug so that diffs can be autogenerated.

To post a comment you must log in.
Revision history for this message
su_v (suv-lp) wrote :

AFAICT the proposed branch misses the two files which are added by the patch:
  src/extension/internal/vsd-input.cpp
  src/extension/internal/vsd-input.h

review: Needs Fixing
lp:~inkscape.dev/inkscape/lp1015572 updated
11535. By Fridrich

Added Visio Files

Revision history for this message
Ted Gould (ted) wrote :

On Mon, 2012-07-09 at 21:29 +0000, ~suv wrote:
> AFAICT the proposed branch misses the two files which are added by the patch:
> src/extension/internal/vsd-input.cpp
> src/extension/internal/vsd-input.h

Uhg, sorry. Fixed.

Revision history for this message
su_v (suv-lp) :
review: Approve
Revision history for this message
jazzynico (jazzynico) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'configure.ac'
--- configure.ac 2012-07-05 21:39:08 +0000
+++ configure.ac 2012-07-09 21:33:25 +0000
@@ -666,6 +666,27 @@
666AM_CONDITIONAL(WITH_LIBWPG02, test "x$with_libwpg02" = "xyes")666AM_CONDITIONAL(WITH_LIBWPG02, test "x$with_libwpg02" = "xyes")
667AM_CONDITIONAL(WITH_LIBWPG, test "x$with_libwpg" = "xyes")667AM_CONDITIONAL(WITH_LIBWPG, test "x$with_libwpg" = "xyes")
668668
669dnl ********************************
670dnl Check for libvisio for extension
671dnl ********************************
672
673AC_ARG_ENABLE(wpg,
674 [ --disable-visio compile without support for Microsoft Visio Diagrams],
675 enable_visio=$enableval,enable_visio=yes)
676
677with_libvisio=no
678
679if test "x$enable_visio" = "xyes"; then
680 PKG_CHECK_MODULES(LIBVISIO, libvisio-0.0 >= 0.0.15 libwpd-0.9 libwpd-stream-0.9 libwpg-0.2, with_libvisio=yes, with_libvisio=no)
681
682 if test "x$with_libvisio" = "xyes"; then
683 AC_DEFINE(WITH_LIBVISIO,1,[Build in libvisio])
684 fi
685fi
686AC_SUBST(LIBVISIO_LIBS)
687AC_SUBST(LIBVISIO_CFLAGS)
688AM_CONDITIONAL(WITH_LIBVISIO, test "x$with_libvisio" = "xyes")
689
669dnl ******************************690dnl ******************************
670dnl Support doing a local install691dnl Support doing a local install
671dnl (mostly for distcheck)692dnl (mostly for distcheck)
@@ -1125,6 +1146,7 @@
1125 Enable Poppler-Cairo: ${enable_poppler_cairo}1146 Enable Poppler-Cairo: ${enable_poppler_cairo}
1126 ImageMagick Magick++: ${magick_ok}1147 ImageMagick Magick++: ${magick_ok}
1127 Libwpg: ${with_libwpg}1148 Libwpg: ${with_libwpg}
1149 Libvisio: ${with_libvisio}
1128 Doing Local Install: ${with_localinstall}1150 Doing Local Install: ${with_localinstall}
1129 GTK+ backend target: ${gtk_backend_target}1151 GTK+ backend target: ${gtk_backend_target}
1130"1152"
11311153
=== modified file 'src/Makefile.am'
--- src/Makefile.am 2012-04-14 13:50:00 +0000
+++ src/Makefile.am 2012-07-09 21:33:25 +0000
@@ -51,6 +51,7 @@
51 $(PYTHON_LIBS) \51 $(PYTHON_LIBS) \
52 $(INKBOARD_LIBS) \52 $(INKBOARD_LIBS) \
53 $(LIBWPG_LIBS) \53 $(LIBWPG_LIBS) \
54 $(LIBVISIO_LIBS) \
54 $(DBUS_LIBS) \55 $(DBUS_LIBS) \
55 $(GDL_LIBS) \56 $(GDL_LIBS) \
56 $(IMAGEMAGICK_LIBS)57 $(IMAGEMAGICK_LIBS)
@@ -74,6 +75,7 @@
74 $(IMAGEMAGICK_CFLAGS) \75 $(IMAGEMAGICK_CFLAGS) \
75 $(INKBOARD_CFLAGS) \76 $(INKBOARD_CFLAGS) \
76 $(LIBWPG_CFLAGS) \77 $(LIBWPG_CFLAGS) \
78 $(LIBVISIO_CFLAGS) \
77 $(DBUS_CFLAGS) \79 $(DBUS_CFLAGS) \
78 $(GDL_CFLAGS) \80 $(GDL_CFLAGS) \
79 $(XFT_CFLAGS) \81 $(XFT_CFLAGS) \
8082
=== modified file 'src/extension/init.cpp'
--- src/extension/init.cpp 2012-02-25 18:49:04 +0000
+++ src/extension/init.cpp 2012-07-09 21:33:25 +0000
@@ -53,6 +53,9 @@
53#ifdef WITH_LIBWPG53#ifdef WITH_LIBWPG
54#include "internal/wpg-input.h"54#include "internal/wpg-input.h"
55#endif55#endif
56#ifdef WITH_LIBVISIO
57#include "internal/vsd-input.h"
58#endif
56#include "preferences.h"59#include "preferences.h"
57#include "io/sys.h"60#include "io/sys.h"
58#ifdef WITH_DBUS61#ifdef WITH_DBUS
@@ -183,6 +186,9 @@
183#ifdef WITH_LIBWPG186#ifdef WITH_LIBWPG
184 Internal::WpgInput::init();187 Internal::WpgInput::init();
185#endif188#endif
189#ifdef WITH_LIBVISIO
190 Internal::VsdInput::init();
191#endif
186192
187 /* Effects */193 /* Effects */
188 Internal::BlurEdge::init();194 Internal::BlurEdge::init();
189195
=== 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-07-09 21:33:25 +0000
@@ -4,7 +4,12 @@
4ink_common_sources += \4ink_common_sources += \
5 extension/internal/wpg-input.cpp \5 extension/internal/wpg-input.cpp \
6 extension/internal/wpg-input.h6 extension/internal/wpg-input.h
7endif
78
9if WITH_LIBVISIO
10ink_common_sources += \
11 extension/internal/vsd-input.cpp \
12 extension/internal/vsd-input.h
8endif13endif
914
10if USE_IMAGE_MAGICK15if USE_IMAGE_MAGICK
1116
=== 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-07-09 21:33:25 +0000
@@ -0,0 +1,289 @@
1/*
2 * This file came from libwpg as a source, their utility wpg2svg
3 * specifically. It has been modified to work as an Inkscape extension.
4 * The Inkscape extension code is covered by this copyright, but the
5 * rest is covered by the one bellow.
6 *
7 * Authors:
8 * Fridrich Strba (fridrich.strba@bluewin.ch)
9 *
10 * Copyright (C) 2012 Authors
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 *
14 */
15
16#include <stdio.h>
17#include "config.h"
18
19#include "vsd-input.h"
20
21#ifdef WITH_LIBVISIO
22
23#include <string>
24#include <cstring>
25
26#include <libvisio/libvisio.h>
27#include <libwpd-stream/libwpd-stream.h>
28
29#include <gtkmm/alignment.h>
30#include <gtkmm/comboboxtext.h>
31#include <gtkmm/drawingarea.h>
32#include <gtkmm/frame.h>
33#include <gtkmm/scale.h>
34
35#include "extension/system.h"
36#include "extension/input.h"
37#include "document.h"
38
39#include "document-private.h"
40#include "document-undo.h"
41#include "inkscape.h"
42
43#include "dialogs/dialog-events.h"
44#include <gtk/gtk.h>
45#include "ui/widget/spinbutton.h"
46#include "ui/widget/frame.h"
47#include <glibmm/i18n.h>
48
49#include <gdkmm/general.h>
50
51#include "svg-view.h"
52#include "svg-view-widget.h"
53
54namespace Inkscape {
55namespace Extension {
56namespace Internal {
57
58
59class VsdImportDialog : public Gtk::Dialog {
60public:
61 VsdImportDialog(const std::vector<WPXString> &vec);
62 virtual ~VsdImportDialog();
63
64 bool showDialog();
65 unsigned getSelectedPage();
66 void getImportSettings(Inkscape::XML::Node *prefs);
67
68private:
69 void _setPreviewPage(unsigned page);
70
71 // Signal handlers
72#if !WITH_GTKMM_3_0
73 bool _onExposePreview(GdkEventExpose *event);
74#endif
75
76 void _onPageNumberChanged();
77
78 class Gtk::Button * cancelbutton;
79 class Gtk::Button * okbutton;
80 class Gtk::Label * _labelSelect;
81 class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
82 class Gtk::Label * _labelTotalPages;
83 class Gtk::VBox * vbox1;
84 class Gtk::VBox * vbox2;
85 class Gtk::Widget * _previewArea;
86
87 const std::vector<WPXString> &_vec; // Document to be imported
88 unsigned _current_page; // Current selected page
89 int _preview_width, _preview_height; // Size of the preview area
90};
91
92VsdImportDialog::VsdImportDialog(const std::vector<WPXString> &vec)
93 : _vec(vec), _current_page(1)
94{
95 int num_pages = _vec.size();
96 if ( num_pages <= 1 )
97 return;
98 cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
99 okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
100 _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
101
102 // Page number
103#if WITH_GTKMM_3_0
104 Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
105 _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
106#else
107 Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
108 new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
109 _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
110#endif
111 _labelTotalPages = Gtk::manage(new class Gtk::Label());
112 gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
113 _labelTotalPages->set_label(label_text);
114 g_free(label_text);
115
116 vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
117 SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
118 _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
119
120 vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
121 cancelbutton->set_can_focus();
122 cancelbutton->set_can_default();
123 cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
124 okbutton->set_can_focus();
125 okbutton->set_can_default();
126 okbutton->set_relief(Gtk::RELIEF_NORMAL);
127 this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
128 _labelSelect->set_line_wrap(false);
129 _labelSelect->set_use_markup(false);
130 _labelSelect->set_selectable(false);
131 _pageNumberSpin->set_can_focus();
132 _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
133 _pageNumberSpin->set_numeric(true);
134 _pageNumberSpin->set_digits(0);
135 _pageNumberSpin->set_wrap(false);
136 _labelTotalPages->set_line_wrap(false);
137 _labelTotalPages->set_use_markup(false);
138 _labelTotalPages->set_selectable(false);
139 vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
140 this->get_vbox()->set_homogeneous(false);
141 this->get_vbox()->set_spacing(0);
142 this->get_vbox()->pack_start(*vbox2);
143 this->set_title(_("Page Selector"));
144 this->set_modal(true);
145 sp_transientize((GtkWidget *)this->gobj()); //Make transient
146 this->property_window_position().set_value(Gtk::WIN_POS_NONE);
147 this->set_resizable(true);
148 this->property_destroy_with_parent().set_value(false);
149 this->get_action_area()->add(*_labelSelect);
150 this->add_action_widget(*_pageNumberSpin, -7);
151 this->get_action_area()->add(*_labelTotalPages);
152 this->add_action_widget(*cancelbutton, -6);
153 this->add_action_widget(*okbutton, -5);
154 cancelbutton->show();
155 okbutton->show();
156 _labelSelect->show();
157 _pageNumberSpin->show();
158 _labelTotalPages->show();
159 vbox1->show();
160 _previewArea->show();
161 vbox2->show();
162
163 // Connect signals
164 _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
165}
166
167VsdImportDialog::~VsdImportDialog() {}
168
169bool VsdImportDialog::showDialog()
170{
171 show();
172 gint b = run();
173 hide();
174 if ( b == Gtk::RESPONSE_OK ) {
175 return TRUE;
176 } else {
177 return FALSE;
178 }
179}
180
181unsigned VsdImportDialog::getSelectedPage()
182{
183 return _current_page;
184}
185
186void VsdImportDialog::_onPageNumberChanged()
187{
188 int page = _pageNumberSpin->get_value_as_int();
189 _current_page = CLAMP(page, 1, _vec.size());
190 _setPreviewPage(_current_page);
191}
192
193/**
194 * \brief Renders the given page's thumbnail
195 */
196void VsdImportDialog::_setPreviewPage(unsigned page)
197{
198 SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
199 Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
200 std::swap(_previewArea, tmpPreviewArea);
201 if (tmpPreviewArea) {
202 _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
203 delete tmpPreviewArea;
204 }
205 vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
206 _previewArea->show_now();
207}
208
209SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri)
210{
211 WPXFileStream input(uri);
212
213 if (!libvisio::VisioDocument::isSupported(&input)) {
214 return NULL;
215 }
216
217 libvisio::VSDStringVector output;
218 if (!libvisio::VisioDocument::generateSVG(&input, output)) {
219 return NULL;
220 }
221
222 if (output.empty()) {
223 return NULL;
224 }
225
226 std::vector<WPXString> tmpSVGOutput;
227 for (unsigned i=0; i<output.size(); ++i) {
228 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");
229 tmpString.append(output[i]);
230 tmpSVGOutput.push_back(tmpString);
231 }
232
233 unsigned page_num = 1;
234
235 // If only one page is present, import that one without bothering user
236 if (tmpSVGOutput.size() > 1) {
237 VsdImportDialog *dlg = 0;
238 if (inkscape_use_gui()) {
239 dlg = new VsdImportDialog(tmpSVGOutput);
240 if (!dlg->showDialog()) {
241 delete dlg;
242 return NULL;
243 }
244 }
245
246 // Get needed page
247 if (dlg) {
248 page_num = dlg->getSelectedPage();
249 if (page_num < 1)
250 page_num = 1;
251 if (page_num > tmpSVGOutput.size())
252 page_num = tmpSVGOutput.size();
253 }
254 }
255
256 SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
257 return doc;
258}
259
260#include "clear-n_.h"
261
262void VsdInput::init(void)
263{
264 Inkscape::Extension::build_from_mem(
265 "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
266 "<name>" N_("VSD Input") "</name>\n"
267 "<id>org.inkscape.input.vsd</id>\n"
268 "<input>\n"
269 "<extension>.vsd</extension>\n"
270 "<mimetype>application/vnd.visio</mimetype>\n"
271 "<filetypename>" N_("Microsoft Visio Diagram (*.vsd)") "</filetypename>\n"
272 "<filetypetooltip>" N_("File format used by Microsoft Visio 6 and later") "</filetypetooltip>\n"
273 "</input>\n"
274 "</inkscape-extension>", new VsdInput());
275} // init
276
277} } } /* namespace Inkscape, Extension, Implementation */
278#endif /* WITH_LIBVISIO */
279
280/*
281 Local Variables:
282 mode:c++
283 c-file-style:"stroustrup"
284 c-file-offsets:((innamespace . 0)(inline-open . 0))
285 indent-tabs-mode:nil
286 fill-column:99
287 End:
288*/
289// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
0290
=== 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-07-09 21:33:25 +0000
@@ -0,0 +1,54 @@
1/*
2 * This code abstracts the libwpg interfaces into the Inkscape
3 * input extension interface.
4 *
5 * Authors:
6 * Fridrich Strba (fridrich.strba@bluewin.ch)
7 *
8 * Copyright (C) 2012 Authors
9 *
10 * Released under GNU GPL, read the file 'COPYING' for more information
11 */
12
13#ifndef __EXTENSION_INTERNAL_VSDOUTPUT_H__
14#define __EXTENSION_INTERNAL_VSDOUTPUT_H__
15
16#ifdef HAVE_CONFIG_H
17# include <config.h>
18#endif
19
20#ifdef WITH_LIBVISIO
21
22#include <gtkmm/dialog.h>
23
24#include "../implementation/implementation.h"
25
26namespace Inkscape {
27namespace Extension {
28namespace Internal {
29
30class VsdInput : public Inkscape::Extension::Implementation::Implementation {
31 VsdInput () { };
32public:
33 SPDocument *open( Inkscape::Extension::Input *mod,
34 const gchar *uri );
35 static void init( void );
36
37};
38
39} } } /* namespace Inkscape, Extension, Implementation */
40
41#endif /* WITH_LIBVISIO */
42#endif /* __EXTENSION_INTERNAL_VSDOUTPUT_H__ */
43
44
45/*
46 Local Variables:
47 mode:c++
48 c-file-style:"stroustrup"
49 c-file-offsets:((innamespace . 0)(inline-open . 0))
50 indent-tabs-mode:nil
51 fill-column:99
52 End:
53*/
54// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :