Fix loading of old projects.
[dcpomatic.git] / src / lib / text_content.cc
index 011c42f35fff5318ef2ad528608708250970141a..ee29ae8c4d28122c6dfeafc2838906a48bf4c0d8 100644 (file)
@@ -57,7 +57,7 @@ int const TextContentProperty::FADE_OUT = 513;
 int const TextContentProperty::OUTLINE_WIDTH = 514;
 int const TextContentProperty::TYPE = 515;
 
-TextContent::TextContent (Content* parent, TextType original_type)
+TextContent::TextContent (Content* parent, TextType type, TextType original_type)
        : ContentPart (parent)
        , _use (false)
        , _burn (false)
@@ -67,13 +67,13 @@ TextContent::TextContent (Content* parent, TextType original_type)
        , _y_scale (1)
        , _line_spacing (1)
        , _outline_width (2)
-       , _type (original_type)
+       , _type (type)
        , _original_type (original_type)
 {
 
 }
 
-/** @return TextContents from node or <Caption> nodes under node (according to version).
+/** @return TextContents from node or <Text> nodes under node (according to version).
  *  The list could be empty if no TextContents are found.
  */
 list<shared_ptr<TextContent> >
@@ -99,12 +99,12 @@ TextContent::from_xml (Content* parent, cxml::ConstNodePtr node, int version)
                return c;
        }
 
-       if (!node->optional_node_child("Caption")) {
+       if (!node->optional_node_child("Text")) {
                return list<shared_ptr<TextContent> >();
        }
 
        list<shared_ptr<TextContent> > c;
-       BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Caption")) {
+       BOOST_FOREACH (cxml::ConstNodePtr i, node->node_children("Text")) {
                c.push_back (shared_ptr<TextContent> (new TextContent (parent, i, version)));
        }
        return c;
@@ -225,8 +225,12 @@ TextContent::TextContent (Content* parent, cxml::ConstNodePtr node, int version)
 
        connect_to_fonts ();
 
-       _type = string_to_text_type (node->optional_string_child("Type").get_value_or("open"));
-       _original_type = string_to_text_type (node->optional_string_child("OriginalType").get_value_or("open"));
+       if (version >= 37) {
+               _type = string_to_text_type (node->optional_string_child("Type").get_value_or("open"));
+               if (node->optional_string_child("OriginalType")) {
+                       _original_type = string_to_text_type (node->optional_string_child("OriginalType").get());
+               }
+       }
 }
 
 TextContent::TextContent (Content* parent, vector<shared_ptr<Content> > c)