Examples of CTP


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

            // creates a new Paragraph, cursor is positioned inside the new
            // element
            cursor.beginElement(localPart, uri);
            // move the cursor to the START token to the paragraph just created
            cursor.toParent();
            CTP p = (CTP) cursor.getObject();
            XWPFParagraph newP = new XWPFParagraph(p, this);
            XmlObject o = null;
            /*
             * move the cursor to the previous element until a) the next
             * paragraph is found or b) all elements have been passed
             */
            while (!(o instanceof CTP) && (cursor.toPrevSibling())) {
                o = cursor.getObject();
            }
            /*
             * if the object that has been found is a) not a paragraph or b) is
             * the paragraph that has just been inserted, as the cursor in the
             * while loop above was not moved as there were no other siblings,
             * then the paragraph that was just inserted is the first paragraph
             * in the body. Otherwise, take the previous paragraph and calculate
             * the new index for the new paragraph.
             */
            if ((!(o instanceof CTP)) || (CTP) o == p) {
                paragraphs.add(0, newP);
            } else {
                int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
                paragraphs.add(pos, newP);
            }

            /*
             * create a new cursor, that points to the START token of the just
             * inserted paragraph
             */
            XmlCursor newParaPos = p.newCursor();
            try {
                /*
                 * Calculate the paragraphs index in the list of all body
                 * elements
                 */
 
View Full Code Here

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

  }
  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

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

  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

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

            // creates a new Paragraph, cursor is positioned inside the new
            // element
            cursor.beginElement(localPart, uri);
            // move the cursor to the START token to the paragraph just created
            cursor.toParent();
            CTP p = (CTP) cursor.getObject();
            XWPFParagraph newP = new XWPFParagraph(p, this);
            XmlObject o = null;
            /*
             * move the cursor to the previous element until a) the next
             * paragraph is found or b) all elements have been passed
             */
            while (!(o instanceof CTP) && (cursor.toPrevSibling())) {
                o = cursor.getObject();
            }
            /*
             * if the object that has been found is a) not a paragraph or b) is
             * the paragraph that has just been inserted, as the cursor in the
             * while loop above was not moved as there were no other siblings,
             * then the paragraph that was just inserted is the first paragraph
             * in the body. Otherwise, take the previous paragraph and calculate
             * the new index for the new paragraph.
             */
            if ((!(o instanceof CTP)) || (CTP) o == p) {
                paragraphs.add(0, newP);
            } else {
                int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
                paragraphs.add(pos, newP);
            }

            /*
             * create a new cursor, that points to the START token of the just
             * inserted paragraph
             */
            XmlCursor newParaPos = p.newCursor();
            try {
                /*
                 * Calculate the paragraphs index in the list of all body
                 * elements
                 */
 
View Full Code Here

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

    }
      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

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

       
    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

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

    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

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

     */
    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

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

    /*
     * 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

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

        if(isCursorInFtn(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
TOP
Copyright © 2018 www.massapi.com. 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.