summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Holder <thomas@thomas-holder.de>2019-10-27 08:04:25 +0000
committerThomas Holder <thomas@thomas-holder.de>2019-10-28 11:31:30 +0000
commitc22238fdce5ff0ec04b22b5714cc9e383276a118 (patch)
tree9f3b8df323857095fed0d24bb0f2ad6a4b3c26bd
parentrefactor: Eliminate SPIEnum::enums (diff)
downloadinkscape-c22238fdce5ff0ec04b22b5714cc9e383276a118.tar.gz
inkscape-c22238fdce5ff0ec04b22b5714cc9e383276a118.zip
refactor: private SPIBase::_name
-rw-r--r--src/live_effects/lpe-copy_rotate.cpp6
-rw-r--r--src/live_effects/lpe-mirror_symmetry.cpp6
-rw-r--r--src/style-internal.cpp30
-rw-r--r--src/style-internal.h12
-rw-r--r--src/style.cpp2
-rw-r--r--src/ui/clipboard.cpp3
-rw-r--r--src/ui/dialog/styledialog.cpp24
7 files changed, 43 insertions, 40 deletions
diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp
index 7a21c2a2c..2a27eac0c 100644
--- a/src/live_effects/lpe-copy_rotate.cpp
+++ b/src/live_effects/lpe-copy_rotate.cpp
@@ -191,10 +191,10 @@ void LPECopyRotate::cloneStyle(SPObject *orig, SPObject *dest)
dest->getRepr()->setAttribute("style", orig->getRepr()->attribute("style"));
for (auto iter : orig->style->properties()) {
if (iter->style_src != SP_STYLE_SRC_UNSET) {
- if (iter->name != "font" && iter->name != "d" && iter->name != "marker") {
- const gchar *attr = orig->getRepr()->attribute(iter->name.c_str());
+ if (iter->name() != "font" && iter->name() != "d" && iter->name() != "marker") {
+ const gchar *attr = orig->getRepr()->attribute(iter->name().c_str());
if (attr) {
- dest->getRepr()->setAttribute(iter->name.c_str(), attr);
+ dest->getRepr()->setAttribute(iter->name(), attr);
}
}
}
diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp
index 9dec35c16..0cc749f2b 100644
--- a/src/live_effects/lpe-mirror_symmetry.cpp
+++ b/src/live_effects/lpe-mirror_symmetry.cpp
@@ -266,10 +266,10 @@ void LPEMirrorSymmetry::cloneStyle(SPObject *orig, SPObject *dest)
dest->getRepr()->setAttribute("style", orig->getRepr()->attribute("style"));
for (auto iter : orig->style->properties()) {
if (iter->style_src != SP_STYLE_SRC_UNSET) {
- if (iter->name != "font" && iter->name != "d" && iter->name != "marker") {
- const gchar *attr = orig->getRepr()->attribute(iter->name.c_str());
+ if (iter->name() != "font" && iter->name() != "d" && iter->name() != "marker") {
+ const gchar *attr = orig->getRepr()->attribute(iter->name().c_str());
if (attr) {
- dest->getRepr()->setAttribute(iter->name.c_str(), attr);
+ dest->getRepr()->setAttribute(iter->name(), attr);
}
}
}
diff --git a/src/style-internal.cpp b/src/style-internal.cpp
index 04ae53f0f..a4569bf84 100644
--- a/src/style-internal.cpp
+++ b/src/style-internal.cpp
@@ -76,7 +76,7 @@ const Glib::ustring SPIBase::write(guint const flags, SPStyleSrc const &style_sr
if (should_write(flags, set, dfp, src)) {
auto value = this->get_value();
if ( !value.empty() ) {
- return (name + ":" + value + important_str() + ";");
+ return (name() + ":" + value + important_str() + ";");
}
}
return Glib::ustring("");
@@ -191,8 +191,8 @@ SPIScale24::merge( const SPIBase* const parent ) {
}
} else {
// Needed only for 'opacity' and 'stop-opacity' which do not inherit. See comment at bottom of file.
- if( name != "opacity" && name != "stop-opacity" )
- std::cerr << "SPIScale24::merge: unhandled property: " << name << std::endl;
+ if( name() != "opacity" && name() != "stop-opacity" )
+ std::cerr << "SPIScale24::merge: unhandled property: " << name() << std::endl;
if( !set || (!inherit && value == SP_SCALE24_MAX) ) {
value = p->value;
set = (value != SP_SCALE24_MAX);
@@ -286,7 +286,7 @@ SPILength::read( gchar const *str ) {
/* Percentage */
unit = SP_CSS_UNIT_PERCENT;
value = value * 0.01;
- if (name.compare( "line-height" ) == 0) {
+ if (name() == "line-height") {
// See: http://www.w3.org/TR/CSS2/visudet.html#propdef-line-height
if( style ) {
computed = value * style->font_size.computed;
@@ -354,7 +354,7 @@ SPILength::cascade( const SPIBase* const parent ) {
} else if (unit == SP_CSS_UNIT_EX) {
// FIXME: Get x height from libnrtype or pango.
computed = value * em * 0.5;
- } else if (unit == SP_CSS_UNIT_PERCENT && name.compare( "line-height" ) == 0 ) {
+ } else if (unit == SP_CSS_UNIT_PERCENT && name() == "line-height") {
// Special case
computed = value * em;
}
@@ -413,7 +413,7 @@ const Glib::ustring SPILength::toString(bool wname) const
{
CSSOStringStream os;
if (wname) {
- os << name << ":";
+ os << name() << ":";
}
os << this->get_value();
if (wname) {
@@ -1086,13 +1086,13 @@ SPIString::read( gchar const *str ) {
inherit = false;
Glib::ustring str_temp(str);
- if( name.compare( "d" ) == 0 && style_src == SP_STYLE_SRC_ATTRIBUTE) {
+ if (name() == "d" && style_src == SP_STYLE_SRC_ATTRIBUTE) {
set = false;
}
- if( name.compare( "font-family" ) == 0 ) {
+ if (name() == "font-family") {
// Family names may be quoted in CSS, internally we use unquoted names.
css_font_family_unquote( str_temp );
- } else if( name.compare( "-inkscape-font-specification" ) == 0 ) {
+ } else if (name() == "-inkscape-font-specification") {
css_unquote( str_temp );
}
@@ -1105,11 +1105,11 @@ const Glib::ustring SPIString::get_value() const
{
if (this->inherit) return Glib::ustring("inherit");
if (!this->value) return Glib::ustring("");
- if( name.compare( "font-family" ) == 0 ) {
+ if (name() == "font-family") {
Glib::ustring font_family( this->value );
css_font_family_quote( font_family );
return font_family;
- } else if( name.compare( "-inkscape-font-specification" ) == 0 ) {
+ } else if (name() == "-inkscape-font-specification") {
Glib::ustring font_spec( this->value );
css_quote( font_spec );
return font_spec;
@@ -1242,7 +1242,7 @@ void SPIColor::read( gchar const *str ) {
} else if ( !strcmp(str, "currentColor") ) {
set = true;
currentcolor = true;
- if( name.compare( "color") == 0 ) {
+ if (name() == "color") {
inherit = true; // CSS3
} else {
setColor( style->color.value.color );
@@ -1519,11 +1519,11 @@ SPIPaint::reset( bool init ) {
}
}
if( init ) {
- if( name.compare( "fill" ) == 0 ) {
+ if (name() == "fill") {
// 'black' is default for 'fill'
setColor(0.0, 0.0, 0.0);
}
- if( name.compare( "text-decoration-color" ) == 0 ) {
+ if (name() == "text-decoration-color") {
// currentcolor = true;
}
}
@@ -2867,7 +2867,7 @@ SPITextDecoration::write( guint const flags, SPStyleSrc const &style_src_req, SP
&& (!my_base->style->text_decoration_line.set ||
style->text_decoration_line != my_base->style->text_decoration_line )))
{
- return (name + ":" + this->get_value() + important_str() + ";");
+ return (name() + ":" + this->get_value() + important_str() + ";");
}
return Glib::ustring("");
}
diff --git a/src/style-internal.h b/src/style-internal.h
index a105da519..2b6e2802b 100644
--- a/src/style-internal.h
+++ b/src/style-internal.h
@@ -126,7 +126,7 @@ class SPIBase
public:
SPIBase( Glib::ustring name="anonymous", bool inherits = true )
- : name(std::move(name)),
+ : _name(std::move(name)),
inherits(inherits),
set(false),
inherit(false),
@@ -177,7 +177,7 @@ public:
}
virtual void readAttribute( Inkscape::XML::Node *repr ) {
- readIfUnset( repr->attribute( name.c_str() ), SP_STYLE_SRC_ATTRIBUTE );
+ readIfUnset(repr->attribute(name().c_str()), SP_STYLE_SRC_ATTRIBUTE);
}
virtual const Glib::ustring get_value() const = 0;
@@ -200,16 +200,20 @@ public:
// Check apples being compared to apples
virtual bool operator==(const SPIBase& rhs) {
- return (name == rhs.name);
+ return (_name == rhs._name);
}
virtual bool operator!=(const SPIBase& rhs) {
return !(*this == rhs);
}
+ Glib::ustring const &name() const { return _name; }
+
+private:
+ Glib::ustring _name;
+
// To do: make private
public:
- Glib::ustring name; // Make const
bool inherits : 1; // Property inherits by default from parent.
bool set : 1; // Property has been explicitly set (vs. inherited).
bool inherit : 1; // Property value set to 'inherit'.
diff --git a/src/style.cpp b/src/style.cpp
index b75cc898e..a67732ffd 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -597,7 +597,7 @@ SPStyle::read( SPObject *object, Inkscape::XML::Node *repr ) {
// font-variant are converted to shorthands in CSS 3 but can still be read as a
// non-shorthand for compatibility with older renders, so they should not be in this list.
// We could add a flag to SPIBase to avoid string comparison.
- if( p->name != "font" && p->name != "marker") {
+ if (p->name() != "font" && p->name() != "marker") {
p->readAttribute( repr );
}
}
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 5d6df02d7..9968e8d7f 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -754,8 +754,7 @@ void ClipboardManagerImpl::_copySelection(ObjectSet *selection)
SPCSSAttr *css = sp_repr_css_attr_inherited(obj, "style");
for (auto iter : item->style->properties()) {
if (iter->style_src == SP_STYLE_SRC_STYLE_SHEET) {
- Glib::ustring val = iter->get_value();
- css->setAttribute(iter->name, val.c_str());
+ css->setAttribute(iter->name(), iter->get_value());
}
}
sp_repr_css_set(obj_copy, css, "style");
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp
index 8b4a252b4..99ada4381 100644
--- a/src/ui/dialog/styledialog.cpp
+++ b/src/ui/dialog/styledialog.cpp
@@ -563,13 +563,13 @@ void StyleDialog::readStyleElement()
Glib::ustring style = obj->getRepr()->attribute("style");
attr_prop = parseStyle(style);
for (auto iter : obj->style->properties()) {
- if (attr_prop.count(iter->name)) {
+ if (attr_prop.count(iter->name())) {
empty = false;
Gtk::TreeModel::Row row = *(store->prepend());
row[_mColumns._colSelector] = "style_properties";
row[_mColumns._colSelectorPos] = 0;
row[_mColumns._colActive] = true;
- row[_mColumns._colName] = iter->name;
+ row[_mColumns._colName] = iter->name();
row[_mColumns._colValue] = iter->get_value();
row[_mColumns._colStrike] = false;
row[_mColumns._colOwner] = Glib::ustring("Current value");
@@ -584,7 +584,7 @@ void StyleDialog::readStyleElement()
row[_mColumns._colLinked] = true;
}
}
- _addOwnerStyle(iter->name, "style attribute");
+ _addOwnerStyle(iter->name(), "style attribute");
}
}
// this is to fix a bug on cairo win:
@@ -766,7 +766,7 @@ void StyleDialog::readStyleElement()
if (iter.second.second) {
Glib::ustring val = "";
for (auto iterprop : obj->style->properties()) {
- if (iterprop->style_src != SP_STYLE_SRC_UNSET && iterprop->name == iter.first) {
+ if (iterprop->style_src != SP_STYLE_SRC_UNSET && iterprop->name() == iter.first) {
val = iterprop->get_value();
break;
}
@@ -831,8 +831,8 @@ void StyleDialog::readStyleElement()
if (obj) {
for (auto iter : obj->style->properties()) {
if (iter->style_src != SP_STYLE_SRC_UNSET) {
- if (iter->name != "font" && iter->name != "d" && iter->name != "marker") {
- const gchar *attr = obj->getRepr()->attribute(iter->name.c_str());
+ if (iter->name() != "font" && iter->name() != "d" && iter->name() != "marker") {
+ const gchar *attr = obj->getRepr()->attribute(iter->name().c_str());
if (attr) {
if (!hasattributes) {
Inkscape::UI::Widget::IconRenderer *addRenderer =
@@ -878,16 +878,16 @@ void StyleDialog::readStyleElement()
row[_mColumns._colSelector] = "attributes";
row[_mColumns._colSelectorPos] = selectorpos;
row[_mColumns._colActive] = true;
- row[_mColumns._colName] = iter->name;
+ row[_mColumns._colName] = iter->name();
row[_mColumns._colValue] = attr;
- if (_owner_style.find(iter->name) != _owner_style.end()) {
+ if (_owner_style.find(iter->name()) != _owner_style.end()) {
row[_mColumns._colStrike] = true;
Glib::ustring tooltiptext = Glib::ustring("");
row[_mColumns._colOwner] = tooltiptext;
} else {
row[_mColumns._colStrike] = false;
row[_mColumns._colOwner] = Glib::ustring("Current value");
- _addOwnerStyle(iter->name, "inline attributes");
+ _addOwnerStyle(iter->name(), "inline attributes");
}
hasattributes = true;
}
@@ -1114,11 +1114,11 @@ void StyleDialog::_writeStyleElement(Glib::RefPtr<Gtk::TreeStore> store, Glib::u
_updating = false;
} else if (selector == "attributes") {
for (auto iter : obj->style->properties()) {
- if (iter->name != "font" && iter->name != "d" && iter->name != "marker") {
- const gchar *attr = obj->getRepr()->attribute(iter->name.c_str());
+ if (iter->name() != "font" && iter->name() != "d" && iter->name() != "marker") {
+ const gchar *attr = obj->getRepr()->attribute(iter->name().c_str());
if (attr) {
_updating = true;
- obj->getRepr()->setAttribute(iter->name.c_str(), nullptr);
+ obj->getRepr()->setAttribute(iter->name(), nullptr);
_updating = false;
}
}