Code

Fix grid extension
authorKrzysztof Kosiński <tweenk.pl@gmail.com>
Sat, 3 Apr 2010 16:50:12 +0000 (18:50 +0200)
committerKrzysztof Kosiński <tweenk.pl@gmail.com>
Sat, 3 Apr 2010 16:50:12 +0000 (18:50 +0200)
src/extension/internal/grid.cpp

index d4b35b261baec5cb49bb89bbdac225bb8bd07179..deef367a484753b69abd96a2a61cd174bb69c190 100644 (file)
@@ -46,13 +46,12 @@ Grid::load (Inkscape::Extension::Extension */*module*/)
 
 namespace {
 
-Glib::ustring build_lines(int axis, Geom::Rect bounding_area,
-                          float offset, float spacing)
+void build_lines(int axis, Geom::Rect bounding_area, float offset,
+                 float spacing, SVG::PathString &path_data)
 {
     Geom::Point point_offset(0.0, 0.0);
     point_offset[axis] = offset;
 
-    SVG::PathString path_data;
     for (Geom::Point start_point = bounding_area.min();
             start_point[axis] + offset <= (bounding_area.max())[axis];
             start_point[axis] += spacing) {
@@ -62,8 +61,6 @@ Glib::ustring build_lines(int axis, Geom::Rect bounding_area,
         path_data.moveTo(start_point + point_offset)
                  .lineTo(end_point + point_offset);
     }
-
-    return path_data;
 }
 
 }
@@ -89,10 +86,8 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc
         if (bounds) {
             bounding_area = *bounds;
         }
-
-        gdouble doc_height  =  sp_document_height(document->doc());
-        Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], doc_height - bounding_area.min()[Geom::Y]),
-                                    Geom::Point(bounding_area.max()[Geom::X], doc_height - bounding_area.max()[Geom::Y]));
+        Geom::Rect temprec = Geom::Rect(Geom::Point(bounding_area.min()[Geom::X], bounding_area.min()[Geom::Y]),
+                                    Geom::Point(bounding_area.max()[Geom::X], bounding_area.max()[Geom::Y]));
 
         bounding_area = temprec;
     }
@@ -103,10 +98,9 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc
     float offsets[2] = { module->get_param_float("xoffset"),
                          module->get_param_float("yoffset") };
 
-    Glib::ustring path_data("");
+    SVG::PathString path_data;
     for ( int axis = 0 ; axis < 2 ; ++axis ) {
-        path_data += build_lines(axis, bounding_area,
-                                 offsets[axis], spacings[axis]);
+        build_lines(axis, bounding_area, offsets[axis], spacings[axis], path_data);
     }
 
     Inkscape::XML::Document * xml_doc = sp_document_repr_doc(document->doc());