示例#1
0
        /**
         * Ensure that the specified paragraph has a reference marker for this
         * footnote by adding a footnote reference if one is not found.
         * <p>This method is for the first paragraph in the footnote, not
         * paragraphs that will refer to the footnote. For references to
         * the footnote, use {@link XWPFParagraph#addFootnoteReference(XWPFFootnote)}.
         * </p>
         * <p>The first run of the first paragraph in a footnote should
         * contain a {@link CTFtnEdnRef} object.</p>
         *
         * @param p The {@link XWPFParagraph} to ensure
         */
        public void EnsureFootnoteRef(XWPFParagraph p)
        {
            XWPFRun r = null;

            if (p.Runs.Count > 0)
            {
                r = p.Runs[0];
            }
            if (r == null)
            {
                r = p.CreateRun();
            }
            CT_R ctr      = r.GetCTR();
            bool foundRef = false;

            foreach (CT_FtnEdnRef reference in ctr.GetFootnoteReferenceList())
            {
                if (Id.ToString().Equals(reference.id))
                {
                    foundRef = true;
                    break;
                }
            }
            if (!foundRef)
            {
                ctr.AddNewRPr().AddNewRStyle().val = "FootnoteReference";
                ctr.AddNewFootnoteRef();
            }
        }