Fix and re-enable the "Timed Swap" convert. Prevent loadcanvas from converting ...
[synfig.git] / synfig-core / trunk / src / synfig / loadcanvas.cpp
index f2f74a6..9132bab 100644 (file)
@@ -2,7 +2,7 @@
 /*!    \file loadcanvas.cpp
 **     \brief writeme
 **
-**     $Id: loadcanvas.cpp,v 1.3 2005/01/04 23:40:44 darco Exp $
+**     $Id$
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
@@ -901,10 +901,22 @@ CanvasParser::parse_animated(xmlpp::Element *element,Canvas::Handle canvas)
 
 
                        ValueNode::Handle waypoint_value_node;
+                       xmlpp::Element::NodeList list = child->get_children();
 
                        if(child->get_attribute("use"))
                        {
-                               waypoint_value_node=canvas->surefind_value_node(child->get_attribute("use")->get_value());
+                               if(!list.empty())
+                                       warning(child,_("Found \"use\" attribute for <waypoint>, but it wasn't empty. Ignoring contents..."));
+
+                               // the waypoint might look like this, in which case we won't find "mycanvas" in the list of valuenodes, 'cos it's a canvas
+                               //
+                               //      <animated type="canvas">
+                               //        <waypoint time="0s" use="mycanvas"/>
+                               //      </animated>
+                               if (type==ValueBase::TYPE_CANVAS)
+                                       waypoint_value_node=ValueNode_Const::create(canvas->surefind_canvas(child->get_attribute("use")->get_value()));
+                               else
+                                       waypoint_value_node=canvas->surefind_value_node(child->get_attribute("use")->get_value());
                        }
                        else
                        {
@@ -914,7 +926,6 @@ CanvasParser::parse_animated(xmlpp::Element *element,Canvas::Handle canvas)
                                        continue;
                                }
 
-                               xmlpp::Element::NodeList list = child->get_children();
                                xmlpp::Element::NodeList::iterator iter;
 
                                // Search for the first non-text XML element
@@ -1601,6 +1612,10 @@ CanvasParser::parse_dynamic_list(xmlpp::Element *element,Canvas::Handle canvas)
                                        String timecode(begin_sequence.begin(), iter);
                                        int priority=0;
 
+                                       // skip whitespace before checking for a priority
+                                       while (isspace(timecode[0]))
+                                               timecode=timecode.substr(1);
+
                                        // If there is a priority, then grab it and remove
                                        // it from the timecode
                                        if(timecode[0]=='p')
@@ -1637,6 +1652,10 @@ CanvasParser::parse_dynamic_list(xmlpp::Element *element,Canvas::Handle canvas)
                                        String timecode(end_sequence.begin(),   iter);
                                        int priority=0;
 
+                                       // skip whitespace before checking for a priority
+                                       while (isspace(timecode[0]))
+                                               timecode=timecode.substr(1);
+
                                        // If there is a priority, then grab it and remove
                                        // it from the timecode
                                        if(timecode[0]=='p')
@@ -1670,6 +1689,7 @@ CanvasParser::parse_dynamic_list(xmlpp::Element *element,Canvas::Handle canvas)
 
                        if(child->get_attribute("use"))
                        {
+                               // \todo does this need to be able to read 'use="canvas"', like waypoints can now?  (see 'surefind_canvas' in this file)
                                string id=child->get_attribute("use")->get_value();
                                try
                                {
@@ -1764,9 +1784,9 @@ CanvasParser::parse_value_node(xmlpp::Element *element,Canvas::Handle canvas)
        if(element->get_name()=="bline") // This is not a typo. The dynamic list parser will parse a bline.
                value_node=parse_dynamic_list(element,canvas);
        else
-       if(element->get_name()=="timed_swap")
-               value_node=parse_timedswap(element,canvas);
-       else
+//     if(element->get_name()=="timed_swap")
+//             value_node=parse_timedswap(element,canvas);
+//     else
        if(LinkableValueNode::book().count(element->get_name()))
                value_node=parse_linkable_value_node(element,canvas);
        else