ソースを参照

Table.removeRow(int index) has been fixed.

Added the method Row.Remove() its easier than calling Table.removeRow(int index)
master
coffeycathal_cp 14年前
コミット
689f778abf
3個のファイルの変更29行の追加17行の削除
  1. 13
    13
      DocX/DocX.cs
  2. 2
    2
      DocX/Paragraph.cs
  3. 14
    2
      DocX/Table.cs

+ 13
- 13
DocX/DocX.cs ファイルの表示

@@ -402,7 +402,7 @@ namespace Novacode
from e in mainDoc.Descendants(XName.Get("body", DocX.w.NamespaceName)).Descendants()
where (e.Name.LocalName == reference) && (e.Attribute(w + "type").Value == type)
select e.Attribute(r + "id").Value
).FirstOrDefault();
).LastOrDefault();
if (Id != null)
{
@@ -2125,11 +2125,11 @@ namespace Novacode
{
var evenHeaderRef =
(
from e in sectPr.Elements(w + "headerReference")
from e in mainDoc.Descendants(w + "headerReference")
let type = e.Attribute(w + "type")
where type != null && type.Value.Equals("even", StringComparison.CurrentCultureIgnoreCase)
select e.Attribute(r + "id").Value
).SingleOrDefault();
).LastOrDefault();
if (evenHeaderRef != null)
{
@@ -2153,11 +2153,11 @@ namespace Novacode
var oddHeaderRef =
(
from e in sectPr.Elements(w + "headerReference")
from e in mainDoc.Descendants(w + "headerReference")
let type = e.Attribute(w + "type")
where type != null && type.Value.Equals("default", StringComparison.CurrentCultureIgnoreCase)
select e.Attribute(r + "id").Value
).SingleOrDefault();
).LastOrDefault();
if (oddHeaderRef != null)
{
@@ -2182,11 +2182,11 @@ namespace Novacode
var firstHeaderRef =
(
from e in sectPr.Elements(w + "headerReference")
from e in mainDoc.Descendants(w + "headerReference")
let type = e.Attribute(w + "type")
where type != null && type.Value.Equals("first", StringComparison.CurrentCultureIgnoreCase)
select e.Attribute(r + "id").Value
).SingleOrDefault();
).LastOrDefault();
if (firstHeaderRef != null)
{
@@ -2210,11 +2210,11 @@ namespace Novacode
var oddFooterRef =
(
from e in sectPr.Elements(w + "footerReference")
from e in mainDoc.Descendants(w + "footerReference")
let type = e.Attribute(w + "type")
where type != null && type.Value.Equals("default", StringComparison.CurrentCultureIgnoreCase)
select e.Attribute(r + "id").Value
).SingleOrDefault();
).LastOrDefault();
if (oddFooterRef != null)
{
@@ -2238,11 +2238,11 @@ namespace Novacode
var evenFooterRef =
(
from e in sectPr.Elements(w + "footerReference")
from e in mainDoc.Descendants(w + "footerReference")
let type = e.Attribute(w + "type")
where type != null && type.Value.Equals("even", StringComparison.CurrentCultureIgnoreCase)
select e.Attribute(r + "id").Value
).SingleOrDefault();
).LastOrDefault();
if (evenFooterRef != null)
{
@@ -2266,11 +2266,11 @@ namespace Novacode
var firstFooterRef =
(
from e in sectPr.Elements(w + "footerReference")
from e in mainDoc.Descendants(w + "footerReference")
let type = e.Attribute(w + "type")
where type != null && type.Value.Equals("first", StringComparison.CurrentCultureIgnoreCase)
select e.Attribute(r + "id").Value
).SingleOrDefault();
).LastOrDefault();
if (firstFooterRef != null)
{

+ 2
- 2
DocX/Paragraph.cs ファイルの表示

@@ -1211,7 +1211,8 @@ namespace Novacode
else
{
if (Xml.Parent.Name.LocalName == "tc")
// If this is the only Paragraph in the Cell then we cannot remove it.
if (Xml.Parent.Name.LocalName == "tc" && Xml.Parent.Elements(XName.Get("p", DocX.w.NamespaceName)).Count() == 1)
Xml.Value = string.Empty;
else
@@ -3075,7 +3076,6 @@ namespace Novacode
// If the formatting matches, do the replace.
if(formattingMatch)
{
var temp = Xml;
InsertText(m.Index + oldValue.Length, newValue, trackChanges, newFormatting);
RemoveText(m.Index, m.Length, trackChanges);
}

+ 14
- 2
DocX/Table.cs ファイルの表示

@@ -676,10 +676,13 @@ namespace Novacode
/// </example>
public void RemoveRow(int index)
{
if (index < 0 || index > rows.Count)
if (index < 0 || index > Rows.Count)
throw new IndexOutOfRangeException();
rows[index].Xml.Remove();
Rows[index].Xml.Remove();
if (Rows.Count == 0)
Remove();
}
/// <summary>
@@ -1557,6 +1560,15 @@ namespace Novacode
}
}
public void Remove()
{
XElement table = Xml.Parent;
Xml.Remove();
if (table.Elements(XName.Get("tr", DocX.w.NamespaceName)).Count() == 0)
table.Remove();
}
public override List<Paragraph> Paragraphs
{
get

読み込み中…
キャンセル
保存