Package org.docx4j.wml

Examples of org.docx4j.wml.R


            // Create object for pStyle
            PPrBase.PStyle pprbasepstyle = wmlObjectFactory.createPPrBasePStyle();
            ppr.setPStyle(pprbasepstyle);
                pprbasepstyle.setVal( style);
        // Create object for r
        R r = wmlObjectFactory.createR();
        p.getContent().add( r);
            // Create object for t (wrapped in JAXBElement)
            Text text = wmlObjectFactory.createText();
            JAXBElement<org.docx4j.wml.Text> textWrapped = wmlObjectFactory.createRT(text);
            r.getContent().add( textWrapped);
                text.setValue( style + "; list " + numId + ", ilvl " + ilvl);

    return p;
    }
View Full Code Here


    }
 
  protected P createUnnumberedP() {
   
    P p = wmlObjectFactory.createP();
        R r = wmlObjectFactory.createR();
        p.getContent().add( r);
            // Create object for t (wrapped in JAXBElement)
            Text text = wmlObjectFactory.createText();
            JAXBElement<org.docx4j.wml.Text> textWrapped = wmlObjectFactory.createRT(text);
            r.getContent().add( textWrapped);
                text.setValue( "UnnumberedP");

    return p;
   
View Full Code Here

      // will ensure that the style is activated 

    // Example 3b: bold text
      // Well, actually you can use addParagraphOfText:
    P p3b = mdp.addParagraphOfText("Example 3b (bold)");
    R r3b = (R)p3b.getContent().get(0);
      // .. now set rPr (I'll just reuse the above object)
    r3b.setRPr(rpr);

     
      // Example 4: Here is an easier way:
      String str = "<w:p xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ><w:r><w:rPr><w:b /></w:rPr><w:t>Example 4</w:t></w:r></w:p>";
     
View Full Code Here

    ctDataBinding.setStoreItemID(storeItemID);
         
    CTSdtContentRun sdtContent = Context.getWmlObjectFactory().createCTSdtContentRun();     
    sdtRun.setSdtContent(sdtContent);

    R rnew = new R();
    rnew.setRPr( rPr ); // point at old rPr, if any
    Text text = Context.getWmlObjectFactory().createText();
    text.setValue(key);
    rnew.getContent().add(text);
   
    sdtContent.getContent().add(rnew);
  }
View Full Code Here

  public static void joinupRuns(P p) {

    List<Object> existingContents = p.getContent();
    List<Object> newContents = new ArrayList<Object>();
   
    R currentR = null;
    String currentRPrString = null;
   
    // First join up runs with same run properties
    for (Object o : existingContents) {
     
      if (o instanceof R) {
       
        if (currentR==null) { // first object, or after something not a run
          currentR=(R)o;
          if (currentR.getRPr()!=null) {
            currentRPrString = XmlUtils.marshaltoString(currentR.getRPr(), true);
          }
          newContents.add(currentR);
        } else {
          RPr other = ((R)o).getRPr();
         
          boolean makeNewRun = true; // unless proven otherwise
         
          if (currentRPrString==null && other==null) makeNewRun=false;
          if (currentRPrString!=null && other!=null) {
            // Simple minded notion of equality
            if ( XmlUtils.marshaltoString(other, true).equals(currentRPrString) )  makeNewRun=false;
          }
         
          if (makeNewRun) {
            currentR=(R)o;
            if (currentR.getRPr()==null) {
              currentRPrString = null;
            } else {
              currentRPrString = XmlUtils.marshaltoString(currentR.getRPr(), true);
            }
            newContents.add(currentR);
          } else {
            currentR.getContent().addAll( ((R)o).getContent() );
          }
        }
       
      } else {
        // not a run (eg w:ins) .. just add it and move on
View Full Code Here

               
                if ( o2 instanceof Text ) {
                  handle((R)o, ((Text)o2).getValue(), 0, replacementContent);
                } else {
                  // Just add this bit
                  R rnew = new R();
                  rnew.setRPr( ((R)o).getRPr() ); // point at old rPr, if any
                  rnew.getContent().add(o2);
                  replacementContent.add(rnew);
                }               
              }
            } else {
              replacementContent.add(o);
View Full Code Here

 
 
   private void addTextRun(R r, String val, List<Object> replacementContent) {
    
      R rnew = new R();
      rnew.setRPr( r.getRPr() ); // point at old rPr, if any
     
      Text text = Context.getWmlObjectFactory().createText();
      text.setValue(val);
      if (val.startsWith(" ")
          || val.endsWith(" ") ) {
        text.setSpace("preserve");
      }
     
      rnew.getContent().add(text);
      replacementContent.add(rnew);
    
   }
View Full Code Here

      if (rPr==null) {
        // Usual case, just reuse the fragment
        return placeholderFragment;
      } else {
        // Specific formatting
        R run = (R)XmlUtils.unmarshal(new ByteArrayInputStream(placeholderBytes));
        run.setRPr(rPr);
        Document tmpDoc = XmlUtils.marshaltoW3CDomDocument(run);
        DocumentFragment docfrag = tmpDoc.createDocumentFragment();
        XmlUtils.treeCopy(tmpDoc.getDocumentElement(), docfrag);           
        return docfrag;
      }
     
    } else {
     
      R run = (R)XmlUtils.unmarshal(new ByteArrayInputStream(placeholderBytes));
      run.setRPr(rPr);
      Document tmpDoc = XmlUtils.marshaltoW3CDomDocument(run);
     
      DocumentFragment docfrag = tmpDoc.createDocumentFragment();
     
      if (contentParent.equals("tbl")) {
View Full Code Here

    assertTrue(xml.contains("<w:bookmarkStart"));
    assertTrue(xml.contains("<w:bookmarkEnd"));
   
    // result slot contents
    FieldRef fieldRef1 =  fieldRefs.get(0);
    R r = fieldRef1.getResultsSlot();
    Text text = (Text)XmlUtils.unwrap(r.getContent().get(0));
    assertTrue(text.getValue().equals("(Customer)"));
   
  }
View Full Code Here

          // <w:r><w:rPr><w:rStyle
          // w:val="CommentReference"/></w:rPr><w:commentReference
          // w:id="0"/></w:r>
          P p = Context.getWmlObjectFactory().createP();
          R r = Context.getWmlObjectFactory().createR();
          p.getParagraphContent().add(r);

          R.CommentReference cr = Context.getWmlObjectFactory()
              .createRCommentReference();
          cr.setId( (BigInteger)id);
          r.getRunContent().add(cr);

          paragraphs.add(p);
        }

      }
View Full Code Here

TOP

Related Classes of org.docx4j.wml.R

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.