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

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


    public void testSetGetWordWrap() {
        XWPFDocument doc = new XWPFDocument();
        XWPFParagraph p = doc.createParagraph();

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

        CTOnOff wordWrap = ppr.addNewWordWrap();
        wordWrap.setVal(STOnOff.FALSE);
        assertEquals(false, p.isWordWrap());
View Full Code Here


    public void testSetGetPageBreak() {
        XWPFDocument doc = new XWPFDocument();
        XWPFParagraph p = doc.createParagraph();

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

        CTOnOff pageBreak = ppr.addNewPageBreakBefore();
        pageBreak.setVal(STOnOff.FALSE);
        assertEquals(false, p.isPageBreak());
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

        if(isCursorInHdrF(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

      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

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

       
    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;
    }
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

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.