Merge lp:~inkscape.dev/inkscape/lp1015572 into lp:~inkscape.dev/inkscape/trunk
- lp1015572
- Merge into 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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
jazzynico (community) | Approve | ||
su_v (community) | Approve | ||
Review via email: mp+114040@code.launchpad.net |
Commit message
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
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/
> src/extension/
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
1 | === modified file 'configure.ac' |
2 | --- configure.ac 2012-07-05 21:39:08 +0000 |
3 | +++ configure.ac 2012-07-09 21:33:25 +0000 |
4 | @@ -666,6 +666,27 @@ |
5 | AM_CONDITIONAL(WITH_LIBWPG02, test "x$with_libwpg02" = "xyes") |
6 | AM_CONDITIONAL(WITH_LIBWPG, test "x$with_libwpg" = "xyes") |
7 | |
8 | +dnl ******************************** |
9 | +dnl Check for libvisio for extension |
10 | +dnl ******************************** |
11 | + |
12 | +AC_ARG_ENABLE(wpg, |
13 | + [ --disable-visio compile without support for Microsoft Visio Diagrams], |
14 | + enable_visio=$enableval,enable_visio=yes) |
15 | + |
16 | +with_libvisio=no |
17 | + |
18 | +if test "x$enable_visio" = "xyes"; then |
19 | + 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) |
20 | + |
21 | + if test "x$with_libvisio" = "xyes"; then |
22 | + AC_DEFINE(WITH_LIBVISIO,1,[Build in libvisio]) |
23 | + fi |
24 | +fi |
25 | +AC_SUBST(LIBVISIO_LIBS) |
26 | +AC_SUBST(LIBVISIO_CFLAGS) |
27 | +AM_CONDITIONAL(WITH_LIBVISIO, test "x$with_libvisio" = "xyes") |
28 | + |
29 | dnl ****************************** |
30 | dnl Support doing a local install |
31 | dnl (mostly for distcheck) |
32 | @@ -1125,6 +1146,7 @@ |
33 | Enable Poppler-Cairo: ${enable_poppler_cairo} |
34 | ImageMagick Magick++: ${magick_ok} |
35 | Libwpg: ${with_libwpg} |
36 | + Libvisio: ${with_libvisio} |
37 | Doing Local Install: ${with_localinstall} |
38 | GTK+ backend target: ${gtk_backend_target} |
39 | " |
40 | |
41 | === modified file 'src/Makefile.am' |
42 | --- src/Makefile.am 2012-04-14 13:50:00 +0000 |
43 | +++ src/Makefile.am 2012-07-09 21:33:25 +0000 |
44 | @@ -51,6 +51,7 @@ |
45 | $(PYTHON_LIBS) \ |
46 | $(INKBOARD_LIBS) \ |
47 | $(LIBWPG_LIBS) \ |
48 | + $(LIBVISIO_LIBS) \ |
49 | $(DBUS_LIBS) \ |
50 | $(GDL_LIBS) \ |
51 | $(IMAGEMAGICK_LIBS) |
52 | @@ -74,6 +75,7 @@ |
53 | $(IMAGEMAGICK_CFLAGS) \ |
54 | $(INKBOARD_CFLAGS) \ |
55 | $(LIBWPG_CFLAGS) \ |
56 | + $(LIBVISIO_CFLAGS) \ |
57 | $(DBUS_CFLAGS) \ |
58 | $(GDL_CFLAGS) \ |
59 | $(XFT_CFLAGS) \ |
60 | |
61 | === modified file 'src/extension/init.cpp' |
62 | --- src/extension/init.cpp 2012-02-25 18:49:04 +0000 |
63 | +++ src/extension/init.cpp 2012-07-09 21:33:25 +0000 |
64 | @@ -53,6 +53,9 @@ |
65 | #ifdef WITH_LIBWPG |
66 | #include "internal/wpg-input.h" |
67 | #endif |
68 | +#ifdef WITH_LIBVISIO |
69 | +#include "internal/vsd-input.h" |
70 | +#endif |
71 | #include "preferences.h" |
72 | #include "io/sys.h" |
73 | #ifdef WITH_DBUS |
74 | @@ -183,6 +186,9 @@ |
75 | #ifdef WITH_LIBWPG |
76 | Internal::WpgInput::init(); |
77 | #endif |
78 | +#ifdef WITH_LIBVISIO |
79 | + Internal::VsdInput::init(); |
80 | +#endif |
81 | |
82 | /* Effects */ |
83 | Internal::BlurEdge::init(); |
84 | |
85 | === modified file 'src/extension/internal/Makefile_insert' |
86 | --- src/extension/internal/Makefile_insert 2011-08-18 21:29:26 +0000 |
87 | +++ src/extension/internal/Makefile_insert 2012-07-09 21:33:25 +0000 |
88 | @@ -4,7 +4,12 @@ |
89 | ink_common_sources += \ |
90 | extension/internal/wpg-input.cpp \ |
91 | extension/internal/wpg-input.h |
92 | +endif |
93 | |
94 | +if WITH_LIBVISIO |
95 | +ink_common_sources += \ |
96 | + extension/internal/vsd-input.cpp \ |
97 | + extension/internal/vsd-input.h |
98 | endif |
99 | |
100 | if USE_IMAGE_MAGICK |
101 | |
102 | === added file 'src/extension/internal/vsd-input.cpp' |
103 | --- src/extension/internal/vsd-input.cpp 1970-01-01 00:00:00 +0000 |
104 | +++ src/extension/internal/vsd-input.cpp 2012-07-09 21:33:25 +0000 |
105 | @@ -0,0 +1,289 @@ |
106 | +/* |
107 | + * This file came from libwpg as a source, their utility wpg2svg |
108 | + * specifically. It has been modified to work as an Inkscape extension. |
109 | + * The Inkscape extension code is covered by this copyright, but the |
110 | + * rest is covered by the one bellow. |
111 | + * |
112 | + * Authors: |
113 | + * Fridrich Strba (fridrich.strba@bluewin.ch) |
114 | + * |
115 | + * Copyright (C) 2012 Authors |
116 | + * |
117 | + * Released under GNU GPL, read the file 'COPYING' for more information |
118 | + * |
119 | + */ |
120 | + |
121 | +#include <stdio.h> |
122 | +#include "config.h" |
123 | + |
124 | +#include "vsd-input.h" |
125 | + |
126 | +#ifdef WITH_LIBVISIO |
127 | + |
128 | +#include <string> |
129 | +#include <cstring> |
130 | + |
131 | +#include <libvisio/libvisio.h> |
132 | +#include <libwpd-stream/libwpd-stream.h> |
133 | + |
134 | +#include <gtkmm/alignment.h> |
135 | +#include <gtkmm/comboboxtext.h> |
136 | +#include <gtkmm/drawingarea.h> |
137 | +#include <gtkmm/frame.h> |
138 | +#include <gtkmm/scale.h> |
139 | + |
140 | +#include "extension/system.h" |
141 | +#include "extension/input.h" |
142 | +#include "document.h" |
143 | + |
144 | +#include "document-private.h" |
145 | +#include "document-undo.h" |
146 | +#include "inkscape.h" |
147 | + |
148 | +#include "dialogs/dialog-events.h" |
149 | +#include <gtk/gtk.h> |
150 | +#include "ui/widget/spinbutton.h" |
151 | +#include "ui/widget/frame.h" |
152 | +#include <glibmm/i18n.h> |
153 | + |
154 | +#include <gdkmm/general.h> |
155 | + |
156 | +#include "svg-view.h" |
157 | +#include "svg-view-widget.h" |
158 | + |
159 | +namespace Inkscape { |
160 | +namespace Extension { |
161 | +namespace Internal { |
162 | + |
163 | + |
164 | +class VsdImportDialog : public Gtk::Dialog { |
165 | +public: |
166 | + VsdImportDialog(const std::vector<WPXString> &vec); |
167 | + virtual ~VsdImportDialog(); |
168 | + |
169 | + bool showDialog(); |
170 | + unsigned getSelectedPage(); |
171 | + void getImportSettings(Inkscape::XML::Node *prefs); |
172 | + |
173 | +private: |
174 | + void _setPreviewPage(unsigned page); |
175 | + |
176 | + // Signal handlers |
177 | +#if !WITH_GTKMM_3_0 |
178 | + bool _onExposePreview(GdkEventExpose *event); |
179 | +#endif |
180 | + |
181 | + void _onPageNumberChanged(); |
182 | + |
183 | + class Gtk::Button * cancelbutton; |
184 | + class Gtk::Button * okbutton; |
185 | + class Gtk::Label * _labelSelect; |
186 | + class Inkscape::UI::Widget::SpinButton * _pageNumberSpin; |
187 | + class Gtk::Label * _labelTotalPages; |
188 | + class Gtk::VBox * vbox1; |
189 | + class Gtk::VBox * vbox2; |
190 | + class Gtk::Widget * _previewArea; |
191 | + |
192 | + const std::vector<WPXString> &_vec; // Document to be imported |
193 | + unsigned _current_page; // Current selected page |
194 | + int _preview_width, _preview_height; // Size of the preview area |
195 | +}; |
196 | + |
197 | +VsdImportDialog::VsdImportDialog(const std::vector<WPXString> &vec) |
198 | + : _vec(vec), _current_page(1) |
199 | +{ |
200 | + int num_pages = _vec.size(); |
201 | + if ( num_pages <= 1 ) |
202 | + return; |
203 | + cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel"))); |
204 | + okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))); |
205 | + _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:"))); |
206 | + |
207 | + // Page number |
208 | +#if WITH_GTKMM_3_0 |
209 | + Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0); |
210 | + _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1)); |
211 | +#else |
212 | + Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage( |
213 | + new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0)); |
214 | + _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1)); |
215 | +#endif |
216 | + _labelTotalPages = Gtk::manage(new class Gtk::Label()); |
217 | + gchar *label_text = g_strdup_printf(_("out of %i"), num_pages); |
218 | + _labelTotalPages->set_label(label_text); |
219 | + g_free(label_text); |
220 | + |
221 | + vbox1 = Gtk::manage(new class Gtk::VBox(false, 4)); |
222 | + SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0); |
223 | + _previewArea = Glib::wrap(sp_svg_view_widget_new(doc)); |
224 | + |
225 | + vbox2 = Gtk::manage(new class Gtk::VBox(false, 4)); |
226 | + cancelbutton->set_can_focus(); |
227 | + cancelbutton->set_can_default(); |
228 | + cancelbutton->set_relief(Gtk::RELIEF_NORMAL); |
229 | + okbutton->set_can_focus(); |
230 | + okbutton->set_can_default(); |
231 | + okbutton->set_relief(Gtk::RELIEF_NORMAL); |
232 | + this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END); |
233 | + _labelSelect->set_line_wrap(false); |
234 | + _labelSelect->set_use_markup(false); |
235 | + _labelSelect->set_selectable(false); |
236 | + _pageNumberSpin->set_can_focus(); |
237 | + _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS); |
238 | + _pageNumberSpin->set_numeric(true); |
239 | + _pageNumberSpin->set_digits(0); |
240 | + _pageNumberSpin->set_wrap(false); |
241 | + _labelTotalPages->set_line_wrap(false); |
242 | + _labelTotalPages->set_use_markup(false); |
243 | + _labelTotalPages->set_selectable(false); |
244 | + vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0); |
245 | + this->get_vbox()->set_homogeneous(false); |
246 | + this->get_vbox()->set_spacing(0); |
247 | + this->get_vbox()->pack_start(*vbox2); |
248 | + this->set_title(_("Page Selector")); |
249 | + this->set_modal(true); |
250 | + sp_transientize((GtkWidget *)this->gobj()); //Make transient |
251 | + this->property_window_position().set_value(Gtk::WIN_POS_NONE); |
252 | + this->set_resizable(true); |
253 | + this->property_destroy_with_parent().set_value(false); |
254 | + this->get_action_area()->add(*_labelSelect); |
255 | + this->add_action_widget(*_pageNumberSpin, -7); |
256 | + this->get_action_area()->add(*_labelTotalPages); |
257 | + this->add_action_widget(*cancelbutton, -6); |
258 | + this->add_action_widget(*okbutton, -5); |
259 | + cancelbutton->show(); |
260 | + okbutton->show(); |
261 | + _labelSelect->show(); |
262 | + _pageNumberSpin->show(); |
263 | + _labelTotalPages->show(); |
264 | + vbox1->show(); |
265 | + _previewArea->show(); |
266 | + vbox2->show(); |
267 | + |
268 | + // Connect signals |
269 | + _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged)); |
270 | +} |
271 | + |
272 | +VsdImportDialog::~VsdImportDialog() {} |
273 | + |
274 | +bool VsdImportDialog::showDialog() |
275 | +{ |
276 | + show(); |
277 | + gint b = run(); |
278 | + hide(); |
279 | + if ( b == Gtk::RESPONSE_OK ) { |
280 | + return TRUE; |
281 | + } else { |
282 | + return FALSE; |
283 | + } |
284 | +} |
285 | + |
286 | +unsigned VsdImportDialog::getSelectedPage() |
287 | +{ |
288 | + return _current_page; |
289 | +} |
290 | + |
291 | +void VsdImportDialog::_onPageNumberChanged() |
292 | +{ |
293 | + int page = _pageNumberSpin->get_value_as_int(); |
294 | + _current_page = CLAMP(page, 1, _vec.size()); |
295 | + _setPreviewPage(_current_page); |
296 | +} |
297 | + |
298 | +/** |
299 | + * \brief Renders the given page's thumbnail |
300 | + */ |
301 | +void VsdImportDialog::_setPreviewPage(unsigned page) |
302 | +{ |
303 | + SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0); |
304 | + Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc)); |
305 | + std::swap(_previewArea, tmpPreviewArea); |
306 | + if (tmpPreviewArea) { |
307 | + _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() ); |
308 | + delete tmpPreviewArea; |
309 | + } |
310 | + vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0); |
311 | + _previewArea->show_now(); |
312 | +} |
313 | + |
314 | +SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) |
315 | +{ |
316 | + WPXFileStream input(uri); |
317 | + |
318 | + if (!libvisio::VisioDocument::isSupported(&input)) { |
319 | + return NULL; |
320 | + } |
321 | + |
322 | + libvisio::VSDStringVector output; |
323 | + if (!libvisio::VisioDocument::generateSVG(&input, output)) { |
324 | + return NULL; |
325 | + } |
326 | + |
327 | + if (output.empty()) { |
328 | + return NULL; |
329 | + } |
330 | + |
331 | + std::vector<WPXString> tmpSVGOutput; |
332 | + for (unsigned i=0; i<output.size(); ++i) { |
333 | + 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"); |
334 | + tmpString.append(output[i]); |
335 | + tmpSVGOutput.push_back(tmpString); |
336 | + } |
337 | + |
338 | + unsigned page_num = 1; |
339 | + |
340 | + // If only one page is present, import that one without bothering user |
341 | + if (tmpSVGOutput.size() > 1) { |
342 | + VsdImportDialog *dlg = 0; |
343 | + if (inkscape_use_gui()) { |
344 | + dlg = new VsdImportDialog(tmpSVGOutput); |
345 | + if (!dlg->showDialog()) { |
346 | + delete dlg; |
347 | + return NULL; |
348 | + } |
349 | + } |
350 | + |
351 | + // Get needed page |
352 | + if (dlg) { |
353 | + page_num = dlg->getSelectedPage(); |
354 | + if (page_num < 1) |
355 | + page_num = 1; |
356 | + if (page_num > tmpSVGOutput.size()) |
357 | + page_num = tmpSVGOutput.size(); |
358 | + } |
359 | + } |
360 | + |
361 | + SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE); |
362 | + return doc; |
363 | +} |
364 | + |
365 | +#include "clear-n_.h" |
366 | + |
367 | +void VsdInput::init(void) |
368 | +{ |
369 | + Inkscape::Extension::build_from_mem( |
370 | + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" |
371 | + "<name>" N_("VSD Input") "</name>\n" |
372 | + "<id>org.inkscape.input.vsd</id>\n" |
373 | + "<input>\n" |
374 | + "<extension>.vsd</extension>\n" |
375 | + "<mimetype>application/vnd.visio</mimetype>\n" |
376 | + "<filetypename>" N_("Microsoft Visio Diagram (*.vsd)") "</filetypename>\n" |
377 | + "<filetypetooltip>" N_("File format used by Microsoft Visio 6 and later") "</filetypetooltip>\n" |
378 | + "</input>\n" |
379 | + "</inkscape-extension>", new VsdInput()); |
380 | +} // init |
381 | + |
382 | +} } } /* namespace Inkscape, Extension, Implementation */ |
383 | +#endif /* WITH_LIBVISIO */ |
384 | + |
385 | +/* |
386 | + Local Variables: |
387 | + mode:c++ |
388 | + c-file-style:"stroustrup" |
389 | + c-file-offsets:((innamespace . 0)(inline-open . 0)) |
390 | + indent-tabs-mode:nil |
391 | + fill-column:99 |
392 | + End: |
393 | +*/ |
394 | +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : |
395 | |
396 | === added file 'src/extension/internal/vsd-input.h' |
397 | --- src/extension/internal/vsd-input.h 1970-01-01 00:00:00 +0000 |
398 | +++ src/extension/internal/vsd-input.h 2012-07-09 21:33:25 +0000 |
399 | @@ -0,0 +1,54 @@ |
400 | +/* |
401 | + * This code abstracts the libwpg interfaces into the Inkscape |
402 | + * input extension interface. |
403 | + * |
404 | + * Authors: |
405 | + * Fridrich Strba (fridrich.strba@bluewin.ch) |
406 | + * |
407 | + * Copyright (C) 2012 Authors |
408 | + * |
409 | + * Released under GNU GPL, read the file 'COPYING' for more information |
410 | + */ |
411 | + |
412 | +#ifndef __EXTENSION_INTERNAL_VSDOUTPUT_H__ |
413 | +#define __EXTENSION_INTERNAL_VSDOUTPUT_H__ |
414 | + |
415 | +#ifdef HAVE_CONFIG_H |
416 | +# include <config.h> |
417 | +#endif |
418 | + |
419 | +#ifdef WITH_LIBVISIO |
420 | + |
421 | +#include <gtkmm/dialog.h> |
422 | + |
423 | +#include "../implementation/implementation.h" |
424 | + |
425 | +namespace Inkscape { |
426 | +namespace Extension { |
427 | +namespace Internal { |
428 | + |
429 | +class VsdInput : public Inkscape::Extension::Implementation::Implementation { |
430 | + VsdInput () { }; |
431 | +public: |
432 | + SPDocument *open( Inkscape::Extension::Input *mod, |
433 | + const gchar *uri ); |
434 | + static void init( void ); |
435 | + |
436 | +}; |
437 | + |
438 | +} } } /* namespace Inkscape, Extension, Implementation */ |
439 | + |
440 | +#endif /* WITH_LIBVISIO */ |
441 | +#endif /* __EXTENSION_INTERNAL_VSDOUTPUT_H__ */ |
442 | + |
443 | + |
444 | +/* |
445 | + Local Variables: |
446 | + mode:c++ |
447 | + c-file-style:"stroustrup" |
448 | + c-file-offsets:((innamespace . 0)(inline-open . 0)) |
449 | + indent-tabs-mode:nil |
450 | + fill-column:99 |
451 | + End: |
452 | +*/ |
453 | +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : |
AFAICT the proposed branch misses the two files which are added by the patch: /internal/ vsd-input. cpp /internal/ vsd-input. h
src/extension
src/extension