diff --git a/main/HPSF/SummaryInformation.cs b/main/HPSF/SummaryInformation.cs
index d9b0a921e..f3c629cbf 100644
--- a/main/HPSF/SummaryInformation.cs
+++ b/main/HPSF/SummaryInformation.cs
@@ -66,7 +66,7 @@ public SummaryInformation(PropertySet ps) : base(ps)
///
///
- /// Creates a instance from an instance from an InputStream in the Horrible Property Set Format.
///
///
/// The constructor reads the first few bytes from the stream
diff --git a/main/SS/UserModel/ConditionalFormattingRule.cs b/main/SS/UserModel/ConditionalFormattingRule.cs
index c524df220..d1e6e9e26 100644
--- a/main/SS/UserModel/ConditionalFormattingRule.cs
+++ b/main/SS/UserModel/ConditionalFormattingRule.cs
@@ -144,7 +144,7 @@ public interface IConditionalFormattingRule : IDifferentialStyleProvider
/// true if conditional formatting rule processing stops when this one is true, false if not
///
///
- /// Microsoft Excel help
+ /// Microsoft Excel help
bool StopIfTrue { get; }
///
diff --git a/ooxml/XWPF/Usermodel/XWPFTableCell.cs b/ooxml/XWPF/Usermodel/XWPFTableCell.cs
index 27aa952ab..674e35f03 100644
--- a/ooxml/XWPF/Usermodel/XWPFTableCell.cs
+++ b/ooxml/XWPF/Usermodel/XWPFTableCell.cs
@@ -155,6 +155,7 @@ public XWPFParagraph AddParagraph()
public void AddParagraph(XWPFParagraph p)
{
paragraphs.Add(p);
+ bodyElements.Add(p);
}
/**
@@ -163,8 +164,10 @@ public void AddParagraph(XWPFParagraph p)
*/
public void RemoveParagraph(int pos)
{
+ XWPFParagraph removedParagraph = paragraphs[pos];
paragraphs.RemoveAt(pos);
ctTc.RemoveP(pos);
+ bodyElements.Remove(removedParagraph);
}
/**
diff --git a/testcases/ooxml/XWPF/UserModel/TestXWPFTableCell.cs b/testcases/ooxml/XWPF/UserModel/TestXWPFTableCell.cs
index a19f70322..726186520 100644
--- a/testcases/ooxml/XWPF/UserModel/TestXWPFTableCell.cs
+++ b/testcases/ooxml/XWPF/UserModel/TestXWPFTableCell.cs
@@ -132,5 +132,59 @@ public void TestCellVerticalAlignShouldNotThrowNPE()
}
}
}
+
+ [Test]
+ public void TestAddParagraph()
+ {
+ using (XWPFDocument doc = new XWPFDocument())
+ {
+ XWPFTable table = doc.CreateTable();
+ XWPFTableRow tr = table.CreateRow();
+ XWPFTableCell cell = tr.AddNewTableCell();
+
+ // cell have at least one paragraph by default
+ ClassicAssert.AreEqual(1, cell.Paragraphs.Count);
+ ClassicAssert.AreEqual(1, cell.BodyElements.Count);
+ ClassicAssert.AreEqual(cell.GetParagraphArray(0), cell.BodyElements[0]);
+
+ XWPFParagraph p = cell.AddParagraph();
+ ClassicAssert.AreEqual(2, cell.Paragraphs.Count);
+ ClassicAssert.AreEqual(2, cell.BodyElements.Count);
+ ClassicAssert.AreEqual(p, cell.GetParagraphArray(1));
+ ClassicAssert.AreEqual(cell.GetParagraphArray(1), cell.BodyElements[1]);
+ }
+ }
+
+ [Test]
+ public void TestRemoveParagraph()
+ {
+ using (XWPFDocument doc = new XWPFDocument())
+ {
+ XWPFTable table = doc.CreateTable();
+ XWPFTableRow tr = table.CreateRow();
+ XWPFTableCell cell = tr.AddNewTableCell();
+
+ // cell have at least one paragraph by default
+ XWPFParagraph p0 = cell.GetParagraphArray(0);
+ XWPFParagraph p1 = cell.AddParagraph();
+ cell.AddParagraph();
+
+ // remove 3rd
+ cell.RemoveParagraph(2);
+ ClassicAssert.AreEqual(2, cell.Paragraphs.Count);
+ ClassicAssert.AreEqual(2, cell.BodyElements.Count);
+ ClassicAssert.AreEqual(p0, cell.GetParagraphArray(0));
+ ClassicAssert.AreEqual(p1, cell.GetParagraphArray(1));
+ ClassicAssert.AreEqual(p0, cell.BodyElements[0]);
+ ClassicAssert.AreEqual(p1, cell.BodyElements[1]);
+
+ // remove 2nd
+ cell.RemoveParagraph(1);
+ ClassicAssert.AreEqual(1, cell.Paragraphs.Count);
+ ClassicAssert.AreEqual(1, cell.BodyElements.Count);
+ ClassicAssert.AreEqual(p0, cell.GetParagraphArray(0));
+ ClassicAssert.AreEqual(p0, cell.BodyElements[0]);
+ }
+ }
}
}