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

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


      if(isCursorInBody(cursor)){
        String uri = CTP.type.getName().getNamespaceURI();
        String localPart = "p";
        cursor.beginElement(localPart,uri);
        cursor.toParent();
        CTP p = (CTP)cursor.getObject();
        XWPFParagraph newP = new XWPFParagraph(p, this);
        XmlObject o = null;
        while(!(o instanceof CTP)&&(cursor.toPrevSibling())){
          o = cursor.getObject();
        }
        if((!(o instanceof CTP)) || (CTP)o == p){
          paragraphs.add(0, newP);
        }
        else{
          int pos = paragraphs.indexOf(getParagraph((CTP)o))+1;
          paragraphs.add(pos,newP);
        }
        int i=0;
        cursor.toCursor(p.newCursor());
      while(cursor.toPrevSibling()){
        o =cursor.getObject();
        if(o instanceof CTP || o instanceof CTTbl)
          i++;
      }
      bodyElements.add(i, newP);
        cursor.toCursor(p.newCursor());
        cursor.toEndToken();
        return newP;
      }
      return null;
    }
View Full Code Here


  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();
      pPr.addNewPStyle().setVal(pStyle);
    }
    return ftr;
  }
View Full Code Here

   */
  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();
      pPr.addNewPStyle().setVal(pStyle);
    }
    return ftr;
  }
View Full Code Here

  /*
   * This is the default Watermark paragraph; the only variable is the text message
   * TODO: manage all the other variables
   */
  private XWPFParagraph getWatermarkParagraph(String text, int idx) {
    CTP p = CTP.Factory.newInstance();
    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();
    pPr.addNewPStyle().setVal("Header");
    // start watermark paragraph
    CTR r = p.addNewR();
    CTRPr rPr = r.addNewRPr();
    rPr.addNewNoProof();
    CTPicture pict = r.addNewPict();
    CTGroup group = CTGroup.Factory.newInstance();
    CTShapetype shapetype = group.addNewShapetype();
View Full Code Here

    XWPFHeaderFooterPolicy policy = sampleDoc.getHeaderFooterPolicy();
    assertNull(policy.getDefaultHeader());
    assertNull(policy.getFirstPageHeader());
    assertNull(policy.getDefaultFooter());

    CTP ctP1 = CTP.Factory.newInstance();
    CTR ctR1 = ctP1.addNewR();
    CTText t = ctR1.addNewT();
    t.setStringValue("Paragraph in header");

    // Commented MB 23 May 2010
    //CTP ctP2 = CTP.Factory.newInstance();
    //CTR ctR2 = ctP2.addNewR();
    //CTText t2 = ctR2.addNewT();
    //t2.setStringValue("Second paragraph.. for footer");
   
    // Create two paragraphs for insertion into the footer.
    // Previously only one was inserted MB 23 May 2010
    CTP ctP2 = CTP.Factory.newInstance();
    CTR ctR2 = ctP2.addNewR();
    CTText t2 = ctR2.addNewT();
    t2.setStringValue("First paragraph for the footer");
   
    CTP ctP3 = CTP.Factory.newInstance();
    CTR ctR3 = ctP3.addNewR();
    CTText t3 = ctR3.addNewT();
    t3.setStringValue("Second paragraph for the footer");

    XWPFParagraph p1 = new XWPFParagraph(ctP1, sampleDoc);
    XWPFParagraph[] pars = new XWPFParagraph[1];
View Full Code Here

    public void testGetText() {
        CTTbl table = CTTbl.Factory.newInstance();
        CTRow row = table.addNewTr();
        CTTc cell = row.addNewTc();
        CTP paragraph = cell.addNewP();
        CTR run = paragraph.addNewR();
        CTText text = run.addNewT();
        text.setStringValue("finally I can write!");

        XWPFTable xtab = new XWPFTable(null, table);
        assertEquals("finally I can write!\n", xtab.getText());
View Full Code Here

        return ctTc.sizeOfPArray() == 0 ? null : new XWPFParagraph(ctTc.getPArray(0));
    }


    public void setText(String text) {
        CTP ctP = (ctTc.sizeOfPArray() == 0) ? ctTc.addNewP() : ctTc.getPArray(0);
        XWPFParagraph par = new XWPFParagraph(ctP);
        par.createRun().setText(text);
    }
View Full Code Here

    rPr.addNewBCs().setVal(STOnOff.OFF);
    rPr.addNewColor().setVal("auto");
    rPr.addNewSz().setVal(new BigInteger("24"));
    rPr.addNewSzCs().setVal(new BigInteger("24"));
    CTSdtContentBlock content = block.addNewSdtContent();
    CTP p = content.addNewP();
    p.setRsidR("00EF7E24".getBytes());
    p.setRsidRDefault("00EF7E24".getBytes());
    p.addNewPPr().addNewPStyle().setVal("TOCHeading");
    p.addNewR().addNewT().set("Table of Contents");
  }
View Full Code Here

    return this.block;
  }

  public void addRow(int level, String title, int page, String bookmarkRef) {
    CTSdtContentBlock contentBlock = this.block.getSdtContent();
    CTP p = contentBlock.addNewP();
    p.setRsidR("00EF7E24".getBytes());
    p.setRsidRDefault("00EF7E24".getBytes());
    CTPPr pPr = p.addNewPPr();
    pPr.addNewPStyle().setVal("TOC" + level);
    CTTabs tabs = pPr.addNewTabs();
    CTTabStop tab = tabs.addNewTab();
    tab.setVal(STTabJc.RIGHT);
    tab.setLeader(STTabTlc.DOT);
    tab.setPos(new BigInteger("8290"));
    pPr.addNewRPr().addNewNoProof();
    CTR run = p.addNewR();
    run.addNewRPr().addNewNoProof();
    run.addNewT().set(title);
    run = p.addNewR();
    run.addNewRPr().addNewNoProof();
    run.addNewTab();
    run = p.addNewR();
    run.addNewRPr().addNewNoProof();
    run.addNewFldChar().setFldCharType(STFldCharType.BEGIN);
    // pageref run
    run = p.addNewR();
    run.addNewRPr().addNewNoProof();
    CTText text = run.addNewInstrText();
    text.setSpace(Space.PRESERVE);
    // bookmark reference
    text.set(" PAGEREF _Toc" + bookmarkRef + " \\h ");
    p.addNewR().addNewRPr().addNewNoProof();
    run = p.addNewR();
    run.addNewRPr().addNewNoProof();
    run.addNewFldChar().setFldCharType(STFldCharType.SEPARATE);
    // page number run
    run = p.addNewR();
    run.addNewRPr().addNewNoProof();
    run.addNewT().set(Integer.valueOf(page).toString());
    run = p.addNewR();
    run.addNewRPr().addNewNoProof();
    run.addNewFldChar().setFldCharType(STFldCharType.END);
  }
View Full Code Here

  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());
      }
    }
    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();
      pPr.addNewPStyle().setVal(pStyle);
    }
    return ftr;
  }
View Full Code Here

TOP

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

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.