vsd-input.cpp revision 7afb53df65578f04da41d1f7a2dcf4a29c93fcb1
/*
* 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>
#include <libwpd-stream/libwpd-stream.h>
#include <gtkmm/alignment.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/drawingarea.h>
#include "document.h"
#include "document-private.h"
#include "document-undo.h"
#include "inkscape.h"
#include "dialogs/dialog-events.h"
#include "ui/widget/spinbutton.h"
#include "svg-view.h"
#include "svg-view-widget.h"
namespace Inkscape {
namespace Extension {
namespace Internal {
public:
virtual ~VsdImportDialog();
bool showDialog();
unsigned getSelectedPage();
private:
void _setPreviewPage(unsigned page);
// Signal handlers
#if !WITH_GTKMM_3_0
#endif
void _onPageNumberChanged();
unsigned _current_page; // Current selected page
};
{
if ( num_pages <= 1 )
return;
// Page number
#if WITH_GTKMM_3_0
Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
#else
_pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
#endif
_labelSelect->set_line_wrap(false);
_labelSelect->set_use_markup(false);
_labelSelect->set_selectable(false);
_pageNumberSpin->set_numeric(true);
_pageNumberSpin->set_wrap(false);
_labelTotalPages->set_line_wrap(false);
_labelTotalPages->set_use_markup(false);
_labelTotalPages->set_selectable(false);
this->get_content_area()->set_homogeneous(false);
this->get_content_area()->set_spacing(0);
this->set_title(_("Page Selector"));
this->set_modal(true);
this->set_resizable(true);
this->property_destroy_with_parent().set_value(false);
cancelbutton->show();
_labelSelect->show();
_pageNumberSpin->show();
_labelTotalPages->show();
_previewArea->show();
// Connect signals
_pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
}
VsdImportDialog::~VsdImportDialog() {}
bool VsdImportDialog::showDialog()
{
show();
hide();
if ( b == Gtk::RESPONSE_OK ) {
return TRUE;
} else {
return FALSE;
}
}
unsigned VsdImportDialog::getSelectedPage()
{
return _current_page;
}
void VsdImportDialog::_onPageNumberChanged()
{
}
/**
* \brief Renders the given page's thumbnail
*/
{
SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
if (tmpPreviewArea) {
delete tmpPreviewArea;
}
_previewArea->show_now();
}
{
return NULL;
}
return NULL;
}
return NULL;
}
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");
}
unsigned page_num = 1;
// If only one page is present, import that one without bothering user
VsdImportDialog *dlg = 0;
if (inkscape_use_gui()) {
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->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit())));
}
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 :