Преглед изворни кода

Added StyleName and FollowingTable properties for Paragraph

master
AndreyKovalenko_cp пре 15 година
родитељ
комит
68db5d6561
2 измењених фајлова са 64 додато и 7 уклоњено
  1. 11
    7
      DocX/Container.cs
  2. 53
    0
      DocX/Paragraph.cs

+ 11
- 7
DocX/Container.cs Прегледај датотеку

@@ -61,13 +61,17 @@ namespace Novacode
{
get
{
List<Paragraph> paragraphs =
(
from p in Xml.Elements(DocX.w + "p")
select new Paragraph(Document, p, 0)
).ToList();
return paragraphs;
List<Paragraph> paragraphs = new List<Paragraph>();
foreach (var p in this.Xml.Elements(DocX.w + "p"))
{
var paragraph = new Paragraph(this.Document, p, 0);
if ((p.ElementsAfterSelf().FirstOrDefault() != null) &&(p.ElementsAfterSelf().First().Name.Equals(DocX.w + "tbl")))
{
paragraph.FollowingTable = new Table(this.Document, p.ElementsAfterSelf().First());
}
paragraphs.Add(paragraph);
}
return paragraphs;
}
}

+ 53
- 0
DocX/Paragraph.cs Прегледај датотеку

@@ -112,6 +112,42 @@ namespace Novacode
}
}
///<summary>
/// The style name of the paragraph.
///</summary>
public string StyleName
{
get
{
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 (attr != null && !string.IsNullOrEmpty(attr.Value))
{
return attr.Value;
}
}
return "Normal";
}
set
{
if (string.IsNullOrEmpty(value))
{
value = "Normal";
}
var element = this.GetOrCreate_pPr();
var styleElement = element.Element(XName.Get("pStyle", DocX.w.NamespaceName));
if (styleElement == null)
{
element.Add(new XElement(XName.Get("pStyle", DocX.w.NamespaceName)));
styleElement = element.Element(XName.Get("pStyle", DocX.w.NamespaceName));
}
styleElement.SetAttributeValue(XName.Get("val", DocX.w.NamespaceName), value);
}
}
// A collection of field type DocProperty.
private List<DocProperty> docProperties;
@@ -2107,6 +2143,23 @@ namespace Novacode
return this;
}
private Table followingTable;
///<summary>
/// Returns table following the paragraph. Null if the following element isn't table.
///</summary>
public Table FollowingTable
{
get
{
return followingTable;
}
internal set
{
followingTable = value;
}
}
/// <summary>
/// For use with Append() and AppendLine()
/// </summary>

Loading…
Откажи
Сачувај