Code

restore rendering markers in outline mode
[inkscape.git] / src / sp-clippath.cpp
index 33feea8ce2eef50669b8a78841becde558822f69..a1927f337c052ad9d554221b267339e438e05121 100644 (file)
@@ -24,6 +24,8 @@
 #include "document-private.h"
 #include "sp-item.h"
 
+#include "libnr/nr-matrix-ops.h"
+
 #include "sp-clippath.h"
 
 struct SPClipPathView {
@@ -243,7 +245,8 @@ static Inkscape::XML::Node *
 sp_clippath_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
 {
     if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
-        repr = sp_repr_new("svg:clipPath");
+        Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
+        repr = xml_doc->createElement("svg:clipPath");
     }
 
     if (((SPObjectClass *) (parent_class))->write)
@@ -327,12 +330,22 @@ sp_clippath_set_bbox(SPClipPath *cp, unsigned int key, NRRect *bbox)
 void
 sp_clippath_get_bbox(SPClipPath *cp, NRRect *bbox, NR::Matrix const &transform, unsigned const flags)
 {
-       for (SPObject *o = sp_object_first_child(SP_OBJECT(cp)); o != NULL; o = SP_OBJECT_NEXT(o)) {
-               if (SP_IS_ITEM(o)) {
-                       SPItem *child = SP_ITEM(o);
-                       sp_item_invoke_bbox_full(child, bbox, transform, flags, FALSE);
-               }
-       }
+    SPObject *i; 
+    for (i = sp_object_first_child(SP_OBJECT(cp)); i && !SP_IS_ITEM(i); i = SP_OBJECT_NEXT(i));
+    if (!i) return;
+
+    sp_item_invoke_bbox_full(SP_ITEM(i), bbox, NR::Matrix(SP_ITEM(i)->transform) * transform, flags, FALSE);
+    SPObject *i_start = i; 
+
+    while (i != NULL) {
+        if (i != i_start) {
+            NRRect i_box;
+            sp_item_invoke_bbox_full(SP_ITEM(i), &i_box, NR::Matrix(SP_ITEM(i)->transform) * transform, flags, FALSE);
+            nr_rect_d_union (bbox, bbox, &i_box);
+        }
+        i = SP_OBJECT_NEXT(i);
+        for (; i && !SP_IS_ITEM(i); i = SP_OBJECT_NEXT(i));
+    }
 }
 
 /* ClipPath views */
@@ -371,11 +384,12 @@ sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view)
 
 // Create a mask element (using passed elements), add it to <defs>
 const gchar *
-sp_clippath_create (GSList *reprs, SPDocument *document)
+sp_clippath_create (GSList *reprs, SPDocument *document, NR::Matrix const* applyTransform)
 {
     Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document));
 
-    Inkscape::XML::Node *repr = sp_repr_new ("svg:clipPath");
+    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
+    Inkscape::XML::Node *repr = xml_doc->createElement("svg:clipPath");
     repr->setAttribute("clipPathUnits", "userSpaceOnUse");
     
     defsrepr->appendChild(repr);
@@ -384,7 +398,13 @@ sp_clippath_create (GSList *reprs, SPDocument *document)
     
     for (GSList *it = reprs; it != NULL; it = it->next) {
         Inkscape::XML::Node *node = (Inkscape::XML::Node *)(it->data);
-        clip_path_object->appendChildRepr(node);
+        SPItem *item = SP_ITEM(clip_path_object->appendChildRepr(node));
+        
+        if (NULL != applyTransform) {
+            NR::Matrix transform (item->transform);
+            transform *= (*applyTransform);
+            sp_item_write_transform(item, SP_OBJECT_REPR(item), transform);
+        }
     }
     
     Inkscape::GC::release(repr);