More work on "Fix common errors" - thx Majid :)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1007 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2012-02-26 20:25:20 +00:00
parent dc56b2d8fd
commit 404cfc6940
2 changed files with 129 additions and 129 deletions

View File

@ -323,13 +323,13 @@ namespace Nikse.SubtitleEdit.Forms
listView1.Items.Add(item); listView1.Items.Add(item);
} }
private void AddFixToListView(Paragraph p, int lineNumber, string action, string before, string after) private void AddFixToListView(Paragraph p, string action, string before, string after)
{ {
if (_onlyListFixes) if (_onlyListFixes)
{ {
var item = new ListViewItem(string.Empty) { Checked = true }; var item = new ListViewItem(string.Empty) { Checked = true };
var subItem = new ListViewItem.ListViewSubItem(item, lineNumber.ToString()); var subItem = new ListViewItem.ListViewSubItem(item, p.Number.ToString());
item.SubItems.Add(subItem); item.SubItems.Add(subItem);
subItem = new ListViewItem.ListViewSubItem(item, action); subItem = new ListViewItem.ListViewSubItem(item, action);
item.SubItems.Add(subItem); item.SubItems.Add(subItem);
@ -344,14 +344,14 @@ namespace Nikse.SubtitleEdit.Forms
} }
} }
public bool AllowFix(int lineNumber, string action) public bool AllowFix(Paragraph p, string action)
{ {
//if (!buttonBack.Enabled) //if (!buttonBack.Enabled)
if (_onlyListFixes) if (_onlyListFixes)
return true; return true;
string ln = lineNumber.ToString(); string ln = p.Number.ToString();
foreach (ListViewItem item in listViewFixes.Items) foreach (ListViewItem item in listViewFixes.Items)
{ {
if (item.SubItems[1].Text == ln && item.SubItems[2].Text == action) if (item.SubItems[1].Text == ln && item.SubItems[2].Text == action)
@ -412,22 +412,20 @@ namespace Nikse.SubtitleEdit.Forms
string text = p.Text.Trim(' '); string text = p.Text.Trim(' ');
if (text.StartsWith(Environment.NewLine)) if (text.StartsWith(Environment.NewLine))
{ {
if (AllowFix(i + 1, fixAction1)) if (AllowFix(p, fixAction1))
{ {
p.Text = text.TrimStart(Environment.NewLine.ToCharArray()); p.Text = text.TrimStart(Environment.NewLine.ToCharArray());
emptyLinesRemoved++; emptyLinesRemoved++;
AddFixToListView(p, i + 1, fixAction1, p.Text, text); AddFixToListView(p, fixAction1, p.Text, text);
} }
} }
if (text.EndsWith(Environment.NewLine)) if (text.EndsWith(Environment.NewLine))
{ {
if (AllowFix(i + 1, fixAction2)) if (AllowFix(p, fixAction2))
{ {
p.Text = text.TrimEnd(Environment.NewLine.ToCharArray()); p.Text = text.TrimEnd(Environment.NewLine.ToCharArray());
emptyLinesRemoved++; emptyLinesRemoved++;
AddFixToListView(p, i + 1, fixAction2, p.Text, text); AddFixToListView(p, fixAction2, p.Text, text);
} }
} }
} }
@ -439,11 +437,11 @@ namespace Nikse.SubtitleEdit.Forms
Paragraph p = _subtitle.Paragraphs[i]; Paragraph p = _subtitle.Paragraphs[i];
if (p.Text.Trim().Length == 0) if (p.Text.Trim().Length == 0)
{ {
if (AllowFix(i + 1, fixAction0)) if (AllowFix(p, fixAction0))
{ {
_subtitle.Paragraphs.RemoveAt(i); _subtitle.Paragraphs.RemoveAt(i);
emptyLinesRemoved++; emptyLinesRemoved++;
AddFixToListView(p, i + 1, fixAction0, p.Text, string.Format("[{0}]", _language.RemovedEmptyLine)); AddFixToListView(p, fixAction0, p.Text, string.Format("[{0}]", _language.RemovedEmptyLine));
_deleteIndices.Add(i); _deleteIndices.Add(i);
} }
} }
@ -479,7 +477,7 @@ namespace Nikse.SubtitleEdit.Forms
if (next == null || next.StartTime.TotalMilliseconds > p.StartTime.TotalMilliseconds + wantedDisplayTime) if (next == null || next.StartTime.TotalMilliseconds > p.StartTime.TotalMilliseconds + wantedDisplayTime)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + wantedDisplayTime; p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + wantedDisplayTime;
isFixed = true; isFixed = true;
@ -487,7 +485,7 @@ namespace Nikse.SubtitleEdit.Forms
} }
else if (next.StartTime.TotalMilliseconds > p.StartTime.TotalMilliseconds + 500.0) else if (next.StartTime.TotalMilliseconds > p.StartTime.TotalMilliseconds + 500.0)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 500.0; p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 500.0;
isFixed = true; isFixed = true;
@ -495,7 +493,7 @@ namespace Nikse.SubtitleEdit.Forms
} }
else if (prev == null || next.StartTime.TotalMilliseconds - wantedDisplayTime > prev.EndTime.TotalMilliseconds) else if (prev == null || next.StartTime.TotalMilliseconds - wantedDisplayTime > prev.EndTime.TotalMilliseconds)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
p.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - wantedDisplayTime; p.StartTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - wantedDisplayTime;
p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1; p.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - 1;
@ -515,7 +513,7 @@ namespace Nikse.SubtitleEdit.Forms
noOfOverlappingDisplayTimesFixed++; noOfOverlappingDisplayTimesFixed++;
status = string.Format(_language.XFixedToYZ, status, Environment.NewLine, p); status = string.Format(_language.XFixedToYZ, status, Environment.NewLine, p);
LogStatus(_language.FixOverlappingDisplayTimes, status); LogStatus(_language.FixOverlappingDisplayTimes, status);
AddFixToListView(p, i + 1, fixAction, oldP.ToString(), p.ToString()); AddFixToListView(p, fixAction, oldP.ToString(), p.ToString());
} }
} }
} }
@ -539,19 +537,19 @@ namespace Nikse.SubtitleEdit.Forms
{ {
if (prevWantedDisplayTime <= (p.StartTime.TotalMilliseconds - prev.StartTime.TotalMilliseconds)) if (prevWantedDisplayTime <= (p.StartTime.TotalMilliseconds - prev.StartTime.TotalMilliseconds))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
prev.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds - 1; prev.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds - 1;
if (canBeEqual) if (canBeEqual)
prev.EndTime.TotalMilliseconds++; prev.EndTime.TotalMilliseconds++;
_totalFixes++; _totalFixes++;
noOfOverlappingDisplayTimesFixed++; noOfOverlappingDisplayTimesFixed++;
AddFixToListView(target, i + 1, fixAction, oldPrevious, prev.ToString()); AddFixToListView(target, fixAction, oldPrevious, prev.ToString());
} }
} }
else if (currentWantedDisplayTime <= p.EndTime.TotalMilliseconds - prev.EndTime.TotalMilliseconds) else if (currentWantedDisplayTime <= p.EndTime.TotalMilliseconds - prev.EndTime.TotalMilliseconds)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
p.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1; p.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1;
if (canBeEqual) if (canBeEqual)
@ -559,12 +557,12 @@ namespace Nikse.SubtitleEdit.Forms
_totalFixes++; _totalFixes++;
noOfOverlappingDisplayTimesFixed++; noOfOverlappingDisplayTimesFixed++;
AddFixToListView(p, i + 1, fixAction, oldCurrent, p.ToString()); AddFixToListView(p, fixAction, oldCurrent, p.ToString());
} }
} }
else if (Math.Abs(p.StartTime.TotalMilliseconds - prev.EndTime.TotalMilliseconds) < 10 && p.Duration.TotalMilliseconds > 1) else if (Math.Abs(p.StartTime.TotalMilliseconds - prev.EndTime.TotalMilliseconds) < 10 && p.Duration.TotalMilliseconds > 1)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
prev.EndTime.TotalMilliseconds -= 2; prev.EndTime.TotalMilliseconds -= 2;
p.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1; p.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1;
@ -572,12 +570,12 @@ namespace Nikse.SubtitleEdit.Forms
p.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds; p.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds;
_totalFixes++; _totalFixes++;
noOfOverlappingDisplayTimesFixed++; noOfOverlappingDisplayTimesFixed++;
AddFixToListView(p, i + 1, fixAction, oldCurrent, p.ToString()); AddFixToListView(p, fixAction, oldCurrent, p.ToString());
} }
} }
else if (Math.Abs(p.StartTime.TotalMilliseconds - prev.StartTime.TotalMilliseconds) < 10 && Math.Abs(p.EndTime.TotalMilliseconds - prev.EndTime.TotalMilliseconds) < 10) else if (Math.Abs(p.StartTime.TotalMilliseconds - prev.StartTime.TotalMilliseconds) < 10 && Math.Abs(p.EndTime.TotalMilliseconds - prev.EndTime.TotalMilliseconds) < 10)
{ // merge lines with same time codes { // merge lines with same time codes
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
prev.Text = prev.Text.Replace(Environment.NewLine, " "); prev.Text = prev.Text.Replace(Environment.NewLine, " ");
p.Text = p.Text.Replace(Environment.NewLine, " "); p.Text = p.Text.Replace(Environment.NewLine, " ");
@ -594,7 +592,7 @@ namespace Nikse.SubtitleEdit.Forms
p.Text = string.Empty; p.Text = string.Empty;
_totalFixes++; _totalFixes++;
noOfOverlappingDisplayTimesFixed++; noOfOverlappingDisplayTimesFixed++;
AddFixToListView(target, i + 1, fixAction, oldCurrent, p.ToString()); AddFixToListView(target, fixAction, oldCurrent, p.ToString());
p.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1; p.StartTime.TotalMilliseconds = prev.EndTime.TotalMilliseconds + 1;
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 1; p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + 1;
@ -607,7 +605,7 @@ namespace Nikse.SubtitleEdit.Forms
} }
else else
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
LogStatus(_language.FixOverlappingDisplayTimes, string.Format(_language.UnableToFixTextXY, i + 1, Environment.NewLine + prev.Number + " " + prev + Environment.NewLine + p.Number + " " + p), true); LogStatus(_language.FixOverlappingDisplayTimes, string.Format(_language.UnableToFixTextXY, i + 1, Environment.NewLine + prev.Number + " " + prev + Environment.NewLine + p.Number + " " + p), true);
_totalErrors++; _totalErrors++;
@ -636,13 +634,13 @@ namespace Nikse.SubtitleEdit.Forms
Paragraph next = _subtitle.GetParagraphOrDefault(i + 1); Paragraph next = _subtitle.GetParagraphOrDefault(i + 1);
if (next == null || (p.StartTime.TotalMilliseconds + Utilities.GetDisplayMillisecondsFromText(p.Text)) < next.StartTime.TotalMilliseconds) if (next == null || (p.StartTime.TotalMilliseconds + Utilities.GetDisplayMillisecondsFromText(p.Text)) < next.StartTime.TotalMilliseconds)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldCurrent = p.ToString(); string oldCurrent = p.ToString();
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetDisplayMillisecondsFromText(p.Text); p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetDisplayMillisecondsFromText(p.Text);
_totalFixes++; _totalFixes++;
noOfShortDisplayTimes++; noOfShortDisplayTimes++;
AddFixToListView(p, i + 1, fixAction, oldCurrent, p.ToString()); AddFixToListView(p, fixAction, oldCurrent, p.ToString());
} }
} }
else else
@ -670,12 +668,12 @@ namespace Nikse.SubtitleEdit.Forms
text = Utilities.FixInvalidItalicTags(text); text = Utilities.FixInvalidItalicTags(text);
if (text != oldText) if (text != oldText)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(_subtitle.Paragraphs[i], fixAction))
{ {
_subtitle.Paragraphs[i].Text = text; _subtitle.Paragraphs[i].Text = text;
_totalFixes++; _totalFixes++;
noOfInvalidHtmlTags++; noOfInvalidHtmlTags++;
AddFixToListView(_subtitle.Paragraphs[i], i + 1, fixAction, oldText, text); AddFixToListView(_subtitle.Paragraphs[i], fixAction, oldText, text);
} }
} }
@ -695,14 +693,14 @@ namespace Nikse.SubtitleEdit.Forms
double displayTime = p.Duration.TotalMilliseconds; double displayTime = p.Duration.TotalMilliseconds;
if (maxDisplayTime < displayTime) if (maxDisplayTime < displayTime)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldCurrent = p.ToString(); string oldCurrent = p.ToString();
displayTime = Utilities.GetDisplayMillisecondsFromText(p.Text) * 2.0; displayTime = Utilities.GetDisplayMillisecondsFromText(p.Text) * 2.0;
p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + displayTime; p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + displayTime;
_totalFixes++; _totalFixes++;
noOfLongDisplayTimes++; noOfLongDisplayTimes++;
AddFixToListView(p, i + 1, fixAction, oldCurrent, p.ToString()); AddFixToListView(p, fixAction, oldCurrent, p.ToString());
} }
} }
} }
@ -728,7 +726,7 @@ namespace Nikse.SubtitleEdit.Forms
} }
if (tooLong) if (tooLong)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = Utilities.AutoBreakLine(p.Text); p.Text = Utilities.AutoBreakLine(p.Text);
@ -736,7 +734,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
_totalFixes++; _totalFixes++;
noOfLongLines++; noOfLongLines++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
else else
{ {
@ -771,7 +769,7 @@ namespace Nikse.SubtitleEdit.Forms
!s.Contains("-") && !s.Contains("-") &&
p.Text != p.Text.ToUpper()) p.Text != p.Text.ToUpper())
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
s = p.Text.Replace(Environment.NewLine, " "); s = p.Text.Replace(Environment.NewLine, " ");
s = s.Replace(" ", " "); s = s.Replace(" ", " ");
@ -780,7 +778,7 @@ namespace Nikse.SubtitleEdit.Forms
p.Text = s; p.Text = s;
_totalFixes++; _totalFixes++;
noOfShortLines++; noOfShortLines++;
AddFixToListView(p, i + 1, fixAction, oldCurrent, p.Text); AddFixToListView(p, fixAction, oldCurrent, p.Text);
} }
} }
} }
@ -803,13 +801,13 @@ namespace Nikse.SubtitleEdit.Forms
s = Utilities.AutoBreakLine(p.Text); s = Utilities.AutoBreakLine(p.Text);
if (s != p.Text) if (s != p.Text)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldCurrent = p.Text; string oldCurrent = p.Text;
p.Text = s; p.Text = s;
_totalFixes++; _totalFixes++;
noOfShortLines++; noOfShortLines++;
AddFixToListView(p, i + 1, fixAction, oldCurrent, p.Text); AddFixToListView(p, fixAction, oldCurrent, p.Text);
} }
} }
} }
@ -965,11 +963,11 @@ namespace Nikse.SubtitleEdit.Forms
if (p.Text.Length != oldText.Length && Utilities.CountTagInText(p.Text, " ") != Utilities.CountTagInText(oldText, " ")) if (p.Text.Length != oldText.Length && Utilities.CountTagInText(p.Text, " ") != Utilities.CountTagInText(oldText, " "))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
doubleSpaces++; doubleSpaces++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
else else
{ {
@ -995,69 +993,69 @@ namespace Nikse.SubtitleEdit.Forms
Paragraph p = _subtitle.Paragraphs[i]; Paragraph p = _subtitle.Paragraphs[i];
if (p.Text.Contains("!." + Environment.NewLine)) if (p.Text.Contains("!." + Environment.NewLine))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Replace("!." + Environment.NewLine, "!" + Environment.NewLine); p.Text = p.Text.Replace("!." + Environment.NewLine, "!" + Environment.NewLine);
unneededPeriods++; unneededPeriods++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
if (p.Text.Contains("?." + Environment.NewLine)) if (p.Text.Contains("?." + Environment.NewLine))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Replace("?." + Environment.NewLine, "?" + Environment.NewLine); p.Text = p.Text.Replace("?." + Environment.NewLine, "?" + Environment.NewLine);
unneededPeriods++; unneededPeriods++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
if (p.Text.EndsWith("!.")) if (p.Text.EndsWith("!."))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.TrimEnd('.'); p.Text = p.Text.TrimEnd('.');
unneededPeriods++; unneededPeriods++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
if (p.Text.EndsWith("?.")) if (p.Text.EndsWith("?."))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.TrimEnd('.'); p.Text = p.Text.TrimEnd('.');
unneededPeriods++; unneededPeriods++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
if (p.Text.Contains("!. ")) if (p.Text.Contains("!. "))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Replace("!. ", "! "); p.Text = p.Text.Replace("!. ", "! ");
unneededPeriods++; unneededPeriods++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
if (p.Text.Contains("?. ")) if (p.Text.Contains("?. "))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Replace("?. ", "? "); p.Text = p.Text.Replace("?. ", "? ");
unneededPeriods++; unneededPeriods++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
@ -1082,14 +1080,14 @@ namespace Nikse.SubtitleEdit.Forms
{ {
if ("\"<.".Contains(p.Text[match.Index + 2].ToString()) == false) if ("\"<.".Contains(p.Text[match.Index + 2].ToString()) == false)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
_totalFixes++; _totalFixes++;
missingSpaces++; missingSpaces++;
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Replace(match.Value, match.Value[0] + ", " + match.Value[match.Value.Length - 1]); p.Text = p.Text.Replace(match.Value, match.Value[0] + ", " + match.Value[match.Value.Length - 1]);
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
match = match.NextMatch(); match = match.NextMatch();
@ -1104,14 +1102,14 @@ namespace Nikse.SubtitleEdit.Forms
{ {
if ("\"<".Contains(p.Text[match.Index + 2].ToString()) == false) if ("\"<".Contains(p.Text[match.Index + 2].ToString()) == false)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
_totalFixes++; _totalFixes++;
missingSpaces++; missingSpaces++;
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Replace(match.Value, match.Value[0] + "? " + match.Value[match.Value.Length - 1]); p.Text = p.Text.Replace(match.Value, match.Value[0] + "? " + match.Value[match.Value.Length - 1]);
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
match = fixMissingSpacesReQuestionMark.Match(p.Text, match.Index + 1); match = fixMissingSpacesReQuestionMark.Match(p.Text, match.Index + 1);
@ -1126,14 +1124,14 @@ namespace Nikse.SubtitleEdit.Forms
{ {
if ("\"<".Contains(p.Text[match.Index + 2].ToString()) == false) if ("\"<".Contains(p.Text[match.Index + 2].ToString()) == false)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
_totalFixes++; _totalFixes++;
missingSpaces++; missingSpaces++;
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Replace(match.Value, match.Value[0] + "! " + match.Value[match.Value.Length - 1]); p.Text = p.Text.Replace(match.Value, match.Value[0] + "! " + match.Value[match.Value.Length - 1]);
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
match = fixMissingSpacesReExclamation.Match(p.Text, match.Index + 1); match = fixMissingSpacesReExclamation.Match(p.Text, match.Index + 1);
@ -1158,14 +1156,14 @@ namespace Nikse.SubtitleEdit.Forms
} }
else if ("\"<".Contains(p.Text[match.Index + 2].ToString()) == false) else if ("\"<".Contains(p.Text[match.Index + 2].ToString()) == false)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
_totalFixes++; _totalFixes++;
missingSpaces++; missingSpaces++;
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Replace(match.Value, match.Value[0] + ": " + match.Value[match.Value.Length - 1]); p.Text = p.Text.Replace(match.Value, match.Value[0] + ": " + match.Value[match.Value.Length - 1]);
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
match = fixMissingSpacesReColon.Match(p.Text, match.Index + 1); match = fixMissingSpacesReColon.Match(p.Text, match.Index + 1);
@ -1194,14 +1192,14 @@ namespace Nikse.SubtitleEdit.Forms
if (match.Value.ToLower() == "h.d" && match.Index > 0 && p.Text.Substring(match.Index - 1, 4).ToLower() == "ph.d") if (match.Value.ToLower() == "h.d" && match.Index > 0 && p.Text.Substring(match.Index - 1, 4).ToLower() == "ph.d")
isMatchAbbreviation = true; isMatchAbbreviation = true;
if (!isMatchAbbreviation && AllowFix(i + 1, fixAction)) if (!isMatchAbbreviation && AllowFix(p, fixAction))
{ {
_totalFixes++; _totalFixes++;
missingSpaces++; missingSpaces++;
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Replace(match.Value, match.Value[0] + ". " + match.Value[match.Value.Length - 1]); p.Text = p.Text.Replace(match.Value, match.Value[0] + ". " + match.Value[match.Value.Length - 1]);
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
match = match.NextMatch(); match = match.NextMatch();
@ -1222,14 +1220,14 @@ namespace Nikse.SubtitleEdit.Forms
if (arr[1].Length > 6 && arr[1].StartsWith("<i>-") && arr[1][4] != ' ') if (arr[1].Length > 6 && arr[1].StartsWith("<i>-") && arr[1][4] != ' ')
arr[1] = arr[1].Insert(4, " "); arr[1] = arr[1].Insert(4, " ");
string newText = arr[0] + Environment.NewLine + arr[1]; string newText = arr[0] + Environment.NewLine + arr[1];
if (newText != p.Text && AllowFix(i + 1, fixAction)) if (newText != p.Text && AllowFix(p, fixAction))
{ {
_totalFixes++; _totalFixes++;
missingSpaces++; missingSpaces++;
string oldText = p.Text; string oldText = p.Text;
p.Text = newText; p.Text = newText;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -1252,14 +1250,14 @@ namespace Nikse.SubtitleEdit.Forms
{ {
newText = newText.Insert(end + 1, " "); newText = newText.Insert(end + 1, " ");
} }
if (newText != p.Text && AllowFix(i + 1, fixAction)) if (newText != p.Text && AllowFix(p, fixAction))
{ {
_totalFixes++; _totalFixes++;
missingSpaces++; missingSpaces++;
string oldText = p.Text; string oldText = p.Text;
p.Text = newText; p.Text = newText;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -1272,14 +1270,14 @@ namespace Nikse.SubtitleEdit.Forms
newText = newText.Insert(1, " "); newText = newText.Insert(1, " ");
if ("#♪♫".Contains(newText[newText.Length - 1].ToString()) && !" >".Contains(newText[newText.Length - 2].ToString())) if ("#♪♫".Contains(newText[newText.Length - 1].ToString()) && !" >".Contains(newText[newText.Length - 2].ToString()))
newText = newText.Insert(newText.Length - 1, " "); newText = newText.Insert(newText.Length - 1, " ");
if (newText != p.Text && AllowFix(i + 1, fixAction)) if (newText != p.Text && AllowFix(p, fixAction))
{ {
_totalFixes++; _totalFixes++;
missingSpaces++; missingSpaces++;
string oldText = p.Text; string oldText = p.Text;
p.Text = newText; p.Text = newText;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
@ -1298,14 +1296,14 @@ namespace Nikse.SubtitleEdit.Forms
} }
index = newText.IndexOf("...", index +2); index = newText.IndexOf("...", index +2);
} }
if (newText != p.Text && AllowFix(i + 1, fixAction)) if (newText != p.Text && AllowFix(p, fixAction))
{ {
_totalFixes++; _totalFixes++;
missingSpaces++; missingSpaces++;
string oldText = p.Text; string oldText = p.Text;
p.Text = newText; p.Text = newText;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
@ -1495,11 +1493,11 @@ namespace Nikse.SubtitleEdit.Forms
if (oldText != p.Text) if (oldText != p.Text)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
_totalFixes++; _totalFixes++;
noOfFixes++; noOfFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
@ -1541,7 +1539,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
if (p.Text[match.Index + 1] == 'I') if (p.Text[match.Index + 1] == 'I')
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
p.Text = p.Text.Substring(0, match.Index + 1) + "l"; p.Text = p.Text.Substring(0, match.Index + 1) + "l";
if (match.Index + 2 < oldText.Length) if (match.Index + 2 < oldText.Length)
@ -1549,7 +1547,7 @@ namespace Nikse.SubtitleEdit.Forms
uppercaseIsInsideLowercaseWords++; uppercaseIsInsideLowercaseWords++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -1566,7 +1564,7 @@ namespace Nikse.SubtitleEdit.Forms
string word = GetWholeWord(st.StrippedText, match.Index); string word = GetWholeWord(st.StrippedText, match.Index);
if (!IsName(word)) if (!IsName(word))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
if (word.ToLower() == "internal" || if (word.ToLower() == "internal" ||
word.ToLower() == "island" || word.ToLower() == "island" ||
@ -1583,7 +1581,7 @@ namespace Nikse.SubtitleEdit.Forms
// p.Text = st.MergedString; // p.Text = st.MergedString;
// uppercaseIsInsideLowercaseWords++; // uppercaseIsInsideLowercaseWords++;
// _totalFixes++; // _totalFixes++;
// AddFixToListView(p, i + 1, fixAction, oldText, p.Text); // AddFixToListView(p, fixAction, oldText, p.Text);
//} //}
} }
else else
@ -1601,7 +1599,7 @@ namespace Nikse.SubtitleEdit.Forms
p.Text = st.MergedString; p.Text = st.MergedString;
uppercaseIsInsideLowercaseWords++; uppercaseIsInsideLowercaseWords++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -1619,7 +1617,7 @@ namespace Nikse.SubtitleEdit.Forms
p.Text = st.MergedString; p.Text = st.MergedString;
uppercaseIsInsideLowercaseWords++; uppercaseIsInsideLowercaseWords++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -1642,7 +1640,7 @@ namespace Nikse.SubtitleEdit.Forms
p.Text = st.MergedString; p.Text = st.MergedString;
uppercaseIsInsideLowercaseWords++; uppercaseIsInsideLowercaseWords++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
else else
{ {
@ -1655,7 +1653,7 @@ namespace Nikse.SubtitleEdit.Forms
p.Text = st.MergedString; p.Text = st.MergedString;
uppercaseIsInsideLowercaseWords++; uppercaseIsInsideLowercaseWords++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -1683,13 +1681,13 @@ namespace Nikse.SubtitleEdit.Forms
if (p.Text.Contains("''")) if (p.Text.Contains("''"))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Replace("''", "\""); p.Text = p.Text.Replace("''", "\"");
fixCount++; fixCount++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -1731,7 +1729,7 @@ namespace Nikse.SubtitleEdit.Forms
//test to see if the first word of the next line is a name //test to see if the first word of the next line is a name
if (!IsName(next.Text.Split(" .,-?!:;\"()[]{}|<>/+\r\n".ToCharArray())[0])) if (!IsName(next.Text.Split(" .,-?!:;\"()[]{}|<>/+\r\n".ToCharArray())[0]))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
if (p.Text.EndsWith(">")) if (p.Text.EndsWith(">"))
@ -1748,7 +1746,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
_totalFixes++; _totalFixes++;
missigPeriodsAtEndOfLine++; missigPeriodsAtEndOfLine++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -1764,7 +1762,7 @@ namespace Nikse.SubtitleEdit.Forms
if (st.StrippedText.Length > 0 && st.StrippedText != st.StrippedText.ToUpper() && if (st.StrippedText.Length > 0 && st.StrippedText != st.StrippedText.ToUpper() &&
Utilities.GetLetters(true, false, false).Contains(st.StrippedText[0].ToString())) Utilities.GetLetters(true, false, false).Contains(st.StrippedText[0].ToString()))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
int j = p.Text.Length - 1; int j = p.Text.Length - 1;
while (j >= 0 && !(".!?¿¡").Contains(p.Text[j].ToString())) while (j >= 0 && !(".!?¿¡").Contains(p.Text[j].ToString()))
@ -1779,7 +1777,7 @@ namespace Nikse.SubtitleEdit.Forms
_totalFixes++; _totalFixes++;
missigPeriodsAtEndOfLine++; missigPeriodsAtEndOfLine++;
p.Text += endSign; p.Text += endSign;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -1798,7 +1796,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
if (Configuration.Settings.General.UppercaseLetters.Contains(p.Text[indexOfNewLine - 1].ToString().ToUpper())) if (Configuration.Settings.General.UppercaseLetters.Contains(p.Text[indexOfNewLine - 1].ToString().ToUpper()))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
@ -1813,7 +1811,7 @@ namespace Nikse.SubtitleEdit.Forms
_totalFixes++; _totalFixes++;
missigPeriodsAtEndOfLine++; missigPeriodsAtEndOfLine++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -1931,12 +1929,12 @@ namespace Nikse.SubtitleEdit.Forms
prevText.EndsWith(" a.m.") || prevText.EndsWith(" a.m.") ||
prevText.EndsWith(" p.m.")); prevText.EndsWith(" p.m."));
if (!isMatchInKnowAbbreviations && AllowFix(i + 1, fixAction1)) if (!isMatchInKnowAbbreviations && AllowFix(p, fixAction1))
{ {
p.Text = pre + firstLetter.ToUpper() + text.Substring(1); p.Text = pre + firstLetter.ToUpper() + text.Substring(1);
_totalFixes++; _totalFixes++;
fixedStartWithUppercaseLetterAfterParagraphTicked++; fixedStartWithUppercaseLetterAfterParagraphTicked++;
AddFixToListView(p, i + 1, fixAction1, oldText, p.Text); AddFixToListView(p, fixAction1, oldText, p.Text);
} }
} }
} }
@ -1984,13 +1982,13 @@ namespace Nikse.SubtitleEdit.Forms
prevText.EndsWith(" p.m.")); prevText.EndsWith(" p.m."));
if (!isMatchInKnowAbbreviations && AllowFix(i + 1, fixAction2)) if (!isMatchInKnowAbbreviations && AllowFix(p, fixAction2))
{ {
text = pre + firstLetter.ToUpper() + text.Substring(1); text = pre + firstLetter.ToUpper() + text.Substring(1);
_totalFixes++; _totalFixes++;
fixedStartWithUppercaseLetterAfterParagraphTicked++; fixedStartWithUppercaseLetterAfterParagraphTicked++;
p.Text = arr[0] + Environment.NewLine + text; p.Text = arr[0] + Environment.NewLine + text;
AddFixToListView(p, i + 1, fixAction2, oldText, p.Text); AddFixToListView(p, fixAction2, oldText, p.Text);
} }
} }
} }
@ -2013,13 +2011,13 @@ namespace Nikse.SubtitleEdit.Forms
{ {
text = st.Pre + st.StrippedText.Remove(0, 1).Insert(0, st.StrippedText[0].ToString().ToUpper()) + st.Post; text = st.Pre + st.StrippedText.Remove(0, 1).Insert(0, st.StrippedText[0].ToString().ToUpper()) + st.Post;
if (AllowFix(i + 1, fixAction2)) if (AllowFix(p, fixAction2))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Remove(indexOfNewLine + 2).Insert(indexOfNewLine + 2, text); p.Text = p.Text.Remove(indexOfNewLine + 2).Insert(indexOfNewLine + 2, text);
_totalFixes++; _totalFixes++;
fixedStartWithUppercaseLetterAfterParagraphTicked++; fixedStartWithUppercaseLetterAfterParagraphTicked++;
AddFixToListView(p, i + 1, fixAction2, oldText, p.Text); AddFixToListView(p, fixAction2, oldText, p.Text);
} }
} }
} }
@ -2076,7 +2074,7 @@ namespace Nikse.SubtitleEdit.Forms
if (subText.StrippedText.Length > 1 && !(subText.Pre.Contains("'") && subText.StrippedText.StartsWith("s"))) if (subText.StrippedText.Length > 1 && !(subText.Pre.Contains("'") && subText.StrippedText.StartsWith("s")))
{ {
text = text.Substring(0, start + 2) + subText.Pre + subText.StrippedText[0].ToString().ToUpper() + subText.StrippedText.Substring(1) + subText.Post; text = text.Substring(0, start + 2) + subText.Pre + subText.StrippedText[0].ToString().ToUpper() + subText.StrippedText.Substring(1) + subText.Post;
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
p.Text = st.Pre + text + st.Post; p.Text = st.Pre + text + st.Post;
} }
@ -2094,7 +2092,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
noOfFixes++; noOfFixes++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
if (noOfFixes > 0) if (noOfFixes > 0)
@ -2135,13 +2133,13 @@ namespace Nikse.SubtitleEdit.Forms
lastLine = text; lastLine = text;
if (p.Text != text) if (p.Text != text)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = text; p.Text = text;
noOfFixes++; noOfFixes++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
Application.DoEvents(); Application.DoEvents();
} }
@ -2166,13 +2164,13 @@ namespace Nikse.SubtitleEdit.Forms
} }
if (p.Text != text) if (p.Text != text)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = text; p.Text = text;
noOfFixes++; noOfFixes++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -2212,12 +2210,12 @@ namespace Nikse.SubtitleEdit.Forms
if (oldText != text) if (oldText != text)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
p.Text = text; p.Text = text;
noOfFixes++; noOfFixes++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -2242,12 +2240,12 @@ namespace Nikse.SubtitleEdit.Forms
{ {
s = FixAloneLowercaseIToUppercaseLine(fixAloneLowercaseIToUppercaseIRE, oldText, s, 'i'); s = FixAloneLowercaseIToUppercaseLine(fixAloneLowercaseIToUppercaseIRE, oldText, s, 'i');
if (s != oldText && AllowFix(i + 1, fixAction)) if (s != oldText && AllowFix(p, fixAction))
{ {
p.Text = s; p.Text = s;
iFixes++; iFixes++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
@ -2400,12 +2398,12 @@ namespace Nikse.SubtitleEdit.Forms
if (text != oldText) if (text != oldText)
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
p.Text = text; p.Text = text;
iFixes++; iFixes++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -2432,12 +2430,12 @@ namespace Nikse.SubtitleEdit.Forms
string oldText = p.Text; string oldText = p.Text;
text = Utilities.AutoBreakLine(text); text = Utilities.AutoBreakLine(text);
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
p.Text = text; p.Text = text;
iFixes++; iFixes++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -2465,12 +2463,12 @@ namespace Nikse.SubtitleEdit.Forms
if (!newText.Equals(oldText)) if (!newText.Equals(oldText))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
p.Text = newText; p.Text = newText;
fixCount++; fixCount++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -2530,12 +2528,12 @@ namespace Nikse.SubtitleEdit.Forms
text = text.Replace(" ...", "..."); text = text.Replace(" ...", "...");
} }
if (text != oldText && AllowFix(i + 1, fixAction)) if (text != oldText && AllowFix(p, fixAction))
{ {
p.Text = text; p.Text = text;
fixCount++; fixCount++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
@ -2553,24 +2551,24 @@ namespace Nikse.SubtitleEdit.Forms
if (p.Text.StartsWith(">> ")) if (p.Text.StartsWith(">> "))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Substring(3, p.Text.Length - 3); p.Text = p.Text.Substring(3, p.Text.Length - 3);
fixCount++; fixCount++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
if (p.Text.StartsWith(">>")) if (p.Text.StartsWith(">>"))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Substring(2, p.Text.Length - 2); p.Text = p.Text.Substring(2, p.Text.Length - 2);
fixCount++; fixCount++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -2588,19 +2586,19 @@ namespace Nikse.SubtitleEdit.Forms
if (p.Text.StartsWith("...")) if (p.Text.StartsWith("..."))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.TrimStart('.'); p.Text = p.Text.TrimStart('.');
fixCount++; fixCount++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
if (p.Text.StartsWith("<i>...")) if (p.Text.StartsWith("<i>..."))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = "<i>" + p.Text.Substring(6, p.Text.Length - 6); p.Text = "<i>" + p.Text.Substring(6, p.Text.Length - 6);
@ -2608,19 +2606,19 @@ namespace Nikse.SubtitleEdit.Forms
p.Text = "<i>" + p.Text.Substring(4, p.Text.Length - 6); p.Text = "<i>" + p.Text.Substring(4, p.Text.Length - 6);
fixCount++; fixCount++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
if (p.Text.Contains(": ...")) if (p.Text.Contains(": ..."))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
p.Text = p.Text.Replace(": ...", ": "); p.Text = p.Text.Replace(": ...", ": ");
fixCount++; fixCount++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
@ -2639,7 +2637,7 @@ namespace Nikse.SubtitleEdit.Forms
if (p.Text.Contains("]") && !p.Text.Contains("[")) if (p.Text.Contains("]") && !p.Text.Contains("["))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
string oldText = p.Text; string oldText = p.Text;
string pre = ""; string pre = "";
@ -2655,7 +2653,7 @@ namespace Nikse.SubtitleEdit.Forms
p.Text = pre + oBkt + p.Text; p.Text = pre + oBkt + p.Text;
fixCount++; fixCount++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
} }
@ -3334,7 +3332,7 @@ namespace Nikse.SubtitleEdit.Forms
_subtitle.Paragraphs[i].Text = text; _subtitle.Paragraphs[i].Text = text;
fixCount++; fixCount++;
_totalFixes++; _totalFixes++;
AddFixToListView(_subtitle.Paragraphs[i], i + 1, fixAction, oldText, text); AddFixToListView(_subtitle.Paragraphs[i], fixAction, oldText, text);
} }
} }
if (fixCount > 0) if (fixCount > 0)
@ -3372,7 +3370,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
fixCount++; fixCount++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i + 1, fixAction, oldText, p.Text); AddFixToListView(p, fixAction, oldText, p.Text);
} }
} }
@ -3401,7 +3399,7 @@ namespace Nikse.SubtitleEdit.Forms
int inverseMarkIndex = p.Text.IndexOf(inverseMark, startIndex); int inverseMarkIndex = p.Text.IndexOf(inverseMark, startIndex);
if (wasLastLineClosed && (inverseMarkIndex == -1 || inverseMarkIndex > markIndex)) if (wasLastLineClosed && (inverseMarkIndex == -1 || inverseMarkIndex > markIndex))
{ {
if (AllowFix(i + 1, fixAction)) if (AllowFix(p, fixAction))
{ {
int j = markIndex - 1; int j = markIndex - 1;
@ -3466,7 +3464,7 @@ namespace Nikse.SubtitleEdit.Forms
last.Text = last.Text.Insert(idx, inverseMark); last.Text = last.Text.Insert(idx, inverseMark);
fixCount++; fixCount++;
_totalFixes++; _totalFixes++;
AddFixToListView(p, i, fixAction, lastOldtext, last.Text); AddFixToListView(last, fixAction, lastOldtext, last.Text);
} }
startIndex = markIndex + 2; startIndex = markIndex + 2;
@ -3699,7 +3697,7 @@ namespace Nikse.SubtitleEdit.Forms
if (listViewFixes.SelectedItems.Count > 0) if (listViewFixes.SelectedItems.Count > 0)
{ {
var p = (Paragraph) listViewFixes.SelectedItems[0].Tag; var p = (Paragraph) listViewFixes.SelectedItems[0].Tag;
int index = _subtitle.GetIndex(p); int index = _originalSubtitle.GetIndex(p);
if (index >= 0) if (index >= 0)
{ {
for (int i = 0; i < index; i++) for (int i = 0; i < index; i++)

View File

@ -1007,7 +1007,9 @@ namespace Nikse.SubtitleEdit.Logic.OCR
if (string.IsNullOrEmpty(lastLine) || if (string.IsNullOrEmpty(lastLine) ||
lastLine.EndsWith(".") || lastLine.EndsWith(".") ||
lastLine.EndsWith("!") || lastLine.EndsWith("!") ||
lastLine.EndsWith("?")) lastLine.EndsWith("?") ||
lastLine.EndsWith("]") ||
lastLine.EndsWith("♪"))
{ {
lastLine = Utilities.RemoveHtmlTags(lastLine); lastLine = Utilities.RemoveHtmlTags(lastLine);
StripableText st = new StripableText(input); StripableText st = new StripableText(input);