Mercurial > hg > octave-lyh
diff src/graphics.cc @ 10733:f72a761a784c
eliminate code duplication in reset_default_properties methods
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 25 Jun 2010 07:22:45 -0400 |
parents | 755fcb5baad3 |
children | 91342260063e |
line wrap: on
line diff
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -2625,8 +2625,8 @@ property_list root_figure::factory_properties = root_figure::init_factory_properties (); -void -root_figure::reset_default_properties (void) +static void +reset_default_properties (property_list& default_properties) { property_list new_defaults; @@ -2650,9 +2650,16 @@ new_defaults.set (prefix + s, q->second); } } + default_properties = new_defaults; } +void +root_figure::reset_default_properties (void) +{ + ::reset_default_properties (default_properties); +} + // --------------------------------------------------------------------- void @@ -2800,29 +2807,7 @@ void figure::reset_default_properties (void) { - property_list new_defaults; - - for (property_list::plist_map_const_iterator p = default_properties.begin (); - p != default_properties.end (); p++) - { - const property_list::pval_map_type pval_map = p->second; - std::string prefix = p->first; - - for (property_list::pval_map_const_iterator q = pval_map.begin (); - q != pval_map.end (); - q++) - { - std::string s = q->first; - - if (prefix == "axes" && (s == "position" || s == "units")) - new_defaults.set (prefix + s, q->second); - else if (prefix == "figure" && (s == "position" || s == "units" - || s == "windowstyle" - || s == "paperunits")) - new_defaults.set (prefix + s, q->second); - } - } - default_properties = new_defaults; + ::reset_default_properties (default_properties); } // --------------------------------------------------------------------- @@ -4345,29 +4330,7 @@ void axes::reset_default_properties (void) { - property_list new_defaults; - - for (property_list::plist_map_const_iterator p = default_properties.begin (); - p != default_properties.end (); p++) - { - const property_list::pval_map_type pval_map = p->second; - std::string prefix = p->first; - - for (property_list::pval_map_const_iterator q = pval_map.begin (); - q != pval_map.end (); - q++) - { - std::string s = q->first; - - if (prefix == "axes" && (s == "position" || s == "units")) - new_defaults.set (prefix + s, q->second); - else if (prefix == "figure" && (s == "position" || s == "units" - || s == "windowstyle" - || s == "paperunits")) - new_defaults.set (prefix + s, q->second); - } - } - default_properties = new_defaults; + ::reset_default_properties (default_properties); } // ---------------------------------------------------------------------