cdr-input.cpp revision 28c3a9de9a8b7b5f345447ef581218d2b7751cb7
/*
* 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 "cdr-input.h"
#ifdef WITH_LIBCDR
#include <string>
#include <cstring>
#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 ~CdrImportDialog();
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_vbox()->set_homogeneous(false);
this->get_vbox()->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, &CdrImportDialog::_onPageNumberChanged));
}
CdrImportDialog::~CdrImportDialog() {}
bool CdrImportDialog::showDialog()
{
show();
hide();
if ( b == Gtk::RESPONSE_OK ) {
return TRUE;
} else {
return FALSE;
}
}
unsigned CdrImportDialog::getSelectedPage()
{
return _current_page;
}
void CdrImportDialog::_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
CdrImportDialog *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"
{
/* CDR */
"<id>org.inkscape.input.cdr</id>\n"
"<input>\n"
"<extension>.cdr</extension>\n"
"</input>\n"
"</inkscape-extension>", new CdrInput());
/* CDT */
"<id>org.inkscape.input.cdt</id>\n"
"<input>\n"
"<extension>.cdt</extension>\n"
"<mimetype>application/x-xcdt</mimetype>\n"
"</input>\n"
"</inkscape-extension>", new CdrInput());
/* CCX */
"<id>org.inkscape.input.ccx</id>\n"
"<input>\n"
"<extension>.ccx</extension>\n"
"<mimetype>application/x-xccx</mimetype>\n"
"</input>\n"
"</inkscape-extension>", new CdrInput());
/* CMX */
"<id>org.inkscape.input.cmx</id>\n"
"<input>\n"
"<extension>.cmx</extension>\n"
"<mimetype>application/x-xcmx</mimetype>\n"
"<filetypetooltip>" N_("Open presentation exchange files saved in Corel DRAW") "</filetypetooltip>\n"
"</input>\n"
"</inkscape-extension>", new CdrInput());
return;
} // init
} } } /* namespace Inkscape, Extension, Implementation */
#endif /* WITH_LIBCDR */
/*
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 :