Package org.docx4j.wml

Examples of org.docx4j.wml.R


          val = FormattingSwitchHelper.applyFormattingSwitch(wmlPackage, fsm, val);
  //        System.out.println("--> " + val);
          report.append( simpleField.getInstr() + "\n");
          report.append( "--> " + val + "\n");
         
          R r=null;
          if (simpleField.getInstr().toUpperCase().contains("MERGEFORMAT")) {         
            // find the first run and use the formatting of that
            r = getFirstRun(simpleField.getContent());         
          }
          if (r==null) {
            r = Context.getWmlObjectFactory().createR();
          } else {
            r.getContent().clear();
          }
          simpleField.getContent().clear()
          simpleField.getContent().add(r);
          Text t = Context.getWmlObjectFactory().createText();
          t.setValue(val);
          // t.setSpace(value) //TODO
          r.getContent().add(t);
         
  //        System.out.println(XmlUtils.marshaltoString(simpleField, true, true));
        }
       
      } else {
View Full Code Here


      // 
     
     
      if ( o instanceof R ) {
       
        R existingRun = (R)o;
        handleRun(existingRun, attachmentPoint);

      } else if (o instanceof ProofErr) {
        // Ignore
        // What happens if we ignore eg grammarStart, but its matching
View Full Code Here

        // if \* MERGEFORMAT, attach the rPr of first run in the result
        if (o2 instanceof R
            && currentField.isMergeFormat()
            && currentField.getResultsSlot()==null) {

          R resultR = Context.getWmlObjectFactory().createR();
          currentField.setResultsSlot(resultR);
          resultR.setRPr(((R)o2).getRPr()); // could be null, but that's ok
          log.debug("MERGEFORMAT Set rPr");
        }
       
       
       
View Full Code Here

              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();
                  rpr.setSz(hpsmeasure3);
                      hpsmeasure3.setVal( BigInteger.valueOf( 96) );

              // 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( "BODY CONTENT");

      return p;
    }   
View Full Code Here

           
    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

          // The original runs are always longer than
          // each rd

        // We will definitely require a new run
        // structure for each side
        R currentLeftStructure = createRunStructure("",
            pl, pLeftIndex );
          R currentRightStructure = createRunStructure("",
            pr, pRightIndex );
         
          pLeftReplacement.add(currentLeftStructure);
          pRightReplacement.add(currentRightStructure);
         
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

          <w:r>
            <w:fldChar w:fldCharType="end"/>
          </w:r>
        </w:p>         */       
        P paragraphForTOC = factory.createP();          
        R r = factory.createR();

        FldChar fldchar = factory.createFldChar();
        fldchar.setFldCharType(STFldCharType.BEGIN);
        fldchar.setDirty(true);
        r.getContent().add(getWrappedFldChar(fldchar));
        paragraphForTOC.getContent().add(r);

        R r1 = factory.createR();
        Text txt = new Text();
        txt.setSpace("preserve");
        txt.setValue("TOC \\o \"1-3\" \\h \\z \\u \\h");
        r.getContent().add(factory.createRInstrText(txt) );
        paragraphForTOC.getContent().add(r1);

        FldChar fldcharend = factory.createFldChar();
        fldcharend.setFldCharType(STFldCharType.END);
        R r2 = factory.createR();
        r2.getContent().add(getWrappedFldChar(fldcharend));
        paragraphForTOC.getContent().add(r2);
           
    body.getContent().add(paragraphForTOC);
   
    documentPart.addStyledParagraphOfText("Heading1", "Hello 1");
View Full Code Here

  private static void addComplexField(P p, String instrText) {
   
    org.docx4j.wml.ObjectFactory wmlObjectFactory = Context.getWmlObjectFactory();

    // Create object for r
      R r = wmlObjectFactory.createR();
      p.getContent().add( r);
          // Create object for fldChar (wrapped in JAXBElement)
          FldChar fldchar = wmlObjectFactory.createFldChar();
          JAXBElement<org.docx4j.wml.FldChar> fldcharWrapped = wmlObjectFactory.createRFldChar(fldchar);
          r.getContent().add( fldcharWrapped);
              fldchar.setFldCharType(org.docx4j.wml.STFldCharType.BEGIN);
          // Create object for instrText (wrapped in JAXBElement)
          Text text = wmlObjectFactory.createText();
          JAXBElement<org.docx4j.wml.Text> textWrapped = wmlObjectFactory.createRInstrText(text);
          r.getContent().add( textWrapped);
              text.setValue( instrText);
              text.setSpace( "preserve");  

          // Create object for fldChar (wrapped in JAXBElement)
          fldchar = wmlObjectFactory.createFldChar();
          fldcharWrapped = wmlObjectFactory.createRFldChar(fldchar);
          r.getContent().add( fldcharWrapped);
              fldchar.setFldCharType(org.docx4j.wml.STFldCharType.END);
   
  }
View Full Code Here

      }
    }

    field.setInstr(instr);

    R r = wmlObjectFactory.createR();
    Text t = wmlObjectFactory.createText();

    r.getContent().add(t);
    field.getContent().add(r);

    t.setValue("guess");

    return field;
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.