示例#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");
        }
示例#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");
        }
示例#3
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);
        }
示例#4
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);
        }