コード例 #1
0
        private CT_HdrFtr buildHdrFtr(String pStyle, XWPFParagraph[] paragraphs)
        {
            CT_HdrFtr ftr = new CT_HdrFtr();

            if (paragraphs != null)
            {
                for (int i = 0; i < paragraphs.Length; i++)
                {
                    CT_P p = ftr.AddNewP();
                    //ftr.PArray=(0, paragraphs[i].CTP);		// MB 23 May 2010
                    ftr.SetPArray(i, paragraphs[i].GetCTP());           // MB 23 May 2010
                }
            }
            else
            {
                CT_P   p            = ftr.AddNewP();
                byte[] rsidr        = doc.Document.body.GetPArray(0).rsidR;
                byte[] rsidrdefault = doc.Document.body.GetPArray(0).rsidRDefault;
                p.rsidR        = (rsidr);
                p.rsidRDefault = (rsidrdefault);
                CT_PPr pPr             = p.AddNewPPr();
                pPr.AddNewPStyle().val = (pStyle);
            }
            return(ftr);
        }
コード例 #2
0
        /**
         * MB 24 May 2010. Created this overloaded buildHdrFtr() method because testing demonstrated
         * that the XWPFFooter or XWPFHeader object returned by calls to the CreateHeader(int, XWPFParagraph[])
         * and CreateFooter(int, XWPFParagraph[]) methods or the GetXXXXXHeader/Footer methods where
         * headers or footers had been Added to a document since it had been Created/opened, returned
         * an object that Contained no XWPFParagraph objects even if the header/footer itself did contain
         * text. The reason was that this line of code; CTHdrFtr ftr = CTHdrFtr.Factory.NewInstance();
         * Created a brand new instance of the CTHDRFtr class which was then populated with data when
         * it should have recovered the CTHdrFtr object encapsulated within the XWPFHeaderFooter object
         * that had previoulsy been instantiated in the CreateHeader(int, XWPFParagraph[]) or
         * CreateFooter(int, XWPFParagraph[]) methods.
         */
        private CT_HdrFtr buildHdrFtr(String pStyle, XWPFParagraph[] paragraphs, XWPFHeaderFooter wrapper)
        {
            CT_HdrFtr ftr = wrapper._getHdrFtr();

            if (paragraphs != null)
            {
                for (int i = 0; i < paragraphs.Length; i++)
                {
                    CT_P p = ftr.AddNewP();
                    ftr.SetPArray(i, paragraphs[i].GetCTP());
                }
            }
            else
            {
                CT_P    p    = ftr.AddNewP();
                CT_Body body = doc.Document.body;
                if (body.SizeOfPArray() > 0)
                {
                    CT_P p0 = body.GetPArray(0);
                    if (p0.IsSetRsidR())
                    {
                        byte[] rsidr        = p0.rsidR;
                        byte[] rsidrdefault = p0.rsidRDefault;
                        p.rsidP        = rsidr;
                        p.rsidRDefault = rsidrdefault;
                    }
                }
                CT_PPr pPr             = p.AddNewPPr();
                pPr.AddNewPStyle().val = (pStyle);
            }
            return(ftr);
        }
コード例 #3
0
        /**
         * Adds a new paragraph at the end of the header or footer
         */
        public XWPFParagraph CreateParagraph()
        {
            XWPFParagraph paragraph = new XWPFParagraph(headerFooter.AddNewP(), this);

            paragraphs.Add(paragraph);
            return(paragraph);
        }
コード例 #4
0
        private CT_HdrFtr buildHdrFtr(string pStyle, XWPFParagraph[] paragraphs, XWPFHeaderFooter wrapper)
        {
            CT_HdrFtr hdrFtr = wrapper._getHdrFtr();

            if (paragraphs != null)
            {
                for (int i = 0; i < paragraphs.Length; ++i)
                {
                    hdrFtr.AddNewP();
                    hdrFtr.SetPArray(i, paragraphs[i].GetCTP());
                }
            }
            else
            {
                CT_P   ctP          = hdrFtr.AddNewP();
                byte[] rsidR        = this.doc.Document.body.GetPArray(0).rsidR;
                byte[] rsidRdefault = this.doc.Document.body.GetPArray(0).rsidRDefault;
                ctP.rsidP        = rsidR;
                ctP.rsidRDefault = rsidRdefault;
                ctP.AddNewPPr().AddNewPStyle().val = pStyle;
            }
            return(hdrFtr);
        }
コード例 #5
0
        private CT_HdrFtr buildHdrFtr(string pStyle, XWPFParagraph[] paragraphs)
        {
            CT_HdrFtr ctHdrFtr = new CT_HdrFtr();

            if (paragraphs != null)
            {
                for (int i = 0; i < paragraphs.Length; ++i)
                {
                    ctHdrFtr.AddNewP();
                    ctHdrFtr.SetPArray(i, paragraphs[i].GetCTP());
                }
            }
            else
            {
                CT_P   ctP          = ctHdrFtr.AddNewP();
                byte[] rsidR        = this.doc.Document.body.GetPArray(0).rsidR;
                byte[] rsidRdefault = this.doc.Document.body.GetPArray(0).rsidRDefault;
                ctP.rsidR        = rsidR;
                ctP.rsidRDefault = rsidRdefault;
                ctP.AddNewPPr().AddNewPStyle().val = pStyle;
            }
            return(ctHdrFtr);
        }
コード例 #6
0
        /**
         * MB 24 May 2010. Created this overloaded buildHdrFtr() method because testing demonstrated
         * that the XWPFFooter or XWPFHeader object returned by calls to the CreateHeader(int, XWPFParagraph[])
         * and CreateFooter(int, XWPFParagraph[]) methods or the GetXXXXXHeader/Footer methods where
         * headers or footers had been Added to a document since it had been Created/opened, returned
         * an object that Contained no XWPFParagraph objects even if the header/footer itself did contain
         * text. The reason was that this line of code; CTHdrFtr ftr = CTHdrFtr.Factory.NewInstance();
         * Created a brand new instance of the CTHDRFtr class which was then populated with data when
         * it should have recovered the CTHdrFtr object encapsulated within the XWPFHeaderFooter object
         * that had previoulsy been instantiated in the CreateHeader(int, XWPFParagraph[]) or
         * CreateFooter(int, XWPFParagraph[]) methods.
         */

        private CT_HdrFtr buildHdrFtr(string pStyle, XWPFParagraph[] paragraphs, XWPFHeaderFooter wrapper)
        {
            CT_HdrFtr ftr = wrapper._getHdrFtr();

            if (paragraphs != null)
            {
                for (int i = 0; i < paragraphs.Length; i++)
                {
                    CT_P p = ftr.AddNewP();
                    ftr.SetPArray(i, paragraphs[i].GetCTP());
                }
            }
            else
            {
                CT_P   p            = ftr.AddNewP();
                byte[] rsidr        = doc.Document.body.GetPArray(0).rsidR;
                byte[] rsidrdefault = doc.Document.body.GetPArray(0).rsidRDefault;
                p.rsidP        = (rsidr);
                p.rsidRDefault = (rsidrdefault);
                CT_PPr pPr             = p.AddNewPPr();
                pPr.AddNewPStyle().val = (pStyle);
            }
            return(ftr);
        }
コード例 #7
0
 private CT_HdrFtr buildHdrFtr(String pStyle, XWPFParagraph[] paragraphs)
 {
     CT_HdrFtr ftr = new CT_HdrFtr();
     if (paragraphs != null) {
         for (int i = 0 ; i < paragraphs.Length ; i++) {
             CT_P p = ftr.AddNewP();
             //ftr.PArray=(0, paragraphs[i].CTP);		// MB 23 May 2010
             ftr.SetPArray(i, paragraphs[i].GetCTP());   	// MB 23 May 2010
         }
     }
     else {
         CT_P p = ftr.AddNewP();
         byte[] rsidr = doc.Document.body.GetPArray(0).rsidR;
         byte[] rsidrdefault = doc.Document.body.GetPArray(0).rsidRDefault;
         p.rsidR = (rsidr);
         p.rsidRDefault = (rsidrdefault);
         CT_PPr pPr = p.AddNewPPr();
         pPr.AddNewPStyle().val = (pStyle);
     }
     return ftr;
 }