Package org.docx4j.wml

Examples of org.docx4j.wml.R$Tab


  }

  private static void appendRun(SdtBlock currentBlock, List<Object> resultElts) {
   
    List<Object> blkElements = null;
    R run = null;
    RPr blockRPr = null;
    if (currentBlock != null) {
      blkElements = currentBlock.getSdtContent().getContent();
      if (blkElements.size() == 1) {
        //If there is only one element, there is no need to use a sdtBlock
        resultElts.add(blkElements.get(0));
      }
      else {
        resultElts.add(currentBlock);
        //Remove the borders of the child elements
        //(and the shading if it is the same as that of the container)
        blockRPr = findBlockRPr(currentBlock);
        for (Object elem:blkElements) {
          if (elem instanceof R) {
            run = (R)elem;
            if (run.getRPr() != null) {
              run.getRPr().setBdr(null);
              if (!shadingChanged(blockRPr.getShd(), run.getRPr().getShd())) {
                run.getRPr().setShd(null);
              }
            }
          }
        }
      }
View Full Code Here


            // Create object for pStyle
//            PPrBase.PStyle pprbasepstyle = wmlObjectFactory.createPPrBasePStyle();
//            ppr.setPStyle(pprbasepstyle);
//                pprbasepstyle.setVal( "ListParagraph");
        // 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( "list " + numId + ", ilvl " + ilvl);

    return p;
    }
View Full Code Here

      If this is not the first child of this w:r, look at the preceding sibling
*/
   
    boolean firstBr = true; // until proven otherwise
   
    R r = (R)br.getParent();
    int pos = getPos(r.getContent(), br);
    if (pos<0) {
      log.error("Couldn't locate w:br in w:r");
    }
    else if (pos==0) {
      // Need to look in preceding run
      Object rParent = r.getParent();
      // Handle just the case where this is w:p for now
      if(rParent instanceof P) {
        P parentP = (P)rParent;
        pos = getPos(parentP.getContent(), r);
        if (pos<0) {
          log.error("Couldn't locate w:r in w:p");
        } else if (pos>0) {
          Object beforeR = parentP.getContent().get(pos-1);
          if (beforeR instanceof R) {
            List list = ((R)beforeR).getContent();
            Object previous = list.get(list.size()-1);
            if (previous instanceof Br) {
              firstBr=false;
            }
          } else {
//            System.out.println(beforeR.getClass().getName());
           
          }
        }
      } else {
        log.info("TODO: handle run parent " + rParent.getClass().getName());
      }
    } else {
      Object previous = r.getContent().get(pos-1);
      if (previous instanceof Br) {
        firstBr=false;
      } else {
//        System.out.println("previous: " + previous.getClass().getName());
      }
View Full Code Here

          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

TOP

Related Classes of org.docx4j.wml.R$Tab

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.