SubtitleEdit/libse/Forms/FixCommonErrors/Fix3PlusLines.cs

25 lines
962 B
C#

namespace Nikse.SubtitleEdit.Core.Forms.FixCommonErrors
{
public class Fix3PlusLines : IFixCommonError
{
public void Fix(Subtitle subtitle, IFixCallbacks callbacks)
{
var language = Configuration.Settings.Language.FixCommonErrors;
string fixAction = language.Fix3PlusLine;
int iFixes = 0;
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
{
Paragraph p = subtitle.Paragraphs[i];
if (Utilities.GetNumberOfLines(p.Text) > 2 && callbacks.AllowFix(p, fixAction))
{
string oldText = p.Text;
p.Text = Utilities.AutoBreakLine(p.Text);
iFixes++;
callbacks.AddFixToListView(p, fixAction, oldText, p.Text);
}
}
callbacks.UpdateFixStatus(iFixes, language.Fix3PlusLines, language.X3PlusLinesFixed);
}
}
}