Examples of CTP


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

        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();
        String tText = "Paragraph in header";
        t.setStringValue(tText);

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

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

     assertEquals(4, doc.getParagraphs().size());
    
     assertEquals(3, doc.getParagraphPos(3));
      assertEquals(3, doc.getPosOfParagraph(p));

     CTP ctp = p.getCTP();
     XWPFParagraph newP = doc.getParagraph(ctp);
     assertSame(p, newP);
     XmlCursor cursor = doc.getDocument().getBody().getPArray(0).newCursor();
     XWPFParagraph cP = doc.insertNewParagraph(cursor);
     assertSame(cP, doc.getParagraphs().get(0));
View Full Code Here

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

        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

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

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

        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
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.