Code

Added --export-area-canvas (-C).
authoracspike <acspike@users.sourceforge.net>
Sun, 26 Mar 2006 14:30:49 +0000 (14:30 +0000)
committeracspike <acspike@users.sourceforge.net>
Sun, 26 Mar 2006 14:30:49 +0000 (14:30 +0000)
Area specifying options (--export-area, --export-area-canvas and --export-area-drawing) can now be used in combination with --export-id.

ChangeLog
inkscape.pod
src/main.cpp

index 8def88483804f1f4d99aa14ccc832df2f03c4cd0..3ac7e76411f862a4b644f3c8437c3270594e7ccc 100644 (file)
--- 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,
index 6d101b997fc3ce705e9b70084eb440a7f4a90166..429b598170f6b72d105caf54c718ea82fe231cc9 100644 (file)
@@ -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>
 
index 32a4b6f94350b3966dcff0784a35de8b386aa6e6..fdfa3aa7bb1f57eaa42c96d2138979a505eb3f32 100644 (file)
@@ -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;