diff options
| author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-06-15 10:46:15 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marcjeanmougin@free.fr> | 2018-06-18 12:27:01 +0000 |
| commit | f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43 (patch) | |
| tree | 7c6044fd3a17a2665841959dac9b3b2110b27924 /src/extension/param | |
| parent | Run clang-tidy’s modernize-use-override pass. (diff) | |
| download | inkscape-f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43.tar.gz inkscape-f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43.zip | |
Run clang-tidy’s modernize-use-nullptr pass.
This replaces all NULL or 0 with nullptr when assigned to or returned as
a pointer.
Diffstat (limited to 'src/extension/param')
| -rw-r--r-- | src/extension/param/bool.cpp | 14 | ||||
| -rw-r--r-- | src/extension/param/color.cpp | 8 | ||||
| -rw-r--r-- | src/extension/param/description.cpp | 16 | ||||
| -rw-r--r-- | src/extension/param/enum.cpp | 28 | ||||
| -rw-r--r-- | src/extension/param/float.cpp | 26 | ||||
| -rw-r--r-- | src/extension/param/int.cpp | 18 | ||||
| -rw-r--r-- | src/extension/param/notebook.cpp | 42 | ||||
| -rw-r--r-- | src/extension/param/parameter.cpp | 76 | ||||
| -rw-r--r-- | src/extension/param/radiobutton.cpp | 38 | ||||
| -rw-r--r-- | src/extension/param/string.cpp | 28 |
10 files changed, 147 insertions, 147 deletions
diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp index 80bc89138..eea660f69 100644 --- a/src/extension/param/bool.cpp +++ b/src/extension/param/bool.cpp @@ -33,12 +33,12 @@ ParamBool::ParamBool(const gchar * name, : Parameter(name, text, description, hidden, indent, ext) , _value(false) { - const char * defaultval = NULL; - if (xml->firstChild() != NULL) { + const char * defaultval = nullptr; + if (xml->firstChild() != nullptr) { defaultval = xml->firstChild()->content(); } - if (defaultval != NULL && (!strcmp(defaultval, "true") || !strcmp(defaultval, "1"))) { + if (defaultval != nullptr && (!strcmp(defaultval, "true") || !strcmp(defaultval, "1"))) { _value = true; } else { _value = false; @@ -85,7 +85,7 @@ public: */ ParamBoolCheckButton (ParamBool * param, gchar * label, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : Gtk::CheckButton(label), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { - this->set_active(_pref->get(NULL, NULL) /**\todo fix */); + this->set_active(_pref->get(nullptr, nullptr) /**\todo fix */); this->signal_toggled().connect(sigc::mem_fun(this, &ParamBoolCheckButton::on_toggle)); return; } @@ -106,8 +106,8 @@ private: void ParamBoolCheckButton::on_toggle(void) { - _pref->set(this->get_active(), NULL /**\todo fix this */, NULL); - if (_changeSignal != NULL) { + _pref->set(this->get_active(), nullptr /**\todo fix this */, nullptr); + if (_changeSignal != nullptr) { _changeSignal->emit(); } return; @@ -127,7 +127,7 @@ void ParamBool::string(std::string &string) const Gtk::Widget *ParamBool::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { if (_hidden) { - return NULL; + return nullptr; } auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, Parameter::GUI_PARAM_WIDGETS_SPACING)); diff --git a/src/extension/param/color.cpp b/src/extension/param/color.cpp index 035c43ba8..1e3b1dc4c 100644 --- a/src/extension/param/color.cpp +++ b/src/extension/param/color.cpp @@ -60,10 +60,10 @@ ParamColor::ParamColor(const gchar * name, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : Parameter(name, text, description, hidden, indent, ext) - , _changeSignal(0) + , _changeSignal(nullptr) { - const char * defaulthex = NULL; - if (xml->firstChild() != NULL) + const char * defaulthex = nullptr; + if (xml->firstChild() != nullptr) defaulthex = xml->firstChild()->content(); gchar * pref_name = this->pref_name(); @@ -92,7 +92,7 @@ Gtk::Widget *ParamColor::get_widget( SPDocument * /*doc*/, Inkscape::XML::Node * { using Inkscape::UI::Widget::ColorNotebook; - if (_hidden) return NULL; + if (_hidden) return nullptr; if (changeSignal) { _changeSignal = new sigc::signal<void>(*changeSignal); diff --git a/src/extension/param/description.cpp b/src/extension/param/description.cpp index cf94918f7..d795514c3 100644 --- a/src/extension/param/description.cpp +++ b/src/extension/param/description.cpp @@ -37,15 +37,15 @@ ParamDescription::ParamDescription(const gchar * name, Inkscape::XML::Node * xml, AppearanceMode mode) : Parameter(name, text, description, hidden, indent, ext) - , _value(NULL) + , _value(nullptr) , _mode(mode) { // construct the text content by concatenating all (non-empty) text nodes, // removing all other nodes (e.g. comment nodes) and replacing <extension:br> elements with "<br/>" Glib::ustring value; Inkscape::XML::Node * cur_child = xml->firstChild(); - while (cur_child != NULL) { - if (cur_child->type() == XML::TEXT_NODE && cur_child->content() != NULL) { + while (cur_child != nullptr) { + if (cur_child->type() == XML::TEXT_NODE && cur_child->content() != nullptr) { value += cur_child->content(); } else if (cur_child->type() == XML::ELEMENT_NODE && !g_strcmp0(cur_child->name(), "extension:br")) { value += "<br/>"; @@ -71,8 +71,8 @@ ParamDescription::ParamDescription(const gchar * name, // translate if underscored version (_param) was used if (g_str_has_prefix(xml->name(), "extension:_")) { const gchar * context = xml->attribute("msgctxt"); - if (context != NULL) { - value = g_dpgettext2(NULL, context, value.c_str()); + if (context != nullptr) { + value = g_dpgettext2(nullptr, context, value.c_str()); } else { value = _(value.c_str()); } @@ -91,10 +91,10 @@ Gtk::Widget * ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/) { if (_hidden) { - return NULL; + return nullptr; } - if (_value == NULL) { - return NULL; + if (_value == nullptr) { + return nullptr; } Glib::ustring newtext = _value; diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index ddcbb358b..c5ee5f6b9 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -39,27 +39,27 @@ ParamComboBox::ParamComboBox(const gchar * name, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : Parameter(name, text, description, hidden, indent, ext) - , _value(NULL) + , _value(nullptr) { - const char *xmlval = NULL; // the value stored in XML + const char *xmlval = nullptr; // the value stored in XML - if (xml != NULL) { + if (xml != nullptr) { // Read XML tree to add enumeration items: for (Inkscape::XML::Node *node = xml->firstChild(); node; node = node->next()) { char const * chname = node->name(); if (!strcmp(chname, INKSCAPE_EXTENSION_NS "item") || !strcmp(chname, INKSCAPE_EXTENSION_NS "_item")) { Glib::ustring newtext, newvalue; - const char * contents = NULL; + const char * contents = nullptr; if (node->firstChild()) { contents = node->firstChild()->content(); } - if (contents != NULL) { + if (contents != nullptr) { // don't translate when 'item' but do translate when '_item' // NOTE: internal extensions use build_from_mem and don't need _item but // still need to include if are to be localized if (!strcmp(chname, INKSCAPE_EXTENSION_NS "_item")) { - if (node->attribute("msgctxt") != NULL) { - newtext = g_dpgettext2(NULL, node->attribute("msgctxt"), contents); + if (node->attribute("msgctxt") != nullptr) { + newtext = g_dpgettext2(nullptr, node->attribute("msgctxt"), contents); } else { newtext = _(contents); } @@ -70,7 +70,7 @@ ParamComboBox::ParamComboBox(const gchar * name, continue; const char * val = node->attribute("value"); - if (val != NULL) { + if (val != nullptr) { newvalue = val; } else { newvalue = contents; @@ -128,8 +128,8 @@ ParamComboBox::~ParamComboBox (void) */ const gchar *ParamComboBox::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { - if (in == NULL) { - return NULL; /* Can't have NULL string */ + if (in == nullptr) { + return nullptr; /* Can't have NULL string */ } Glib::ustring settext; @@ -140,7 +140,7 @@ const gchar *ParamComboBox::set(const gchar * in, SPDocument * /*doc*/, Inkscape } } if (!settext.empty()) { - if (_value != NULL) { + if (_value != nullptr) { g_free(_value); } _value = g_strdup(settext.data()); @@ -158,7 +158,7 @@ const gchar *ParamComboBox::set(const gchar * in, SPDocument * /*doc*/, Inkscape */ bool ParamComboBox::contains(const gchar * text, SPDocument const * /*doc*/, Inkscape::XML::Node const * /*node*/) const { - if (text == NULL) { + if (text == nullptr) { return false; /* Can't have NULL string */ } @@ -214,7 +214,7 @@ ParamComboBoxEntry::changed (void) { Glib::ustring data = this->get_active_text(); _pref->set(data.c_str(), _doc, _node); - if (_changeSignal != NULL) { + if (_changeSignal != nullptr) { _changeSignal->emit(); } } @@ -225,7 +225,7 @@ ParamComboBoxEntry::changed (void) Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { if (_hidden) { - return NULL; + return nullptr; } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, Parameter::GUI_PARAM_WIDGETS_SPACING)); diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index 1dd3f073b..aaf871068 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -40,27 +40,27 @@ ParamFloat::ParamFloat(const gchar * name, , _min(0.0) , _max(10.0) { - const gchar * defaultval = NULL; - if (xml->firstChild() != NULL) { + const gchar * defaultval = nullptr; + if (xml->firstChild() != nullptr) { defaultval = xml->firstChild()->content(); } - if (defaultval != NULL) { - _value = g_ascii_strtod (defaultval,NULL); + if (defaultval != nullptr) { + _value = g_ascii_strtod (defaultval,nullptr); } const char * maxval = xml->attribute("max"); - if (maxval != NULL) { - _max = g_ascii_strtod (maxval,NULL); + if (maxval != nullptr) { + _max = g_ascii_strtod (maxval,nullptr); } const char * minval = xml->attribute("min"); - if (minval != NULL) { - _min = g_ascii_strtod (minval,NULL); + if (minval != nullptr) { + _min = g_ascii_strtod (minval,nullptr); } _precision = 1; const char * precision = xml->attribute("precision"); - if (precision != NULL) { + if (precision != nullptr) { _precision = atoi(precision); } @@ -136,7 +136,7 @@ public: describing the parameter. */ ParamFloatAdjustment (ParamFloat * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : Gtk::Adjustment(0.0, param->min(), param->max(), 0.1, 1.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { - this->set_value(_pref->get(NULL, NULL) /* \todo fix */); + this->set_value(_pref->get(nullptr, nullptr) /* \todo fix */); this->signal_value_changed().connect(sigc::mem_fun(this, &ParamFloatAdjustment::val_changed)); return; }; @@ -154,7 +154,7 @@ void ParamFloatAdjustment::val_changed(void) { //std::cout << "Value Changed to: " << this->get_value() << std::endl; _pref->set(this->get_value(), _doc, _node); - if (_changeSignal != NULL) { + if (_changeSignal != nullptr) { _changeSignal->emit(); } return; @@ -168,7 +168,7 @@ void ParamFloatAdjustment::val_changed(void) Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { if (_hidden) { - return NULL; + return nullptr; } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, Parameter::GUI_PARAM_WIDGETS_SPACING)); @@ -179,7 +179,7 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod if (_mode == FULL) { Glib::ustring text; - if (_text != NULL) + if (_text != nullptr) text = _text; UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(text, fadjust, _precision); scale->set_size_request(400, -1); diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp index 9ad9b591c..1c946d8b8 100644 --- a/src/extension/param/int.cpp +++ b/src/extension/param/int.cpp @@ -40,21 +40,21 @@ ParamInt::ParamInt(const gchar * name, , _min(0) , _max(10) { - const char * defaultval = NULL; - if (xml->firstChild() != NULL) { + const char * defaultval = nullptr; + if (xml->firstChild() != nullptr) { defaultval = xml->firstChild()->content(); } - if (defaultval != NULL) { + if (defaultval != nullptr) { _value = atoi(defaultval); } const char * maxval = xml->attribute("max"); - if (maxval != NULL) { + if (maxval != nullptr) { _max = atoi(maxval); } const char * minval = xml->attribute("min"); - if (minval != NULL) { + if (minval != nullptr) { _min = atoi(minval); } /* We're handling this by just killing both values */ @@ -118,7 +118,7 @@ public: describing the parameter. */ ParamIntAdjustment (ParamInt * param, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : Gtk::Adjustment(0.0, param->min(), param->max(), 1.0, 10.0, 0), _pref(param), _doc(doc), _node(node), _changeSignal(changeSignal) { - this->set_value(_pref->get(NULL, NULL) /* \todo fix */); + this->set_value(_pref->get(nullptr, nullptr) /* \todo fix */); this->signal_value_changed().connect(sigc::mem_fun(this, &ParamIntAdjustment::val_changed)); }; @@ -135,7 +135,7 @@ void ParamIntAdjustment::val_changed(void) { //std::cout << "Value Changed to: " << this->get_value() << std::endl; _pref->set((int)this->get_value(), _doc, _node); - if (_changeSignal != NULL) { + if (_changeSignal != nullptr) { _changeSignal->emit(); } } @@ -149,7 +149,7 @@ Gtk::Widget * ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { if (_hidden) { - return NULL; + return nullptr; } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, Parameter::GUI_PARAM_WIDGETS_SPACING)); @@ -160,7 +160,7 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal if (_mode == FULL) { Glib::ustring text; - if (_text != NULL) + if (_text != nullptr) text = _text; UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(text, fadjust, 0); scale->set_size_request(400, -1); diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp index e47644f45..d00693db4 100644 --- a/src/extension/param/notebook.cpp +++ b/src/extension/param/notebook.cpp @@ -51,9 +51,9 @@ ParamNotebook::ParamNotebookPage::ParamNotebookPage(const gchar * name, { // Read XML to build page - if (xml != NULL) { + if (xml != nullptr) { Inkscape::XML::Node *child_repr = xml->firstChild(); - while (child_repr != NULL) { + while (child_repr != nullptr) { char const * chname = child_repr->name(); if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) { chname += strlen(INKSCAPE_EXTENSION_NS); @@ -63,7 +63,7 @@ ParamNotebook::ParamNotebookPage::ParamNotebookPage(const gchar * name, if (!strcmp(chname, "param") || !strcmp(chname, "_param")) { Parameter * param; param = Parameter::make(child_repr, ext); - if (param != NULL) parameters.push_back(param); + if (param != nullptr) parameters.push_back(param); } child_repr = child_repr->next(); } @@ -122,13 +122,13 @@ ParamNotebook::ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inksc name = in_repr->attribute("name"); text = in_repr->attribute("gui-text"); - if (text == NULL) + if (text == nullptr) text = in_repr->attribute("_gui-text"); description = in_repr->attribute("gui-description"); - if (description == NULL) + if (description == nullptr) description = in_repr->attribute("_gui-description"); hide = in_repr->attribute("gui-hidden"); - if (hide != NULL) { + if (hide != nullptr) { if (strcmp(hide, "1") == 0 || strcmp(hide, "true") == 0) { hidden = true; @@ -137,8 +137,8 @@ ParamNotebook::ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inksc } /* In this case we just don't have enough information */ - if (name == NULL) { - return NULL; + if (name == nullptr) { + return nullptr; } ParamNotebookPage * page = new ParamNotebookPage(name, text, description, hidden, in_ext, in_repr); @@ -157,7 +157,7 @@ ParamNotebook::ParamNotebookPage::makepage (Inkscape::XML::Node * in_repr, Inksc Gtk::Widget * ParamNotebook::ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { if (_hidden) { - return NULL; + return nullptr; } Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox); @@ -194,7 +194,7 @@ Gtk::Widget * ParamNotebook::ParamNotebookPage::get_widget(SPDocument * doc, Ink /** Search the parameter's name in the page content. */ Parameter *ParamNotebook::ParamNotebookPage::get_param(const gchar * name) { - if (name == NULL) { + if (name == nullptr) { throw Extension::param_not_exist(); } if (this->parameters.empty()) { @@ -208,7 +208,7 @@ Parameter *ParamNotebook::ParamNotebookPage::get_param(const gchar * name) } } - return NULL; + return nullptr; } /** End ParamNotebookPage **/ @@ -224,9 +224,9 @@ ParamNotebook::ParamNotebook(const gchar * name, : Parameter(name, text, description, hidden, indent, ext) { // Read XML tree to add pages: - if (xml != NULL) { + if (xml != nullptr) { Inkscape::XML::Node *child_repr = xml->firstChild(); - while (child_repr != NULL) { + while (child_repr != nullptr) { char const * chname = child_repr->name(); if (!strncmp(chname, INKSCAPE_EXTENSION_NS_NC, strlen(INKSCAPE_EXTENSION_NS_NC))) { chname += strlen(INKSCAPE_EXTENSION_NS); @@ -236,14 +236,14 @@ ParamNotebook::ParamNotebook(const gchar * name, if (!strcmp(chname, "page")) { ParamNotebookPage * page; page = ParamNotebookPage::makepage(child_repr, ext); - if (page != NULL) pages.push_back(page); + if (page != nullptr) pages.push_back(page); } child_repr = child_repr->next(); } } // Initialize _value with the current page - const char * defaultval = NULL; + const char * defaultval = nullptr; // set first page as default if (!pages.empty()) { defaultval = pages[0]->name(); @@ -256,7 +256,7 @@ ParamNotebook::ParamNotebook(const gchar * name, if (!paramval.empty()) defaultval = paramval.data(); - if (defaultval != NULL) + if (defaultval != nullptr) _value = g_strdup(defaultval); // allocate space for _value } @@ -290,9 +290,9 @@ const gchar *ParamNotebook::set(const int in, SPDocument * /*doc*/, Inkscape::XM int i = in < pages.size() ? in : pages.size()-1; ParamNotebookPage * page = pages[i]; - if (page == NULL) return _value; + if (page == nullptr) return _value; - if (_value != NULL) g_free(_value); + if (_value != nullptr) g_free(_value); _value = g_strdup(page->name()); gchar * prefname = this->pref_name(); @@ -359,7 +359,7 @@ void ParamNotebookWdg::changed_page(Gtk::Widget * /*page*/, guint pagenum) /** Search the parameter's name in the notebook content. */ Parameter *ParamNotebook::get_param(const gchar * name) { - if (name == NULL) { + if (name == nullptr) { throw Extension::param_not_exist(); } for (auto page:pages) { @@ -369,7 +369,7 @@ Parameter *ParamNotebook::get_param(const gchar * name) } } - return NULL; + return nullptr; } @@ -381,7 +381,7 @@ Parameter *ParamNotebook::get_param(const gchar * name) Gtk::Widget * ParamNotebook::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { if (_hidden) { - return NULL; + return nullptr; } ParamNotebookWdg * nb = Gtk::manage(new ParamNotebookWdg(this, doc, node)); diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index f9a69de05..d897903cb 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -52,37 +52,37 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex // we can't create a parameter without type if (!type) { - return NULL; + return nullptr; } // also require name unless it's a pure UI element that does not store its value if (!name) { static std::vector<std::string> ui_elements = {"description"}; if (std::find(ui_elements.begin(), ui_elements.end(), type) == ui_elements.end()) { - return NULL; + return nullptr; } } const char *text = in_repr->attribute("gui-text"); - if (text == NULL) { + if (text == nullptr) { text = in_repr->attribute("_gui-text"); - if (text == NULL) { + if (text == nullptr) { // text = ""; // probably better to require devs to explicitly set an empty gui-text if this is what they want } else { const char *context = in_repr->attribute("msgctxt"); - if (context != NULL) { - text = g_dpgettext2(NULL, context, text); + if (context != nullptr) { + text = g_dpgettext2(nullptr, context, text); } else { text = _(text); } } } const char *description = in_repr->attribute("gui-description"); - if (description == NULL) { + if (description == nullptr) { description = in_repr->attribute("_gui-description"); - if (description != NULL) { + if (description != nullptr) { const char *context = in_repr->attribute("msgctxt"); - if (context != NULL) { - description = g_dpgettext2(NULL, context, description); + if (context != nullptr) { + description = g_dpgettext2(nullptr, context, description); } else { description = _(description); } @@ -91,7 +91,7 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex bool hidden = false; { const char *gui_hide = in_repr->attribute("gui-hidden"); - if (gui_hide != NULL) { + if (gui_hide != nullptr) { if (strcmp(gui_hide, "1") == 0 || strcmp(gui_hide, "true") == 0) { hidden = true; @@ -102,7 +102,7 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex int indent = 0; { const char *indent_attr = in_repr->attribute("indent"); - if (indent_attr != NULL) { + if (indent_attr != nullptr) { if (strcmp(indent_attr, "true") == 0) { indent = 1; } else { @@ -112,7 +112,7 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex } const gchar* appearance = in_repr->attribute("appearance"); - Parameter * param = NULL; + Parameter * param = nullptr; if (!strcmp(type, "boolean")) { param = new ParamBool(name, text, description, hidden, indent, in_ext, in_repr); } else if (!strcmp(type, "int")) { @@ -130,7 +130,7 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex } else if (!strcmp(type, "string")) { param = new ParamString(name, text, description, hidden, indent, in_ext, in_repr); gchar const * max_length = in_repr->attribute("max_length"); - if (max_length != NULL) { + if (max_length != nullptr) { ParamString * ps = dynamic_cast<ParamString *>(param); ps->setMaxLength(atoi(max_length)); } @@ -237,7 +237,7 @@ guint32 Parameter::get_color(const SPDocument* doc, Inkscape::XML::Node const *n bool Parameter::set_bool(bool in, SPDocument * doc, Inkscape::XML::Node * node) { ParamBool * boolpntr = dynamic_cast<ParamBool *>(this); - if (boolpntr == NULL) + if (boolpntr == nullptr) throw Extension::param_not_bool_param(); return boolpntr->set(in, doc, node); } @@ -245,7 +245,7 @@ bool Parameter::set_bool(bool in, SPDocument * doc, Inkscape::XML::Node * node) int Parameter::set_int(int in, SPDocument * doc, Inkscape::XML::Node * node) { ParamInt * intpntr = dynamic_cast<ParamInt *>(this); - if (intpntr == NULL) + if (intpntr == nullptr) throw Extension::param_not_int_param(); return intpntr->set(in, doc, node); } @@ -256,7 +256,7 @@ Parameter::set_float (float in, SPDocument * doc, Inkscape::XML::Node * node) { ParamFloat * floatpntr; floatpntr = dynamic_cast<ParamFloat *>(this); - if (floatpntr == NULL) + if (floatpntr == nullptr) throw Extension::param_not_float_param(); return floatpntr->set(in, doc, node); } @@ -266,7 +266,7 @@ gchar const * Parameter::set_string (gchar const * in, SPDocument * doc, Inkscape::XML::Node * node) { ParamString * stringpntr = dynamic_cast<ParamString *>(this); - if (stringpntr == NULL) + if (stringpntr == nullptr) throw Extension::param_not_string_param(); return stringpntr->set(in, doc, node); } @@ -295,7 +295,7 @@ guint32 Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node) { ParamColor* param = dynamic_cast<ParamColor *>(this); - if (param == NULL) + if (param == nullptr) throw Extension::param_not_color_param(); return param->set(in, doc, node); } @@ -303,22 +303,22 @@ Parameter::set_color (guint32 in, SPDocument * doc, Inkscape::XML::Node * node) /** Oop, now that we need a parameter, we need it's name. */ Parameter::Parameter(gchar const * name, gchar const * text, gchar const * description, bool hidden, int indent, Inkscape::Extension::Extension * ext) : - _description(0), - _text(0), + _description(nullptr), + _text(nullptr), _hidden(hidden), _indent(indent), _extension(ext), - _name(0) + _name(nullptr) { - if (name != NULL) { + if (name != nullptr) { _name = g_strdup(name); } - if (description != NULL) { + if (description != nullptr) { _description = g_strdup(description); } - if (text != NULL) { + if (text != nullptr) { _text = g_strdup(text); } else { _text = g_strdup(name); @@ -329,17 +329,17 @@ Parameter::Parameter(gchar const * name, gchar const * text, gchar const * descr /** Oop, now that we need a parameter, we need it's name. */ Parameter::Parameter (gchar const * name, gchar const * text, Inkscape::Extension::Extension * ext) : - _description(0), - _text(0), + _description(nullptr), + _text(nullptr), _hidden(false), _indent(0), _extension(ext), - _name(0) + _name(nullptr) { - if (name != NULL) { + if (name != nullptr) { _name = g_strdup(name); } - if (text != NULL) { + if (text != nullptr) { _text = g_strdup(text); } else { _text = g_strdup(name); @@ -351,13 +351,13 @@ Parameter::Parameter (gchar const * name, gchar const * text, Inkscape::Extensio Parameter::~Parameter(void) { g_free(_name); - _name = 0; + _name = nullptr; g_free(_text); - _text = 0; + _text = nullptr; g_free(_description); - _description = 0; + _description = nullptr; } gchar *Parameter::pref_name(void) const @@ -387,12 +387,12 @@ Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc) { Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node * defs = doc->getDefs()->getRepr(); - Inkscape::XML::Node * params = NULL; + Inkscape::XML::Node * params = nullptr; GQuark const name_quark = g_quark_from_string("inkscape:extension-params"); for (Inkscape::XML::Node * child = defs->firstChild(); - child != NULL; + child != nullptr; child = child->next()) { if ((GQuark)child->code() == name_quark && !strcmp(child->attribute("extension"), _extension->get_id())) { @@ -401,7 +401,7 @@ Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc) } } - if (params == NULL) { + if (params == nullptr) { params = xml_doc->createElement("inkscape:extension-param"); params->setAttribute("extension", _extension->get_id()); defs->appendChild(params); @@ -415,7 +415,7 @@ Inkscape::XML::Node *Parameter::document_param_node(SPDocument * doc) Gtk::Widget * Parameter::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/, sigc::signal<void> * /*changeSignal*/) { - return NULL; + return nullptr; } /** If I'm not sure which it is, just don't return a value. */ @@ -441,7 +441,7 @@ void Parameter::string(std::list <std::string> &list) const Parameter *Parameter::get_param(gchar const * /*name*/) { - return NULL; + return nullptr; } Glib::ustring const extension_pref_root = "/extensions/"; diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp index 5598081f3..45869378a 100644 --- a/src/extension/param/radiobutton.cpp +++ b/src/extension/param/radiobutton.cpp @@ -51,25 +51,25 @@ ParamRadioButton::ParamRadioButton(const gchar * name, Inkscape::XML::Node * xml, AppearanceMode mode) : Parameter(name, text, description, hidden, indent, ext) - , _value(0) + , _value(nullptr) , _mode(mode) { // Read XML tree to add enumeration items: // printf("Extension Constructor: "); - if (xml != NULL) { + if (xml != nullptr) { Inkscape::XML::Node *child_repr = xml->firstChild(); - while (child_repr != NULL) { + while (child_repr != nullptr) { char const * chname = child_repr->name(); if (!strcmp(chname, INKSCAPE_EXTENSION_NS "option") || !strcmp(chname, INKSCAPE_EXTENSION_NS "_option")) { - Glib::ustring * newtext = NULL; - Glib::ustring * newvalue = NULL; + Glib::ustring * newtext = nullptr; + Glib::ustring * newvalue = nullptr; const char * contents = child_repr->firstChild()->content(); - if (contents != NULL) { + if (contents != nullptr) { // don't translate when 'item' but do translate when '_option' if (!strcmp(chname, INKSCAPE_EXTENSION_NS "_option")) { - if (child_repr->attribute("msgctxt") != NULL) { - newtext = new Glib::ustring(g_dpgettext2(NULL, child_repr->attribute("msgctxt"), contents)); + if (child_repr->attribute("msgctxt") != nullptr) { + newtext = new Glib::ustring(g_dpgettext2(nullptr, child_repr->attribute("msgctxt"), contents)); } else { newtext = new Glib::ustring(_(contents)); } @@ -82,7 +82,7 @@ ParamRadioButton::ParamRadioButton(const gchar * name, const char * val = child_repr->attribute("value"); - if (val != NULL) { + if (val != nullptr) { newvalue = new Glib::ustring(val); } else { newvalue = new Glib::ustring(contents); @@ -98,7 +98,7 @@ ParamRadioButton::ParamRadioButton(const gchar * name, // Initialize _value with the default value from xml // for simplicity : default to the contents of the first xml-child - const char * defaultval = NULL; + const char * defaultval = nullptr; if (!choices.empty()) { defaultval = (static_cast<optionentry*> (choices[0]))->value->c_str(); } @@ -111,7 +111,7 @@ ParamRadioButton::ParamRadioButton(const gchar * name, if (!paramval.empty()) { defaultval = paramval.data(); } - if (defaultval != NULL) { + if (defaultval != nullptr) { _value = g_strdup(defaultval); // allocate space for _value } } @@ -143,11 +143,11 @@ ParamRadioButton::~ParamRadioButton (void) */ const gchar *ParamRadioButton::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { - if (in == NULL) { - return NULL; /* Can't have NULL string */ + if (in == nullptr) { + return nullptr; /* Can't have NULL string */ } - Glib::ustring * settext = NULL; + Glib::ustring * settext = nullptr; for (auto entr:choices) { if ( !entr->value->compare(in) ) { settext = entr->value; @@ -155,7 +155,7 @@ const gchar *ParamRadioButton::set(const gchar * in, SPDocument * /*doc*/, Inksc } } if (settext) { - if (_value != NULL) { + if (_value != nullptr) { g_free(_value); } _value = g_strdup(settext->c_str()); @@ -215,7 +215,7 @@ void ParamRadioButtonWdg::changed(void) Glib::ustring value = _pref->value_from_label(this->get_label()); _pref->set(value.c_str(), _doc, _node); } - if (_changeSignal != NULL) { + if (_changeSignal != nullptr) { _changeSignal->emit(); } } @@ -247,7 +247,7 @@ void ComboWdg::changed(void) Glib::ustring value = _base->value_from_label(get_active_text()); _base->set(value.c_str(), _doc, _node); } - if (_changeSignal != NULL) { + if (_changeSignal != nullptr) { _changeSignal->emit(); } } @@ -276,7 +276,7 @@ Glib::ustring ParamRadioButton::value_from_label(const Glib::ustring label) Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { if (_hidden) { - return NULL; + return nullptr; } auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, Parameter::GUI_PARAM_WIDGETS_SPACING)); @@ -288,7 +288,7 @@ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node label->show(); hbox->pack_start(*label, false, false); - Gtk::ComboBoxText* cbt = 0; + Gtk::ComboBoxText* cbt = nullptr; bool comboSet = false; if (_mode == MINIMAL) { cbt = Gtk::manage(new ComboWdg(this, doc, node, changeSignal)); diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp index 51b5dfdf3..775bf62ee 100644 --- a/src/extension/param/string.cpp +++ b/src/extension/param/string.cpp @@ -30,7 +30,7 @@ namespace Extension { ParamString::~ParamString(void) { g_free(_value); - _value = 0; + _value = nullptr; } /** @@ -50,11 +50,11 @@ ParamString::~ParamString(void) */ const gchar * ParamString::set(const gchar * in, SPDocument * /*doc*/, Inkscape::XML::Node * /*node*/) { - if (in == NULL) { - return NULL; /* Can't have NULL string */ + if (in == nullptr) { + return nullptr; /* Can't have NULL string */ } - if (_value != NULL) { + if (_value != nullptr) { g_free(_value); } @@ -84,10 +84,10 @@ ParamString::ParamString(const gchar * name, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml) : Parameter(name, text, description, hidden, indent, ext) - , _value(NULL) + , _value(nullptr) { - const char * defaultval = NULL; - if (xml->firstChild() != NULL) { + const char * defaultval = nullptr; + if (xml->firstChild() != nullptr) { defaultval = xml->firstChild()->content(); } @@ -99,11 +99,11 @@ ParamString::ParamString(const gchar * name, if (!paramval.empty()) { defaultval = paramval.data(); } - if (defaultval != NULL) { + if (defaultval != nullptr) { char const * chname = xml->name(); if (!strcmp(chname, INKSCAPE_EXTENSION_NS "_param")) { - if (xml->attribute("msgctxt") != NULL) { - _value = g_strdup(g_dpgettext2(NULL, xml->attribute("msgctxt"), defaultval)); + if (xml->attribute("msgctxt") != nullptr) { + _value = g_strdup(g_dpgettext2(nullptr, xml->attribute("msgctxt"), defaultval)); } else { _value = g_strdup(_(defaultval)); } @@ -130,8 +130,8 @@ public: */ ParamStringEntry (ParamString * pref, SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) : Gtk::Entry(), _pref(pref), _doc(doc), _node(node), _changeSignal(changeSignal) { - if (_pref->get(NULL, NULL) != NULL) { - this->set_text(Glib::ustring(_pref->get(NULL, NULL))); + if (_pref->get(nullptr, nullptr) != nullptr) { + this->set_text(Glib::ustring(_pref->get(nullptr, nullptr))); } this->set_max_length(_pref->getMaxLength()); //Set the max length - default zero means no maximum this->signal_changed().connect(sigc::mem_fun(this, &ParamStringEntry::changed_text)); @@ -150,7 +150,7 @@ void ParamStringEntry::changed_text(void) { Glib::ustring data = this->get_text(); _pref->set(data.c_str(), _doc, _node); - if (_changeSignal != NULL) { + if (_changeSignal != nullptr) { _changeSignal->emit(); } } @@ -163,7 +163,7 @@ void ParamStringEntry::changed_text(void) Gtk::Widget * ParamString::get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal<void> * changeSignal) { if (_hidden) { - return NULL; + return nullptr; } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, Parameter::GUI_PARAM_WIDGETS_SPACING)); |
