summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorsu_v <suv-sf@users.sourceforge.net>2012-12-16 05:41:25 +0000
committer~suv <suv-sf@users.sourceforge.net>2012-12-16 05:41:25 +0000
commit7ec903c9898f872dbd9426ed7a62e1969fdb7be7 (patch)
treea306139e829118a83516af02279c9eafd3440eaa /src/extension
parentHershey Text: whitespace; py: docstring, modeline; inx: fix attribute value (diff)
parentTranslations.Spanish translation update by Lucas Vieites. (diff)
downloadinkscape-7ec903c9898f872dbd9426ed7a62e1969fdb7be7.tar.gz
inkscape-7ec903c9898f872dbd9426ed7a62e1969fdb7be7.zip
merge from trunk (r11955)
(bzr r11687.1.3)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/CMakeLists.txt4
-rw-r--r--src/extension/Makefile_insert1
-rw-r--r--src/extension/effect.h2
-rw-r--r--src/extension/implementation/implementation.h1
-rw-r--r--src/extension/init.cpp8
-rw-r--r--src/extension/input.cpp7
-rw-r--r--src/extension/input.h4
-rw-r--r--src/extension/internal/Makefile_insert21
-rw-r--r--src/extension/internal/cairo-png-out.cpp2
-rw-r--r--src/extension/internal/cairo-ps-out.cpp6
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp20
-rw-r--r--src/extension/internal/cairo-renderer.cpp28
-rw-r--r--src/extension/internal/cairo-renderer.h2
-rw-r--r--src/extension/internal/emf-win32-inout.cpp29
-rw-r--r--src/extension/internal/filter/color.h63
-rw-r--r--src/extension/internal/filter/paint.h51
-rw-r--r--src/extension/internal/latex-text-renderer.cpp7
-rw-r--r--src/extension/internal/latex-text-renderer.h4
-rw-r--r--src/extension/internal/odf.cpp2
-rw-r--r--src/extension/internal/pdf-input-cairo.cpp8
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp16
-rw-r--r--src/extension/internal/pdfinput/pdf-input.h4
-rw-r--r--src/extension/internal/svg.cpp2
-rw-r--r--src/extension/internal/vsd-input.cpp289
-rw-r--r--src/extension/internal/vsd-input.h54
-rw-r--r--src/extension/param/enum.cpp4
-rw-r--r--src/extension/param/float.cpp25
-rw-r--r--src/extension/param/int.cpp25
-rw-r--r--src/extension/param/radiobutton.cpp4
-rw-r--r--src/extension/prefdialog.cpp10
-rw-r--r--src/extension/system.cpp1
31 files changed, 543 insertions, 161 deletions
diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt
index 5761b1e8b..e1f04fa10 100644
--- a/src/extension/CMakeLists.txt
+++ b/src/extension/CMakeLists.txt
@@ -41,6 +41,7 @@ set(extension_SRC
internal/gdkpixbuf-input.cpp
internal/gimpgrad.cpp
internal/grid.cpp
+ internal/image-resolution.cpp
internal/latex-pstricks.cpp
internal/latex-pstricks-out.cpp
internal/odf.cpp
@@ -50,6 +51,7 @@ set(extension_SRC
internal/javafx-out.cpp
internal/svg.cpp
internal/svgz.cpp
+ internal/vsd-input.cpp
internal/filter/filter-all.cpp
internal/filter/filter-file.cpp
@@ -129,6 +131,7 @@ set(extension_SRC
internal/gdkpixbuf-input.h
internal/gimpgrad.h
internal/grid.h
+ internal/image-resolution.h
internal/javafx-out.h
internal/latex-pstricks-out.h
internal/latex-pstricks.h
@@ -141,6 +144,7 @@ set(extension_SRC
internal/pov-out.h
internal/svg.h
internal/svgz.h
+ internal/vsd-input.h
script/InkscapeScript.h
)
diff --git a/src/extension/Makefile_insert b/src/extension/Makefile_insert
index ffcee5f9a..4e75de13a 100644
--- a/src/extension/Makefile_insert
+++ b/src/extension/Makefile_insert
@@ -3,7 +3,6 @@
ink_common_sources += \
extension/extension.cpp \
extension/extension.h \
- extension/extension-forward.h \
extension/db.cpp \
extension/db.h \
extension/dependency.cpp \
diff --git a/src/extension/effect.h b/src/extension/effect.h
index bb36b9238..6616a23ec 100644
--- a/src/extension/effect.h
+++ b/src/extension/effect.h
@@ -67,7 +67,7 @@ class Effect : public Extension {
gchar const * image,
Effect * effect,
bool showPrefs) :
- Verb(id, _(name), _(tip), image),
+ Verb(id, _(name), _(tip), image, _("Extensions")),
_effect(effect),
_showPrefs(showPrefs),
_elip_name(NULL) {
diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h
index b0230b7c4..fb323cd78 100644
--- a/src/extension/implementation/implementation.h
+++ b/src/extension/implementation/implementation.h
@@ -104,6 +104,7 @@ public:
virtual bool check(Inkscape::Extension::Extension * /*module*/) { return true; }
virtual bool cancelProcessing () { return true; }
+ virtual bool wasCancelled () { return false; }
virtual void commitDocument () {}
// ----- Input functions -----
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index b0732568f..ac3c90421 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -53,6 +53,9 @@
#ifdef WITH_LIBWPG
#include "internal/wpg-input.h"
#endif
+#ifdef WITH_LIBVISIO
+#include "internal/vsd-input.h"
+#endif
#include "preferences.h"
#include "io/sys.h"
#ifdef WITH_DBUS
@@ -99,6 +102,8 @@
#include "internal/filter/filter.h"
+#include "init.h"
+
extern gboolean inkscape_app_use_gui( Inkscape::Application const *app );
namespace Inkscape {
@@ -183,6 +188,9 @@ init()
#ifdef WITH_LIBWPG
Internal::WpgInput::init();
#endif
+#ifdef WITH_LIBVISIO
+ Internal::VsdInput::init();
+#endif
/* Effects */
Internal::BlurEdge::init();
diff --git a/src/extension/input.cpp b/src/extension/input.cpp
index 1662ef073..5cef38009 100644
--- a/src/extension/input.cpp
+++ b/src/extension/input.cpp
@@ -152,6 +152,10 @@ Input::open (const gchar *uri)
SPDocument *const doc = imp->open(this, uri);
+ if (imp->wasCancelled()) {
+ throw Input::open_cancelled();
+ }
+
return doc;
}
@@ -227,8 +231,7 @@ Input::prefs (const gchar *uri)
delete dialog;
- if (response == Gtk::RESPONSE_OK) return true;
- return false;
+ return (response == Gtk::RESPONSE_OK);
}
} } /* namespace Inkscape, Extension */
diff --git a/src/extension/input.h b/src/extension/input.h
index 8b198495e..b01ffeb86 100644
--- a/src/extension/input.h
+++ b/src/extension/input.h
@@ -39,6 +39,10 @@ public:
virtual ~no_extension_found() throw() {}
const char *what() const throw() { return "No suitable input extension found"; }
};
+ struct open_cancelled : public std::exception {
+ virtual ~open_cancelled() throw() {}
+ const char *what() const throw() { return "Open was cancelled"; }
+ };
Input (Inkscape::XML::Node * in_repr,
Implementation::Implementation * in_imp);
diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert
index e9b11553b..1ea6caca9 100644
--- a/src/extension/internal/Makefile_insert
+++ b/src/extension/internal/Makefile_insert
@@ -4,7 +4,12 @@ if WITH_LIBWPG
ink_common_sources += \
extension/internal/wpg-input.cpp \
extension/internal/wpg-input.h
+endif
+if WITH_LIBVISIO
+ink_common_sources += \
+ extension/internal/vsd-input.cpp \
+ extension/internal/vsd-input.h
endif
if USE_IMAGE_MAGICK
@@ -127,12 +132,24 @@ ink_common_sources += \
extension/internal/latex-pstricks.h \
extension/internal/latex-pstricks-out.cpp \
extension/internal/latex-pstricks-out.h \
+ extension/internal/filter/bevels.h \
+ extension/internal/filter/blurs.h \
+ extension/internal/filter/bumps.h \
+ extension/internal/filter/color.h \
+ extension/internal/filter/distort.h \
+ extension/internal/filter/filter.h \
+ extension/internal/filter/image.h \
+ extension/internal/filter/morphology.h \
+ extension/internal/filter/overlays.h \
+ extension/internal/filter/paint.h \
+ extension/internal/filter/protrusions.h \
+ extension/internal/filter/shadows.h \
+ extension/internal/filter/textures.h \
+ extension/internal/filter/transparency.h \
extension/internal/filter/filter-all.cpp \
extension/internal/filter/filter-file.cpp \
extension/internal/filter/filter.cpp \
extension/internal/filter/filter.h \
- extension/internal/filter/drop-shadow.h \
- extension/internal/filter/snow.h \
extension/internal/emf-win32-print.h \
extension/internal/emf-win32-print.cpp \
extension/internal/emf-win32-inout.h \
diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp
index 4751a229a..956fcce9a 100644
--- a/src/extension/internal/cairo-png-out.cpp
+++ b/src/extension/internal/cairo-png-out.cpp
@@ -68,7 +68,7 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename)
ctx = renderer->createContext();
/* Render document */
- bool ret = renderer->setupDocument(ctx, doc, TRUE, NULL);
+ bool ret = renderer->setupDocument(ctx, doc, TRUE, 0., NULL);
if (ret) {
renderer->renderItem(ctx, base);
ctx->saveAsPng(filename);
diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp
index 605f0237c..8a39f4ea9 100644
--- a/src/extension/internal/cairo-ps-out.cpp
+++ b/src/extension/internal/cairo-ps-out.cpp
@@ -104,7 +104,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
bool ret = ctx->setPsTarget(filename);
if(ret) {
/* Render document */
- ret = renderer->setupDocument(ctx, doc, pageBoundingBox, base);
+ ret = renderer->setupDocument(ctx, doc, pageBoundingBox, 0., base);
if (ret) {
renderer->renderItem(ctx, base);
ret = ctx->finish();
@@ -192,7 +192,7 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con
// Create LaTeX file (if requested)
if (new_textToLaTeX) {
- ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, 0., false);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
@@ -272,7 +272,7 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co
// Create LaTeX file (if requested)
if (new_textToLaTeX) {
- ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, 0., false);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index 494ff1e8d..773109c77 100644
--- a/src/extension/internal/cairo-renderer-pdf-out.cpp
+++ b/src/extension/internal/cairo-renderer-pdf-out.cpp
@@ -39,6 +39,8 @@
#include <2geom/affine.h>
#include "document.h"
+#include "unit-constants.h"
+
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -57,7 +59,7 @@ bool CairoRendererPdfOutput::check(Inkscape::Extension::Extension * /*module*/)
static bool
pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level,
bool texttopath, bool omittext, bool filtertobitmap, int resolution,
- const gchar * const exportId, bool exportDrawing, bool exportCanvas)
+ const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px)
{
doc->ensureUpToDate();
@@ -99,7 +101,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
bool ret = ctx->setPdfTarget (filename);
if(ret) {
/* Render document */
- ret = renderer->setupDocument(ctx, doc, pageBoundingBox, base);
+ ret = renderer->setupDocument(ctx, doc, pageBoundingBox, bleedmargin_px, base);
if (ret) {
renderer->renderItem(ctx, base);
ret = ctx->finish();
@@ -191,16 +193,23 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
} catch(...) {
g_warning("Parameter <area> might not exist");
}
-
bool new_exportDrawing = !new_exportCanvas;
+ float new_bleedmargin_px = 0.;
+ try {
+ new_bleedmargin_px = mod->get_param_float("bleed") * PX_PER_MM;
+ }
+ catch(...) {
+ g_warning("Parameter <bleed> might not exist");
+ }
+
// Create PDF file
{
gchar * final_name;
final_name = g_strdup_printf("> %s", filename);
ret = pdf_render_document_to_file(doc, final_name, level,
new_textToPath, new_textToLaTeX, new_blurToBitmap, new_bitmapResolution,
- new_exportId, new_exportDrawing, new_exportCanvas);
+ new_exportId, new_exportDrawing, new_exportCanvas, new_bleedmargin_px);
g_free(final_name);
if (!ret)
@@ -209,7 +218,7 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
// Create LaTeX file (if requested)
if (new_textToLaTeX) {
- ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, true);
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, new_bleedmargin_px, true);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
@@ -246,6 +255,7 @@ CairoRendererPdfOutput::init (void)
"<option value=\"page\">" N_("Use document's page size") "</option>"
"<option value=\"drawing\">" N_("Use exported object's size") "</option>"
"</param>"
+ "<param name=\"bleed\" gui-text=\"" N_("Bleed/margin (mm)") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n"
"<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
"<output>\n"
"<extension>.pdf</extension>\n"
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index 09d69becb..0a3cff26a 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -604,7 +604,7 @@ void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item)
}
bool
-CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, SPItem *base)
+CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base)
{
// PLEASE note when making changes to the boundingbox and transform calculation, corresponding changes should be made to PDFLaTeXRenderer::setupDocument !!!
@@ -625,6 +625,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
}
d = *bbox;
}
+ d.expandBy(bleedmargin_px);
if (ctx->_vector_based_target) {
// convert from px to pt
@@ -638,16 +639,21 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
bool ret = ctx->setupSurface(ctx->_width, ctx->_height);
- if (ret && !pageBoundingBox)
- {
- double high = doc->getHeight();
- if (ctx->_vector_based_target)
- high *= PT_PER_PX;
-
- /// @fixme hardcoded dt2doc transform?
- Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
- (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
- ctx->transform(tp);
+ if (ret) {
+ if (pageBoundingBox) {
+ // translate to set bleed/margin
+ Geom::Affine tp( Geom::Translate( bleedmargin_px, bleedmargin_px ) );
+ ctx->transform(tp);
+ } else {
+ double high = doc->getHeight();
+ if (ctx->_vector_based_target)
+ high *= PT_PER_PX;
+
+ // this transform translates the export drawing to a virtual page (0,0)-(width,height)
+ Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
+ (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
+ ctx->transform(tp);
+ }
}
return ret;
diff --git a/src/extension/internal/cairo-renderer.h b/src/extension/internal/cairo-renderer.h
index 7fa7c7ff5..db3068fed 100644
--- a/src/extension/internal/cairo-renderer.h
+++ b/src/extension/internal/cairo-renderer.h
@@ -53,7 +53,7 @@ public:
/** Initializes the CairoRenderContext according to the specified
SPDocument. A set*Target function can only be called on the context
before setupDocument. */
- bool setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, SPItem *base);
+ bool setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base);
/** Traverses the object tree and invokes the render methods. */
void renderItem(CairoRenderContext *ctx, SPItem *item);
diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp
index 7593a4806..e9360a0ea 100644
--- a/src/extension/internal/emf-win32-inout.cpp
+++ b/src/extension/internal/emf-win32-inout.cpp
@@ -61,6 +61,8 @@ namespace Extension {
namespace Internal {
static float device_scale = DEVICESCALE;
+static float device_x;
+static float device_y;
static RECTL rc_old;
static bool clipset = false;
@@ -322,11 +324,11 @@ _pix_y_to_point(PEMF_CALLBACK_DATA d, double px)
static double
pix_to_x_point(PEMF_CALLBACK_DATA d, double px, double py)
{
- double ppx = _pix_x_to_point(d, px);
- double ppy = _pix_y_to_point(d, py);
+ double ppx = px * d->dc[d->level].worldTransform.eM11 + py * d->dc[d->level].worldTransform.eM21 + d->dc[d->level].worldTransform.eDx;
+ double x = _pix_x_to_point(d, ppx);
- double x = ppx * d->dc[d->level].worldTransform.eM11 + ppy * d->dc[d->level].worldTransform.eM21 + d->dc[d->level].worldTransform.eDx;
x *= device_scale;
+ x -= device_x;
return x;
}
@@ -334,11 +336,11 @@ pix_to_x_point(PEMF_CALLBACK_DATA d, double px, double py)
static double
pix_to_y_point(PEMF_CALLBACK_DATA d, double px, double py)
{
- double ppx = _pix_x_to_point(d, px);
- double ppy = _pix_y_to_point(d, py);
+ double ppy = px * d->dc[d->level].worldTransform.eM12 + py * d->dc[d->level].worldTransform.eM22 + d->dc[d->level].worldTransform.eDy;
+ double y = _pix_y_to_point(d, ppy);
- double y = ppx * d->dc[d->level].worldTransform.eM12 + ppy * d->dc[d->level].worldTransform.eM22 + d->dc[d->level].worldTransform.eDy;
y *= device_scale;
+ y -= device_y;
return y;
}
@@ -773,8 +775,10 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
d->xDPI = 2540;
d->yDPI = 2540;
- d->dc[d->level].PixelsInX = pEmr->rclFrame.right; // - pEmr->rclFrame.left;
- d->dc[d->level].PixelsInY = pEmr->rclFrame.bottom; // - pEmr->rclFrame.top;
+ d->dc[d->level].PixelsInX = pEmr->rclFrame.right - pEmr->rclFrame.left;
+ d->dc[d->level].PixelsInY = pEmr->rclFrame.bottom - pEmr->rclFrame.top;
+ device_x = pEmr->rclFrame.left/100.0*PX_PER_MM;
+ device_y = pEmr->rclFrame.top/100.0*PX_PER_MM;
d->MMX = d->dc[d->level].PixelsInX / 100.0;
d->MMY = d->dc[d->level].PixelsInY / 100.0;
@@ -1815,7 +1819,7 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
dbg_str << "<!-- EMR_BITBLT -->\n";
PEMRBITBLT pEmr = (PEMRBITBLT) lpEMFR;
- if (pEmr->dwRop == DPA) {
+ if ((pEmr->dwRop == PATCOPY) || (pEmr->dwRop == DPA)) {
// should be an application of a DIBPATTERNBRUSHPT, use a solid color instead
double l = pix_to_x_point( d, pEmr->xDest, pEmr->yDest);
double t = pix_to_y_point( d, pEmr->xDest, pEmr->yDest);
@@ -1905,6 +1909,10 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
(gchar *) g_utf16_to_utf8( (gunichar2 *) wide_text, pEmr->emrtext.nChars, NULL, NULL, NULL );
if (ansi_text) {
+ if ((wide_text[0] < 32) && (strlen(ansi_text) == 1)) {
+ g_free(ansi_text); // filter out isolated control characters
+ ansi_text = g_strdup("");
+ }
// gchar *p = ansi_text;
// while (*p) {
// if (*p < 32 || *p >= 127) {
@@ -2460,9 +2468,10 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
DWORD dwNeeded = GetEnhMetaFileDescriptionA( hemf, 0, NULL );
if ( dwNeeded > 0 ) {
d.pDesc = (CHAR *) malloc( dwNeeded + 1 );
+ d.pDesc[dwNeeded] = 0;
if ( GetEnhMetaFileDescription( hemf, dwNeeded, d.pDesc ) == 0 )
lstrcpy( d.pDesc, "" );
- if ( lstrlen( d.pDesc ) > 1 )
+ if ((lstrlen(d.pDesc) > 1) && (lstrlen(d.pDesc) < dwNeeded))
d.pDesc[lstrlen(d.pDesc)] = '#';
}
diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h
index b6b194c8b..785059cca 100644
--- a/src/extension/internal/filter/color.h
+++ b/src/extension/internal/filter/color.h
@@ -615,9 +615,8 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext)
Filter's parameters:
* Channel (enum, all colors, default Red) -> colormatrix (values)
- * Background blend (enum, all blend modes, default Multiply) -> blend (mode)
+ * Background blend (enum, Normal, Multiply, Screen, default Normal) -> blend (mode)
* Channel to alpha (boolean, default false) -> colormatrix (values)
- * Invert (boolean, default false) -> colormatrix (values)
*/
class ExtractChannel : public Inkscape::Extension::Internal::Filter::Filter {
@@ -637,16 +636,16 @@ public:
"<_item value=\"r\">" N_("Red") "</_item>\n"
"<_item value=\"g\">" N_("Green") "</_item>\n"
"<_item value=\"b\">" N_("Blue") "</_item>\n"
+ "<_item value=\"c\">" N_("Cyan") "</_item>\n"
+ "<_item value=\"m\">" N_("Magenta") "</_item>\n"
+ "<_item value=\"y\">" N_("Yellow") "</_item>\n"
"</param>\n"
"<param name=\"blend\" gui-text=\"" N_("Background blend mode:") "\" type=\"enum\">\n"
"<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
"<_item value=\"normal\">" N_("Normal") "</_item>\n"
"<_item value=\"screen\">" N_("Screen") "</_item>\n"
- "<_item value=\"darken\">" N_("Darken") "</_item>\n"
- "<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
"</param>\n"
"<param name=\"alpha\" gui-text=\"" N_("Channel to alpha") "\" type=\"boolean\">false</param>\n"
- "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
@@ -667,45 +666,45 @@ ExtractChannel::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream blend;
std::ostringstream colors;
- std::ostringstream alpha;
- std::ostringstream invert;
blend << ext->get_param_enum("blend");
const gchar *channel = ext->get_param_enum("source");
if (ext->get_param_bool("alpha")) {
- colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0";
- } else if ((g_ascii_strcasecmp("r", channel) == 0)) {
- colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 0";
- } else if ((g_ascii_strcasecmp("g", channel) == 0)) {
- colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 0";
- } else {
- colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 1";
- }
-
- if (ext->get_param_bool("invert")) {
if ((g_ascii_strcasecmp("r", channel) == 0)) {
- alpha << "-1 0 0 1";
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0";
} else if ((g_ascii_strcasecmp("g", channel) == 0)) {
- alpha << "0 -1 0 1";
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0";
+ } else if ((g_ascii_strcasecmp("b", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0";
+ } else if ((g_ascii_strcasecmp("c", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 1 0";
+ } else if ((g_ascii_strcasecmp("m", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 1 0";
} else {
- alpha << "0 0 -1 1";
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 0";
}
} else {
if ((g_ascii_strcasecmp("r", channel) == 0)) {
- alpha << "1 0 0 0";
+ colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0";
} else if ((g_ascii_strcasecmp("g", channel) == 0)) {
- alpha << "0 1 0 0";
+ colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0";
+ } else if ((g_ascii_strcasecmp("b", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0";
+ } else if ((g_ascii_strcasecmp("c", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 -1 0 0 1 0";
+ } else if ((g_ascii_strcasecmp("m", channel) == 0)) {
+ colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 -1 0 1 0";
} else {
- alpha << "0 0 1 0";
+ colors << "0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 -1 1 0";
}
}
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Extract Channel\">\n"
- "<feColorMatrix in=\"SourceGraphic\" values=\"%s %s %s 0 \" result=\"colormatrix\" />\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"%s 0 \" result=\"colormatrix\" />\n"
"<feBlend in2=\"BackgroundImage\" mode=\"%s\" result=\"blend\" />\n"
- "</filter>\n", colors.str().c_str(), alpha.str().c_str(), invert.str().c_str(), blend.str().c_str() );
+ "</filter>\n", colors.str().c_str(), blend.str().c_str() );
return _filter;
}; /* ExtractChannel filter */
@@ -1157,9 +1156,9 @@ LightnessContrast::get_filter_text (Inkscape::Extension::Extension * ext)
}; /* Lightness-Contrast filter */
/**
- \brief Custom predefined Nudge filter.
+ \brief Custom predefined Nudge RGB filter.
- Nudge separately RGB channels and blend them to different types of backgrounds
+ Nudge RGB channels separately and blend them to different types of backgrounds
Filter's parameters:
Offsets
@@ -1193,8 +1192,8 @@ public:
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Nudge") "</name>\n"
- "<id>org.inkscape.effect.filter.Nudge</id>\n"
+ "<name>" N_("Nudge RGB") "</name>\n"
+ "<id>org.inkscape.effect.filter.NudgeRGB</id>\n"
"<param name=\"tab\" type=\"notebook\">\n"
"<page name=\"offsettab\" _gui-text=\"Offset\">\n"
"<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Red offset") "</_param>\n"
@@ -1232,7 +1231,7 @@ public:
"<submenu name=\"" N_("Color") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
- "<menu-tip>" N_("Nudge separately RGB channels and blend them to different types of backgrounds") "</menu-tip>\n"
+ "<menu-tip>" N_("Nudge RGB channels separately and blend them to different types of backgrounds") "</menu-tip>\n"
"</effect>\n"
"</inkscape-extension>\n", new Nudge());
};
@@ -1277,7 +1276,7 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext)
a << (color & 0xff) / 255.0F;
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Nudge\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Nudge RGB\">\n"
"<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
"<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 \" result=\"colormatrix1\" />\n"
"<feOffset dy=\"%s\" dx=\"%s\" result=\"offset1\" />\n"
@@ -1297,7 +1296,7 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext)
return _filter;
-}; /* Nudge filter */
+}; /* Nudge RGB filter */
/**
\brief Custom predefined Quadritone filter.
diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h
index debdd7d79..ad396e08f 100644
--- a/src/extension/internal/filter/paint.h
+++ b/src/extension/internal/filter/paint.h
@@ -3,7 +3,7 @@
/* Change the 'PAINT' above to be your file name */
/*
- * Copyright (C) 2011 Authors:
+ * Copyright (C) 2012 Authors:
* Ivan Louette (filters)
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
*
@@ -563,13 +563,13 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext)
Filter's parameters:
* Lines type (enum, default smooth) ->
- smooth = component1 (type="table"), component2 (type="table"), composite1 (in2="blur2")
- hard = component1 (type="discrete"), component2 (type="discrete"), composite1 (in2="component1")
- * Simplify (0.01->20., default 1.5) -> blur1 (stdDeviation)
- * Line width (0.01->20., default 1.5) -> blur2 (stdDeviation)
- * Lightness (0.->10., default 0.5) -> composite1 (k3)
+ smooth = component2 (type="table"), composite1 (in2="blur2")
+ hard = component2 (type="discrete"), composite1 (in2="component1")
+ * Simplify (0.01->20., default 3) -> blur1 (stdDeviation)
+ * Line width (0.01->20., default 3) -> blur2 (stdDeviation)
+ * Lightness (0.->10., default 1) -> composite1 (k2)
* Blend (enum [normal, multiply, screen], default normal) -> blend (mode)
- * Dark mode (boolean, default false) -> composite1 (true: in2="component2")
+ * Dark mode (boolean, default false) -> composite2 (true: in2="component2")
*/
class NeonDraw : public Inkscape::Extension::Internal::Filter::Filter {
protected:
@@ -588,15 +588,14 @@ public:
"<_item value=\"table\">" N_("Smoothed") "</_item>\n"
"<_item value=\"discrete\">" N_("Contrasted") "</_item>\n"
"</param>\n"
- "<param name=\"simply\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1.5</param>\n"
- "<param name=\"width\" gui-text=\"" N_("Line width:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1.5</param>\n"
- "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">0.5</param>\n"
+ "<param name=\"simply\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n"
+ "<param name=\"width\" gui-text=\"" N_("Line width:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n"
+ "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">1</param>\n"
"<param name=\"blend\" gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n"
"<_item value=\"normal\">Normal</_item>\n"
"<_item value=\"multiply\">Multiply</_item>\n"
"<_item value=\"screen\">Screen</_item>\n"
"</param>\n"
- "<param name=\"dark\" gui-text=\"" N_("Dark mode") "\" type=\"boolean\" >false</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
@@ -620,7 +619,6 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream width;
std::ostringstream lightness;
std::ostringstream type;
- std::ostringstream dark;
type << ext->get_param_enum("type");
blend << ext->get_param_enum("blend");
@@ -628,33 +626,26 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext)
width << ext->get_param_float("width");
lightness << ext->get_param_float("lightness");
- const gchar *typestr = ext->get_param_enum("type");
- if (ext->get_param_bool("dark")) {
- dark << "component2";
- } else if ((g_ascii_strcasecmp("table", typestr) == 0)) {
- dark << "blur2";
- } else {
- dark << "component1";
- }
-
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Neon Draw\">\n"
"<feBlend mode=\"%s\" result=\"blend\" />\n"
"<feGaussianBlur in=\"blend\" stdDeviation=\"%s\" result=\"blur1\" />\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 50 0\" result=\"color1\" />\n"
"<feComponentTransfer result=\"component1\">\n"
- "<feFuncR type=\"discrete\" tableValues=\"0 0.3 0.6 1 1\" />\n"
- "<feFuncG type=\"discrete\" tableValues=\"0 0.3 0.6 1 1\" />\n"
- "<feFuncB type=\"discrete\" tableValues=\"0 0.3 0.6 1 1\" />\n"
+ "<feFuncR type=\"discrete\" tableValues=\"0 0.3 0.3 0.3 0.3 0.6 0.6 0.6 0.6 1 1\" />\n"
+ "<feFuncG type=\"discrete\" tableValues=\"0 0.3 0.3 0.3 0.3 0.6 0.6 0.6 0.6 1 1\" />\n"
+ "<feFuncB type=\"discrete\" tableValues=\"0 0.3 0.3 0.3 0.3 0.6 0.6 0.6 0.6 1 1\" />\n"
"</feComponentTransfer>\n"
"<feGaussianBlur in=\"component1\" stdDeviation=\"%s\" result=\"blur2\" />\n"
- "<feComponentTransfer in=\"blur2\" result=\"component2\">\n"
- "<feFuncR type=\"%s\" tableValues=\"0 1 0 1 0 1 0 1\" />\n"
- "<feFuncG type=\"%s\" tableValues=\"0 1 0 1 0 1 0 1\" />\n"
- "<feFuncB type=\"%s\" tableValues=\"0 1 0 1 0 1 0 1\" />\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 50 0\" result=\"color2\" />\n"
+ "<feComponentTransfer in=\"color2\" result=\"component2\">\n"
+ "<feFuncR type=\"%s\" tableValues=\"0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1\" />\n"
+ "<feFuncG type=\"%s\" tableValues=\"0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1\" />\n"
+ "<feFuncB type=\"%s\" tableValues=\"0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1\" />\n"
"</feComponentTransfer>\n"
- "<feComposite in=\"component2\" in2=\"%s\" k3=\"%s\" operator=\"arithmetic\" k2=\"1\" result=\"composite1\" />\n"
+ "<feComposite in=\"component2\" in2=\"blur2\" k3=\"%s\" operator=\"arithmetic\" k2=\"1\" result=\"composite1\" />\n"
"<feComposite in=\"composite1\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite2\" />\n"
- "</filter>\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), dark.str().c_str(), lightness.str().c_str());
+ "</filter>\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), lightness.str().c_str());
return _filter;
}; /* NeonDraw filter */
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index ebd73a033..ecc201733 100644
--- a/src/extension/internal/latex-text-renderer.cpp
+++ b/src/extension/internal/latex-text-renderer.cpp
@@ -56,7 +56,7 @@ namespace Internal {
*/
bool
latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
- const gchar * const exportId, bool exportDrawing, bool exportCanvas,
+ const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px,
bool pdflatex)
{
doc->ensureUpToDate();
@@ -84,7 +84,7 @@ latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
bool ret = renderer->setTargetFile(filename);
if (ret) {
/* Render document */
- bool ret = renderer->setupDocument(doc, pageBoundingBox, base);
+ bool ret = renderer->setupDocument(doc, pageBoundingBox, bleedmargin_px, base);
if (ret) {
renderer->renderItem(base);
}
@@ -569,7 +569,7 @@ LaTeXTextRenderer::renderItem(SPItem *item)
}
bool
-LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *base)
+LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base)
{
// The boundingbox calculation here should be exactly the same as the one by CairoRenderer::setupDocument !
@@ -588,6 +588,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *
}
d = *bbox;
}
+ d.expandBy(bleedmargin_px);
// scale all coordinates, such that the width of the image is 1, this is convenient for scaling the image in LaTeX
double scale = 1/(d.width());
diff --git a/src/extension/internal/latex-text-renderer.h b/src/extension/internal/latex-text-renderer.h
index 66055a3bc..0fa94c9e6 100644
--- a/src/extension/internal/latex-text-renderer.h
+++ b/src/extension/internal/latex-text-renderer.h
@@ -29,7 +29,7 @@ namespace Extension {
namespace Internal {
bool latex_render_document_text_to_file(SPDocument *doc, gchar const *filename,
- const gchar * const exportId, bool exportDrawing, bool exportCanvas,
+ const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px,
bool pdflatex);
class LaTeXTextRenderer {
@@ -41,7 +41,7 @@ public:
/** Initializes the LaTeXTextRenderer according to the specified
SPDocument. Important to set the boundingbox to the pdf boundingbox */
- bool setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *base);
+ bool setupDocument(SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base);
/** Traverses the object tree and invokes the render methods. */
void renderItem(SPItem *item);
diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp
index c8c187c77..0639ae8d0 100644
--- a/src/extension/internal/odf.cpp
+++ b/src/extension/internal/odf.cpp
@@ -969,7 +969,7 @@ static Geom::Affine getODFTransform(const SPItem *item)
static Geom::OptRect getODFBoundingBox(const SPItem *item)
{
// TODO: geometric or visual?
- Geom::OptRect bbox = ((SPItem *)item)->documentVisualBounds();
+ Geom::OptRect bbox = item->documentVisualBounds();
if (bbox) {
*bbox *= Geom::Affine(Geom::Scale(pxToCm));
}
diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp
index eee1b43bf..03b7c0a90 100644
--- a/src/extension/internal/pdf-input-cairo.cpp
+++ b/src/extension/internal/pdf-input-cairo.cpp
@@ -95,11 +95,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
_cropTypeCombo = Gtk::manage(new class Gtk::ComboBoxText());
int num_crop_choices = sizeof(crop_setting_choices) / sizeof(crop_setting_choices[0]);
for ( int i = 0 ; i < num_crop_choices ; i++ ) {
-#if WITH_GTKMM_2_24
_cropTypeCombo->append(_(crop_setting_choices[i]));
-#else
- _cropTypeCombo->append_text(_(crop_setting_choices[i]));
-#endif
}
_cropTypeCombo->set_active_text(_(crop_setting_choices[0]));
_cropTypeCombo->set_sensitive(false);
@@ -124,11 +120,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
// Text options
_labelText = Gtk::manage(new class Gtk::Label(_("Text handling:")));
_textHandlingCombo = Gtk::manage(new class Gtk::ComboBoxText());
-#if WITH_GTKMM_2_24
_textHandlingCombo->append(_("Import text as text"));
-#else
- _textHandlingCombo->append_text(_("Import text as text"));
-#endif
_textHandlingCombo->set_active_text(_("Import text as text"));
_localFontsCheck = Gtk::manage(new class Gtk::CheckButton(_("Replace PDF fonts by closest-named installed fonts")));
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 6b6107444..688e3f612 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -111,11 +111,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
_cropTypeCombo = Gtk::manage(new class Gtk::ComboBoxText());
int num_crop_choices = sizeof(crop_setting_choices) / sizeof(crop_setting_choices[0]);
for ( int i = 0 ; i < num_crop_choices ; i++ ) {
-#if WITH_GTKMM_2_24
_cropTypeCombo->append(_(crop_setting_choices[i]));
-#else
- _cropTypeCombo->append_text(_(crop_setting_choices[i]));
-#endif
}
_cropTypeCombo->set_active_text(_(crop_setting_choices[0]));
_cropTypeCombo->set_sensitive(false);
@@ -140,11 +136,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
// Text options
_labelText = Gtk::manage(new class Gtk::Label(_("Text handling:")));
_textHandlingCombo = Gtk::manage(new class Gtk::ComboBoxText());
-#if WITH_GTKMM_2_24
_textHandlingCombo->append(_("Import text as text"));
-#else
- _textHandlingCombo->append_text(_("Import text as text"));
-#endif
_textHandlingCombo->set_active_text(_("Import text as text"));
_localFontsCheck = Gtk::manage(new class Gtk::CheckButton(_("Replace PDF fonts by closest-named installed fonts")));
@@ -588,12 +580,19 @@ void PdfImportDialog::_setPreviewPage(int page) {
////////////////////////////////////////////////////////////////////////////////
+bool
+PdfInput::wasCancelled () {
+ return _cancelled;
+}
+
/**
* Parses the selected page of the given PDF document using PdfParser.
*/
SPDocument *
PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
+ _cancelled = false;
+
// Initialize the globalParams variable for poppler
if (!globalParams) {
globalParams = new GlobalParams();
@@ -648,6 +647,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
if (inkscape_use_gui()) {
dlg = new PdfImportDialog(pdf_doc, uri);
if (!dlg->showDialog()) {
+ _cancelled = true;
delete dlg;
delete pdf_doc;
return NULL;
diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h
index 75fcfa69a..e9da5b27c 100644
--- a/src/extension/internal/pdfinput/pdf-input.h
+++ b/src/extension/internal/pdfinput/pdf-input.h
@@ -135,7 +135,9 @@ public:
SPDocument *open( Inkscape::Extension::Input *mod,
const gchar *uri );
static void init( void );
-
+ virtual bool wasCancelled();
+private:
+ bool _cancelled;
};
} // namespace Implementation
diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp
index 9b1098afd..8b272af60 100644
--- a/src/extension/internal/svg.cpp
+++ b/src/extension/internal/svg.cpp
@@ -44,7 +44,7 @@ using Inkscape::XML::Node;
-void pruneExtendedAttributes( Inkscape::XML::Node *repr )
+static void pruneExtendedAttributes( Inkscape::XML::Node *repr )
{
if (repr) {
if ( repr->type() == Inkscape::XML::ELEMENT_NODE ) {
diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp
new file mode 100644
index 000000000..6d71ce72a
--- /dev/null
+++ b/src/extension/internal/vsd-input.cpp
@@ -0,0 +1,289 @@
+/*
+ * 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 <gtkmm/frame.h>
+#include <gtkmm/scale.h>
+
+#include "extension/system.h"
+#include "extension/input.h"
+#include "document.h"
+
+#include "document-private.h"
+#include "document-undo.h"
+#include "inkscape.h"
+
+#include "dialogs/dialog-events.h"
+#include <gtk/gtk.h>
+#include "ui/widget/spinbutton.h"
+#include "ui/widget/frame.h"
+#include <glibmm/i18n.h>
+
+#include <gdkmm/general.h>
+
+#include "svg-view.h"
+#include "svg-view-widget.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+
+class VsdImportDialog : public Gtk::Dialog {
+public:
+ VsdImportDialog(const std::vector<WPXString> &vec);
+ virtual ~VsdImportDialog();
+
+ bool showDialog();
+ unsigned getSelectedPage();
+ void getImportSettings(Inkscape::XML::Node *prefs);
+
+private:
+ void _setPreviewPage(unsigned page);
+
+ // Signal handlers
+#if !WITH_GTKMM_3_0
+ bool _onExposePreview(GdkEventExpose *event);
+#endif
+
+ void _onPageNumberChanged();
+
+ class Gtk::Button * cancelbutton;
+ class Gtk::Button * okbutton;
+ class Gtk::Label * _labelSelect;
+ class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
+ class Gtk::Label * _labelTotalPages;
+ class Gtk::VBox * vbox1;
+ class Gtk::VBox * vbox2;
+ class Gtk::Widget * _previewArea;
+
+ const std::vector<WPXString> &_vec; // Document to be imported
+ unsigned _current_page; // Current selected page
+ int _preview_width, _preview_height; // Size of the preview area
+};
+
+VsdImportDialog::VsdImportDialog(const std::vector<WPXString> &vec)
+ : _vec(vec), _current_page(1)
+{
+ int num_pages = _vec.size();
+ if ( num_pages <= 1 )
+ return;
+ cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+ okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+ _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
+
+ // Page number
+#if WITH_GTKMM_3_0
+ Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
+ _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
+#else
+ Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
+ new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
+ _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
+#endif
+ _labelTotalPages = Gtk::manage(new class Gtk::Label());
+ gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
+ _labelTotalPages->set_label(label_text);
+ g_free(label_text);
+
+ vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
+ _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
+
+ vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
+ cancelbutton->set_can_focus();
+ cancelbutton->set_can_default();
+ cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
+ okbutton->set_can_focus();
+ okbutton->set_can_default();
+ okbutton->set_relief(Gtk::RELIEF_NORMAL);
+ this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
+ _labelSelect->set_line_wrap(false);
+ _labelSelect->set_use_markup(false);
+ _labelSelect->set_selectable(false);
+ _pageNumberSpin->set_can_focus();
+ _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
+ _pageNumberSpin->set_numeric(true);
+ _pageNumberSpin->set_digits(0);
+ _pageNumberSpin->set_wrap(false);
+ _labelTotalPages->set_line_wrap(false);
+ _labelTotalPages->set_use_markup(false);
+ _labelTotalPages->set_selectable(false);
+ vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ this->get_vbox()->set_homogeneous(false);
+ this->get_vbox()->set_spacing(0);
+ this->get_vbox()->pack_start(*vbox2);
+ this->set_title(_("Page Selector"));
+ this->set_modal(true);
+ sp_transientize((GtkWidget *)this->gobj()); //Make transient
+ this->property_window_position().set_value(Gtk::WIN_POS_NONE);
+ this->set_resizable(true);
+ this->property_destroy_with_parent().set_value(false);
+ this->get_action_area()->add(*_labelSelect);
+ this->add_action_widget(*_pageNumberSpin, -7);
+ this->get_action_area()->add(*_labelTotalPages);
+ this->add_action_widget(*cancelbutton, -6);
+ this->add_action_widget(*okbutton, -5);
+ cancelbutton->show();
+ okbutton->show();
+ _labelSelect->show();
+ _pageNumberSpin->show();
+ _labelTotalPages->show();
+ vbox1->show();
+ _previewArea->show();
+ vbox2->show();
+
+ // Connect signals
+ _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
+}
+
+VsdImportDialog::~VsdImportDialog() {}
+
+bool VsdImportDialog::showDialog()
+{
+ show();
+ gint b = run();
+ hide();
+ if ( b == Gtk::RESPONSE_OK ) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+unsigned VsdImportDialog::getSelectedPage()
+{
+ return _current_page;
+}
+
+void VsdImportDialog::_onPageNumberChanged()
+{
+ int page = _pageNumberSpin->get_value_as_int();
+ _current_page = CLAMP(page, 1, _vec.size());
+ _setPreviewPage(_current_page);
+}
+
+/**
+ * \brief Renders the given page's thumbnail
+ */
+void VsdImportDialog::_setPreviewPage(unsigned page)
+{
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
+ Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
+ std::swap(_previewArea, tmpPreviewArea);
+ if (tmpPreviewArea) {
+ _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
+ delete tmpPreviewArea;
+ }
+ vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ _previewArea->show_now();
+}
+
+SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri)
+{
+ WPXFileStream input(uri);
+
+ if (!libvisio::VisioDocument::isSupported(&input)) {
+ return NULL;
+ }
+
+ libvisio::VSDStringVector output;
+ if (!libvisio::VisioDocument::generateSVG(&input, output)) {
+ return NULL;
+ }
+
+ if (output.empty()) {
+ return NULL;
+ }
+
+ std::vector<WPXString> tmpSVGOutput;
+ for (unsigned i=0; i<output.size(); ++i) {
+ 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");
+ tmpString.append(output[i]);
+ tmpSVGOutput.push_back(tmpString);
+ }
+
+ unsigned page_num = 1;
+
+ // If only one page is present, import that one without bothering user
+ if (tmpSVGOutput.size() > 1) {
+ VsdImportDialog *dlg = 0;
+ if (inkscape_use_gui()) {
+ dlg = new VsdImportDialog(tmpSVGOutput);
+ if (!dlg->showDialog()) {
+ delete dlg;
+ return NULL;
+ }
+ }
+
+ // Get needed page
+ if (dlg) {
+ page_num = dlg->getSelectedPage();
+ if (page_num < 1)
+ page_num = 1;
+ if (page_num > tmpSVGOutput.size())
+ page_num = tmpSVGOutput.size();
+ }
+ }
+
+ SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
+ return doc;
+}
+
+#include "clear-n_.h"
+
+void VsdInput::init(void)
+{
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("VSD Input") "</name>\n"
+ "<id>org.inkscape.input.vsd</id>\n"
+ "<input>\n"
+ "<extension>.vsd</extension>\n"
+ "<mimetype>application/vnd.visio</mimetype>\n"
+ "<filetypename>" N_("Microsoft Visio Diagram (*.vsd)") "</filetypename>\n"
+ "<filetypetooltip>" N_("File format used by Microsoft Visio 6 and later") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new VsdInput());
+} // 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 :
diff --git a/src/extension/internal/vsd-input.h b/src/extension/internal/vsd-input.h
new file mode 100644
index 000000000..acc52debf
--- /dev/null
+++ b/src/extension/internal/vsd-input.h
@@ -0,0 +1,54 @@
+/*
+ * This code abstracts the libwpg interfaces into the Inkscape
+ * input extension interface.
+ *
+ * Authors:
+ * Fridrich Strba (fridrich.strba@bluewin.ch)
+ *
+ * Copyright (C) 2012 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef __EXTENSION_INTERNAL_VSDOUTPUT_H__
+#define __EXTENSION_INTERNAL_VSDOUTPUT_H__
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef WITH_LIBVISIO
+
+#include <gtkmm/dialog.h>
+
+#include "../implementation/implementation.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+class VsdInput : public Inkscape::Extension::Implementation::Implementation {
+ VsdInput () { };
+public:
+ SPDocument *open( Inkscape::Extension::Input *mod,
+ const gchar *uri );
+ static void init( void );
+
+};
+
+} } } /* namespace Inkscape, Extension, Implementation */
+
+#endif /* WITH_LIBVISIO */
+#endif /* __EXTENSION_INTERNAL_VSDOUTPUT_H__ */
+
+
+/*
+ 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 :
diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp
index b1968a4d6..18a73beb6 100644
--- a/src/extension/param/enum.cpp
+++ b/src/extension/param/enum.cpp
@@ -242,11 +242,7 @@ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * n
for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
enumentry * entr = reinterpret_cast<enumentry *>(list->data);
Glib::ustring text = entr->guitext;
-#if WITH_GTKMM_2_24
combo->append(text);
-#else
- combo->append_text(text);
-#endif
if ( _value && !entr->value.compare(_value) ) {
settext = entr->guitext;
diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp
index b9ffe68d2..81508f6c0 100644
--- a/src/extension/param/float.cpp
+++ b/src/extension/param/float.cpp
@@ -14,6 +14,7 @@
#include <gtkmm/box.h>
#include <gtkmm/scale.h>
#include "ui/widget/spinbutton.h"
+#include "ui/widget/spin-scale.h"
#include "xml/node.h"
#include "extension/extension.h"
@@ -175,9 +176,6 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod
}
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
- Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
- label->show();
- hbox->pack_start(*label, true, true, _indent);
#if WITH_GTKMM_3_0
ParamFloatAdjustment * pfa = new ParamFloatAdjustment(this, doc, node, changeSignal);
@@ -187,24 +185,27 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod
#endif
if (_mode == FULL) {
-#if WITH_GTKMM_3_0
- Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(fadjust));
-#else
- Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust));
-#endif
- scale->set_draw_value(false);
- scale->set_size_request(200, -1);
+
+ UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_(_text), fadjust, _precision);
+ scale->set_size_request(400, -1);
scale->show();
hbox->pack_start(*scale, false, false);
+
}
+ else if (_mode == MINIMAL) {
+
+ Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
+ label->show();
+ hbox->pack_start(*label, true, true, _indent);
#if WITH_GTKMM_3_0
Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 0.1, _precision));
#else
Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 0.1, _precision));
#endif
- spin->show();
- hbox->pack_start(*spin, false, false);
+ spin->show();
+ hbox->pack_start(*spin, false, false);
+ }
hbox->show();
diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp
index 7cb930f50..c286018fd 100644
--- a/src/extension/param/int.cpp
+++ b/src/extension/param/int.cpp
@@ -14,6 +14,7 @@
#include <gtkmm/box.h>
#include <gtkmm/scale.h>
#include "ui/widget/spinbutton.h"
+#include "ui/widget/spin-scale.h"
#include "xml/node.h"
#include "extension/extension.h"
@@ -156,9 +157,7 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal
}
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
- Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
- label->show();
- hbox->pack_start(*label, true, true, _indent);
+
#if WITH_GTKMM_3_0
ParamIntAdjustment * pia = new ParamIntAdjustment(this, doc, node, changeSignal);
@@ -168,24 +167,26 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal
#endif
if (_mode == FULL) {
-#if WITH_GTKMM_3_0
- Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(fadjust));
-#else
- Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust));
-#endif
- scale->set_draw_value(false);
- scale->set_size_request(200, -1);
+
+ UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_(_text), fadjust, 0);
+ scale->set_size_request(400, -1);
scale->show();
hbox->pack_start(*scale, false, false);
}
+ else if (_mode == MINIMAL) {
+ Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
+ label->show();
+ hbox->pack_start(*label, true, true, _indent);
+
#if WITH_GTKMM_3_0
Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 1.0, 0));
#else
Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 1.0, 0));
#endif
- spin->show();
- hbox->pack_start(*spin, false, false);
+ spin->show();
+ hbox->pack_start(*spin, false, false);
+ }
hbox->show();
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp
index 5b5e179d2..921c322b6 100644
--- a/src/extension/param/radiobutton.cpp
+++ b/src/extension/param/radiobutton.cpp
@@ -305,11 +305,7 @@ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node
switch ( _mode ) {
case MINIMAL:
{
-#if WITH_GTKMM_2_24
cbt->append(*text);
-#else
- cbt->append_text(*text);
-#endif
if (!entr->value->compare(_value)) {
cbt->set_active_text(*text);
comboSet = true;
diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp
index 94f128a42..2d2604c7f 100644
--- a/src/extension/prefdialog.cpp
+++ b/src/extension/prefdialog.cpp
@@ -32,13 +32,13 @@ namespace Extension {
/** \brief Creates a new preference dialog for extension preferences
- \param name Name of the Extension who's dialog this is
+ \param name Name of the Extension whose dialog this is
\param help The help string for the extension (NULL if none)
\param controls The extension specific widgets in the dialog
This function initializes the dialog with the name of the extension
in the title. It adds a few buttons and sets up handlers for
- them. It also places the passed in widgets into the dialog.
+ them. It also places the passed-in widgets into the dialog.
*/
PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls, Effect * effect) :
#if WITH_GTKMM_3_0
@@ -102,12 +102,10 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co
Gtk::Box * hbox = dynamic_cast<Gtk::Box *>(_button_preview);
if (hbox != NULL) {
#if WITH_GTKMM_3_0
- Gtk::Widget * back = hbox->get_children().back();
+ _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->get_children().front());
#else
- Gtk::Widget * back = hbox->children().back().get_widget();
+ _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->children().back().get_widget());
#endif
- Gtk::CheckButton * cb = dynamic_cast<Gtk::CheckButton *>(back);
- _checkbox_preview = cb;
}
preview_toggle();
diff --git a/src/extension/system.cpp b/src/extension/system.cpp
index fc20095c5..7fb6e1591 100644
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
@@ -144,6 +144,7 @@ SPDocument *open(Extension *key, gchar const *filename)
}
SPDocument *doc = imod->open(filename);
+
if (!doc) {
throw Input::open_failed();
}