From e2ae473da92a1f96e307e3f1f3e206cad7bd1c38 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 23 Oct 2014 19:33:47 -0700 Subject: Initial removal of box3d outdated GTKish macros. (bzr r13634) --- src/path-chemistry.cpp | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'src/path-chemistry.cpp') diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 787193060..56aafcb02 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -65,8 +65,9 @@ sp_selected_path_combine(SPDesktop *desktop) GSList *to_paths = NULL; for (GSList *i = items; i != NULL; i = i->next) { SPItem *item = (SPItem *) i->data; - if (!SP_IS_PATH(item) && !SP_IS_GROUP(item)) + if (!dynamic_cast(item) && !dynamic_cast(item)) { to_paths = g_slist_prepend(to_paths, item); + } } GSList *converted = NULL; bool did = sp_item_list_to_curves(to_paths, &items, &converted); @@ -98,7 +99,8 @@ sp_selected_path_combine(SPDesktop *desktop) for (GSList *i = items; i != NULL; i = i->next) { // going from top to bottom SPItem *item = (SPItem *) i->data; - if (!SP_IS_PATH(item)) { + SPPath *path = dynamic_cast(item); + if (!path) { continue; } @@ -107,7 +109,7 @@ sp_selected_path_combine(SPDesktop *desktop) did = true; } - SPCurve *c = SP_PATH(item)->get_curve_for_edit(); + SPCurve *c = path->get_curve_for_edit(); if (first == NULL) { // this is the topmost path first = item; parent = first->getRepr()->parent(); @@ -203,12 +205,11 @@ sp_selected_path_break_apart(SPDesktop *desktop) SPItem *item = (SPItem *) items->data; - if (!SP_IS_PATH(item)) { + SPPath *path = dynamic_cast(item); + if (!path) { continue; } - SPPath *path = SP_PATH(item); - SPCurve *curve = path->get_curve_for_edit(); if (curve == NULL) { continue; @@ -365,17 +366,20 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec items != NULL; items = items->next) { - SPItem *item = SP_ITEM(items->data); + SPItem *item = dynamic_cast(static_cast(items->data)); + g_assert(item != NULL); SPDocument *document = item->document; + SPGroup *group = dynamic_cast(item); if ( skip_all_lpeitems && - SP_IS_LPE_ITEM(item) && - !SP_IS_GROUP(item) ) // also convert objects in an SPGroup when skip_all_lpeitems is set. + dynamic_cast(item) && + !group ) // also convert objects in an SPGroup when skip_all_lpeitems is set. { continue; } - if (SP_IS_PATH(item) && !SP_SHAPE(item)->_curve_before_lpe) { + SPPath *path = dynamic_cast(item); + if (path && !path->_curve_before_lpe) { // remove connector attributes if (item->getAttribute("inkscape:connector-type") != NULL) { item->removeAttribute("inkscape:connection-start"); @@ -387,9 +391,10 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec continue; // already a path, and no path effect } - if (SP_IS_BOX3D(item)) { + SPBox3D *box = dynamic_cast(item); + if (box) { // convert 3D box to ordinary group of paths; replace the old element in 'selected' with the new group - Inkscape::XML::Node *repr = box3d_convert_to_group(SP_BOX3D(item))->getRepr(); + Inkscape::XML::Node *repr = box3d_convert_to_group(box)->getRepr(); if (repr) { *to_select = g_slist_prepend (*to_select, repr); @@ -400,9 +405,9 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec continue; } - if (SP_IS_GROUP(item)) { - SP_LPE_ITEM(item)->removeAllPathEffects(true); - GSList *item_list = sp_item_group_item_list(SP_GROUP(item)); + if (group) { + group->removeAllPathEffects(true); + GSList *item_list = sp_item_group_item_list(group); GSList *item_to_select = NULL; GSList *item_selected = NULL; @@ -472,7 +477,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/) Inkscape::XML::Document *xml_doc = item->getRepr()->document(); - if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) { + if (dynamic_cast(item) || dynamic_cast(item)) { // Special treatment for text: convert each glyph to separate path, then group the paths Inkscape::XML::Node *g_repr = xml_doc->createElement("svg:g"); g_repr->setAttribute("transform", item->getRepr()->attribute("transform")); @@ -506,7 +511,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/) if (!rawptr || !SP_IS_OBJECT(rawptr)) // no source for glyph, abort break; pos_obj = SP_OBJECT(rawptr); - while (SP_IS_STRING(pos_obj) && pos_obj->parent) { + while (dynamic_cast(pos_obj) && pos_obj->parent) { pos_obj = pos_obj->parent; // SPStrings don't have style } gchar *style_str = sp_style_write_difference(pos_obj->style, @@ -547,8 +552,11 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/) } SPCurve *curve = NULL; - if (SP_IS_SHAPE(item)) { - curve = SP_SHAPE(item)->getCurve(); + { + SPShape *shape = dynamic_cast(item); + if (shape) { + curve = shape->getCurve(); + } } if (!curve) @@ -614,12 +622,12 @@ sp_selected_path_reverse(SPDesktop *desktop) for (GSList *i = items; i != NULL; i = i->next) { - if (!SP_IS_PATH(i->data)) { + SPPath *path = dynamic_cast(static_cast(i->data)); + if (!path) { continue; } did = true; - SPPath *path = SP_PATH(i->data); SPCurve *rcurve = path->get_curve_reference()->create_reverse(); -- cgit v1.2.3 From b2336cda4ca07849f7fe96438980ecdb3374064f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Fri, 24 Oct 2014 07:53:41 -0700 Subject: Address possible-yet-unlikely null parent scenario. (bzr r13636) --- src/path-chemistry.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/path-chemistry.cpp') diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 56aafcb02..9456135f7 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -494,7 +494,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/) g_repr->setAttribute("inkscape:transform-center-y", item->getRepr()->attribute("inkscape:transform-center-y"), false); /* Whole text's style */ gchar *style_str = sp_style_write_difference(item->style, - item->parent->style); + item->parent ? item->parent->style : NULL); // TODO investigate posibility g_repr->setAttribute("style", style_str); g_free(style_str); Inkscape::Text::Layout::iterator iter = te_get_layout(item)->begin(); @@ -515,7 +515,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/) pos_obj = pos_obj->parent; // SPStrings don't have style } gchar *style_str = sp_style_write_difference(pos_obj->style, - pos_obj->parent->style); + pos_obj->parent ? pos_obj->parent->style : NULL); // TODO investigate posibility // get path from iter to iter_next: SPCurve *curve = te_get_layout(item)->convertToCurves(iter, iter_next); @@ -575,7 +575,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/) repr->setAttribute("transform", item->getRepr()->attribute("transform")); /* Style */ gchar *style_str = sp_style_write_difference(item->style, - item->parent->style); + item->parent ? item->parent->style : NULL); // TODO investigate posibility repr->setAttribute("style", style_str); g_free(style_str); -- cgit v1.2.3