summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2011-02-21 07:59:34 +0000
committerJon A. Cruz <jon@joncruz.org>2011-02-21 07:59:34 +0000
commitccba415bc620a21239f11361078c8c30006106c7 (patch)
treeb68a10c9bfa0af11aed2a2db8ef8ed025af39654 /src
parentPass removing some outdated C-macro use. (diff)
downloadinkscape-ccba415bc620a21239f11361078c8c30006106c7.tar.gz
inkscape-ccba415bc620a21239f11361078c8c30006106c7.zip
Finished cleanup of outated SP_OBJECT_DOCUMENT C macro.
(bzr r10060)
Diffstat (limited to 'src')
-rw-r--r--src/knotholder.cpp12
-rw-r--r--src/layer-fns.cpp47
-rw-r--r--src/live_effects/effect.cpp18
-rw-r--r--src/live_effects/lpe-line_segment.cpp2
-rw-r--r--src/live_effects/lpeobject.cpp12
-rw-r--r--src/select-context.cpp14
-rw-r--r--src/selection-chemistry.cpp104
-rw-r--r--src/seltrans.cpp22
-rw-r--r--src/sp-clippath.cpp12
-rw-r--r--src/sp-filter.cpp18
-rw-r--r--src/sp-flowtext.cpp26
-rw-r--r--src/sp-font.cpp4
-rw-r--r--src/sp-gradient.cpp22
-rw-r--r--src/sp-image.cpp18
-rw-r--r--src/sp-item-group.cpp93
-rw-r--r--src/sp-mask.cpp33
-rw-r--r--src/sp-namedview.cpp20
-rw-r--r--src/sp-object.h1
-rw-r--r--src/sp-pattern.cpp68
-rw-r--r--src/sp-script.cpp9
-rw-r--r--src/sp-shape.cpp33
-rw-r--r--src/sp-text.cpp37
-rw-r--r--src/sp-tref.cpp78
-rw-r--r--src/spray-context.cpp16
-rw-r--r--src/style.cpp56
-rw-r--r--src/text-context.cpp25
-rw-r--r--src/text-editing.cpp347
-rw-r--r--src/tweak-context.cpp34
-rw-r--r--src/ui/context-menu.cpp22
-rw-r--r--src/ui/dialog/guides.cpp6
-rw-r--r--src/ui/dialog/icon-preview.cpp4
-rw-r--r--src/uri-references.cpp2
-rw-r--r--src/widgets/gradient-selector.cpp12
-rw-r--r--src/widgets/gradient-vector.cpp76
-rw-r--r--src/widgets/paint-selector.cpp10
-rw-r--r--src/widgets/sp-attribute-widget.cpp20
-rw-r--r--src/widgets/stroke-style.cpp66
-rw-r--r--src/widgets/swatch-selector.cpp6
-rw-r--r--src/widgets/toolbox.cpp103
39 files changed, 796 insertions, 712 deletions
diff --git a/src/knotholder.cpp b/src/knotholder.cpp
index 5ff42a7c6..59059c2a8 100644
--- a/src/knotholder.cpp
+++ b/src/knotholder.cpp
@@ -44,7 +44,7 @@ class SPDesktop;
KnotHolder::KnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFunc relhandler)
{
//XML Tree being used directly here while it shouldn't be...
- Inkscape::XML::Node *repr = SP_OBJECT(item)->getRepr();
+ Inkscape::XML::Node *repr = item->getRepr();
if (!desktop || !item || !SP_IS_ITEM(item)) {
g_print ("Error! Throw an exception, please!\n");
@@ -148,7 +148,7 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state)
}
// for drag, this is done by ungrabbed_handler, but for click we must do it here
- DocumentUndo::done(SP_OBJECT_DOCUMENT(item), object_verb,
+ DocumentUndo::done(item->document, object_verb,
_("Change handle"));
}
@@ -204,7 +204,7 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/)
Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(object));
if (lpe) {
LivePathEffectObject *lpeobj = lpe->getLPEObj();
- SP_OBJECT(lpeobj)->updateRepr();
+ lpeobj->updateRepr();
}
}
@@ -227,7 +227,7 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/)
object_verb = SP_VERB_SELECTION_DYNAMIC_OFFSET;
}
- DocumentUndo::done(SP_OBJECT_DOCUMENT (object), object_verb,
+ DocumentUndo::done(object->document, object_verb,
_("Move handle"));
}
}
@@ -241,8 +241,8 @@ KnotHolder::add(KnotHolderEntity *e)
void
KnotHolder::add_pattern_knotholder()
{
- if ((SP_OBJECT(item)->style->fill.isPaintserver())
- && SP_IS_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style)))
+ if ((item->style->fill.isPaintserver())
+ && SP_IS_PATTERN(item->style->getFillPaintServer()))
{
PatternKnotHolderEntityXY *entity_xy = new PatternKnotHolderEntityXY();
PatternKnotHolderEntityAngle *entity_angle = new PatternKnotHolderEntityAngle();
diff --git a/src/layer-fns.cpp b/src/layer-fns.cpp
index 84f21cd97..3637c11f1 100644
--- a/src/layer-fns.cpp
+++ b/src/layer-fns.cpp
@@ -51,7 +51,7 @@ SPObject *previous_sibling_layer(SPObject *layer) {
using Inkscape::Algorithms::find_last_if;
SPObject *sibling(find_last_if<SPObject::SiblingIterator>(
- SP_OBJECT_PARENT(layer)->firstChild(), layer, &is_layer
+ layer->parent->firstChild(), layer, &is_layer
));
return ( sibling != layer ) ? sibling : NULL;
@@ -91,16 +91,18 @@ SPObject *last_child_layer(SPObject *layer) {
SPObject *last_elder_layer(SPObject *root, SPObject *layer) {
using Inkscape::Algorithms::find_last_if;
+ SPObject *result = 0;
while ( layer != root ) {
SPObject *sibling(previous_sibling_layer(layer));
if (sibling) {
- return sibling;
+ result = sibling;
+ break;
}
- layer = SP_OBJECT_PARENT(layer);
+ layer = layer->parent;
}
- return NULL;
+ return result;
}
}
@@ -114,23 +116,21 @@ SPObject *next_layer(SPObject *root, SPObject *layer) {
using std::find_if;
g_return_val_if_fail(layer != NULL, NULL);
+ SPObject *result = 0;
- SPObject *sibling(next_sibling_layer(layer));
+ SPObject *sibling = next_sibling_layer(layer);
if (sibling) {
SPObject *descendant(first_descendant_layer(sibling));
if (descendant) {
- return descendant;
+ result = descendant;
} else {
- return sibling;
- }
- } else {
- SPObject *parent=SP_OBJECT_PARENT(layer);
- if ( parent != root ) {
- return parent;
- } else {
- return NULL;
+ result = sibling;
}
+ } else if ( layer->parent != root ) {
+ result = layer->parent;
}
+
+ return result;
}
@@ -143,20 +143,21 @@ SPObject *previous_layer(SPObject *root, SPObject *layer) {
using Inkscape::Algorithms::find_last_if;
g_return_val_if_fail(layer != NULL, NULL);
+ SPObject *result = 0;
- SPObject *child(last_child_layer(layer));
+ SPObject *child = last_child_layer(layer);
if (child) {
- return child;
+ result = child;
} else if ( layer != root ) {
- SPObject *sibling(previous_sibling_layer(layer));
+ SPObject *sibling = previous_sibling_layer(layer);
if (sibling) {
- return sibling;
+ result = sibling;
} else {
- return last_elder_layer(root, SP_OBJECT_PARENT(layer));
+ result = last_elder_layer(root, layer->parent);
}
}
- return NULL;
+ return result;
}
/**
@@ -168,7 +169,7 @@ SPObject *previous_layer(SPObject *root, SPObject *layer) {
* \pre \a root should be either \a layer or an ancestor of it
*/
SPObject *create_layer(SPObject *root, SPObject *layer, LayerRelativePosition position) {
- SPDocument *document=SP_OBJECT_DOCUMENT(root);
+ SPDocument *document = root->document;
static int layer_suffix=1;
gchar *id=NULL;
@@ -192,9 +193,9 @@ SPObject *create_layer(SPObject *root, SPObject *layer, LayerRelativePosition po
}
if ( root == layer ) {
- SP_OBJECT_REPR(root)->appendChild(repr);
+ root->getRepr()->appendChild(repr);
} else {
- Inkscape::XML::Node *layer_repr=SP_OBJECT_REPR(layer);
+ Inkscape::XML::Node *layer_repr = layer->getRepr();
sp_repr_parent(layer_repr)->addChild(repr, layer_repr);
if ( LPOS_BELOW == position ) {
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index f59a38fac..ed0d162ac 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -249,7 +249,7 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
}
if (neweffect) {
- neweffect->readallParameters(SP_OBJECT_REPR(lpeobj));
+ neweffect->readallParameters(lpeobj->getRepr());
}
return neweffect;
@@ -262,7 +262,7 @@ void Effect::createAndApply(const char* name, SPDocument *doc, SPItem *item)
Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect");
repr->setAttribute("effect", name);
- SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc))->addChild(repr, NULL); // adds to <defs> and assigns the 'id' attribute
+ SP_DOCUMENT_DEFS(doc)->getRepr()->addChild(repr, NULL); // adds to <defs> and assigns the 'id' attribute
const gchar * repr_id = repr->attribute("id");
Inkscape::GC::release(repr);
@@ -579,17 +579,17 @@ Effect::newWidget(Gtk::Tooltips * tooltips)
}
-Inkscape::XML::Node *
-Effect::getRepr()
+Inkscape::XML::Node *Effect::getRepr()
{
- return SP_OBJECT_REPR(lpeobj);
+ return lpeobj->getRepr();
}
-SPDocument *
-Effect::getSPDoc()
+SPDocument *Effect::getSPDoc()
{
- if (SP_OBJECT_DOCUMENT(lpeobj) == NULL) g_message("Effect::getSPDoc() returns NULL");
- return SP_OBJECT_DOCUMENT(lpeobj);
+ if (lpeobj->document == NULL) {
+ g_message("Effect::getSPDoc() returns NULL");
+ }
+ return lpeobj->document;
}
Parameter *
diff --git a/src/live_effects/lpe-line_segment.cpp b/src/live_effects/lpe-line_segment.cpp
index df5619002..da30cd32c 100644
--- a/src/live_effects/lpe-line_segment.cpp
+++ b/src/live_effects/lpe-line_segment.cpp
@@ -47,7 +47,7 @@ LPELineSegment::~LPELineSegment()
void
LPELineSegment::doBeforeEffect (SPLPEItem *lpeitem)
{
- lpetool_get_limiting_bbox_corners(SP_OBJECT_DOCUMENT(lpeitem), bboxA, bboxB);
+ lpetool_get_limiting_bbox_corners(lpeitem->document, bboxA, bboxB);
}
std::vector<Geom::Path>
diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp
index 389e18d20..1b5ed1d49 100644
--- a/src/live_effects/lpeobject.cpp
+++ b/src/live_effects/lpeobject.cpp
@@ -125,13 +125,13 @@ LivePathEffectObject::livepatheffect_release(SPObject *object)
LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object);
- SP_OBJECT_REPR(object)->removeListenerByData(object);
+ object->getRepr()->removeListenerByData(object);
/*
- if (SP_OBJECT_DOCUMENT(object)) {
+ if (object->document) {
// Unregister ourselves
- sp_document_removeResource(SP_OBJECT_DOCUMENT(object), "livepatheffect", SP_OBJECT(object));
+ sp_document_removeResource(object->document, "livepatheffect", object);
}
if (gradient->ref) {
@@ -249,11 +249,11 @@ livepatheffect_on_repr_attr_changed ( Inkscape::XML::Node * /*repr*/,
LivePathEffectObject *LivePathEffectObject::fork_private_if_necessary(unsigned int nr_of_allowed_users)
{
if (hrefcount > nr_of_allowed_users) {
- SPDocument *doc = SP_OBJECT_DOCUMENT(this);
+ SPDocument *doc = this->document;
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::XML::Node *dup_repr = SP_OBJECT_REPR (this)->duplicate(xml_doc);
+ Inkscape::XML::Node *dup_repr = this->getRepr()->duplicate(xml_doc);
- SP_OBJECT_REPR (SP_DOCUMENT_DEFS (doc))->addChild(dup_repr, NULL);
+ SP_DOCUMENT_DEFS(doc)->getRepr()->addChild(dup_repr, NULL);
LivePathEffectObject *lpeobj_new = LIVEPATHEFFECT( doc->getObjectByRepr(dup_repr) );
Inkscape::GC::release(dup_repr);
diff --git a/src/select-context.cpp b/src/select-context.cpp
index 4d1d06fe3..e6d78975b 100644
--- a/src/select-context.cpp
+++ b/src/select-context.cpp
@@ -230,11 +230,11 @@ sp_select_context_abort(SPEventContext *event_context)
if (sc->item) {
// only undo if the item is still valid
- if (SP_OBJECT_DOCUMENT( SP_OBJECT(sc->item))) {
+ if (sc->item->document) {
DocumentUndo::undo(sp_desktop_document(desktop));
}
- sp_object_unref( SP_OBJECT(sc->item), NULL);
+ sp_object_unref( sc->item, NULL);
} else if (sc->button_press_ctrl) {
// NOTE: This is a workaround to a bug.
// When the ctrl key is held, sc->item is not defined
@@ -286,9 +286,9 @@ sp_select_context_up_one_layer(SPDesktop *desktop)
*/
SPObject *const current_layer = desktop->currentLayer();
if (current_layer) {
- SPObject *const parent = SP_OBJECT_PARENT(current_layer);
+ SPObject *const parent = current_layer->parent;
if ( parent
- && ( SP_OBJECT_PARENT(parent)
+ && ( parent->parent
|| !( SP_IS_GROUP(current_layer)
&& ( SPGroup::LAYER
== SP_GROUP(current_layer)->layerMode() ) ) ) )
@@ -313,7 +313,7 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE
tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
// make sure we still have valid objects to move around
- if (sc->item && SP_OBJECT_DOCUMENT( SP_OBJECT(sc->item))==NULL) {
+ if (sc->item && sc->item->document == NULL) {
sp_select_context_abort(event_context);
}
@@ -460,7 +460,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// make sure we still have valid objects to move around
- if (sc->item && SP_OBJECT_DOCUMENT( SP_OBJECT(sc->item))==NULL) {
+ if (sc->item && sc->item->document == NULL) {
sp_select_context_abort(event_context);
}
@@ -652,7 +652,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
sp_canvas_end_forced_full_redraws(desktop->canvas);
if (sc->item) {
- sp_object_unref( SP_OBJECT(sc->item), NULL);
+ sp_object_unref( sc->item, NULL);
}
sc->item = NULL;
} else {
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 9acacf7d5..5ae4205bb 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -243,7 +243,7 @@ void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::D
// Copy item reprs:
for (GSList *i = (GSList *) sorted_items; i != NULL; i = i->next) {
- sp_selection_copy_one(SP_OBJECT_REPR(i->data), SP_ITEM(i->data)->i2doc_affine(), clip, xml_doc);
+ sp_selection_copy_one(SP_OBJECT(i->data)->getRepr(), SP_ITEM(i->data)->i2doc_affine(), clip, xml_doc);
}
*clip = g_slist_reverse(*clip);
@@ -412,7 +412,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone)
// std::cout << id << " old, its ori: " << orig->getId() << "; will relink:" << new_ids[i] << " to " << new_ids[j] << "\n";
gchar *newref = g_strdup_printf("#%s", new_ids[j]);
SPObject *new_clone = doc->getObjectById(new_ids[i]);
- SP_OBJECT_REPR(new_clone)->setAttribute("xlink:href", newref);
+ new_clone->getRepr()->setAttribute("xlink:href", newref);
new_clone->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
g_free(newref);
}
@@ -695,7 +695,7 @@ void sp_selection_ungroup(SPDesktop *desktop)
}
/* We do not allow ungrouping <svg> etc. (lauris) */
- if (strcmp(SP_OBJECT_REPR(group)->name(), "svg:g") && strcmp(SP_OBJECT_REPR(group)->name(), "svg:switch")) {
+ if (strcmp(group->getRepr()->name(), "svg:g") && strcmp(group->getRepr()->name(), "svg:switch")) {
// keep the non-group item in the new selection
new_select = g_slist_append(new_select, group);
continue;
@@ -759,13 +759,13 @@ sp_item_list_common_parent_group(GSList const *items)
if (!items) {
return NULL;
}
- SPObject *parent = SP_OBJECT_PARENT(items->data);
- /* Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor */
+ SPObject *parent = SP_OBJECT(items->data)->parent;
+ // Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor
if (!SP_IS_GROUP(parent)) {
return NULL;
}
for (items = items->next; items; items = items->next) {
- if (SP_OBJECT_PARENT(items->data) != parent) {
+ if (SP_OBJECT(items->data)->parent != parent) {
return NULL;
}
}
@@ -816,7 +816,7 @@ sp_selection_raise(SPDesktop *desktop)
return;
}
- Inkscape::XML::Node *grepr = SP_OBJECT_REPR(group);
+ Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(group->getRepr());
/* Construct reverse-ordered list of selected children. */
GSList *rev = g_slist_copy((GSList *) items);
@@ -838,7 +838,7 @@ sp_selection_raise(SPDesktop *desktop)
// AND if it's not one of our selected objects,
if (!g_slist_find((GSList *) items, newref)) {
// move the selected object after that sibling
- grepr->changeOrder(SP_OBJECT_REPR(child), SP_OBJECT_REPR(newref));
+ grepr->changeOrder(child->getRepr(), newref->getRepr());
}
break;
}
@@ -910,7 +910,7 @@ sp_selection_lower(SPDesktop *desktop)
return;
}
- Inkscape::XML::Node *grepr = SP_OBJECT_REPR(group);
+ Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(group->getRepr());
// Determine the common bbox of the selected items.
Geom::OptRect selected = enclose_items(items);
@@ -935,9 +935,9 @@ sp_selection_lower(SPDesktop *desktop)
// move the selected object before that sibling
SPObject *put_after = prev_sibling(newref);
if (put_after)
- grepr->changeOrder(SP_OBJECT_REPR(child), SP_OBJECT_REPR(put_after));
+ grepr->changeOrder(child->getRepr(), put_after->getRepr());
else
- SP_OBJECT_REPR(child)->setPosition(0);
+ child->getRepr()->setPosition(0);
}
break;
}
@@ -1320,7 +1320,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons
std::list<SPBox3D *> selboxes = selection->box3DList(persp);
// create a new perspective as a copy of the current one and link the selected boxes to it
- transf_persp = persp3d_create_xml_element (SP_OBJECT_DOCUMENT(persp), persp->perspective_impl);
+ transf_persp = persp3d_create_xml_element (persp->document, persp->perspective_impl);
for (std::list<SPBox3D *>::iterator b = selboxes.begin(); b != selboxes.end(); ++b)
box3d_switch_perspectives(*b, persp, transf_persp);
@@ -1381,7 +1381,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons
* Same for linked offset if we are also moving its source: do not move it. */
if (transform_textpath_with_path || transform_offset_with_source) {
// Restore item->transform field from the repr, in case it was changed by seltrans.
- SP_OBJECT(item)->readAttr( "transform" );
+ item->readAttr( "transform" );
} else if (transform_flowtext_with_frame) {
// apply the inverse of the region's transform to the <use> so that the flow remains
// the same (even though the output itself gets transformed)
@@ -1400,10 +1400,10 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons
// transform and its move compensation are both cancelled out.
// restore item->transform field from the repr, in case it was changed by seltrans
- SP_OBJECT(item)->readAttr( "transform" );
+ item->readAttr( "transform" );
// calculate the matrix we need to apply to the clone to cancel its induced transform from its original
- Geom::Affine parent2dt = SP_ITEM(SP_OBJECT_PARENT(item))->i2d_affine();
+ Geom::Affine parent2dt = SP_ITEM(item->parent)->i2d_affine();
Geom::Affine t = parent2dt * affine * parent2dt.inverse();
Geom::Affine t_inv = t.inverse();
Geom::Affine result = t_inv * item->transform * t;
@@ -1417,25 +1417,25 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons
if (prefs_parallel) {
Geom::Affine move = result * clone_move * t_inv;
- item->doWriteTransform(SP_OBJECT_REPR(item), move, &move, compensate);
+ item->doWriteTransform(item->getRepr(), move, &move, compensate);
} else if (prefs_unmoved) {
//if (SP_IS_USE(sp_use_get_original(SP_USE(item))))
// clone_move = Geom::identity();
Geom::Affine move = result * clone_move;
- item->doWriteTransform(SP_OBJECT_REPR(item), move, &t, compensate);
+ item->doWriteTransform(item->getRepr(), move, &t, compensate);
}
} else {
// just apply the result
- item->doWriteTransform(SP_OBJECT_REPR(item), result, &t, compensate);
+ item->doWriteTransform(item->getRepr(), result, &t, compensate);
}
} else {
if (set_i2d) {
item->set_i2d_affine(item->i2d_affine() * (Geom::Affine)affine);
}
- item->doWriteTransform(SP_OBJECT_REPR(item), item->transform, NULL, compensate);
+ item->doWriteTransform(item->getRepr(), item->transform, NULL, compensate);
}
// if we're moving the actual object, not just updating the repr, we can transform the
@@ -1766,7 +1766,7 @@ struct ListReverse {
return make_list(o->firstChild(), NULL);
}
static Iterator siblings_after(SPObject *o) {
- return make_list(SP_OBJECT_PARENT(o)->firstChild(), o);
+ return make_list(o->parent->firstChild(), o);
}
static void dispose(Iterator i) {
g_slist_free(i);
@@ -1897,8 +1897,8 @@ void sp_selection_edit_clip_or_mask(SPDesktop * /*dt*/, bool /*clip*/)
for (GSList *i = const_cast<GSList*>(items); i; i= i->next) {
SPItem *item = SP_ITEM(i->data);
SPObject *search = clip
- ? SP_OBJECT(item->clip_ref ? item->clip_ref->getObject() : NULL)
- : SP_OBJECT(item->mask_ref ? item->mask_ref->getObject() : NULL);
+ ? (item->clip_ref ? item->clip_ref->getObject() : NULL)
+ : item->mask_ref ? item->mask_ref->getObject() : NULL;
has_path |= has_path_recursive(search);
if (has_path) break;
}
@@ -1939,7 +1939,7 @@ SPItem *next_item_from_list(SPDesktop *desktop, GSList const *items,
GSList *path=NULL;
while ( current != root ) {
path = g_slist_prepend(path, current);
- current = SP_OBJECT_PARENT(current);
+ current = current->parent;
}
SPItem *next;
@@ -1965,7 +1965,7 @@ SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root,
if (path) {
SPObject *object=reinterpret_cast<SPObject *>(path->data);
- g_assert(SP_OBJECT_PARENT(object) == root);
+ g_assert(object->parent == root);
if (desktop->isLayer(object)) {
found = next_item<D>(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive);
}
@@ -2105,7 +2105,7 @@ sp_selection_relink(SPDesktop *desktop)
if (!SP_IS_USE(item))
continue;
- SP_OBJECT_REPR(item)->setAttribute("xlink:href", newref);
+ item->getRepr()->setAttribute("xlink:href", newref);
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
relinked = true;
}
@@ -2215,7 +2215,7 @@ sp_select_clone_original(SPDesktop *desktop)
} else if (SP_IS_OFFSET(item) && SP_OFFSET(item)->sourceHref) {
original = sp_offset_get_source(SP_OFFSET(item));
} else if (SP_IS_TEXT_TEXTPATH(item)) {
- original = sp_textpath_get_path_item(SP_TEXTPATH(SP_OBJECT(item)->firstChild()));
+ original = sp_textpath_get_path_item(SP_TEXTPATH(item->firstChild()));
} else if (SP_IS_FLOWTEXT(item)) {
original = SP_FLOWTEXT(item)->get_frame(NULL); // first frame only
} else { // it's an object that we don't know what to do with
@@ -2228,7 +2228,7 @@ sp_select_clone_original(SPDesktop *desktop)
return;
}
- for (SPObject *o = original; o && !SP_IS_ROOT(o); o = SP_OBJECT_PARENT(o)) {
+ for (SPObject *o = original; o && !SP_IS_ROOT(o); o = o->parent) {
if (SP_IS_DEFS(o)) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The object you're trying to select is <b>not visible</b> (it is in &lt;defs&gt;)"));
return;
@@ -2298,18 +2298,18 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position);
// bottommost object, after sorting
- SPObject *parent = SP_OBJECT_PARENT(items->data);
+ SPObject *parent = SP_OBJECT(items->data)->parent;
Geom::Affine parent_transform(SP_ITEM(parent)->i2doc_affine());
// remember the position of the first item
- gint pos = SP_OBJECT_REPR(items->data)->position();
+ gint pos = SP_OBJECT(items->data)->getRepr()->position();
(void)pos; // TODO check why this was remembered
// create a list of duplicates
GSList *repr_copies = NULL;
for (GSList *i = items; i != NULL; i = i->next) {
- Inkscape::XML::Node *dup = (SP_OBJECT_REPR(i->data))->duplicate(xml_doc);
+ Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc);
repr_copies = g_slist_prepend(repr_copies, dup);
}
@@ -2422,17 +2422,17 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position);
// bottommost object, after sorting
- SPObject *parent = SP_OBJECT_PARENT(items->data);
+ SPObject *parent = SP_OBJECT(items->data)->parent;
Geom::Affine parent_transform(SP_ITEM(parent)->i2doc_affine());
// remember the position of the first item
- gint pos = SP_OBJECT_REPR(items->data)->position();
+ gint pos = SP_OBJECT(items->data)->getRepr()->position();
// create a list of duplicates
GSList *repr_copies = NULL;
for (GSList *i = items; i != NULL; i = i->next) {
- Inkscape::XML::Node *dup = (SP_OBJECT_REPR(i->data))->duplicate(xml_doc);
+ Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc);
repr_copies = g_slist_prepend(repr_copies, dup);
}
// restore the z-order after prepends
@@ -2477,7 +2477,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
sp_repr_set_svg_double(rect, "y", min[Geom::Y]);
// restore parent and position
- SP_OBJECT_REPR(parent)->appendChild(rect);
+ parent->getRepr()->appendChild(rect);
rect->setPosition(pos > 0 ? pos : 0);
SPItem *rectangle = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(rect);
@@ -2538,7 +2538,7 @@ void sp_selection_untile(SPDesktop *desktop)
pat_transform *= item->transform;
for (SPObject *child = pattern->firstChild() ; child != NULL; child = child->next ) {
- Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate(xml_doc);
+ Inkscape::XML::Node *copy = child->getRepr()->duplicate(xml_doc);
SPItem *i = SP_ITEM(desktop->currentLayer()->appendChildRepr(copy));
// FIXME: relink clones to the new canvas objects
@@ -2548,14 +2548,14 @@ void sp_selection_untile(SPDesktop *desktop)
doc->ensureUpToDate();
Geom::Affine transform( i->transform * pat_transform );
- i->doWriteTransform(SP_OBJECT_REPR(i), transform);
+ i->doWriteTransform(i->getRepr(), transform);
new_select = g_slist_prepend(new_select, i);
}
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill", "none");
- sp_repr_css_change(SP_OBJECT_REPR(item), css, "style");
+ sp_repr_css_change(item->getRepr(), css, "style");
}
if (!did) {
@@ -2676,7 +2676,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
// Create the filename.
gchar *const basename = g_strdup_printf("%s-%s-%u.png",
document->getName(),
- SP_OBJECT_REPR(items->data)->attribute("id"),
+ SP_OBJECT(items->data)->getRepr()->attribute("id"),
current);
// Imagemagick is known not to handle spaces in filenames, so we replace anything but letters,
// digits, and a few other chars, with "_"
@@ -2695,9 +2695,9 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
//g_print("%s\n", filepath);
// Remember parent and z-order of the topmost one
- gint pos = SP_OBJECT_REPR(g_slist_last(items)->data)->position();
- SPObject *parent_object = SP_OBJECT_PARENT(g_slist_last(items)->data);
- Inkscape::XML::Node *parent = SP_OBJECT_REPR(parent_object);
+ gint pos = SP_OBJECT(g_slist_last(items)->data)->getRepr()->position();
+ SPObject *parent_object = SP_OBJECT(g_slist_last(items)->data)->parent;
+ Inkscape::XML::Node *parent = parent_object->getRepr();
// Calculate resolution
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -2894,7 +2894,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_
apply_to_items = g_slist_prepend(apply_to_items, desktop->currentLayer());
for (GSList *i = items; i != NULL; i = i->next) {
- Inkscape::XML::Node *dup = (SP_OBJECT_REPR(i->data))->duplicate(xml_doc);
+ Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc);
mask_items = g_slist_prepend(mask_items, dup);
SPObject *item = reinterpret_cast<SPObject*>(i->data);
@@ -2908,7 +2908,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_
} else if (!topmost) {
// topmost item is used as a mask, which is applied to other items in a selection
GSList *i = items;
- Inkscape::XML::Node *dup = (SP_OBJECT_REPR(i->data))->duplicate(xml_doc);
+ Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc);
mask_items = g_slist_prepend(mask_items, dup);
if (remove_original) {
@@ -2927,7 +2927,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_
items_to_select = g_slist_prepend(items_to_select, i->data);
}
- Inkscape::XML::Node *dup = (SP_OBJECT_REPR(i->data))->duplicate(xml_doc);
+ Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc);
mask_items = g_slist_prepend(mask_items, dup);
if (remove_original) {
@@ -2950,8 +2950,8 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_
GSList *reprs_to_group = NULL;
for (GSList *i = apply_to_items ; NULL != i ; i = i->next) {
- reprs_to_group = g_slist_prepend(reprs_to_group, SP_OBJECT_REPR(i->data));
- items_to_select = g_slist_remove(items_to_select, i->data);
+ reprs_to_group = g_slist_prepend(reprs_to_group, SP_OBJECT(i->data)->getRepr());
+ items_to_select = g_slist_remove(items_to_select, i->data);
}
reprs_to_group = g_slist_reverse(reprs_to_group);
@@ -2992,7 +2992,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_
g_slist_free(mask_items_dup);
mask_items_dup = NULL;
- Inkscape::XML::Node *current = SP_OBJECT_REPR(i->data);
+ Inkscape::XML::Node *current = SP_OBJECT(i->data)->getRepr();
// Node to apply mask to
Inkscape::XML::Node *apply_mask_to = current;
@@ -3095,7 +3095,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
}
}
- SP_OBJECT_REPR(i->data)->setAttribute(attributeName, "none");
+ SP_OBJECT(i->data)->getRepr()->setAttribute(attributeName, "none");
if (ungroup_masked && SP_IS_GROUP(i->data)) {
// if we had previously enclosed masked object in group,
@@ -3117,7 +3117,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
GSList *items_to_move = NULL;
for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) {
// Collect all clipped paths and masks within a single group
- Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate(xml_doc);
+ Inkscape::XML::Node *copy = SP_OBJECT(child)->getRepr()->duplicate(xml_doc);
items_to_move = g_slist_prepend(items_to_move, copy);
}
@@ -3127,8 +3127,8 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
}
// remember parent and position of the item to which the clippath/mask was applied
- Inkscape::XML::Node *parent = SP_OBJECT_REPR((*it).second)->parent();
- gint pos = SP_OBJECT_REPR((*it).second)->position();
+ Inkscape::XML::Node *parent = ((*it).second)->getRepr()->parent();
+ gint pos = ((*it).second)->getRepr()->position();
// Iterate through all clipped paths / masks
for (GSList *i = items_to_move; NULL != i; i = i->next) {
@@ -3144,7 +3144,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
// transform mask, so it is moved the same spot where mask was applied
Geom::Affine transform(mask_item->transform);
transform *= (*it).second->transform;
- mask_item->doWriteTransform(SP_OBJECT_REPR(mask_item), transform);
+ mask_item->doWriteTransform(mask_item->getRepr(), transform);
}
g_slist_free(items_to_move);
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 848c0836a..f05ccaa6b 100644
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -201,7 +201,7 @@ Inkscape::SelTrans::~SelTrans()
}
for (unsigned i = 0; i < _items.size(); i++) {
- sp_object_unref(SP_OBJECT(_items[i]), NULL);
+ sp_object_unref(_items[i], NULL);
}
_items.clear();
@@ -235,7 +235,7 @@ void Inkscape::SelTrans::setCenter(Geom::Point const &p)
// Write the new center position into all selected items
for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) {
- SPItem *it = (SPItem*)SP_OBJECT(l->data);
+ SPItem *it = SP_ITEM(l->data);
it->setCenter(p);
// only set the value; updating repr and document_done will be done once, on ungrab
}
@@ -264,7 +264,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s
}
for (GSList const *l = selection->itemList(); l; l = l->next) {
- SPItem *it = (SPItem *)sp_object_ref(SP_OBJECT(l->data), NULL);
+ SPItem *it = reinterpret_cast<SPItem*>(sp_object_ref(SP_ITEM(l->data), NULL));
_items.push_back(it);
_items_const.push_back(it);
_items_affines.push_back(it->i2d_affine());
@@ -463,7 +463,7 @@ void Inkscape::SelTrans::ungrab()
_updateVolatileState();
for (unsigned i = 0; i < _items.size(); i++) {
- sp_object_unref(SP_OBJECT(_items[i]), NULL);
+ sp_object_unref(_items[i], NULL);
}
sp_canvas_item_hide(_norm);
@@ -496,7 +496,7 @@ void Inkscape::SelTrans::ungrab()
SPItem *currentItem = _items[i];
if (currentItem->isCenterSet()) { // only if it's already set
currentItem->setCenter (_items_centers[i] * _current_relative_affine);
- SP_OBJECT(currentItem)->updateRepr();
+ currentItem->updateRepr();
}
}
}
@@ -525,8 +525,8 @@ void Inkscape::SelTrans::ungrab()
if (_center_is_set) {
// we were dragging center; update reprs and commit undoable action
for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) {
- SPItem *it = (SPItem*)SP_OBJECT(l->data);
- SP_OBJECT(it)->updateRepr();
+ SPItem *it = SP_ITEM(l->data);
+ it->updateRepr();
}
DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT,
_("Set center"));
@@ -568,7 +568,7 @@ void Inkscape::SelTrans::stamp()
while (l) {
SPItem *original_item = SP_ITEM(l->data);
- Inkscape::XML::Node *original_repr = SP_OBJECT_REPR(original_item);
+ Inkscape::XML::Node *original_repr = original_item->getRepr();
// remember the position of the item
gint pos = original_repr->position();
@@ -786,9 +786,9 @@ void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHa
if (state & GDK_SHIFT_MASK) {
// Unset the center position for all selected items
for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) {
- SPItem *it = (SPItem*)(SP_OBJECT(l->data));
+ SPItem *it = SP_ITEM(l->data);
it->unsetCenter();
- SP_OBJECT(it)->updateRepr();
+ it->updateRepr();
_center_is_set = false; // center has changed
_updateHandles();
}
@@ -835,7 +835,7 @@ void Inkscape::SelTrans::handleNewEvent(SPKnot *knot, Geom::Point *position, gui
// in case items have been unhooked from the document, don't
// try to continue processing events for them.
for (unsigned int i = 0; i < _items.size(); i++) {
- if (!SP_OBJECT_DOCUMENT(SP_OBJECT(_items[i])) ) {
+ if ( !_items[i]->document ) {
return;
}
}
diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp
index 4e6f41a70..be5b9a4d1 100644
--- a/src/sp-clippath.cpp
+++ b/src/sp-clippath.cpp
@@ -98,9 +98,9 @@ void SPClipPath::build(SPObject *object, SPDocument *document, Inkscape::XML::No
void SPClipPath::release(SPObject * object)
{
- if (SP_OBJECT_DOCUMENT(object)) {
- /* Unregister ourselves */
- SP_OBJECT_DOCUMENT(object)->removeResource("clipPath", object);
+ if (object->document) {
+ // Unregister ourselves
+ object->document->removeResource("clipPath", object);
}
SPClipPath *cp = SP_CLIPPATH(object);
@@ -146,7 +146,7 @@ void SPClipPath::childAdded(SPObject *object, Inkscape::XML::Node *child, Inksca
((SPObjectClass *) (SPClipPathClass::static_parent_class))->child_added(object, child, ref);
/* Show new object */
- SPObject *ochild = SP_OBJECT_DOCUMENT(object)->getObjectByRepr(child);
+ SPObject *ochild = object->document->getObjectByRepr(child);
if (SP_IS_ITEM(ochild)) {
SPClipPath *cp = SP_CLIPPATH(object);
for (SPClipPathView *v = cp->display; v != NULL; v = v->next) {
@@ -357,7 +357,7 @@ sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view)
// Create a mask element (using passed elements), add it to <defs>
const gchar *SPClipPath::create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform)
{
- Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document));
+ Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr();
Inkscape::XML::Document *xml_doc = document->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:clipPath");
@@ -374,7 +374,7 @@ const gchar *SPClipPath::create (GSList *reprs, SPDocument *document, Geom::Affi
if (NULL != applyTransform) {
Geom::Affine transform (item->transform);
transform *= (*applyTransform);
- item->doWriteTransform(SP_OBJECT_REPR(item), transform);
+ item->doWriteTransform(item->getRepr(), transform);
}
}
diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp
index cfd6253a3..fd4319320 100644
--- a/src/sp-filter.cpp
+++ b/src/sp-filter.cpp
@@ -99,7 +99,7 @@ sp_filter_class_init(SPFilterClass *klass)
static void
sp_filter_init(SPFilter *filter)
{
- filter->href = new SPFilterReference(SP_OBJECT(filter));
+ filter->href = new SPFilterReference(filter);
filter->href->changedSignal().connect(sigc::bind(sigc::ptr_fun(filter_ref_changed), filter));
filter->x = 0;
@@ -152,14 +152,13 @@ sp_filter_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
/**
* Drops any allocated memory.
*/
-static void
-sp_filter_release(SPObject *object)
+static void sp_filter_release(SPObject *object)
{
SPFilter *filter = SP_FILTER(object);
- if (SP_OBJECT_DOCUMENT(object)) {
- /* Unregister ourselves */
- SP_OBJECT_DOCUMENT(object)->removeResource("filter", SP_OBJECT(object));
+ if (object->document) {
+ // Unregister ourselves
+ object->document->removeResource("filter", object);
}
//TODO: release resources here
@@ -404,10 +403,9 @@ filter_ref_changed(SPObject *old_ref, SPObject *ref, SPFilter *filter)
filter_ref_modified(ref, 0, filter);
}
-static void
-filter_ref_modified(SPObject */*href*/, guint /*flags*/, SPFilter *filter)
+static void filter_ref_modified(SPObject */*href*/, guint /*flags*/, SPFilter *filter)
{
- SP_OBJECT(filter)->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ filter->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
/**
@@ -552,7 +550,7 @@ Glib::ustring sp_filter_get_new_result_name(SPFilter *filter) {
SPObject *primitive_obj = filter->children;
while (primitive_obj) {
if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(primitive_obj);
+ Inkscape::XML::Node *repr = primitive_obj->getRepr();
char const *result = repr->attribute("result");
int index;
if (result && sscanf(result, "result%d", &index) == 1) {
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index 2db1d8787..d7bc0053f 100644
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
@@ -180,7 +180,7 @@ static void sp_flowtext_update(SPObject *object, SPCtx *ctx, unsigned flags)
group->invoke_bbox( &paintbox, Geom::identity(), TRUE);
for (SPItemView *v = group->display; v != NULL; v = v->next) {
group->_clearFlow(NR_ARENA_GROUP(v->arenaitem));
- nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
+ nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style);
// pass the bbox of the flowtext object as paintbox (used for paintserver fills)
group->layout.show(NR_ARENA_GROUP(v->arenaitem), &paintbox);
}
@@ -201,7 +201,7 @@ static void sp_flowtext_modified(SPObject *object, guint flags)
text->invoke_bbox( &paintbox, Geom::identity(), TRUE);
for (SPItemView* v = text->display; v != NULL; v = v->next) {
text->_clearFlow(NR_ARENA_GROUP(v->arenaitem));
- nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
+ nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style);
text->layout.show(NR_ARENA_GROUP(v->arenaitem), &paintbox);
}
}
@@ -241,7 +241,7 @@ sp_flowtext_set(SPObject *object, unsigned key, gchar const *value)
case SP_ATTR_LAYOUT_OPTIONS: {
// deprecated attribute, read for backward compatibility only
//XML Tree being directly used while it shouldn't be.
- SPCSSAttr *opts = sp_repr_css_attr((SP_OBJECT(group))->getRepr(), "inkscape:layoutOptions");
+ SPCSSAttr *opts = sp_repr_css_attr(group->getRepr(), "inkscape:layoutOptions");
{
gchar const *val = sp_repr_css_property(opts, "justification", NULL);
if (val != NULL && !object->style->text_align.set) {
@@ -334,7 +334,7 @@ sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform
group->layout.getBoundingBox(bbox, transform);
// Add stroke width
- SPStyle* style=SP_OBJECT_STYLE (item);
+ SPStyle* style = item->style;
if ( !style->stroke.isNone() ) {
double const scale = transform.descrim();
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
@@ -366,8 +366,8 @@ sp_flowtext_print(SPItem *item, SPPrintContext *ctx)
NRRect dbox;
dbox.x0 = 0.0;
dbox.y0 = 0.0;
- dbox.x1 = SP_OBJECT_DOCUMENT(item)->getWidth();
- dbox.y1 = SP_OBJECT_DOCUMENT(item)->getHeight();
+ dbox.x1 = item->document->getWidth();
+ dbox.y1 = item->document->getHeight();
Geom::Affine const ctm (item->i2d_affine());
group->layout.print(ctx, &pbox, &dbox, &bbox, ctm);
@@ -438,7 +438,7 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape,
if (SP_IS_FLOWPARA(root)) {
// emulate par-indent with the first char's kern
SPObject *t = root;
- for ( ; t != NULL && !SP_IS_FLOWTEXT(t); t = SP_OBJECT_PARENT(t)){};
+ for ( ; t != NULL && !SP_IS_FLOWTEXT(t); t = t->parent){};
if (SP_IS_FLOWTEXT(t)) {
double indent = SP_FLOWTEXT(t)->par_indent;
if (indent != 0) {
@@ -556,10 +556,10 @@ SPFlowtext::getAsText()
SPItem *item = SP_ITEM(this);
- Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(this)->getReprDoc();
+ Inkscape::XML::Document *xml_doc = this->document->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:text");
repr->setAttribute("xml:space", "preserve");
- repr->setAttribute("style", SP_OBJECT_REPR(this)->attribute("style"));
+ repr->setAttribute("style", this->getRepr()->attribute("style"));
Geom::Point anchor_point = this->layout.characterAnchorPoint(this->layout.begin());
sp_repr_set_svg_double(repr, "x", anchor_point[Geom::X]);
sp_repr_set_svg_double(repr, "y", anchor_point[Geom::Y]);
@@ -695,7 +695,7 @@ bool SPFlowtext::has_internal_frame()
{
SPItem *frame = get_frame(NULL);
- return (frame && SP_OBJECT(this)->isAncestorOf(SP_OBJECT(frame)) && SP_IS_RECT(frame));
+ return (frame && this->isAncestorOf(frame) && SP_IS_RECT(frame));
}
@@ -718,7 +718,7 @@ SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p0,
Inkscape::XML::Node *rect_repr = xml_doc->createElement("svg:rect"); // FIXME: use path!!! after rects are converted to use path
region_repr->appendChild(rect_repr);
- SPObject *rect = doc->getObjectByRepr(rect_repr);
+ SPRect *rect = SP_RECT(doc->getObjectByRepr(rect_repr));
p0 *= desktop->dt2doc();
p1 *= desktop->dt2doc();
@@ -731,8 +731,8 @@ SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p0,
Geom::Coord const w = x1 - x0;
Geom::Coord const h = y1 - y0;
- sp_rect_position_set(SP_RECT(rect), x0, y0, w, h);
- SP_OBJECT(rect)->updateRepr();
+ sp_rect_position_set(rect, x0, y0, w, h);
+ rect->updateRepr();
Inkscape::XML::Node *para_repr = xml_doc->createElement("svg:flowPara");
root_repr->appendChild(para_repr);
diff --git a/src/sp-font.cpp b/src/sp-font.cpp
index 64f7bd481..852e6ba5d 100644
--- a/src/sp-font.cpp
+++ b/src/sp-font.cpp
@@ -151,7 +151,7 @@ sp_font_remove_child(SPObject *object, Inkscape::XML::Node *child)
static void sp_font_release(SPObject *object)
{
//SPFont *font = SP_FONT(object);
- SP_OBJECT_DOCUMENT(object)->removeResource("font", object);
+ object->document->removeResource("font", object);
if (((SPObjectClass *) parent_class)->release) {
((SPObjectClass *) parent_class)->release(object);
@@ -263,7 +263,7 @@ static Inkscape::XML::Node *sp_font_write(SPObject *object, Inkscape::XML::Docum
sp_repr_set_svg_double(repr, "vert-origin-y", font->vert_origin_y);
sp_repr_set_svg_double(repr, "vert-adv-y", font->vert_adv_y);
- if (repr != SP_OBJECT_REPR(object)) {
+ if (repr != object->getRepr()) {
// All the below COPY_ATTR funtions are directly using
// the XML Tree while they shouldn't
COPY_ATTR(repr, object->getRepr(), "horiz-origin-x");
diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp
index 06008c083..ad422a6ca 100644
--- a/src/sp-gradient.cpp
+++ b/src/sp-gradient.cpp
@@ -375,7 +375,7 @@ void SPGradientImpl::classInit(SPGradientClass *klass)
*/
void SPGradientImpl::init(SPGradient *gr)
{
- gr->ref = new SPGradientReference(SP_OBJECT(gr));
+ gr->ref = new SPGradientReference(gr);
gr->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(SPGradientImpl::gradientRefChanged), gr));
/** \todo
@@ -447,9 +447,9 @@ void SPGradientImpl::release(SPObject *object)
g_print("Releasing gradient %s\n", object->getId());
#endif
- if (SP_OBJECT_DOCUMENT(object)) {
- /* Unregister ourselves */
- SP_OBJECT_DOCUMENT(object)->removeResource("gradient", SP_OBJECT(object));
+ if (object->document) {
+ // Unregister ourselves
+ object->document->removeResource("gradient", object);
}
if (gradient->ref) {
@@ -932,7 +932,7 @@ SPGradientUnits SPGradient::fetchUnits()
void
sp_gradient_repr_clear_vector(SPGradient *gr)
{
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(gr);
+ Inkscape::XML::Node *repr = gr->getRepr();
/* Collect stops from original repr */
GSList *sl = NULL;
@@ -962,8 +962,8 @@ sp_gradient_repr_write_vector(SPGradient *gr)
g_return_if_fail(gr != NULL);
g_return_if_fail(SP_IS_GRADIENT(gr));
- Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(gr)->getReprDoc();
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(gr);
+ Inkscape::XML::Document *xml_doc = gr->document->getReprDoc();
+ Inkscape::XML::Node *repr = gr->getRepr();
/* We have to be careful, as vector may be our own, so construct repr list at first */
GSList *cl = NULL;
@@ -995,7 +995,7 @@ sp_gradient_repr_write_vector(SPGradient *gr)
void SPGradientImpl::gradientRefModified(SPObject */*href*/, guint /*flags*/, SPGradient *gradient)
{
if ( gradient->invalidateVector() ) {
- SP_OBJECT(gradient)->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ gradient->requestModified(SP_OBJECT_MODIFIED_FLAG);
// Conditional to avoid causing infinite loop if there's a cycle in the href chain.
}
}
@@ -1427,7 +1427,7 @@ sp_gradient_set_gs2d_matrix(SPGradient *gr, Geom::Affine const &ctm,
}
gr->gradientTransform_set = TRUE;
- SP_OBJECT(gr)->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ gr->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
/*
@@ -1689,7 +1689,7 @@ sp_lineargradient_set_position(SPLinearGradient *lg,
lg->x2.set(SVGLength::NONE, x2, x2);
lg->y2.set(SVGLength::NONE, y2, y2);
- SP_OBJECT(lg)->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ lg->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
/**
@@ -1968,7 +1968,7 @@ sp_radialgradient_set_position(SPRadialGradient *rg,
rg->fy.set(SVGLength::NONE, fy, fy);
rg->r.set(SVGLength::NONE, r, r);
- SP_OBJECT(rg)->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ rg->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
/**
diff --git a/src/sp-image.cpp b/src/sp-image.cpp
index b23c2e161..ed9d84b70 100644
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
@@ -655,9 +655,9 @@ sp_image_release (SPObject *object)
{
SPImage *image = SP_IMAGE(object);
- if (SP_OBJECT_DOCUMENT (object)) {
- /* Unregister ourselves */
- SP_OBJECT_DOCUMENT(object)->removeResource("image", SP_OBJECT(object));
+ if (object->document) {
+ // Unregister ourselves
+ object->document->removeResource("image", object);
}
if (image->href) {
@@ -818,7 +818,7 @@ static void
sp_image_update (SPObject *object, SPCtx *ctx, unsigned int flags)
{
SPImage *image = SP_IMAGE(object);
- SPDocument *doc = SP_OBJECT_DOCUMENT(object);
+ SPDocument *doc = object->document;
if (((SPObjectClass *) (parent_class))->update) {
((SPObjectClass *) (parent_class))->update (object, ctx, flags);
@@ -862,7 +862,7 @@ sp_image_update (SPObject *object, SPCtx *ctx, unsigned int flags)
DEBUG_MESSAGE( lcmsFive, "in <image>'s sp_image_update. About to call colorprofile_get_handle()" );
#endif // DEBUG_LCMS
guint profIntent = Inkscape::RENDERING_INTENT_UNKNOWN;
- cmsHPROFILE prof = Inkscape::colorprofile_get_handle( SP_OBJECT_DOCUMENT( object ),
+ cmsHPROFILE prof = Inkscape::colorprofile_get_handle( object->document,
&profIntent,
image->color_profile );
if ( prof ) {
@@ -1124,9 +1124,9 @@ sp_image_print (SPItem *item, SPPrintContext *ctx)
}
if (image->aspect_align == SP_ASPECT_NONE) {
- sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, &t, SP_OBJECT_STYLE (item));
+ sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, &t, item->style);
} else { // preserveAspectRatio
- sp_print_image_R8G8B8A8_N(ctx, px + image->trimx*pixskip + image->trimy*rs, image->trimwidth, image->trimheight, rs, &t, SP_OBJECT_STYLE(item));
+ sp_print_image_R8G8B8A8_N(ctx, px + image->trimx*pixskip + image->trimy*rs, image->trimwidth, image->trimheight, rs, &t, item->style);
}
}
}
@@ -1164,7 +1164,7 @@ sp_image_show (SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int
if (image->pixbuf) {
int pixskip = gdk_pixbuf_get_n_channels(image->pixbuf) * gdk_pixbuf_get_bits_per_sample(image->pixbuf) / 8;
int rs = gdk_pixbuf_get_rowstride(image->pixbuf);
- nr_arena_image_set_style(NR_ARENA_IMAGE(ai), SP_OBJECT_STYLE(SP_OBJECT(item)));
+ nr_arena_image_set_style(NR_ARENA_IMAGE(ai), item->style);
if (image->aspect_align == SP_ASPECT_NONE) {
nr_arena_image_set_pixels(NR_ARENA_IMAGE(ai),
gdk_pixbuf_get_pixels(image->pixbuf),
@@ -1315,7 +1315,7 @@ sp_image_update_canvas_image (SPImage *image)
for (SPItemView *v = item->display; v != NULL; v = v->next) {
int pixskip = gdk_pixbuf_get_n_channels(image->pixbuf) * gdk_pixbuf_get_bits_per_sample(image->pixbuf) / 8;
int rs = gdk_pixbuf_get_rowstride(image->pixbuf);
- nr_arena_image_set_style(NR_ARENA_IMAGE(v->arenaitem), SP_OBJECT_STYLE(SP_OBJECT(image)));
+ nr_arena_image_set_style(NR_ARENA_IMAGE(v->arenaitem), image->style);
if (image->aspect_align == SP_ASPECT_NONE) {
nr_arena_image_set_pixels(NR_ARENA_IMAGE(v->arenaitem),
gdk_pixbuf_get_pixels(image->pixbuf),
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index bdc9400cf..a31961d2e 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -156,7 +156,7 @@ static void sp_group_build(SPObject *object, SPDocument *document, Inkscape::XML
static void sp_group_release(SPObject *object) {
if ( SP_GROUP(object)->_layer_mode == SPGroup::LAYER ) {
- SP_OBJECT_DOCUMENT(object)->removeResource("layer", object);
+ object->document->removeResource("layer", object);
}
if (((SPObjectClass *)parent_class)->release) {
((SPObjectClass *)parent_class)->release(object);
@@ -344,20 +344,20 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
g_return_if_fail (group != NULL);
g_return_if_fail (SP_IS_GROUP (group));
- SPDocument *doc = SP_OBJECT_DOCUMENT (group);
+ SPDocument *doc = group->document;
SPObject *root = doc->getRoot();
- SPObject *defs = SP_OBJECT (SP_ROOT (root)->defs);
+ SPObject *defs = SP_OBJECT(SP_ROOT(root)->defs);
SPItem *gitem = SP_ITEM (group);
- Inkscape::XML::Node *grepr = SP_OBJECT_REPR (gitem);
+ Inkscape::XML::Node *grepr = gitem->getRepr();
g_return_if_fail (!strcmp (grepr->name(), "svg:g") || !strcmp (grepr->name(), "svg:a") || !strcmp (grepr->name(), "svg:switch"));
// this converts the gradient/pattern fill/stroke on the group, if any, to userSpaceOnUse
gitem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false);
- SPItem *pitem = SP_ITEM (SP_OBJECT_PARENT (gitem));
- Inkscape::XML::Node *prepr = SP_OBJECT_REPR (pitem);
+ SPItem *pitem = SP_ITEM(gitem->parent);
+ Inkscape::XML::Node *prepr = pitem->getRepr();
if (SP_IS_BOX3D(gitem)) {
group = box3d_convert_to_group(SP_BOX3D(gitem));
@@ -380,7 +380,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
// it here _before_ the new transform is set, so as to use the pre-transform bbox
citem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false);
- sp_style_merge_from_dying_parent(SP_OBJECT_STYLE(child), SP_OBJECT_STYLE(gitem));
+ sp_style_merge_from_dying_parent(child->style, gitem->style);
/*
* fixme: We currently make no allowance for the case where child is cloned
* and the group has any style settings.
@@ -405,33 +405,33 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
child->updateRepr();
- Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate(prepr->document());
+ Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document());
// Merging transform
Geom::Affine ctrans;
Geom::Affine const g(gitem->transform);
if (SP_IS_USE(citem) && sp_use_get_original (SP_USE(citem)) &&
- SP_OBJECT_PARENT (sp_use_get_original (SP_USE(citem))) == SP_OBJECT(group)) {
+ sp_use_get_original( SP_USE(citem) )->parent == SP_OBJECT(group)) {
// make sure a clone's effective transform is the same as was under group
ctrans = g.inverse() * citem->transform * g;
} else {
- // We should not apply the group's transformation to both a linked offset AND to its source
- if (SP_IS_OFFSET(citem)) { // Do we have an offset at hand (whether it's dynamic or linked)?
- SPItem *source = sp_offset_get_source(SP_OFFSET(citem));
- // When dealing with a chain of linked offsets, the transformation of an offset will be
- // tied to the transformation of the top-most source, not to any of the intermediate
- // offsets. So let's find the top-most source
- while (source != NULL && SP_IS_OFFSET(source)) {
- source = sp_offset_get_source(SP_OFFSET(source));
- }
- if (source != NULL && // If true then we must be dealing with a linked offset ...
- SP_OBJECT(group)->isAncestorOf(SP_OBJECT(source)) == false) { // ... of which the source is not in the same group
- ctrans = citem->transform * g; // then we should apply the transformation of the group to the offset
- } else {
- ctrans = citem->transform;
- }
+ // We should not apply the group's transformation to both a linked offset AND to its source
+ if (SP_IS_OFFSET(citem)) { // Do we have an offset at hand (whether it's dynamic or linked)?
+ SPItem *source = sp_offset_get_source(SP_OFFSET(citem));
+ // When dealing with a chain of linked offsets, the transformation of an offset will be
+ // tied to the transformation of the top-most source, not to any of the intermediate
+ // offsets. So let's find the top-most source
+ while (source != NULL && SP_IS_OFFSET(source)) {
+ source = sp_offset_get_source(SP_OFFSET(source));
+ }
+ if (source != NULL && // If true then we must be dealing with a linked offset ...
+ group->isAncestorOf(source) == false) { // ... of which the source is not in the same group
+ ctrans = citem->transform * g; // then we should apply the transformation of the group to the offset
+ } else {
+ ctrans = citem->transform;
+ }
} else {
- ctrans = citem->transform * g;
+ ctrans = citem->transform * g;
}
}
@@ -452,27 +452,28 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
items = g_slist_prepend (items, nrepr);
} else {
- Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate(prepr->document());
+ Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document());
objects = g_slist_prepend (objects, nrepr);
}
}
/* Step 2 - clear group */
// remember the position of the group
- gint pos = SP_OBJECT_REPR(group)->position();
+ gint pos = group->getRepr()->position();
// the group is leaving forever, no heir, clones should take note; its children however are going to reemerge
- SP_OBJECT (group)->deleteObject(true, false);
+ group->deleteObject(true, false);
/* Step 3 - add nonitems */
if (objects) {
- Inkscape::XML::Node *last_def = SP_OBJECT_REPR(defs)->lastChild();
+ Inkscape::XML::Node *last_def = defs->getRepr()->lastChild();
while (objects) {
- 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);
+ Inkscape::XML::Node *repr = (Inkscape::XML::Node *) objects->data;
+ if (!sp_repr_is_meta_element(repr)) {
+ defs->getRepr()->addChild(repr, last_def);
+ }
+ Inkscape::GC::release(repr);
+ objects = g_slist_remove (objects, objects->data);
}
}
@@ -534,9 +535,9 @@ SPObject *sp_item_group_get_child_by_name(SPGroup *group, SPObject *ref, const g
void SPGroup::setLayerMode(LayerMode mode) {
if ( _layer_mode != mode ) {
if ( mode == LAYER ) {
- SP_OBJECT_DOCUMENT(this)->addResource("layer", this);
+ this->document->addResource("layer", this);
} else if ( _layer_mode == LAYER ) {
- SP_OBJECT_DOCUMENT(this)->removeResource("layer", this);
+ this->document->removeResource("layer", this);
}
_layer_mode = mode;
_updateLayerMode();
@@ -592,7 +593,7 @@ CGroup::~CGroup() {
void CGroup::onChildAdded(Inkscape::XML::Node *child) {
SPObject *last_child = _group->lastChild();
- if (last_child && SP_OBJECT_REPR(last_child) == child) {
+ if (last_child && last_child->getRepr() == child) {
// optimization for the common special case where the child is being added at the end
SPObject *ochild = last_child;
if ( SP_IS_ITEM(ochild) ) {
@@ -648,9 +649,9 @@ void CGroup::onUpdate(SPCtx *ctx, unsigned int flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
- SPObject *object = SP_OBJECT(_group);
- for (SPItemView *v = SP_ITEM(_group)->display; v != NULL; v = v->next) {
- nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
+ SPObject *object = _group;
+ for (SPItemView *v = _group->display; v != NULL; v = v->next) {
+ nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style);
}
}
@@ -679,9 +680,9 @@ void CGroup::onModified(guint flags) {
flags &= SP_OBJECT_MODIFIED_CASCADE;
if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
- SPObject *object = SP_OBJECT(_group);
- for (SPItemView *v = SP_ITEM(_group)->display; v != NULL; v = v->next) {
- nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
+ SPObject *object = _group;
+ for (SPItemView *v = _group->display; v != NULL; v = v->next) {
+ nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style);
}
}
@@ -746,14 +747,14 @@ gchar *CGroup::getDescription() {
NRArenaItem *CGroup::show (NRArena *arena, unsigned int key, unsigned int flags) {
NRArenaItem *ai;
- SPObject *object = SP_OBJECT(_group);
+ SPObject *object = _group;
ai = NRArenaGroup::create(arena);
nr_arena_group_set_transparent(NR_ARENA_GROUP (ai),
_group->effectiveLayerMode(key) ==
SPGroup::LAYER);
- nr_arena_group_set_style(NR_ARENA_GROUP(ai), SP_OBJECT_STYLE(object));
+ nr_arena_group_set_style(NR_ARENA_GROUP(ai), object->style);
_showChildren(arena, ai, key, flags);
return ai;
@@ -863,7 +864,7 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write)
SP_SHAPE(subitem)->setCurve(c, TRUE);
if (write) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(subitem);
+ Inkscape::XML::Node *repr = subitem->getRepr();
gchar *str = sp_svg_write_path(c->get_pathvector());
repr->setAttribute("d", str);
#ifdef GROUP_VERBOSE
diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp
index 372dd51da..700efa572 100644
--- a/src/sp-mask.cpp
+++ b/src/sp-mask.cpp
@@ -111,23 +111,22 @@ sp_mask_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *repr
document->addResource("mask", object);
}
-static void
-sp_mask_release (SPObject * object)
+static void sp_mask_release (SPObject * object)
{
- if (SP_OBJECT_DOCUMENT (object)) {
- /* Unregister ourselves */
- SP_OBJECT_DOCUMENT(object)->removeResource("mask", object);
- }
+ if (object->document) {
+ // Unregister ourselves
+ object->document->removeResource("mask", object);
+ }
- SPMask *cp = SP_MASK (object);
- while (cp->display) {
- /* We simply unref and let item manage this in handler */
- cp->display = sp_mask_view_list_remove (cp->display, cp->display);
- }
+ SPMask *cp = SP_MASK (object);
+ while (cp->display) {
+ // We simply unref and let item manage this in handler
+ cp->display = sp_mask_view_list_remove (cp->display, cp->display);
+ }
- if (((SPObjectClass *) (parent_class))->release) {
- ((SPObjectClass *) parent_class)->release (object);
- }
+ if (((SPObjectClass *) (parent_class))->release) {
+ ((SPObjectClass *) parent_class)->release (object);
+ }
}
static void
@@ -176,7 +175,7 @@ sp_mask_child_added (SPObject *object, Inkscape::XML::Node *child, Inkscape::XML
((SPObjectClass *) (parent_class))->child_added (object, child, ref);
/* Show new object */
- SPObject *ochild = SP_OBJECT_DOCUMENT (object)->getObjectByRepr(child);
+ SPObject *ochild = object->document->getObjectByRepr(child);
if (SP_IS_ITEM (ochild)) {
SPMask *cp = SP_MASK (object);
for (SPMaskView *v = cp->display; v != NULL; v = v->next) {
@@ -269,7 +268,7 @@ sp_mask_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML
const gchar *
sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform)
{
- Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document));
+ Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr();
Inkscape::XML::Document *xml_doc = document->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:mask");
@@ -286,7 +285,7 @@ sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTr
if (NULL != applyTransform) {
Geom::Affine transform (item->transform);
transform *= (*applyTransform);
- item->doWriteTransform(SP_OBJECT_REPR(item), transform);
+ item->doWriteTransform(item->getRepr(), transform);
}
}
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 59ef4762d..001f7731f 100644
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -269,7 +269,7 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape:
object->readAttr( "inkscape:connector-spacing" );
/* Construct guideline list */
- for (SPObject *o = SP_OBJECT(og)->firstChild() ; o; o = o->getNext() ) {
+ for (SPObject *o = og->firstChild() ; o; o = o->getNext() ) {
if (SP_IS_GUIDE(o)) {
SPGuide * g = SP_GUIDE(o);
nv->guides = g_slist_prepend(nv->guides, g);
@@ -696,7 +696,7 @@ static void sp_namedview_remove_child(SPObject *object, Inkscape::XML::Node *chi
} else {
GSList **ref = &nv->guides;
for ( GSList *iter = nv->guides ; iter ; iter = iter->next ) {
- if ( SP_OBJECT_REPR((SPObject *)iter->data) == child ) {
+ if ( reinterpret_cast<SPObject *>(iter->data)->getRepr() == child ) {
*ref = iter->next;
iter->next = NULL;
g_slist_free_1(iter);
@@ -714,12 +714,12 @@ static void sp_namedview_remove_child(SPObject *object, Inkscape::XML::Node *chi
static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags)
{
if ( ( flags & SP_OBJECT_WRITE_EXT ) &&
- repr != SP_OBJECT_REPR(object) )
+ repr != object->getRepr() )
{
if (repr) {
- repr->mergeFrom(SP_OBJECT_REPR(object), "id");
+ repr->mergeFrom(object->getRepr(), "id");
} else {
- repr = SP_OBJECT_REPR(object)->duplicate(doc);
+ repr = object->getRepr()->duplicate(doc);
}
}
@@ -739,7 +739,7 @@ void SPNamedView::show(SPDesktop *desktop)
views = g_slist_prepend(views, desktop);
// generate grids specified in SVG:
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(this);
+ Inkscape::XML::Node *repr = this->getRepr();
if (repr) {
for (Inkscape::XML::Node * child = repr->firstChild() ; child != NULL; child = child->next() ) {
if (!strcmp(child->name(), "inkscape:grid")) {
@@ -850,7 +850,7 @@ void sp_namedview_document_from_window(SPDesktop *desktop)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool save_geometry_in_file = prefs->getBool("/options/savewindowgeometry/value", 0);
- Inkscape::XML::Node *view = SP_OBJECT_REPR(desktop->namedview);
+ Inkscape::XML::Node *view = desktop->namedview->getRepr();
Geom::Rect const r = desktop->get_display_area();
// saving window geometry is not undoable
@@ -943,8 +943,8 @@ void sp_namedview_show_grids(SPNamedView * namedview, bool show, bool dirty_docu
{
namedview->grids_visible = show;
- SPDocument *doc = SP_OBJECT_DOCUMENT (namedview);
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview);
+ SPDocument *doc = namedview->document;
+ Inkscape::XML::Node *repr = namedview->getRepr();
bool saved = DocumentUndo::getUndoSensitive(doc);
DocumentUndo::setUndoSensitive(doc, false);
@@ -962,7 +962,7 @@ gchar const *SPNamedView::getName() const
{
SPException ex;
SP_EXCEPTION_INIT(&ex);
- return SP_OBJECT(this)->getAttribute("id", &ex);
+ return this->getAttribute("id", &ex);
}
guint SPNamedView::getViewCount()
diff --git a/src/sp-object.h b/src/sp-object.h
index 8581fd35a..094ad5bb0 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_DOCUMENT(o) (((SPObject *) (o))->document)
#define SP_OBJECT_PARENT(o) (((SPObject *) (o))->parent)
#define SP_OBJECT_STYLE(o) (((SPObject *) (o))->style)
diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp
index b0264ad13..cd2e706f0 100644
--- a/src/sp-pattern.cpp
+++ b/src/sp-pattern.cpp
@@ -128,7 +128,7 @@ sp_pattern_class_init (SPPatternClass *klass)
static void
sp_pattern_init (SPPattern *pat)
{
- pat->ref = new SPPatternReference(SP_OBJECT(pat));
+ pat->ref = new SPPatternReference(pat);
pat->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(pattern_ref_changed), pat));
pat->patternUnits = SP_PATTERN_UNITS_OBJECTBOUNDINGBOX;
@@ -170,29 +170,27 @@ sp_pattern_build (SPObject *object, SPDocument *document, Inkscape::XML::Node *r
document->addResource("pattern", object);
}
-static void
-sp_pattern_release (SPObject *object)
+static void sp_pattern_release(SPObject *object)
{
- SPPattern *pat;
+ SPPattern *pat = reinterpret_cast<SPPattern *>(object);
- pat = (SPPattern *) object;
-
- if (SP_OBJECT_DOCUMENT (object)) {
- /* Unregister ourselves */
- SP_OBJECT_DOCUMENT (object)->removeResource("pattern", SP_OBJECT (object));
- }
+ if (object->document) {
+ // Unregister ourselves
+ object->document->removeResource("pattern", object);
+ }
- if (pat->ref) {
- pat->modified_connection.disconnect();
- pat->ref->detach();
- delete pat->ref;
- pat->ref = NULL;
- }
+ if (pat->ref) {
+ pat->modified_connection.disconnect();
+ pat->ref->detach();
+ delete pat->ref;
+ pat->ref = NULL;
+ }
- pat->modified_connection.~connection();
+ pat->modified_connection.~connection();
- if (((SPObjectClass *) pattern_parent_class)->release)
- ((SPObjectClass *) pattern_parent_class)->release (object);
+ if (((SPObjectClass *) pattern_parent_class)->release) {
+ ((SPObjectClass *) pattern_parent_class)->release (object);
+ }
}
static void
@@ -426,12 +424,12 @@ pattern_ref_changed(SPObject *old_ref, SPObject *ref, SPPattern *pat)
/**
Gets called when the referenced <pattern> is changed
*/
-static void
-pattern_ref_modified (SPObject */*ref*/, guint /*flags*/, SPPattern *pattern)
+static void pattern_ref_modified (SPObject */*ref*/, guint /*flags*/, SPPattern *pattern)
{
- if (SP_IS_OBJECT (pattern))
- SP_OBJECT (pattern)->requestModified(SP_OBJECT_MODIFIED_FLAG);
- /* Conditional to avoid causing infinite loop if there's a cycle in the href chain. */
+ if ( SP_IS_OBJECT(pattern) ) {
+ pattern->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
+ // Conditional to avoid causing infinite loop if there's a cycle in the href chain.
}
@@ -446,7 +444,7 @@ count_pattern_hrefs(SPObject *o, SPPattern *pat)
guint i = 0;
- SPStyle *style = SP_OBJECT_STYLE(o);
+ SPStyle *style = o->style;
if (style
&& style->fill.isPaintserver()
&& SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style))
@@ -471,13 +469,13 @@ count_pattern_hrefs(SPObject *o, SPPattern *pat)
SPPattern *pattern_chain(SPPattern *pattern)
{
- SPDocument *document = SP_OBJECT_DOCUMENT (pattern);
+ SPDocument *document = pattern->document;
Inkscape::XML::Document *xml_doc = document->getReprDoc();
- Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document));
+ Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern");
repr->setAttribute("inkscape:collect", "always");
- gchar *parent_ref = g_strconcat ("#", SP_OBJECT_REPR(pattern)->attribute("id"), NULL);
+ gchar *parent_ref = g_strconcat("#", pattern->getRepr()->attribute("id"), NULL);
repr->setAttribute("xlink:href", parent_ref);
g_free (parent_ref);
@@ -494,11 +492,11 @@ sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *pr
{
if (!pattern->href || pattern->hrefcount > count_pattern_hrefs(item, pattern)) {
pattern = pattern_chain (pattern);
- gchar *href = g_strconcat ("url(#", SP_OBJECT_REPR (pattern)->attribute("id"), ")", NULL);
+ gchar *href = g_strconcat("url(#", pattern->getRepr()->attribute("id"), ")", NULL);
SPCSSAttr *css = sp_repr_css_attr_new ();
sp_repr_css_set_property (css, property, href);
- sp_repr_css_change_recursive (SP_OBJECT_REPR (item), css, "style");
+ sp_repr_css_change_recursive(item->getRepr(), css, "style");
}
return pattern;
}
@@ -507,7 +505,7 @@ void
sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set)
{
// this formula is for a different interpretation of pattern transforms as described in (*) in sp-pattern.cpp
- // for it to work, we also need sp_object_read_attr (SP_OBJECT (item), "transform");
+ // for it to work, we also need sp_object_read_attr( item, "transform");
//pattern->patternTransform = premul * item->transform * pattern->patternTransform * item->transform.inverse() * postmul;
// otherwise the formula is much simpler
@@ -519,14 +517,14 @@ sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool se
pattern->patternTransform_set = TRUE;
gchar *c=sp_svg_transform_write(pattern->patternTransform);
- SP_OBJECT_REPR(pattern)->setAttribute("patternTransform", c);
+ pattern->getRepr()->setAttribute("patternTransform", c);
g_free(c);
}
const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move)
{
Inkscape::XML::Document *xml_doc = document->getReprDoc();
- Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document));
+ Inkscape::XML::Node *defsrepr = SP_DOCUMENT_DEFS(document)->getRepr();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern");
repr->setAttribute("patternUnits", "userSpaceOnUse");
@@ -550,8 +548,8 @@ const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document
dup_transform = Geom::identity();
dup_transform *= move;
- copy->doWriteTransform(SP_OBJECT_REPR(copy), dup_transform, NULL, false);
- }
+ copy->doWriteTransform(copy->getRepr(), dup_transform, NULL, false);
+ }
Inkscape::GC::release(repr);
return pat_id;
diff --git a/src/sp-script.cpp b/src/sp-script.cpp
index 3b6a8796d..f18d231b0 100644
--- a/src/sp-script.cpp
+++ b/src/sp-script.cpp
@@ -90,13 +90,14 @@ sp_script_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *rep
static void sp_script_release(SPObject *object)
{
- if (SP_OBJECT_DOCUMENT(object)) {
- /* Unregister ourselves */
- SP_OBJECT_DOCUMENT(object)->removeResource("script", SP_OBJECT(object));
+ if (object->document) {
+ // Unregister ourselves
+ object->document->removeResource("script", object);
}
- if (((SPObjectClass *) parent_class)->release)
+ if (((SPObjectClass *) parent_class)->release) {
((SPObjectClass *) parent_class)->release(object);
+ }
}
static void sp_script_update(SPObject */*object*/, SPCtx */*ctx*/, guint /*flags*/)
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 59105a1c7..d9a47f76a 100644
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -242,8 +242,7 @@ void SPShape::sp_shape_update(SPObject *object, SPCtx *ctx, unsigned int flags)
}
if (flags & (SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
- SPStyle *style;
- style = SP_OBJECT_STYLE (object);
+ SPStyle *style = object->style;
if (style->stroke_width.unit == SP_CSS_UNIT_PERCENT) {
SPItemCtx *ictx = (SPItemCtx *) ctx;
double const aw = 1.0 / NR::expansion(ictx->i2vp);
@@ -525,7 +524,7 @@ void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const
}
case SPItem::RENDERING_BBOX: {
// convert the stroke to a path and calculate that path's geometric bbox
- SPStyle* style=SP_OBJECT_STYLE (item);
+ SPStyle* style = item->style;
if (!style->stroke.isNone()) {
Geom::PathVector *pathv = item_outline(item);
if (pathv) {
@@ -545,7 +544,7 @@ void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const
}
default:
case SPItem::APPROXIMATE_BBOX: {
- SPStyle* style=SP_OBJECT_STYLE (item);
+ SPStyle* style = item->style;
if (!style->stroke.isNone()) {
double const scale = transform.descrim();
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
@@ -567,7 +566,7 @@ void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const
for (unsigned i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START
if ( shape->marker[i] ) {
SPMarker* marker = SP_MARKER (shape->marker[i]);
- SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (marker));
+ SPItem* marker_item = sp_item_first_item_child( marker );
if (marker_item) {
Geom::Affine tr(sp_shape_marker_get_transform_at_start(pathv.begin()->front()));
@@ -594,7 +593,7 @@ void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const
for (unsigned i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID
SPMarker* marker = SP_MARKER (shape->marker[i]);
if ( !shape->marker[i] ) continue;
- SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (marker));
+ SPItem* marker_item = sp_item_first_item_child( marker );
if ( !marker_item ) continue;
for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
@@ -626,7 +625,7 @@ void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const
* there should be a midpoint marker between last segment and closing straight line segment */
SPMarker* marker = SP_MARKER (shape->marker[i]);
- SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (marker));
+ SPItem* marker_item = sp_item_first_item_child( marker );
if (marker_item) {
Geom::Affine tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2));
@@ -669,7 +668,7 @@ void SPShape::sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const
for (unsigned i = 0; i < 4; i += 3) { // SP_MARKER_LOC and SP_MARKER_LOC_END
if ( shape->marker[i] ) {
SPMarker* marker = SP_MARKER (shape->marker[i]);
- SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (marker));
+ SPItem* marker_item = sp_item_first_item_child( marker );
if (marker_item) {
/* Get reference to last curve in the path.
@@ -719,7 +718,7 @@ sp_shape_print_invoke_marker_printing(SPObject* obj, Geom::Affine tr, SPStyle* s
tr = Geom::Scale(style->stroke_width.computed) * tr;
}
- SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (marker));
+ SPItem* marker_item = sp_item_first_item_child( marker );
tr = marker_item->transform * marker->c2p * tr;
Geom::Affine old_tr = marker_item->transform;
@@ -749,7 +748,7 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx)
gint add_comments = prefs->getBool("/printing/debug/add-label-comments");
if (add_comments) {
gchar * comment = g_strdup_printf("begin '%s'",
- SP_OBJECT(item)->defaultLabel());
+ item->defaultLabel());
sp_print_comment(ctx, comment);
g_free(comment);
}
@@ -758,12 +757,12 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx)
item->invoke_bbox( &pbox, Geom::identity(), TRUE);
dbox.x0 = 0.0;
dbox.y0 = 0.0;
- dbox.x1 = SP_OBJECT_DOCUMENT (item)->getWidth ();
- dbox.y1 = SP_OBJECT_DOCUMENT (item)->getHeight ();
+ dbox.x1 = item->document->getWidth();
+ dbox.y1 = item->document->getHeight();
item->getBboxDesktop (&bbox);
Geom::Affine const i2d(item->i2d_affine());
- SPStyle* style = SP_OBJECT_STYLE (item);
+ SPStyle* style = item->style;
if (!style->fill.isNone()) {
sp_print_fill (ctx, pathv, &i2d, style, &pbox, &dbox, &bbox);
@@ -839,7 +838,7 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx)
if (add_comments) {
gchar * comment = g_strdup_printf("end '%s'",
- SP_OBJECT(item)->defaultLabel());
+ item->defaultLabel());
sp_print_comment(ctx, comment);
g_free(comment);
}
@@ -850,7 +849,7 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx)
*/
NRArenaItem * SPShape::sp_shape_show(SPItem *item, NRArena *arena, unsigned int /*key*/, unsigned int /*flags*/)
{
- SPObject *object = SP_OBJECT(item);
+ SPObject *object = item;
SPShape *shape = SP_SHAPE(item);
NRArenaItem *arenaitem = NRArenaShape::create(arena);
@@ -1050,7 +1049,7 @@ sp_shape_set_marker (SPObject *object, unsigned int key, const gchar *value)
return;
}
- SPObject *mrk = sp_css_uri_reference_resolve (SP_OBJECT_DOCUMENT (object), value);
+ SPObject *mrk = sp_css_uri_reference_resolve(object->document, value);
if (mrk != shape->marker[key]) {
if (shape->marker[key]) {
SPItemView *v;
@@ -1110,7 +1109,7 @@ void SPShape::setCurve(SPCurve *curve, unsigned int owner)
this->curve = curve->copy();
}
}
- SP_OBJECT(this)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
/**
diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index 3abeadaee..57f9dd14e 100644
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
@@ -227,18 +227,18 @@ static void sp_text_update(SPObject *object, SPCtx *ctx, guint flags)
// Create temporary list of children
GSList *l = NULL;
for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) {
- sp_object_ref (SP_OBJECT (child), object);
+ sp_object_ref(child, object);
l = g_slist_prepend (l, child);
}
l = g_slist_reverse (l);
while (l) {
- SPObject *child = SP_OBJECT (l->data);
+ SPObject *child = reinterpret_cast<SPObject*>(l->data); // We just built this list, so cast is safe.
l = g_slist_remove (l, child);
if (cflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
/* fixme: Do we need transform? */
child->updateDisplay(ctx, cflags);
}
- sp_object_unref (SP_OBJECT (child), object);
+ sp_object_unref(child, object);
}
if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_CHILD_MODIFIED_FLAG |
@@ -253,7 +253,7 @@ static void sp_text_update(SPObject *object, SPCtx *ctx, guint flags)
text->invoke_bbox( &paintbox, Geom::identity(), TRUE);
for (SPItemView* v = text->display; v != NULL; v = v->next) {
text->_clearFlow(NR_ARENA_GROUP(v->arenaitem));
- nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
+ nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style);
// pass the bbox of the text object as paintbox (used for paintserver fills)
text->layout.show(NR_ARENA_GROUP(v->arenaitem), &paintbox);
}
@@ -281,7 +281,7 @@ static void sp_text_modified(SPObject *object, guint flags)
text->invoke_bbox( &paintbox, Geom::identity(), TRUE);
for (SPItemView* v = text->display; v != NULL; v = v->next) {
text->_clearFlow(NR_ARENA_GROUP(v->arenaitem));
- nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
+ nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), object->style);
text->layout.show(NR_ARENA_GROUP(v->arenaitem), &paintbox);
}
}
@@ -289,17 +289,17 @@ static void sp_text_modified(SPObject *object, guint flags)
// Create temporary list of children
GSList *l = NULL;
for (SPObject *child = object->firstChild() ; child ; child = child->getNext() ) {
- sp_object_ref (SP_OBJECT (child), object);
+ sp_object_ref(child, object);
l = g_slist_prepend (l, child);
}
l = g_slist_reverse (l);
while (l) {
- SPObject *child = SP_OBJECT (l->data);
+ SPObject *child = reinterpret_cast<SPObject*>(l->data); // We just built this list, so cast is safe.
l = g_slist_remove (l, child);
if (cflags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
child->emitModified(cflags);
}
- sp_object_unref (SP_OBJECT (child), object);
+ sp_object_unref(child, object);
}
}
@@ -337,7 +337,7 @@ static Inkscape::XML::Node *sp_text_write(SPObject *object, Inkscape::XML::Docum
continue;
}
if (SP_IS_STRING(child)) {
- SP_OBJECT_REPR(child)->setContent(SP_STRING(child)->string.c_str());
+ child->getRepr()->setContent(SP_STRING(child)->string.c_str());
} else {
child->updateRepr(flags);
}
@@ -350,9 +350,9 @@ static Inkscape::XML::Node *sp_text_write(SPObject *object, Inkscape::XML::Docum
if (text->style->line_height.set && !text->style->line_height.inherit && !text->style->line_height.normal && text->style->line_height.unit == SP_CSS_UNIT_PERCENT) {
Inkscape::SVGOStringStream os;
os << (text->style->line_height.value * 100.0) << "%";
- SP_OBJECT_REPR(text)->setAttribute("sodipodi:linespacing", os.str().c_str());
+ text->getRepr()->setAttribute("sodipodi:linespacing", os.str().c_str());
} else {
- SP_OBJECT_REPR(text)->setAttribute("sodipodi:linespacing", NULL);
+ text->getRepr()->setAttribute("sodipodi:linespacing", NULL);
}
if (((SPObjectClass *) (text_parent_class))->write) {
@@ -368,7 +368,7 @@ sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, un
SP_TEXT(item)->layout.getBoundingBox(bbox, transform);
// Add stroke width
- SPStyle* style=SP_OBJECT_STYLE (item);
+ SPStyle* style = item->style;
if (!style->stroke.isNone()) {
double const scale = transform.descrim();
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
@@ -409,11 +409,10 @@ sp_text_hide(SPItem *item, unsigned key)
((SPItemClass *) text_parent_class)->hide (item, key);
}
-static char *
-sp_text_description(SPItem *item)
+static char * sp_text_description(SPItem *item)
{
- SPText *text = (SPText *) item;
- SPStyle *style = SP_OBJECT_STYLE(text);
+ SPText *text = reinterpret_cast<SPText *>(item);
+ SPStyle *style = text->style;
font_instance *tf = font_factory::Default()->FaceFromStyle(style);
@@ -515,8 +514,8 @@ sp_text_print (SPItem *item, SPPrintContext *ctx)
item->getBboxDesktop (&bbox);
dbox.x0 = 0.0;
dbox.y0 = 0.0;
- dbox.x1 = SP_OBJECT_DOCUMENT (item)->getWidth ();
- dbox.y1 = SP_OBJECT_DOCUMENT (item)->getHeight ();
+ dbox.x1 = item->document->getWidth();
+ dbox.y1 = item->document->getHeight();
Geom::Affine const ctm (item->i2d_affine());
group->layout.print(ctx,&pbox,&dbox,&bbox,ctm);
@@ -623,7 +622,7 @@ void SPText::rebuildLayout()
void SPText::_adjustFontsizeRecursive(SPItem *item, double ex, bool is_root)
{
- SPStyle *style = SP_OBJECT_STYLE (item);
+ SPStyle *style = item->style;
if (style && !NR_DF_TEST_CLOSE (ex, 1.0, NR_EPSILON)) {
if (!style->font_size.set && is_root) {
diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp
index a882ee0b0..7c4976a11 100644
--- a/src/sp-tref.cpp
+++ b/src/sp-tref.cpp
@@ -123,7 +123,7 @@ sp_tref_init(SPTRef *tref)
new (&tref->attributes) TextTagAttributes;
tref->href = NULL;
- tref->uriOriginalRef = new SPTRefReference(SP_OBJECT(tref));
+ tref->uriOriginalRef = new SPTRefReference(tref);
new (&tref->_delete_connection) sigc::connection();
new (&tref->_changed_connection) sigc::connection();
@@ -223,7 +223,7 @@ sp_tref_set(SPObject *object, unsigned int key, gchar const *value)
}
// No matter what happened, an update should be in order
- SP_OBJECT(tref)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ tref->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
} else { // default
@@ -323,16 +323,20 @@ static void
sp_tref_bbox(SPItem const *item, NRRect *bbox, Geom::Affine const &transform, unsigned const /*flags*/)
{
// find out the ancestor text which holds our layout
- SPObject *parent_text = SP_OBJECT(item);
- for (; parent_text != NULL && !SP_IS_TEXT(parent_text); parent_text = SP_OBJECT_PARENT (parent_text)){};
- if (parent_text == NULL) return;
+ SPObject const *parent_text = item;
+ while ( parent_text && !SP_IS_TEXT(parent_text) ) {
+ parent_text = parent_text->parent;
+ }
+ if (parent_text == NULL) {
+ return;
+ }
// get the bbox of our portion of the layout
SP_TEXT(parent_text)->layout.getBoundingBox(
bbox, transform, sp_text_get_length_upto(parent_text, item), sp_text_get_length_upto(item, NULL) - 1);
// Add stroke width
- SPStyle* style=SP_OBJECT_STYLE (item);
+ SPStyle* style = item->style;
if (!style->stroke.isNone()) {
double const scale = transform.descrim();
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
@@ -388,7 +392,7 @@ sp_tref_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPTRef *tref)
tref->_delete_connection.disconnect();
if (tref->stringChild) {
- SP_OBJECT(tref)->detach(tref->stringChild);
+ tref->detach(tref->stringChild);
tref->stringChild = NULL;
}
@@ -399,7 +403,7 @@ sp_tref_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPTRef *tref)
sp_tref_update_text(tref);
// Restore the delete connection now that we're done messing with stuff
- tref->_delete_connection = SP_OBJECT(refRoot)->connectDelete(sigc::bind(sigc::ptr_fun(&sp_tref_delete_self), tref));
+ tref->_delete_connection = refRoot->connectDelete(sigc::bind(sigc::ptr_fun(&sp_tref_delete_self), tref));
}
}
@@ -412,7 +416,7 @@ sp_tref_href_changed(SPObject */*old_ref*/, SPObject */*ref*/, SPTRef *tref)
static void
sp_tref_delete_self(SPObject */*deleted*/, SPTRef *self)
{
- SP_OBJECT(self)->deleteObject();
+ self->deleteObject();
}
/**
@@ -423,7 +427,7 @@ SPObject * SPTRef::getObjectReferredTo(void)
SPObject *referredObject = NULL;
if (uriOriginalRef) {
- referredObject = SP_OBJECT(uriOriginalRef->getObject());
+ referredObject = uriOriginalRef->getObject();
}
return referredObject;
@@ -441,7 +445,7 @@ sp_tref_reference_allowed(SPTRef *tref, SPObject *possible_ref)
if (tref && possible_ref) {
if (tref != possible_ref) {
bool ancestor = false;
- for (SPObject *obj = tref; obj; obj = SP_OBJECT_PARENT(obj)) {
+ for (SPObject *obj = tref; obj; obj = obj->parent) {
if (possible_ref == obj) {
ancestor = true;
break;
@@ -470,15 +474,15 @@ sp_tref_fully_contained(SPObject *start_item, Glib::ustring::iterator &start,
// If neither the beginning or the end is a tref then we return true (whether there
// is a tref in the innards or not, because if there is one then it must be totally
// contained)
- if (!(SP_IS_STRING(start_item) && SP_IS_TREF(SP_OBJECT_PARENT(start_item)))
- && !(SP_IS_STRING(end_item) && SP_IS_TREF(SP_OBJECT_PARENT(end_item)))) {
+ if (!(SP_IS_STRING(start_item) && SP_IS_TREF(start_item->parent))
+ && !(SP_IS_STRING(end_item) && SP_IS_TREF(end_item->parent))) {
fully_contained = true;
}
// Both the beginning and end are trefs; but in this case, the string iterators
// must be at the right places
- else if ((SP_IS_STRING(start_item) && SP_IS_TREF(SP_OBJECT_PARENT(start_item)))
- && (SP_IS_STRING(end_item) && SP_IS_TREF(SP_OBJECT_PARENT(end_item)))) {
+ else if ((SP_IS_STRING(start_item) && SP_IS_TREF(start_item->parent))
+ && (SP_IS_STRING(end_item) && SP_IS_TREF(end_item->parent))) {
if (start == SP_STRING(start_item)->string.begin()
&& end == SP_STRING(start_item)->string.end()) {
fully_contained = true;
@@ -487,16 +491,16 @@ sp_tref_fully_contained(SPObject *start_item, Glib::ustring::iterator &start,
// If the beginning is a string that is a child of a tref, the iterator has to be
// at the beginning of the item
- else if ((SP_IS_STRING(start_item) && SP_IS_TREF(SP_OBJECT_PARENT(start_item)))
- && !(SP_IS_STRING(end_item) && SP_IS_TREF(SP_OBJECT_PARENT(end_item)))) {
+ else if ((SP_IS_STRING(start_item) && SP_IS_TREF(start_item->parent))
+ && !(SP_IS_STRING(end_item) && SP_IS_TREF(end_item->parent))) {
if (start == SP_STRING(start_item)->string.begin()) {
fully_contained = true;
}
}
// Same, but the for the end
- else if (!(SP_IS_STRING(start_item) && SP_IS_TREF(SP_OBJECT_PARENT(start_item)))
- && (SP_IS_STRING(end_item) && SP_IS_TREF(SP_OBJECT_PARENT(end_item)))) {
+ else if (!(SP_IS_STRING(start_item) && SP_IS_TREF(start_item->parent))
+ && (SP_IS_STRING(end_item) && SP_IS_TREF(end_item->parent))) {
if (end == SP_STRING(start_item)->string.end()) {
fully_contained = true;
}
@@ -512,23 +516,23 @@ void sp_tref_update_text(SPTRef *tref)
if (tref) {
// Get the character data that will be used with this tref
Glib::ustring charData = "";
- build_string_from_root(SP_OBJECT_REPR(tref->getObjectReferredTo()), &charData);
+ build_string_from_root(tref->getObjectReferredTo()->getRepr(), &charData);
if (tref->stringChild) {
- SP_OBJECT(tref)->detach(tref->stringChild);
+ tref->detach(tref->stringChild);
tref->stringChild = NULL;
}
// Create the node and SPString to be the tref's child
- Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(tref)->getReprDoc();
+ Inkscape::XML::Document *xml_doc = tref->document->getReprDoc();
Inkscape::XML::Node *newStringRepr = xml_doc->createTextNode(charData.c_str());
tref->stringChild = SP_OBJECT(g_object_new(sp_repr_type_lookup(newStringRepr), NULL));
// Add this SPString as a child of the tref
- SP_OBJECT(tref)->attach(tref->stringChild, tref->lastChild());
+ tref->attach(tref->stringChild, tref->lastChild());
sp_object_unref(tref->stringChild, NULL);
- (tref->stringChild)->invoke_build(SP_OBJECT(tref)->document, newStringRepr, TRUE);
+ (tref->stringChild)->invoke_build(tref->document, newStringRepr, TRUE);
Inkscape::GC::release(newStringRepr);
}
@@ -581,10 +585,10 @@ sp_tref_convert_to_tspan(SPObject *obj)
SPTRef *tref = SP_TREF(obj);
if (tref && tref->stringChild) {
- Inkscape::XML::Node *tref_repr = SP_OBJECT_REPR(tref);
+ Inkscape::XML::Node *tref_repr = tref->getRepr();
Inkscape::XML::Node *tref_parent = sp_repr_parent(tref_repr);
- SPDocument *document = SP_OBJECT(tref)->document;
+ SPDocument *document = tref->document;
Inkscape::XML::Document *xml_doc = document->getReprDoc();
Inkscape::XML::Node *new_tspan_repr = xml_doc->createElement("svg:tspan");
@@ -596,35 +600,35 @@ sp_tref_convert_to_tspan(SPObject *obj)
new_tspan = document->getObjectByRepr(new_tspan_repr);
// Create a new string child for the tspan
- Inkscape::XML::Node *new_string_repr = SP_OBJECT_REPR(tref->stringChild)->duplicate(xml_doc);
+ Inkscape::XML::Node *new_string_repr = tref->stringChild->getRepr()->duplicate(xml_doc);
new_tspan_repr->addChild(new_string_repr, NULL);
//SPObject * new_string_child = document->getObjectByRepr(new_string_repr);
// Merge style from the tref
- SPStyle *new_tspan_sty = SP_OBJECT_STYLE(new_tspan);
- SPStyle const *tref_sty = SP_OBJECT_STYLE(tref);
+ SPStyle *new_tspan_sty = new_tspan->style;
+ SPStyle const *tref_sty = tref->style;
sp_style_merge_from_dying_parent(new_tspan_sty, tref_sty);
sp_style_merge_from_parent(new_tspan_sty, new_tspan->parent->style);
- SP_OBJECT(new_tspan)->updateRepr();
+ new_tspan->updateRepr();
// Hold onto our SPObject and repr for now.
- sp_object_ref(SP_OBJECT(tref), NULL);
+ sp_object_ref(tref, NULL);
Inkscape::GC::anchor(tref_repr);
// Remove ourselves, not propagating delete events to avoid a
// chain-reaction with other elements that might reference us.
- SP_OBJECT(tref)->deleteObject(false);
+ tref->deleteObject(false);
// Give the copy our old id and let go of our old repr.
new_tspan_repr->setAttribute("id", tref_repr->attribute("id"));
Inkscape::GC::release(tref_repr);
// Establish the succession and let go of our object.
- SP_OBJECT(tref)->setSuccessor(new_tspan);
- sp_object_unref(SP_OBJECT(tref), NULL);
+ tref->setSuccessor(new_tspan);
+ sp_object_unref(tref, NULL);
}
}
////////////////////
@@ -633,19 +637,19 @@ sp_tref_convert_to_tspan(SPObject *obj)
else {
GSList *l = NULL;
for (SPObject *child = obj->firstChild() ; child != NULL ; child = child->getNext() ) {
- sp_object_ref (SP_OBJECT (child), obj);
+ sp_object_ref(child, obj);
l = g_slist_prepend (l, child);
}
l = g_slist_reverse (l);
while (l) {
- SPObject *child = SP_OBJECT (l->data);
+ SPObject *child = reinterpret_cast<SPObject *>(l->data); // We just built this list, so cast is safe.
l = g_slist_remove (l, child);
// Note that there may be more than one conversion happening here, so if it's not a
// tref being passed into this function, the returned value can't be specifically known
new_tspan = sp_tref_convert_to_tspan(child);
- sp_object_unref (SP_OBJECT (child), obj);
+ sp_object_unref(child, obj);
}
}
diff --git a/src/spray-context.cpp b/src/spray-context.cpp
index 244c52fad..e7ef9d317 100644
--- a/src/spray-context.cpp
+++ b/src/spray-context.cpp
@@ -155,7 +155,7 @@ void sp_spray_rotate_rel(Geom::Point c,SPDesktop */*desktop*/,SPItem *item, Geom
// Rotate item.
item->set_i2d_affine(item->i2d_affine() * (Geom::Affine)affine);
// Use each item's own transform writer, consistent with sp_selection_apply_affine()
- item->doWriteTransform(SP_OBJECT_REPR(item), item->transform);
+ item->doWriteTransform(item->getRepr(), item->transform);
// Restore the center position (it's changed because the bbox center changed)
if (item->isCenterSet()) {
item->setCenter(c);
@@ -168,7 +168,7 @@ void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geo
{
Geom::Translate const s(c);
item->set_i2d_affine(item->i2d_affine() * s.inverse() * scale * s );
- item->doWriteTransform(SP_OBJECT_REPR(item), item->transform);
+ item->doWriteTransform(item->getRepr(), item->transform);
}
static void sp_spray_context_init(SPSprayContext *tc)
@@ -487,9 +487,9 @@ bool sp_spray_recursive(SPDesktop *desktop,
if(_fid<=population)
{
// duplicate
- SPDocument *doc = SP_OBJECT_DOCUMENT(item);
+ SPDocument *doc = item->document;
Inkscape::XML::Document* xml_doc = doc->getReprDoc();
- Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(item);
+ Inkscape::XML::Node *old_repr = item->getRepr();
Inkscape::XML::Node *parent = old_repr->parent();
Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
parent->appendChild(copy);
@@ -528,9 +528,9 @@ bool sp_spray_recursive(SPDesktop *desktop,
}
i++;
}
- SPDocument *doc = SP_OBJECT_DOCUMENT(father);
+ SPDocument *doc = father->document;
Inkscape::XML::Document* xml_doc = doc->getReprDoc();
- Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(father);
+ Inkscape::XML::Node *old_repr = father->getRepr();
Inkscape::XML::Node *parent = old_repr->parent();
Geom::OptRect a = father->getBounds(father->i2doc_affine());
@@ -575,9 +575,9 @@ bool sp_spray_recursive(SPDesktop *desktop,
if (a) {
if(_fid<=population) {
SPItem *item_copied;
- SPDocument *doc = SP_OBJECT_DOCUMENT(item);
+ SPDocument *doc = item->document;
Inkscape::XML::Document* xml_doc = doc->getReprDoc();
- Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(item);
+ Inkscape::XML::Node *old_repr = item->getRepr();
Inkscape::XML::Node *parent = old_repr->parent();
// Creation of the clone
diff --git a/src/style.cpp b/src/style.cpp
index d254ab6f4..bb25a5f46 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -568,7 +568,7 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr)
{
g_assert(style != NULL);
g_assert(repr != NULL);
- g_assert(!object || (SP_OBJECT_REPR(object) == repr));
+ g_assert(!object || (object->getRepr() == repr));
sp_style_clear(style);
@@ -652,7 +652,7 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr)
val = repr->attribute("color");
if (val) {
sp_style_read_icolor(&style->color, val, style, ( object
- ? SP_OBJECT_DOCUMENT(object)
+ ? object->document
: NULL ));
}
}
@@ -660,7 +660,7 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr)
if (!style->fill.set) {
val = repr->attribute("fill");
if (val) {
- style->fill.read( val, *style, (object) ? SP_OBJECT_DOCUMENT(object) : NULL );
+ style->fill.read( val, *style, (object) ? object->document : NULL );
}
}
/* fill-opacity */
@@ -676,7 +676,7 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr)
if (!style->stroke.set) {
val = repr->attribute("stroke");
if (val) {
- style->stroke.read( val, *style, (object) ? SP_OBJECT_DOCUMENT(object) : NULL );
+ style->stroke.read( val, *style, (object) ? object->document : NULL );
}
}
SPS_READ_PLENGTH_IF_UNSET(&style->stroke_width, repr, "stroke-width");
@@ -762,7 +762,7 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr)
if (!style->filter.set) {
val = repr->attribute("filter");
if (val) {
- sp_style_read_ifilter(val, style, (object) ? SP_OBJECT_DOCUMENT(object) : NULL);
+ sp_style_read_ifilter(val, style, (object) ? object->document : NULL);
}
}
SPS_READ_PENUM_IF_UNSET(&style->enable_background, repr,
@@ -771,7 +771,7 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr)
/* 3. Merge from parent */
if (object) {
if (object->parent) {
- sp_style_merge_from_parent(style, SP_OBJECT_STYLE(object->parent));
+ sp_style_merge_from_parent(style, object->parent->style);
}
} else {
if (sp_repr_parent(repr)) {
@@ -799,7 +799,7 @@ sp_style_read_from_object(SPStyle *style, SPObject *object)
g_return_if_fail(object != NULL);
g_return_if_fail(SP_IS_OBJECT(object));
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(object);
+ Inkscape::XML::Node *repr = object->getRepr();
g_return_if_fail(repr != NULL);
sp_style_read(style, object, repr);
@@ -987,7 +987,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val)
break;
case SP_PROP_COLOR:
if (!style->color.set) {
- sp_style_read_icolor(&style->color, val, style, (style->object) ? SP_OBJECT_DOCUMENT(style->object) : NULL);
+ sp_style_read_icolor(&style->color, val, style, (style->object) ? style->object->document : NULL);
}
break;
case SP_PROP_CURSOR:
@@ -1044,7 +1044,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val)
/* Filter */
case SP_PROP_FILTER:
if (!style->filter.set && !style->filter.inherit) {
- sp_style_read_ifilter(val, style, (style->object) ? SP_OBJECT_DOCUMENT(style->object) : NULL);
+ sp_style_read_ifilter(val, style, (style->object) ? style->object->document : NULL);
}
break;
case SP_PROP_FLOOD_COLOR:
@@ -1085,7 +1085,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val)
}
case SP_PROP_FILL:
if (!style->fill.set) {
- style->fill.read( val, *style, (style->object) ? SP_OBJECT_DOCUMENT(style->object) : NULL );
+ style->fill.read( val, *style, (style->object) ? style->object->document : NULL );
}
break;
case SP_PROP_FILL_OPACITY:
@@ -1152,7 +1152,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val)
case SP_PROP_STROKE:
if (!style->stroke.set) {
- style->stroke.read( val, *style, (style->object) ? SP_OBJECT_DOCUMENT(style->object) : NULL );
+ style->stroke.read( val, *style, (style->object) ? style->object->document : NULL );
}
break;
case SP_PROP_STROKE_WIDTH:
@@ -2274,8 +2274,8 @@ sp_style_merge_ifilter(SPStyle *style, SPIFilter const *parent)
style->filter.href->detach();
// it may be that this style has not yet created its SPFilterReference
- if (!style->filter.href && style->object && SP_OBJECT_DOCUMENT(style->object)) {
- style->filter.href = new SPFilterReference(SP_OBJECT_DOCUMENT(style->object));
+ if (!style->filter.href && style->object && style->object->document) {
+ style->filter.href = new SPFilterReference(style->object->document);
style->filter.href->changedSignal().connect(sigc::bind(sigc::ptr_fun(sp_style_filter_ref_changed), style));
}
@@ -4071,7 +4071,7 @@ sp_style_filter_clear(SPStyle *style)
void
sp_style_set_property_url (SPObject *item, gchar const *property, SPObject *linked, bool recursive)
{
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(item);
+ Inkscape::XML::Node *repr = item->getRepr();
if (repr == NULL) return;
@@ -4099,13 +4099,19 @@ sp_style_set_property_url (SPObject *item, gchar const *property, SPObject *link
void
sp_style_unset_property_attrs(SPObject *o)
{
- if (!o) return;
+ if (!o) {
+ return;
+ }
- SPStyle *style = SP_OBJECT_STYLE(o);
- if (!style) return;
+ SPStyle *style = o->style;
+ if (!style) {
+ return;
+ }
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(o);
- if (!repr) return;
+ Inkscape::XML::Node *repr = o->getRepr();
+ if (!repr) {
+ return;
+ }
if (style->opacity.set) {
repr->setAttribute("opacity", NULL);
@@ -4198,16 +4204,16 @@ sp_css_attr_from_style(SPStyle const *const style, guint const flags)
* \pre object != NULL
* \pre flags in {IFSET, ALWAYS}.
*/
-SPCSSAttr *
-sp_css_attr_from_object(SPObject *object, guint const flags)
+SPCSSAttr *sp_css_attr_from_object(SPObject *object, guint const flags)
{
g_return_val_if_fail(((flags == SP_STYLE_FLAG_IFSET) ||
(flags == SP_STYLE_FLAG_ALWAYS) ),
NULL);
- SPStyle const *const style = SP_OBJECT_STYLE(object);
- if (style == NULL)
- return NULL;
- return sp_css_attr_from_style(style, flags);
+ SPCSSAttr * result = 0;
+ if (object->style) {
+ result = sp_css_attr_from_style(object->style, flags);
+ }
+ return result;
}
/**
diff --git a/src/text-context.cpp b/src/text-context.cpp
index 66e5f9450..5af2c5ebc 100644
--- a/src/text-context.cpp
+++ b/src/text-context.cpp
@@ -721,7 +721,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
// otherwise even one line won't fit; most probably a slip of hand (even if bigger than tolerance)
SPItem *ft = create_flowtext_with_internal_frame (desktop, tc->p0, p1);
/* Set style */
- sp_desktop_apply_style_tool(desktop, SP_OBJECT_REPR(ft), "/tools/text", true);
+ sp_desktop_apply_style_tool(desktop, ft->getRepr(), "/tools/text", true);
sp_desktop_selection(desktop)->set(ft);
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Flowed text is created."));
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
@@ -1526,11 +1526,13 @@ sp_text_context_style_set(SPCSSAttr const *css, SPTextContext *tc)
static int
sp_text_context_style_query(SPStyle *style, int property, SPTextContext *tc)
{
- if (tc->text == NULL)
+ if (tc->text == NULL) {
return QUERY_STYLE_NOTHING;
+ }
const Inkscape::Text::Layout *layout = te_get_layout(tc->text);
- if (layout == NULL)
+ if (layout == NULL) {
return QUERY_STYLE_NOTHING;
+ }
sp_text_context_validate_cursor_iterators(tc);
GSList *styles_list = NULL;
@@ -1543,18 +1545,21 @@ sp_text_context_style_query(SPStyle *style, int property, SPTextContext *tc)
begin_it = tc->text_sel_end;
end_it = tc->text_sel_start;
}
- if (begin_it == end_it)
- if (!begin_it.prevCharacter())
+ if (begin_it == end_it) {
+ if (!begin_it.prevCharacter()) {
end_it.nextCharacter();
+ }
+ }
for (Inkscape::Text::Layout::iterator it = begin_it ; it < end_it ; it.nextStartOfSpan()) {
SPObject const *pos_obj = 0;
void *rawptr = 0;
layout->getSourceOfCharacter(it, &rawptr);
- if (!rawptr || !SP_IS_OBJECT(rawptr))
+ if (!rawptr || !SP_IS_OBJECT(rawptr)) {
continue;
+ }
pos_obj = SP_OBJECT(rawptr);
- while (SP_IS_STRING(pos_obj) && SP_OBJECT_PARENT(pos_obj)) {
- pos_obj = SP_OBJECT_PARENT(pos_obj); // SPStrings don't have style
+ while (SP_IS_STRING(pos_obj) && pos_obj->parent) {
+ pos_obj = pos_obj->parent; // SPStrings don't have style
}
styles_list = g_slist_prepend(styles_list, (gpointer)pos_obj);
}
@@ -1716,7 +1721,7 @@ sp_text_context_forget_text(SPTextContext *tc)
*/
/*
if ((SP_IS_TEXT(ti) || SP_IS_FLOWTEXT(ti)) && sp_te_input_is_empty(ti)) {
- Inkscape::XML::Node *text_repr=SP_OBJECT_REPR(ti);
+ Inkscape::XML::Node *text_repr = ti->getRepr();
// the repr may already have been unparented
// if we were called e.g. as the result of
// an undo or the element being removed from
@@ -1756,7 +1761,7 @@ sptc_commit(GtkIMContext */*imc*/, gchar *string, SPTextContext *tc)
sp_text_context_update_cursor(tc);
sp_text_context_update_text_selection(tc);
- DocumentUndo::done(SP_OBJECT_DOCUMENT(tc->text), SP_VERB_CONTEXT_TEXT,
+ DocumentUndo::done(tc->text->document, SP_VERB_CONTEXT_TEXT,
_("Type text"));
}
diff --git a/src/text-editing.cpp b/src/text-editing.cpp
index fb9e2e6a3..1e918ae00 100644
--- a/src/text-editing.cpp
+++ b/src/text-editing.cpp
@@ -118,23 +118,26 @@ sp_te_get_cursor_coords (SPItem const *item, Inkscape::Text::Layout::iterator co
SPStyle const * sp_te_style_at_position(SPItem const *text, Inkscape::Text::Layout::iterator const &position)
{
SPObject const *pos_obj = sp_te_object_at_position(text, position);
- if (pos_obj)
- return SP_OBJECT_STYLE(pos_obj);
- return NULL;
+ SPStyle *result = (pos_obj) ? pos_obj->style : 0;
+ return result;
}
SPObject const * sp_te_object_at_position(SPItem const *text, Inkscape::Text::Layout::iterator const &position)
{
Inkscape::Text::Layout const *layout = te_get_layout(text);
- if (layout == NULL)
+ if (layout == NULL) {
return NULL;
+ }
SPObject const *pos_obj = 0;
void *rawptr = 0;
layout->getSourceOfCharacter(position, &rawptr);
pos_obj = SP_OBJECT(rawptr);
- if (pos_obj == 0) pos_obj = text;
- while (SP_OBJECT_STYLE(pos_obj) == NULL)
- pos_obj = SP_OBJECT_PARENT(pos_obj); // not interested in SPStrings
+ if (pos_obj == 0) {
+ pos_obj = text;
+ }
+ while (pos_obj->style == NULL) {
+ pos_obj = pos_obj->parent; // not interested in SPStrings
+ }
return pos_obj;
}
@@ -240,7 +243,7 @@ unsigned sp_text_get_length_upto(SPObject const *item, SPObject const *upto)
// Take care of new lines...
if (is_line_break_object(item) && !SP_IS_TEXT(item)) {
- if (item != SP_OBJECT_PARENT(item)->firstChild()) {
+ if (item != item->parent->firstChild()) {
// add 1 for each newline
length++;
}
@@ -303,7 +306,7 @@ to \a item at the same level. */
static unsigned sum_sibling_text_lengths_before(SPObject const *item)
{
unsigned char_index = 0;
- for (SPObject *sibling = SP_OBJECT_PARENT(item)->firstChild() ; sibling && sibling != item ; sibling = sibling->getNext()) {
+ for (SPObject *sibling = item->parent->firstChild() ; sibling && sibling != item ; sibling = sibling->getNext()) {
char_index += sp_text_get_length(sibling);
}
return char_index;
@@ -327,20 +330,20 @@ parent of the first line break node encountered.
*/
static SPObject* split_text_object_tree_at(SPObject *split_obj, unsigned char_index)
{
- Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(split_obj)->getReprDoc();
+ Inkscape::XML::Document *xml_doc = split_obj->document->getReprDoc();
if (is_line_break_object(split_obj)) {
- Inkscape::XML::Node *new_node = duplicate_node_without_children(xml_doc, SP_OBJECT_REPR(split_obj));
- SP_OBJECT_REPR(SP_OBJECT_PARENT(split_obj))->addChild(new_node, SP_OBJECT_REPR(split_obj));
+ Inkscape::XML::Node *new_node = duplicate_node_without_children(xml_doc, split_obj->getRepr());
+ split_obj->parent->getRepr()->addChild(new_node, split_obj->getRepr());
Inkscape::GC::release(new_node);
split_attributes(split_obj, split_obj->getNext(), char_index);
return split_obj->getNext();
}
unsigned char_count_before = sum_sibling_text_lengths_before(split_obj);
- SPObject *duplicate_obj = split_text_object_tree_at(SP_OBJECT_PARENT(split_obj), char_index + char_count_before);
+ SPObject *duplicate_obj = split_text_object_tree_at(split_obj->parent, char_index + char_count_before);
// copy the split node
- Inkscape::XML::Node *new_node = duplicate_node_without_children(xml_doc, SP_OBJECT_REPR(split_obj));
- SP_OBJECT_REPR(duplicate_obj)->appendChild(new_node);
+ Inkscape::XML::Node *new_node = duplicate_node_without_children(xml_doc, split_obj->getRepr());
+ duplicate_obj->getRepr()->appendChild(new_node);
Inkscape::GC::release(new_node);
// sort out the copied attributes (x/y/dx/dy/rotate)
@@ -349,11 +352,11 @@ static SPObject* split_text_object_tree_at(SPObject *split_obj, unsigned char_in
// then move all the subsequent nodes
split_obj = split_obj->getNext();
while (split_obj) {
- Inkscape::XML::Node *move_repr = SP_OBJECT_REPR(split_obj);
+ Inkscape::XML::Node *move_repr = split_obj->getRepr();
SPObject *next_obj = split_obj->getNext(); // this is about to become invalidated by removeChild()
Inkscape::GC::anchor(move_repr);
- SP_OBJECT_REPR(SP_OBJECT_PARENT(split_obj))->removeChild(move_repr);
- SP_OBJECT_REPR(duplicate_obj)->appendChild(move_repr);
+ split_obj->parent->getRepr()->removeChild(move_repr);
+ duplicate_obj->getRepr()->appendChild(move_repr);
Inkscape::GC::release(move_repr);
split_obj = next_obj;
@@ -392,14 +395,14 @@ Inkscape::Text::Layout::iterator sp_te_insert_line (SPItem *item, Inkscape::Text
}
if (split_obj) {
- Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(split_obj)->getReprDoc();
- Inkscape::XML::Node *new_node = duplicate_node_without_children(xml_doc, SP_OBJECT_REPR(split_obj));
- SP_OBJECT_REPR(SP_OBJECT_PARENT(split_obj))->addChild(new_node, SP_OBJECT_REPR(split_obj));
+ Inkscape::XML::Document *xml_doc = split_obj->document->getReprDoc();
+ Inkscape::XML::Node *new_node = duplicate_node_without_children(xml_doc, split_obj->getRepr());
+ split_obj->parent->getRepr()->addChild(new_node, split_obj->getRepr());
Inkscape::GC::release(new_node);
}
} else if (SP_IS_STRING(split_obj)) {
// If the parent is a tref, editing on this particular string is disallowed.
- if (SP_IS_TREF(SP_OBJECT_PARENT(split_obj))) {
+ if (SP_IS_TREF(split_obj->parent)) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, tref_edit_message);
return position;
}
@@ -410,9 +413,9 @@ Inkscape::Text::Layout::iterator sp_te_insert_line (SPItem *item, Inkscape::Text
char_index++;
// we need to split the entire text tree into two
SPString *new_string = SP_STRING(split_text_object_tree_at(split_obj, char_index));
- SP_OBJECT_REPR(new_string)->setContent(&*split_text_iter.base()); // a little ugly
+ new_string->getRepr()->setContent(&*split_text_iter.base()); // a little ugly
string->erase(split_text_iter, string->end());
- SP_OBJECT_REPR(split_obj)->setContent(string->c_str());
+ split_obj->getRepr()->setContent(string->c_str());
// TODO: if the split point was at the beginning of a span we have a whole load of empty elements to clean up
} else {
// TODO
@@ -461,7 +464,7 @@ static void insert_into_spstring(SPString *string_item, Glib::ustring::iterator
SPObject *parent_item = string_item;
for ( ; ; ) {
char_index += sum_sibling_text_lengths_before(parent_item);
- parent_item = SP_OBJECT_PARENT(parent_item);
+ parent_item = parent_item->parent;
TextTagAttributes *attributes = attributes_for_object(parent_item);
if (!attributes) break;
attributes->insert(char_index, char_count);
@@ -494,7 +497,7 @@ sp_te_insert(SPItem *item, Inkscape::Text::Layout::iterator const &position, gch
source_obj = SP_OBJECT(rawptr);
if (SP_IS_STRING(source_obj)) {
// If the parent is a tref, editing on this particular string is disallowed.
- if (SP_IS_TREF(SP_OBJECT_PARENT(source_obj))) {
+ if (SP_IS_TREF(source_obj->parent)) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, tref_edit_message);
return position;
}
@@ -505,7 +508,7 @@ sp_te_insert(SPItem *item, Inkscape::Text::Layout::iterator const &position, gch
insert_into_spstring(string_item, cursor_at_end ? string_item->string.end() : iter_text, utf8);
} else {
// the not-so-simple case where we're at a line break or other control char; add to the next child/sibling SPString
- Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(item)->document();
+ Inkscape::XML::Document *xml_doc = item->getRepr()->document();
if (cursor_at_start) {
source_obj = item;
if (source_obj->hasChildren()) {
@@ -521,7 +524,7 @@ sp_te_insert(SPItem *item, Inkscape::Text::Layout::iterator const &position, gch
}
if (source_obj == item && SP_IS_FLOWTEXT(item)) {
Inkscape::XML::Node *para = xml_doc->createElement("svg:flowPara");
- SP_OBJECT_REPR(item)->appendChild(para);
+ item->getRepr()->appendChild(para);
source_obj = item->lastChild();
}
} else
@@ -532,13 +535,13 @@ sp_te_insert(SPItem *item, Inkscape::Text::Layout::iterator const &position, gch
if (string_item == NULL) {
// need to add an SPString in this (pathological) case
Inkscape::XML::Node *rstring = xml_doc->createTextNode("");
- SP_OBJECT_REPR(source_obj)->addChild(rstring, NULL);
+ source_obj->getRepr()->addChild(rstring, NULL);
Inkscape::GC::release(rstring);
g_assert(SP_IS_STRING(source_obj->firstChild()));
string_item = SP_STRING(source_obj->firstChild());
}
// If the parent is a tref, editing on this particular string is disallowed.
- if (SP_IS_TREF(SP_OBJECT_PARENT(string_item))) {
+ if (SP_IS_TREF(string_item->parent)) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, tref_edit_message);
return position;
}
@@ -581,10 +584,10 @@ static SPObject* get_common_ancestor(SPObject *text, SPObject *one, SPObject *tw
return text;
SPObject *common_ancestor = one;
if (SP_IS_STRING(common_ancestor))
- common_ancestor = SP_OBJECT_PARENT(common_ancestor);
+ common_ancestor = common_ancestor->parent;
while (!(common_ancestor == two || common_ancestor->isAncestorOf(two))) {
g_assert(common_ancestor != text);
- common_ancestor = SP_OBJECT_PARENT(common_ancestor);
+ common_ancestor = common_ancestor->parent;
}
return common_ancestor;
}
@@ -605,7 +608,7 @@ the next suitable object and deleting \a item. Returns the object after the
ones that have just been moved and sets \a next_is_sibling accordingly. */
static SPObject* delete_line_break(SPObject *root, SPObject *item, bool *next_is_sibling)
{
- Inkscape::XML::Node *this_repr = SP_OBJECT_REPR(item);
+ Inkscape::XML::Node *this_repr = item->getRepr();
SPObject *next_item = NULL;
unsigned moved_char_count = sp_text_get_length(item) - 1; // the -1 is because it's going to count the line break
@@ -614,7 +617,7 @@ static SPObject* delete_line_break(SPObject *root, SPObject *item, bool *next_is
<p><div></div>*text</p>
<p><div></div></p><p>*text</p>
*/
- Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(item)->document();
+ Inkscape::XML::Document *xml_doc = item->getRepr()->document();
Inkscape::XML::Node *new_span_repr = xml_doc->createElement(span_name_for_text_object(root));
if (gchar const *a = this_repr->attribute("dx"))
@@ -626,15 +629,15 @@ static SPObject* delete_line_break(SPObject *root, SPObject *item, bool *next_is
SPObject *following_item = item;
while (following_item->getNext() == NULL) {
- following_item = SP_OBJECT_PARENT(following_item);
+ following_item = following_item->parent;
g_assert(following_item != root);
}
following_item = following_item->getNext();
SPObject *new_parent_item;
if (SP_IS_STRING(following_item)) {
- new_parent_item = SP_OBJECT_PARENT(following_item);
- SP_OBJECT_REPR(new_parent_item)->addChild(new_span_repr, following_item->getPrev() ? SP_OBJECT_REPR(following_item->getPrev()) : NULL);
+ new_parent_item = following_item->parent;
+ new_parent_item->getRepr()->addChild(new_span_repr, following_item->getPrev() ? following_item->getPrev()->getRepr() : NULL);
next_item = following_item;
*next_is_sibling = true;
} else {
@@ -645,13 +648,13 @@ static SPObject* delete_line_break(SPObject *root, SPObject *item, bool *next_is
next_item = new_parent_item;
*next_is_sibling = false;
}
- SP_OBJECT_REPR(new_parent_item)->addChild(new_span_repr, NULL);
+ new_parent_item->getRepr()->addChild(new_span_repr, NULL);
}
// work around a bug in sp_style_write_difference() which causes the difference
// not to be written if the second param has a style set which the first does not
// by causing the first param to have everything set
- SPCSSAttr *dest_node_attrs = sp_repr_css_attr(SP_OBJECT_REPR(new_parent_item), "style");
+ SPCSSAttr *dest_node_attrs = sp_repr_css_attr(new_parent_item->getRepr(), "style");
SPCSSAttr *this_node_attrs = sp_repr_css_attr(this_repr, "style");
SPCSSAttr *this_node_attrs_inherited = sp_repr_css_attr_inherited(this_repr, "style");
Inkscape::Util::List<Inkscape::XML::AttributeRecord const> attrs = dest_node_attrs->attributeList();
@@ -687,17 +690,19 @@ static void erase_from_spstring(SPString *string_item, Glib::ustring::iterator i
for (Glib::ustring::iterator it = iter_from ; it != iter_to ; it++)
char_count++;
string->erase(iter_from, iter_to);
- SP_OBJECT_REPR(string_item)->setContent(string->c_str());
+ string_item->getRepr()->setContent(string->c_str());
SPObject *parent_item = string_item;
for ( ; ; ) {
char_index += sum_sibling_text_lengths_before(parent_item);
- parent_item = SP_OBJECT_PARENT(parent_item);
+ parent_item = parent_item->parent;
TextTagAttributes *attributes = attributes_for_object(parent_item);
- if (attributes == NULL) break;
+ if (attributes == NULL) {
+ break;
+ }
attributes->erase(char_index, char_count);
- attributes->writeTo(SP_OBJECT_REPR(parent_item));
+ attributes->writeTo(parent_item->getRepr());
}
}
@@ -732,16 +737,18 @@ sp_te_delete (SPItem *item, Inkscape::Text::Layout::iterator const &start,
start_item = SP_OBJECT(rawptr);
layout->getSourceOfCharacter(iter_pair.second, &rawptr, &end_text_iter);
end_item = SP_OBJECT(rawptr);
- if (start_item == 0)
+ if (start_item == 0) {
return success; // start is at end of text
- if (is_line_break_object(start_item))
+ }
+ if (is_line_break_object(start_item)) {
move_to_end_of_paragraph(&start_item, &start_text_iter);
+ }
if (end_item == 0) {
end_item = item->lastChild();
move_to_end_of_paragraph(&end_item, &end_text_iter);
- }
- else if (is_line_break_object(end_item))
+ } else if (is_line_break_object(end_item)) {
move_to_end_of_paragraph(&end_item, &end_text_iter);
+ }
SPObject *common_ancestor = get_common_ancestor(item, start_item, end_item);
@@ -749,7 +756,7 @@ sp_te_delete (SPItem *item, Inkscape::Text::Layout::iterator const &start,
// the quick case where we're deleting stuff all from the same string
if (SP_IS_STRING(start_item)) { // always true (if it_start != it_end anyway)
// If the parent is a tref, editing on this particular string is disallowed.
- if (SP_IS_TREF(SP_OBJECT_PARENT(start_item))) {
+ if (SP_IS_TREF(start_item->parent)) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, tref_edit_message);
} else {
erase_from_spstring(SP_STRING(start_item), start_text_iter, end_text_iter);
@@ -763,7 +770,7 @@ sp_te_delete (SPItem *item, Inkscape::Text::Layout::iterator const &start,
if (sub_item == end_item) {
if (SP_IS_STRING(sub_item)) {
// If the parent is a tref, editing on this particular string is disallowed.
- if (SP_IS_TREF(SP_OBJECT_PARENT(sub_item))) {
+ if (SP_IS_TREF(sub_item->parent)) {
desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, tref_edit_message);
break;
}
@@ -791,7 +798,7 @@ sp_te_delete (SPItem *item, Inkscape::Text::Layout::iterator const &start,
bool is_sibling = true;
next_item = sub_item->getNext();
if (next_item == NULL) {
- next_item = SP_OBJECT_PARENT(sub_item);
+ next_item = sub_item->parent;
is_sibling = false;
}
@@ -875,10 +882,11 @@ sp_te_get_string_multiline (SPItem const *text, Inkscape::Text::Layout::iterator
Glib::ustring::iterator text_iter;
layout->getSourceOfCharacter(first, &rawptr, &text_iter);
char_item = SP_OBJECT(rawptr);
- if (SP_IS_STRING(char_item))
+ if (SP_IS_STRING(char_item)) {
result += *text_iter;
- else
+ } else {
result += '\n';
+ }
}
return result;
}
@@ -889,20 +897,22 @@ sp_te_set_repr_text_multiline(SPItem *text, gchar const *str)
g_return_if_fail (text != NULL);
g_return_if_fail (SP_IS_TEXT(text) || SP_IS_FLOWTEXT(text));
- Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(text)->document();
+ Inkscape::XML::Document *xml_doc = text->getRepr()->document();
Inkscape::XML::Node *repr;
SPObject *object;
bool is_textpath = false;
if (SP_IS_TEXT_TEXTPATH (text)) {
- repr = SP_OBJECT_REPR(text->firstChild());
+ repr = text->firstChild()->getRepr();
object = text->firstChild();
is_textpath = true;
} else {
- repr = SP_OBJECT_REPR (text);
- object = SP_OBJECT (text);
+ repr = text->getRepr();
+ object = text;
}
- if (!str) str = "";
+ if (!str) {
+ str = "";
+ }
gchar *content = g_strdup (str);
repr->setContent("");
@@ -910,7 +920,7 @@ sp_te_set_repr_text_multiline(SPItem *text, gchar const *str)
while (child) {
SPObject *next = child->getNext();
if (!SP_IS_FLOWREGION(child) && !SP_IS_FLOWREGIONEXCLUDE(child)) {
- repr->removeChild(SP_OBJECT_REPR(child));
+ repr->removeChild(child->getRepr());
}
child = next;
}
@@ -954,8 +964,9 @@ which represents the iterator \a position. */
TextTagAttributes*
text_tag_attributes_at_position(SPItem *item, Inkscape::Text::Layout::iterator const &position, unsigned *char_index)
{
- if (item == NULL || char_index == NULL || !SP_IS_TEXT(item))
+ if (item == NULL || char_index == NULL || !SP_IS_TEXT(item)) {
return NULL; // flowtext doesn't support kerning yet
+ }
SPText *text = SP_TEXT(item);
SPObject *source_item = 0;
@@ -964,13 +975,16 @@ text_tag_attributes_at_position(SPItem *item, Inkscape::Text::Layout::iterator c
text->layout.getSourceOfCharacter(position, &rawptr, &source_text_iter);
source_item = SP_OBJECT(rawptr);
- if (!SP_IS_STRING(source_item)) return NULL;
+ if (!SP_IS_STRING(source_item)) {
+ return NULL;
+ }
Glib::ustring *string = &SP_STRING(source_item)->string;
*char_index = sum_sibling_text_lengths_before(source_item);
- for (Glib::ustring::iterator it = string->begin() ; it != source_text_iter ; it++)
+ for (Glib::ustring::iterator it = string->begin() ; it != source_text_iter ; it++) {
++*char_index;
+ }
- return attributes_for_object(SP_OBJECT_PARENT(source_item));
+ return attributes_for_object(source_item->parent);
}
void
@@ -1045,8 +1059,10 @@ sp_te_adjust_rotation_screen(SPItem *text, Inkscape::Text::Layout::iterator cons
void *rawptr = 0;
layout->getSourceOfCharacter(std::min(start, end), &rawptr);
source_item = SP_OBJECT(rawptr);
- if (source_item == 0) return;
- gdouble degrees = (180/M_PI) * atan2(pixels, SP_OBJECT_PARENT(source_item)->style->font_size.computed / factor);
+ if (source_item == 0) {
+ return;
+ }
+ gdouble degrees = (180/M_PI) * atan2(pixels, source_item->parent->style->font_size.computed / factor);
sp_te_adjust_rotation(text, start, end, desktop, degrees);
}
@@ -1113,7 +1129,7 @@ sp_te_adjust_tspan_letterspacing_screen(SPItem *text, Inkscape::Text::Layout::it
source_obj = source_obj->parent;
}
- SPStyle *style = SP_OBJECT_STYLE (source_obj);
+ SPStyle *style = source_obj->style;
// calculate real value
/* TODO: Consider calculating val unconditionally, i.e. drop the first `if' line, and
@@ -1131,8 +1147,9 @@ sp_te_adjust_tspan_letterspacing_screen(SPItem *text, Inkscape::Text::Layout::it
}
if (start == end) {
- while (!is_line_break_object(source_obj)) // move up the tree so we apply to the closest paragraph
- source_obj = SP_OBJECT_PARENT(source_obj);
+ while (!is_line_break_object(source_obj)) { // move up the tree so we apply to the closest paragraph
+ source_obj = source_obj->parent;
+ }
nb_let = sp_text_get_length(source_obj);
} else {
nb_let = abs(layout->iteratorToCharIndex(end) - layout->iteratorToCharIndex(start));
@@ -1195,7 +1212,7 @@ sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator
g_return_if_fail (SP_IS_TEXT(text) || SP_IS_FLOWTEXT(text));
Inkscape::Text::Layout const *layout = te_get_layout(text);
- SPStyle *style = SP_OBJECT_STYLE (text);
+ SPStyle *style = text->style;
if (!style->line_height.set || style->line_height.inherit || style->line_height.normal) {
style->line_height.set = TRUE;
@@ -1283,14 +1300,15 @@ as opposed to sp_style_merge_from_style_string which merges its parameter
underneath the existing styles (ie ignoring already set properties). */
static void overwrite_style_with_string(SPObject *item, gchar const *style_string)
{
- SPStyle *new_style = sp_style_new(SP_OBJECT_DOCUMENT(item));
+ SPStyle *new_style = sp_style_new(item->document);
sp_style_merge_from_style_string(new_style, style_string);
- gchar const *item_style_string = SP_OBJECT_REPR(item)->attribute("style");
- if (item_style_string && *item_style_string)
+ gchar const *item_style_string = item->getRepr()->attribute("style");
+ if (item_style_string && *item_style_string) {
sp_style_merge_from_style_string(new_style, item_style_string);
+ }
gchar *new_style_string = sp_style_write_string(new_style);
sp_style_unref(new_style);
- SP_OBJECT_REPR(item)->setAttribute("style", new_style_string && *new_style_string ? new_style_string : NULL);
+ item->getRepr()->setAttribute("style", new_style_string && *new_style_string ? new_style_string : NULL);
g_free(new_style_string);
}
@@ -1308,7 +1326,7 @@ static bool objects_have_equal_style(SPObject const *parent, SPObject const *chi
gchar *parent_style = sp_style_write_string(parent->style, SP_STYLE_FLAG_ALWAYS);
// we have to write parent_style then read it again, because some properties format their values
// differently depending on whether they're set or not (*cough*dash-offset*cough*)
- SPStyle *parent_spstyle = sp_style_new(SP_OBJECT_DOCUMENT(parent));
+ SPStyle *parent_spstyle = sp_style_new(parent->document);
sp_style_merge_from_style_string(parent_spstyle, parent_style);
g_free(parent_style);
parent_style = sp_style_write_string(parent_spstyle, SP_STYLE_FLAG_ALWAYS);
@@ -1317,15 +1335,15 @@ static bool objects_have_equal_style(SPObject const *parent, SPObject const *chi
Glib::ustring child_style_construction;
while (child != parent) {
// FIXME: this assumes that child's style is only in style= whereas it can also be in css attributes!
- char const *style_text = SP_OBJECT_REPR(child)->attribute("style");
+ char const *style_text = child->getRepr()->attribute("style");
if (style_text && *style_text) {
child_style_construction.insert(0, style_text);
child_style_construction.insert(0, 1, ';');
}
- child = SP_OBJECT_PARENT(child);
+ child = child->parent;
}
child_style_construction.insert(0, parent_style);
- SPStyle *child_spstyle = sp_style_new(SP_OBJECT_DOCUMENT(parent));
+ SPStyle *child_spstyle = sp_style_new(parent->document);
sp_style_merge_from_style_string(child_spstyle, child_style_construction.c_str());
gchar *child_style = sp_style_write_string(child_spstyle, SP_STYLE_FLAG_ALWAYS);
sp_style_unref(child_spstyle);
@@ -1361,7 +1379,7 @@ Annoyingly similar to sp_desktop_apply_css_recursive(), except without the
transform stuff. */
static void apply_css_recursive(SPObject *o, SPCSSAttr const *css)
{
- sp_repr_css_change(SP_OBJECT_REPR(o), const_cast<SPCSSAttr*>(css), "style");
+ sp_repr_css_change(o->getRepr(), const_cast<SPCSSAttr*>(css), "style");
for (SPObject *child = o->firstChild() ; child ; child = child->getNext() ) {
if (sp_repr_css_property(const_cast<SPCSSAttr*>(css), "opacity", NULL) != NULL) {
@@ -1386,7 +1404,7 @@ name of the xml for a text span (ie tspan or flowspan). */
static void recursively_apply_style(SPObject *common_ancestor, SPCSSAttr const *css, SPObject *start_item, Glib::ustring::iterator start_text_iter, SPObject *end_item, Glib::ustring::iterator end_text_iter, char const *span_object_name)
{
bool passed_start = start_item == NULL ? true : false;
- Inkscape::XML::Document *xml_doc = SP_OBJECT_DOCUMENT(common_ancestor)->getReprDoc();
+ Inkscape::XML::Document *xml_doc = common_ancestor->document->getReprDoc();
for (SPObject *child = common_ancestor->firstChild() ; child ; child = child->getNext()) {
if (start_item == child) {
@@ -1409,7 +1427,7 @@ static void recursively_apply_style(SPObject *common_ancestor, SPCSSAttr const *
Inkscape::XML::Node *child_span = xml_doc->createElement(span_object_name);
sp_repr_css_set(child_span, const_cast<SPCSSAttr*>(css), "style"); // better hope that prototype wasn't nonconst for a good reason
SPObject *prev_item = child->getPrev();
- Inkscape::XML::Node *prev_repr = prev_item ? SP_OBJECT_REPR(prev_item) : NULL;
+ Inkscape::XML::Node *prev_repr = prev_item ? prev_item->getRepr() : NULL;
if (child == start_item || child == end_item) {
surround_entire_string = false;
@@ -1419,33 +1437,31 @@ static void recursively_apply_style(SPObject *common_ancestor, SPCSSAttr const *
unsigned end_char_index = char_index_of_iterator(string_item->string, end_text_iter);
Inkscape::XML::Node *text_before = xml_doc->createTextNode(string_item->string.substr(0, start_char_index).c_str());
- SP_OBJECT_REPR(common_ancestor)->addChild(text_before, prev_repr);
- SP_OBJECT_REPR(common_ancestor)->addChild(child_span, text_before);
+ common_ancestor->getRepr()->addChild(text_before, prev_repr);
+ common_ancestor->getRepr()->addChild(child_span, text_before);
Inkscape::GC::release(text_before);
Inkscape::XML::Node *text_in_span = xml_doc->createTextNode(string_item->string.substr(start_char_index, end_char_index - start_char_index).c_str());
child_span->appendChild(text_in_span);
Inkscape::GC::release(text_in_span);
- SP_OBJECT_REPR(child)->setContent(string_item->string.substr(end_char_index).c_str());
-
+ child->getRepr()->setContent(string_item->string.substr(end_char_index).c_str());
} else if (child == end_item) {
// eg "ABCdef" -> <span>"ABC"</span>"def"
// (includes case where start_text_iter == begin())
// NB: we might create an empty string here. Doesn't matter, it'll get cleaned up later
unsigned end_char_index = char_index_of_iterator(string_item->string, end_text_iter);
- SP_OBJECT_REPR(common_ancestor)->addChild(child_span, prev_repr);
+ common_ancestor->getRepr()->addChild(child_span, prev_repr);
Inkscape::XML::Node *text_in_span = xml_doc->createTextNode(string_item->string.substr(0, end_char_index).c_str());
child_span->appendChild(text_in_span);
Inkscape::GC::release(text_in_span);
- SP_OBJECT_REPR(child)->setContent(string_item->string.substr(end_char_index).c_str());
-
+ child->getRepr()->setContent(string_item->string.substr(end_char_index).c_str());
} else if (start_text_iter != string_item->string.begin()) {
// eg "abcDEF" -> "abc"<span>"DEF"</span>
unsigned start_char_index = char_index_of_iterator(string_item->string, start_text_iter);
Inkscape::XML::Node *text_before = xml_doc->createTextNode(string_item->string.substr(0, start_char_index).c_str());
- SP_OBJECT_REPR(common_ancestor)->addChild(text_before, prev_repr);
- SP_OBJECT_REPR(common_ancestor)->addChild(child_span, text_before);
+ common_ancestor->getRepr()->addChild(text_before, prev_repr);
+ common_ancestor->getRepr()->addChild(child_span, text_before);
Inkscape::GC::release(text_before);
Inkscape::XML::Node *text_in_span = xml_doc->createTextNode(string_item->string.substr(start_char_index).c_str());
child_span->appendChild(text_in_span);
@@ -1457,10 +1473,10 @@ static void recursively_apply_style(SPObject *common_ancestor, SPCSSAttr const *
surround_entire_string = true;
}
if (surround_entire_string) {
- Inkscape::XML::Node *child_repr = SP_OBJECT_REPR(child);
- SP_OBJECT_REPR(common_ancestor)->addChild(child_span, child_repr);
+ Inkscape::XML::Node *child_repr = child->getRepr();
+ common_ancestor->getRepr()->addChild(child_span, child_repr);
Inkscape::GC::anchor(child_repr);
- SP_OBJECT_REPR(common_ancestor)->removeChild(child_repr);
+ common_ancestor->getRepr()->removeChild(child_repr);
child_span->appendChild(child_repr);
Inkscape::GC::release(child_repr);
child = common_ancestor->get_child_by_repr(child_span);
@@ -1501,11 +1517,13 @@ static SPObject* ascend_while_first(SPObject *item, Glib::ustring::iterator text
if (text_iter != SP_STRING(item)->string.begin())
return item;
for ( ; ; ) {
- SPObject *parent = SP_OBJECT_PARENT(item);
- if (parent == common_ancestor)
+ SPObject *parent = item->parent;
+ if (parent == common_ancestor) {
break;
- if (item != parent->firstChild())
+ }
+ if (item != parent->firstChild()) {
break;
+ }
item = parent;
}
return item;
@@ -1535,18 +1553,28 @@ the repeated strings will be merged by another operator. */
static bool tidy_operator_inexplicable_spans(SPObject **item)
{
//XML Tree being directly used here while it shouldn't be.
- if (*item && sp_repr_is_meta_element((*item)->getRepr())) return false;
- if (SP_IS_STRING(*item)) return false;
- if (is_line_break_object(*item)) return false;
+ if (*item && sp_repr_is_meta_element((*item)->getRepr())) {
+ return false;
+ }
+ if (SP_IS_STRING(*item)) {
+ return false;
+ }
+ if (is_line_break_object(*item)) {
+ return false;
+ }
TextTagAttributes *attrs = attributes_for_object(*item);
- if (attrs && attrs->anyAttributesSet()) return false;
- if (!objects_have_equal_style(SP_OBJECT_PARENT(*item), *item)) return false;
+ if (attrs && attrs->anyAttributesSet()) {
+ return false;
+ }
+ if (!objects_have_equal_style((*item)->parent, *item)) {
+ return false;
+ }
SPObject *next = *item;
while ((*item)->hasChildren()) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR((*item)->firstChild());
+ Inkscape::XML::Node *repr = (*item)->firstChild()->getRepr();
Inkscape::GC::anchor(repr);
- SP_OBJECT_REPR(*item)->removeChild(repr);
- SP_OBJECT_REPR(SP_OBJECT_PARENT(*item))->addChild(repr, SP_OBJECT_REPR(next));
+ (*item)->getRepr()->removeChild(repr);
+ (*item)->parent->getRepr()->addChild(repr, next->getRepr());
Inkscape::GC::release(repr);
next = next->getNext();
}
@@ -1563,15 +1591,15 @@ static bool tidy_operator_repeated_spans(SPObject **item)
SPObject *second = first->getNext();
if (second == NULL) return false;
- Inkscape::XML::Node *first_repr = SP_OBJECT_REPR(first);
- Inkscape::XML::Node *second_repr = SP_OBJECT_REPR(second);
+ Inkscape::XML::Node *first_repr = first->getRepr();
+ Inkscape::XML::Node *second_repr = second->getRepr();
if (first_repr->type() != second_repr->type()) return false;
if (SP_IS_STRING(first) && SP_IS_STRING(second)) {
// also amalgamate consecutive SPStrings into one
Glib::ustring merged_string = SP_STRING(first)->string + SP_STRING(second)->string;
- SP_OBJECT_REPR(first)->setContent(merged_string.c_str());
+ first->getRepr()->setContent(merged_string.c_str());
second_repr->parent()->removeChild(second_repr);
return true;
}
@@ -1605,18 +1633,30 @@ static bool tidy_operator_repeated_spans(SPObject **item)
-> <font a,size 1>abc</font> */
static bool tidy_operator_excessive_nesting(SPObject **item)
{
- if (!(*item)->hasChildren()) return false;
- if ((*item)->firstChild() != (*item)->lastChild()) return false;
- if (SP_IS_FLOWREGION((*item)->firstChild()) || SP_IS_FLOWREGIONEXCLUDE((*item)->firstChild()))
+ if (!(*item)->hasChildren()) {
return false;
- if (SP_IS_STRING((*item)->firstChild())) return false;
- if (is_line_break_object((*item)->firstChild())) return false;
+ }
+ if ((*item)->firstChild() != (*item)->lastChild()) {
+ return false;
+ }
+ if (SP_IS_FLOWREGION((*item)->firstChild()) || SP_IS_FLOWREGIONEXCLUDE((*item)->firstChild())) {
+ return false;
+ }
+ if (SP_IS_STRING((*item)->firstChild())) {
+ return false;
+ }
+ if (is_line_break_object((*item)->firstChild())) {
+ return false;
+ }
TextTagAttributes *attrs = attributes_for_object((*item)->firstChild());
- if (attrs && attrs->anyAttributesSet()) return false;
- gchar const *child_style = SP_OBJECT_REPR((*item)->firstChild())->attribute("style");
- if (child_style && *child_style)
+ if (attrs && attrs->anyAttributesSet()) {
+ return false;
+ }
+ gchar const *child_style = (*item)->firstChild()->getRepr()->attribute("style");
+ if (child_style && *child_style) {
overwrite_style_with_string(*item, child_style);
- move_child_nodes(SP_OBJECT_REPR((*item)->firstChild()), SP_OBJECT_REPR(*item));
+ }
+ move_child_nodes((*item)->firstChild()->getRepr(), (*item)->getRepr());
(*item)->firstChild()->deleteObject();
return true;
}
@@ -1624,26 +1664,37 @@ static bool tidy_operator_excessive_nesting(SPObject **item)
/** helper for tidy_operator_redundant_double_nesting() */
static bool redundant_double_nesting_processor(SPObject **item, SPObject *child, bool prepend)
{
- if (SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child))
+ if (SP_IS_FLOWREGION(child) || SP_IS_FLOWREGIONEXCLUDE(child)) {
return false;
- if (SP_IS_STRING(child)) return false;
- if (is_line_break_object(child)) return false;
- if (is_line_break_object(*item)) return false;
+ }
+ if (SP_IS_STRING(child)) {
+ return false;
+ }
+ if (is_line_break_object(child)) {
+ return false;
+ }
+ if (is_line_break_object(*item)) {
+ return false;
+ }
TextTagAttributes *attrs = attributes_for_object(child);
- if (attrs && attrs->anyAttributesSet()) return false;
- if (!objects_have_equal_style(SP_OBJECT_PARENT(*item), child)) return false;
+ if (attrs && attrs->anyAttributesSet()) {
+ return false;
+ }
+ if (!objects_have_equal_style((*item)->parent, child)) {
+ return false;
+ }
Inkscape::XML::Node *insert_after_repr = 0;
if (!prepend) {
- insert_after_repr = SP_OBJECT_REPR(*item);
+ insert_after_repr = (*item)->getRepr();
} else if ((*item)->getPrev()) {
- insert_after_repr = SP_OBJECT_REPR((*item)->getPrev());
+ insert_after_repr = (*item)->getPrev()->getRepr();
}
- while (SP_OBJECT_REPR(child)->childCount()) {
- Inkscape::XML::Node *move_repr = SP_OBJECT_REPR(child)->firstChild();
+ while (child->getRepr()->childCount()) {
+ Inkscape::XML::Node *move_repr = child->getRepr()->firstChild();
Inkscape::GC::anchor(move_repr);
- SP_OBJECT_REPR(child)->removeChild(move_repr);
- SP_OBJECT_REPR(SP_OBJECT_PARENT(*item))->addChild(move_repr, insert_after_repr);
+ child->getRepr()->removeChild(move_repr);
+ (*item)->parent->getRepr()->addChild(move_repr, insert_after_repr);
Inkscape::GC::release(move_repr);
insert_after_repr = move_repr; // I think this will stay valid long enough. It's garbage collected these days.
}
@@ -1686,11 +1737,11 @@ static bool redundant_semi_nesting_processor(SPObject **item, SPObject *child, b
SPCSSAttr *css_child_and_item = sp_repr_css_attr_new();
SPCSSAttr *css_child_only = sp_repr_css_attr_new();
- gchar const *item_style = SP_OBJECT_REPR(*item)->attribute("style");
+ gchar const *item_style = (*item)->getRepr()->attribute("style");
if (item_style && *item_style) {
sp_repr_css_attr_add_from_string(css_child_and_item, item_style);
}
- gchar const *child_style = SP_OBJECT_REPR(child)->attribute("style");
+ gchar const *child_style = child->getRepr()->attribute("style");
if (child_style && *child_style) {
sp_repr_css_attr_add_from_string(css_child_and_item, child_style);
sp_repr_css_attr_add_from_string(css_child_only, child_style);
@@ -1700,15 +1751,16 @@ static bool redundant_semi_nesting_processor(SPObject **item, SPObject *child, b
sp_repr_css_attr_unref(css_child_only);
if (!equal) return false;
- Inkscape::XML::Document *xml_doc = SP_OBJECT_REPR(*item)->document();
- Inkscape::XML::Node *new_span = xml_doc->createElement(SP_OBJECT_REPR(*item)->name());
+ Inkscape::XML::Document *xml_doc = (*item)->getRepr()->document();
+ Inkscape::XML::Node *new_span = xml_doc->createElement((*item)->getRepr()->name());
if (prepend) {
SPObject *prev = (*item)->getPrev();
- SP_OBJECT_REPR(SP_OBJECT_PARENT(*item))->addChild(new_span, prev ? SP_OBJECT_REPR(prev) : NULL);
- } else
+ (*item)->parent->getRepr()->addChild(new_span, prev ? prev->getRepr() : NULL);
+ } else {
SP_OBJECT_REPR(SP_OBJECT_PARENT(*item))->addChild(new_span, SP_OBJECT_REPR(*item));
- new_span->setAttribute("style", SP_OBJECT_REPR(child)->attribute("style"));
- move_child_nodes(SP_OBJECT_REPR(child), new_span);
+ }
+ new_span->setAttribute("style", child->getRepr()->attribute("style"));
+ move_child_nodes(child->getRepr(), new_span);
Inkscape::GC::release(new_span);
child->deleteObject();
return true;
@@ -1751,10 +1803,15 @@ static SPString* find_last_string_child_not_equal_to(SPObject *root, SPObject *n
-> abc<b><i>def</i></b> ghi */
static bool tidy_operator_styled_whitespace(SPObject **item)
{
- if (!SP_IS_STRING(*item)) return false;
+ if (!SP_IS_STRING(*item)) {
+ return false;
+ }
Glib::ustring const &str = SP_STRING(*item)->string;
- for (Glib::ustring::const_iterator it = str.begin() ; it != str.end() ; ++it)
- if (!g_unichar_isspace(*it)) return false;
+ for (Glib::ustring::const_iterator it = str.begin() ; it != str.end() ; ++it) {
+ if (!g_unichar_isspace(*it)) {
+ return false;
+ }
+ }
SPObject *test_item = *item;
SPString *next_string;
@@ -1765,9 +1822,13 @@ static bool tidy_operator_styled_whitespace(SPObject **item)
break;
}
for ( ; ; ) { // go up one item in the xml
- test_item = SP_OBJECT_PARENT(test_item);
- if (is_line_break_object(test_item)) break;
- if (SP_IS_FLOWTEXT(test_item)) return false;
+ test_item = test_item->parent;
+ if (is_line_break_object(test_item)) {
+ break;
+ }
+ if (SP_IS_FLOWTEXT(test_item)) {
+ return false;
+ }
SPObject *next = test_item->getNext();
if (next) {
test_item = next;
@@ -1776,12 +1837,14 @@ static bool tidy_operator_styled_whitespace(SPObject **item)
}
if (is_line_break_object(test_item)) { // no next string, see if there's a prev string
next_string = find_last_string_child_not_equal_to(test_item, *item);
- if (next_string == NULL) return false; // an empty paragraph
+ if (next_string == NULL) {
+ return false; // an empty paragraph
+ }
next_string->string += str;
break;
}
}
- SP_OBJECT_REPR(next_string)->setContent(next_string->string.c_str());
+ next_string->getRepr()->setContent(next_string->string.c_str());
SPObject *delete_obj = *item;
*item = (*item)->getNext();
delete_obj->deleteObject();
diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp
index 999ee877f..c1ab82af8 100644
--- a/src/tweak-context.cpp
+++ b/src/tweak-context.cpp
@@ -416,7 +416,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
GSList *items = g_slist_prepend (NULL, item);
GSList *selected = NULL;
GSList *to_select = NULL;
- SPDocument *doc = SP_OBJECT_DOCUMENT(item);
+ SPDocument *doc = item->document;
sp_item_list_to_curves (items, &selected, &to_select);
g_slist_free (items);
SPObject* newObj = doc->getObjectByRepr((Inkscape::XML::Node *) to_select->data);
@@ -521,13 +521,13 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
double chance = g_random_double_range(0, 1);
if (chance <= prob) {
if (reverse) { // delete
- sp_object_ref(SP_OBJECT(item), NULL);
- SP_OBJECT(item)->deleteObject(true, true);
- sp_object_unref(SP_OBJECT(item), NULL);
+ sp_object_ref(item, NULL);
+ item->deleteObject(true, true);
+ sp_object_unref(item, NULL);
} else { // duplicate
- SPDocument *doc = SP_OBJECT_DOCUMENT(item);
+ SPDocument *doc = item->document;
Inkscape::XML::Document* xml_doc = doc->getReprDoc();
- Inkscape::XML::Node *old_repr = SP_OBJECT_REPR(item);
+ Inkscape::XML::Node *old_repr = item->getRepr();
SPObject *old_obj = doc->getObjectByRepr(old_repr);
Inkscape::XML::Node *parent = old_repr->parent();
Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
@@ -555,11 +555,11 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
return false;
// remember the position of the item
- pos = SP_OBJECT_REPR(item)->position();
+ pos = item->getRepr()->position();
// remember parent
- parent = SP_OBJECT_REPR(item)->parent();
+ parent = item->getRepr()->parent();
// remember id
- id = SP_OBJECT_REPR(item)->attribute("id");
+ id = item->getRepr()->attribute("id");
}
@@ -587,7 +587,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / i2doc.descrim()); // default 0.059
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)
{
@@ -650,7 +650,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
selection->remove(item);
// It's going to resurrect, so we delete without notifying listeners.
- SP_OBJECT(item)->deleteObject(false);
+ item->deleteObject(false);
// restore id
newrepr->setAttribute("id", id);
@@ -669,9 +669,9 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
newrepr->setAttribute("d", str);
} else {
if (SP_IS_LPE_ITEM(item) && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(item))) {
- SP_OBJECT_REPR(item)->setAttribute("inkscape:original-d", str);
+ item->getRepr()->setAttribute("inkscape:original-d", str);
} else {
- SP_OBJECT_REPR(item)->setAttribute("d", str);
+ item->getRepr()->setAttribute("d", str);
}
}
g_free(str);
@@ -886,7 +886,7 @@ tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke,
tweak_color (mode, SP_STOP(child_prev)->specified_color.v.c, rgb_goal,
force * (offset_h - pos_e) / (offset_h - offset_l),
do_h, do_s, do_l);
- SP_OBJECT(stop)->updateRepr();
+ stop->updateRepr();
child_prev->updateRepr();
break;
} else {
@@ -903,7 +903,7 @@ tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke,
tweak_color (mode, stop->specified_color.v.c, rgb_goal,
force * tweak_profile (fabs (pos_e - offset_h), r),
do_h, do_s, do_l);
- SP_OBJECT(stop)->updateRepr();
+ stop->updateRepr();
}
}
}
@@ -938,7 +938,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
}
} else {
- SPStyle *style = SP_OBJECT_STYLE(item);
+ SPStyle *style = item->style;
if (!style) {
return false;
}
@@ -1012,7 +1012,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
remove_filter(item, false);
} else {
double radius = blur_new * perimeter;
- SPFilter *filter = modify_filter_gaussian_blur_from_item(SP_OBJECT_DOCUMENT(item), item, radius);
+ SPFilter *filter = modify_filter_gaussian_blur_from_item(item->document, item, radius);
sp_style_set_property_url(item, "filter", filter, false);
}
diff --git a/src/ui/context-menu.cpp b/src/ui/context-menu.cpp
index c544d1999..8e50897e8 100644
--- a/src/ui/context-menu.cpp
+++ b/src/ui/context-menu.cpp
@@ -278,20 +278,20 @@ sp_item_create_link(GtkMenuItem *menuitem, SPItem *item)
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:a");
- SP_OBJECT_REPR(SP_OBJECT_PARENT(item))->addChild(repr, SP_OBJECT_REPR(item));
- SPObject *object = SP_OBJECT_DOCUMENT(item)->getObjectByRepr(repr);
+ item->parent->getRepr()->addChild(repr, item->getRepr());
+ SPObject *object = item->document->getObjectByRepr(repr);
g_return_if_fail(SP_IS_ANCHOR(object));
- const char *id = SP_OBJECT_REPR(item)->attribute("id");
- Inkscape::XML::Node *child = SP_OBJECT_REPR(item)->duplicate(xml_doc);
- SP_OBJECT(item)->deleteObject(false);
+ const char *id = item->getRepr()->attribute("id");
+ Inkscape::XML::Node *child = item->getRepr()->duplicate(xml_doc);
+ item->deleteObject(false);
repr->addChild(child, NULL);
child->setAttribute("id", id);
Inkscape::GC::release(repr);
Inkscape::GC::release(child);
- DocumentUndo::done(SP_OBJECT_DOCUMENT(object), SP_VERB_NONE,
+ DocumentUndo::done(object->document, SP_VERB_NONE,
_("Create link"));
sp_object_attributes_dialog(object, "SPAnchor");
@@ -371,7 +371,7 @@ sp_anchor_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m)
static void
sp_anchor_link_properties(GtkMenuItem */*menuitem*/, SPAnchor *anchor)
{
- sp_object_attributes_dialog(SP_OBJECT(anchor), "Link");
+ sp_object_attributes_dialog(anchor, "Link");
}
static void
@@ -420,7 +420,7 @@ sp_image_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m)
gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_image_image_edit), item);
gtk_widget_show(w);
gtk_menu_append(GTK_MENU(m), w);
- Inkscape::XML::Node *ir = SP_OBJECT_REPR(object);
+ Inkscape::XML::Node *ir = object->getRepr();
const gchar *href = ir->attribute("xlink:href");
if ( (!href) || ((strncmp(href, "data:", 5) == 0)) ) {
gtk_widget_set_sensitive( w, FALSE );
@@ -430,7 +430,7 @@ sp_image_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m)
static void
sp_image_image_properties(GtkMenuItem */*menuitem*/, SPAnchor *anchor)
{
- sp_object_attributes_dialog(SP_OBJECT(anchor), "Image");
+ sp_object_attributes_dialog(anchor, "Image");
}
static gchar* getImageEditorName() {
@@ -455,8 +455,8 @@ static gchar* getImageEditorName() {
static void sp_image_image_edit(GtkMenuItem *menuitem, SPAnchor *anchor)
{
- SPObject* obj = SP_OBJECT(anchor);
- Inkscape::XML::Node *ir = SP_OBJECT_REPR(obj);
+ SPObject* obj = anchor;
+ Inkscape::XML::Node *ir = obj->getRepr();
const gchar *href = ir->attribute("xlink:href");
GError* errThing = 0;
diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp
index 1ab0d51bc..bd9777048 100644
--- a/src/ui/dialog/guides.cpp
+++ b/src/ui/dialog/guides.cpp
@@ -109,7 +109,7 @@ void GuidelinePropertiesDialog::_onApply()
sp_guide_moveto(*_guide, newpos, true);
- DocumentUndo::done(SP_OBJECT_DOCUMENT(_guide), SP_VERB_NONE,
+ DocumentUndo::done(_guide->document, SP_VERB_NONE,
_("Set guide properties"));
}
@@ -120,7 +120,7 @@ void GuidelinePropertiesDialog::_onOK()
void GuidelinePropertiesDialog::_onDelete()
{
- SPDocument *doc = SP_OBJECT_DOCUMENT(_guide);
+ SPDocument *doc = _guide->document;
sp_guide_remove(_guide);
DocumentUndo::done(doc, SP_VERB_NONE,
_("Delete guide"));
@@ -235,7 +235,7 @@ void GuidelinePropertiesDialog::_setup() {
}
{
- Inkscape::XML::Node *repr = SP_OBJECT_REPR (_guide);
+ Inkscape::XML::Node *repr = _guide->getRepr();
const gchar *guide_id = repr->attribute("id");
gchar *label = g_strdup_printf(_("Guideline ID: %s"), guide_id);
_label_name.set_label(label);
diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp
index b507d9f9a..bb566fb7f 100644
--- a/src/ui/dialog/icon-preview.cpp
+++ b/src/ui/dialog/icon-preview.cpp
@@ -355,7 +355,7 @@ void IconPreviewPanel::refreshPreview()
GSList const *items = sel->itemList();
while ( items && !target ) {
SPItem* item = SP_ITEM( items->data );
- SPObject * obj = SP_OBJECT(item);
+ SPObject * obj = item;
gchar const *id = obj->getId();
if ( id ) {
targetId = id;
@@ -427,7 +427,7 @@ void IconPreviewPanel::modeToggled()
void IconPreviewPanel::renderPreview( SPObject* obj )
{
- SPDocument * doc = SP_OBJECT_DOCUMENT(obj);
+ SPDocument * doc = obj->document;
gchar const * id = obj->getId();
if ( !renderTimer ) {
renderTimer = new Glib::Timer();
diff --git a/src/uri-references.cpp b/src/uri-references.cpp
index d979fe292..2c09695d4 100644
--- a/src/uri-references.cpp
+++ b/src/uri-references.cpp
@@ -47,7 +47,7 @@ void URIReference::attach(const URI &uri) throw(BadURIException)
{
SPDocument *document;
if (_owner) {
- document = SP_OBJECT_DOCUMENT(_owner);
+ document = _owner->document;
} else if (_owner_document) {
document = _owner_document;
} else {
diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp
index 49549de1c..f7a981c9f 100644
--- a/src/widgets/gradient-selector.cpp
+++ b/src/widgets/gradient-selector.cpp
@@ -259,7 +259,7 @@ SPGradientSpread SPGradientSelector::getSpread()
void SPGradientSelector::setVector(SPDocument *doc, SPGradient *vector)
{
g_return_if_fail(!vector || SP_IS_GRADIENT(vector));
- g_return_if_fail(!vector || (SP_OBJECT_DOCUMENT(vector) == doc));
+ g_return_if_fail(!vector || (vector->document == doc));
if (vector && !vector->hasStops()) {
return;
@@ -312,7 +312,7 @@ sp_gradient_selector_vector_set (SPGradientVectorSelector */*gvs*/, SPGradient *
if (!blocked) {
blocked = TRUE;
gr = sp_gradient_ensure_vector_normalized (gr);
- sel->setVector((gr) ? SP_OBJECT_DOCUMENT (gr) : 0, gr);
+ sel->setVector((gr) ? gr->document : 0, gr);
g_signal_emit (G_OBJECT (sel), signals[CHANGED], 0, gr);
blocked = FALSE;
}
@@ -344,9 +344,9 @@ sp_gradient_selector_add_vector_clicked (GtkWidget */*w*/, SPGradientSelector *s
Inkscape::XML::Node *repr = NULL;
- if (gr)
- repr = SP_OBJECT_REPR (gr)->duplicate(xml_doc);
- else {
+ if (gr) {
+ repr = gr->getRepr()->duplicate(xml_doc);
+ } else {
repr = xml_doc->createElement("svg:linearGradient");
Inkscape::XML::Node *stop = xml_doc->createElement("svg:stop");
stop->setAttribute("offset", "0");
@@ -360,7 +360,7 @@ sp_gradient_selector_add_vector_clicked (GtkWidget */*w*/, SPGradientSelector *s
Inkscape::GC::release(stop);
}
- SP_OBJECT_REPR (SP_DOCUMENT_DEFS (doc))->addChild(repr, NULL);
+ SP_DOCUMENT_DEFS(doc)->getRepr()->addChild(repr, NULL);
gr = (SPGradient *) doc->getObjectByRepr(repr);
sp_gradient_vector_selector_set_gradient(
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index 1be0aae8e..839ddf67c 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -162,7 +162,7 @@ GtkWidget *sp_gradient_vector_selector_new(SPDocument *doc, SPGradient *gr)
GtkWidget *gvs;
g_return_val_if_fail(!gr || SP_IS_GRADIENT(gr), NULL);
- g_return_val_if_fail(!gr || (SP_OBJECT_DOCUMENT(gr) == doc), NULL);
+ g_return_val_if_fail(!gr || (gr->document == doc), NULL);
gvs = static_cast<GtkWidget*>(gtk_type_new(SP_TYPE_GRADIENT_VECTOR_SELECTOR));
@@ -187,7 +187,7 @@ void sp_gradient_vector_selector_set_gradient(SPGradientVectorSelector *gvs, SPD
g_return_if_fail(SP_IS_GRADIENT_VECTOR_SELECTOR(gvs));
g_return_if_fail(!gr || (doc != NULL));
g_return_if_fail(!gr || SP_IS_GRADIENT(gr));
- g_return_if_fail(!gr || (SP_OBJECT_DOCUMENT(gr) == doc));
+ g_return_if_fail(!gr || (gr->document == doc));
g_return_if_fail(!gr || gr->hasStops());
if (doc != gvs->doc) {
@@ -256,7 +256,7 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs)
/* Pick up all gradients with vectors */
GSList *gl = NULL;
if (gvs->gr) {
- const GSList *gradients = SP_OBJECT_DOCUMENT(gvs->gr)->getResourceList("gradient");
+ const GSList *gradients = gvs->gr->document->getResourceList("gradient");
for (const GSList *curr = gradients; curr; curr = curr->next) {
SPGradient* grad = SP_GRADIENT(curr->data);
if ( grad->hasStops() && (grad->isSwatch() == gvs->swatched) ) {
@@ -371,7 +371,7 @@ static void sp_gvs_gradient_activate(GtkMenuItem *mi, SPGradientVectorSelector *
/* We do extra undo push here */
/* If handler has already done it, it is just NOP */
// FIXME: looks like this is never a valid undo step, consider removing this
- DocumentUndo::done(SP_OBJECT_DOCUMENT(norm), SP_VERB_CONTEXT_GRADIENT,
+ DocumentUndo::done(norm->document, SP_VERB_CONTEXT_GRADIENT,
/* TODO: annotate */ "gradient-vector.cpp:350");
}
}
@@ -479,7 +479,7 @@ static void verify_grad(SPGradient *gradient)
}
Inkscape::XML::Document *xml_doc;
- xml_doc = SP_OBJECT_REPR(gradient)->document();
+ xml_doc = gradient->getRepr()->document();
if (i < 1) {
Inkscape::CSSOStringStream os;
@@ -490,20 +490,20 @@ static void verify_grad(SPGradient *gradient)
child = xml_doc->createElement("svg:stop");
sp_repr_set_css_double(child, "offset", 0.0);
child->setAttribute("style", os.str().c_str());
- SP_OBJECT_REPR(gradient)->addChild(child, NULL);
+ gradient->getRepr()->addChild(child, NULL);
Inkscape::GC::release(child);
child = xml_doc->createElement("svg:stop");
sp_repr_set_css_double(child, "offset", 1.0);
child->setAttribute("style", os.str().c_str());
- SP_OBJECT_REPR(gradient)->addChild(child, NULL);
+ gradient->getRepr()->addChild(child, NULL);
Inkscape::GC::release(child);
}
if (i < 2) {
- sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", 0.0);
- Inkscape::XML::Node *child = SP_OBJECT_REPR(stop)->duplicate(SP_OBJECT_REPR(gradient)->document());
+ sp_repr_set_css_double(stop->getRepr(), "offset", 0.0);
+ Inkscape::XML::Node *child = stop->getRepr()->duplicate(gradient->getRepr()->document());
sp_repr_set_css_double(child, "offset", 1.0);
- SP_OBJECT_REPR(gradient)->addChild(child, SP_OBJECT_REPR(stop));
+ gradient->getRepr()->addChild(child, stop->getRepr());
Inkscape::GC::release(child);
}
}
@@ -513,7 +513,7 @@ static void select_stop_in_list( GtkWidget *mnu, SPGradient *gradient, SPStop *n
int i = 0;
for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) {
if (SP_IS_STOP(ochild)) {
- if (SP_OBJECT(ochild) == SP_OBJECT(new_stop)) {
+ if (ochild == new_stop) {
gtk_option_menu_set_history(GTK_OPTION_MENU(mnu), i);
break;
}
@@ -565,7 +565,7 @@ static void update_stop_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_
gtk_widget_show(cpv);
gtk_container_add( GTK_CONTAINER(hb), cpv );
g_object_set_data( G_OBJECT(i), "preview", cpv );
- Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) sl->data);
+ Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(sl->data)->getRepr();
GtkWidget *l = gtk_label_new(repr->attribute("id"));
gtk_widget_show(l);
gtk_misc_set_alignment(GTK_MISC(l), 1.0, 0.5);
@@ -659,9 +659,9 @@ static void offadjustmentChanged( GtkAdjustment *adjustment, GtkWidget *vb)
SPStop *stop = SP_STOP(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "stop"));
stop->offset = adjustment->value;
- sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", stop->offset);
+ sp_repr_set_css_double(stop->getRepr(), "offset", stop->offset);
- DocumentUndo::maybeDone(SP_OBJECT_DOCUMENT(stop), "gradient:stop:offset", SP_VERB_CONTEXT_GRADIENT,
+ DocumentUndo::maybeDone(stop->document, "gradient:stop:offset", SP_VERB_CONTEXT_GRADIENT,
_("Change gradient stop offset"));
blocked = FALSE;
@@ -705,15 +705,15 @@ static void sp_grd_ed_add_stop(GtkWidget */*widget*/, GtkWidget *vb)
}
if (next != NULL) {
- new_stop_repr = SP_OBJECT_REPR(stop)->duplicate(SP_OBJECT_REPR(gradient)->document());
- SP_OBJECT_REPR(gradient)->addChild(new_stop_repr, SP_OBJECT_REPR(stop));
+ new_stop_repr = stop->getRepr()->duplicate(gradient->getRepr()->document());
+ gradient->getRepr()->addChild(new_stop_repr, stop->getRepr());
} else {
next = stop;
- new_stop_repr = SP_OBJECT_REPR(stop->getPrevStop())->duplicate(SP_OBJECT_REPR(gradient)->document());
- SP_OBJECT_REPR(gradient)->addChild(new_stop_repr, SP_OBJECT_REPR(stop->getPrevStop()));
+ new_stop_repr = stop->getPrevStop()->getRepr()->duplicate(gradient->getRepr()->document());
+ gradient->getRepr()->addChild(new_stop_repr, stop->getPrevStop()->getRepr());
}
- SPStop *newstop = (SPStop *) SP_OBJECT_DOCUMENT(gradient)->getObjectByRepr(new_stop_repr);
+ SPStop *newstop = reinterpret_cast<SPStop *>(gradient->document->getObjectByRepr(new_stop_repr));
newstop->offset = (stop->offset + next->offset) * 0.5 ;
@@ -726,8 +726,8 @@ static void sp_grd_ed_add_stop(GtkWidget */*widget*/, GtkWidget *vb)
sp_svg_write_color(c, sizeof(c), cnew);
gdouble opacity = static_cast<gdouble>(SP_RGBA32_A_F(cnew));
os << "stop-color:" << c << ";stop-opacity:" << opacity <<";";
- SP_OBJECT_REPR (newstop)->setAttribute("style", os.str().c_str());
- sp_repr_set_css_double( SP_OBJECT_REPR(newstop), "offset", (double)newstop->offset);
+ newstop->getRepr()->setAttribute("style", os.str().c_str());
+ sp_repr_set_css_double( newstop->getRepr(), "offset", (double)newstop->offset);
sp_gradient_vector_widget_load_gradient(vb, gradient);
Inkscape::GC::release(new_stop_repr);
@@ -736,7 +736,7 @@ static void sp_grd_ed_add_stop(GtkWidget */*widget*/, GtkWidget *vb)
GtkWidget *offslide =GTK_WIDGET(g_object_get_data(G_OBJECT(vb), "offslide"));
gtk_widget_set_sensitive(offslide, TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(offspin), TRUE);
- DocumentUndo::done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT,
+ DocumentUndo::done(gradient->document, SP_VERB_CONTEXT_GRADIENT,
_("Add gradient stop"));
}
@@ -754,20 +754,20 @@ static void sp_grd_ed_del_stop(GtkWidget */*widget*/, GtkWidget *vb)
SPStop *next = stop->getNextStop();
if (next) {
next->offset = 0;
- sp_repr_set_css_double(SP_OBJECT_REPR(next), "offset", 0);
+ sp_repr_set_css_double(next->getRepr(), "offset", 0);
}
} else if (stop->offset == 1) {
SPStop *prev = stop->getPrevStop();
if (prev) {
prev->offset = 1;
- sp_repr_set_css_double(SP_OBJECT_REPR(prev), "offset", 1);
+ sp_repr_set_css_double(prev->getRepr(), "offset", 1);
}
}
- SP_OBJECT_REPR(gradient)->removeChild(SP_OBJECT_REPR(stop));
+ gradient->getRepr()->removeChild(stop->getRepr());
sp_gradient_vector_widget_load_gradient(vb, gradient);
update_stop_list(GTK_WIDGET(mnu), gradient, NULL);
- DocumentUndo::done(SP_OBJECT_DOCUMENT(gradient), SP_VERB_CONTEXT_GRADIENT,
+ DocumentUndo::done(gradient->document, SP_VERB_CONTEXT_GRADIENT,
_("Delete gradient stop"));
}
@@ -787,7 +787,7 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s
gtk_widget_show(w);
gtk_box_pack_start(GTK_BOX(vb), w, TRUE, TRUE, PAD);
- sp_repr_add_listener(SP_OBJECT_REPR(gradient), &grad_edit_dia_repr_events, vb);
+ sp_repr_add_listener(gradient->getRepr(), &grad_edit_dia_repr_events, vb);
GtkTooltips *tt = gtk_tooltips_new();
/* Stop list */
@@ -1031,11 +1031,11 @@ static void sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradien
update_stop_list(GTK_WIDGET(mnu), gradient, NULL);
// Once the user edits a gradient, it stops being auto-collectable
- if (SP_OBJECT_REPR(gradient)->attribute("inkscape:collect")) {
- SPDocument *document = SP_OBJECT_DOCUMENT(gradient);
+ if (gradient->getRepr()->attribute("inkscape:collect")) {
+ SPDocument *document = gradient->document;
bool saved = DocumentUndo::getUndoSensitive(document);
DocumentUndo::setUndoSensitive(document, false);
- SP_OBJECT_REPR(gradient)->setAttribute("inkscape:collect", NULL);
+ gradient->getRepr()->setAttribute("inkscape:collect", NULL);
DocumentUndo::setUndoSensitive(document, saved);
}
} else { // no gradient, disable everything
@@ -1077,9 +1077,7 @@ static gboolean sp_gradient_vector_dialog_delete(GtkWidget */*widget*/, GdkEvent
static void sp_gradient_vector_widget_destroy(GtkObject *object, gpointer /*data*/)
{
- GObject *gradient;
-
- gradient = (GObject*)g_object_get_data(G_OBJECT(object), "gradient");
+ SPObject *gradient = reinterpret_cast<SPObject*>(g_object_get_data(G_OBJECT(object), "gradient"));
sigc::connection *release_connection = (sigc::connection *)g_object_get_data(G_OBJECT(object), "gradient_release_connection");
sigc::connection *modified_connection = (sigc::connection *)g_object_get_data(G_OBJECT(object), "gradient_modified_connection");
@@ -1092,8 +1090,8 @@ static void sp_gradient_vector_widget_destroy(GtkObject *object, gpointer /*data
sp_signal_disconnect_by_data(gradient, object);
}
- if (gradient && SP_OBJECT_REPR(gradient)) {
- sp_repr_remove_listener_by_data(SP_OBJECT_REPR(gradient), object);
+ if (gradient && gradient->getRepr()) {
+ sp_repr_remove_listener_by_data(gradient->getRepr(), object);
}
}
@@ -1178,14 +1176,14 @@ static void sp_gradient_vector_color_changed(SPColorSelector *csel, GtkObject *o
float alpha = 0;
csel->base->getColorAlpha( color, alpha );
- sp_repr_set_css_double(SP_OBJECT_REPR(stop), "offset", stop->offset);
+ sp_repr_set_css_double(stop->getRepr(), "offset", stop->offset);
Inkscape::CSSOStringStream os;
os << "stop-color:" << color.toString() << ";stop-opacity:" << static_cast<gdouble>(alpha) <<";";
- SP_OBJECT_REPR(stop)->setAttribute("style", os.str().c_str());
+ stop->getRepr()->setAttribute("style", os.str().c_str());
// g_snprintf(c, 256, "stop-color:#%06x;stop-opacity:%g;", rgb >> 8, static_cast<gdouble>(alpha));
- //SP_OBJECT_REPR(stop)->setAttribute("style", c);
+ //stop->getRepr()->setAttribute("style", c);
- DocumentUndo::done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT,
+ DocumentUndo::done(ngr->document, SP_VERB_CONTEXT_GRADIENT,
_("Change gradient stop color"));
blocked = FALSE;
diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp
index 1d8acb40a..7b513a4d7 100644
--- a/src/widgets/paint-selector.cpp
+++ b/src/widgets/paint-selector.cpp
@@ -457,7 +457,7 @@ void SPPaintSelector::setSwatch(SPGradient *vector )
SwatchSelector *swatchsel = static_cast<SwatchSelector*>(g_object_get_data(G_OBJECT(selector), "swatch-selector"));
if (swatchsel) {
- swatchsel->setVector( (vector) ? SP_OBJECT_DOCUMENT(vector) : 0, vector );
+ swatchsel->setVector( (vector) ? vector->document : 0, vector );
}
}
@@ -471,7 +471,7 @@ void SPPaintSelector::setGradientLinear(SPGradient *vector)
SPGradientSelector *gsel = getGradientFromData(this);
gsel->setMode(SPGradientSelector::MODE_LINEAR);
- gsel->setVector((vector) ? SP_OBJECT_DOCUMENT(vector) : 0, vector);
+ gsel->setVector((vector) ? vector->document : 0, vector);
}
void SPPaintSelector::setGradientRadial(SPGradient *vector)
@@ -485,7 +485,7 @@ void SPPaintSelector::setGradientRadial(SPGradient *vector)
gsel->setMode(SPGradientSelector::MODE_RADIAL);
- gsel->setVector((vector) ? SP_OBJECT_DOCUMENT(vector) : 0, vector);
+ gsel->setVector((vector) ? vector->document : 0, vector);
}
void SPPaintSelector::setGradientProperties( SPGradientUnits units, SPGradientSpread spread )
@@ -541,7 +541,7 @@ void SPPaintSelector::pushAttrsToGradient( SPGradient *gr ) const
getGradientProperties( units, spread );
gr->setUnits(units);
gr->setSpread(spread);
- SP_OBJECT(gr)->updateRepr();
+ gr->updateRepr();
}
static void
@@ -804,7 +804,7 @@ sp_pattern_menu_build (GtkWidget *m, GSList *pattern_list, SPDocument */*source*
{
for (; pattern_list != NULL; pattern_list = pattern_list->next) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) pattern_list->data);
+ Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(pattern_list->data)->getRepr();
GtkWidget *i = gtk_menu_item_new();
gtk_widget_show(i);
diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp
index 0c31c2f74..a64a03f4e 100644
--- a/src/widgets/sp-attribute-widget.cpp
+++ b/src/widgets/sp-attribute-widget.cpp
@@ -154,14 +154,12 @@ sp_attribute_widget_changed (GtkEditable *editable)
if (!*text)
text = NULL;
- if (spaw->hasobj && spaw->src.object) {
-
- SP_OBJECT_REPR (spaw->src.object)->setAttribute(spaw->attribute, text, false);
- DocumentUndo::done(SP_OBJECT_DOCUMENT (spaw->src.object), SP_VERB_NONE,
+ if (spaw->hasobj && spaw->src.object) {
+ spaw->src.object->getRepr()->setAttribute(spaw->attribute, text, false);
+ DocumentUndo::done(spaw->src.object->document, SP_VERB_NONE,
_("Set attribute"));
} else if (spaw->src.repr) {
-
spaw->src.repr->setAttribute(spaw->attribute, text, false);
/* TODO: Warning! Undo will not be flushed in given case */
}
@@ -248,7 +246,7 @@ sp_attribute_widget_set_object ( SPAttributeWidget *spaw,
spaw->attribute = g_strdup (attribute);
- val = SP_OBJECT_REPR (object)->attribute(attribute);
+ val = object->getRepr()->attribute(attribute);
gtk_entry_set_text (GTK_ENTRY (spaw), val ? val : (const gchar *) "");
spaw->blocked = FALSE;
}
@@ -317,7 +315,7 @@ sp_attribute_widget_object_modified ( SPObject */*object*/,
if (flags && SP_OBJECT_MODIFIED_FLAG) {
const gchar *val, *text;
- val = SP_OBJECT_REPR (spaw->src.object)->attribute(spaw->attribute);
+ val = spaw->src.object->getRepr()->attribute(spaw->attribute);
text = gtk_entry_get_text (GTK_ENTRY (spaw));
if (val || text) {
@@ -588,7 +586,7 @@ sp_attribute_table_set_object ( SPAttributeTable *spat,
XPAD, YPAD );
w = gtk_entry_new ();
gtk_widget_show (w);
- val = SP_OBJECT_REPR (object)->attribute(attributes[i]);
+ val = object->getRepr()->attribute(attributes[i]);
gtk_entry_set_text (GTK_ENTRY (w), val ? val : (const gchar *) "");
gtk_table_attach ( GTK_TABLE (spat->table), w, 1, 2, i, i + 1,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL),
@@ -719,7 +717,7 @@ sp_attribute_table_object_modified ( SPObject */*object*/,
gint i;
for (i = 0; i < spat->num_attr; i++) {
const gchar *val, *text;
- val = SP_OBJECT_REPR (spat->src.object)->attribute(spat->attributes[i]);
+ val = spat->src.object->getRepr()->attribute(spat->attributes[i]);
text = gtk_entry_get_text (GTK_ENTRY (spat->entries[i]));
if (val || text) {
if (!val || !text || strcmp (val, text)) {
@@ -763,8 +761,8 @@ sp_attribute_table_entry_changed ( GtkEditable *editable,
text = NULL;
if (spat->hasobj && spat->src.object) {
- SP_OBJECT_REPR (spat->src.object)->setAttribute(spat->attributes[i], text, false);
- DocumentUndo::done(SP_OBJECT_DOCUMENT (spat->src.object), SP_VERB_NONE,
+ spat->src.object->getRepr()->setAttribute(spat->attributes[i], text, false);
+ DocumentUndo::done(spat->src.object->document, SP_VERB_NONE,
_("Set attribute"));
} else if (spat->src.repr) {
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index 9b79ed09e..555418269 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -161,11 +161,11 @@ sp_marker_prev_new(unsigned psize, gchar const *mname,
// Create a copy repr of the marker with id="sample"
Inkscape::XML::Document *xml_doc = sandbox->getReprDoc();
- Inkscape::XML::Node *mrepr = SP_OBJECT_REPR (marker)->duplicate(xml_doc);
+ Inkscape::XML::Node *mrepr = marker->getRepr()->duplicate(xml_doc);
mrepr->setAttribute("id", "sample");
// Replace the old sample in the sandbox by the new one
- Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (sandbox->getObjectById("defs"));
+ Inkscape::XML::Node *defsrepr = sandbox->getObjectById("defs")->getRepr();
SPObject *oldmarker = sandbox->getObjectById("sample");
if (oldmarker)
oldmarker->deleteObject(false);
@@ -225,7 +225,7 @@ ink_marker_list_get (SPDocument *source)
GSList *ml = NULL;
SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS (source);
- for ( SPObject *child = SP_OBJECT(defs)->firstChild(); child; child = child->getNext() )
+ for ( SPObject *child = defs->firstChild(); child; child = child->getNext() )
{
if (SP_IS_MARKER(child)) {
ml = g_slist_prepend (ml, child);
@@ -248,14 +248,15 @@ sp_marker_menu_build (Gtk::Menu *m, GSList *marker_list, SPDocument *source, SPD
NRArenaItem *root = SP_ITEM(sandbox->getRoot())->invoke_show((NRArena *) arena, visionkey, SP_ITEM_SHOW_DISPLAY);
for (; marker_list != NULL; marker_list = marker_list->next) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) marker_list->data);
+ Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(marker_list->data)->getRepr();
Gtk::MenuItem *i = new Gtk::MenuItem();
i->show();
- if (repr->attribute("inkscape:stockid"))
+ if (repr->attribute("inkscape:stockid")) {
i->set_data("stockid", (void *) "true");
- else
+ } else {
i->set_data("stockid", (void *) "false");
+ }
gchar const *markid = repr->attribute("id");
i->set_data("marker", (void *) markid);
@@ -468,7 +469,7 @@ sp_marker_select(Gtk::OptionMenu *mnu, Gtk::Container *spw, SPMarkerLoc const wh
if (!strcmp(stockid,"true")) markurn = g_strconcat("urn:inkscape:marker:",markid,NULL);
SPObject *mark = get_stock_item(markurn);
if (mark) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(mark);
+ Inkscape::XML::Node *repr = mark->getRepr();
marker = g_strconcat("url(#", repr->attribute("id"), ")", NULL);
}
} else {
@@ -486,16 +487,17 @@ sp_marker_select(Gtk::OptionMenu *mnu, Gtk::Container *spw, SPMarkerLoc const wh
Inkscape::Selection *selection = sp_desktop_selection(desktop);
GSList const *items = selection->itemList();
for (; items != NULL; items = items->next) {
- SPItem *item = (SPItem *) items->data;
- if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) // can't set marker to rect, until it's converted to using <path>
- continue;
- Inkscape::XML::Node *selrepr = SP_OBJECT_REPR((SPItem *) items->data);
- if (selrepr) {
- sp_repr_css_change_recursive(selrepr, css, "style");
- }
- SP_OBJECT(items->data)->requestModified(SP_OBJECT_MODIFIED_FLAG);
- SP_OBJECT(items->data)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
- }
+ SPItem *item = reinterpret_cast<SPItem *>(items->data);
+ if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) { // can't set marker to rect, until it's converted to using <path>
+ continue;
+ }
+ Inkscape::XML::Node *selrepr = item->getRepr();
+ if (selrepr) {
+ sp_repr_css_change_recursive(selrepr, css, "style");
+ }
+ item->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
+ }
sp_repr_css_attr_unref(css);
css = 0;
@@ -690,7 +692,7 @@ sp_stroke_style_line_widget_new(void)
tt->set_tip(*sb, _("Stroke width"));
sb->show();
spw_label(t, C_("Stroke width", "_Width:"), 0, i, sb);
-
+
sp_dialog_defocus_on_enter_cpp(sb);
hb->pack_start(*sb, false, false, 0);
@@ -813,10 +815,10 @@ sp_stroke_style_line_widget_new(void)
/* Dash */
spw_label(t, _("Dashes:"), 0, i, NULL); //no mnemonic for now
- //decide what to do:
- // implement a set_mnemonic_source function in the
- // SPDashSelector class, so that we do not have to
- // expose any of the underlying widgets?
+ //decide what to do:
+ // implement a set_mnemonic_source function in the
+ // SPDashSelector class, so that we do not have to
+ // expose any of the underlying widgets?
ds = manage(new SPDashSelector);
ds->show();
@@ -1091,7 +1093,7 @@ sp_stroke_style_line_update(Gtk::Container *spw, Inkscape::Selection *sel)
GSList const *objects = sel->itemList();
SPObject * const object = SP_OBJECT(objects->data);
- SPStyle * const style = SP_OBJECT_STYLE(object);
+ SPStyle * const style = object->style;
/* Markers */
sp_stroke_style_update_marker_menus(spw, objects); // FIXME: make this desktop query too
@@ -1174,7 +1176,7 @@ sp_stroke_style_scale_line(Gtk::Container *spw)
if (unit->base == SP_UNIT_ABSOLUTE || unit->base == SP_UNIT_DEVICE) {
width = sp_units_get_pixels (width_typed, *unit);
} else { // percentage
- gdouble old_w = SP_OBJECT_STYLE (i->data)->stroke_width.computed;
+ gdouble old_w = SP_OBJECT(i->data)->style->stroke_width.computed;
width = old_w * width_typed / 100;
}
@@ -1362,14 +1364,16 @@ ink_marker_menu_set_current(SPObject *marker, Gtk::OptionMenu *mnu)
Gtk::Menu *m = mnu->get_menu();
if (marker != NULL) {
bool mark_is_stock = false;
- if (SP_OBJECT_REPR(marker)->attribute("inkscape:stockid"))
+ if (marker->getRepr()->attribute("inkscape:stockid")) {
mark_is_stock = true;
+ }
- gchar *markname;
- if (mark_is_stock)
- markname = g_strdup(SP_OBJECT_REPR(marker)->attribute("inkscape:stockid"));
- else
- markname = g_strdup(SP_OBJECT_REPR(marker)->attribute("id"));
+ gchar *markname = 0;
+ if (mark_is_stock) {
+ markname = g_strdup(marker->getRepr()->attribute("inkscape:stockid"));
+ } else {
+ markname = g_strdup(marker->getRepr()->attribute("id"));
+ }
int markpos = ink_marker_menu_get_pos(m, markname);
mnu->set_history(markpos);
@@ -1427,7 +1431,7 @@ sp_stroke_style_update_marker_menus(Gtk::Container *spw, GSList const *objects)
// If the object has this type of markers,
// Extract the name of the marker that the object uses
- SPObject *marker = ink_extract_marker_name(object->style->marker[keyloc[i].loc].value, SP_OBJECT_DOCUMENT(object));
+ SPObject *marker = ink_extract_marker_name(object->style->marker[keyloc[i].loc].value, object->document);
// Scroll the menu to that marker
ink_marker_menu_set_current(marker, mnu);
diff --git a/src/widgets/swatch-selector.cpp b/src/widgets/swatch-selector.cpp
index 935282a3a..cd624630b 100644
--- a/src/widgets/swatch-selector.cpp
+++ b/src/widgets/swatch-selector.cpp
@@ -133,9 +133,9 @@ void SwatchSelector::_changedCb(SPColorSelector */*csel*/, void *data)
gchar c[64];
sp_svg_write_color(c, sizeof(c), rgb);
os << "stop-color:" << c << ";stop-opacity:" << static_cast<gdouble>(alpha) <<";";
- SP_OBJECT_REPR(stop)->setAttribute("style", os.str().c_str());
+ stop->getRepr()->setAttribute("style", os.str().c_str());
- DocumentUndo::done(SP_OBJECT_DOCUMENT(ngr), SP_VERB_CONTEXT_GRADIENT,
+ DocumentUndo::done(ngr->document, SP_VERB_CONTEXT_GRADIENT,
_("Change swatch color"));
}
}
@@ -169,7 +169,7 @@ void SwatchSelector::connectchangedHandler( GCallback handler, void *data )
void SwatchSelector::setVector(SPDocument */*doc*/, SPGradient *vector)
{
//GtkVBox * box = gobj();
- _gsel->setVector((vector) ? SP_OBJECT_DOCUMENT(vector) : 0, vector);
+ _gsel->setVector((vector) ? vector->document : 0, vector);
if ( vector && vector->isSolid() ) {
SPStop* stop = vector->getFirstStop();
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index b488a0280..7ef864383 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -2041,14 +2041,14 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi
SPDesktop *dt = reinterpret_cast<SPDesktop*>(ptr);
SPNamedView *nv = sp_desktop_namedview(dt);
- SPDocument *doc = SP_OBJECT_DOCUMENT(nv);
+ SPDocument *doc = nv->document;
if (dt == NULL || nv == NULL) {
g_warning("No desktop or namedview specified (in toggle_snap_callback)!");
return;
}
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(nv);
+ Inkscape::XML::Node *repr = nv->getRepr();
if (repr == NULL) {
g_warning("This namedview doesn't have a xml representation attached!");
@@ -2520,13 +2520,14 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu
Inkscape::Selection *selection = sp_desktop_selection(desktop);
GSList const *items = selection->itemList();
for (; items != NULL; items = items->next) {
- if (SP_IS_STAR((SPItem *) items->data)) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data);
+ SPItem *item = reinterpret_cast<SPItem*>(items->data);
+ if (SP_IS_STAR(item)) {
+ Inkscape::XML::Node *repr = item->getRepr();
sp_repr_set_int(repr,"sodipodi:sides",(gint)adj->value);
sp_repr_set_svg_double(repr, "sodipodi:arg2",
(sp_repr_get_double_attribute(repr, "sodipodi:arg1", 0.5)
+ M_PI / (gint)adj->value));
- SP_OBJECT((SPItem *) items->data)->updateRepr();
+ item->updateRepr();
modmade = true;
}
}
@@ -2561,8 +2562,9 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl
Inkscape::Selection *selection = sp_desktop_selection(desktop);
GSList const *items = selection->itemList();
for (; items != NULL; items = items->next) {
- if (SP_IS_STAR((SPItem *) items->data)) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data);
+ SPItem *item = reinterpret_cast<SPItem *>(items->data);
+ if (SP_IS_STAR(item)) {
+ Inkscape::XML::Node *repr = item->getRepr();
gdouble r1 = sp_repr_get_double_attribute(repr, "sodipodi:r1", 1.0);
gdouble r2 = sp_repr_get_double_attribute(repr, "sodipodi:r2", 1.0);
@@ -2572,7 +2574,7 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl
sp_repr_set_svg_double(repr, "sodipodi:r1", r2*adj->value);
}
- SP_OBJECT((SPItem *) items->data)->updateRepr();
+ item->updateRepr();
modmade = true;
}
}
@@ -2613,10 +2615,11 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d
}
for (; items != NULL; items = items->next) {
- if (SP_IS_STAR((SPItem *) items->data)) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data);
+ SPItem *item = reinterpret_cast<SPItem *>(items->data);
+ if (SP_IS_STAR(item)) {
+ Inkscape::XML::Node *repr = item->getRepr();
repr->setAttribute("inkscape:flatsided", flat ? "true" : "false" );
- SP_OBJECT((SPItem *) items->data)->updateRepr();
+ item->updateRepr();
modmade = true;
}
}
@@ -2651,10 +2654,11 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg
Inkscape::Selection *selection = sp_desktop_selection(desktop);
GSList const *items = selection->itemList();
for (; items != NULL; items = items->next) {
- if (SP_IS_STAR((SPItem *) items->data)) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data);
+ SPItem *item = reinterpret_cast<SPItem*>(items->data);
+ if (SP_IS_STAR(item)) {
+ Inkscape::XML::Node *repr = item->getRepr();
sp_repr_set_svg_double(repr, "inkscape:rounded", (gdouble) adj->value);
- SP_OBJECT(items->data)->updateRepr();
+ item->updateRepr();
modmade = true;
}
}
@@ -2688,10 +2692,11 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl
Inkscape::Selection *selection = sp_desktop_selection(desktop);
GSList const *items = selection->itemList();
for (; items != NULL; items = items->next) {
- if (SP_IS_STAR((SPItem *) items->data)) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data);
+ SPItem *item = reinterpret_cast<SPItem *>(items->data);
+ if (SP_IS_STAR(item)) {
+ Inkscape::XML::Node *repr = item->getRepr();
sp_repr_set_svg_double(repr, "inkscape:randomized", (gdouble) adj->value);
- SP_OBJECT(items->data)->updateRepr();
+ item->updateRepr();
modmade = true;
}
}
@@ -2783,9 +2788,10 @@ sp_star_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl)
items != NULL;
items = items->next)
{
- if (SP_IS_STAR((SPItem *) items->data)) {
+ SPItem* item = reinterpret_cast<SPItem *>(items->data);
+ if (SP_IS_STAR(item)) {
n_selected++;
- repr = SP_OBJECT_REPR((SPItem *) items->data);
+ repr = item->getRepr();
}
}
@@ -3055,7 +3061,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *
if (adj->value != 0) {
setter(SP_RECT(items->data), sp_units_get_pixels(adj->value, *unit));
} else {
- SP_OBJECT_REPR(items->data)->setAttribute(value_name, NULL);
+ SP_OBJECT(items->data)->getRepr()->setAttribute(value_name, NULL);
}
modmade = true;
}
@@ -3184,10 +3190,10 @@ static void sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GO
for (GSList const *items = selection->itemList();
items != NULL;
items = items->next) {
- if (SP_IS_RECT((SPItem *) items->data)) {
+ if (SP_IS_RECT(reinterpret_cast<SPItem *>(items->data))) {
n_selected++;
- item = (SPItem *) items->data;
- repr = SP_OBJECT_REPR(item);
+ item = reinterpret_cast<SPItem *>(items->data);
+ repr = item->getRepr();
}
}
@@ -3474,7 +3480,7 @@ static void box3d_toolbox_selection_changed(Inkscape::Selection *selection, GObj
// FIXME: Also deal with multiple selected boxes
SPBox3D *box = SP_BOX3D(item);
Persp3D *persp = box3d_get_perspective(box);
- persp_repr = SP_OBJECT_REPR(persp);
+ persp_repr = persp->getRepr();
if (persp_repr) {
g_object_set_data(tbl, "repr", persp_repr);
Inkscape::GC::anchor(persp_repr);
@@ -3513,7 +3519,7 @@ static void box3d_angle_value_changed(GtkAdjustment *adj, GObject *dataKludge, P
Persp3D *persp = sel_persps.front();
persp->perspective_impl->tmat.set_infinite_direction (axis, adj->value);
- SP_OBJECT(persp)->updateRepr();
+ persp->updateRepr();
// TODO: use the correct axis here, too
DocumentUndo::maybeDone(document, "perspangle", SP_VERB_CONTEXT_3DBOX, _("3D Box: Change perspective (angle of infinite axis)"));
@@ -3731,10 +3737,11 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr
items != NULL;
items = items->next)
{
- if (SP_IS_SPIRAL((SPItem *) items->data)) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data);
+ SPItem *item = reinterpret_cast<SPItem*>(items->data);
+ if (SP_IS_SPIRAL(item)) {
+ Inkscape::XML::Node *repr = item->getRepr();
sp_repr_set_svg_double( repr, namespaced_name, adj->value );
- SP_OBJECT((SPItem *) items->data)->updateRepr();
+ item->updateRepr();
modmade = true;
}
}
@@ -3841,9 +3848,10 @@ static void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection,
items != NULL;
items = items->next)
{
- if (SP_IS_SPIRAL((SPItem *) items->data)) {
+ SPItem *item = reinterpret_cast<SPItem*>(items->data);
+ if (SP_IS_SPIRAL(item)) {
n_selected++;
- repr = SP_OBJECT_REPR((SPItem *) items->data);
+ repr = item->getRepr();
}
}
@@ -5395,10 +5403,11 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
items != NULL;
items = items->next)
{
- if (SP_IS_ARC((SPItem *) items->data)) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data);
+ SPItem *item = reinterpret_cast<SPItem*>(items->data);
+ if (SP_IS_ARC(item)) {
+ Inkscape::XML::Node *repr = item->getRepr();
repr->setAttribute("sodipodi:open", "true");
- SP_OBJECT((SPItem *) items->data)->updateRepr();
+ item->updateRepr();
modmade = true;
}
}
@@ -5407,10 +5416,11 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl )
items != NULL;
items = items->next)
{
- if (SP_IS_ARC((SPItem *) items->data)) {
- Inkscape::XML::Node *repr = SP_OBJECT_REPR((SPItem *) items->data);
+ SPItem *item = reinterpret_cast<SPItem *>(items->data);
+ if (SP_IS_ARC(item)) {
+ Inkscape::XML::Node *repr = item->getRepr();
repr->setAttribute("sodipodi:open", NULL);
- SP_OBJECT((SPItem *) items->data)->updateRepr();
+ item->updateRepr();
modmade = true;
}
}
@@ -5496,9 +5506,10 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb
items != NULL;
items = items->next)
{
- if (SP_IS_ARC((SPItem *) items->data)) {
+ SPItem *item = reinterpret_cast<SPItem *>(items->data);
+ if (SP_IS_ARC(item)) {
n_selected++;
- repr = SP_OBJECT_REPR((SPItem *) items->data);
+ repr = item->getRepr();
}
}
@@ -6688,7 +6699,7 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl )
if (SP_IS_TEXT((SPItem *) items->data)) {
SPItem *item = SP_ITEM(items->data);
- unsigned writing_mode = SP_OBJECT_STYLE(item)->writing_mode.value;
+ unsigned writing_mode = item->style->writing_mode.value;
// below, variable names suggest horizontal move, but we check the writing direction
// and move in the corresponding axis
int axis;
@@ -6708,7 +6719,7 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl )
// frame (currently unused)
double left_slack = 0;
double right_slack = 0;
- unsigned old_align = SP_OBJECT_STYLE(item)->text_align.value;
+ unsigned old_align = item->style->text_align.value;
double move = 0;
if (old_align == SP_CSS_TEXT_ALIGN_START || old_align == SP_CSS_TEXT_ALIGN_LEFT) {
switch (mode) {
@@ -6754,8 +6765,8 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl )
XY = XY + Geom::Point (0, move);
}
SP_TEXT(item)->attributes.setFirstXY(XY);
- SP_OBJECT(item)->updateRepr();
- SP_OBJECT(item)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ item->updateRepr();
+ item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
}
@@ -6843,7 +6854,7 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl )
bool modmade = false;
for (; items != NULL; items = items->next) {
if (SP_IS_TEXT (items->data)) {
- SP_OBJECT_REPR(items->data)->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL));
+ SP_OBJECT(items->data)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL));
modmade = true;
}
}
@@ -8013,7 +8024,7 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl)
return;
}
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview);
+ Inkscape::XML::Node *repr = desktop->namedview->getRepr();
if ( !repr->attribute("inkscape:connector-spacing") &&
( adj->value == defaultConnSpacing )) {
@@ -8032,7 +8043,7 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl)
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE));
sp_repr_set_css_double(repr, "inkscape:connector-spacing", adj->value);
- SP_OBJECT(desktop->namedview)->updateRepr();
+ desktop->namedview->updateRepr();
bool modmade = false;
GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop);
@@ -8314,7 +8325,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
// Code to watch for changes to the connector-spacing attribute in
// the XML.
- Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview);
+ Inkscape::XML::Node *repr = desktop->namedview->getRepr();
g_assert(repr != NULL);
purge_repr_listener( holder, holder );