mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 20:52:44 +01:00
Added subtitle format "Flash xml" + fixed a bug in D-Cinema
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@430 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
a389d8252a
commit
166204e2d8
@ -3,29 +3,27 @@ Subtitle Edit Changelog
|
||||
|
||||
3.2 (not yet released)
|
||||
* NEW:
|
||||
* Subtitle formats: D-Cinema, Cavena890, Timed Text 1.0, Captionate
|
||||
* Subtitle formats: D-Cinema, Cavena890, Timed Text 1.0, Captionate, Flash xml
|
||||
* Most important shortcuts in Options -> Settings
|
||||
* Export bdn-xml/images + import/ocr bdn-xml/images
|
||||
* Added "Point sync via other subtitle" - thx ioannis
|
||||
* Command line conversion between subtitle formats (example: subtitleedit /convert *.srt microdvd)
|
||||
* Added "Point sync via other subtitle" (thx ioannis)
|
||||
* Command line conversion between subtitle formats (example: subtitleedit /convert *.srt microdvd - thx Carl)
|
||||
* Subtitle preview font size (below video player) is now available in Options -> Settings
|
||||
* Edit -> Select all
|
||||
* List view context menu: Copy as text to clipboard
|
||||
* Text box context menu -> Split line at cursor position
|
||||
* Text box context menu -> Split line at cursor position (thx dr. Jackson)
|
||||
* Import+ocr of blu-ray sup files inside matroska files
|
||||
* Now remembers undocked controls pos/size
|
||||
* Transcript importer...???
|
||||
* Plug-ins...???
|
||||
* IMPROVED:
|
||||
* OCR unknown words highlighting now works better
|
||||
* OCR unknown words highlighting now works better (thx sialivi)
|
||||
* Merge short lines can now also merge lines ending with ".", "?", or "!" (optional)
|
||||
* Can now read Adobe Encore files starting with line numbers
|
||||
* Can now read Adobe Encore files starting with line numbers (thx Pier)
|
||||
* FIXED:
|
||||
* Adjust all times did not work for MicroDvd
|
||||
* Now removes empty white spaces from Google translate
|
||||
* Crash when entering invalid text in source view (thx Frédéric)
|
||||
* Fixed a few bugs in DVD Architect format + added another two new variants (thx Jacob)
|
||||
* Fixed incorrect line-break in last part of sub (thx Jacob)
|
||||
* Fixed incorrect line-break in Microsoft Translate in last part of sub (thx Jacob)
|
||||
|
||||
|
||||
3.1 (3rd March 2011)
|
||||
|
3
src/Forms/Main.Designer.cs
generated
3
src/Forms/Main.Designer.cs
generated
@ -1584,7 +1584,7 @@
|
||||
this.fixCommonErrorsInSelectedLinesToolStripMenuItem,
|
||||
this.changeCasingForSelectedLinesToolStripMenuItem});
|
||||
this.contextMenuStripListview.Name = "contextMenuStripListview";
|
||||
this.contextMenuStripListview.Size = new System.Drawing.Size(285, 606);
|
||||
this.contextMenuStripListview.Size = new System.Drawing.Size(285, 628);
|
||||
this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening);
|
||||
//
|
||||
// toolStripMenuItemDelete
|
||||
@ -1767,6 +1767,7 @@
|
||||
this.toolStripMenuItemGoogleMicrosoftTranslateSelLine.Name = "toolStripMenuItemGoogleMicrosoftTranslateSelLine";
|
||||
this.toolStripMenuItemGoogleMicrosoftTranslateSelLine.Size = new System.Drawing.Size(284, 22);
|
||||
this.toolStripMenuItemGoogleMicrosoftTranslateSelLine.Text = "Google/Microsoft translate selected line";
|
||||
this.toolStripMenuItemGoogleMicrosoftTranslateSelLine.Click += new System.EventHandler(this.toolStripMenuItemGoogleMicrosoftTranslateSelLine_Click);
|
||||
//
|
||||
// googleTranslateSelectedLinesToolStripMenuItem
|
||||
//
|
||||
|
@ -84,6 +84,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
WaveFormUnDocked _waveFormUnDocked = null;
|
||||
VideoControlsUndocked _videoControlsUnDocked = null;
|
||||
|
||||
GoogleOrMicrosoftTranslate _googleOrMicrosoftTranslate = null;
|
||||
|
||||
bool _cancelWordSpellCheck = false;
|
||||
|
||||
private bool AutoRepeatContinueOn
|
||||
@ -1692,7 +1694,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
try
|
||||
{
|
||||
string allText = _subtitle.ToText(format).Trim();
|
||||
string allText = _subtitle.ToText(format);
|
||||
var currentEncoding = GetCurrentEncoding();
|
||||
if (currentEncoding == Encoding.Default && (allText.Contains("♪") || allText.Contains("♫") | allText.Contains("♥"))) // ANSI & music/unicode symbols
|
||||
{
|
||||
@ -1744,7 +1746,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private DialogResult SaveOriginalSubtitle(SubtitleFormat format)
|
||||
{
|
||||
try
|
||||
@ -3235,6 +3236,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
showHistory.Initialize(_subtitle);
|
||||
if (showHistory.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
int selectedIndex = FirstSelectedIndex;
|
||||
_subtitleListViewIndex = -1;
|
||||
textBoxListViewText.Text = string.Empty;
|
||||
textBoxListViewTextAlternate.Text = string.Empty;
|
||||
@ -3260,8 +3262,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
_change = true;
|
||||
|
||||
if (SubtitleListview1.Items.Count > 0)
|
||||
SubtitleListview1.Items[0].Selected = true;
|
||||
if (selectedIndex >= 0 && selectedIndex < _subtitle.Paragraphs.Count)
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(selectedIndex);
|
||||
else
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -4605,29 +4609,39 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (_subtitleListViewIndex >= 0)
|
||||
{
|
||||
int firstSelectedIndex = FirstSelectedIndex;
|
||||
Paragraph oldParagraph = _subtitle.GetParagraphOrDefault(firstSelectedIndex);
|
||||
if (oldParagraph != null)
|
||||
oldParagraph = new Paragraph(oldParagraph);
|
||||
|
||||
UpdateStartTimeInfo(timeUpDownStartTime.TimeCode);
|
||||
_change = true;
|
||||
|
||||
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
|
||||
{
|
||||
int firstSelectedIndex = FirstSelectedIndex;
|
||||
Paragraph p = _subtitle.GetParagraphOrDefault(firstSelectedIndex);
|
||||
if (p != null)
|
||||
{
|
||||
Paragraph original = Utilities.GetOriginalParagraph(firstSelectedIndex, p, _subtitleAlternate.Paragraphs);
|
||||
if (original != null)
|
||||
{
|
||||
original.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds;
|
||||
original.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds;
|
||||
_changeAlternate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
UpdateOriginalTimeCodes(oldParagraph);
|
||||
|
||||
MakeHistoryForUndoWhenNoMoreChanges(string.Format(_language.StarTimeAdjustedX, "#" + (_subtitleListViewIndex+1).ToString() + ": " + timeUpDownStartTime.TimeCode.ToString()));
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateOriginalTimeCodes(Paragraph currentPargraphBeforeChange)
|
||||
{
|
||||
if (Configuration.Settings.General.AllowEditOfOriginalSubtitle && _subtitleAlternate != null && _subtitleAlternate.Paragraphs.Count > 0)
|
||||
{
|
||||
int firstSelectedIndex = FirstSelectedIndex;
|
||||
Paragraph p = _subtitle.GetParagraphOrDefault(firstSelectedIndex);
|
||||
if (currentPargraphBeforeChange != null && p != null)
|
||||
{
|
||||
Paragraph original = Utilities.GetOriginalParagraph(FirstSelectedIndex, currentPargraphBeforeChange, _subtitleAlternate.Paragraphs);
|
||||
if (original != null)
|
||||
{
|
||||
original.StartTime.TotalMilliseconds = p.StartTime.TotalMilliseconds;
|
||||
original.EndTime.TotalMilliseconds = p.EndTime.TotalMilliseconds;
|
||||
_changeAlternate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
ReloadFromSourceView();
|
||||
@ -7361,6 +7375,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBox_TextChanged;
|
||||
int index = SubtitleListview1.SelectedItems[0].Index;
|
||||
Paragraph oldParagraph = new Paragraph(_subtitle.Paragraphs[index]);
|
||||
double videoPosition = mediaPlayer.CurrentPosition;
|
||||
|
||||
timeUpDownStartTime.TimeCode = new TimeCode(TimeSpan.FromSeconds(videoPosition));
|
||||
@ -7373,7 +7388,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SubtitleListview1.SetDuration(index, _subtitle.Paragraphs[index]);
|
||||
timeUpDownStartTime.TimeCode = _subtitle.Paragraphs[index].StartTime;
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBox_TextChanged;
|
||||
|
||||
UpdateOriginalTimeCodes(oldParagraph);
|
||||
_change = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7926,6 +7942,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (SubtitleListview1.SelectedItems.Count == 1)
|
||||
{
|
||||
bool oldSync = checkBoxSyncListViewWithVideoWhilePlaying.Checked;
|
||||
checkBoxSyncListViewWithVideoWhilePlaying.Checked = false;
|
||||
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged -= MaskedTextBox_TextChanged;
|
||||
int index = SubtitleListview1.SelectedItems[0].Index;
|
||||
@ -7954,13 +7972,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_subtitleAlternate.Paragraphs[i].StartTime = new TimeCode(TimeSpan.FromMilliseconds(_subtitleAlternate.Paragraphs[i].StartTime.TotalMilliseconds - offset));
|
||||
_subtitleAlternate.Paragraphs[i].EndTime = new TimeCode(TimeSpan.FromMilliseconds(_subtitleAlternate.Paragraphs[i].EndTime.TotalMilliseconds - offset));
|
||||
}
|
||||
SaveSubtitleListviewIndexes();
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
RestoreSubtitleListviewIndexes();
|
||||
}
|
||||
}
|
||||
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBox_TextChanged;
|
||||
checkBoxSyncListViewWithVideoWhilePlaying.Checked = oldSync;
|
||||
timeUpDownStartTime.MaskedTextBox.TextChanged += MaskedTextBox_TextChanged;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10011,5 +10026,41 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Configuration.Settings.General.CurrentFrameRate = CurrentFrameRate;
|
||||
}
|
||||
|
||||
private void toolStripMenuItemGoogleMicrosoftTranslateSelLine_Click(object sender, EventArgs e)
|
||||
{
|
||||
int firstSelectedIndex = FirstSelectedIndex;
|
||||
if (firstSelectedIndex >= 0)
|
||||
{
|
||||
Paragraph p = _subtitle.GetParagraphOrDefault(firstSelectedIndex);
|
||||
Paragraph normalParagraph = p;
|
||||
if (p != null)
|
||||
{
|
||||
string defaultFromLanguage = Utilities.AutoDetectGoogleLanguage(_subtitle);
|
||||
string defaultToLanguage = defaultFromLanguage;
|
||||
if (_subtitleAlternate != null)
|
||||
{
|
||||
Paragraph o = Utilities.GetOriginalParagraph(firstSelectedIndex, p, _subtitleAlternate.Paragraphs);
|
||||
if (o != null)
|
||||
{
|
||||
p = o;
|
||||
defaultFromLanguage = Utilities.AutoDetectGoogleLanguage(_subtitleAlternate);
|
||||
}
|
||||
}
|
||||
Cursor = Cursors.WaitCursor;
|
||||
if (_googleOrMicrosoftTranslate == null || _googleOrMicrosoftTranslate.IsDisposed)
|
||||
{
|
||||
_googleOrMicrosoftTranslate = new GoogleOrMicrosoftTranslate();
|
||||
_googleOrMicrosoftTranslate.InitializeFromLanguage(defaultFromLanguage, defaultToLanguage);
|
||||
}
|
||||
_googleOrMicrosoftTranslate.Initialize(p);
|
||||
Cursor = Cursors.Default;
|
||||
if (_googleOrMicrosoftTranslate.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
textBoxListViewText.Text = _googleOrMicrosoftTranslate.TranslatedText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -577,9 +577,6 @@
|
||||
<metadata name="toolStripWaveControls.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>208, 56</value>
|
||||
</metadata>
|
||||
<metadata name="toolStripWaveControls.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>208, 56</value>
|
||||
</metadata>
|
||||
<data name="toolStripButtonWaveFormZoomOut.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
@ -687,7 +684,7 @@
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2
|
||||
CAAAAk1TRnQBSQFMAgEBAgEAAUABBQFAAQUBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||
CAAAAk1TRnQBSQFMAgEBAgEAAYgBBQGIAQUBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
|
||||
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
|
||||
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
|
||||
|
@ -34,6 +34,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public LanguageStructure.FixCommonErrors FixCommonErrors;
|
||||
public LanguageStructure.GetDictionaries GetDictionaries;
|
||||
public LanguageStructure.GoogleTranslate GoogleTranslate;
|
||||
public LanguageStructure.GoogleOrMicrosoftTranslate GoogleOrMicrosoftTranslate;
|
||||
public LanguageStructure.GoToLine GoToLine;
|
||||
public LanguageStructure.ImportText ImportText;
|
||||
public LanguageStructure.Interjections Interjections;
|
||||
@ -480,6 +481,17 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
PoweredByMicrosoftTranslate = "Powered by Microsoft translate",
|
||||
};
|
||||
|
||||
GoogleOrMicrosoftTranslate = new LanguageStructure.GoogleOrMicrosoftTranslate
|
||||
{
|
||||
Title = "Google vs Microsoft translate",
|
||||
From = "From:",
|
||||
To = "To:",
|
||||
Translate = "Translate",
|
||||
SourceText = "Source text",
|
||||
GoogleTranslate = "Google translate",
|
||||
MicrosoftTranslate = "Microsoft translate",
|
||||
};
|
||||
|
||||
GoToLine = new LanguageStructure.GoToLine
|
||||
{
|
||||
Title = "Go to subtitle number",
|
||||
|
@ -409,6 +409,17 @@
|
||||
public string PoweredByMicrosoftTranslate { get; set; }
|
||||
}
|
||||
|
||||
public class GoogleOrMicrosoftTranslate
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string From { get; set; }
|
||||
public string To { get; set; }
|
||||
public string Translate { get; set; }
|
||||
public string SourceText { get; set; }
|
||||
public string GoogleTranslate { get; set; }
|
||||
public string MicrosoftTranslate { get; set; }
|
||||
}
|
||||
|
||||
public class GoToLine
|
||||
{
|
||||
public string Title { get; set; }
|
||||
|
@ -55,20 +55,16 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
StringBuilder sb = new StringBuilder();
|
||||
lines.ForEach(line => sb.AppendLine(line));
|
||||
string xmlAsString = sb.ToString().Trim();
|
||||
if (xmlAsString.Contains("<DCSubtitle") &&
|
||||
xmlAsString.Contains("<SubtitleList"))
|
||||
if (xmlAsString.Contains("<DCSubtitle")) // && xmlAsString.Contains("<SubtitleList"))
|
||||
{
|
||||
XmlDocument xml = new XmlDocument();
|
||||
try
|
||||
{
|
||||
xml.LoadXml(xmlAsString);
|
||||
|
||||
XmlNode subtitleList = xml.DocumentElement.SelectSingleNode("SubtitleList");
|
||||
if (subtitleList != null)
|
||||
{
|
||||
var subtitles = subtitleList.SelectNodes("//Subtitle");
|
||||
var subtitles = xml.DocumentElement.SelectNodes("//Subtitle");
|
||||
if (subtitles != null)
|
||||
return subtitles != null && subtitles.Count > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -256,8 +252,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
XmlDocument xml = new XmlDocument();
|
||||
xml.LoadXml(sb.ToString());
|
||||
|
||||
XmlNode subtitleList = xml.DocumentElement.SelectSingleNode("SubtitleList");
|
||||
foreach (XmlNode node in subtitleList.SelectNodes("//Subtitle"))
|
||||
foreach (XmlNode node in xml.DocumentElement.SelectNodes("//Subtitle"))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
205
src/Logic/SubtitleFormats/FlashXml.cs
Normal file
205
src/Logic/SubtitleFormats/FlashXml.cs
Normal file
@ -0,0 +1,205 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
|
||||
//<?xml version="1.0" encoding="UTF-8"?>
|
||||
//<tt>
|
||||
// <div>
|
||||
// <p begin="00:00:00.700" end="00:00:05.000"><![CDATA[<sub>This is fully skinnable through XML<br/>using external images for each button</sub>]]></p>
|
||||
// <p begin="00:00:05.200" end="00:00:10.000"><![CDATA[<sub>You can put in any order or enable/disable<br/>the control buttons</sub>]]></p>
|
||||
// <p begin="00:00:10.200" end="00:00:15.000"><![CDATA[<sub>Test below some of the customizable<br/>properties this player has</sub>]]></p>
|
||||
// <p begin="00:00:15.200" end="00:00:19.700"><![CDATA[<sub>Many other properties related to fonts, sizes, colors<br/>and list properties are in style.css file</sub>]]></p>
|
||||
// </div>
|
||||
//</tt>
|
||||
class FlashXml : SubtitleFormat
|
||||
{
|
||||
public override string Extension
|
||||
{
|
||||
get { return ".xml"; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "Flash Xml"; }
|
||||
}
|
||||
|
||||
public override bool HasLineNumber
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override bool IsTimeBased
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override bool IsMine(List<string> lines, string fileName)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
lines.ForEach(line => sb.AppendLine(line));
|
||||
string xmlAsString = sb.ToString().Trim();
|
||||
if ((xmlAsString.Contains("<tt>") || xmlAsString.Contains("<tt ")) && (xmlAsString.Contains("<sub>")))
|
||||
{
|
||||
XmlDocument xml = new XmlDocument();
|
||||
try
|
||||
{
|
||||
xml.LoadXml(xmlAsString);
|
||||
var paragraphs = xml.DocumentElement.SelectNodes("div/p");
|
||||
return paragraphs != null && paragraphs.Count > 0 && xml.DocumentElement.Name == "tt";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static string ConvertToTimeString(TimeCode time)
|
||||
{
|
||||
return string.Format("{0:00}:{1:00}:{2:00}.{3:00}", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
|
||||
}
|
||||
|
||||
public override string ToText(Subtitle subtitle, string title)
|
||||
{
|
||||
string xmlStructure =
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + Environment.NewLine +
|
||||
"<tt>" + Environment.NewLine +
|
||||
" <div>" + Environment.NewLine +
|
||||
" </div>" + Environment.NewLine +
|
||||
"</tt>";
|
||||
|
||||
XmlDocument xml = new XmlDocument();
|
||||
xml.LoadXml(xmlStructure);
|
||||
XmlNode div = xml.DocumentElement.SelectSingleNode("div");
|
||||
int no = 0;
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
XmlNode paragraph = xml.CreateElement("p");
|
||||
string text = Utilities.RemoveHtmlTags(p.Text);
|
||||
|
||||
paragraph.InnerText = p.Text;
|
||||
paragraph.InnerXml = "<![CDATA[<sub>" + p.Text.Replace(Environment.NewLine, "<br />") + "</sub>]]>";
|
||||
|
||||
XmlAttribute start = xml.CreateAttribute("begin");
|
||||
start.InnerText = ConvertToTimeString(p.StartTime);
|
||||
paragraph.Attributes.Append(start);
|
||||
|
||||
XmlAttribute end = xml.CreateAttribute("end");
|
||||
end.InnerText = ConvertToTimeString(p.EndTime);
|
||||
paragraph.Attributes.Append(end);
|
||||
|
||||
div.AppendChild(paragraph);
|
||||
no++;
|
||||
}
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
XmlTextWriter writer = new XmlTextWriter(ms, Encoding.UTF8);
|
||||
writer.Formatting = Formatting.Indented;
|
||||
xml.Save(writer);
|
||||
return Encoding.UTF8.GetString(ms.ToArray()).Trim();
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
_errorCount = 0;
|
||||
double startSeconds = 0;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
lines.ForEach(line => sb.AppendLine(line));
|
||||
XmlDocument xml = new XmlDocument();
|
||||
xml.LoadXml(sb.ToString());
|
||||
|
||||
foreach (XmlNode node in xml.DocumentElement.SelectNodes("div/p"))
|
||||
{
|
||||
try
|
||||
{
|
||||
StringBuilder pText = new StringBuilder();
|
||||
foreach (XmlNode innerNode in node.ChildNodes)
|
||||
{
|
||||
switch (innerNode.Name.ToString())
|
||||
{
|
||||
case "br":
|
||||
pText.AppendLine();
|
||||
break;
|
||||
default:
|
||||
pText.Append(innerNode.InnerText.Trim());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string start = string.Empty;
|
||||
if (node.Attributes["begin"] != null)
|
||||
{
|
||||
start = node.Attributes["begin"].InnerText;
|
||||
}
|
||||
|
||||
string end = string.Empty;
|
||||
if (node.Attributes["end"] != null)
|
||||
{
|
||||
end = node.Attributes["end"].InnerText;
|
||||
}
|
||||
|
||||
string dur = string.Empty;
|
||||
if (node.Attributes["dur"] != null)
|
||||
{
|
||||
dur = node.Attributes["dur"].InnerText;
|
||||
}
|
||||
|
||||
TimeCode startCode = new TimeCode(TimeSpan.FromSeconds(startSeconds));
|
||||
if (start != string.Empty)
|
||||
{
|
||||
startCode = GetTimeCode(start);
|
||||
}
|
||||
|
||||
TimeCode endCode;
|
||||
if (end != string.Empty)
|
||||
{
|
||||
endCode = GetTimeCode(end);
|
||||
}
|
||||
else if (dur != string.Empty)
|
||||
{
|
||||
endCode = new TimeCode(TimeSpan.FromMilliseconds(GetTimeCode(dur).TotalMilliseconds + startCode.TotalMilliseconds));
|
||||
}
|
||||
else
|
||||
{
|
||||
endCode = new TimeCode(TimeSpan.FromMilliseconds(startCode.TotalMilliseconds + 3000));
|
||||
}
|
||||
startSeconds = endCode.TotalSeconds;
|
||||
|
||||
|
||||
subtitle.Paragraphs.Add(new Paragraph(startCode, endCode, pText.ToString().Replace("<sub>", string.Empty).Replace("</sub>", string.Empty)));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine(ex.Message);
|
||||
_errorCount++;
|
||||
}
|
||||
}
|
||||
subtitle.Renumber(1);
|
||||
}
|
||||
|
||||
private static TimeCode GetTimeCode(string s)
|
||||
{
|
||||
if (s.EndsWith("s"))
|
||||
{
|
||||
s = s.TrimEnd('s');
|
||||
TimeSpan ts = TimeSpan.FromSeconds(double.Parse(s));
|
||||
return new TimeCode(ts);
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] parts = s.Split(new char[] { ':', '.', ',' });
|
||||
TimeSpan ts = new TimeSpan(0, int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), int.Parse(parts[3]));
|
||||
return new TimeCode(ts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
new Eeg708(),
|
||||
new FinalCutProXml(),
|
||||
new FinalCutProTestXml(),
|
||||
new FlashXml(),
|
||||
new MicroDvd(),
|
||||
new MPlayer2(),
|
||||
new OpenDvt(),
|
||||
|
@ -453,6 +453,12 @@
|
||||
<Compile Include="Forms\WaveFormUnDocked.Designer.cs">
|
||||
<DependentUpon>WaveFormUnDocked.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\GoogleOrMicrosoftTranslate.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\GoogleOrMicrosoftTranslate.Designer.cs">
|
||||
<DependentUpon>GoogleOrMicrosoftTranslate.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Logic\BluRaySup\BluRaySupPalette.cs" />
|
||||
<Compile Include="Logic\BluRaySup\BluRaySupParser.cs" />
|
||||
<Compile Include="Logic\BluRaySup\BluRaySupPicture.cs" />
|
||||
@ -541,6 +547,7 @@
|
||||
<Compile Include="Logic\SubtitleFormats\Eeg708.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\FinalCutProTextXml.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\FinalCutProXml.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\FlashXml.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\Pac.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\PinnacleImpression.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\QuickTimeText.cs" />
|
||||
@ -814,6 +821,9 @@
|
||||
<EmbeddedResource Include="Forms\WaveFormUnDocked.resx">
|
||||
<DependentUpon>WaveFormUnDocked.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\GoogleOrMicrosoftTranslate.resx">
|
||||
<DependentUpon>GoogleOrMicrosoftTranslate.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
Loading…
Reference in New Issue
Block a user