diff options
| author | Shlomi Fish <shlomif@shlomifish.org> | 2019-05-23 08:06:12 +0000 |
|---|---|---|
| committer | Shlomi Fish <shlomif@shlomifish.org> | 2019-06-06 12:57:27 +0000 |
| commit | cb8c36249e983866378e7915e6605ef92d247923 (patch) | |
| tree | 53ec0a0745250375aaeb4b5a52f821380ccb614a /src/object | |
| parent | CI: Avoid failure due to sorting issue (diff) | |
| download | inkscape-cb8c36249e983866378e7915e6605ef92d247923.tar.gz inkscape-cb8c36249e983866378e7915e6605ef92d247923.zip | |
Refactoring: call setAttribute() directly.
Call this->setAttribute(...) directly instead of
this->getRepr()->setAttribute(...). This avoids clutter and mental indirection.
See
http://wiki.inkscape.org/wiki/index.php?title=Refactoring_projects&oldid=112116
and https://en.wikipedia.org/wiki/Law_of_Demeter .
---
I hereby disclaim any implicit or explicit ownership of my changes in this
changeset, and put them under a multiple licence consisting of your choice of
one of more of:
- The CC0 / Public Domain - https://creativecommons.org/choose/zero/ .
- The MIT / Expat license - https://en.wikipedia.org/wiki/MIT_License
- The default licence of your project
- The https://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License - version
2.1 or higher
- The https://en.wikipedia.org/wiki/GNU_General_Public_License - version 2 or
higher
- Any licence in the 2018-Aug-27 popular licenses list of
https://opensource.org/licenses
- The https://en.wikipedia.org/wiki/Apache_License version 2.0 or later
- The https://en.wikipedia.org/wiki/Artistic_License version 2.0 or later
- The https://en.wikipedia.org/wiki/ISC_license
- The https://opensource.org/licenses/BSD-2-Clause
Crediting me will be nice, but not mandatory, and you can change the licence
of the project without needing my permission.
Diffstat (limited to 'src/object')
| -rw-r--r-- | src/object/filters/blend.cpp | 2 | ||||
| -rw-r--r-- | src/object/filters/composite.cpp | 2 | ||||
| -rw-r--r-- | src/object/filters/displacementmap.cpp | 2 | ||||
| -rw-r--r-- | src/object/filters/sp-filter-primitive.cpp | 2 | ||||
| -rw-r--r-- | src/object/sp-conn-end.cpp | 2 | ||||
| -rw-r--r-- | src/object/sp-guide.cpp | 6 | ||||
| -rwxr-xr-x | src/object/sp-lpe-item.cpp | 18 | ||||
| -rw-r--r-- | src/object/sp-marker.cpp | 4 | ||||
| -rw-r--r-- | src/object/sp-object.cpp | 2 | ||||
| -rw-r--r-- | src/object/sp-offset.cpp | 14 | ||||
| -rw-r--r-- | src/object/sp-path.cpp | 2 | ||||
| -rw-r--r-- | src/object/sp-pattern.cpp | 2 | ||||
| -rw-r--r-- | src/object/sp-text.cpp | 2 | ||||
| -rw-r--r-- | src/object/sp-tspan.cpp | 4 |
14 files changed, 32 insertions, 32 deletions
diff --git a/src/object/filters/blend.cpp b/src/object/filters/blend.cpp index 9c0aa166c..eae652579 100644 --- a/src/object/filters/blend.cpp +++ b/src/object/filters/blend.cpp @@ -178,7 +178,7 @@ void SPFeBlend::update(SPCtx *ctx, guint flags) { this->in2 = this->name_previous_out(); // TODO: XML Tree being used directly here while it shouldn't be. - this->getRepr()->setAttribute("in2", parent->name_for_image(this->in2)); + this->setAttribute("in2", parent->name_for_image(this->in2)); } SPFilterPrimitive::update(ctx, flags); diff --git a/src/object/filters/composite.cpp b/src/object/filters/composite.cpp index 181aeb27e..6a01c4789 100644 --- a/src/object/filters/composite.cpp +++ b/src/object/filters/composite.cpp @@ -205,7 +205,7 @@ void SPFeComposite::update(SPCtx *ctx, guint flags) { this->in2 = this->name_previous_out(); //XML Tree being used directly here while it shouldn't be. - this->getRepr()->setAttribute("in2", parent->name_for_image(this->in2)); + this->setAttribute("in2", parent->name_for_image(this->in2)); } SPFilterPrimitive::update(ctx, flags); diff --git a/src/object/filters/displacementmap.cpp b/src/object/filters/displacementmap.cpp index 99556571e..80b9638f1 100644 --- a/src/object/filters/displacementmap.cpp +++ b/src/object/filters/displacementmap.cpp @@ -162,7 +162,7 @@ void SPFeDisplacementMap::update(SPCtx *ctx, guint flags) { this->in2 = this->name_previous_out(); //XML Tree being used directly here while it shouldn't be. - this->getRepr()->setAttribute("in2", parent->name_for_image(this->in2)); + this->setAttribute("in2", parent->name_for_image(this->in2)); } SPFilterPrimitive::update(ctx, flags); diff --git a/src/object/filters/sp-filter-primitive.cpp b/src/object/filters/sp-filter-primitive.cpp index 25d993b7c..8ed14ff3c 100644 --- a/src/object/filters/sp-filter-primitive.cpp +++ b/src/object/filters/sp-filter-primitive.cpp @@ -233,7 +233,7 @@ int SPFilterPrimitive::name_previous_out() { int slot = parent->set_image_name(name.c_str()); i_prim->image_out = slot; //XML Tree is being directly used while it shouldn't be. - i_prim->getRepr()->setAttribute("result", name.c_str()); + i_prim->setAttribute("result", name); return slot; } else { return i_prim->image_out; diff --git a/src/object/sp-conn-end.cpp b/src/object/sp-conn-end.cpp index dab25bfc0..d121be025 100644 --- a/src/object/sp-conn-end.cpp +++ b/src/object/sp-conn-end.cpp @@ -229,7 +229,7 @@ static void sp_conn_end_deleted(SPObject *, SPObject *const owner, unsigned cons { char const * const attrs[] = { "inkscape:connection-start", "inkscape:connection-end"}; - owner->getRepr()->setAttribute(attrs[handle_ix], nullptr); + owner->setAttribute(attrs[handle_ix], nullptr); /* I believe this will trigger sp_conn_end_href_changed. */ } diff --git a/src/object/sp-guide.cpp b/src/object/sp-guide.cpp index 4fe73ca4e..853511d42 100644 --- a/src/object/sp-guide.cpp +++ b/src/object/sp-guide.cpp @@ -471,7 +471,7 @@ void SPGuide::set_color(const unsigned r, const unsigned g, const unsigned b, bo std::ostringstream os; os << "rgb(" << r << "," << g << "," << b << ")"; //XML Tree being used directly while it shouldn't be - getRepr()->setAttribute("inkscape:color", os.str().c_str()); + setAttribute("inkscape:color", os.str()); } } @@ -483,7 +483,7 @@ void SPGuide::set_locked(const bool locked, bool const commit) } if (commit) { - getRepr()->setAttribute("inkscape:locked", g_strdup(locked ? "true" : "false")); + setAttribute("inkscape:locked", locked ? "true" : "false"); } } @@ -495,7 +495,7 @@ void SPGuide::set_label(const char* label, bool const commit) if (commit) { //XML Tree being used directly while it shouldn't be - getRepr()->setAttribute("inkscape:label", label); + setAttribute("inkscape:label", label); } } diff --git a/src/object/sp-lpe-item.cpp b/src/object/sp-lpe-item.cpp index ec7b6469e..47ace710b 100755 --- a/src/object/sp-lpe-item.cpp +++ b/src/object/sp-lpe-item.cpp @@ -548,7 +548,7 @@ void SPLPEItem::addPathEffect(std::string value, bool reset) } hreflist.push_back(value); // C++11: should be emplace_back std::move'd (also the reason why passed by value to addPathEffect) - this->getRepr()->setAttribute("inkscape:path-effect", hreflist_svg_string(hreflist)); + this->setAttribute("inkscape:path-effect", hreflist_svg_string(hreflist)); // Make sure that ellipse is stored as <svg:path> if( SP_IS_GENERICELLIPSE(this)) { SP_GENERICELLIPSE(this)->write( this->getRepr()->document(), this->getRepr(), SP_OBJECT_WRITE_EXT ); @@ -603,7 +603,7 @@ void SPLPEItem::removeCurrentPathEffect(bool keep_paths) effect_->keep_paths = keep_paths; effect_->doOnRemove(this); this->path_effect_list->remove(lperef); //current lpe ref is always our 'own' pointer from the path_effect_list - this->getRepr()->setAttribute("inkscape:path-effect", patheffectlist_svg_string(*this->path_effect_list)); + this->setAttribute("inkscape:path-effect", patheffectlist_svg_string(*this->path_effect_list)); if (!keep_paths) { // Make sure that ellipse is stored as <svg:circle> or <svg:ellipse> if possible. if( SP_IS_GENERICELLIPSE(this)) { @@ -640,7 +640,7 @@ void SPLPEItem::removeAllPathEffects(bool keep_paths) } } this->path_effect_list->clear(); - this->getRepr()->setAttribute("inkscape:path-effect", nullptr); + this->setAttribute("inkscape:path-effect", nullptr); if (!keep_paths) { // Make sure that ellipse is stored as <svg:circle> or <svg:ellipse> if possible. if (SP_IS_GENERICELLIPSE(this)) { @@ -667,7 +667,7 @@ void SPLPEItem::downCurrentPathEffect() } } - this->getRepr()->setAttribute("inkscape:path-effect", patheffectlist_svg_string(new_list)); + this->setAttribute("inkscape:path-effect", patheffectlist_svg_string(new_list)); sp_lpe_item_cleanup_original_path_recursive(this, false); } @@ -686,7 +686,7 @@ void SPLPEItem::upCurrentPathEffect() std::iter_swap(cur_it, up_it); } - this->getRepr()->setAttribute("inkscape:path-effect", patheffectlist_svg_string(new_list)); + this->setAttribute("inkscape:path-effect", patheffectlist_svg_string(new_list)); sp_lpe_item_cleanup_original_path_recursive(this, false); } @@ -820,7 +820,7 @@ SPLPEItem::resetClipPathAndMaskLPE(bool fromrecurse) } else if (shape) { shape->setCurveInsync( shape->getCurveForEdit()); if (!hasPathEffectOnClipOrMaskRecursive(shape)) { - shape->getRepr()->setAttribute("inkscape:original-d", nullptr); + shape->setAttribute("inkscape:original-d", nullptr); shape->setCurveBeforeLPE(nullptr); } else { // make sure there is an original-d for paths!!! @@ -846,7 +846,7 @@ SPLPEItem::resetClipPathAndMaskLPE(bool fromrecurse) } else if (shape) { shape->setCurveInsync( shape->getCurveForEdit()); if (!hasPathEffectOnClipOrMaskRecursive(shape)) { - shape->getRepr()->setAttribute("inkscape:original-d", nullptr); + shape->setAttribute("inkscape:original-d", nullptr); shape->setCurveBeforeLPE(nullptr); } else { // make sure there is an original-d for paths!!! @@ -872,7 +872,7 @@ SPLPEItem::resetClipPathAndMaskLPE(bool fromrecurse) } else if (shape) { shape->setCurveInsync( shape->getCurveForEdit()); if (!hasPathEffectOnClipOrMaskRecursive(shape)) { - shape->getRepr()->setAttribute("inkscape:original-d", nullptr); + shape->setAttribute("inkscape:original-d", nullptr); shape->setCurveBeforeLPE(nullptr); } else { // make sure there is an original-d for paths!!! @@ -1143,7 +1143,7 @@ void SPLPEItem::replacePathEffects( std::vector<LivePathEffectObject const *> co } } - this->getRepr()->setAttribute("inkscape:path-effect", hreflist_svg_string(hreflist)); + this->setAttribute("inkscape:path-effect", hreflist_svg_string(hreflist)); } /** diff --git a/src/object/sp-marker.cpp b/src/object/sp-marker.cpp index 22d06a247..8084dd5f8 100644 --- a/src/object/sp-marker.cpp +++ b/src/object/sp-marker.cpp @@ -482,13 +482,13 @@ SPObject *sp_marker_fork_if_necessary(SPObject *marker) SPDocument *doc = marker->document; Inkscape::XML::Document *xml_doc = doc->getReprDoc(); // Turn off garbage-collectable or it might be collected before we can use it - marker->getRepr()->setAttribute("inkscape:collect", nullptr); + marker->setAttribute("inkscape:collect", nullptr); Inkscape::XML::Node *mark_repr = marker->getRepr()->duplicate(xml_doc); doc->getDefs()->getRepr()->addChild(mark_repr, nullptr); if (!mark_repr->attribute("inkscape:stockid")) { mark_repr->setAttribute("inkscape:stockid", mark_repr->attribute("id")); } - marker->getRepr()->setAttribute("inkscape:collect", "always"); + marker->setAttribute("inkscape:collect", "always"); SPObject *marker_new = static_cast<SPObject *>(doc->getObjectByRepr(mark_repr)); Inkscape::GC::release(mark_repr); diff --git a/src/object/sp-object.cpp b/src/object/sp-object.cpp index 714518f08..5936963c7 100644 --- a/src/object/sp-object.cpp +++ b/src/object/sp-object.cpp @@ -906,7 +906,7 @@ void SPObject::set(SPAttributeEnum key, gchar const* value) { sp_object_ref(conflict, nullptr); // give the conflicting object a new ID gchar *new_conflict_id = sp_object_get_unique_id(conflict, nullptr); - conflict->getRepr()->setAttribute("id", new_conflict_id); + conflict->setAttribute("id", new_conflict_id); g_free(new_conflict_id); sp_object_unref(conflict, nullptr); } else { diff --git a/src/object/sp-offset.cpp b/src/object/sp-offset.cpp index 13de079e0..b5965813e 100644 --- a/src/object/sp-offset.cpp +++ b/src/object/sp-offset.cpp @@ -118,8 +118,8 @@ void SPOffset::build(SPDocument *document, Inkscape::XML::Node *repr) { //XML Tree being used directly here (as object->getRepr) //in all the below lines in the block while it shouldn't be. gchar const *oldA = this->getRepr()->attribute("sodipodi:radius"); - this->getRepr()->setAttribute("inkscape:radius",oldA); - this->getRepr()->setAttribute("sodipodi:radius",nullptr); + this->setAttribute("inkscape:radius",oldA); + this->setAttribute("sodipodi:radius",nullptr); this->readAttr( "inkscape:radius" ); } @@ -128,8 +128,8 @@ void SPOffset::build(SPDocument *document, Inkscape::XML::Node *repr) { this->readAttr( "inkscape:original" ); } else { gchar const *oldA = this->getRepr()->attribute("sodipodi:original"); - this->getRepr()->setAttribute("inkscape:original",oldA); - this->getRepr()->setAttribute("sodipodi:original",nullptr); + this->setAttribute("inkscape:original",oldA); + this->setAttribute("sodipodi:original",nullptr); this->readAttr( "inkscape:original" ); } @@ -148,11 +148,11 @@ void SPOffset::build(SPDocument *document, Inkscape::XML::Node *repr) { nA[0]='#'; nA[lA+1]=0; - this->getRepr()->setAttribute("xlink:href",nA); + this->setAttribute("xlink:href",nA); free(nA); - this->getRepr()->setAttribute("inkscape:href",nullptr); + this->setAttribute("inkscape:href",nullptr); } this->readAttr( "xlink:href" ); @@ -1188,7 +1188,7 @@ refresh_offset_source(SPOffset* offset) // TODO fix: //XML Tree being used directly here while it shouldn't be. - offset->getRepr()->setAttribute("inkscape:original", res_d); + offset->setAttribute("inkscape:original", res_d); free (res_d); } diff --git a/src/object/sp-path.cpp b/src/object/sp-path.cpp index 379b1bfdf..9d7ef1fe0 100644 --- a/src/object/sp-path.cpp +++ b/src/object/sp-path.cpp @@ -158,7 +158,7 @@ void SPPath::build(SPDocument *document, Inkscape::XML::Node *repr) { curve->unref(); // Convert from property to attribute (convert back on write) - getRepr()->setAttribute("d", value); + setAttribute("d", value); SPCSSAttr *css = sp_repr_css_attr( getRepr(), "style"); sp_repr_css_unset_property ( css, "d"); diff --git a/src/object/sp-pattern.cpp b/src/object/sp-pattern.cpp index a7035e98e..c20752bc2 100644 --- a/src/object/sp-pattern.cpp +++ b/src/object/sp-pattern.cpp @@ -372,7 +372,7 @@ void SPPattern::transform_multiply(Geom::Affine postmul, bool set) _pattern_transform_set = true; gchar *c = sp_svg_transform_write(_pattern_transform); - getRepr()->setAttribute("patternTransform", c); + setAttribute("patternTransform", c); g_free(c); } diff --git a/src/object/sp-text.cpp b/src/object/sp-text.cpp index 49052d92c..da9c2cca9 100644 --- a/src/object/sp-text.cpp +++ b/src/object/sp-text.cpp @@ -102,7 +102,7 @@ void SPText::set(SPAttributeEnum key, const gchar* value) { this->style->line_height.value = this->style->line_height.computed = sp_svg_read_percentage (value, 1.0); } // Remove deprecated attribute - this->getRepr()->setAttribute("sodipodi:linespacing", nullptr); + this->setAttribute("sodipodi:linespacing", nullptr); this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); break; diff --git a/src/object/sp-tspan.cpp b/src/object/sp-tspan.cpp index 7a0db5687..30abb9bb4 100644 --- a/src/object/sp-tspan.cpp +++ b/src/object/sp-tspan.cpp @@ -405,14 +405,14 @@ Inkscape::XML::Node* SPTextPath::write(Inkscape::XML::Document *xml_doc, Inkscap this->attributes.writeTo(repr); if (this->side == SP_TEXT_PATH_SIDE_RIGHT) { - this->getRepr()->setAttribute("side", "right"); + this->setAttribute("side", "right"); } if (this->startOffset._set) { if (this->startOffset.unit == SVGLength::PERCENT) { Inkscape::SVGOStringStream os; os << (this->startOffset.computed * 100.0) << "%"; - this->getRepr()->setAttribute("startOffset", os.str().c_str()); + this->setAttribute("startOffset", os.str()); } else { /* FIXME: This logic looks rather undesirable if e.g. startOffset is to be in ems. */ |
