Merge lp:~inkscape.dev/inkscape/cdr-input into lp:~inkscape.dev/inkscape/trunk

Proposed by su_v
Status: Merged
Approved by: jazzynico
Approved revision: 12063
Merged at revision: 12087
Proposed branch: lp:~inkscape.dev/inkscape/cdr-input
Merge into: lp:~inkscape.dev/inkscape/trunk
Diff against target: 612 lines (+441/-19)
12 files modified
configure.ac (+22/-0)
share/extensions/Makefile.am (+1/-1)
share/extensions/ccx_input.inx (+4/-4)
share/extensions/cdr_input.inx (+4/-4)
share/extensions/cdt_input.inx (+4/-4)
share/extensions/cmx_input.inx (+4/-4)
src/Makefile.am (+2/-0)
src/extension/init.cpp (+6/-0)
src/extension/internal/Makefile_insert (+6/-0)
src/extension/internal/cdr-input.cpp (+332/-0)
src/extension/internal/cdr-input.h (+54/-0)
src/extension/internal/vsd-input.cpp (+2/-2)
To merge this branch: bzr merge lp:~inkscape.dev/inkscape/cdr-input
Reviewer Review Type Date Requested Status
jazzynico (community) Approve
Martin Owens code review Approve
Review via email: mp+145060@code.launchpad.net

Description of the change

Implement (optional) internal support for CDR input based on libcdr:
<http://www.freedesktop.org/wiki/Software/libcdr>

To post a comment you must log in.
Revision history for this message
Martin Owens (doctormo) wrote :

Looks good, solid library, solid configure changes.

I'm unsettled by the gtk widgets section, do we not use glade at all? If we don't, then I approve.

review: Approve (code review)
Revision history for this message
jazzynico (jazzynico) wrote :

Looks good on Debian testing too (note that libcdr is in experimental only).
Some (planed) tests needed on Windows.

Revision history for this message
ScislaC (scislac) wrote :

Martin: We do not use glade at all. In fact, historically the project stance has been that we really don't ever want it to be used in Inkscape.

Revision history for this message
jazzynico (jazzynico) wrote :

Tested successfully on Windows XP, with lcms2.2.4 and libcdr-0.0.9, terra.cdr file from <http://sk1project.org/files/terra.cdr>. We need more test files before merging.

Note that compiling ICU (required by libcdr-0.0.10) doesn't seem to work on my machine (hangs when 'make' enters the data folder).

Revision history for this message
Alexandre Prokoudine (alexandre-prokoudine) wrote :

You can find tons of free CDR samples at http://www.stocklayouts.com/Templates/Flyer/Make-A-Flyer-Design.aspx (scroll down to the "Free Sample Templates" tab)

lp:~inkscape.dev/inkscape/cdr-input updated
12063. By su_v

libcdr: add remaining CorelDRAW formats (CDT, CCX, CMX) to internal support

Revision history for this message
jazzynico (jazzynico) wrote :

Tested on Windows XP, Inkscape trunk revision 12068, libcdr-0.0.10, lcms2.2.4 and ICU-50.1.2.
terra.cdr looks good, and the cdr files (except the ones in the zip file) from http://uniconvertor.svn.sourceforge.net/viewvc/uniconvertor/formats/CDR/test_data/ load successfully, with no obvious regression.
I suggest we merge now so that we have more testers.

review: Approve
lp:~inkscape.dev/inkscape/cdr-input updated
12064. By su_v

Revert change of file names of the UC-based input extensions
(changing the ID and name tags is sufficiant, keeping the old names prevents any issues with left-behind duplicates in the install dir of a trunk build)

Revision history for this message
su_v (suv-lp) wrote :

Any objections to the latest change?

For current trunk IMHO it's ok to keep the UC-based extensions as alternative (e.g. to compare import results), but for the stable release maybe it would be possible to add some Makefile magic, so that the UC-based extensions will not get installed if $WITH_LIBCDR is defined.

lp:~inkscape.dev/inkscape/cdr-input updated
12065. By su_v

Revert renaming in 'share/extensions/Makefile.am' too

12066. By su_v

libcdr, libvisio: fix compiler warnings (comparison between signed and unsigned integer expressions)

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 2013-01-08 12:06:44 +0000
3+++ configure.ac 2013-02-01 12:43:19 +0000
4@@ -706,6 +706,27 @@
5 AC_SUBST(LIBVISIO_CFLAGS)
6 AM_CONDITIONAL(WITH_LIBVISIO, test "x$with_libvisio" = "xyes")
7
8+dnl ********************************
9+dnl Check for libcdr for extension
10+dnl ********************************
11+
12+AC_ARG_ENABLE(wpg,
13+ [ --disable-cdr compile without support for Microsoft Visio Diagrams],
14+ enable_cdr=$enableval,enable_cdr=yes)
15+
16+with_libcdr=no
17+
18+if test "x$enable_cdr" = "xyes"; then
19+ PKG_CHECK_MODULES(LIBCDR, libcdr-0.0 >= 0.0.3 libwpd-0.9 libwpd-stream-0.9 libwpg-0.2, with_libcdr=yes, with_libcdr=no)
20+
21+ if test "x$with_libcdr" = "xyes"; then
22+ AC_DEFINE(WITH_LIBCDR,1,[Build in libcdr])
23+ fi
24+fi
25+AC_SUBST(LIBCDR_LIBS)
26+AC_SUBST(LIBCDR_CFLAGS)
27+AM_CONDITIONAL(WITH_LIBCDR, test "x$with_libcdr" = "xyes")
28+
29 dnl ******************************
30 dnl Support doing a local install
31 dnl (mostly for distcheck)
32@@ -1170,6 +1191,7 @@
33 ImageMagick Magick++: ${magick_ok}
34 Libwpg: ${with_libwpg}
35 Libvisio: ${with_libvisio}
36+ Libcdr: ${with_libcdr}
37 Doing Local Install: ${with_localinstall}
38 GTK+ backend target: ${gtk_backend_target}
39 "
40
41=== modified file 'share/extensions/Makefile.am'
42--- share/extensions/Makefile.am 2012-09-20 14:11:29 +0000
43+++ share/extensions/Makefile.am 2013-02-01 12:43:19 +0000
44@@ -196,7 +196,7 @@
45 ai_input.inx \
46 aisvg.inx \
47 ccx_input.inx \
48- cdr_input.inx\
49+ cdr_input.inx \
50 cdt_input.inx \
51 cgm_input.inx \
52 cmx_input.inx \
53
54=== modified file 'share/extensions/ccx_input.inx'
55--- share/extensions/ccx_input.inx 2009-03-02 20:40:26 +0000
56+++ share/extensions/ccx_input.inx 2013-02-01 12:43:19 +0000
57@@ -1,13 +1,13 @@
58 <?xml version="1.0" encoding="UTF-8"?>
59 <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
60- <_name>Corel DRAW Compressed Exchange files input</_name>
61- <id>org.inkscape.input.ccx</id>
62+ <_name>Corel DRAW Compressed Exchange files input (UC)</_name>
63+ <id>org.inkscape.input.ccx.uniconvertor</id>
64 <dependency type="executable" location="extensions">uniconv-ext.py</dependency>
65 <input>
66 <extension>.ccx</extension>
67 <mimetype>application/x-xccx</mimetype>
68- <_filetypename>Corel DRAW Compressed Exchange files (.ccx)</_filetypename>
69- <_filetypetooltip>Open compressed exchange files saved in Corel DRAW</_filetypetooltip>
70+ <_filetypename>Corel DRAW Compressed Exchange files (UC) (.ccx)</_filetypename>
71+ <_filetypetooltip>Open compressed exchange files saved in Corel DRAW (UC)</_filetypetooltip>
72 </input>
73 <script>
74 <command reldir="extensions" interpreter="python">uniconv-ext.py</command>
75
76=== modified file 'share/extensions/cdr_input.inx'
77--- share/extensions/cdr_input.inx 2008-12-01 22:35:10 +0000
78+++ share/extensions/cdr_input.inx 2013-02-01 12:43:19 +0000
79@@ -1,14 +1,14 @@
80 <?xml version="1.0" encoding="UTF-8"?>
81 <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
82- <_name>Corel DRAW Input</_name>
83- <id>org.inkscape.input.cdr</id>
84+ <_name>Corel DRAW Input (UC)</_name>
85+ <id>org.inkscape.input.cdr.uniconvertor</id>
86 <!-- the uniconv or uniconvertor dependency will be tested by uniconv-ext.py -->
87 <dependency type="executable" location="extensions">uniconv-ext.py</dependency>
88 <input>
89 <extension>.cdr</extension>
90 <mimetype>image/x-xcdr</mimetype>
91- <_filetypename>Corel DRAW 7-X4 files (*.cdr)</_filetypename>
92- <_filetypetooltip>Open files saved in Corel DRAW 7-X4</_filetypetooltip>
93+ <_filetypename>Corel DRAW 7-X4 files (UC) (*.cdr)</_filetypename>
94+ <_filetypetooltip>Open files saved in Corel DRAW 7-X4 (UC)</_filetypetooltip>
95 <output_extension>org.inkscape.output.cdr</output_extension>
96 </input>
97 <script>
98
99=== modified file 'share/extensions/cdt_input.inx'
100--- share/extensions/cdt_input.inx 2009-03-02 20:40:26 +0000
101+++ share/extensions/cdt_input.inx 2013-02-01 12:43:19 +0000
102@@ -1,13 +1,13 @@
103 <?xml version="1.0" encoding="UTF-8"?>
104 <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
105- <_name>Corel DRAW templates input</_name>
106- <id>org.inkscape.input.cdt</id>
107+ <_name>Corel DRAW templates input (UC)</_name>
108+ <id>org.inkscape.input.cdt.uniconvertor</id>
109 <dependency type="executable" location="extensions">uniconv-ext.py</dependency>
110 <input>
111 <extension>.cdt</extension>
112 <mimetype>application/x-xcdt</mimetype>
113- <_filetypename>Corel DRAW 7-13 template files (.cdt)</_filetypename>
114- <_filetypetooltip>Open files saved in Corel DRAW 7-13</_filetypetooltip>
115+ <_filetypename>Corel DRAW 7-13 template files (UC) (.cdt)</_filetypename>
116+ <_filetypetooltip>Open files saved in Corel DRAW 7-13 (UC)</_filetypetooltip>
117 </input>
118 <script>
119 <command reldir="extensions" interpreter="python">uniconv-ext.py</command>
120
121=== modified file 'share/extensions/cmx_input.inx'
122--- share/extensions/cmx_input.inx 2009-03-02 20:40:26 +0000
123+++ share/extensions/cmx_input.inx 2013-02-01 12:43:19 +0000
124@@ -1,13 +1,13 @@
125 <?xml version="1.0" encoding="UTF-8"?>
126 <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
127- <_name>Corel DRAW Presentation Exchange files input</_name>
128- <id>org.inkscape.input.cmx</id>
129+ <_name>Corel DRAW Presentation Exchange files input (UC)</_name>
130+ <id>org.inkscape.input.cmx.uniconvertor</id>
131 <dependency type="executable" location="extensions">uniconv-ext.py</dependency>
132 <input>
133 <extension>.cmx</extension>
134 <mimetype>application/x-xcmx</mimetype>
135- <_filetypename>Corel DRAW Presentation Exchange files (.cmx)</_filetypename>
136- <_filetypetooltip>Open presentation exchange files saved in Corel DRAW</_filetypetooltip>
137+ <_filetypename>Corel DRAW Presentation Exchange files (UC) (.cmx)</_filetypename>
138+ <_filetypetooltip>Open presentation exchange files saved in Corel DRAW (UC)</_filetypetooltip>
139 </input>
140 <script>
141 <command reldir="extensions" interpreter="python">uniconv-ext.py</command>
142
143=== modified file 'src/Makefile.am'
144--- src/Makefile.am 2012-10-15 21:58:41 +0000
145+++ src/Makefile.am 2013-02-01 12:43:19 +0000
146@@ -48,6 +48,7 @@
147 $(INKBOARD_LIBS) \
148 $(LIBWPG_LIBS) \
149 $(LIBVISIO_LIBS) \
150+ $(LIBCDR_LIBS) \
151 $(DBUS_LIBS) \
152 $(GDL_LIBS) \
153 $(IMAGEMAGICK_LIBS)
154@@ -72,6 +73,7 @@
155 $(INKBOARD_CFLAGS) \
156 $(LIBWPG_CFLAGS) \
157 $(LIBVISIO_CFLAGS) \
158+ $(LIBCDR_CFLAGS) \
159 $(DBUS_CFLAGS) \
160 $(GDL_CFLAGS) \
161 $(XFT_CFLAGS) \
162
163=== modified file 'src/extension/init.cpp'
164--- src/extension/init.cpp 2012-10-04 02:30:12 +0000
165+++ src/extension/init.cpp 2013-02-01 12:43:19 +0000
166@@ -56,6 +56,9 @@
167 #ifdef WITH_LIBVISIO
168 #include "internal/vsd-input.h"
169 #endif
170+#ifdef WITH_LIBCDR
171+#include "internal/cdr-input.h"
172+#endif
173 #include "preferences.h"
174 #include "io/sys.h"
175 #ifdef WITH_DBUS
176@@ -191,6 +194,9 @@
177 #ifdef WITH_LIBVISIO
178 Internal::VsdInput::init();
179 #endif
180+#ifdef WITH_LIBCDR
181+ Internal::CdrInput::init();
182+#endif
183
184 /* Effects */
185 Internal::BlurEdge::init();
186
187=== modified file 'src/extension/internal/Makefile_insert'
188--- src/extension/internal/Makefile_insert 2012-10-16 02:15:24 +0000
189+++ src/extension/internal/Makefile_insert 2013-02-01 12:43:19 +0000
190@@ -12,6 +12,12 @@
191 extension/internal/vsd-input.h
192 endif
193
194+if WITH_LIBCDR
195+ink_common_sources += \
196+ extension/internal/cdr-input.cpp \
197+ extension/internal/cdr-input.h
198+endif
199+
200 if USE_IMAGE_MAGICK
201 ink_common_sources += \
202 extension/internal/bitmap/imagemagick.cpp \
203
204=== added file 'src/extension/internal/cdr-input.cpp'
205--- src/extension/internal/cdr-input.cpp 1970-01-01 00:00:00 +0000
206+++ src/extension/internal/cdr-input.cpp 2013-02-01 12:43:19 +0000
207@@ -0,0 +1,332 @@
208+/*
209+ * This file came from libwpg as a source, their utility wpg2svg
210+ * specifically. It has been modified to work as an Inkscape extension.
211+ * The Inkscape extension code is covered by this copyright, but the
212+ * rest is covered by the one bellow.
213+ *
214+ * Authors:
215+ * Fridrich Strba (fridrich.strba@bluewin.ch)
216+ *
217+ * Copyright (C) 2012 Authors
218+ *
219+ * Released under GNU GPL, read the file 'COPYING' for more information
220+ *
221+ */
222+
223+#include <stdio.h>
224+#include "config.h"
225+
226+#include "cdr-input.h"
227+
228+#ifdef WITH_LIBCDR
229+
230+#include <string>
231+#include <cstring>
232+
233+#include <libcdr/libcdr.h>
234+#include <libwpd-stream/libwpd-stream.h>
235+
236+#include <gtkmm/alignment.h>
237+#include <gtkmm/comboboxtext.h>
238+#include <gtkmm/drawingarea.h>
239+#include <gtkmm/frame.h>
240+#include <gtkmm/scale.h>
241+
242+#include "extension/system.h"
243+#include "extension/input.h"
244+#include "document.h"
245+
246+#include "document-private.h"
247+#include "document-undo.h"
248+#include "inkscape.h"
249+
250+#include "dialogs/dialog-events.h"
251+#include <gtk/gtk.h>
252+#include "ui/widget/spinbutton.h"
253+#include "ui/widget/frame.h"
254+#include <glibmm/i18n.h>
255+
256+#include <gdkmm/general.h>
257+
258+#include "svg-view.h"
259+#include "svg-view-widget.h"
260+
261+namespace Inkscape {
262+namespace Extension {
263+namespace Internal {
264+
265+
266+class CdrImportDialog : public Gtk::Dialog {
267+public:
268+ CdrImportDialog(const std::vector<WPXString> &vec);
269+ virtual ~CdrImportDialog();
270+
271+ bool showDialog();
272+ unsigned getSelectedPage();
273+ void getImportSettings(Inkscape::XML::Node *prefs);
274+
275+private:
276+ void _setPreviewPage(unsigned page);
277+
278+ // Signal handlers
279+#if !WITH_GTKMM_3_0
280+ bool _onExposePreview(GdkEventExpose *event);
281+#endif
282+
283+ void _onPageNumberChanged();
284+
285+ class Gtk::Button * cancelbutton;
286+ class Gtk::Button * okbutton;
287+ class Gtk::Label * _labelSelect;
288+ class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
289+ class Gtk::Label * _labelTotalPages;
290+ class Gtk::VBox * vbox1;
291+ class Gtk::VBox * vbox2;
292+ class Gtk::Widget * _previewArea;
293+
294+ const std::vector<WPXString> &_vec; // Document to be imported
295+ unsigned _current_page; // Current selected page
296+ int _preview_width, _preview_height; // Size of the preview area
297+};
298+
299+CdrImportDialog::CdrImportDialog(const std::vector<WPXString> &vec)
300+ : _vec(vec), _current_page(1)
301+{
302+ int num_pages = _vec.size();
303+ if ( num_pages <= 1 )
304+ return;
305+ cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
306+ okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
307+ _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
308+
309+ // Page number
310+#if WITH_GTKMM_3_0
311+ Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
312+ _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
313+#else
314+ Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
315+ new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
316+ _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
317+#endif
318+ _labelTotalPages = Gtk::manage(new class Gtk::Label());
319+ gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
320+ _labelTotalPages->set_label(label_text);
321+ g_free(label_text);
322+
323+ vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
324+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
325+ _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
326+
327+ vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
328+ cancelbutton->set_can_focus();
329+ cancelbutton->set_can_default();
330+ cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
331+ okbutton->set_can_focus();
332+ okbutton->set_can_default();
333+ okbutton->set_relief(Gtk::RELIEF_NORMAL);
334+ this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
335+ _labelSelect->set_line_wrap(false);
336+ _labelSelect->set_use_markup(false);
337+ _labelSelect->set_selectable(false);
338+ _pageNumberSpin->set_can_focus();
339+ _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
340+ _pageNumberSpin->set_numeric(true);
341+ _pageNumberSpin->set_digits(0);
342+ _pageNumberSpin->set_wrap(false);
343+ _labelTotalPages->set_line_wrap(false);
344+ _labelTotalPages->set_use_markup(false);
345+ _labelTotalPages->set_selectable(false);
346+ vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
347+ this->get_vbox()->set_homogeneous(false);
348+ this->get_vbox()->set_spacing(0);
349+ this->get_vbox()->pack_start(*vbox2);
350+ this->set_title(_("Page Selector"));
351+ this->set_modal(true);
352+ sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
353+ this->property_window_position().set_value(Gtk::WIN_POS_NONE);
354+ this->set_resizable(true);
355+ this->property_destroy_with_parent().set_value(false);
356+ this->get_action_area()->add(*_labelSelect);
357+ this->add_action_widget(*_pageNumberSpin, -7);
358+ this->get_action_area()->add(*_labelTotalPages);
359+ this->add_action_widget(*cancelbutton, -6);
360+ this->add_action_widget(*okbutton, -5);
361+ cancelbutton->show();
362+ okbutton->show();
363+ _labelSelect->show();
364+ _pageNumberSpin->show();
365+ _labelTotalPages->show();
366+ vbox1->show();
367+ _previewArea->show();
368+ vbox2->show();
369+
370+ // Connect signals
371+ _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &CdrImportDialog::_onPageNumberChanged));
372+}
373+
374+CdrImportDialog::~CdrImportDialog() {}
375+
376+bool CdrImportDialog::showDialog()
377+{
378+ show();
379+ gint b = run();
380+ hide();
381+ if ( b == Gtk::RESPONSE_OK ) {
382+ return TRUE;
383+ } else {
384+ return FALSE;
385+ }
386+}
387+
388+unsigned CdrImportDialog::getSelectedPage()
389+{
390+ return _current_page;
391+}
392+
393+void CdrImportDialog::_onPageNumberChanged()
394+{
395+ unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int());
396+ _current_page = CLAMP(page, 1U, _vec.size());
397+ _setPreviewPage(_current_page);
398+}
399+
400+/**
401+ * \brief Renders the given page's thumbnail
402+ */
403+void CdrImportDialog::_setPreviewPage(unsigned page)
404+{
405+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
406+ Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
407+ std::swap(_previewArea, tmpPreviewArea);
408+ if (tmpPreviewArea) {
409+ _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
410+ delete tmpPreviewArea;
411+ }
412+ vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
413+ _previewArea->show_now();
414+}
415+
416+SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri)
417+{
418+ WPXFileStream input(uri);
419+
420+ if (!libcdr::CDRDocument::isSupported(&input)) {
421+ return NULL;
422+ }
423+
424+ libcdr::CDRStringVector output;
425+ if (!libcdr::CDRDocument::generateSVG(&input, output)) {
426+ return NULL;
427+ }
428+
429+ if (output.empty()) {
430+ return NULL;
431+ }
432+
433+ std::vector<WPXString> tmpSVGOutput;
434+ for (unsigned i=0; i<output.size(); ++i) {
435+ 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");
436+ tmpString.append(output[i]);
437+ tmpSVGOutput.push_back(tmpString);
438+ }
439+
440+ unsigned page_num = 1;
441+
442+ // If only one page is present, import that one without bothering user
443+ if (tmpSVGOutput.size() > 1) {
444+ CdrImportDialog *dlg = 0;
445+ if (inkscape_use_gui()) {
446+ dlg = new CdrImportDialog(tmpSVGOutput);
447+ if (!dlg->showDialog()) {
448+ delete dlg;
449+ return NULL;
450+ }
451+ }
452+
453+ // Get needed page
454+ if (dlg) {
455+ page_num = dlg->getSelectedPage();
456+ if (page_num < 1)
457+ page_num = 1;
458+ if (page_num > tmpSVGOutput.size())
459+ page_num = tmpSVGOutput.size();
460+ }
461+ }
462+
463+ SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
464+ return doc;
465+}
466+
467+#include "clear-n_.h"
468+
469+void CdrInput::init(void)
470+{
471+ /* CDR */
472+ Inkscape::Extension::build_from_mem(
473+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
474+ "<name>" N_("Corel DRAW Input") "</name>\n"
475+ "<id>org.inkscape.input.cdr</id>\n"
476+ "<input>\n"
477+ "<extension>.cdr</extension>\n"
478+ "<mimetype>image/x-xcdr</mimetype>\n"
479+ "<filetypename>" N_("Corel DRAW 7-X4 files (*.cdr)") "</filetypename>\n"
480+ "<filetypetooltip>" N_("Open files saved in Corel DRAW 7-X4") "</filetypetooltip>\n"
481+ "</input>\n"
482+ "</inkscape-extension>", new CdrInput());
483+
484+ /* CDT */
485+ Inkscape::Extension::build_from_mem(
486+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
487+ "<name>" N_("Corel DRAW templates input") "</name>\n"
488+ "<id>org.inkscape.input.cdt</id>\n"
489+ "<input>\n"
490+ "<extension>.cdt</extension>\n"
491+ "<mimetype>application/x-xcdt</mimetype>\n"
492+ "<filetypename>" N_("Corel DRAW 7-13 template files (*.cdt)") "</filetypename>\n"
493+ "<filetypetooltip>" N_("Open files saved in Corel DRAW 7-13") "</filetypetooltip>\n"
494+ "</input>\n"
495+ "</inkscape-extension>", new CdrInput());
496+
497+ /* CCX */
498+ Inkscape::Extension::build_from_mem(
499+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
500+ "<name>" N_("Corel DRAW Compressed Exchange files input") "</name>\n"
501+ "<id>org.inkscape.input.ccx</id>\n"
502+ "<input>\n"
503+ "<extension>.ccx</extension>\n"
504+ "<mimetype>application/x-xccx</mimetype>\n"
505+ "<filetypename>" N_("Corel DRAW Compressed Exchange files (*.ccx)") "</filetypename>\n"
506+ "<filetypetooltip>" N_("Open compressed exchange files saved in Corel DRAW") "</filetypetooltip>\n"
507+ "</input>\n"
508+ "</inkscape-extension>", new CdrInput());
509+
510+ /* CMX */
511+ Inkscape::Extension::build_from_mem(
512+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
513+ "<name>" N_("Corel DRAW Presentation Exchange files input") "</name>\n"
514+ "<id>org.inkscape.input.cmx</id>\n"
515+ "<input>\n"
516+ "<extension>.cmx</extension>\n"
517+ "<mimetype>application/x-xcmx</mimetype>\n"
518+ "<filetypename>" N_("Corel DRAW Presentation Exchange files (*.cmx)") "</filetypename>\n"
519+ "<filetypetooltip>" N_("Open presentation exchange files saved in Corel DRAW") "</filetypetooltip>\n"
520+ "</input>\n"
521+ "</inkscape-extension>", new CdrInput());
522+
523+ return;
524+
525+} // init
526+
527+} } } /* namespace Inkscape, Extension, Implementation */
528+#endif /* WITH_LIBCDR */
529+
530+/*
531+ Local Variables:
532+ mode:c++
533+ c-file-style:"stroustrup"
534+ c-file-offsets:((innamespace . 0)(inline-open . 0))
535+ indent-tabs-mode:nil
536+ fill-column:99
537+ End:
538+*/
539+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
540
541=== added file 'src/extension/internal/cdr-input.h'
542--- src/extension/internal/cdr-input.h 1970-01-01 00:00:00 +0000
543+++ src/extension/internal/cdr-input.h 2013-02-01 12:43:19 +0000
544@@ -0,0 +1,54 @@
545+/*
546+ * This code abstracts the libwpg interfaces into the Inkscape
547+ * input extension interface.
548+ *
549+ * Authors:
550+ * Fridrich Strba (fridrich.strba@bluewin.ch)
551+ *
552+ * Copyright (C) 2012 Authors
553+ *
554+ * Released under GNU GPL, read the file 'COPYING' for more information
555+ */
556+
557+#ifndef __EXTENSION_INTERNAL_CDROUTPUT_H__
558+#define __EXTENSION_INTERNAL_CDROUTPUT_H__
559+
560+#ifdef HAVE_CONFIG_H
561+# include <config.h>
562+#endif
563+
564+#ifdef WITH_LIBCDR
565+
566+#include <gtkmm/dialog.h>
567+
568+#include "../implementation/implementation.h"
569+
570+namespace Inkscape {
571+namespace Extension {
572+namespace Internal {
573+
574+class CdrInput : public Inkscape::Extension::Implementation::Implementation {
575+ CdrInput () { };
576+public:
577+ SPDocument *open( Inkscape::Extension::Input *mod,
578+ const gchar *uri );
579+ static void init( void );
580+
581+};
582+
583+} } } /* namespace Inkscape, Extension, Implementation */
584+
585+#endif /* WITH_LIBCDR */
586+#endif /* __EXTENSION_INTERNAL_CDROUTPUT_H__ */
587+
588+
589+/*
590+ Local Variables:
591+ mode:c++
592+ c-file-style:"stroustrup"
593+ c-file-offsets:((innamespace . 0)(inline-open . 0))
594+ indent-tabs-mode:nil
595+ fill-column:99
596+ End:
597+*/
598+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
599
600=== modified file 'src/extension/internal/vsd-input.cpp'
601--- src/extension/internal/vsd-input.cpp 2012-12-25 22:50:08 +0000
602+++ src/extension/internal/vsd-input.cpp 2013-02-01 12:43:19 +0000
603@@ -185,8 +185,8 @@
604
605 void VsdImportDialog::_onPageNumberChanged()
606 {
607- int page = _pageNumberSpin->get_value_as_int();
608- _current_page = CLAMP(page, 1, _vec.size());
609+ unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int());
610+ _current_page = CLAMP(page, 1U, _vec.size());
611 _setPreviewPage(_current_page);
612 }
613