From 0edd87a93be08fdc1053961eba05dac6ede95d1a Mon Sep 17 00:00:00 2001 From: Tema Date: Fri, 2 Jun 2017 23:53:29 +0300 Subject: [PATCH 1/2] Added Paragraph.NoProof() to disable proofing on the last appended text. --- DocX/Paragraph.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/DocX/Paragraph.cs b/DocX/Paragraph.cs index 64f6e8de..7b10ed10 100644 --- a/DocX/Paragraph.cs +++ b/DocX/Paragraph.cs @@ -2214,6 +2214,30 @@ public Paragraph Culture(CultureInfo culture) return this; } + /// + /// For use with Append() and AppendLine() + /// + /// This Paragraph with the last appended text with proofing disabled. + /// + /// Add a new Paragraph to this document and then disable proofing on it. + /// + /// // Load a document. + /// using (DocX document = DocX.Create(@"Test.docx")) + /// { + /// // Insert a new Paragraph and disable proofing on it. + /// Paragraph p = document.InsertParagraph("Hello, мир!").NoProof(); + /// + /// // Save this document. + /// document.Save(); + /// } + /// + /// + public Paragraph NoProof() + { + ApplyTextFormattingProperty(XName.Get("noProof", DocX.w.NamespaceName), string.Empty, null); + return this; + } + /// /// Append text to this Paragraph. /// From 6a89faa4afbd74fd9e08dea864dd797f709e320e Mon Sep 17 00:00:00 2001 From: Tema Date: Sat, 3 Jun 2017 00:18:10 +0300 Subject: [PATCH 2/2] Added Formatting.NoProof to disable proofing. --- DocX/Formatting.cs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/DocX/Formatting.cs b/DocX/Formatting.cs index e94d8c8a..61554424 100644 --- a/DocX/Formatting.cs +++ b/DocX/Formatting.cs @@ -30,6 +30,7 @@ public class Formatting : IComparable private double? spacing; private CultureInfo language; + private bool? noProof; /// /// A text formatting. @@ -65,6 +66,22 @@ public CultureInfo Language } } + /// + /// Text proofing + /// + public bool? NoProof + { + get + { + return noProof; + } + + set + { + noProof = value; + } + } + /// /// Returns a new identical instance of Formatting. /// @@ -81,6 +98,7 @@ public Formatting Clone() newf.Italic = italic; if (kerning.HasValue) { newf.Kerning = kerning; } newf.Language = language; + newf.NoProof = noProof; newf.Misc = misc; if (percentageScale.HasValue) { newf.PercentageScale = percentageScale; } if (position.HasValue) { newf.Position = position; } @@ -108,6 +126,8 @@ public static Formatting Parse(XElement rPr) option.GetAttribute(XName.Get("eastAsia", DocX.w.NamespaceName), null) ?? option.GetAttribute(XName.Get("bidi", DocX.w.NamespaceName))); break; + case "noProof": + formatting.NoProof = true; break; case "spacing": formatting.Spacing = Double.Parse( option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 20.0; @@ -172,7 +192,10 @@ internal XElement Xml if (language != null) rPr.Add(new XElement(XName.Get("lang", DocX.w.NamespaceName), new XAttribute(XName.Get("val", DocX.w.NamespaceName), language.Name))); - if(spacing.HasValue) + if (noProof.HasValue && noProof.Value) + rPr.Add(new XElement(XName.Get("noProof", DocX.w.NamespaceName))); + + if(spacing.HasValue) rPr.Add(new XElement(XName.Get("spacing", DocX.w.NamespaceName), new XAttribute(XName.Get("val", DocX.w.NamespaceName), spacing.Value * 20))); if(position.HasValue) @@ -542,6 +565,9 @@ public int CompareTo(object obj) if (!other.language.Equals(this.language)) return -1; + if (other.noProof != this.noProof) + return -1; + return 0; } }