- if (!subtitle || font_changed ||
- (last_in != (*i)->in() ||
- last_out != (*i)->out() ||
- last_fade_up_time != (*i)->fade_up_time() ||
- last_fade_down_time != (*i)->fade_down_time()
- )) {
-
- subtitle = font->add_child ("Subtitle");
- subtitle->set_attribute ("SpotNumber", lexical_cast<string> (spot_number++));
- subtitle->set_attribute ("TimeIn", (*i)->in().to_string());
- subtitle->set_attribute ("TimeOut", (*i)->out().to_string());
- subtitle->set_attribute ("FadeUpTime", lexical_cast<string> ((*i)->fade_up_time().to_ticks()));
- subtitle->set_attribute ("FadeDownTime", lexical_cast<string> ((*i)->fade_down_time().to_ticks()));
-
- last_in = (*i)->in ();
- last_out = (*i)->out ();
- last_fade_up_time = (*i)->fade_up_time ();
- last_fade_down_time = (*i)->fade_down_time ();
+/** @param standard Standard (INTEROP or SMPTE); this is used rather than putting things in the child
+ * class because the differences between the two are fairly subtle.
+ */
+void
+SubtitleAsset::subtitles_as_xml (xmlpp::Element* xml_root, int time_code_rate, Standard standard) const
+{
+ list<SubtitleString> sorted = _subtitles;
+ sorted.sort (SubtitleSorter ());
+
+ /* Gather our subtitles into a hierarchy of Subtitle/Text/String objects, writing
+ font information into the bottom level (String) objects.
+ */
+
+ shared_ptr<order::Part> root (new order::Part (shared_ptr<order::Part> ()));
+ shared_ptr<order::Subtitle> subtitle;
+ shared_ptr<order::Text> text;
+
+ Time last_in;
+ Time last_out;
+ Time last_fade_up_time;
+ Time last_fade_down_time;
+ HAlign last_h_align;
+ float last_h_position;
+ VAlign last_v_align;
+ float last_v_position;
+ Direction last_direction;
+
+ BOOST_FOREACH (SubtitleString const & i, sorted) {
+ if (!subtitle ||
+ (last_in != i.in() ||
+ last_out != i.out() ||
+ last_fade_up_time != i.fade_up_time() ||
+ last_fade_down_time != i.fade_down_time())
+ ) {
+
+ subtitle.reset (new order::Subtitle (root, i.in(), i.out(), i.fade_up_time(), i.fade_down_time()));
+ root->children.push_back (subtitle);
+
+ last_in = i.in ();
+ last_out = i.out ();
+ last_fade_up_time = i.fade_up_time ();
+ last_fade_down_time = i.fade_down_time ();
+ text.reset ();