Add my copyright to files I've modified.
[synfig.git] / synfig-core / trunk / src / synfig / savecanvas.cpp
index cb47847..4f37a25 100644 (file)
@@ -6,6 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007 Chris Moore
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
 #include "gradient.h"
 #include <errno.h>
 
+extern "C" {
+#include <libxml/tree.h>
+}
+
 #endif
 
 /* === U S I N G =========================================================== */
@@ -96,7 +101,7 @@ xmlpp::Element* encode_real(xmlpp::Element* root,Real v)
        return root;
 }
 
-xmlpp::Element* encode_time(xmlpp::Element* root,Time t, float fps=0)
+xmlpp::Element* encode_time(xmlpp::Element* root,Time t, float /*fps*/=0)
 {
        root->set_name("time");
        //root->set_attribute("value",t.get_string(fps));
@@ -287,7 +292,9 @@ xmlpp::Element* encode_animated(xmlpp::Element* root,ValueNode_Animated::ConstHa
                        waypoint_node->set_attribute("before","halt");
                        break;
                case INTERPOLATION_LINEAR:
-                       waypoint_node->set_attribute("before","linear");
+                       // This is the default value for angles, so don't add a new attribute for them
+                       if (value_node->get_type() != ValueBase::TYPE_ANGLE)
+                               waypoint_node->set_attribute("before","linear");
                        break;
                case INTERPOLATION_MANUAL:
                        waypoint_node->set_attribute("before","manual");
@@ -296,7 +303,9 @@ xmlpp::Element* encode_animated(xmlpp::Element* root,ValueNode_Animated::ConstHa
                        waypoint_node->set_attribute("before","constant");
                        break;
                case INTERPOLATION_TCB:
-                       // This is the default value, so don't add a new attribute
+                       // This is the default value, so don't add a new attribute (unless it's an angle - they default to linear)
+                       if (value_node->get_type() == ValueBase::TYPE_ANGLE)
+                               waypoint_node->set_attribute("before","auto");
                        break;
                default:
                        error("Unknown waypoint type for \"before\" attribute");
@@ -308,7 +317,9 @@ xmlpp::Element* encode_animated(xmlpp::Element* root,ValueNode_Animated::ConstHa
                        waypoint_node->set_attribute("after","halt");
                        break;
                case INTERPOLATION_LINEAR:
-                       waypoint_node->set_attribute("after","linear");
+                       // This is the default value for angles, so don't add a new attribute for them
+                       if (value_node->get_type() != ValueBase::TYPE_ANGLE)
+                               waypoint_node->set_attribute("after","linear");
                        break;
                case INTERPOLATION_MANUAL:
                        waypoint_node->set_attribute("after","manual");
@@ -317,10 +328,12 @@ xmlpp::Element* encode_animated(xmlpp::Element* root,ValueNode_Animated::ConstHa
                        waypoint_node->set_attribute("after","constant");
                        break;
                case INTERPOLATION_TCB:
-                       // This is the default value, so don't add a new attribute
+                       // This is the default value, so don't add a new attribute (unless it's an angle - they default to linear)
+                       if (value_node->get_type() == ValueBase::TYPE_ANGLE)
+                               waypoint_node->set_attribute("after","auto");
                        break;
                default:
-                       error("Unknown waypoint type for \"before\" attribute");
+                       error("Unknown waypoint type for \"after\" attribute");
                }
 
                if(iter->get_tension()!=0.0)
@@ -739,6 +752,11 @@ synfig::save_canvas(const String &filename, Canvas::ConstHandle canvas)
 
        synfig::String tmp_filename(filename+".TMP");
 
+       if (String(filename.begin() + filename.find_last_of('.')+1, filename.end()) == "sifz")
+               xmlSetCompressMode(9);
+       else
+               xmlSetCompressMode(0);
+
        try
        {
                assert(canvas);