Example #1
0
        public void TestAddTableToFootnote()
        {
            XWPFTable table = footnote.CreateTable();

            Assert.IsNotNull(table);

            XWPFDocument docIn = XWPFTestDataSamples.WriteOutAndReadBack(docOut);

            XWPFFootnote testFootnote = docIn.GetFootnoteByID(footnoteId);
            XWPFTable    testTable    = testFootnote.GetTableArray(0);

            Assert.IsNotNull(testTable);

            table = footnote.CreateTable(2, 3);
            Assert.AreEqual(2, table.NumberOfRows);
            Assert.AreEqual(3, table.GetRow(0).GetTableCells().Count);

            // If the table is the first body element of the footnote then
            // a paragraph with the footnote reference should have been
            // added automatically.

            Assert.AreEqual(3, footnote.BodyElements.Count, "Expected 3 body elements");
            IBodyElement testP1 = footnote.BodyElements[0];

            Assert.IsTrue(testP1 is XWPFParagraph, "Expected a paragraph, got " + testP1.GetType().Name);
            XWPFRun r1 = ((XWPFParagraph)testP1).Runs[0];

            Assert.IsNotNull(r1);
            Assert.IsTrue(r1.GetCTR().GetFootnoteRefList().Count > 0, "No footnote reference in testP1");
            Assert.IsNotNull(r1.GetCTR().GetFootnoteRefArray(0), "No footnote reference in testP1");
        }
Example #2
0
        public void TestAddParagraphsToFootnote()
        {
            // Add a run to the first paragraph:

            XWPFParagraph p1 = footnote.CreateParagraph();

            p1.CreateRun().SetText(p1Text);

            // Create a second paragraph:

            XWPFParagraph p = footnote.CreateParagraph();

            Assert.IsNotNull(p, "Paragraph is null");
            p.CreateRun().SetText(p2Text);

            XWPFDocument docIn = XWPFTestDataSamples.WriteOutAndReadBack(docOut);

            XWPFFootnote testFootnote = docIn.GetFootnoteByID(footnoteId);

            Assert.IsNotNull(testFootnote);

            Assert.AreEqual(2, testFootnote.GetParagraphs().Count);
            XWPFParagraph testP1 = testFootnote.GetParagraphs()[0];

            Assert.AreEqual(p1Text, testP1.Text);

            XWPFParagraph testP2 = testFootnote.GetParagraphs()[1];

            Assert.AreEqual(p2Text, testP2.Text);

            // The first paragraph added using CreateParagraph() should
            // have the required footnote reference added to the first
            // run.

            // Verify that we have a footnote reference in the first paragraph and not
            // in the second paragraph.

            XWPFRun r1 = testP1.Runs[0];

            Assert.IsNotNull(r1);
            Assert.IsTrue(r1.GetCTR().GetFootnoteRefList().Count > 0, "No footnote reference in testP1");
            Assert.IsNotNull(r1.GetCTR().GetFootnoteRefArray(0), "No footnote reference in testP1");

            XWPFRun r2 = testP2.Runs[0];

            Assert.IsNotNull(r2, "Expected a run in testP2");
            Assert.IsTrue(r2.GetCTR().GetFootnoteRefList().Count == 0, "Found a footnote reference in testP2");
        }
Example #3
0
        public void SetUp()
        {
            docOut = new XWPFDocument();
            p1Text = "First paragraph in footnote";
            p2Text = "Second paragraph in footnote";

            // NOTE: XWPFDocument.CreateFootnote() delegates directly
            //       to XWPFFootnotes.CreateFootnote() so this tests
            //       both creation of new XWPFFootnotes in document
            //       and XWPFFootnotes.CreateFootnote();

            // NOTE: Creating the footnote does not automatically
            //       create a first paragraph.
            footnote   = docOut.CreateFootnote();
            footnoteId = footnote.Id;
        }
        public void TestFootnoteRender()
        {
            XWPFDocument doc = renderDoc("\\c 1 \\v 1 This is a verse. \\f + \\ft This is a footnote. \\f*");

            // Chapter 1
            Assert.AreEqual("Chapter 1", doc.Paragraphs[0].ParagraphText);
            // Verse 1
            Assert.AreEqual("1", doc.Paragraphs[1].Runs[0].Text);
            // Footnote Reference 1
            CT_FtnEdnRef footnoteRef = (CT_FtnEdnRef)doc.Paragraphs[1].Runs[3].GetCTR().Items[1];

            Assert.AreEqual("1", footnoteRef.id);
            // Footnote Content 1
            XWPFFootnote footnote = doc.GetFootnotes()[0];

            Assert.AreEqual("F1 This is a footnote. ", footnote.Paragraphs[0].ParagraphText);
        }
Example #5
0
        public void TestAddFootnotesToDocument()
        {
            XWPFDocument docOut = new XWPFDocument();

            // NOTE: XWPFDocument.createFootnote() delegates directly
            //       to XWPFFootnotes.createFootnote() so this tests
            //       both creation of new XWPFFootnotes in document
            //       and XWPFFootnotes.createFootnote();
            XWPFFootnote footnote = docOut.CreateFootnote();
            int          noteId   = footnote.Id;

            XWPFDocument docIn = XWPFTestDataSamples.WriteOutAndReadBack(docOut);

            XWPFFootnote note = docIn.GetFootnoteByID(noteId);

            Assert.IsNotNull(note);
            Assert.AreEqual(note.GetCTFtnEdn().type, ST_FtnEdn.normal);
        }
Example #6
0
        public void TestAddFootnotesToDocument()
        {
            XWPFDocument docOut = new XWPFDocument();

            int noteId = 1;

            XWPFFootnotes footnotes = docOut.CreateFootnotes();
            CT_FtnEdn     ctNote    = new CT_FtnEdn();

            ctNote.id   = (noteId.ToString());
            ctNote.type = (ST_FtnEdn.normal);
            footnotes.AddFootnote(ctNote);

            XWPFDocument docIn = XWPFTestDataSamples.WriteOutAndReadBack(docOut);

            XWPFFootnote note = docIn.GetFootnoteByID(noteId);

            Assert.AreEqual(note.GetCTFtnEdn().type, ST_FtnEdn.normal);
        }
Example #7
0
 public XWPFFootnote AddEndnote(CT_FtnEdn note)
 {
     XWPFFootnote endnote = new XWPFFootnote(this, note);
     endnotes.Add(int.Parse(note.id), endnote);
     return endnote;
 }
Example #8
0
 /**
  * add a footnote to the document
  * @param note
  * @throws IOException		 
  */
 public XWPFFootnote AddFootnote(CT_FtnEdn note)
 {
     CT_FtnEdn newNote = ctFootnotes.AddNewFootnote();
     newNote.Set(note);
     XWPFFootnote xNote = new XWPFFootnote(newNote, this);
     listFootnote.Add(xNote);
     return xNote;
 }
Example #9
0
 /**
  * add an XWPFFootnote to the document
  * @param footnote
  * @throws IOException		 
  */
 public void AddFootnote(XWPFFootnote footnote)
 {
     listFootnote.Add(footnote);
     ctFootnotes.AddNewFootnote().Set(footnote.GetCTFtnEdn());
 }