Package org.openxmlformats.schemas.wordprocessingml.x2006.main

Examples of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr


        XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("bookmarks.docx");
        XWPFParagraph paragraph = doc.getParagraphs().get(0);
        assertEquals("Sample Word Document", paragraph.getText());
        assertEquals(1, paragraph.getCTP().sizeOfBookmarkStartArray());
        assertEquals(0, paragraph.getCTP().sizeOfBookmarkEndArray());
        CTBookmark ctBookmark = paragraph.getCTP().getBookmarkStartArray(0);
        assertEquals("poi", ctBookmark.getName());
        for(CTBookmark bookmark : paragraph.getCTP().getBookmarkStartList()) {
           assertEquals("poi", bookmark.getName());
        }
    }
View Full Code Here


        CTP ctp = p.getCTP();
        CTPPr ppr = ctp.getPPr()== null? ctp.addNewPPr() : ctp.getPPr();

        //bordi
        CTPBdr bdr = ppr.addNewPBdr();
        CTBorder borderTop = bdr.addNewTop();
        borderTop.setVal(STBorder.DOUBLE);
        bdr.setTop(borderTop);

        assertEquals(Borders.DOUBLE, p.getBorderTop());
        p.setBorderTop(Borders.SINGLE);
        assertEquals(STBorder.SINGLE, borderTop.getVal());
    }
View Full Code Here

    public void testAddPageBreak() {
  ctRun.addNewT().setStringValue("TEST STRING");
  ctRun.addNewBr();
  ctRun.addNewT().setStringValue("TEST2 STRING");
  CTBr breac=ctRun.addNewBr();
  breac.setClear(STBrClear.LEFT);
  ctRun.addNewT().setStringValue("TEST3 STRING");
        assertEquals(2, ctRun.sizeOfBrArray());
       
        XWPFRun run = new XWPFRun(CTR.Factory.newInstance(), p);
        run.setText("TEXT1");
View Full Code Here

    for(int i=0; i<sectPr.sizeOfHeaderReferenceArray(); i++) {
      // Get the header
      CTHdrFtrRef ref = sectPr.getHeaderReferenceArray(i);
      PackagePart hdrPart = doc.getPartById(ref.getId());
      HdrDocument hdrDoc = HdrDocument.Factory.parse(hdrPart.getInputStream());
      CTHdrFtr hdrFtr = hdrDoc.getHdr();
      XWPFHeader hdr = new XWPFHeader(doc, hdrFtr);

      // Assign it
      Enum type = ref.getType();
      assignHeader(hdr, type);
View Full Code Here

      String pStyle = "Header";
      int i = getRelationIndex(relation);
      HdrDocument hdrDoc = HdrDocument.Factory.newInstance();
      XWPFHeader wrapper = (XWPFHeader)doc.createRelationship(relation, XWPFFactory.getInstance(), i);

      CTHdrFtr hdr = buildHdr(type, pStyle, wrapper, pars);
      wrapper.setHeaderFooter(hdr);
     
      OutputStream outputStream = wrapper.getPackagePart().getOutputStream();
      hdrDoc.setHdr(hdr);
     
View Full Code Here

      String pStyle = "Footer";
      int i = getRelationIndex(relation);
      FtrDocument ftrDoc = FtrDocument.Factory.newInstance();
      XWPFFooter wrapper = (XWPFFooter)doc.createRelationship(relation, XWPFFactory.getInstance(), i);

      CTHdrFtr ftr = buildFtr(type, pStyle, wrapper, pars);
      wrapper.setHeaderFooter(ftr);
     
      OutputStream outputStream = wrapper.getPackagePart().getOutputStream();
      ftrDoc.setFtr(ftr);
     
View Full Code Here

  }


  private CTHdrFtr buildFtr(Enum type, String pStyle, XWPFHeaderFooter wrapper, XWPFParagraph[] pars) {
    //CTHdrFtr ftr = buildHdrFtr(pStyle, pars);        // MB 24 May 2010
    CTHdrFtr ftr = buildHdrFtr(pStyle, pars, wrapper);    // MB 24 May 2010
      setFooterReference(type, wrapper);
    return ftr;
  }
View Full Code Here

  }


  private CTHdrFtr buildHdr(Enum type, String pStyle, XWPFHeaderFooter wrapper, XWPFParagraph[] pars) {
    //CTHdrFtr hdr = buildHdrFtr(pStyle, pars);        // MB 24 May 2010
    CTHdrFtr hdr = buildHdrFtr(pStyle, pars, wrapper);    // MB 24 May 2010
      setHeaderReference(type, wrapper);
    return hdr;
  }
View Full Code Here

      setHeaderReference(type, wrapper);
    return hdr;
  }

  private CTHdrFtr buildHdrFtr(String pStyle, XWPFParagraph[] paragraphs) {
    CTHdrFtr ftr = CTHdrFtr.Factory.newInstance();
    if (paragraphs != null) {
      for (int i = 0 ; i < paragraphs.length ; i++) {
        CTP p = ftr.addNewP();
        //ftr.setPArray(0, paragraphs[i].getCTP());    // MB 23 May 2010
        ftr.setPArray(i, paragraphs[i].getCTP());     // MB 23 May 2010
      }
    }
    else {
      CTP p = ftr.addNewP();
      byte[] rsidr = doc.getDocument().getBody().getPArray(0).getRsidR();
      byte[] rsidrdefault = doc.getDocument().getBody().getPArray(0).getRsidRDefault();
      p.setRsidP(rsidr);
      p.setRsidRDefault(rsidrdefault);
      CTPPr pPr = p.addNewPPr();
View Full Code Here

   * 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 CTHdrFtr buildHdrFtr(String pStyle, XWPFParagraph[] paragraphs, XWPFHeaderFooter wrapper) {
    CTHdrFtr ftr = wrapper._getHdrFtr();
    if (paragraphs != null) {
      for (int i = 0 ; i < paragraphs.length ; i++) {
        CTP p = ftr.addNewP();
        ftr.setPArray(i, paragraphs[i].getCTP());
      }
    }
    else {
      CTP p = ftr.addNewP();
      byte[] rsidr = doc.getDocument().getBody().getPArray(0).getRsidR();
      byte[] rsidrdefault = doc.getDocument().getBody().getPArray(0).getRsidRDefault();
      p.setRsidP(rsidr);
      p.setRsidRDefault(rsidrdefault);
      CTPPr pPr = p.addNewPPr();
View Full Code Here

TOP

Related Classes of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHdrFtr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.