Fix 1795922: loadcanvas.cpp was special-casing subtract valuenodes when there's no...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sun, 16 Sep 2007 22:52:14 +0000 (22:52 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sun, 16 Sep 2007 22:52:14 +0000 (22:52 +0000)
git-svn-id: http://svn.voria.com/code@683 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/synfig/loadcanvas.cpp

index f4a91c8..760a231 100644 (file)
@@ -1040,194 +1040,6 @@ CanvasParser::parse_animated(xmlpp::Element *element,Canvas::Handle canvas)
        return value_node;
 }
 
-handle<ValueNode_Subtract>
-CanvasParser::parse_subtract(xmlpp::Element *element,Canvas::Handle canvas)
-{
-       assert(element->get_name()=="subtract");
-
-       handle<ValueNode_Subtract> value_node;
-       handle<ValueNode> 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 <subtract>");
-                       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 <subtract>")));
-               return handle<ValueNode_Subtract>();
-       }
-
-       //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 <subtract> 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<xmlpp::Element*>(*iter));
-               if(!child)
-                       continue;
-               else
-               if(child->get_name()=="lhs")
-               {
-                       if(lhs)
-                       {
-                               error(child,"LHS component of <subtract> 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<xmlpp::Element*>(*iter)) break;
-
-                       if(iter==list.end())
-                       {
-                               error(child,_("<lhs> is missing its contents"));
-                               continue;
-                       }
-
-                       lhs=parse_value_node(dynamic_cast<xmlpp::Element*>(*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 <subtract> 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<xmlpp::Element*>(*iter)) break;
-
-                       if(iter==list.end())
-                       {
-                               error(child,_("<rhs> is missing its contents"));
-                               continue;
-                       }
-
-                       rhs=parse_value_node(dynamic_cast<xmlpp::Element*>(*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 <subtract> 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<xmlpp::Element*>(*iter)) break;
-
-                       if(iter==list.end())
-                       {
-                               error(child,_("<scalar> is missing its contents"));
-                               continue;
-                       }
-
-                       scalar=parse_value_node(dynamic_cast<xmlpp::Element*>(*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,"<subtract> is missing LHS, RHS, or SCALAR");
-
-       if(value_node->get_rhs() == value_node->get_lhs())
-               warning(element,"LHS is equal to RHS in <subtract>, so this value_node will always be zero!");
-
-       return value_node;
-}
-
 etl::handle<LinkableValueNode>
 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