mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Added new subtitle format + a minor ocr fix (with unit test)
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1067 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
a16751f951
commit
6f2c9a8d98
100
src/Forms/Main.Designer.cs
generated
100
src/Forms/Main.Designer.cs
generated
@ -101,10 +101,6 @@
|
||||
this.showHistoryforUndoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator14 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.toolStripMenuItemInsertUnicodeCharacter = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemSingleNote = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemDoubleNote = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemSmiley = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemLove = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparatorInsertUnicodeCharacter = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.findToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.findNextToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@ -197,6 +193,7 @@
|
||||
this.underlineToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.colorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemFont = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemSurroundWithMusicSymbols = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.toolStripMenuItemAutoBreakLines = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItemUnbreakLines = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@ -341,10 +338,6 @@
|
||||
this.fontNameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator26 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.toolStripMenuItemInsertUnicodeSymbol = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.labelSingleLine = new System.Windows.Forms.Label();
|
||||
this.buttonAutoBreak = new System.Windows.Forms.Button();
|
||||
this.labelTextLineLengths = new System.Windows.Forms.Label();
|
||||
@ -1061,47 +1054,10 @@
|
||||
//
|
||||
// toolStripMenuItemInsertUnicodeCharacter
|
||||
//
|
||||
this.toolStripMenuItemInsertUnicodeCharacter.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripMenuItemSingleNote,
|
||||
this.toolStripMenuItemDoubleNote,
|
||||
this.toolStripMenuItemSmiley,
|
||||
this.toolStripMenuItemLove});
|
||||
this.toolStripMenuItemInsertUnicodeCharacter.Name = "toolStripMenuItemInsertUnicodeCharacter";
|
||||
this.toolStripMenuItemInsertUnicodeCharacter.Size = new System.Drawing.Size(222, 22);
|
||||
this.toolStripMenuItemInsertUnicodeCharacter.Text = "Insert unicode character";
|
||||
//
|
||||
// toolStripMenuItemSingleNote
|
||||
//
|
||||
this.toolStripMenuItemSingleNote.Font = new System.Drawing.Font("Times New Roman", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.toolStripMenuItemSingleNote.Name = "toolStripMenuItemSingleNote";
|
||||
this.toolStripMenuItemSingleNote.Size = new System.Drawing.Size(86, 22);
|
||||
this.toolStripMenuItemSingleNote.Text = "♪";
|
||||
this.toolStripMenuItemSingleNote.Click += new System.EventHandler(this.InsertUnicodeSymbol);
|
||||
//
|
||||
// toolStripMenuItemDoubleNote
|
||||
//
|
||||
this.toolStripMenuItemDoubleNote.Font = new System.Drawing.Font("Times New Roman", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.toolStripMenuItemDoubleNote.Name = "toolStripMenuItemDoubleNote";
|
||||
this.toolStripMenuItemDoubleNote.Size = new System.Drawing.Size(86, 22);
|
||||
this.toolStripMenuItemDoubleNote.Text = "♫";
|
||||
this.toolStripMenuItemDoubleNote.Click += new System.EventHandler(this.InsertUnicodeSymbol);
|
||||
//
|
||||
// toolStripMenuItemSmiley
|
||||
//
|
||||
this.toolStripMenuItemSmiley.Font = new System.Drawing.Font("Times New Roman", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.toolStripMenuItemSmiley.Name = "toolStripMenuItemSmiley";
|
||||
this.toolStripMenuItemSmiley.Size = new System.Drawing.Size(86, 22);
|
||||
this.toolStripMenuItemSmiley.Text = "☺";
|
||||
this.toolStripMenuItemSmiley.Click += new System.EventHandler(this.InsertUnicodeSymbol);
|
||||
//
|
||||
// toolStripMenuItemLove
|
||||
//
|
||||
this.toolStripMenuItemLove.Font = new System.Drawing.Font("Times New Roman", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.toolStripMenuItemLove.Name = "toolStripMenuItemLove";
|
||||
this.toolStripMenuItemLove.Size = new System.Drawing.Size(86, 22);
|
||||
this.toolStripMenuItemLove.Text = "♥";
|
||||
this.toolStripMenuItemLove.Click += new System.EventHandler(this.InsertUnicodeSymbol);
|
||||
//
|
||||
// toolStripSeparatorInsertUnicodeCharacter
|
||||
//
|
||||
this.toolStripSeparatorInsertUnicodeCharacter.Name = "toolStripSeparatorInsertUnicodeCharacter";
|
||||
@ -1702,6 +1658,7 @@
|
||||
this.underlineToolStripMenuItem,
|
||||
this.colorToolStripMenuItem,
|
||||
this.toolStripMenuItemFont,
|
||||
this.toolStripMenuItemSurroundWithMusicSymbols,
|
||||
this.toolStripSeparator2,
|
||||
this.toolStripMenuItemAutoBreakLines,
|
||||
this.toolStripMenuItemUnbreakLines,
|
||||
@ -1717,7 +1674,7 @@
|
||||
this.fixCommonErrorsInSelectedLinesToolStripMenuItem,
|
||||
this.changeCasingForSelectedLinesToolStripMenuItem});
|
||||
this.contextMenuStripListview.Name = "contextMenuStripListview";
|
||||
this.contextMenuStripListview.Size = new System.Drawing.Size(285, 672);
|
||||
this.contextMenuStripListview.Size = new System.Drawing.Size(285, 694);
|
||||
this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening);
|
||||
//
|
||||
// setStylesForSelectedLinesToolStripMenuItem
|
||||
@ -1851,6 +1808,13 @@
|
||||
this.toolStripMenuItemFont.Text = "Font name...";
|
||||
this.toolStripMenuItemFont.Click += new System.EventHandler(this.toolStripMenuItemFont_Click);
|
||||
//
|
||||
// toolStripMenuItemSurroundWithMusicSymbols
|
||||
//
|
||||
this.toolStripMenuItemSurroundWithMusicSymbols.Name = "toolStripMenuItemSurroundWithMusicSymbols";
|
||||
this.toolStripMenuItemSurroundWithMusicSymbols.Size = new System.Drawing.Size(284, 22);
|
||||
this.toolStripMenuItemSurroundWithMusicSymbols.Text = "♪";
|
||||
this.toolStripMenuItemSurroundWithMusicSymbols.Click += new System.EventHandler(this.ToolStripMenuItemSurroundWithMusicSymbolsClick);
|
||||
//
|
||||
// toolStripSeparator2
|
||||
//
|
||||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||
@ -3228,7 +3192,7 @@
|
||||
this.toolStripSeparator26,
|
||||
this.toolStripMenuItemInsertUnicodeSymbol});
|
||||
this.contextMenuStripTextBoxListView.Name = "contextMenuStripTextBoxListView";
|
||||
this.contextMenuStripTextBoxListView.Size = new System.Drawing.Size(215, 308);
|
||||
this.contextMenuStripTextBoxListView.Size = new System.Drawing.Size(215, 330);
|
||||
this.contextMenuStripTextBoxListView.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripTextBoxListViewOpening);
|
||||
//
|
||||
// cutToolStripMenuItem
|
||||
@ -3337,43 +3301,10 @@
|
||||
//
|
||||
// toolStripMenuItemInsertUnicodeSymbol
|
||||
//
|
||||
this.toolStripMenuItemInsertUnicodeSymbol.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripMenuItem3,
|
||||
this.toolStripMenuItem4,
|
||||
this.toolStripMenuItem5,
|
||||
this.toolStripMenuItem6});
|
||||
this.toolStripMenuItemInsertUnicodeSymbol.Name = "toolStripMenuItemInsertUnicodeSymbol";
|
||||
this.toolStripMenuItemInsertUnicodeSymbol.Size = new System.Drawing.Size(214, 22);
|
||||
this.toolStripMenuItemInsertUnicodeSymbol.Text = "Insert unicode character";
|
||||
//
|
||||
// toolStripMenuItem3
|
||||
//
|
||||
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
|
||||
this.toolStripMenuItem3.Size = new System.Drawing.Size(86, 22);
|
||||
this.toolStripMenuItem3.Text = "♪";
|
||||
this.toolStripMenuItem3.Click += new System.EventHandler(this.InsertUnicodeSymbol);
|
||||
//
|
||||
// toolStripMenuItem4
|
||||
//
|
||||
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
|
||||
this.toolStripMenuItem4.Size = new System.Drawing.Size(86, 22);
|
||||
this.toolStripMenuItem4.Text = "♫";
|
||||
this.toolStripMenuItem4.Click += new System.EventHandler(this.InsertUnicodeSymbol);
|
||||
//
|
||||
// toolStripMenuItem5
|
||||
//
|
||||
this.toolStripMenuItem5.Name = "toolStripMenuItem5";
|
||||
this.toolStripMenuItem5.Size = new System.Drawing.Size(86, 22);
|
||||
this.toolStripMenuItem5.Text = "☺";
|
||||
this.toolStripMenuItem5.Click += new System.EventHandler(this.InsertUnicodeSymbol);
|
||||
//
|
||||
// toolStripMenuItem6
|
||||
//
|
||||
this.toolStripMenuItem6.Name = "toolStripMenuItem6";
|
||||
this.toolStripMenuItem6.Size = new System.Drawing.Size(86, 22);
|
||||
this.toolStripMenuItem6.Text = "♥";
|
||||
this.toolStripMenuItem6.Click += new System.EventHandler(this.InsertUnicodeSymbol);
|
||||
//
|
||||
// labelSingleLine
|
||||
//
|
||||
this.labelSingleLine.AutoSize = true;
|
||||
@ -3875,11 +3806,7 @@
|
||||
private System.Windows.Forms.ToolStripStatusLabel toolStripSelected;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertUnicodeCharacter;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparatorInsertUnicodeCharacter;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSingleNote;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemDoubleNote;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemAutoMergeShortLines;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSmiley;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemLove;
|
||||
private System.Windows.Forms.ToolStripMenuItem setMinimumDisplayTimeBetweenParagraphsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportText;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemImportTimeCodes;
|
||||
@ -4079,10 +4006,6 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem showOnlySpectrogramToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator26;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInsertUnicodeSymbol;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem6;
|
||||
private System.Windows.Forms.ToolStripMenuItem setStylesForSelectedLinesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem FindDoubleLinesToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem eBUSTLToolStripMenuItem;
|
||||
@ -4098,6 +4021,7 @@
|
||||
private System.Windows.Forms.Timer timerAlternateTextUndo;
|
||||
private System.Windows.Forms.ToolStripMenuItem adobeEncoreFABImageScriptToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemMergeDialogue;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemSurroundWithMusicSymbols;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -496,7 +496,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
int converted = 0;
|
||||
int errors = 0;
|
||||
var formats = SubtitleFormat.AllSubtitleFormats;
|
||||
string outputFileName;
|
||||
|
||||
foreach (string fileName in files)
|
||||
{
|
||||
@ -504,9 +503,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
|
||||
Encoding encoding;
|
||||
Subtitle sub = new Subtitle();
|
||||
var sub = new Subtitle();
|
||||
SubtitleFormat format = sub.LoadSubtitle(fileName, out encoding, null);
|
||||
if (format == null)
|
||||
{
|
||||
@ -573,6 +571,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
|
||||
bool targetFormatFound = false;
|
||||
string outputFileName;
|
||||
foreach (SubtitleFormat sf in formats)
|
||||
{
|
||||
if (sf.Name.ToLower().Replace(" ", string.Empty) == toFormat.ToLower())
|
||||
@ -584,13 +583,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
sub.CalculateFrameNumbersFromTimeCodesNoCheck(Configuration.Settings.General.DefaultFrameRate);
|
||||
else if (sf.IsTimeBased && sub.WasLoadedWithFrameNumbers)
|
||||
sub.CalculateTimeCodesFromFrameNumbers(Configuration.Settings.General.DefaultFrameRate);
|
||||
System.IO.File.WriteAllText(outputFileName, sub.ToText(sf), targetEncoding);
|
||||
File.WriteAllText(outputFileName, sub.ToText(sf), targetEncoding);
|
||||
if (format.GetType() == typeof(Sami))
|
||||
{
|
||||
Sami sami = (Sami)format;
|
||||
var sami = (Sami)format;
|
||||
foreach (string className in sami.GetClasses(sub))
|
||||
{
|
||||
Subtitle newSub = new Subtitle();
|
||||
var newSub = new Subtitle();
|
||||
foreach (Paragraph p in sub.Paragraphs)
|
||||
{
|
||||
if (p.Extra != null && p.Extra.ToLower().Trim() == className.ToLower().Trim())
|
||||
@ -604,7 +603,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
else
|
||||
s += "_" + className + format.Extension;
|
||||
outputFileName = FormatOutputFileNameForBatchConvert(s , sf.Extension);
|
||||
System.IO.File.WriteAllText(outputFileName, newSub.ToText(sf), targetEncoding);
|
||||
File.WriteAllText(outputFileName, newSub.ToText(sf), targetEncoding);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -920,7 +919,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void VideoPositionChanged(object sender, EventArgs e)
|
||||
{
|
||||
TimeUpDown tud = (TimeUpDown)sender;
|
||||
var tud = (TimeUpDown)sender;
|
||||
if (tud.Enabled)
|
||||
{
|
||||
mediaPlayer.CurrentPosition = tud.TimeCode.TotalSeconds;
|
||||
@ -999,18 +998,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (Environment.OSVersion.Version.Major < 6 && Configuration.Settings.General.SubtitleFontName == Utilities.WinXp2kUnicodeFontName) // 6 == Vista/Win2008Server/Win7
|
||||
{
|
||||
string unicodeFontName = Utilities.WinXp2kUnicodeFontName;
|
||||
const string unicodeFontName = Utilities.WinXp2kUnicodeFontName;
|
||||
Configuration.Settings.General.SubtitleFontName = unicodeFontName;
|
||||
float fontSize = toolStripMenuItemSingleNote.Font.Size;
|
||||
toolStripMenuItemSingleNote.Font = new System.Drawing.Font(unicodeFontName, fontSize);
|
||||
toolStripMenuItemDoubleNote.Font = new System.Drawing.Font(unicodeFontName, fontSize);
|
||||
toolStripMenuItemSmiley.Font = new System.Drawing.Font(unicodeFontName, fontSize);
|
||||
toolStripMenuItemLove.Font = new System.Drawing.Font(unicodeFontName, fontSize);
|
||||
textBoxSource.Font = new System.Drawing.Font(unicodeFontName, fontSize);
|
||||
textBoxListViewText.Font = new System.Drawing.Font(unicodeFontName, fontSize);
|
||||
SubtitleListview1.Font = new System.Drawing.Font(unicodeFontName, fontSize);
|
||||
|
||||
float fontSize = toolStripMenuItemInsertUnicodeSymbol.Font.Size;
|
||||
textBoxSource.Font = new Font(unicodeFontName, fontSize);
|
||||
textBoxListViewText.Font = new Font(unicodeFontName, fontSize);
|
||||
SubtitleListview1.Font = new Font(unicodeFontName, fontSize);
|
||||
toolStripWaveControls.RenderMode = ToolStripRenderMode.System;
|
||||
toolStripMenuItemSurroundWithMusicSymbols.Font = new Font(unicodeFontName, fontSize);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4273,6 +4268,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
toolStripMenuItemUnbreakLines.Visible = true;
|
||||
toolStripMenuItemAutoBreakLines.Visible = true;
|
||||
toolStripSeparatorBreakLines.Visible = true;
|
||||
toolStripMenuItemSurroundWithMusicSymbols.Visible = IsUnicode;
|
||||
|
||||
if (SubtitleListview1.SelectedItems.Count == 1)
|
||||
{
|
||||
@ -4882,6 +4878,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (p != null)
|
||||
{
|
||||
p.Text = Utilities.RemoveHtmlTags(p.Text);
|
||||
p.Text = p.Text.Replace("♪", string.Empty);
|
||||
if (isSsa)
|
||||
p.Text = RemoveSsaStyle(p.Text);
|
||||
SubtitleListview1.SetText(item.Index, p.Text);
|
||||
@ -4892,6 +4889,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (original != null)
|
||||
{
|
||||
original.Text = Utilities.RemoveHtmlTags(original.Text);
|
||||
original.Text = original.Text.Replace("♪", string.Empty);
|
||||
if (isSsa)
|
||||
original.Text = RemoveSsaStyle(original.Text);
|
||||
SubtitleListview1.SetAlternateText(item.Index, original.Text);
|
||||
@ -8381,33 +8379,56 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_formPositionsAndSizes.SavePositionAndSize(addToNamesList);
|
||||
}
|
||||
|
||||
private bool IsUnicode
|
||||
{
|
||||
get
|
||||
{
|
||||
var enc = GetCurrentEncoding();
|
||||
return enc == Encoding.UTF8 || enc == Encoding.Unicode || enc == Encoding.UTF7 || enc == Encoding.UTF32 || enc == Encoding.BigEndianUnicode;
|
||||
}
|
||||
}
|
||||
|
||||
private void EditToolStripMenuItemDropDownOpening(object sender, EventArgs e)
|
||||
{
|
||||
if (GetCurrentEncoding() == Encoding.Default || _subtitleListViewIndex == -1)
|
||||
if (!IsUnicode || _subtitleListViewIndex == -1)
|
||||
{
|
||||
toolStripMenuItemInsertUnicodeCharacter.Visible = false;
|
||||
toolStripSeparatorInsertUnicodeCharacter.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
toolStripMenuItemInsertUnicodeCharacter.Visible = true;
|
||||
toolStripSeparatorInsertUnicodeCharacter.Visible = true;
|
||||
if (toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Count == 0)
|
||||
{
|
||||
foreach (string s in Configuration.Settings.Tools.UnicodeSymbolsToInsert.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Add(s, null, InsertUnicodeGlyph);
|
||||
if (Environment.OSVersion.Version.Major < 6 && Configuration.Settings.General.SubtitleFontName == Utilities.WinXp2kUnicodeFontName) // 6 == Vista/Win2008Server/Win7
|
||||
toolStripMenuItemInsertUnicodeCharacter.DropDownItems[toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Count - 1].Font = new Font(Utilities.WinXp2kUnicodeFontName, toolStripMenuItemInsertUnicodeSymbol.Font.Size);
|
||||
}
|
||||
}
|
||||
toolStripMenuItemInsertUnicodeCharacter.Visible = toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Count > 0;
|
||||
toolStripSeparatorInsertUnicodeCharacter.Visible = toolStripMenuItemInsertUnicodeCharacter.DropDownItems.Count > 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void InsertUnicodeSymbol(object sender, EventArgs e)
|
||||
private void InsertUnicodeGlyph(object sender, EventArgs e)
|
||||
{
|
||||
if (tabControlSubtitle.SelectedIndex == TabControlSourceView)
|
||||
var item = sender as ToolStripItem;
|
||||
if (item != null)
|
||||
{
|
||||
string s = item.Text;
|
||||
|
||||
textBoxSource.Text = textBoxSource.Text.Insert(textBoxSource.SelectionStart, (sender as ToolStripMenuItem).Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (textBoxListViewTextAlternate.Visible && textBoxListViewTextAlternate.Enabled && textBoxListViewTextAlternate.Focused)
|
||||
textBoxListViewTextAlternate.Text = textBoxListViewTextAlternate.Text.Insert(textBoxListViewTextAlternate.SelectionStart, (sender as ToolStripMenuItem).Text);
|
||||
if (tabControlSubtitle.SelectedIndex == TabControlSourceView)
|
||||
{
|
||||
textBoxSource.Text = textBoxSource.Text.Insert(textBoxSource.SelectionStart, s);
|
||||
}
|
||||
else
|
||||
textBoxListViewText.Text = textBoxListViewText.Text.Insert(textBoxListViewText.SelectionStart, (sender as ToolStripMenuItem).Text);
|
||||
{
|
||||
if (textBoxListViewTextAlternate.Visible && textBoxListViewTextAlternate.Enabled && textBoxListViewTextAlternate.Focused)
|
||||
textBoxListViewTextAlternate.Text = textBoxListViewTextAlternate.Text.Insert(textBoxListViewTextAlternate.SelectionStart, s);
|
||||
else
|
||||
textBoxListViewText.Text = textBoxListViewText.Text.Insert(textBoxListViewText.SelectionStart, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12180,15 +12201,24 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
tb = textBoxListViewTextAlternate;
|
||||
toolStripMenuItemSplitTextAtCursor.Visible = tb.Text.Length > 5 && tb.SelectionStart > 2 && tb.SelectionStart < tb.Text.Length - 2;
|
||||
|
||||
if (GetCurrentEncoding() == Encoding.Default || _subtitleListViewIndex == -1)
|
||||
if (IsUnicode)
|
||||
{
|
||||
toolStripMenuItemInsertUnicodeSymbol.Visible = false;
|
||||
toolStripSeparator26.Visible = false;
|
||||
if (toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Count == 0)
|
||||
{
|
||||
foreach (string s in Configuration.Settings.Tools.UnicodeSymbolsToInsert.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Add(s, null, InsertUnicodeGlyph);
|
||||
if (Environment.OSVersion.Version.Major < 6 && Configuration.Settings.General.SubtitleFontName == Utilities.WinXp2kUnicodeFontName) // 6 == Vista/Win2008Server/Win7
|
||||
toolStripMenuItemInsertUnicodeSymbol.DropDownItems[toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Count - 1].Font = new Font(Utilities.WinXp2kUnicodeFontName, toolStripMenuItemInsertUnicodeSymbol.Font.Size);
|
||||
}
|
||||
}
|
||||
toolStripMenuItemInsertUnicodeSymbol.Visible = toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Count > 0;
|
||||
toolStripSeparator26.Visible = toolStripMenuItemInsertUnicodeSymbol.DropDownItems.Count > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
toolStripMenuItemInsertUnicodeSymbol.Visible = true;
|
||||
toolStripSeparator26.Visible = true;
|
||||
toolStripMenuItemInsertUnicodeSymbol.Visible = false;
|
||||
toolStripSeparator26.Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -12772,5 +12802,55 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void ToolStripMenuItemSurroundWithMusicSymbolsClick(object sender, EventArgs e)
|
||||
{
|
||||
const string tag = "♪";
|
||||
if (_subtitle.Paragraphs.Count > 0 && SubtitleListview1.SelectedItems.Count > 0)
|
||||
{
|
||||
SubtitleListview1.SelectedIndexChanged -= SubtitleListview1_SelectedIndexChanged;
|
||||
MakeHistoryForUndo(string.Format(_language.BeforeAddingTagX, tag));
|
||||
|
||||
var indexes = new List<int>();
|
||||
foreach (ListViewItem item in SubtitleListview1.SelectedItems)
|
||||
indexes.Add(item.Index);
|
||||
|
||||
SubtitleListview1.BeginUpdate();
|
||||
foreach (int i in indexes)
|
||||
{
|
||||
if (_subtitleAlternate != null)
|
||||
{
|
||||
Paragraph original = Utilities.GetOriginalParagraph(i, _subtitle.Paragraphs[i], _subtitleAlternate.Paragraphs);
|
||||
if (original != null)
|
||||
{
|
||||
if (original.Text.Contains(tag))
|
||||
{
|
||||
original.Text = original.Text.Replace(tag, string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
original.Text = string.Format("{0}{1}{0}", tag, original.Text.Replace(Environment.NewLine, "♪" + Environment.NewLine + "♪"));
|
||||
}
|
||||
SubtitleListview1.SetAlternateText(i, original.Text);
|
||||
}
|
||||
}
|
||||
|
||||
if (_subtitle.Paragraphs[i].Text.Contains(tag))
|
||||
{
|
||||
_subtitle.Paragraphs[i].Text = _subtitle.Paragraphs[i].Text.Replace("♪", string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
_subtitle.Paragraphs[i].Text = string.Format("{0}{1}{0}", tag, _subtitle.Paragraphs[i].Text.Replace(Environment.NewLine, "♪" + Environment.NewLine + "♪"));
|
||||
}
|
||||
SubtitleListview1.SetText(i, _subtitle.Paragraphs[i].Text);
|
||||
}
|
||||
SubtitleListview1.EndUpdate();
|
||||
|
||||
ShowStatus(string.Format(_language.TagXAdded, tag));
|
||||
ShowSource();
|
||||
RefreshSelectedParagraph();
|
||||
SubtitleListview1.SelectedIndexChanged += SubtitleListview1_SelectedIndexChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -680,46 +680,46 @@
|
||||
<value>
|
||||
AAEAA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gDmAJ4AnIBbQGYAngCcgFtAZIBCAOYAngCcgFtAZgCeAJy
|
||||
AW0gAAEcAcIECAJ4AewBmQIIAngB7AHzARwBwgQIAngB7AGZAggCeAHsAXUgAAGYARwBkgHtAewBCAGY
|
||||
AewB8AHvAewBCAGYAewB8wEAAZgBHAGSAe0B7AEIAZgB7AHwAe8B7AEIAZgB7AJ1JAAB7QEIAewB8wIA
|
||||
Ae0BCAHsAfMCAAR1Ae0BCAHsA3UB7QEIAewDdSQAAZIB7AHzAwABkgHsAfMDAAR1AZIB7AR1AZIB7AR1
|
||||
JAABHAH0BAABHAH0BAAEdQEcBXUBHAV1MAAQdTAAEHUgAAFCAU0BPgcAAT4DAAEoAwABQAMAARADAAEB
|
||||
AQABAQUAAYAXAAP/AQAC/wYAAv8GAAL/BgAB8wHPBgAB8QHHBgAB8AHDBwABAR8AAQEGAAHwAcMGAAHx
|
||||
AccGAAHzAc8GAAL/BgAC/wYACw==
|
||||
</value>
|
||||
</data>
|
||||
<metadata name="timerTextUndo.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
|
@ -742,7 +742,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
BeforeTimeCodeImport = "Before import of time codes",
|
||||
TimeCodeImportedFromXY = "Time codes imported from {0}: {1}",
|
||||
BeforeInsertSubtitleAtVideoPosition = "Before insert subtitle at video position",
|
||||
BeforeSetStartTimeAndOffsetTheRest = "Before set start time and offset the rest",
|
||||
BeforeSetStartTimeAndOffsetTheRest = "Before set start time and off-set the rest",
|
||||
BeforeSetEndAndVideoPosition = "Before set end time at video position and auto calculate start",
|
||||
ContinueWithCurrentSpellCheck = "Continue with current spell check?",
|
||||
CharactersPerSecond = "Chars/sec: {0:0.00}",
|
||||
@ -1000,10 +1000,10 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
Pause = "Pause",
|
||||
GoToSubtitlePositionAndPause = "Go to subposition and pause",
|
||||
SetStartTime = "Set &start time",
|
||||
SetEndTimeAndGoToNext = "Set &end && goto next",
|
||||
SetEndTimeAndGoToNext = "Set &end && go to next",
|
||||
AdjustedViaEndTime = "Adjusted via end time {0}",
|
||||
SetEndTime = "Set e&nd time",
|
||||
SetstartTimeAndOffsetOfRest = "Set sta&rt and offset the rest",
|
||||
SetstartTimeAndOffsetOfRest = "Set sta&rt and off-set the rest",
|
||||
|
||||
GoogleIt = "Google it",
|
||||
GoogleTranslate = "Google translate",
|
||||
|
@ -1285,7 +1285,9 @@ namespace Nikse.SubtitleEdit.Logic.OCR
|
||||
bool allSlashedCorrect = true;
|
||||
foreach (var slashedWord in slashedWords)
|
||||
{
|
||||
if (slashedWord.Length < 2 || !IsWordKnownOrNumber(slashedWord, line))
|
||||
if (slashedWord.Length < 2)
|
||||
allSlashedCorrect = false;
|
||||
if (allSlashedCorrect && !(DoSpell(slashedWord) || IsWordKnownOrNumber(slashedWord, line)))
|
||||
allSlashedCorrect = false;
|
||||
}
|
||||
correct = allSlashedCorrect;
|
||||
|
@ -77,6 +77,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
public int MergeLinesShorterThan { get; set; }
|
||||
public string MusicSymbol { get; set; }
|
||||
public string MusicSymbolToReplace { get; set; }
|
||||
public string UnicodeSymbolsToInsert { get; set; }
|
||||
public bool SpellCheckAutoChangeNames { get; set; }
|
||||
public bool SpellCheckOneLetterWords { get; set; }
|
||||
public bool OcrFixUseHardcodedRules { get; set; }
|
||||
@ -97,6 +98,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
MergeLinesShorterThan = 33;
|
||||
MusicSymbol = "♪";
|
||||
MusicSymbolToReplace = "⪠ⶠ♪ âTª ã¢â™âª ?t×3 ?t¤3 #";
|
||||
UnicodeSymbolsToInsert = "♪;♫;☺;☹;♥;©;☮;☯";
|
||||
SpellCheckAutoChangeNames = true;
|
||||
OcrFixUseHardcodedRules = true;
|
||||
Interjections = "Ah;Ahh;Ahhh;Eh;Ehh;Ehhh;Hm;Hmm;Hmmm;Phew;Gah;Oh;Ohh;Ohhh;Ow;Oww;Owww;Ugh;Ughh;Uh;Uhh;Uhhh;Whew";
|
||||
@ -1003,6 +1005,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
subNode = node.SelectSingleNode("MusicSymbolToReplace");
|
||||
if (subNode != null)
|
||||
settings.Tools.MusicSymbolToReplace = subNode.InnerText;
|
||||
subNode = node.SelectSingleNode("UnicodeSymbolsToInsert");
|
||||
if (subNode != null)
|
||||
settings.Tools.MusicSymbolToReplace = subNode.InnerText;
|
||||
subNode = node.SelectSingleNode("SpellCheckAutoChangeNames");
|
||||
if (subNode != null)
|
||||
settings.Tools.SpellCheckAutoChangeNames = Convert.ToBoolean(subNode.InnerText);
|
||||
@ -1646,6 +1651,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
textWriter.WriteElementString("MergeLinesShorterThan", settings.Tools.MergeLinesShorterThan.ToString());
|
||||
textWriter.WriteElementString("MusicSymbol", settings.Tools.MusicSymbol);
|
||||
textWriter.WriteElementString("MusicSymbolToReplace", settings.Tools.MusicSymbolToReplace);
|
||||
textWriter.WriteElementString("MusicSymbolToReplace", settings.Tools.UnicodeSymbolsToInsert);
|
||||
textWriter.WriteElementString("SpellCheckAutoChangeNames", settings.Tools.SpellCheckAutoChangeNames.ToString());
|
||||
textWriter.WriteElementString("SpellCheckOneLetterWords", settings.Tools.SpellCheckOneLetterWords.ToString());
|
||||
textWriter.WriteElementString("OcrFixUseHardcodedRules", settings.Tools.OcrFixUseHardcodedRules.ToString());
|
||||
|
@ -7,6 +7,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
public class PE2 : SubtitleFormat
|
||||
{
|
||||
|
||||
static readonly Regex RegexTimeCode = new Regex(@"^\d\d:\d\d:\d\d:\d\d ", RegexOptions.Compiled);
|
||||
static readonly Regex RegexTimeCodeEnd = new Regex(@"^\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled);
|
||||
|
||||
enum ExpectingLine
|
||||
{
|
||||
TimeStart,
|
||||
@ -36,7 +40,14 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
public override bool IsMine(List<string> lines, string fileName)
|
||||
{
|
||||
Subtitle subtitle = new Subtitle();
|
||||
var sb = new StringBuilder();
|
||||
foreach (string line in lines)
|
||||
sb.AppendLine(line);
|
||||
string s = sb.ToString();
|
||||
if (s.Contains("[HEADER]") && s.Contains("[BODY]"))
|
||||
return false; // UnknownSubtitle17
|
||||
|
||||
var subtitle = new Subtitle();
|
||||
LoadSubtitle(subtitle, lines, fileName);
|
||||
return subtitle.Paragraphs.Count > _errorCount;
|
||||
}
|
||||
@ -66,9 +77,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
var regexTimeCode = new Regex(@"^\d\d:\d\d:\d\d:\d\d ", RegexOptions.Compiled);
|
||||
var regexTimeCodeEnd = new Regex(@"^\d\d:\d\d:\d\d:\d\d$", RegexOptions.Compiled);
|
||||
|
||||
var paragraph = new Paragraph();
|
||||
ExpectingLine expecting = ExpectingLine.TimeStart;
|
||||
_errorCount = 0;
|
||||
@ -76,7 +84,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
subtitle.Paragraphs.Clear();
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (regexTimeCode.IsMatch(line))
|
||||
if (RegexTimeCode.IsMatch(line))
|
||||
{
|
||||
string[] parts = line.Substring(0, 11).Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length == 4)
|
||||
@ -100,7 +108,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (regexTimeCodeEnd.IsMatch(line))
|
||||
else if (RegexTimeCodeEnd.IsMatch(line))
|
||||
{
|
||||
string[] parts = line.Substring(0, 11).Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length == 4)
|
||||
|
@ -12,10 +12,12 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
public class Pac : SubtitleFormat
|
||||
{
|
||||
public static TimeCode PacNullTime = new TimeCode(7, 35, 0, 0);
|
||||
|
||||
/// <summary>
|
||||
/// Contains Swedish, Danish, German, Spanish, and French letters
|
||||
/// </summary>
|
||||
static List<int> _latinCodes = new List<int> {
|
||||
static readonly List<int> LatinCodes = new List<int> {
|
||||
0xe041, // Ã
|
||||
0xe04e, // Ñ
|
||||
0xe04f, // Õ
|
||||
@ -111,7 +113,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
0xe87a, // ż
|
||||
};
|
||||
|
||||
static List<string> _latinLetters = new List<string> {
|
||||
static readonly List<string> LatinLetters = new List<string> {
|
||||
"Ã",
|
||||
"Ñ",
|
||||
"Õ",
|
||||
@ -207,7 +209,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
"ż",
|
||||
};
|
||||
|
||||
static List<int> _hebrewCodes = new List<int>
|
||||
static readonly List<int> HebrewCodes = new List<int>
|
||||
{
|
||||
0xa0, // א
|
||||
0xa1, // ב
|
||||
@ -239,7 +241,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
};
|
||||
|
||||
static List<string> _hebrewLetters = new List<string>
|
||||
static readonly List<string> HebrewLetters = new List<string>
|
||||
{
|
||||
"א", // 0xa0
|
||||
"ב", // 0xa1
|
||||
@ -272,7 +274,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
|
||||
|
||||
static List<int> _arabicCodes = new List<int> {
|
||||
static readonly List<int> ArabicCodes = new List<int> {
|
||||
0xe081, //=أ
|
||||
0xe09b, //=ؤ
|
||||
0xe09c, //=ئ
|
||||
@ -313,7 +315,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
0xa0, //=ء
|
||||
};
|
||||
|
||||
static List<string> _arabicLetters = new List<string> {
|
||||
static readonly List<string> ArabicLetters = new List<string> {
|
||||
"أ",
|
||||
"ؤ",
|
||||
"ئ",
|
||||
@ -355,7 +357,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
};
|
||||
|
||||
|
||||
static List<int> _cyrillicCodes = new List<int> {
|
||||
static readonly List<int> CyrillicCodes = new List<int> {
|
||||
0x20, //space
|
||||
0x21, //!
|
||||
0x22, //Э
|
||||
@ -482,7 +484,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
};
|
||||
|
||||
static List<string> _cyrillicLetters = new List<string> {
|
||||
static readonly List<string> CyrillicLetters = new List<string> {
|
||||
" ", //0x20
|
||||
"!", //0x21
|
||||
"Э", //0x22
|
||||
@ -634,7 +636,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
public void Save(string fileName, Subtitle subtitle)
|
||||
{
|
||||
FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
|
||||
var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write);
|
||||
_fileName = fileName;
|
||||
|
||||
// header
|
||||
@ -657,7 +659,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
fs.WriteByte(0);
|
||||
fs.WriteByte(0x11);
|
||||
fs.WriteByte(0);
|
||||
byte[] footerBuffer = System.Text.Encoding.ASCII.GetBytes("dummy end of file");
|
||||
byte[] footerBuffer = Encoding.ASCII.GetBytes("dummy end of file");
|
||||
fs.Write(footerBuffer, 0, footerBuffer.Length);
|
||||
|
||||
fs.Close();
|
||||
@ -665,14 +667,14 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
private void WriteParagraph(FileStream fs, Paragraph p, int number, bool isLast)
|
||||
{
|
||||
WriteTimeCode(fs, p.StartTime);
|
||||
WriteTimeCode(fs, p.EndTime);
|
||||
WriteTimeCode(fs, p.StartTime, p.StartTime.TotalMilliseconds == 0 && p.Extra != null && p.Extra.Contains("(STARTFFFF0000)"));
|
||||
WriteTimeCode(fs, p.EndTime, p.EndTime.TotalMilliseconds == 0 && p.Extra != null && p.Extra.Contains("(ENDFFFF0000)"));
|
||||
|
||||
if (_codePage == -1)
|
||||
GetCodePage(null, 0, 0);
|
||||
|
||||
string text = MakePacItalicsAndRemoveOtherTags(p.Text);
|
||||
text = text.Replace(Environment.NewLine, System.Text.Encoding.Default.GetString(new byte[] { 0xfe, 0x02, 0x03 })); // fix line breaks
|
||||
text = text.Replace(Environment.NewLine, Encoding.Default.GetString(new byte[] { 0xfe, 0x02, 0x03 })); // fix line breaks
|
||||
|
||||
Encoding encoding = GetEncoding(_codePage);
|
||||
byte[] textBuffer;
|
||||
@ -688,7 +690,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
textBuffer = encoding.GetBytes(text);
|
||||
|
||||
// write text length
|
||||
UInt16 length = (UInt16)(textBuffer.Length + 4);
|
||||
var length = (UInt16)(textBuffer.Length + 4);
|
||||
fs.Write(BitConverter.GetBytes(length), 0, 2);
|
||||
|
||||
fs.WriteByte(0x0a); // sometimes 0x0b?
|
||||
@ -702,8 +704,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
if (!isLast)
|
||||
{
|
||||
fs.WriteByte(0);
|
||||
fs.WriteByte((byte)(number + 1));
|
||||
fs.WriteByte(0);
|
||||
fs.WriteByte((byte)((number + 1) % 256));
|
||||
fs.WriteByte((byte)((number + 1) / 256));
|
||||
fs.WriteByte(0x60);
|
||||
}
|
||||
}
|
||||
@ -743,13 +745,19 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
|
||||
private void WriteTimeCode(FileStream fs, TimeCode timeCode)
|
||||
private void WriteTimeCode(FileStream fs, TimeCode timeCode, bool nullTimeCode)
|
||||
{
|
||||
// write four bytes time code
|
||||
string highPart = string.Format("{0:00}", timeCode.Hours) + string.Format("{0:00}", timeCode.Minutes);
|
||||
if (timeCode.Hours == 7 && timeCode.Minutes == 35)
|
||||
highPart = "065535";
|
||||
if (nullTimeCode)
|
||||
{
|
||||
fs.WriteByte(0xff);
|
||||
fs.WriteByte(0xff);
|
||||
fs.WriteByte(0);
|
||||
fs.WriteByte(0);
|
||||
return;
|
||||
}
|
||||
|
||||
// write four bytes time code
|
||||
string highPart = string.Format("{0:00}", timeCode.Hours) + string.Format("{0:00}", timeCode.Minutes);
|
||||
byte frames = (byte)MillisecondsToFrames(timeCode.Milliseconds);
|
||||
string lowPart = string.Format("{0:00}", timeCode.Seconds) + string.Format("{0:00}", frames);
|
||||
|
||||
@ -782,7 +790,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
if (!string.IsNullOrEmpty(fileName) && File.Exists(fileName))
|
||||
{
|
||||
FileInfo fi = new FileInfo(fileName);
|
||||
var fi = new FileInfo(fileName);
|
||||
if (fi.Length > 100 && fi.Length < 1024000) // not too small or too big
|
||||
{
|
||||
byte[] buffer = File.ReadAllBytes(fileName);
|
||||
@ -859,14 +867,14 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
con = false;
|
||||
}
|
||||
|
||||
int FEIndex = index;
|
||||
int endDelimiter = 0x00;
|
||||
int feIndex = index;
|
||||
const int endDelimiter = 0x00;
|
||||
|
||||
if (_codePage == -1)
|
||||
GetCodePage(buffer, index, endDelimiter);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
index = FEIndex + 3;
|
||||
index = feIndex + 3;
|
||||
while (index < buffer.Length && buffer[index] != endDelimiter)
|
||||
{
|
||||
if (buffer[index] == 0xFF)
|
||||
@ -896,12 +904,11 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
if (index + 20 >= buffer.Length)
|
||||
return null;
|
||||
|
||||
var p = new Paragraph();
|
||||
p.Text = sb.ToString();
|
||||
var p = new Paragraph {Text = sb.ToString()};
|
||||
p.Text = FixItalics(p.Text);
|
||||
if (_codePage == 3)
|
||||
p.Text = Utilities.FixEnglishTextInRightToLeftLanguage(p.Text, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
int timeStartIndex = FEIndex - 15;
|
||||
int timeStartIndex = feIndex - 15;
|
||||
if (buffer[timeStartIndex] == 0x60)
|
||||
{
|
||||
p.StartTime = GetTimeCode(timeStartIndex + 1, buffer);
|
||||
@ -911,7 +918,18 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
timeStartIndex += 3;
|
||||
p.StartTime = GetTimeCode(timeStartIndex + 1, buffer);
|
||||
if (p.StartTime.TotalMilliseconds == 0)
|
||||
{
|
||||
p.StartTime.TotalMilliseconds = 0;
|
||||
p.Extra = "(STARTFFFF0000)";
|
||||
}
|
||||
|
||||
p.EndTime = GetTimeCode(timeStartIndex + 5, buffer);
|
||||
if (p.StartTime.TotalMilliseconds == 0 && p.EndTime.Hours == PacNullTime.Hours && p.EndTime.Minutes == Pac.PacNullTime.Minutes)
|
||||
{
|
||||
p.EndTime.TotalMilliseconds = 0;
|
||||
p.Extra = "(ENDFFFF0000)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -925,15 +943,15 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
/// </summary>
|
||||
private string FixItalics(string text)
|
||||
{
|
||||
int index = text.IndexOf("<");
|
||||
int index = text.IndexOf("<", StringComparison.Ordinal);
|
||||
if (index < 0)
|
||||
return text;
|
||||
|
||||
while (index >= 0 && index < text.Length-1)
|
||||
{
|
||||
text = text.Insert(index+1, "i>");
|
||||
int indexOfNewLine = text.IndexOf(Environment.NewLine, index);
|
||||
int indexOfEnd = text.IndexOf(">", index+3);
|
||||
int indexOfNewLine = text.IndexOf(Environment.NewLine, index, StringComparison.Ordinal);
|
||||
int indexOfEnd = text.IndexOf(">", index+3, StringComparison.Ordinal);
|
||||
if (indexOfNewLine < 0 && indexOfEnd < 0)
|
||||
{
|
||||
index = -1;
|
||||
@ -944,12 +962,12 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
if (indexOfNewLine < 0 || (indexOfEnd > 0 && indexOfEnd < indexOfNewLine))
|
||||
{
|
||||
text = text.Insert(indexOfEnd, "</i");
|
||||
index = text.IndexOf("<", indexOfEnd+3);
|
||||
index = text.IndexOf("<", indexOfEnd+3, StringComparison.Ordinal);
|
||||
}
|
||||
else
|
||||
{
|
||||
text = text.Insert(indexOfNewLine, "</i>");
|
||||
index = text.IndexOf("<", indexOfNewLine + 4);
|
||||
index = text.IndexOf("<", indexOfNewLine + 4, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1035,10 +1053,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
while (i < text.Length)
|
||||
{
|
||||
string letter = text.Substring(i, 1);
|
||||
int idx = _latinLetters.IndexOf(letter);
|
||||
int idx = LatinLetters.IndexOf(letter);
|
||||
if (idx >= 0)
|
||||
{
|
||||
int byteValue = _latinCodes[idx];
|
||||
int byteValue = LatinCodes[idx];
|
||||
if (byteValue < 256)
|
||||
{
|
||||
buffer[i + extra] = (byte)byteValue;
|
||||
@ -1076,17 +1094,17 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
|
||||
private byte[] GetArabicBytes(string text)
|
||||
{
|
||||
return GetBytesViaLists(text, _arabicLetters, _arabicCodes);
|
||||
return GetBytesViaLists(text, ArabicLetters, ArabicCodes);
|
||||
}
|
||||
|
||||
private byte[] GetHebrewBytes(string text)
|
||||
{
|
||||
return GetBytesViaLists(text, _hebrewLetters, _hebrewCodes);
|
||||
return GetBytesViaLists(text, HebrewLetters, HebrewCodes);
|
||||
}
|
||||
|
||||
private byte[] GetCyrillicBytes(string text)
|
||||
{
|
||||
return GetBytesViaLists(text, _cyrillicLetters, _cyrillicCodes);
|
||||
return GetBytesViaLists(text, CyrillicLetters, CyrillicCodes);
|
||||
}
|
||||
|
||||
private byte[] GetBytesViaLists(string text, List<string> letters, List<int> codes)
|
||||
@ -1163,17 +1181,17 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
if (b >= 0x20 && b < 0x70)
|
||||
return Encoding.ASCII.GetString(buffer, index, 1);
|
||||
|
||||
int idx = _arabicCodes.IndexOf(b);
|
||||
int idx = ArabicCodes.IndexOf(b);
|
||||
if (idx >= 0)
|
||||
return _arabicLetters[idx];
|
||||
return ArabicLetters[idx];
|
||||
|
||||
if (buffer.Length > index + 1)
|
||||
{
|
||||
idx = _arabicCodes.IndexOf(b * 256 + buffer[index + 1]);
|
||||
idx = ArabicCodes.IndexOf(b * 256 + buffer[index + 1]);
|
||||
if (idx >= 0)
|
||||
{
|
||||
index++;
|
||||
return _arabicLetters[idx];
|
||||
return ArabicLetters[idx];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1186,9 +1204,9 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
if (b >= 0x20 && b < 0x70)
|
||||
return Encoding.ASCII.GetString(buffer, index, 1);
|
||||
|
||||
int idx = _hebrewCodes.IndexOf(b);
|
||||
int idx = HebrewCodes.IndexOf(b);
|
||||
if (idx >= 0)
|
||||
return _hebrewLetters[idx];
|
||||
return HebrewLetters[idx];
|
||||
|
||||
return string.Format("({0})", b);
|
||||
}
|
||||
@ -1197,17 +1215,17 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
byte b = buffer[index];
|
||||
|
||||
int idx = _latinCodes.IndexOf(b);
|
||||
int idx = LatinCodes.IndexOf(b);
|
||||
if (idx >= 0)
|
||||
return _latinLetters[idx];
|
||||
return LatinLetters[idx];
|
||||
|
||||
if (buffer.Length > index + 1)
|
||||
{
|
||||
idx = _latinCodes.IndexOf(b * 256 + buffer[index + 1]);
|
||||
idx = LatinCodes.IndexOf(b * 256 + buffer[index + 1]);
|
||||
if (idx >= 0)
|
||||
{
|
||||
index++;
|
||||
return _latinLetters[idx];
|
||||
return LatinLetters[idx];
|
||||
}
|
||||
}
|
||||
|
||||
@ -1221,17 +1239,17 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
if (b >= 0x30 && b <= 0x39) // numbers
|
||||
return Encoding.ASCII.GetString(buffer, index, 1);
|
||||
|
||||
int idx = _cyrillicCodes.IndexOf(b);
|
||||
int idx = CyrillicCodes.IndexOf(b);
|
||||
if (idx >= 0)
|
||||
return _cyrillicLetters[idx];
|
||||
return CyrillicLetters[idx];
|
||||
|
||||
if (buffer.Length > index + 1)
|
||||
{
|
||||
idx = _cyrillicCodes.IndexOf(b * 256 + buffer[index + 1]);
|
||||
idx = CyrillicCodes.IndexOf(b * 256 + buffer[index + 1]);
|
||||
if (idx >= 0)
|
||||
{
|
||||
index++;
|
||||
return _cyrillicLetters[idx];
|
||||
return CyrillicLetters[idx];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,6 +96,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
new UnknownSubtitle14(),
|
||||
new UnknownSubtitle15(),
|
||||
new UnknownSubtitle16(),
|
||||
new UnknownSubtitle17(),
|
||||
new UTSubtitleXml(),
|
||||
new Utx(),
|
||||
new UtxFrames(),
|
||||
|
194
src/Logic/SubtitleFormats/UnknownSubtitle17.cs
Normal file
194
src/Logic/SubtitleFormats/UnknownSubtitle17.cs
Normal file
@ -0,0 +1,194 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
public class UnknownSubtitle17 : SubtitleFormat
|
||||
{
|
||||
|
||||
static readonly Regex RegexTimeCode = new Regex(@"^\d\d:\d\d:\d\d:\d\d", RegexOptions.Compiled);
|
||||
static readonly Regex RegexNumber = new Regex(@"^\[\d+\]$", RegexOptions.Compiled);
|
||||
|
||||
enum ExpectingLine
|
||||
{
|
||||
Number,
|
||||
TimeStart,
|
||||
TimeEnd,
|
||||
Text
|
||||
}
|
||||
|
||||
public override string Extension
|
||||
{
|
||||
get { return ".txt"; }
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get { return "Unknown 17"; }
|
||||
}
|
||||
|
||||
public override bool HasLineNumber
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override bool IsTimeBased
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override bool IsMine(List<string> lines, string fileName)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
foreach (string line in lines)
|
||||
sb.AppendLine(line);
|
||||
string s = sb.ToString();
|
||||
if (!s.Contains("[HEADER]") || !s.Contains("[BODY]"))
|
||||
return false;
|
||||
|
||||
var subtitle = new Subtitle();
|
||||
LoadSubtitle(subtitle, lines, fileName);
|
||||
return subtitle.Paragraphs.Count > _errorCount;
|
||||
}
|
||||
|
||||
public override string ToText(Subtitle subtitle, string title)
|
||||
{
|
||||
//[1]
|
||||
//01:00:21:20
|
||||
//01:00:23:17
|
||||
//[I]Pysy kanavalla,
|
||||
//[I]koska myöhemmin tänään
|
||||
|
||||
const string paragraphWriteFormat = "[{4}]{3}{0}{3}{1}{3}{2}";
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine(@"[HEADER]
|
||||
SUBTITLING_COMPANY=Softitler Net, Inc.
|
||||
TIME_FORMAT=NTSC
|
||||
CLIENT=UNIVERSAL
|
||||
LANGUAGE=Finnish
|
||||
DATE=5/28/2007
|
||||
JOB_ID=89972
|
||||
JOB_TYPE=Feature
|
||||
TITLE=Notting Hill
|
||||
SUBNAME=BD TRTL
|
||||
YEAR=1999
|
||||
DIGITAL_CINEMA=YES
|
||||
[/HEADER]
|
||||
[BODY]");
|
||||
int count = 0;
|
||||
foreach (Paragraph p in subtitle.Paragraphs)
|
||||
{
|
||||
count++;
|
||||
string text = p.Text.Replace("<i>", "[I]").Replace("</i>", "[/I]");
|
||||
sb.AppendLine(string.Format(paragraphWriteFormat, EncodeTimeCode(p.StartTime), EncodeTimeCode(p.EndTime), text, Environment.NewLine, count));
|
||||
}
|
||||
sb.AppendLine("[/BODY]");
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
Paragraph paragraph = null;
|
||||
ExpectingLine expecting = ExpectingLine.Number;
|
||||
_errorCount = 0;
|
||||
|
||||
subtitle.Paragraphs.Clear();
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (RegexNumber.IsMatch(line))
|
||||
{
|
||||
if (paragraph != null)
|
||||
subtitle.Paragraphs.Add(paragraph);
|
||||
paragraph = new Paragraph();
|
||||
expecting = ExpectingLine.TimeStart;
|
||||
}
|
||||
else if (paragraph != null && expecting == ExpectingLine.TimeStart && RegexTimeCode.IsMatch(line))
|
||||
{
|
||||
string[] parts = line.Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length == 4)
|
||||
{
|
||||
try
|
||||
{
|
||||
var tc = DecodeTimeCode(parts);
|
||||
paragraph.StartTime = tc;
|
||||
expecting = ExpectingLine.TimeEnd;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_errorCount++;
|
||||
expecting = ExpectingLine.Number;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (paragraph != null && expecting == ExpectingLine.TimeEnd && RegexTimeCode.IsMatch(line))
|
||||
{
|
||||
string[] parts = line.Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if (parts.Length == 4)
|
||||
{
|
||||
try
|
||||
{
|
||||
var tc = DecodeTimeCode(parts);
|
||||
paragraph.EndTime = tc;
|
||||
expecting = ExpectingLine.Text;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_errorCount++;
|
||||
expecting = ExpectingLine.Number;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (paragraph != null && expecting == ExpectingLine.Text)
|
||||
{
|
||||
if (line.Length > 0)
|
||||
{
|
||||
string s = line;
|
||||
if (line.ToLower().StartsWith("[i]"))
|
||||
{
|
||||
s = "<i>" + s.Remove(0, 3);
|
||||
if (s.ToLower().EndsWith("[/i]"))
|
||||
s = s.Remove(s.Length - 4, 4);
|
||||
s += "</i>";
|
||||
}
|
||||
s = s.Replace("[I]", "<i>");
|
||||
s = s.Replace("[/I]", "</i>");
|
||||
s = s.Replace("[P]", string.Empty);
|
||||
s = s.Replace("[/P]", string.Empty);
|
||||
paragraph.Text = (paragraph.Text + Environment.NewLine + s).Trim();
|
||||
if (paragraph.Text.Length > 2000)
|
||||
{
|
||||
_errorCount += 100;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
subtitle.Renumber(1);
|
||||
}
|
||||
|
||||
private string EncodeTimeCode(TimeCode time)
|
||||
{
|
||||
return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, MillisecondsToFrames(time.Milliseconds));
|
||||
}
|
||||
|
||||
private TimeCode DecodeTimeCode(string[] parts)
|
||||
{
|
||||
string hour = parts[0];
|
||||
string minutes = parts[1];
|
||||
string seconds = parts[2];
|
||||
string frames = parts[3];
|
||||
|
||||
var milliseconds = (int)((1000.0 / Configuration.Settings.General.CurrentFrameRate) * int.Parse(frames));
|
||||
if (milliseconds > 999)
|
||||
milliseconds = 999;
|
||||
|
||||
return new TimeCode(int.Parse(hour), int.Parse(minutes), int.Parse(seconds), milliseconds);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -638,6 +638,7 @@
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle14.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle15.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle16.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle17.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\UnknownSubtitle5.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\OpenDvt.cs" />
|
||||
<Compile Include="Logic\SubtitleFormats\AbcIViewer.cs" />
|
||||
|
@ -9,38 +9,25 @@ namespace Test
|
||||
///This is a test class for FixCommonErrors and is intended
|
||||
///to contain all FixCommonErrorsTest Unit Tests
|
||||
///</summary>
|
||||
[TestClass()]
|
||||
[TestClass]
|
||||
public class FixCommonErrorsTest
|
||||
{
|
||||
|
||||
private TestContext testContextInstance;
|
||||
|
||||
/// <summary>
|
||||
///Gets or sets the test context which provides
|
||||
///information about and functionality for the current test run.
|
||||
///</summary>
|
||||
public TestContext TestContext
|
||||
{
|
||||
get
|
||||
{
|
||||
return testContextInstance;
|
||||
}
|
||||
set
|
||||
{
|
||||
testContextInstance = value;
|
||||
}
|
||||
}
|
||||
public TestContext TestContext { get; set; }
|
||||
|
||||
private static void InitializeFixCommonErrorsLine(FixCommonErrors_Accessor target, string line)
|
||||
{
|
||||
Subtitle subtitle = new Subtitle();
|
||||
var subtitle = new Subtitle();
|
||||
subtitle.Paragraphs.Add(new Paragraph(line, 100, 10000));
|
||||
target.Initialize(subtitle, new Nikse.SubtitleEdit.Logic.SubtitleFormats.SubRip());
|
||||
}
|
||||
|
||||
private static void InitializeFixCommonErrorsLine(FixCommonErrors_Accessor target, string line, string line2)
|
||||
{
|
||||
Subtitle subtitle = new Subtitle();
|
||||
var subtitle = new Subtitle();
|
||||
subtitle.Paragraphs.Add(new Paragraph(line, 100, 10000));
|
||||
subtitle.Paragraphs.Add(new Paragraph(line2, 10001, 30000));
|
||||
target.Initialize(subtitle, new Nikse.SubtitleEdit.Logic.SubtitleFormats.SubRip());
|
||||
@ -77,51 +64,51 @@ namespace Test
|
||||
#endregion
|
||||
|
||||
#region Merge short lines
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixShortLinesNormal()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "This is" + Environment.NewLine + "short!");
|
||||
target.FixShortLines();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "This is short!");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixShortLinesLong()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "This I'm pretty sure is not a" + Environment.NewLine + "short line, that should be merged!!!");
|
||||
target.FixShortLines();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "This I'm pretty sure is not a" + Environment.NewLine + "short line, that should be merged!!!");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixShortLinesNormalItalic()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "<i>This is" + Environment.NewLine + "short!</i>");
|
||||
target.FixShortLines();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "<i>This is short!</i>");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixShortLinesDialogue()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "- Hallo!" + Environment.NewLine + "- Hi");
|
||||
target.FixShortLines();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "- Hallo!" + Environment.NewLine + "- Hi");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixShortLinesDialogueItalic()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "<i>- Hallo!" + Environment.NewLine + "- Hi</i>");
|
||||
target.FixShortLines();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "<i>- Hallo!" + Environment.NewLine + "- Hi</i>");
|
||||
@ -131,11 +118,11 @@ namespace Test
|
||||
/// <summary>
|
||||
///A test for Merge short lines
|
||||
///</summary>
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixShortLinesDialogueItalicTwo()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "<i>- Hallo!</i>" + Environment.NewLine + "<i>- Hi<i>");
|
||||
target.FixShortLines();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "<i>- Hallo!</i>" + Environment.NewLine + "<i>- Hi<i>");
|
||||
@ -143,91 +130,91 @@ namespace Test
|
||||
#endregion
|
||||
|
||||
#region Fix Italics
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixItalicsBeginOnly()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "<i>Hey!" + Environment.NewLine + "<i>Boy!");
|
||||
target.FixInvalidItalicTags();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "<i>Hey!</i>" + Environment.NewLine + "<i>Boy!</i>");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixItalicsFirstLineEndMissing()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "<i>(jones) seems their attackers headed north." + Environment.NewLine + "<i>Hi!</i>");
|
||||
target.FixInvalidItalicTags();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "<i>(jones) seems their attackers headed north." + Environment.NewLine + "Hi!</i>");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixItalicsStartInMiddle()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "Seems their <i>attackers headed north.");
|
||||
target.FixInvalidItalicTags();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "Seems their attackers headed north.");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixItalicsEmptyStart()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "<i></i>test");
|
||||
target.FixInvalidItalicTags();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "test");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixItalicsSecondLineMissingEnd()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "- And..." + Environment.NewLine + "<i>Awesome it is!");
|
||||
target.FixInvalidItalicTags();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "- And..." + Environment.NewLine + "<i>Awesome it is!</i>");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixItalicsBadEnding()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "Awesome it is!</i>");
|
||||
target.FixInvalidItalicTags();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "Awesome it is!");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixItalicsBadEnding2()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "Awesome it is!<i></i>");
|
||||
target.FixInvalidItalicTags();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "Awesome it is!");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixItalicsBadEnding3()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "Awesome it is!<i>");
|
||||
target.FixInvalidItalicTags();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "Awesome it is!");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixItalicsBadEnding4()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "Awesome it is!</i><i>");
|
||||
target.FixInvalidItalicTags();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "Awesome it is!");
|
||||
@ -235,36 +222,72 @@ namespace Test
|
||||
#endregion
|
||||
|
||||
#region Fix Missing Periods At End Of Line
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixMissingPeriodsAtEndOfLineNone()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "This is line one!" + Environment.NewLine + "<i>Boy!</i>", "This is line one!" + Environment.NewLine + "<i>Boy!</i>");
|
||||
target.FixMissingPeriodsAtEndOfLine();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "This is line one!" + Environment.NewLine + "<i>Boy!</i>");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixMissingPeriodsAtEndOfLineItalicAndMissing()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "This is line one!" + Environment.NewLine + "<i>Boy</i>", "This is line one!" + Environment.NewLine + "<i>Boy!</i>");
|
||||
target.FixMissingPeriodsAtEndOfLine();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "This is line one!" + Environment.NewLine + "<i>Boy.</i>");
|
||||
}
|
||||
|
||||
[TestMethod()]
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixMissingPeriodsAtEndOfLineItalicAndMissing2()
|
||||
{
|
||||
FixCommonErrors_Accessor target = new FixCommonErrors_Accessor();
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "<i>This is line one!" + Environment.NewLine + "Boy</i>", "This is line one!" + Environment.NewLine + "<i>Boy!</i>");
|
||||
target.FixMissingPeriodsAtEndOfLine();
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "<i>This is line one!" + Environment.NewLine + "Boy.</i>");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Fix OCR errors
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixCommonOcrErrorsSlashMakesTwoWords()
|
||||
{
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "(laughing/clapping)");
|
||||
target.FixOcrErrorsViaReplaceList("eng");
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "(laughing/clapping)");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixCommonOcrErrorsSlashIsL()
|
||||
{
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "The font is ita/ic!");
|
||||
target.FixOcrErrorsViaReplaceList("eng");
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "The font is italic!");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DeploymentItem("SubtitleEdit.exe")]
|
||||
public void FixCommonOcrErrorsDashedWords()
|
||||
{
|
||||
var target = new FixCommonErrors_Accessor();
|
||||
InitializeFixCommonErrorsLine(target, "The clock is 12 a.m.");
|
||||
target.FixOcrErrorsViaReplaceList("eng");
|
||||
Assert.AreEqual(target._subtitle.Paragraphs[0].Text, "The clock is 12 a.m.");
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
BIN
src/Test/Hunspellx86.dll
Normal file
BIN
src/Test/Hunspellx86.dll
Normal file
Binary file not shown.
@ -73,6 +73,11 @@
|
||||
<Name>SubtitleEdit</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Hunspellx86.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
Loading…
Reference in New Issue
Block a user