diff options
| -rw-r--r-- | src/extension/internal/cairo-renderer.cpp | 56 | ||||
| -rw-r--r-- | src/extension/internal/javafx-out.cpp | 13 | ||||
| -rw-r--r-- | src/extension/internal/latex-text-renderer.cpp | 4 | ||||
| -rw-r--r-- | src/extension/internal/pov-out.cpp | 17 | ||||
| -rw-r--r-- | src/filter-chemistry.cpp | 41 | ||||
| -rw-r--r-- | src/id-clash.cpp | 28 | ||||
| -rw-r--r-- | src/sp-item.cpp | 7 | ||||
| -rw-r--r-- | src/sp-item.h | 3 | ||||
| -rw-r--r-- | src/sp-object.h | 1 | ||||
| -rw-r--r-- | src/splivarot.cpp | 122 | ||||
| -rw-r--r-- | src/ui/dialog/filter-effects-dialog.cpp | 98 | ||||
| -rw-r--r-- | src/ui/tool/path-manipulator.cpp | 8 | ||||
| -rw-r--r-- | src/ui/widget/object-composite-settings.cpp | 2 |
13 files changed, 211 insertions, 189 deletions
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 015b3b2cb..dbda82c28 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -169,7 +169,7 @@ static void sp_shape_render_invoke_marker_rendering(SPMarker* marker, Geom::Affi } if (render) { - SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (marker)); + SPItem* marker_item = sp_item_first_item_child(marker); tr = (Geom::Affine)marker_item->transform * (Geom::Affine)marker->c2p * tr; Geom::Affine old_tr = marker_item->transform; marker_item->transform = tr; @@ -184,14 +184,18 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) SPShape *shape = SP_SHAPE(item); - if (!shape->curve) return; + if (!shape->curve) { + return; + } item->invoke_bbox( &pbox, Geom::identity(), TRUE); - SPStyle* style = SP_OBJECT_STYLE (item); + SPStyle* style = item->style; Geom::PathVector const & pathv = shape->curve->get_pathvector(); - if (pathv.empty()) return; + if (pathv.empty()) { + return; + } ctx->renderPathVector(pathv, style, &pbox); @@ -290,7 +294,7 @@ static void sp_group_render(SPItem *item, CairoRenderContext *ctx) { SPGroup *group = SP_GROUP(item); CairoRenderer *renderer = ctx->getRenderer(); - TRACE(("sp_group_render opacity: %f\n", SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(item)->opacity.value))); + TRACE(("sp_group_render opacity: %f\n", SP_SCALE24_TO_FLOAT(item->style->opacity.value))); GSList *l = g_slist_reverse(group->childList(false)); while (l) { @@ -370,14 +374,15 @@ static void sp_image_render(SPItem *item, CairoRenderContext *ctx) Geom::Scale s(width / (double)w, height / (double)h); Geom::Affine t(s * tp); - ctx->renderImage (px, w, h, rs, &t, SP_OBJECT_STYLE (item)); + ctx->renderImage (px, w, h, rs, &t, item->style); } static void sp_symbol_render(SPItem *item, CairoRenderContext *ctx) { SPSymbol *symbol = SP_SYMBOL(item); - if (!SP_OBJECT_IS_CLONED (symbol)) + if (!symbol->cloned) { return; + } /* Cloned <symbol> is actually renderable */ ctx->pushState(); @@ -418,7 +423,7 @@ static void sp_root_render(SPItem *item, CairoRenderContext *ctx) SPRoot *root = SP_ROOT(item); CairoRenderer *renderer = ctx->getRenderer(); - if (!ctx->getCurrentState()->has_overflow && SP_OBJECT(item)->parent) + if (!ctx->getCurrentState()->has_overflow && item->parent) ctx->addClippingRect(root->x.computed, root->y.computed, root->width.computed, root->height.computed); ctx->pushState(); @@ -457,7 +462,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) return; } - Geom::Rect docrect(Geom::Rect(Geom::Point(0, 0), SP_OBJECT(item)->document->getDimensions())); + Geom::Rect docrect(Geom::Rect(Geom::Point(0, 0), item->document->getDimensions())); Geom::Rect bboxrect(Geom::Rect(Geom::Point(bbox->min()[Geom::X], bbox->min()[Geom::Y]), Geom::Point(bbox->max()[Geom::X], bbox->max()[Geom::Y]))); Geom::OptRect _bbox = Geom::intersect(docrect, bboxrect); @@ -500,7 +505,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) Geom::Affine t = t_on_document * t_item.inverse(); // Do the export - SPDocument *document = SP_OBJECT(item)->document; + SPDocument *document = item->document; GSList *items = NULL; items = g_slist_append(items, item); @@ -514,8 +519,9 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) unsigned int w = gdk_pixbuf_get_width(pb); unsigned int h = gdk_pixbuf_get_height(pb); unsigned int rs = gdk_pixbuf_get_rowstride(pb); - ctx->renderImage (px, w, h, rs, &t, SP_OBJECT_STYLE (item)); - gdk_pixbuf_unref (pb); + ctx->renderImage(px, w, h, rs, &t, item->style); + gdk_pixbuf_unref(pb); + pb = 0; } g_slist_free (items); } @@ -528,7 +534,7 @@ static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx) return; } - SPStyle* style = SP_OBJECT_STYLE (item); + SPStyle* style = item->style; if((ctx->getFilterToBitmap() == TRUE) && (style->filter.set != 0)) { return sp_asbitmap_render(item, ctx); } @@ -564,7 +570,7 @@ static void sp_item_invoke_render(SPItem *item, CairoRenderContext *ctx) void CairoRenderer::setStateForItem(CairoRenderContext *ctx, SPItem const *item) { - SPStyle const *style = SP_OBJECT_STYLE(item); + SPStyle const *style = item->style; ctx->setStateForStyle(style); CairoRenderState *state = ctx->getCurrentState(); @@ -582,8 +588,8 @@ CairoRenderer::setStateForItem(CairoRenderContext *ctx, SPItem const *item) TRACE(("setStateForItem opacity: %f\n", state->opacity)); } -void -CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) +// TODO change this to accept a const SPItem: +void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) { if ( _omitText && (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) ) { // skip text if _omitText is true @@ -687,10 +693,10 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) } TRACE(("BEGIN clip\n")); - SPObject *co = SP_OBJECT(cp); - for ( SPObject *child = co->firstChild() ; child; child = child->getNext() ) { + SPObject const *co = cp; + for ( SPObject const *child = co->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM(child)) { - SPItem *item = SP_ITEM(child); + SPItem const *item = SP_ITEM(child); // combine transform of the item in clippath and the item using clippath: Geom::Affine tempmat (item->transform); @@ -700,7 +706,8 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) ctx->pushState(); ctx->transform(&tempmat); setStateForItem(ctx, item); - sp_item_invoke_render(item, ctx); + // TODO fix this call to accept const items + sp_item_invoke_render(const_cast<SPItem *>(item), ctx); ctx->popState(); } } @@ -745,11 +752,12 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask) ctx->pushState(); TRACE(("BEGIN mask\n")); - SPObject *co = SP_OBJECT(mask); - for ( SPObject *child = co->firstChild() ; child; child = child->getNext() ) { + SPObject const *co = mask; + for ( SPObject const *child = co->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM(child)) { - SPItem *item = SP_ITEM(child); - renderItem(ctx, item); + SPItem const *item = SP_ITEM(child); + // TODO fix const correctness: + renderItem(ctx, const_cast<SPItem*>(item)); } } TRACE(("END mask\n")); diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 5902c3ad0..750849eb1 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -86,12 +86,11 @@ static double effective_opacity(const SPStyle *style) { double val = 1.0; for (SPObject const *obj = style->object; obj ; obj = obj->parent) - { - style = SP_OBJECT_STYLE(obj); - if (style) { - val *= SP_SCALE24_TO_FLOAT(style->opacity.value); - } + { + if (obj->style) { + val *= SP_SCALE24_TO_FLOAT(obj->style->opacity.value); } + } return val; } @@ -488,7 +487,7 @@ bool JavaFXOutput::doCurve(SPItem *item, const String &id) /** * Output the style information */ - if (!doStyle(SP_OBJECT_STYLE(shape))) { + if (!doStyle(shape->style)) { return false; } @@ -630,7 +629,7 @@ bool JavaFXOutput::doCurve(SPItem *item, const String &id) /** * Output the style information */ - if (!doStyle(SP_OBJECT_STYLE(shape))) { + if (!doStyle(shape->style)) { return false; } diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 3c4bb5c92..a4050540f 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -264,7 +264,7 @@ void LaTeXTextRenderer::sp_text_render(SPItem *item) { SPText *textobj = SP_TEXT (item); - SPStyle *style = SP_OBJECT_STYLE (SP_OBJECT(item)); + SPStyle *style = item->style; gchar *str = sp_te_get_string_multiline(item); if (!str) { @@ -350,7 +350,7 @@ Flowing in rectangle is possible, not in arb shape. */ SPFlowtext *flowtext = SP_FLOWTEXT(item); - SPStyle *style = SP_OBJECT_STYLE (SP_OBJECT(item)); + SPStyle *style = item->style; gchar *strtext = sp_te_get_string_multiline(item); if (!strtext) { diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index b5389bad3..1563d04c1 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -72,16 +72,15 @@ static void err(const char *fmt, ...) -static double -effective_opacity(SPItem const *item) +static double effective_opacity(SPItem const *item) { + // TODO investigate this. The early return seems that it would abort early. + // Plus is will emit a warning, which may not be proper here. double ret = 1.0; - for (SPObject const *obj = item; obj; obj = obj->parent) - { - SPStyle const *const style = SP_OBJECT_STYLE(obj); - g_return_val_if_fail(style, ret); - ret *= SP_SCALE24_TO_FLOAT(style->opacity.value); - } + for (SPObject const *obj = item; obj; obj = obj->parent) { + g_return_val_if_fail(obj->style, ret); + ret *= SP_SCALE24_TO_FLOAT(obj->style->opacity.value); + } return ret; } @@ -275,7 +274,7 @@ bool PovOutput::doCurve(SPItem *item, const String &id) shapeInfo.color = ""; //Try to get the fill color of the shape - SPStyle *style = SP_OBJECT_STYLE(shape); + SPStyle *style = shape->style; /* fixme: Handle other fill types, even if this means translating gradients to a single flat colour. */ if (style) diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 742ac7261..b2c5f3020 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -41,7 +41,7 @@ static guint count_filter_hrefs(SPObject *o, SPFilter *filter) guint i = 0; - SPStyle *style = SP_OBJECT_STYLE(o); + SPStyle *style = o->style; if (style && style->filter.set && style->getFilter() == filter) @@ -355,8 +355,8 @@ SPFilter *modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *it // If there are more users for this filter, duplicate it if (filter->hrefcount > count_filter_hrefs(item, filter)) { - Inkscape::XML::Node *repr = SP_OBJECT_REPR(item->style->getFilter())->duplicate(xml_doc); - SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + Inkscape::XML::Node *repr = item->style->getFilter()->getRepr()->duplicate(xml_doc); + SPDefs *defs = reinterpret_cast<SPDefs *>(SP_DOCUMENT_DEFS(document)); defs->appendChild(repr); filter = SP_FILTER( document->getObjectByRepr(repr) ); @@ -382,7 +382,7 @@ SPFilter *modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *it } // Set the filter effects area - Inkscape::XML::Node *repr = SP_OBJECT_REPR(item->style->getFilter()); + Inkscape::XML::Node *repr = item->style->getFilter()->getRepr(); set_filter_area(repr, radius, expansion, i2d.expansionX(), i2d.expansionY(), width, height); @@ -409,7 +409,7 @@ SPFilter *modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *it sp_repr_set_svg_double(b_repr, "stdDeviation", stdDeviation); //set feGaussianBlur as child of filter node - SP_OBJECT_REPR(filter)->appendChild(b_repr); + filter->getRepr()->appendChild(b_repr); Inkscape::GC::release(b_repr); return filter; @@ -417,13 +417,14 @@ SPFilter *modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *it void remove_filter (SPObject *item, bool recursive) { - SPCSSAttr *css = sp_repr_css_attr_new (); - sp_repr_css_unset_property (css, "filter"); - if (recursive) - sp_repr_css_change_recursive(SP_OBJECT_REPR(item), css, "style"); - else - sp_repr_css_change (SP_OBJECT_REPR(item), css, "style"); - sp_repr_css_attr_unref (css); + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_unset_property(css, "filter"); + if (recursive) { + sp_repr_css_change_recursive(item->getRepr(), css, "style"); + } else { + sp_repr_css_change(item->getRepr(), css, "style"); + } + sp_repr_css_attr_unref(css); } /** @@ -437,7 +438,7 @@ void remove_filter_gaussian_blur (SPObject *item) { if (item->style && item->style->filter.set && item->style->getFilter()) { // Search for the first blur primitive and remove it. (if found) - Inkscape::XML::Node *repr = SP_OBJECT_REPR(item->style->getFilter()); + Inkscape::XML::Node *repr = item->style->getFilter()->getRepr(); Inkscape::XML::Node *primitive = repr->firstChild(); while (primitive) { if (strcmp("svg:feGaussianBlur", primitive->name()) == 0) { @@ -456,18 +457,18 @@ void remove_filter_gaussian_blur (SPObject *item) bool filter_is_single_gaussian_blur(SPFilter *filter) { - return (SP_OBJECT(filter)->firstChild() && - SP_OBJECT(filter)->firstChild() == SP_OBJECT(filter)->lastChild() && - SP_IS_GAUSSIANBLUR(SP_OBJECT(filter)->firstChild())); + return (filter->firstChild() && + (filter->firstChild() == filter->lastChild()) && + SP_IS_GAUSSIANBLUR(filter->firstChild())); } double get_single_gaussian_blur_radius(SPFilter *filter) { - if (SP_OBJECT(filter)->firstChild() && - SP_OBJECT(filter)->firstChild() == SP_OBJECT(filter)->lastChild() && - SP_IS_GAUSSIANBLUR(SP_OBJECT(filter)->firstChild())) { + if (filter->firstChild() && + (filter->firstChild() == filter->lastChild()) && + SP_IS_GAUSSIANBLUR(filter->firstChild())) { - SPGaussianBlur *gb = SP_GAUSSIANBLUR(SP_OBJECT(filter)->firstChild()); + SPGaussianBlur *gb = SP_GAUSSIANBLUR(filter->firstChild()); double x = gb->stdDeviation.getNumber(); double y = gb->stdDeviation.getOptNumber(); if (x > 0 && y > 0) { diff --git a/src/id-clash.cpp b/src/id-clash.cpp index 0594fe8e6..67e27e2f0 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -88,8 +88,8 @@ const char* clipboard_properties[] = { static void find_references(SPObject *elem, refmap_type *refmap) { - if (SP_OBJECT_IS_CLONED(elem)) return; - Inkscape::XML::Node *repr_elem = SP_OBJECT_REPR(elem); + if (elem->cloned) return; + Inkscape::XML::Node *repr_elem = elem->getRepr(); if (!repr_elem) return; if (repr_elem->type() != Inkscape::XML::ELEMENT_NODE) return; @@ -124,7 +124,7 @@ find_references(SPObject *elem, refmap_type *refmap) } } - SPStyle *style = SP_OBJECT_STYLE(elem); + SPStyle *style = elem->style; /* check for url(#...) references in 'fill' or 'stroke' */ for (unsigned i = 0; i < NUM_SPIPAINT_PROPERTIES; ++i) { @@ -197,7 +197,7 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc, imported_doc->getObjectById(str) == NULL) break; } // Change to the new ID - SP_OBJECT_REPR(elem)->setAttribute("id", new_id.c_str()); + elem->getRepr()->setAttribute("id", new_id.c_str()); // Make a note of this change, if we need to fix up refs to it if (refmap->find(old_id) != refmap->end()) id_changes->push_back(id_changeitem_type(elem, old_id)); @@ -226,27 +226,25 @@ fix_up_refs(const refmap_type *refmap, const id_changelist_type &id_changes) for (it = pos->second.begin(); it != it_end; ++it) { if (it->type == REF_HREF) { gchar *new_uri = g_strdup_printf("#%s", obj->getId()); - SP_OBJECT_REPR(it->elem)->setAttribute(it->attr, new_uri); + it->elem->getRepr()->setAttribute(it->attr, new_uri); g_free(new_uri); - } - else if (it->type == REF_STYLE) { + } else if (it->type == REF_STYLE) { sp_style_set_property_url(it->elem, it->attr, obj, false); - } - else if (it->type == REF_URL) { + } else if (it->type == REF_URL) { gchar *url = g_strdup_printf("url(#%s)", obj->getId()); - SP_OBJECT_REPR(it->elem)->setAttribute(it->attr, url); + it->elem->getRepr()->setAttribute(it->attr, url); g_free(url); - } - else if (it->type == REF_CLIPBOARD) { - SPCSSAttr *style = sp_repr_css_attr(SP_OBJECT_REPR(it->elem), "style"); + } else if (it->type == REF_CLIPBOARD) { + SPCSSAttr *style = sp_repr_css_attr(it->elem->getRepr(), "style"); gchar *url = g_strdup_printf("url(#%s)", obj->getId()); sp_repr_css_set_property(style, it->attr, url); g_free(url); gchar *style_string = sp_repr_css_write_string(style); - SP_OBJECT_REPR(it->elem)->setAttribute("style", style_string); + it->elem->getRepr()->setAttribute("style", style_string); g_free(style_string); + } else { + g_assert(0); // shouldn't happen } - else g_assert(0); // shouldn't happen } } } diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 37bd0b19b..40c9b0233 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1550,12 +1550,17 @@ NRArenaItem *SPItem::get_arenaitem(unsigned key) return NULL; } -int sp_item_repr_compare_position(SPItem *first, SPItem *second) +int sp_item_repr_compare_position(SPItem const *first, SPItem const *second) { return sp_repr_compare_position(first->getRepr(), second->getRepr()); } +SPItem const *sp_item_first_item_child(SPObject const *obj) +{ + return sp_item_first_item_child( const_cast<SPObject *>(obj) ); +} + SPItem *sp_item_first_item_child(SPObject *obj) { SPItem *child = 0; diff --git a/src/sp-item.h b/src/sp-item.h index dc440b397..7c3eb87d9 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -286,8 +286,9 @@ Geom::Affine i2i_affine(SPObject const *src, SPObject const *dest); * * \return TRANSFORM. */ -int sp_item_repr_compare_position(SPItem *first, SPItem *second); +int sp_item_repr_compare_position(SPItem const *first, SPItem const *second); SPItem *sp_item_first_item_child (SPObject *obj); +SPItem const *sp_item_first_item_child (SPObject const *obj); #endif // SEEN_SP_ITEM_H diff --git a/src/sp-object.h b/src/sp-object.h index 5d9ac88ff..74e957b4b 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -56,7 +56,6 @@ class SPObjectClass; /* Convenience stuff */ #define SP_OBJECT_REPR(o) (((SPObject *) (o))->getRepr()) -#define SP_OBJECT_STYLE(o) (((SPObject *) (o))->style) #include <glib-object.h> #include <sigc++/connection.h> diff --git a/src/splivarot.cpp b/src/splivarot.cpp index bcb9b1bb6..fe8d8a894 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -141,8 +141,8 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb if (bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice) { // check in the tree to find which element of the selection list is topmost (for 2-operand commands only) - Inkscape::XML::Node *a = SP_OBJECT_REPR(il->data); - Inkscape::XML::Node *b = SP_OBJECT_REPR(il->next->data); + Inkscape::XML::Node *a = reinterpret_cast<SPObject *>(il->data)->getRepr(); + Inkscape::XML::Node *b = reinterpret_cast<SPObject *>(il->next->data)->getRepr(); if (a == NULL || b == NULL) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Unable to determine the <b>z-order</b> of the objects selected for difference, XOR, division, or path cut.")); @@ -206,7 +206,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb curOrig = 0; for (GSList *l = il; l != NULL; l = l->next) { - SPCSSAttr *css = sp_repr_css_attr(SP_OBJECT_REPR(il->data), "style"); + SPCSSAttr *css = sp_repr_css_attr(reinterpret_cast<SPObject *>(il->data)->getRepr(), "style"); gchar const *val = sp_repr_css_property(css, "fill-rule", NULL); if (val && strcmp(val, "nonzero") == 0) { origWind[curOrig]= fill_nonZero; @@ -458,7 +458,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb item_source->adjust_gradient(i2doc); item_source->adjust_livepatheffect(i2doc); - Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(source); + Inkscape::XML::Node *repr_source = source->getRepr(); // remember important aspects of the source path, to be restored gint pos = repr_source->position(); @@ -473,7 +473,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb selection->clear(); for (GSList *l = il; l != NULL; l = l->next) { // if this is the bottommost object, - if (!strcmp(SP_OBJECT_REPR(l->data)->attribute("id"), id)) { + if (!strcmp(reinterpret_cast<SPObject *>(l->data)->getRepr()->attribute("id"), id)) { // delete it so that its clones don't get alerted; this object will be restored shortly, with the same id SP_OBJECT(l->data)->deleteObject(false); } else { @@ -606,7 +606,7 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Affine Inkscape::XML::Node *g_repr, Inkscape::XML::Document *xml_doc, SPDocument * doc ) { SPMarker* marker = SP_MARKER (marker_object); - SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (marker_object)); + SPItem* marker_item = sp_item_first_item_child(marker_object); Geom::Affine tr(marker_transform); @@ -617,8 +617,8 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Affine // total marker transform tr = marker_item->transform * marker->c2p * tr * transform; - if (SP_OBJECT_REPR(marker_item)) { - Inkscape::XML::Node *m_repr = SP_OBJECT_REPR(marker_item)->duplicate(xml_doc); + if (marker_item->getRepr()) { + Inkscape::XML::Node *m_repr = marker_item->getRepr()->duplicate(xml_doc); g_repr->appendChild(m_repr); SPItem *marker_item = (SPItem *) doc->getObjectByRepr(m_repr); marker_item->doWriteTransform(m_repr, tr); @@ -629,8 +629,8 @@ static void item_outline_add_marker( SPObject const *marker_object, Geom::Affine marker_transform, Geom::Scale stroke_scale, Geom::PathVector* pathv_in ) { - SPMarker* marker = SP_MARKER (marker_object); - SPItem* marker_item = sp_item_first_item_child(SP_OBJECT(marker_object)); + SPMarker const * marker = SP_MARKER(marker_object); + SPItem const * marker_item = sp_item_first_item_child(marker_object); Geom::Affine tr(marker_transform); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { @@ -657,11 +657,12 @@ Geom::PathVector* item_outline(SPItem const *item) { Geom::PathVector *ret_pathv = NULL; - if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) + if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) { return ret_pathv; + } // no stroke: no outline - if (!SP_OBJECT_STYLE(item) || SP_OBJECT_STYLE(item)->stroke.noneSet) { + if (!item->style || item->style->stroke.noneSet) { return ret_pathv; } @@ -680,7 +681,7 @@ Geom::PathVector* item_outline(SPItem const *item) } // remember old stroke style, to be set on fill - SPStyle *i_style = SP_OBJECT_STYLE(item); + SPStyle *i_style = item->style; Geom::Affine const transform(item->transform); float const scale = transform.descrim(); @@ -910,14 +911,14 @@ sp_selected_path_outline(SPDesktop *desktop) } // pas de stroke pas de chocolat - if (!SP_OBJECT_STYLE(item) || SP_OBJECT_STYLE(item)->stroke.noneSet) { + if (!item->style || item->style->stroke.noneSet) { curve->unref(); continue; } // remember old stroke style, to be set on fill - SPStyle *i_style = SP_OBJECT_STYLE(item); - SPCSSAttr *ncss; + SPStyle *i_style = item->style; + SPCSSAttr *ncss = 0; { ncss = sp_css_attr_from_style(i_style, SP_STYLE_FLAG_ALWAYS); gchar const *s_val = sp_repr_css_property(ncss, "stroke", NULL); @@ -938,8 +939,8 @@ sp_selected_path_outline(SPDesktop *desktop) Geom::Affine const transform(item->transform); float const scale = transform.descrim(); - gchar const *mask = SP_OBJECT_REPR(item)->attribute("mask"); - gchar const *clip_path = SP_OBJECT_REPR(item)->attribute("clip-path"); + gchar const *mask = item->getRepr()->attribute("mask"); + gchar const *clip_path = item->getRepr()->attribute("clip-path"); float o_width, o_miter; JoinType o_join; @@ -1053,11 +1054,11 @@ sp_selected_path_outline(SPDesktop *desktop) did = true; // remember the position of the item - gint pos = SP_OBJECT_REPR(item)->position(); + gint pos = item->getRepr()->position(); // remember parent - Inkscape::XML::Node *parent = SP_OBJECT_REPR(item)->parent(); + Inkscape::XML::Node *parent = item->getRepr()->parent(); // remember id - char const *id = SP_OBJECT_REPR(item)->attribute("id"); + char const *id = item->getRepr()->attribute("id"); // remember title gchar *title = item->title(); // remember description @@ -1213,11 +1214,17 @@ sp_selected_path_outline(SPDesktop *desktop) curve->unref(); selection->remove(item); - SP_OBJECT(item)->deleteObject(false); + item->deleteObject(false); } - if (title) g_free(title); - if (desc) g_free(desc); + if (title) { + g_free(title); + title = 0; + } + if (desc) { + g_free(desc); + desc = 0; + } delete res; delete orig; @@ -1329,22 +1336,21 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat Geom::Affine const transform(item->transform); - item->doWriteTransform(SP_OBJECT_REPR(item), Geom::identity()); + item->doWriteTransform(item->getRepr(), Geom::identity()); //XML Tree being used directly here while it shouldn't be... - style = g_strdup(SP_OBJECT(item)->getRepr()->attribute("style")); + style = g_strdup(item->getRepr()->attribute("style")); // remember the position of the item - gint pos = SP_OBJECT_REPR(item)->position(); + gint pos = item->getRepr()->position(); // remember parent - Inkscape::XML::Node *parent = SP_OBJECT_REPR(item)->parent(); + Inkscape::XML::Node *parent = item->getRepr()->parent(); { - SPStyle *i_style = SP_OBJECT(item)->style; - int jointype, captype; + SPStyle *i_style = item->style; + int jointype = i_style->stroke_linejoin.value; + int captype = i_style->stroke_linecap.value; - jointype = i_style->stroke_linejoin.value; - captype = i_style->stroke_linecap.value; o_width = i_style->stroke_width.computed; if (jointype == SP_STROKE_LINEJOIN_MITER) { @@ -1399,7 +1405,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat orig->ConvertWithBackData(1.0); orig->Fill(theShape, 0); - SPCSSAttr *css = sp_repr_css_attr(SP_OBJECT_REPR(item), "style"); + SPCSSAttr *css = sp_repr_css_attr(item->getRepr(), "style"); gchar const *val = sp_repr_css_property(css, "fill-rule", NULL); if (val && strcmp(val, "nonzero") == 0) { @@ -1462,7 +1468,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat if ( updating ) { //XML Tree being used directly here while it shouldn't be - char const *id = SP_OBJECT(item)->getRepr()->attribute("id"); + char const *id = item->getRepr()->attribute("id"); char const *uri = g_strdup_printf("#%s", id); repr->setAttribute("xlink:href", uri); g_free((void *) uri); @@ -1483,16 +1489,16 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat if ( updating ) { // on conserve l'original // we reapply the transform to the original (offset will feel it) - item->doWriteTransform(SP_OBJECT_REPR(item), transform); + item->doWriteTransform(item->getRepr(), transform); } else { // delete original, apply the transform to the offset - SP_OBJECT(item)->deleteObject(false); + item->deleteObject(false); nitem->doWriteTransform(repr, transform); } // The object just created from a temporary repr is only a seed. // We need to invoke its write which will update its real repr (in particular adding d=) - SP_OBJECT(nitem)->updateRepr(); + nitem->updateRepr(); Inkscape::GC::release(repr); @@ -1557,20 +1563,19 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) Geom::Affine const transform(item->transform); - item->doWriteTransform(SP_OBJECT_REPR(item), Geom::identity()); + item->doWriteTransform(item->getRepr(), Geom::identity()); - gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style")); + gchar *style = g_strdup(item->getRepr()->attribute("style")); float o_width, o_miter; JoinType o_join; ButtType o_butt; { - SPStyle *i_style = SP_OBJECT(item)->style; - int jointype, captype; + SPStyle *i_style = item->style; + int jointype = i_style->stroke_linejoin.value; + int captype = i_style->stroke_linecap.value; - jointype = i_style->stroke_linejoin.value; - captype = i_style->stroke_linecap.value; o_width = i_style->stroke_width.computed; switch (jointype) { @@ -1621,7 +1626,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) orig->ConvertWithBackData(0.03); orig->Fill(theShape, 0); - SPCSSAttr *css = sp_repr_css_attr(SP_OBJECT_REPR(item), "style"); + SPCSSAttr *css = sp_repr_css_attr(item->getRepr(), "style"); gchar const *val = sp_repr_css_property(css, "fill-rule", NULL); if (val && strcmp(val, "nonzero") == 0) { @@ -1697,14 +1702,14 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) curve->unref(); // remember the position of the item - gint pos = SP_OBJECT_REPR(item)->position(); + gint pos = item->getRepr()->position(); // remember parent - Inkscape::XML::Node *parent = SP_OBJECT_REPR(item)->parent(); + Inkscape::XML::Node *parent = item->getRepr()->parent(); // remember id - char const *id = SP_OBJECT_REPR(item)->attribute("id"); + char const *id = item->getRepr()->attribute("id"); selection->remove(item); - SP_OBJECT(item)->deleteObject(false); + item->deleteObject(false); if (res->descr_cmd.size() > 1) { // if there's 0 or 1 node left, drop this path altogether @@ -1809,11 +1814,11 @@ sp_selected_path_simplify_item(SPDesktop *desktop, this is necessary so that the item is transformed twice back and forth, allowing all compensations to cancel out regardless of the preferences */ - item->doWriteTransform(SP_OBJECT_REPR(item), Geom::identity()); + item->doWriteTransform(item->getRepr(), Geom::identity()); - gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style")); - gchar *mask = g_strdup(SP_OBJECT_REPR(item)->attribute("mask")); - gchar *clip_path = g_strdup(SP_OBJECT_REPR(item)->attribute("clip-path")); + gchar *style = g_strdup(item->getRepr()->attribute("style")); + gchar *mask = g_strdup(item->getRepr()->attribute("mask")); + gchar *clip_path = g_strdup(item->getRepr()->attribute("clip-path")); Path *orig = Path_for_item(item, false); if (orig == NULL) { @@ -1824,23 +1829,24 @@ sp_selected_path_simplify_item(SPDesktop *desktop, curve->unref(); // remember the position of the item - gint pos = SP_OBJECT_REPR(item)->position(); + gint pos = item->getRepr()->position(); // remember parent - Inkscape::XML::Node *parent = SP_OBJECT_REPR(item)->parent(); + Inkscape::XML::Node *parent = item->getRepr()->parent(); // remember id - char const *id = SP_OBJECT_REPR(item)->attribute("id"); + char const *id = item->getRepr()->attribute("id"); // remember path effect - char const *patheffect = SP_OBJECT_REPR(item)->attribute("inkscape:path-effect"); + char const *patheffect = item->getRepr()->attribute("inkscape:path-effect"); // remember title gchar *title = item->title(); // remember description gchar *desc = item->desc(); //If a group was selected, to not change the selection list - if (modifySelection) + if (modifySelection) { selection->remove(item); + } - SP_OBJECT(item)->deleteObject(false); + item->deleteObject(false); if ( justCoalesce ) { orig->Coalesce(threshold * size); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 3fbb3663d..2699d9201 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1181,29 +1181,32 @@ void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel) { std::set<SPObject*> used; - for(GSList const *i = sel->itemList(); i != NULL; i = i->next) { + for (GSList const *i = sel->itemList(); i != NULL; i = i->next) { SPObject *obj = SP_OBJECT (i->data); - SPStyle *style = SP_OBJECT_STYLE (obj); - if(!style || !SP_IS_ITEM(obj)) continue; + SPStyle *style = obj->style; + if (!style || !SP_IS_ITEM(obj)) { + continue; + } - if(style->filter.set && style->getFilter()) + if (style->filter.set && style->getFilter()) { used.insert(style->getFilter()); - else + } else { used.insert(0); + } } const int size = used.size(); - for(Gtk::TreeIter iter = _model->children().begin(); - iter != _model->children().end(); ++iter) { - if(used.find((*iter)[_columns.filter]) != used.end()) { + for (Gtk::TreeIter iter = _model->children().begin(); iter != _model->children().end(); ++iter) { + if (used.find((*iter)[_columns.filter]) != used.end()) { // If only one filter is in use by the selection, select it - if(size == 1) + if (size == 1) { _list.get_selection()->select(iter); + } (*iter)[_columns.sel] = size; - } - else + } else { (*iter)[_columns.sel] = 0; + } } } @@ -1244,15 +1247,16 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri for (GSList const *i = items; i != NULL; i = i->next) { SPItem * item = SP_ITEM(i->data); - SPStyle *style = SP_OBJECT_STYLE(item); + SPStyle *style = item->style; g_assert(style != NULL); - if(filter) - sp_style_set_property_url(SP_OBJECT(item), "filter", SP_OBJECT(filter), false); - else + if (filter) { + sp_style_set_property_url(item, "filter", filter, false); + } else { ::remove_filter(item, false); + } - SP_OBJECT(item)->requestDisplayUpdate((SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG )); + item->requestDisplayUpdate((SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG )); } update_selection(sel); @@ -1355,8 +1359,9 @@ void FilterEffectsDialog::FilterModifier::duplicate_filter() { SPFilter* filter = get_selected_filter(); - if(filter) { - Inkscape::XML::Node* repr = SP_OBJECT_REPR(filter), *parent = repr->parent(); + if (filter) { + Inkscape::XML::Node *repr = filter->getRepr(); + Inkscape::XML::Node *parent = repr->parent(); repr = repr->duplicate(repr->document()); parent->appendChild(repr); @@ -1902,7 +1907,7 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* for(Gtk::TreeIter iter = _model->children().begin(); iter != get_selection()->get_selected(); ++iter) { if(iter == target_iter) { - Inkscape::XML::Node *repr = SP_OBJECT_REPR(target); + Inkscape::XML::Node *repr = target->getRepr(); // Make sure the target has a result const gchar *gres = repr->attribute("result"); if(!gres) { @@ -1979,22 +1984,23 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* // Checks all of prim's inputs, removes any that use result void check_single_connection(SPFilterPrimitive* prim, const int result) { - if(prim && result >= 0) { - - if(prim->image_in == result) - SP_OBJECT_REPR(prim)->setAttribute("in", 0); - - if(SP_IS_FEBLEND(prim)) { - if(SP_FEBLEND(prim)->in2 == result) - SP_OBJECT_REPR(prim)->setAttribute("in2", 0); + if (prim && (result >= 0)) { + if (prim->image_in == result) { + prim->getRepr()->setAttribute("in", 0); } - else if(SP_IS_FECOMPOSITE(prim)) { - if(SP_FECOMPOSITE(prim)->in2 == result) - SP_OBJECT_REPR(prim)->setAttribute("in2", 0); - } - else if(SP_IS_FEDISPLACEMENTMAP(prim)) { - if(SP_FEDISPLACEMENTMAP(prim)->in2 == result) - SP_OBJECT_REPR(prim)->setAttribute("in2", 0); + + if (SP_IS_FEBLEND(prim)) { + if (SP_FEBLEND(prim)->in2 == result) { + prim->getRepr()->setAttribute("in2", 0); + } + } else if (SP_IS_FECOMPOSITE(prim)) { + if (SP_FECOMPOSITE(prim)->in2 == result) { + prim->getRepr()->setAttribute("in2", 0); + } + } else if (SP_IS_FEDISPLACEMENTMAP(prim)) { + if (SP_FEDISPLACEMENTMAP(prim)->in2 == result) { + prim->getRepr()->setAttribute("in2", 0); + } } } } @@ -2025,19 +2031,19 @@ void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtr<Gdk::Dra SPFilter* filter = _dialog._filter_modifier.get_selected_filter(); int ndx = 0; - for(Gtk::TreeModel::iterator iter = _model->children().begin(); + for (Gtk::TreeModel::iterator iter = _model->children().begin(); iter != _model->children().end(); ++iter, ++ndx) { SPFilterPrimitive* prim = (*iter)[_columns.primitive]; - if(prim && prim == _drag_prim) { - SP_OBJECT_REPR(prim)->setPosition(ndx); + if (prim && prim == _drag_prim) { + prim->getRepr()->setPosition(ndx); break; } } - for(Gtk::TreeModel::iterator iter = _model->children().begin(); + for (Gtk::TreeModel::iterator iter = _model->children().begin(); iter != _model->children().end(); ++iter, ++ndx) { SPFilterPrimitive* prim = (*iter)[_columns.primitive]; - if(prim && prim == _drag_prim) { + if (prim && prim == _drag_prim) { sanitize_connections(iter); get_selection()->select(iter); break; @@ -2369,10 +2375,10 @@ void FilterEffectsDialog::duplicate_primitive() SPFilter* filter = _filter_modifier.get_selected_filter(); SPFilterPrimitive* origprim = _primitive_list.get_selected(); - if(filter && origprim) { + if (filter && origprim) { Inkscape::XML::Node *repr; - repr = SP_OBJECT_REPR(origprim)->duplicate(SP_OBJECT_REPR(origprim)->document()); - SP_OBJECT_REPR(filter)->appendChild(repr); + repr = origprim->getRepr()->duplicate(origprim->getRepr()->document()); + filter->getRepr()->appendChild(repr); DocumentUndo::done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Duplicate filter primitive")); @@ -2382,7 +2388,7 @@ void FilterEffectsDialog::duplicate_primitive() void FilterEffectsDialog::convolve_order_changed() { - _convolve_matrix->set_from_attribute(SP_OBJECT(_primitive_list.get_selected())); + _convolve_matrix->set_from_attribute(_primitive_list.get_selected()); _convolve_target->get_spinbuttons()[0]->get_adjustment()->set_upper(_convolve_order->get_spinbutton1().get_value() - 1); _convolve_target->get_spinbuttons()[1]->get_adjustment()->set_upper(_convolve_order->get_spinbutton2().get_value() - 1); } @@ -2398,8 +2404,8 @@ void FilterEffectsDialog::set_filternode_attr(const AttrWidget* input) _attr_lock = true; SPFilter *filter = _filter_modifier.get_selected_filter(); const gchar* name = (const gchar*)sp_attribute_name(input->get_attribute()); - if (filter && name && SP_OBJECT_REPR(filter)){ - SP_OBJECT_REPR(filter)->setAttribute(name, input->get_as_attribute().c_str()); + if (filter && name && filter->getRepr()){ + filter->getRepr()->setAttribute(name, input->get_as_attribute().c_str()); filter->requestModified(SP_OBJECT_MODIFIED_FLAG); } _attr_lock = false; @@ -2421,7 +2427,7 @@ void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, cons if(filter && name && o) { update_settings_sensitivity(); - SP_OBJECT_REPR(o)->setAttribute(name, val); + o->getRepr()->setAttribute(name, val); filter->requestModified(SP_OBJECT_MODIFIED_FLAG); Glib::ustring undokey = "filtereffects:"; diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 1e0dc85a4..7c2013872 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -109,7 +109,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, , _path(path) , _spcurve(new SPCurve()) , _dragpoint(new CurveDragPoint(*this)) - , /* XML Tree being used here directly while it shouldn't be*/_observer(new PathManipulatorObserver(this, SP_OBJECT(path)->getRepr())) + , /* XML Tree being used here directly while it shouldn't be*/_observer(new PathManipulatorObserver(this, path->getRepr())) , _edit_transform(et) , _num_selected(0) , _show_handles(true) @@ -191,7 +191,7 @@ void PathManipulator::writeXML() if (!_path) return; _observer->block(); if (!empty()) { - SP_OBJECT(_path)->updateRepr(); + _path->updateRepr(); _getXMLNode()->setAttribute(_nodetypesKey().data(), _createTypeString().data()); } else { // this manipulator will have to be destroyed right after this call @@ -1430,8 +1430,8 @@ double PathManipulator::_getStrokeTolerance() * drag tolerance setting. */ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double ret = prefs->getIntLimited("/options/dragtolerance/value", 2, 0, 100); - if (_path && SP_OBJECT_STYLE(_path) && !SP_OBJECT_STYLE(_path)->stroke.isNone()) { - ret += SP_OBJECT_STYLE(_path)->stroke_width.computed * 0.5 + if (_path && _path->style && !_path->style->stroke.isNone()) { + ret += _path->style->stroke_width.computed * 0.5 * (_edit_transform * _i2d_transform).descrim() // scale to desktop coords * _desktop->current_zoom(); // == _d2w.descrim() - scale to window coords } diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index 997c2f0dc..06d57c4ac 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -146,7 +146,7 @@ ObjectCompositeSettings::_blendBlurValueChanged() } SPItem * item = SP_ITEM(*i); - SPStyle *style = SP_OBJECT_STYLE(item); + SPStyle *style = item->style; g_assert(style != NULL); if (blendmode != "normal") { |
