Beispiel #1
0
        public void TestRemoveFootnote()
        {
            // NOTE: XWPFDocument.removeFootnote() delegates directly to
            //       XWPFFootnotes.
            docOut.CreateFootnote();
            Assert.AreEqual(2, docOut.GetFootnotes().Count, "Expected 2 footnotes");
            Assert.IsNotNull(docOut.GetFootnotes()[1], "Didn't get second footnote");
            bool result = docOut.RemoveFootnote(0);

            Assert.IsTrue(result, "Remove footnote did not return true");
            Assert.AreEqual(1, docOut.GetFootnotes().Count, "Expected 1 footnote after removal");
        }
Beispiel #2
0
        private List <AbstractXWPFSDT> ExtractAllSDTs(XWPFDocument doc)
        {
            List <AbstractXWPFSDT> sdts = new List <AbstractXWPFSDT>();

            IList <XWPFHeader> headers = doc.HeaderList;

            foreach (XWPFHeader header in headers)
            {
                sdts.AddRange(ExtractSDTsFromBodyElements(header.BodyElements));
            }
            sdts.AddRange(ExtractSDTsFromBodyElements(doc.BodyElements));

            IList <XWPFFooter> footers = doc.FooterList;

            foreach (XWPFFooter footer in footers)
            {
                sdts.AddRange(ExtractSDTsFromBodyElements(footer.BodyElements));
            }

            foreach (XWPFFootnote footnote in doc.GetFootnotes())
            {
                sdts.AddRange(ExtractSDTsFromBodyElements(footnote.BodyElements));
            }
            foreach (KeyValuePair <int, XWPFFootnote> e in doc.Endnotes)
            {
                sdts.AddRange(ExtractSDTsFromBodyElements(e.Value.BodyElements));
            }
            return(sdts);
        }
        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);
        }
Beispiel #4
0
        public void TestLoadFootnotesOnce()
        {
            XWPFDocument         doc       = XWPFTestDataSamples.OpenSampleDocument("Bug54849.docx");
            IList <XWPFFootnote> footnotes = doc.GetFootnotes();
            int hits = 0;

            foreach (XWPFFootnote fn in footnotes)
            {
                foreach (IBodyElement e in fn.BodyElements)
                {
                    if (e is XWPFParagraph)
                    {
                        String txt = ((XWPFParagraph)e).Text;
                        if (txt.IndexOf("Footnote_sdt") > -1)
                        {
                            hits++;
                        }
                    }
                }
            }
            Assert.AreEqual(1, hits, "Load footnotes once");
        }