From 899bef2135047fcea316348dfdf60af632193006 Mon Sep 17 00:00:00 2001 From: dooglus Date: Sun, 16 Sep 2007 22:52:14 +0000 Subject: [PATCH] Fix 1795922: loadcanvas.cpp was special-casing subtract valuenodes when there's no need to - the generic code works better. git-svn-id: http://svn.voria.com/code@683 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/src/synfig/loadcanvas.cpp | 191 ---------------------------- 1 file changed, 191 deletions(-) diff --git a/synfig-core/trunk/src/synfig/loadcanvas.cpp b/synfig-core/trunk/src/synfig/loadcanvas.cpp index f4a91c8..760a231 100644 --- a/synfig-core/trunk/src/synfig/loadcanvas.cpp +++ b/synfig-core/trunk/src/synfig/loadcanvas.cpp @@ -1040,194 +1040,6 @@ CanvasParser::parse_animated(xmlpp::Element *element,Canvas::Handle canvas) return value_node; } -handle -CanvasParser::parse_subtract(xmlpp::Element *element,Canvas::Handle canvas) -{ - assert(element->get_name()=="subtract"); - - handle value_node; - handle lhs,rhs,scalar; - - if(element->get_attribute("type")) - { - ValueBase::Type type=ValueBase::ident_type(element->get_attribute("type")->get_value()); - - if(!type) - { - error(element,"Bad type in "); - return ValueNode_Subtract::Handle(); - } - value_node=ValueNode_Subtract::create(type); - } - else - value_node=ValueNode_Subtract::create(); - - if(!value_node) - { - error(element,strprintf(_("Unable to create "))); - return handle(); - } - - //if(element->get_attribute("scalar")) - //{ - // value_node->set_scalar(atof(element->get_attribute("scalar")->get_value().c_str())); - //} - - try - { - if(element->get_attribute("scalar")) - { - // This is for compatibility with older versions of the file format - String value(element->get_attribute("scalar")->get_value()); - if((value[0]<='9' && value[0]>='0') || value[0]=='-') - { - warning(element, _("Use of a real value where the ID should be is deprecated")); - value_node->set_scalar(atof(value.c_str())); - } - else - value_node->set_scalar(canvas->surefind_value_node(value)); - scalar=value_node->get_scalar(); - } - - if(element->get_attribute("lhs")) - { - lhs=canvas->surefind_value_node(element->get_attribute("lhs")->get_value()); - value_node->set_lhs(lhs); - } - - if(element->get_attribute("rhs")) - { - rhs=canvas->surefind_value_node(element->get_attribute("rhs")->get_value()); - value_node->set_rhs(rhs); - } - } - catch (Exception::IDNotFound) - { - error(element,"attribute in references unknown ID"); - } - catch (Exception::FileNotFound) - { - error(element,"Unable to open external file referenced in ID"); - } - - xmlpp::Element::NodeList list = element->get_children(); - for(xmlpp::Element::NodeList::iterator iter = list.begin(); iter != list.end(); ++iter) - { - xmlpp::Element *child(dynamic_cast(*iter)); - if(!child) - continue; - else - if(child->get_name()=="lhs") - { - if(lhs) - { - error(child,"LHS component of already defined!"); - continue; - } - - xmlpp::Element::NodeList list = child->get_children(); - xmlpp::Element::NodeList::iterator iter; - - // Search for the first non-text XML element - for(iter = list.begin(); iter != list.end(); ++iter) - if(dynamic_cast(*iter)) break; - - if(iter==list.end()) - { - error(child,_(" is missing its contents")); - continue; - } - - lhs=parse_value_node(dynamic_cast(*iter),canvas); - - if(lhs) - value_node->set_lhs(lhs); - else - { - error((*iter),"Parse of LHS ValueNode failed"); - } - - // \todo do a search for more elements and warn if they are found - } - else - if(child->get_name()=="rhs") - { - if(rhs) - { - error(child,"RHS component of already defined!"); - continue; - } - - xmlpp::Element::NodeList list = child->get_children(); - xmlpp::Element::NodeList::iterator iter; - - // Search for the first non-text XML element - for(iter = list.begin(); iter != list.end(); ++iter) - if(dynamic_cast(*iter)) break; - - if(iter==list.end()) - { - error(child,_(" is missing its contents")); - continue; - } - - rhs=parse_value_node(dynamic_cast(*iter),canvas); - - if(rhs) - value_node->set_rhs(rhs); - else - { - error((*iter),"Parse of RHS ValueNode failed"); - } - - // \todo do a search for more elements and warn if they are found - } - else - if(child->get_name()=="scalar") - { - if(scalar) - { - error(child,"scalar component of already defined!"); - continue; - } - - xmlpp::Element::NodeList list = child->get_children(); - xmlpp::Element::NodeList::iterator iter; - - // Search for the first non-text XML element - for(iter = list.begin(); iter != list.end(); ++iter) - if(dynamic_cast(*iter)) break; - - if(iter==list.end()) - { - error(child,_(" is missing its contents")); - continue; - } - - scalar=parse_value_node(dynamic_cast(*iter),canvas); - - if(scalar) - value_node->set_scalar(scalar); - else - { - error((*iter),"Parse of scalar ValueNode failed"); - } - - // \todo do a search for more elements and warn if they are found - } - else - error_unexpected_element(child,child->get_name()); - } - - if(!value_node->get_rhs() || !value_node->get_lhs() || !value_node->get_scalar()) - error(element," is missing LHS, RHS, or SCALAR"); - - if(value_node->get_rhs() == value_node->get_lhs()) - warning(element,"LHS is equal to RHS in , so this value_node will always be zero!"); - - return value_node; -} - etl::handle CanvasParser::parse_linkable_value_node(xmlpp::Element *element,Canvas::Handle canvas) { @@ -1745,9 +1557,6 @@ CanvasParser::parse_value_node(xmlpp::Element *element,Canvas::Handle canvas) if(element->get_name()=="hermite" || element->get_name()=="animated") value_node=parse_animated(element,canvas); else - if(element->get_name()=="subtract") - value_node=parse_subtract(element,canvas); - else if(element->get_name()=="composite") value_node=parse_composite(element,canvas); else -- 2.7.4