private CT_HdrFtr buildHdr(ST_HdrFtr type, string pStyle, XWPFHeaderFooter wrapper, XWPFParagraph[] pars)
        {
            CT_HdrFtr ctHdrFtr = this.buildHdrFtr(pStyle, pars, wrapper);

            this.SetHeaderReference(type, wrapper);
            return(ctHdrFtr);
        }
 public XWPFHeaderFooterPolicy(XWPFDocument doc, CT_SectPr sectPr)
 {
     this.doc = doc;
     for (int i = 0; i < sectPr.SizeOfHeaderReferenceArray(); ++i)
     {
         CT_HdrFtrRef       headerReferenceArray = sectPr.GetHeaderReferenceArray(i);
         POIXMLDocumentPart relationById         = doc.GetRelationById(headerReferenceArray.id);
         XWPFHeader         hdr = (XWPFHeader)null;
         if (relationById != null && relationById is XWPFHeader)
         {
             hdr = (XWPFHeader)relationById;
         }
         ST_HdrFtr type = headerReferenceArray.type;
         this.assignHeader(hdr, type);
     }
     for (int i = 0; i < sectPr.SizeOfFooterReferenceArray(); ++i)
     {
         CT_HdrFtrRef       footerReferenceArray = sectPr.GetFooterReferenceArray(i);
         POIXMLDocumentPart relationById         = doc.GetRelationById(footerReferenceArray.id);
         XWPFFooter         ftr = (XWPFFooter)null;
         if (relationById != null && relationById is XWPFFooter)
         {
             ftr = (XWPFFooter)relationById;
         }
         ST_HdrFtr type = footerReferenceArray.type;
         this.assignFooter(ftr, type);
     }
 }
Beispiel #3
0
        private void SetHeaderReference(ST_HdrFtr type, XWPFHeaderFooter wrapper)
        {
            CT_HdrFtrRef ref1 = doc.Document.body.sectPr.AddNewHeaderReference();

            ref1.type = (type);
            ref1.id   = (doc.GetRelationId(wrapper));
        }
        private void SetHeaderReference(ST_HdrFtr type, XWPFHeaderFooter wrapper)
        {
            CT_HdrFtrRef ref1 = doc.Document.body.sectPr.AddNewHeaderReference();

            ref1.type = (type);
            ref1.id   = (wrapper.GetPackageRelationship().Id);
        }
        private void SetHeaderReference(ST_HdrFtr type, XWPFHeaderFooter wrapper)
        {
            CT_HdrFtrRef ctHdrFtrRef = this.doc.Document.body.sectPr.AddNewHeaderReference();

            ctHdrFtrRef.type = type;
            ctHdrFtrRef.id   = wrapper.GetPackageRelationship().Id;
        }
        private CT_HdrFtr buildHdr(ST_HdrFtr type, String pStyle, XWPFHeaderFooter wrapper, XWPFParagraph[] pars)
        {
            //CTHdrFtr hdr = buildHdrFtr(pStyle, pars);				// MB 24 May 2010
            CT_HdrFtr hdr = buildHdrFtr(pStyle, pars, wrapper);         // MB 24 May 2010

            SetHeaderReference(type, wrapper);
            return(hdr);
        }
 private void assignFooter(XWPFFooter ftr, ST_HdrFtr type)
 {
     if (type == ST_HdrFtr.first)
     {
         firstPageFooter = ftr;
     }
     else if (type == ST_HdrFtr.even)
     {
         evenPageFooter = ftr;
     }
     else
     {
         defaultFooter = ftr;
     }
 }
 private void assignHeader(XWPFHeader hdr, ST_HdrFtr type)
 {
     if (type == ST_HdrFtr.FIRST)
     {
         this.firstPageHeader = hdr;
     }
     else if (type == ST_HdrFtr.EVEN)
     {
         this.evenPageHeader = hdr;
     }
     else
     {
         this.defaultHeader = hdr;
     }
 }
 private void assignFooter(XWPFFooter ftr, ST_HdrFtr type)
 {
     if (type == ST_HdrFtr.FIRST)
     {
         this.firstPageFooter = ftr;
     }
     else if (type == ST_HdrFtr.EVEN)
     {
         this.evenPageFooter = ftr;
     }
     else
     {
         this.defaultFooter = ftr;
     }
 }
 private void assignHeader(XWPFHeader hdr, ST_HdrFtr type)
 {
     if (type == ST_HdrFtr.first)
     {
         firstPageHeader = hdr;
     }
     else if (type == ST_HdrFtr.even)
     {
         evenPageHeader = hdr;
     }
     else
     {
         defaultHeader = hdr;
     }
 }
        public XWPFFooter CreateFooter(ST_HdrFtr type, XWPFParagraph[] pars)
        {
            XWPFRelation footer        = XWPFRelation.FOOTER;
            string       pStyle        = "Footer";
            int          relationIndex = this.GetRelationIndex(footer);
            FtrDocument  ftrDocument   = new FtrDocument();
            XWPFFooter   relationship  = (XWPFFooter)this.doc.CreateRelationship((POIXMLRelation)footer, (POIXMLFactory)XWPFFactory.GetInstance(), relationIndex);
            CT_HdrFtr    headerFooter  = this.buildFtr(type, pStyle, (XWPFHeaderFooter)relationship, pars);

            relationship.SetHeaderFooter(headerFooter);
            Stream outputStream = relationship.GetPackagePart().GetOutputStream();

            ftrDocument.SetFtr((CT_Ftr)headerFooter);
            this.assignFooter(relationship, type);
            ftrDocument.Save(outputStream, this.Commit((XWPFHeaderFooter)relationship));
            outputStream.Close();
            return(relationship);
        }
        public XWPFHeader CreateHeader(ST_HdrFtr type, XWPFParagraph[] pars)
        {
            XWPFRelation relation = XWPFRelation.HEADER;
            String       pStyle   = "Header";
            int          i        = GetRelationIndex(relation);
            HdrDocument  hdrDoc   = new HdrDocument();
            XWPFHeader   wrapper  = (XWPFHeader)doc.CreateRelationship(relation, XWPFFactory.GetInstance(), i);

            CT_HdrFtr hdr = buildHdr(type, pStyle, wrapper, pars);

            wrapper.SetHeaderFooter(hdr);

            hdrDoc.SetHdr((CT_Hdr)hdr);

            assignHeader(wrapper, type);
            using (Stream outputStream = wrapper.GetPackagePart().GetOutputStream())
            {
                hdrDoc.Save(outputStream);
            }
            return(wrapper);
        }
        public XWPFFooter CreateFooter(ST_HdrFtr type, XWPFParagraph[] pars)
        {
            XWPFRelation relation = XWPFRelation.FOOTER;
            String       pStyle   = "Footer";
            int          i        = GetRelationIndex(relation);
            FtrDocument  ftrDoc   = new FtrDocument();
            XWPFFooter   wrapper  = (XWPFFooter)doc.CreateRelationship(relation, XWPFFactory.GetInstance(), i);

            CT_HdrFtr ftr = buildFtr(type, pStyle, wrapper, pars);

            wrapper.SetHeaderFooter(ftr);

            ftrDoc.SetFtr((CT_Ftr)ftr);

            assignFooter(wrapper, type);
            using (Stream outputStream = wrapper.GetPackagePart().GetOutputStream())
            {
                ftrDoc.Save(outputStream);
            }
            return(wrapper);
        }
 /**
  * Figures out the policy for the given document,
  *  and Creates any header and footer objects
  *  as required.
  */
 public XWPFHeaderFooterPolicy(XWPFDocument doc, CT_SectPr sectPr)
 {
     // Grab what headers and footers have been defined
     // For now, we don't care about different ranges, as it
     //  doesn't seem that .docx properly supports that
     //  feature of the file format yet
     this.doc = doc;
     for (int i = 0; i < sectPr.SizeOfHeaderReferenceArray(); i++)
     {
         // Get the header
         CT_HdrFtrRef       ref1        = sectPr.GetHeaderReferenceArray(i);
         POIXMLDocumentPart relatedPart = doc.GetRelationById(ref1.id);
         XWPFHeader         hdr         = null;
         if (relatedPart != null && relatedPart is XWPFHeader)
         {
             hdr = (XWPFHeader)relatedPart;
         }
         // Assign it
         ST_HdrFtr type = ref1.type;
         assignHeader(hdr, type);
     }
     for (int i = 0; i < sectPr.SizeOfFooterReferenceArray(); i++)
     {
         // Get the footer
         CT_HdrFtrRef       ref1        = sectPr.GetFooterReferenceArray(i);
         POIXMLDocumentPart relatedPart = doc.GetRelationById(ref1.id);
         XWPFFooter         ftr         = null;
         if (relatedPart != null && relatedPart is XWPFFooter)
         {
             ftr = (XWPFFooter)relatedPart;
         }
         // Assign it
         ST_HdrFtr type = ref1.type;
         assignFooter(ftr, type);
     }
 }
 static ST_HdrFtr()
 {
     ST_HdrFtr.even     = new ST_HdrFtr("even");
     ST_HdrFtr._default = new ST_HdrFtr("default");
     ST_HdrFtr.first    = new ST_HdrFtr("first");
 }
Beispiel #16
0
 private void SetHeaderReference(ST_HdrFtr type, XWPFHeaderFooter wrapper)
 {
     CT_HdrFtrRef ref1 = doc.Document.body.sectPr.AddNewHeaderReference();
     ref1.type = (type);
     ref1.id = (wrapper.GetPackageRelationship().Id);
 }
Beispiel #17
0
 private CT_HdrFtr buildHdr(ST_HdrFtr type, String pStyle, XWPFHeaderFooter wrapper, XWPFParagraph[] pars)
 {
     //CTHdrFtr hdr = buildHdrFtr(pStyle, pars);				// MB 24 May 2010
     CT_HdrFtr hdr = buildHdrFtr(pStyle, pars, wrapper);		// MB 24 May 2010
     SetHeaderReference(type, wrapper);
     return hdr;
 }
Beispiel #18
0
        public XWPFFooter CreateFooter(ST_HdrFtr type, XWPFParagraph[] pars)
        {
            XWPFRelation relation = XWPFRelation.FOOTER;
            String pStyle = "Footer";
            int i = GetRelationIndex(relation);
            FtrDocument ftrDoc = new FtrDocument();
            XWPFFooter wrapper = (XWPFFooter)doc.CreateRelationship(relation, XWPFFactory.GetInstance(), i);

            CT_HdrFtr ftr = buildFtr(type, pStyle, wrapper, pars);
            wrapper.SetHeaderFooter(ftr);

            Stream outputStream = wrapper.GetPackagePart().GetOutputStream();
            ftrDoc.SetFtr((CT_Ftr)ftr);

            //XmlOptions xmlOptions = Commit(wrapper);

            assignFooter(wrapper, type);
            ftrDoc.Save(outputStream, Commit(wrapper));
            outputStream.Close();
            return wrapper;
        }
Beispiel #19
0
 public XWPFFooter CreateFooter(ST_HdrFtr type)
 {
     return CreateFooter(type, null);
 }
Beispiel #20
0
 public XWPFHeader CreateHeader(ST_HdrFtr type)
 {
     return CreateHeader(type, null);
 }
Beispiel #21
0
 private void assignHeader(XWPFHeader hdr, ST_HdrFtr type)
 {
     if (type == ST_HdrFtr.FIRST)
     {
         firstPageHeader = hdr;
     }
     else if (type == ST_HdrFtr.EVEN)
     {
         evenPageHeader = hdr;
     }
     else
     {
         defaultHeader = hdr;
     }
 }
Beispiel #22
0
 private void assignFooter(XWPFFooter ftr, ST_HdrFtr type)
 {
     if (type == ST_HdrFtr.FIRST)
     {
         firstPageFooter = ftr;
     }
     else if (type == ST_HdrFtr.EVEN)
     {
         evenPageFooter = ftr;
     }
     else
     {
         defaultFooter = ftr;
     }
 }
 public XWPFHeader CreateHeader(ST_HdrFtr type)
 {
     return(this.CreateHeader(type, (XWPFParagraph[])null));
 }
Beispiel #24
0
 static ST_HdrFtr()
 {
     even     = new ST_HdrFtr("even");
     _default = new ST_HdrFtr("default");
     first    = new ST_HdrFtr("first");
 }
 public XWPFFooter CreateFooter(ST_HdrFtr type)
 {
     return(CreateFooter(type, null));
 }
        public XWPFHeader CreateHeader(ST_HdrFtr type, XWPFParagraph[] pars)
        {
            XWPFRelation relation = XWPFRelation.HEADER;
            String pStyle = "Header";
            int i = GetRelationIndex(relation);
            HdrDocument hdrDoc = new HdrDocument();
            XWPFHeader wrapper = (XWPFHeader)doc.CreateRelationship(relation, XWPFFactory.GetInstance(), i);

            CT_HdrFtr hdr = buildHdr(type, pStyle, wrapper, pars);
            wrapper.SetHeaderFooter(hdr);

            hdrDoc.SetHdr((CT_Hdr)hdr);

            assignHeader(wrapper, type);
            using (Stream outputStream = wrapper.GetPackagePart().GetOutputStream())
            {
                hdrDoc.Save(outputStream);
            }
            return wrapper;
        }
 public XWPFHeader CreateHeader(ST_HdrFtr type)
 {
     return(CreateHeader(type, null));
 }