X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsp-flowregion.cpp;h=3981aa9ba4874fbd7daff7abc69055ec2ecba0ba;hb=9336a24ccde2bdbbe7d3bd069e29b2cce87cb4be;hp=4071e4d92610d7068476576ea54d23590e942aee;hpb=6b15695578f07a3f72c4c9475c1a261a3021472a;p=inkscape.git diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 4071e4d92..3981aa9ba 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -14,6 +14,7 @@ #include "sp-text.h" #include "sp-use.h" #include "style.h" +#include "document.h" #include "sp-flowregion.h" @@ -82,21 +83,21 @@ sp_flowregion_class_init (SPFlowregionClass *klass) GObjectClass * object_class; SPObjectClass * sp_object_class; SPItemClass * item_class; - + object_class = (GObjectClass *) klass; sp_object_class = (SPObjectClass *) klass; item_class = (SPItemClass *) klass; - + flowregion_parent_class = (SPItemClass *)g_type_class_ref (SP_TYPE_ITEM); - + object_class->dispose = sp_flowregion_dispose; - + sp_object_class->child_added = sp_flowregion_child_added; sp_object_class->remove_child = sp_flowregion_remove_child; sp_object_class->update = sp_flowregion_update; sp_object_class->modified = sp_flowregion_modified; sp_object_class->write = sp_flowregion_write; - + item_class->description = sp_flowregion_description; } @@ -119,12 +120,12 @@ static void sp_flowregion_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { SPItem *item; - + item = SP_ITEM (object); - + if (((SPObjectClass *) (flowregion_parent_class))->child_added) (* ((SPObjectClass *) (flowregion_parent_class))->child_added) (object, child, ref); - + object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -135,7 +136,7 @@ sp_flowregion_remove_child (SPObject * object, Inkscape::XML::Node * child) { if (((SPObjectClass *) (flowregion_parent_class))->remove_child) (* ((SPObjectClass *) (flowregion_parent_class))->remove_child) (object, child); - + object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -147,17 +148,17 @@ sp_flowregion_update (SPObject *object, SPCtx *ctx, unsigned int flags) SPObject *child; SPItemCtx *ictx, cctx; GSList *l; - + group = SP_FLOWREGION (object); ictx = (SPItemCtx *) ctx; cctx = *ictx; - + if (((SPObjectClass *) (flowregion_parent_class))->update) ((SPObjectClass *) (flowregion_parent_class))->update (object, ctx, flags); - + if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; flags &= SP_OBJECT_MODIFIED_CASCADE; - + l = NULL; for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); @@ -186,14 +187,14 @@ sp_flowregion_update (SPObject *object, SPCtx *ctx, unsigned int flags) void SPFlowregion::UpdateComputed(void) { SPObject* object=SP_OBJECT(this); - + NR::Matrix itr_mat=sp_item_i2root_affine (SP_ITEM(object)); itr_mat=itr_mat.inverse(); - + for (std::vector::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) ) { Shape *shape = NULL; GetDest(child,&shape,itr_mat); @@ -207,12 +208,12 @@ sp_flowregion_modified (SPObject *object, guint flags) SPFlowregion *group; SPObject *child; GSList *l; - - group = SP_FLOWREGION (object); - + + group = SP_FLOWREGION (object); + if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; flags &= SP_OBJECT_MODIFIED_CASCADE; - + l = NULL; for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); @@ -233,20 +234,23 @@ static Inkscape::XML::Node * sp_flowregion_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) { if (flags & SP_OBJECT_WRITE_BUILD) { - if ( repr == NULL ) repr = sp_repr_new ("svg:flowRegion"); - + if ( repr == NULL ) { + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:flowRegion"); + } + GSList *l = NULL; for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node *crepr = child->updateRepr(NULL, flags); if (crepr) l = g_slist_prepend(l, crepr); } - + while (l) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); Inkscape::GC::release((Inkscape::XML::Node *) l->data); l = g_slist_remove(l, l->data); } - + } else { for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { child->updateRepr(flags); @@ -298,21 +302,21 @@ sp_flowregionexclude_class_init (SPFlowregionExcludeClass *klass) GObjectClass * object_class; SPObjectClass * sp_object_class; SPItemClass * item_class; - + object_class = (GObjectClass *) klass; sp_object_class = (SPObjectClass *) klass; item_class = (SPItemClass *) klass; - + flowregionexclude_parent_class = (SPItemClass *)g_type_class_ref (SP_TYPE_ITEM); - + object_class->dispose = sp_flowregionexclude_dispose; - + sp_object_class->child_added = sp_flowregionexclude_child_added; sp_object_class->remove_child = sp_flowregionexclude_remove_child; sp_object_class->update = sp_flowregionexclude_update; sp_object_class->modified = sp_flowregionexclude_modified; sp_object_class->write = sp_flowregionexclude_write; - + item_class->description = sp_flowregionexclude_description; } @@ -336,12 +340,12 @@ static void sp_flowregionexclude_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { SPItem *item; - + item = SP_ITEM (object); - + if (((SPObjectClass *) (flowregionexclude_parent_class))->child_added) (* ((SPObjectClass *) (flowregionexclude_parent_class))->child_added) (object, child, ref); - + object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -352,7 +356,7 @@ sp_flowregionexclude_remove_child (SPObject * object, Inkscape::XML::Node * chil { if (((SPObjectClass *) (flowregionexclude_parent_class))->remove_child) (* ((SPObjectClass *) (flowregionexclude_parent_class))->remove_child) (object, child); - + object->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -364,17 +368,17 @@ sp_flowregionexclude_update (SPObject *object, SPCtx *ctx, unsigned int flags) SPObject *child; SPItemCtx *ictx, cctx; GSList *l; - + group = SP_FLOWREGIONEXCLUDE (object); ictx = (SPItemCtx *) ctx; cctx = *ictx; - + if (((SPObjectClass *) (flowregionexclude_parent_class))->update) ((SPObjectClass *) (flowregionexclude_parent_class))->update (object, ctx, flags); - + if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; flags &= SP_OBJECT_MODIFIED_CASCADE; - + l = NULL; for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); @@ -402,14 +406,14 @@ sp_flowregionexclude_update (SPObject *object, SPCtx *ctx, unsigned int flags) void SPFlowregionExclude::UpdateComputed(void) { SPObject* object=SP_OBJECT(this); - + if (computed) { delete computed; computed = NULL; } NR::Matrix itr_mat=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); } @@ -421,12 +425,12 @@ sp_flowregionexclude_modified (SPObject *object, guint flags) SPFlowregionExclude *group; SPObject *child; GSList *l; - + group = SP_FLOWREGIONEXCLUDE (object); - + if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; flags &= SP_OBJECT_MODIFIED_CASCADE; - + l = NULL; for (child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { g_object_ref (G_OBJECT (child)); @@ -447,20 +451,23 @@ static Inkscape::XML::Node * sp_flowregionexclude_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) { if (flags & SP_OBJECT_WRITE_BUILD) { - if ( repr == NULL ) repr = sp_repr_new ("svg:flowRegionExclude"); - + if ( repr == NULL ) { + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object)); + repr = xml_doc->createElement("svg:flowRegionExclude"); + } + GSList *l = NULL; for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { Inkscape::XML::Node *crepr = child->updateRepr(NULL, flags); if (crepr) l = g_slist_prepend(l, crepr); } - + while (l) { repr->addChild((Inkscape::XML::Node *) l->data, NULL); Inkscape::GC::release((Inkscape::XML::Node *) l->data); l = g_slist_remove(l, l->data); } - + } else { for ( SPObject *child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { child->updateRepr(flags); @@ -502,11 +509,11 @@ static void UnionShape(Shape **base_shape, Shape const *add_shape) } static void GetDest(SPObject* child,Shape **computed,NR::Matrix itr_mat) -{ +{ if ( child == NULL ) return; - + SPCurve *curve=NULL; - + SPObject* u_child=child; if ( SP_IS_USE(u_child) ) { u_child=SP_USE(u_child)->child; @@ -516,12 +523,12 @@ static void GetDest(SPObject* child,Shape **computed,NR::Matrix itr_mat) } else if ( SP_IS_TEXT (u_child) ) { curve = SP_TEXT (u_child)->getNormalizedBpath (); } - + if ( curve ) { Path* temp=new Path; NR::Matrix tr_mat=sp_item_i2root_affine (SP_ITEM(u_child)); tr_mat=itr_mat*tr_mat; - temp->LoadArtBPath(curve->bpath,tr_mat,true); + temp->LoadArtBPath(SP_CURVE_BPATH(curve),tr_mat,true); Shape* n_shp=new Shape; temp->Convert(0.25); temp->Fill(n_shp,0);