Advertisement
Guest User

Untitled

a guest
Jun 19th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 15.44 KB | None | 0 0
  1. === modified file 'configure.ac'
  2. --- configure.ac    2012-06-12 16:12:48 +0000
  3. +++ configure.ac    2012-06-19 17:13:40 +0000
  4. @@ -660,6 +660,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 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. @@ -1132,6 +1153,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-06-15 15:47:36 +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-06-15 15:45:44 +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-06-19 09:26:30 +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-06-19 17:02:27 +0000
  105. @@ -0,0 +1,337 @@
  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. +     bool _onDraw(const Cairo::RefPtr<Cairo::Context>& cr);
  182. +     void _onPageNumberChanged();
  183. +     void _onToggleCropping();
  184. +     void _onPrecisionChanged();
  185. +
  186. +     class Gtk::Button * cancelbutton;
  187. +     class Gtk::Button * okbutton;
  188. +     class Gtk::Label * _labelSelect;
  189. +     class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
  190. +     class Gtk::Label * _labelTotalPages;
  191. +     class Gtk::HBox * hbox2;
  192. +     class Gtk::VBox * vbox2;
  193. +     class Inkscape::UI::Widget::Frame * _pageSettingsFrame;
  194. +     class Gtk::VBox * vbox1;
  195. +     class Gtk::Widget * _previewArea;
  196. +     class Gtk::HBox * hbox1;
  197. +
  198. +     const std::vector<WPXString> &_vec;   // Document to be imported
  199. +     unsigned _current_page;  // Current selected page
  200. +     int _preview_width, _preview_height;    // Size of the preview area
  201. +};
  202. +
  203. +VsdImportDialog::VsdImportDialog(const std::vector<WPXString> &vec)
  204. +     : _vec(vec), _current_page(1)
  205. +{
  206. +     cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
  207. +     okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
  208. +     _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
  209. +
  210. +     // Page number
  211. +#if WITH_GTKMM_3_0
  212. +     Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
  213. +     _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
  214. +#else
  215. +     Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
  216. +               new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
  217. +     _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
  218. +#endif
  219. +     _labelTotalPages = Gtk::manage(new class Gtk::Label());
  220. +     hbox2 = Gtk::manage(new class Gtk::HBox(false, 0));
  221. +     // Disable the page selector when there's only one page
  222. +     int num_pages = _vec.size();
  223. +     if ( num_pages == 1 ) {
  224. +          _pageNumberSpin->set_sensitive(false);
  225. +     } else {
  226. +          // Display total number of pages
  227. +          gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
  228. +          _labelTotalPages->set_label(label_text);
  229. +          g_free(label_text);
  230. +     }
  231. +
  232. +     vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
  233. +     _pageSettingsFrame = Gtk::manage(new class Inkscape::UI::Widget::Frame());
  234. +
  235. +     vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
  236. +     SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
  237. +     _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
  238. +
  239. +     hbox1 = Gtk::manage(new class Gtk::HBox(false, 4));
  240. +     cancelbutton->set_can_focus();
  241. +     cancelbutton->set_can_default();
  242. +     cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
  243. +     okbutton->set_can_focus();
  244. +     okbutton->set_can_default();
  245. +     okbutton->set_relief(Gtk::RELIEF_NORMAL);
  246. +     this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
  247. +     _labelSelect->set_alignment(0.5,0.5);
  248. +     _labelSelect->set_padding(4,0);
  249. +     _labelSelect->set_justify(Gtk::JUSTIFY_LEFT);
  250. +     _labelSelect->set_line_wrap(false);
  251. +     _labelSelect->set_use_markup(false);
  252. +     _labelSelect->set_selectable(false);
  253. +     _pageNumberSpin->set_can_focus();
  254. +     _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
  255. +     _pageNumberSpin->set_numeric(true);
  256. +     _pageNumberSpin->set_digits(0);
  257. +     _pageNumberSpin->set_wrap(false);
  258. +     _labelTotalPages->set_alignment(0.5,0.5);
  259. +     _labelTotalPages->set_padding(4,0);
  260. +     _labelTotalPages->set_justify(Gtk::JUSTIFY_LEFT);
  261. +     _labelTotalPages->set_line_wrap(false);
  262. +     _labelTotalPages->set_use_markup(false);
  263. +     _labelTotalPages->set_selectable(false);
  264. +     hbox2->pack_start(*_labelSelect, Gtk::PACK_SHRINK, 4);
  265. +     hbox2->pack_start(*_pageNumberSpin, Gtk::PACK_SHRINK, 4);
  266. +     hbox2->pack_start(*_labelTotalPages, Gtk::PACK_SHRINK, 4);
  267. +     vbox2->pack_start(*hbox2);
  268. +     _pageSettingsFrame->add(*vbox2);
  269. +     _pageSettingsFrame->set_border_width(4);
  270. +     vbox1->pack_start(*_pageSettingsFrame, Gtk::PACK_SHRINK, 0);
  271. +     hbox1->pack_start(*vbox1, Gtk::PACK_EXPAND_PADDING, 0);
  272. +     hbox1->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
  273. +     this->get_vbox()->set_homogeneous(false);
  274. +     this->get_vbox()->set_spacing(0);
  275. +     this->get_vbox()->pack_start(*hbox1);
  276. +     this->set_title(_("Page Selector"));
  277. +     this->set_modal(true);
  278. +     sp_transientize((GtkWidget *)this->gobj());  //Make transient
  279. +     this->property_window_position().set_value(Gtk::WIN_POS_NONE);
  280. +     this->set_resizable(true);
  281. +     this->property_destroy_with_parent().set_value(false);
  282. +     this->add_action_widget(*cancelbutton, -6);
  283. +     this->add_action_widget(*okbutton, -5);
  284. +     cancelbutton->show();
  285. +     okbutton->show();
  286. +     _labelSelect->show();
  287. +     _pageNumberSpin->show();
  288. +     _labelTotalPages->show();
  289. +     hbox2->show();
  290. +     vbox2->show();
  291. +     _pageSettingsFrame->show();
  292. +     vbox1->show();
  293. +     _previewArea->show();
  294. +     hbox1->show();
  295. +
  296. +     // Connect signals
  297. +     _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
  298. +}
  299. +
  300. +VsdImportDialog::~VsdImportDialog() {}
  301. +
  302. +bool VsdImportDialog::showDialog()
  303. +{
  304. +     show();
  305. +     gint b = run();
  306. +     hide();
  307. +     if ( b == Gtk::RESPONSE_OK ) {
  308. +          return TRUE;
  309. +     } else {
  310. +          return FALSE;
  311. +     }
  312. +}
  313. +
  314. +unsigned VsdImportDialog::getSelectedPage()
  315. +{
  316. +     return _current_page;
  317. +}
  318. +
  319. +/**
  320. + * \brief Retrieves the current settings into a repr which SvgBuilder will use
  321. + *        for determining the behaviour desired by the user
  322. + */
  323. +void VsdImportDialog::getImportSettings(Inkscape::XML::Node *prefs)
  324. +{
  325. +}
  326. +
  327. +/**
  328. + * \brief Redisplay the comment on the current approximation precision setting
  329. + * Evenly divides the interval of possible values between the available labels.
  330. + */
  331. +void VsdImportDialog::_onPrecisionChanged()
  332. +{
  333. +}
  334. +
  335. +void VsdImportDialog::_onToggleCropping()
  336. +{
  337. +}
  338. +
  339. +void VsdImportDialog::_onPageNumberChanged()
  340. +{
  341. +     int page = _pageNumberSpin->get_value_as_int();
  342. +     _current_page = CLAMP(page, 1, _vec.size());
  343. +     _setPreviewPage(_current_page);
  344. +}
  345. +
  346. +/**
  347. + * \brief Renders the given page's thumbnail
  348. + */
  349. +void VsdImportDialog::_setPreviewPage(unsigned page)
  350. +{
  351. +     SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
  352. +     Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
  353. +     std::swap(_previewArea, tmpPreviewArea);
  354. +     if (tmpPreviewArea) {
  355. +          _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
  356. +          delete tmpPreviewArea;
  357. +     }
  358. +     hbox1->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
  359. +     _previewArea->show_now();
  360. +}
  361. +
  362. +SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri)
  363. +{
  364. +     WPXFileStream input(uri);
  365. +
  366. +     if (!libvisio::VisioDocument::isSupported(&input)) {
  367. +          return NULL;
  368. +     }
  369. +
  370. +     libvisio::VSDStringVector output;
  371. +     if (!libvisio::VisioDocument::generateSVG(&input, output)) {
  372. +          return NULL;
  373. +     }
  374. +
  375. +     if (output.empty()) {
  376. +          return NULL;
  377. +     }
  378. +
  379. +     std::vector<WPXString> tmpSVGOutput;
  380. +     for (unsigned i=0; i<output.size(); ++i) {
  381. +          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");
  382. +          tmpString.append(output[i]);
  383. +          tmpSVGOutput.push_back(tmpString);
  384. +     }
  385. +
  386. +     unsigned page_num = 1;
  387. +
  388. +     // If only one page is present, import that one without bothering user
  389. +     if (tmpSVGOutput.size() > 1) {
  390. +          VsdImportDialog *dlg = 0;
  391. +          if (inkscape_use_gui()) {
  392. +               dlg = new VsdImportDialog(tmpSVGOutput);
  393. +               if (!dlg->showDialog()) {
  394. +                    delete dlg;
  395. +                    return NULL;
  396. +               }
  397. +          }
  398. +
  399. +          // Get needed page
  400. +          if (dlg) {
  401. +               page_num = dlg->getSelectedPage();
  402. +               if (page_num < 1)
  403. +                    page_num = 1;
  404. +               if (page_num > tmpSVGOutput.size())
  405. +                    page_num = tmpSVGOutput.size();
  406. +          }
  407. +     }
  408. +
  409. +     SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
  410. +     return doc;
  411. +}
  412. +
  413. +#include "clear-n_.h"
  414. +
  415. +void VsdInput::init(void)
  416. +{
  417. +     Inkscape::Extension::build_from_mem(
  418. +        "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
  419. +            "<name>" N_("VSD Input") "</name>\n"
  420. +            "<id>org.inkscape.input.vsd</id>\n"
  421. +            "<input>\n"
  422. +                "<extension>.vsd</extension>\n"
  423. +                "<mimetype>application/vnd.visio</mimetype>\n"
  424. +                "<filetypename>" N_("Microsoft Visio Diagram (*.vsd)") "</filetypename>\n"
  425. +                "<filetypetooltip>" N_("File format used by Microsoft Visio 6 and later") "</filetypetooltip>\n"
  426. +            "</input>\n"
  427. +        "</inkscape-extension>", new VsdInput());
  428. +} // init
  429. +
  430. +} } }  /* namespace Inkscape, Extension, Implementation */
  431. +#endif /* WITH_LIBVISIO */
  432. +
  433. +/*
  434. +  Local Variables:
  435. +  mode:c++
  436. +  c-file-style:"stroustrup"
  437. +  c-file-offsets:((innamespace . 0)(inline-open . 0))
  438. +  indent-tabs-mode:nil
  439. +  fill-column:99
  440. +  End:
  441. +*/
  442. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
  443.  
  444. === added file 'src/extension/internal/vsd-input.h'
  445. --- src/extension/internal/vsd-input.h  1970-01-01 00:00:00 +0000
  446. +++ src/extension/internal/vsd-input.h  2012-06-19 16:54:25 +0000
  447. @@ -0,0 +1,54 @@
  448. +/*
  449. + * This code abstracts the libwpg interfaces into the Inkscape
  450. + * input extension interface.
  451. + *
  452. + * Authors:
  453. + *   Fridrich Strba (fridrich.strba@bluewin.ch)
  454. + *
  455. + * Copyright (C) 2012 Authors
  456. + *
  457. + * Released under GNU GPL, read the file 'COPYING' for more information
  458. + */
  459. +
  460. +#ifndef __EXTENSION_INTERNAL_VSDOUTPUT_H__
  461. +#define __EXTENSION_INTERNAL_VSDOUTPUT_H__
  462. +
  463. +#ifdef HAVE_CONFIG_H
  464. +# include <config.h>
  465. +#endif
  466. +
  467. +#ifdef WITH_LIBVISIO
  468. +
  469. +#include <gtkmm/dialog.h>
  470. +
  471. +#include "../implementation/implementation.h"
  472. +
  473. +namespace Inkscape {
  474. +namespace Extension {
  475. +namespace Internal {
  476. +
  477. +class VsdInput : public Inkscape::Extension::Implementation::Implementation {
  478. +     VsdInput () { };
  479. +public:
  480. +     SPDocument *open( Inkscape::Extension::Input *mod,
  481. +                       const gchar *uri );
  482. +     static void         init( void );
  483. +
  484. +};
  485. +
  486. +} } }  /* namespace Inkscape, Extension, Implementation */
  487. +
  488. +#endif /* WITH_LIBVISIO */
  489. +#endif /* __EXTENSION_INTERNAL_VSDOUTPUT_H__ */
  490. +
  491. +
  492. +/*
  493. +  Local Variables:
  494. +  mode:c++
  495. +  c-file-style:"stroustrup"
  496. +  c-file-offsets:((innamespace . 0)(inline-open . 0))
  497. +  indent-tabs-mode:nil
  498. +  fill-column:99
  499. +  End:
  500. +*/
  501. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement