/*
* 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>
// TODO: Drop this check when librevenge is widespread.
#if WITH_LIBVISIO01
#include <librevenge-stream/librevenge-stream.h>
using librevenge::RVNGString;
using librevenge::RVNGFileStream;
using librevenge::RVNGStringVector;
#else
#include <libwpd-stream/libwpd-stream.h>
typedef WPXString RVNGString;
typedef WPXFileStream RVNGFileStream;
#endif
#include <gtkmm/alignment.h>
#include <gtkmm/spinbutton.h>
#include "document.h"
#include "document-private.h"
#include "inkscape.h"
#include "ui/dialog-events.h"
#include "svg-view-widget.h"
namespace Inkscape {
namespace Extension {
namespace Internal {
public:
virtual ~VsdImportDialog();
bool showDialog();
unsigned getSelectedPage();
private:
void _setPreviewPage();
// Signal handlers
void _onPageNumberChanged();
};
{
if ( num_pages <= 1 )
return;
// Dialog settings
this->set_title(_("Page Selector"));
this->set_modal(true);
this->set_resizable(true);
this->property_destroy_with_parent().set_value(false);
// Preview area
#if WITH_GTKMM_3_0
#else
#endif
// CONTROLS
// Buttons
// Labels
_labelSelect->set_line_wrap(false);
_labelSelect->set_use_markup(false);
_labelSelect->set_selectable(false);
_labelTotalPages->set_line_wrap(false);
_labelTotalPages->set_use_markup(false);
_labelTotalPages->set_selectable(false);
// Adjustment + spinner
#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
#else
Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
#endif
_pageNumberSpin->set_numeric(true);
_pageNumberSpin->set_wrap(false);
// Show all widgets in dialog
this->show_all();
// Connect signals
_pageNumberSpin->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
_pageNumberSpin->signal_button_press_event().connect_notify(sigc::mem_fun(*this, &VsdImportDialog::_onSpinButtonPress));
_pageNumberSpin->signal_button_release_event().connect_notify(sigc::mem_fun(*this, &VsdImportDialog::_onSpinButtonRelease));
}
VsdImportDialog::~VsdImportDialog() {}
{
show();
hide();
return TRUE;
} else {
return FALSE;
}
}
{
return _current_page;
}
{
}
{
_spinning = true;
}
{
_spinning = false;
}
/**
* \brief Renders the given page's thumbnail
*/
{
if (_spinning) {
return;
}
SPDocument *doc = SPDocument::createNewDocFromMem(_vec[_current_page-1].cstr(), strlen(_vec[_current_page-1].cstr()), 0);
delete tmpPreviewArea;
_previewArea->show_now();
}
{
return NULL;
}
#if WITH_LIBVISIO01
#else
#endif
return NULL;
}
return NULL;
}
RVNGString 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");
}
// If only one page is present, import that one without bothering user
if (!dlg->showDialog()) {
delete dlg;
return NULL;
}
}
// Get needed page
if (dlg) {
if (page_num < 1)
page_num = 1;
}
}
SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
// Set viewBox if it doesn't exist
doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDisplayUnit()), doc->getHeight().value(doc->getDisplayUnit())));
}
return doc;
}
#include "clear-n_.h"
{
/* VSD */
"<id>org.inkscape.input.vsd</id>\n"
"<input>\n"
"<extension>.vsd</extension>\n"
"<mimetype>application/vnd.visio</mimetype>\n"
"</input>\n"
"</inkscape-extension>", new VsdInput());
/* VDX */
"<id>org.inkscape.input.vdx</id>\n"
"<input>\n"
"<extension>.vdx</extension>\n"
"<mimetype>application/vnd.visio</mimetype>\n"
"</input>\n"
"</inkscape-extension>", new VsdInput());
/* VSDM */
"<id>org.inkscape.input.vsdm</id>\n"
"<input>\n"
"<extension>.vsdm</extension>\n"
"<mimetype>application/vnd.visio</mimetype>\n"
"</input>\n"
"</inkscape-extension>", new VsdInput());
/* VSDX */
"<id>org.inkscape.input.vsdx</id>\n"
"<input>\n"
"<extension>.vsdx</extension>\n"
"<mimetype>application/vnd.visio</mimetype>\n"
"</input>\n"
"</inkscape-extension>", new VsdInput());
return;
} // 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 :