Code

A simple layout document as to what, why and how is cppification.
[inkscape.git] / src / sp-flowregion.cpp
index cbfb5119504b583990a57c68af863b4a94f28512..cff7a5db78edc2c90e6cd3f0a4b6ca10a0c8ac57 100644 (file)
@@ -15,6 +15,8 @@
 #include "sp-use.h"
 #include "style.h"
 #include "document.h"
+#include "sp-title.h"
+#include "sp-desc.h"
 
 #include "sp-flowregion.h"
 
@@ -53,7 +55,7 @@ static gchar * sp_flowregionexclude_description (SPItem * item);
 static SPItemClass * flowregionexclude_parent_class;
 
 
-static void         GetDest(SPObject* child,Shape **computed,NR::Matrix itr_mat);
+static void         GetDest(SPObject* child,Shape **computed);
 
 GType
 sp_flowregion_get_type (void)
@@ -160,7 +162,7 @@ sp_flowregion_update (SPObject *object, SPCtx *ctx, unsigned int flags)
        flags &= SP_OBJECT_MODIFIED_CASCADE;
 
        l = NULL;
-       for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
+       for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
                g_object_ref (G_OBJECT (child));
                l = g_slist_prepend (l, child);
        }
@@ -188,16 +190,13 @@ void             SPFlowregion::UpdateComputed(void)
 {
        SPObject* object=SP_OBJECT(this);
 
-    NR::Matrix itr_mat = from_2geom(sp_item_i2root_affine (SP_ITEM(object)));
-    itr_mat = itr_mat.inverse();
-
     for (std::vector<Shape*>::iterator it = computed.begin() ; it != computed.end() ; it++)
         delete *it;
     computed.clear();
 
-       for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
+       for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
         Shape *shape = NULL;
-               GetDest(child,&shape,itr_mat);
+               GetDest(child,&shape);
         computed.push_back(shape);
        }
 }
@@ -215,7 +214,7 @@ sp_flowregion_modified (SPObject *object, guint flags)
        flags &= SP_OBJECT_MODIFIED_CASCADE;
 
        l = NULL;
-       for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
+       for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
                g_object_ref (G_OBJECT (child));
                l = g_slist_prepend (l, child);
        }
@@ -239,7 +238,8 @@ sp_flowregion_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscap
        }
 
         GSList *l = NULL;
-        for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+        for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+            if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue;
             Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
             if (crepr) l = g_slist_prepend(l, crepr);
         }
@@ -251,7 +251,8 @@ sp_flowregion_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscap
         }
 
     } else {
-        for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+        for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+            if (SP_IS_TITLE(child) || SP_IS_DESC(child)) continue;
             child->updateRepr(flags);
         }
     }
@@ -379,7 +380,7 @@ sp_flowregionexclude_update (SPObject *object, SPCtx *ctx, unsigned int flags)
        flags &= SP_OBJECT_MODIFIED_CASCADE;
 
        l = NULL;
-       for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
+       for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
                g_object_ref (G_OBJECT (child));
                l = g_slist_prepend (l, child);
        }
@@ -410,11 +411,9 @@ void             SPFlowregionExclude::UpdateComputed(void)
         delete computed;
         computed = NULL;
     }
-    NR::Matrix itr_mat = from_2geom(sp_item_i2root_affine (SP_ITEM(object)));
-    itr_mat = itr_mat.inverse();
 
-       for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
-               GetDest(child,&computed,itr_mat);
+       for (SPObject* child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
+               GetDest(child,&computed);
        }
 }
 
@@ -431,7 +430,7 @@ sp_flowregionexclude_modified (SPObject *object, guint flags)
        flags &= SP_OBJECT_MODIFIED_CASCADE;
 
        l = NULL;
-       for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
+       for (child = object->first_child() ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
                g_object_ref (G_OBJECT (child));
                l = g_slist_prepend (l, child);
        }
@@ -455,7 +454,7 @@ sp_flowregionexclude_write (SPObject *object, Inkscape::XML::Document *xml_doc,
        }
 
         GSList *l = NULL;
-        for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+        for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
             Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
             if (crepr) l = g_slist_prepend(l, crepr);
         }
@@ -467,7 +466,7 @@ sp_flowregionexclude_write (SPObject *object, Inkscape::XML::Document *xml_doc,
         }
 
     } else {
-        for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+        for ( SPObject *child = object->first_child() ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
             child->updateRepr(flags);
         }
     }
@@ -506,26 +505,28 @@ static void         UnionShape(Shape **base_shape, Shape const *add_shape)
        }
 }
 
-static void         GetDest(SPObject* child,Shape **computed,NR::Matrix itr_mat)
+static void         GetDest(SPObject* child,Shape **computed)
 {
        if ( child == NULL ) return;
 
        SPCurve *curve=NULL;
+       Geom::Matrix tr_mat;
 
        SPObject* u_child=child;
        if ( SP_IS_USE(u_child) ) {
                u_child=SP_USE(u_child)->child;
+               tr_mat = SP_ITEM(u_child)->getRelativeTransform(SP_OBJECT_PARENT(child));
+       } else {
+               tr_mat = SP_ITEM(u_child)->transform;
        }
        if ( SP_IS_SHAPE (u_child) ) {
-               curve = sp_shape_get_curve (SP_SHAPE (u_child));
+               curve = SP_SHAPE (u_child)->getCurve ();
        } else if ( SP_IS_TEXT (u_child) ) {
        curve = SP_TEXT (u_child)->getNormalizedBpath ();
        }
 
        if ( curve ) {
                Path*   temp=new Path;
-        Geom::Matrix tr_mat = sp_item_i2root_affine (SP_ITEM(u_child));
-        tr_mat = to_2geom(itr_mat) * tr_mat;
         temp->LoadPathVector(curve->get_pathvector(), tr_mat, true);
                Shape*  n_shp=new Shape;
                temp->Convert(0.25);