Code

NR::Maybe => boost::optional
[inkscape.git] / src / sp-item-group.cpp
index 20efd8fe72c76e4c370d84f51eb9e015b1ab8bdb..186b766635f1115ee63e0817401f4fd83af249c5 100644 (file)
@@ -57,7 +57,7 @@ static void sp_group_remove_child (SPObject * object, Inkscape::XML::Node * chil
 static void sp_group_order_changed (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * old_ref, Inkscape::XML::Node * new_ref);
 static void sp_group_update (SPObject *object, SPCtx *ctx, guint flags);
 static void sp_group_modified (SPObject *object, guint flags);
-static Inkscape::XML::Node *sp_group_write (SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static Inkscape::XML::Node *sp_group_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
 static void sp_group_set(SPObject *object, unsigned key, char const *value);
 
 static void sp_group_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
@@ -218,7 +218,7 @@ sp_group_modified (SPObject *object, guint flags)
 }
 
 static Inkscape::XML::Node *
-sp_group_write (SPObject *object, Inkscape::XML::Node *repr, guint flags)
+sp_group_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
 {
        SPGroup *group;
        SPObject *child;
@@ -229,12 +229,11 @@ sp_group_write (SPObject *object, Inkscape::XML::Node *repr, guint flags)
        if (flags & SP_OBJECT_WRITE_BUILD) {
                GSList *l;
                if (!repr) {
-                    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
                     repr = xml_doc->createElement("svg:g");
                 }
                l = NULL;
                for (child = sp_object_first_child(object); child != NULL; child = SP_OBJECT_NEXT(child) ) {
-                       crepr = child->updateRepr(NULL, flags);
+                       crepr = child->updateRepr(xml_doc, NULL, flags);
                        if (crepr) l = g_slist_prepend (l, crepr);
                }
                while (l) {
@@ -261,7 +260,7 @@ sp_group_write (SPObject *object, Inkscape::XML::Node *repr, guint flags)
        }
 
        if (((SPObjectClass *) (parent_class))->write)
-               ((SPObjectClass *) (parent_class))->write (object, repr, flags);
+               ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags);
 
        return repr;
 }
@@ -458,8 +457,10 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
        if (objects) {
            Inkscape::XML::Node *last_def = SP_OBJECT_REPR(defs)->lastChild();
            while (objects) {
-               SP_OBJECT_REPR(defs)->addChild((Inkscape::XML::Node *) objects->data, last_def);
-               Inkscape::GC::release((Inkscape::XML::Node *) objects->data);
+                Inkscape::XML::Node *repr = (Inkscape::XML::Node *) objects->data;
+                if (!sp_repr_is_meta_element(repr))
+                    SP_OBJECT_REPR(defs)->addChild(repr, last_def);
+                Inkscape::GC::release(repr);
                objects = g_slist_remove (objects, objects->data);
            }
        }
@@ -695,12 +696,12 @@ void CGroup::onModified(guint flags) {
 
 void CGroup::calculateBBox(NRRect *bbox, NR::Matrix const &transform, unsigned const flags) {
 
-    NR::Maybe<NR::Rect> dummy_bbox = NR::Nothing();
+    boost::optional<NR::Rect> dummy_bbox;
 
     GSList *l = _group->childList(false, SPObject::ActionBBox);
     while (l) {
         SPObject *o = SP_OBJECT (l->data);
-        if (SP_IS_ITEM(o)) {
+        if (SP_IS_ITEM(o) && !SP_ITEM(o)->isHidden()) {
             SPItem *child = SP_ITEM(o);
             NR::Matrix const ct(child->transform * transform);
             sp_item_invoke_bbox_full(child, &dummy_bbox, ct, flags, FALSE);
@@ -853,16 +854,11 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup)
             
             Inkscape::XML::Node *repr = SP_OBJECT_REPR(subitem);
  
-                NArtBpath *abp = c->first_bpath();
-                if (abp) {
-                    gchar *str = sp_svg_write_path(abp);
-                    repr->setAttribute("d", str);
-                    g_free(str);
-                } else {
-                   repr->setAttribute("d", "");
-                }
+            gchar *str = sp_svg_write_path(c->get_pathvector());
+            repr->setAttribute("d", str);
+            g_free(str);
 
-                c->unref();
+            c->unref();
         }
     }
 }