From c43bc9f3f9166bebc21ac06c84a66de7567127f9 Mon Sep 17 00:00:00 2001 From: askolesov Date: Thu, 12 Jan 2017 18:44:14 +0300 Subject: [PATCH] Bugfixing - styles editing -fixed crash when user opens ttml styles editor in new project -fixed styles editing(was completely non-working) -added title in QC messagebox --- libse/Subtitle.cs | 4 +-- libse/SubtitleFormats/TimedText10.cs | 8 +++--- src/Forms/Main.cs | 2 +- src/Forms/Styles/TimedTextStyles.cs | 39 ++++++++++++++++------------ 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/libse/Subtitle.cs b/libse/Subtitle.cs index b686b36013..bc719bba8d 100644 --- a/libse/Subtitle.cs +++ b/libse/Subtitle.cs @@ -14,8 +14,8 @@ public class Subtitle private readonly List _history; private SubtitleFormat _format; private bool _wasLoadedWithFrameNumbers; - public string Header { get; set; } - public string Footer { get; set; } + public string Header { get; set; } = ""; + public string Footer { get; set; } = ""; public string FileName { get; set; } diff --git a/libse/SubtitleFormats/TimedText10.cs b/libse/SubtitleFormats/TimedText10.cs index f992367b30..02a531384b 100644 --- a/libse/SubtitleFormats/TimedText10.cs +++ b/libse/SubtitleFormats/TimedText10.cs @@ -31,10 +31,10 @@ public override bool IsTimeBased get { return true; } } - private static string TTMLNamespace = "http://www.w3.org/ns/ttml"; - private static string TTMLParameterNamespace = "http://www.w3.org/ns/ttml#parameter"; - private static string TTMLStylingNamespace = "http://www.w3.org/ns/ttml#styling"; - private static string TTMLMetadataNamespace = "http://www.w3.org/ns/ttml#metadata"; + public static string TTMLNamespace = "http://www.w3.org/ns/ttml"; + public static string TTMLParameterNamespace = "http://www.w3.org/ns/ttml#parameter"; + public static string TTMLStylingNamespace = "http://www.w3.org/ns/ttml#styling"; + public static string TTMLMetadataNamespace = "http://www.w3.org/ns/ttml#metadata"; private bool HasTTMLParagraphs(string xmlAsStr) { diff --git a/src/Forms/Main.cs b/src/Forms/Main.cs index a1ab295357..e5f91c1ada 100644 --- a/src/Forms/Main.cs +++ b/src/Forms/Main.cs @@ -20373,7 +20373,7 @@ private void NetflixGlyphCheck(bool showSuccessMessage = true) if (messages.Count != 0) { - MessageBox.Show(String.Join("\n\n", messages.ToArray())); + MessageBox.Show(String.Join(Environment.NewLine, messages.ToArray()), Configuration.Settings.Language.Main.Menu.ToolBar.NetflixQualityCheck); } } diff --git a/src/Forms/Styles/TimedTextStyles.cs b/src/Forms/Styles/TimedTextStyles.cs index f578154b7a..41da067c6b 100644 --- a/src/Forms/Styles/TimedTextStyles.cs +++ b/src/Forms/Styles/TimedTextStyles.cs @@ -435,27 +435,34 @@ private void textBoxStyleName_TextChanged(object sender, EventArgs e) private void UpdateHeaderXml(string id, string tag, string value) { - foreach (XmlNode innerNode in _xmlHead) + XmlNodeList styles = _xml.DocumentElement.SelectNodes("//ttml:head//ttml:styling/ttml:style", _nsmgr); + + foreach (XmlNode style in styles) { - if (innerNode.Name == "styling") + XmlAttribute idAttr = style.Attributes["xml:id"]; + + if (idAttr == null) { - foreach (XmlNode innerInnerNode in innerNode) + idAttr = style.Attributes["id"]; + } + + if (idAttr != null && idAttr.Value == id) + { + if (tag == "id" || tag == "xml:id") { - if (innerInnerNode.Name == "style") + idAttr.Value = value; + } + else + { + XmlAttribute attrToChange = style.Attributes[tag]; + + if (attrToChange == null) { - XmlAttribute idAttr = innerInnerNode.Attributes["xml:id"]; - if (idAttr != null && idAttr.InnerText == id) - { - XmlAttribute attr = innerInnerNode.Attributes[tag]; - if (attr == null) - { - attr = _xml.CreateAttribute("tts:fontSize", "http://www.w3.org/ns/10/ttml#style"); - innerInnerNode.Attributes.Append(attr); - } - attr.InnerText = value; - break; - } + attrToChange = _xml.CreateAttribute(tag); + style.Attributes.Append(attrToChange); } + + attrToChange.Value = value; } } }