Code

change API: separate functions creating a blur filter, one for a given item, another...
[inkscape.git] / src / dialogs / export.cpp
index 9d50018e9c6d1e9b3780663b4920f992be0416c3..720cebbedc0efbba201efc66060ec85a54dd2eab 100644 (file)
@@ -54,6 +54,8 @@
 
 #include "io/sys.h"
 
+#include "helper/png-write.h"
+
 
 #define SP_EXPORT_MIN_SIZE 1.0
 
@@ -530,7 +532,7 @@ sp_export_dialog (void)
                 Gtk::Button *b = new Gtk::Button();
 
                 Gtk::HBox* pixlabel = new Gtk::HBox(false, 3);
-                Gtk::Image *im = new Gtk::Image(Gtk::StockID(Gtk::Stock::DIRECTORY),
+                Gtk::Image *im = new Gtk::Image(Gtk::StockID(Gtk::Stock::INDEX),
                         Gtk::ICON_SIZE_BUTTON);
                 pixlabel->pack_start(*im);
 
@@ -684,12 +686,15 @@ sp_export_selection_modified ( Inkscape::Application *inkscape,
         case SELECTION_DRAWING:
             if ( SP_ACTIVE_DESKTOP ) {
                 SPDocument *doc;
-                NRRect bbox;
                 doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
-                sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)), &bbox);
+                NR::Rect bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)));
 
-                if (!(bbox.x0 > bbox.x1 && bbox.y0 > bbox.y1)) {
-                    sp_export_set_area (base, bbox.x0, bbox.y0, bbox.x1, bbox.y1);
+                if (!(bbox.min()[NR::X] > bbox.max()[NR::X] &&
+                      bbox.min()[NR::Y] > bbox.max()[NR::Y])) {
+                    sp_export_set_area (base, bbox.min()[NR::X],
+                                              bbox.min()[NR::Y],
+                                              bbox.max()[NR::X],
+                                              bbox.max()[NR::Y]);
                 }
             }
             break;
@@ -743,7 +748,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base)
     if ( SP_ACTIVE_DESKTOP )
     {
         SPDocument *doc;
-        NRRect bbox;
+        NR::Rect bbox;
         doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
 
         /* Notice how the switch is used to 'fall through' here to get
@@ -753,7 +758,7 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base)
             case SELECTION_SELECTION:
                 if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false)
                 {
-                    (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds(&bbox);
+                    bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds();
                     /* Only if there is a selection that we can set
                        do we break, otherwise we fall through to the
                        drawing */
@@ -765,20 +770,21 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base)
                 /** \todo 
                  * This returns wrong values if the document has a viewBox.
                  */
-                sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)), &bbox);
+                bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)));
                 
                 /* If the drawing is valid, then we'll use it and break
                    otherwise we drop through to the page settings */
-                if (!(bbox.x0 > bbox.x1 && bbox.y0 > bbox.y1)) { 
+                if (!(bbox.min()[NR::X] > bbox.max()[NR::X] &&
+                      bbox.min()[NR::Y] > bbox.max()[NR::Y])) { 
                     // std::cout << "Using selection: DRAWING" << std::endl;
                     key = SELECTION_DRAWING;
                     break;
                 }
             case SELECTION_PAGE:
-                bbox.x0 = 0.0;
-                bbox.y0 = 0.0;
-                bbox.x1 = sp_document_width (doc);
-                bbox.y1 = sp_document_height (doc);
+                bbox = NR::Rect(NR::Point(0.0, 0.0), 
+                                NR::Point(sp_document_width(doc), sp_document_height(doc))
+                                );
+
                 // std::cout << "Using selection: PAGE" << std::endl;
                 key = SELECTION_PAGE;
                 break;
@@ -792,7 +798,10 @@ sp_export_area_toggled (GtkToggleButton *tb, GtkObject *base)
                                      "value", selection_names[key]);
 
         if (key != SELECTION_CUSTOM) {
-            sp_export_set_area (base, bbox.x0, bbox.y0, bbox.x1, bbox.y1);
+            sp_export_set_area (base, bbox.min()[NR::X],
+                                      bbox.min()[NR::Y],
+                                      bbox.max()[NR::X],
+                                      bbox.max()[NR::Y]);
         }
     
     } // end of if ( SP_ACTIVE_DESKTOP )
@@ -1063,7 +1072,7 @@ sp_export_export_clicked (GtkButton *button, GtkObject *base)
     
     /* Do export */
     if (!sp_export_png_file (sp_desktop_document (SP_ACTIVE_DESKTOP), filename, 
-                             x0, y0, x1, y1, width, height, 
+                             x0, y0, x1, y1, width, height, xdpi, ydpi, 
                              nv->pagecolor, 
                              sp_export_progress_callback, base)) {
         gchar * error;
@@ -1089,26 +1098,26 @@ sp_export_export_clicked (GtkButton *button, GtkObject *base)
         case SELECTION_DRAWING: {
             SPDocument * doc = SP_ACTIVE_DOCUMENT;
             Inkscape::XML::Node * repr = sp_document_repr_root(doc);
-            bool modified = FALSE;
+            bool modified = false;
             const gchar * temp_string;
 
             bool saved = sp_document_get_undo_sensitive(doc);
-            sp_document_set_undo_sensitive(doc, FALSE);
+            sp_document_set_undo_sensitive(doc, false);
 
             temp_string = repr->attribute("inkscape:export-filename");
             if (temp_string == NULL || strcmp(temp_string, filename)) {
                 repr->setAttribute("inkscape:export-filename", filename);
-                modified = TRUE;
+                modified = true;
             }
             temp_string = repr->attribute("inkscape:export-xdpi");
             if (temp_string == NULL || xdpi != atof(temp_string)) {
                 sp_repr_set_svg_double(repr, "inkscape:export-xdpi", xdpi);
-                modified = TRUE;
+                modified = true;
             }
             temp_string = repr->attribute("inkscape:export-ydpi");
             if (temp_string == NULL || xdpi != atof(temp_string)) {
                 sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi);
-                modified = TRUE;
+                modified = true;
             }
 
             if (modified)
@@ -1119,10 +1128,10 @@ sp_export_export_clicked (GtkButton *button, GtkObject *base)
         case SELECTION_SELECTION: {
             const GSList * reprlst;
             SPDocument * doc = SP_ACTIVE_DOCUMENT;
-            bool modified = FALSE;
+            bool modified = false;
 
             bool saved = sp_document_get_undo_sensitive(doc);
-            sp_document_set_undo_sensitive(doc, FALSE);
+            sp_document_set_undo_sensitive(doc, false);
             reprlst = sp_desktop_selection(SP_ACTIVE_DESKTOP)->reprList();
 
             for(; reprlst != NULL; reprlst = reprlst->next) {
@@ -1136,18 +1145,18 @@ sp_export_export_clicked (GtkButton *button, GtkObject *base)
                     temp_string = repr->attribute("inkscape:export-filename");
                     if (temp_string == NULL || strcmp(temp_string, filename)) {
                         repr->setAttribute("inkscape:export-filename", filename);
-                        modified = TRUE;
+                        modified = true;
                     }
                 }
                 temp_string = repr->attribute("inkscape:export-xdpi");
                 if (temp_string == NULL || xdpi != atof(temp_string)) {
                     sp_repr_set_svg_double(repr, "inkscape:export-xdpi", xdpi);
-                    modified = TRUE;
+                    modified = true;
                 }
                 temp_string = repr->attribute("inkscape:export-ydpi");
                 if (temp_string == NULL || xdpi != atof(temp_string)) {
                     sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi);
-                    modified = TRUE;
+                    modified = true;
                 }
             }