/*
* 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>
// TODO: Drop this check when librevenge is widespread.
#if WITH_LIBCDR01
#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 ~CdrImportDialog();
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, &CdrImportDialog::_onPageNumberChanged));
_pageNumberSpin->signal_button_press_event().connect_notify(sigc::mem_fun(*this, &CdrImportDialog::_onSpinButtonPress));
_pageNumberSpin->signal_button_release_event().connect_notify(sigc::mem_fun(*this, &CdrImportDialog::_onSpinButtonRelease));
}
CdrImportDialog::~CdrImportDialog() {}
{
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_LIBCDR01
#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"
{
/* 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 :