Package org.docx4j.wml

Examples of org.docx4j.wml.P


    List<FieldRef> fieldRefs = new ArrayList<FieldRef>();
    for( P p : fl.getStarts() ) {
      int index;
      if (p.getParent() instanceof ContentAccessor) {
        index = ((ContentAccessor)p.getParent()).getContent().indexOf(p);
        P newP = FieldsPreprocessor.canonicalise(p, fieldRefs);
//        log.debug("NewP length: " + newP.getContent().size() );
        ((ContentAccessor)p.getParent()).getContent().set(index, newP);
      } else if (p.getParent() instanceof java.util.List) {
        // This does happen!
        index = ((java.util.List)p.getParent()).indexOf(p);
        P newP = FieldsPreprocessor.canonicalise(p, fieldRefs);
//        log.debug("NewP length: " + newP.getContent().size() );
        ((java.util.List)p.getParent()).set(index, newP);       
      } else {
        throw new Docx4JException ("Unexpected parent: " + p.getParent().getClass().getName() );
      }
View Full Code Here


    return fp.canonicaliseInstance(p);
  }
 
  private P canonicaliseInstance(P p) {

    P newP = Context.getWmlObjectFactory().createP();
    newP.setPPr(p.getPPr());
   
    newR = Context.getWmlObjectFactory().createR();
//    fieldRPr = null;
   
    stack = new LinkedList<FieldRef>();
View Full Code Here

   
  }
 
  private static void pasteSectPr(List<Object> contentList, SectPr sectPr) {
   
    P p = new P();
    PPr ppr = Context.getWmlObjectFactory().createPPr();
    p.setPPr(ppr);
    ppr.setSectPr(sectPr);
   
    contentList.add(1, p);
   
  }
View Full Code Here

    private boolean isParagraph(Object child) {
      return (child instanceof P);
    }

    private void moveBookmarks(Object child) {
    P p = null;
    List<Object> content = null;
      if (!bookmarksStartToMove.isEmpty()) {
        p = (P)XmlUtils.unwrap(child);
        content = p.getContent();
        content.addAll(0, bookmarksStartToMove);
        bookmarksStartToMove.clear();
      }
    }
View Full Code Here

    if (o instanceof org.docx4j.wml.FldChar) {
      FldChar fldChar = (FldChar)o;
      if (fldChar.getFldCharType().equals(STFldCharType.BEGIN) ) {
        //System.out.println("Found a BEGIN");
        depth++;
        P currentP = pStack.peek();
        if (depth==1 && !starts.contains(currentP)) {
          starts.add(currentP);
//          System.out.println("Adding " + XmlUtils.marshaltoString(currentP));
        }
      }
View Full Code Here

      //then delete the first entry (which is where SectPrFinder put it)
      sectPrList.remove(0)
    }
   
    // Now generate content; let's use
    P filler = createFillerP();
    List<Object> contents = hfPkg.getMainDocumentPart().getContent();
    contents.clear();
   
    for (SectPr sectPr : sectPrList) {
     
      contents.add(filler);
      contents.add(filler);
      contents.add(filler);
      contents.add(filler);
     
      // We expect to cause, in due course, something like:
      // WARN org.apache.fop.apps.FOUserAgent .processEvent line 97 -
      //          The contents of fo:region-body on page 6 exceed its viewport
      //          by 29068 millipoints. (See position 1:1038)


      // now add the sectPr
        P p = Context.getWmlObjectFactory().createP();
          PPr ppr = Context.getWmlObjectFactory().createPPr();
          p.setPPr(ppr);
          ppr.setSectPr(sectPr);
         
      contents.add(p);
     
    }
View Full Code Here

   
    private static P createFillerP() {

      org.docx4j.wml.ObjectFactory wmlObjectFactory = Context.getWmlObjectFactory();

      P p = wmlObjectFactory.createP();
          // Create object for pPr
          PPr ppr = wmlObjectFactory.createPPr();
          p.setPPr(ppr);
              // Create object for rPr
              ParaRPr pararpr = wmlObjectFactory.createParaRPr();

              // Create object for spacing
              PPrBase.Spacing pprbasespacing = wmlObjectFactory.createPPrBaseSpacing();
              ppr.setSpacing(pprbasespacing);
                  pprbasespacing.setBefore( BigInteger.valueOf( 800) );
                  pprbasespacing.setAfter( BigInteger.valueOf( 800) );
          // Create object for r
          R r = wmlObjectFactory.createR();
          p.getContent().add( r);
              // Create object for rPr
              RPr rpr = wmlObjectFactory.createRPr();
              r.setRPr(rpr);
                  // Create object for sz
                  HpsMeasure hpsmeasure3 = wmlObjectFactory.createHpsMeasure();
View Full Code Here

        + "/OUT_bookmarkAdd.docx";;   
           
    wordMLPackage.getMainDocumentPart().addParagraphOfText("x");
    wordMLPackage.getMainDocumentPart().addParagraphOfText("x");
    wordMLPackage.getMainDocumentPart().addParagraphOfText("hello world");
    P p = (P)wordMLPackage.getMainDocumentPart().getContent().get(2);
    R r = (R)p.getContent().get(0);
   
    String bookmarkName = "abcd";
    bookmarkRun(p,r, bookmarkName, 123);

    wordMLPackage.getMainDocumentPart().addParagraphOfText("x");
View Full Code Here

                +"</w:sdtContent>"

          +"</w:sdt>"
          + "</w:p>";
     
    P p = (P)XmlUtils.unmarshalString(openXML);     

          hdr.getContent().add(p);
      return hdr;

    }
View Full Code Here

    Comment theComment = createComment(commentId, "fred", null,
        "my first comment");
    comments.getComment().add(theComment);
   
    // Add comment reference to document
    P paraToCommentOn = wordMLPackage.getMainDocumentPart().addParagraphOfText("here is some content");
    paraToCommentOn.getContent().add(createRunCommentReference(commentId));

    // ++, for next comment ...
    commentId = commentId.add(java.math.BigInteger.ONE);

    // Now save it
View Full Code Here

TOP

Related Classes of org.docx4j.wml.P

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.