summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Spike <aaron@ekips.org>2006-03-26 14:30:49 +0000
committeracspike <acspike@users.sourceforge.net>2006-03-26 14:30:49 +0000
commitdcb7772e96c7fff041e300dfa4f9475966590f05 (patch)
tree6f53878d7116c1995f0696e5e0a6d6e1c497ce77
parentmost of region selection completed (diff)
downloadinkscape-dcb7772e96c7fff041e300dfa4f9475966590f05.tar.gz
inkscape-dcb7772e96c7fff041e300dfa4f9475966590f05.zip
Added --export-area-canvas (-C).
Area specifying options (--export-area, --export-area-canvas and --export-area-drawing) can now be used in combination with --export-id. (bzr r300)
-rw-r--r--ChangeLog8
-rw-r--r--inkscape.pod7
-rw-r--r--src/main.cpp33
3 files changed, 38 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 8def88483..3ac7e7641 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-03-26 Aaron C. Spike <aaron@ekips.org>
+
+ * inkscape.pod, src/main.cpp:
+
+ Added --export-area-canvas (-C). Area specifying options
+ (--export-area, --export-area-canvas and --export-area-drawing)
+ can now be used in combination with --export-id.
+
2006-03-10 Jon A. Cruz <jon@joncruz.org>
* src/dialogs/eek-color-def.cpp, src/dialogs/eek-color-def.h,
diff --git a/inkscape.pod b/inkscape.pod
index 6d101b997..429b59817 100644
--- a/inkscape.pod
+++ b/inkscape.pod
@@ -18,6 +18,7 @@ options:
-e, --export-png=FILENAME
-a, --export-area=x0:y0:x1:y1
+ -C, --export-area-canvas
-D, --export-area-drawing
--export-area-snap
-i, --export-id=ID
@@ -96,6 +97,10 @@ In PNG export, set the exported area in SVG user units (anonymous length units n
in Inkscape SVG). The default is to export the entire document canvas. The point (0,0)
is the lower-left corner.
+=item B<-C>, B<--export-area-canvas>
+
+In PNG export, exported area is the entire canvas.
+
=item B<-D>, B<--export-area-drawing>
In PNG export, exported area is the entire drawing (not canvas), i.e. the bounding box
@@ -146,7 +151,7 @@ This value overrides the --export-dpi setting (or the DPI hint if used with --ex
=item B<-i> I<ID>, B<--export-id>=I<ID>
The id attribute value of the object that you want to export from the document.
-Exported is the bounding box of the object, so with this option, --export-area is ignored.
+By default the exported area is the bounding box of the object.
=item B<-j>, B<--export-id-only>
diff --git a/src/main.cpp b/src/main.cpp
index 32a4b6f94..fdfa3aa7b 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -118,6 +118,7 @@ enum {
SP_ARG_EXPORT_DPI,
SP_ARG_EXPORT_AREA,
SP_ARG_EXPORT_AREA_DRAWING,
+ SP_ARG_EXPORT_AREA_CANVAS,
SP_ARG_EXPORT_AREA_SNAP,
SP_ARG_EXPORT_WIDTH,
SP_ARG_EXPORT_HEIGHT,
@@ -157,6 +158,7 @@ static gchar *sp_export_png = NULL;
static gchar *sp_export_dpi = NULL;
static gchar *sp_export_area = NULL;
static gboolean sp_export_area_drawing = FALSE;
+static gboolean sp_export_area_canvas = FALSE;
static gchar *sp_export_width = NULL;
static gchar *sp_export_height = NULL;
static gchar *sp_export_id = NULL;
@@ -232,6 +234,11 @@ struct poptOption options[] = {
N_("Exported area is the entire drawing (not canvas)"),
NULL},
+ {"export-area-canvas", 'C',
+ POPT_ARG_NONE, &sp_export_area_canvas, SP_ARG_EXPORT_AREA_CANVAS,
+ N_("Exported area is the entire canvas"),
+ NULL},
+
{"export-area-snap", 0,
POPT_ARG_NONE, &sp_export_area_snap, SP_ARG_EXPORT_AREA_SNAP,
N_("Snap the bitmap export area outwards to the nearest integer values (in SVG user units)"),
@@ -249,7 +256,7 @@ struct poptOption options[] = {
{"export-id", 'i',
POPT_ARG_STRING, &sp_export_id, SP_ARG_EXPORT_ID,
- N_("The ID of the object to export (overrides export-area)"),
+ N_("The ID of the object to export"),
N_("ID")},
{"export-id-only", 'j',
@@ -424,6 +431,8 @@ main(int argc, char **argv)
|| !strcmp(argv[i], "-i")
|| !strncmp(argv[i], "--export-area-drawing", 21)
|| !strcmp(argv[i], "-D")
+ || !strncmp(argv[i], "--export-area-canvas", 20)
+ || !strcmp(argv[i], "-C")
|| !strncmp(argv[i], "--export-id", 12)
|| !strcmp(argv[i], "-P")
|| !strncmp(argv[i], "--export-ps", 11)
@@ -773,16 +782,20 @@ sp_do_export_png(SPDocument *doc)
o = doc->getObjectById(sp_export_id);
} else if (sp_export_area_drawing) {
o = SP_DOCUMENT_ROOT (doc);
- }
-
+ }
+
+ SPObject *o_area = NULL;
+ if (sp_export_area_drawing) {
+ o_area = SP_DOCUMENT_ROOT (doc);
+ } else if (sp_export_id) {
+ o_area = doc->getObjectById(sp_export_id);
+ }
+
if (o) {
if (!SP_IS_ITEM (o)) {
g_warning("Object with id=\"%s\" is not a visible item. Nothing exported.", sp_export_id);
return;
}
- if (sp_export_area) {
- g_warning ("Object with id=\"%s\" is being exported; --export-area is ignored.", sp_export_id);
- }
items = g_slist_prepend (items, SP_ITEM(o));
@@ -822,12 +835,14 @@ sp_do_export_png(SPDocument *doc)
// write object bbox to area
sp_document_ensure_up_to_date (doc);
- sp_item_invoke_bbox((SPItem *) o, &area, sp_item_i2r_affine((SPItem *) o), TRUE);
+ sp_item_invoke_bbox((SPItem *) o_area, &area, sp_item_i2r_affine((SPItem *) o_area), TRUE);
} else {
g_warning("Object with id=\"%s\" was not found in the document. Nothing exported.", sp_export_id);
return;
}
- } else if (sp_export_area) {
+ }
+
+ if (sp_export_area) {
/* Try to parse area (given in SVG pixels) */
if (!sscanf(sp_export_area, "%lg:%lg:%lg:%lg", &area.x0, &area.y0, &area.x1, &area.y1) == 4) {
g_warning("Cannot parse export area '%s'; use 'x0:y0:x1:y1'. Nothing exported.", sp_export_area);
@@ -837,7 +852,7 @@ sp_do_export_png(SPDocument *doc)
g_warning("Export area '%s' has negative width or height. Nothing exported.", sp_export_area);
return;
}
- } else {
+ } else if (sp_export_area_canvas || !(sp_export_id || sp_export_area_drawing)) {
/* Export the whole canvas */
sp_document_ensure_up_to_date (doc);
area.x0 = SP_ROOT(doc->root)->x.computed;