| @@ -22,11 +22,7 @@ namespace Novacode | |||
| public void SetText(string newText) | |||
| { | |||
| string x = this.Tag; | |||
| XElement el = Xml; | |||
| Xml.Descendants(XName.Get("t", DocX.w.NamespaceName)).First().Value = newText; | |||
| } | |||
| } | |||
| @@ -4,21 +4,17 @@ namespace Novacode | |||
| { | |||
| public class CustomProperty | |||
| { | |||
| private string name; | |||
| private object value; | |||
| private string type; | |||
| /// <summary> | |||
| /// The name of this CustomProperty. | |||
| /// </summary> | |||
| public string Name { get { return name;} } | |||
| public string Name { get; } | |||
| /// <summary> | |||
| /// The value of this CustomProperty. | |||
| /// </summary> | |||
| public object Value { get { return value; } } | |||
| public object Value { get; } | |||
| internal string Type { get { return type; } } | |||
| internal string Type { get; } | |||
| internal CustomProperty(string name, string type, string value) | |||
| { | |||
| @@ -58,16 +54,16 @@ namespace Novacode | |||
| default: throw new Exception(); | |||
| } | |||
| this.name = name; | |||
| this.type = type; | |||
| this.value = realValue; | |||
| Name = name; | |||
| Type = type; | |||
| Value = realValue; | |||
| } | |||
| private CustomProperty(string name, string type, object value) | |||
| { | |||
| this.name = name; | |||
| this.type = type; | |||
| this.value = value; | |||
| Name = name; | |||
| Type = type; | |||
| Value = value; | |||
| } | |||
| /// <summary> | |||
| @@ -83,7 +79,7 @@ namespace Novacode | |||
| /// </summary> | |||
| /// <param name="name">The name of this CustomProperty.</param> | |||
| /// <param name="value">The value of this CustomProperty.</param> | |||
| public CustomProperty(string name, int value) : this(name, "i4", value as object) { } | |||
| public CustomProperty(string name, int value) : this(name, "i4", value) { } | |||
| /// <summary> | |||
| @@ -91,7 +87,7 @@ namespace Novacode | |||
| /// </summary> | |||
| /// <param name="name">The name of this CustomProperty.</param> | |||
| /// <param name="value">The value of this CustomProperty.</param> | |||
| public CustomProperty(string name, double value) : this(name, "r8", value as object) { } | |||
| public CustomProperty(string name, double value) : this(name, "r8", value) { } | |||
| /// <summary> | |||
| @@ -99,13 +95,13 @@ namespace Novacode | |||
| /// </summary> | |||
| /// <param name="name">The name of this CustomProperty.</param> | |||
| /// <param name="value">The value of this CustomProperty.</param> | |||
| public CustomProperty(string name, DateTime value) : this(name, "filetime", value.ToUniversalTime() as object) { } | |||
| public CustomProperty(string name, DateTime value) : this(name, "filetime", value.ToUniversalTime()) { } | |||
| /// <summary> | |||
| /// Create a new CustomProperty to hold a bool. | |||
| /// </summary> | |||
| /// <param name="name">The name of this CustomProperty.</param> | |||
| /// <param name="value">The value of this CustomProperty.</param> | |||
| public CustomProperty(string name, bool value) : this(name, "bool", value as object) { } | |||
| public CustomProperty(string name, bool value) : this(name, "bool", value) { } | |||
| } | |||
| } | |||
| @@ -9,17 +9,16 @@ namespace Novacode | |||
| public class DocProperty: DocXElement | |||
| { | |||
| internal Regex extractName = new Regex(@"DOCPROPERTY (?<name>.*) "); | |||
| private string name; | |||
| /// <summary> | |||
| /// The custom property to display. | |||
| /// </summary> | |||
| public string Name { get { return name; } } | |||
| public string Name { get; } | |||
| internal DocProperty(DocX document, XElement xml):base(document, xml) | |||
| { | |||
| string instr = Xml.Attribute(XName.Get("instr", "http://schemas.openxmlformats.org/wordprocessingml/2006/main")).Value; | |||
| this.name = extractName.Match(instr.Trim()).Groups["name"].Value; | |||
| Name = extractName.Match(instr.Trim()).Groups["name"].Value; | |||
| } | |||
| } | |||
| } | |||
| @@ -254,13 +254,10 @@ namespace Novacode | |||
| { | |||
| var element = this.GetOrCreate_pPr(); | |||
| var styleElement = element.Element(XName.Get("pStyle", DocX.w.NamespaceName)); | |||
| if (styleElement != null) | |||
| var attr = styleElement?.Attribute(XName.Get("val", DocX.w.NamespaceName)); | |||
| if (!string.IsNullOrEmpty(attr?.Value)) | |||
| { | |||
| var attr = styleElement.Attribute(XName.Get("val", DocX.w.NamespaceName)); | |||
| if (attr != null && !string.IsNullOrEmpty(attr.Value)) | |||
| { | |||
| return attr.Value; | |||
| } | |||
| return attr.Value; | |||
| } | |||
| return "Normal"; | |||
| } | |||
| @@ -408,11 +405,7 @@ namespace Novacode | |||
| XElement pPr = GetOrCreate_pPr(); | |||
| XElement bidi = pPr.Element(XName.Get("bidi", DocX.w.NamespaceName)); | |||
| if (bidi == null) | |||
| return Direction.LeftToRight; | |||
| else | |||
| return Direction.RightToLeft; | |||
| return bidi == null ? Direction.LeftToRight : Direction.RightToLeft; | |||
| } | |||
| set | |||
| @@ -427,11 +420,9 @@ namespace Novacode | |||
| if (bidi == null) | |||
| pPr.Add(new XElement(XName.Get("bidi", DocX.w.NamespaceName))); | |||
| } | |||
| else | |||
| { | |||
| if (bidi != null) | |||
| bidi.Remove(); | |||
| bidi?.Remove(); | |||
| } | |||
| } | |||
| } | |||
| @@ -514,9 +505,9 @@ namespace Novacode | |||
| { | |||
| pPr.Add(new XElement(XName.Get("keepLines", DocX.w.NamespaceName))); | |||
| } | |||
| if (!keepTogether && keepLinesE != null) | |||
| if (!keepTogether) | |||
| { | |||
| keepLinesE.Remove(); | |||
| keepLinesE?.Remove(); | |||
| } | |||
| return this; | |||
| } | |||
| @@ -586,7 +577,7 @@ namespace Novacode | |||
| { | |||
| get | |||
| { | |||
| XElement pPr = GetOrCreate_pPr(); | |||
| GetOrCreate_pPr(); | |||
| XElement ind = GetOrCreate_pPr_ind(); | |||
| XAttribute firstLine = ind.Attribute(XName.Get("firstLine", DocX.w.NamespaceName)); | |||
| @@ -607,8 +598,7 @@ namespace Novacode | |||
| // Paragraph can either be firstLine or hanging (Remove hanging). | |||
| XAttribute hanging = ind.Attribute(XName.Get("hanging", DocX.w.NamespaceName)); | |||
| if (hanging != null) | |||
| hanging.Remove(); | |||
| hanging?.Remove(); | |||
| string indentation = ((indentationFirstLine / 0.1) * 57).ToString(); | |||
| XAttribute firstLine = ind.Attribute(XName.Get("firstLine", DocX.w.NamespaceName)); | |||
| @@ -645,7 +635,7 @@ namespace Novacode | |||
| { | |||
| get | |||
| { | |||
| XElement pPr = GetOrCreate_pPr(); | |||
| GetOrCreate_pPr(); | |||
| XElement ind = GetOrCreate_pPr_ind(); | |||
| XAttribute hanging = ind.Attribute(XName.Get("hanging", DocX.w.NamespaceName)); | |||
| @@ -734,7 +724,7 @@ namespace Novacode | |||
| } | |||
| } | |||
| private float indentationAfter = 0.0f; | |||
| private float indentationAfter; | |||
| /// <summary> | |||
| /// Set the after indentation in cm for this Paragraph. | |||
| /// </summary> | |||
| @@ -762,7 +752,7 @@ namespace Novacode | |||
| { | |||
| get | |||
| { | |||
| XElement pPr = GetOrCreate_pPr(); | |||
| GetOrCreate_pPr(); | |||
| XElement ind = GetOrCreate_pPr_ind(); | |||
| XAttribute right = ind.Attribute(XName.Get("right", DocX.w.NamespaceName)); | |||
| @@ -108,11 +108,9 @@ namespace Novacode | |||
| { | |||
| return new Paragraph(Document, newlyInserted, (this as Paragraph).endIndex); | |||
| } | |||
| else | |||
| { | |||
| p.Xml = newlyInserted; //IMPORTANT: I think we have return new paragraph in any case, but I dont know what to put as startIndex parameter into Paragraph constructor | |||
| return p; | |||
| } | |||
| p.Xml = newlyInserted; //IMPORTANT: I think we have return new paragraph in any case, but I dont know what to put as startIndex parameter into Paragraph constructor | |||
| return p; | |||
| } | |||
| public virtual Paragraph InsertParagraphBeforeSelf(string text) | |||
| @@ -186,9 +184,6 @@ namespace Novacode | |||
| XElement newlyInserted = Xml.ElementsAfterSelf().First(); | |||
| //Dmitchern | |||
| return new Table(Document, newlyInserted) { mainPart = mainPart }; //return new table, dont affect parameter table | |||
| //t.Xml = newlyInserted; | |||
| //return t; | |||
| } | |||
| public virtual Table InsertTableBeforeSelf(int rowCount, int columnCount) | |||
| @@ -79,7 +79,6 @@ namespace Novacode | |||
| { | |||
| XNamespace ab = "http://schemas.openxmlformats.org/wordprocessingml/2006/main"; | |||
| var tempElement = document.PageLayout.Xml.Descendants(ab + "pgMar"); | |||
| var e = tempElement.GetEnumerator(); | |||
| foreach (var item in tempElement) | |||
| { | |||