Examples of RPr


Examples of org.docx4j.wml.RPr

       
        SdtPr sdtPr = ((SdtElement)o).getSdtPr();
        if (sdtPr!=null) {
          Object o2 = sdtPr.getByClass(RPr.class);
          if (o2!=null) {
            RPr rPr = (RPr)o2;
            RStyle rStyle = rPr.getRStyle();
            if (rStyle!=null) {
              // Add it
              if (stylesInUse !=null) {
                stylesInUse.add(rStyle.getVal());
                // and linked p style (if any), useful for OpenDoPE XHTML
View Full Code Here

Examples of org.docx4j.wml.RPr

      spacing.setAfter(BigInteger.ZERO);
      spacing.setLine(BigInteger.valueOf(240));
    }

    // Setup documentDefaultRPr
    RPr documentDefaultRPr;
    if (docDefaults.getRPrDefault() == null) {
      log.warn("No RPrDefault present");
      try {
        documentDefaultRPr = (RPr) XmlUtils
            .unmarshalString(rPrDefaultsString);
          // that includes font size 10
      } catch (JAXBException e) {
        throw new Docx4JException("Problem unmarshalling "
            + rPrDefaultsString, e);
      }
    } else {
      documentDefaultRPr = docDefaults.getRPrDefault().getRPr();
      if (documentDefaultRPr==null) {
        documentDefaultRPr = Context.getWmlObjectFactory().createRPr();
      }
      // If default font size is not specified, set it to match Word default when unspecified (ie 10)
      // It is useful to have this explicitly, especially for XHTML Import
//          <w:sz w:val="20"/>
//          <w:szCs w:val="20"/>     
      if (documentDefaultRPr.getSz()==null) {
        HpsMeasure s10pt = Context.getWmlObjectFactory().createHpsMeasure();
        s10pt.setVal(BigInteger.valueOf(20));
        documentDefaultRPr.setSz(s10pt);
      }
      if (documentDefaultRPr.getSzCs()==null) {
        HpsMeasure s10pt = Context.getWmlObjectFactory().createHpsMeasure();
        s10pt.setVal(BigInteger.valueOf(20));
        documentDefaultRPr.setSzCs(s10pt);
      }
    }
     
    styleDocDefaults.setPPr(documentDefaultPPr);
    styleDocDefaults.setRPr(documentDefaultRPr);
View Full Code Here

Examples of org.docx4j.wml.RPr

            </w:p>
          </w:tc>
         */
   
    List<Object> xpathResults = wordMLPackage.getMainDocumentPart().getJAXBNodesViaXPath("//w:rPr", true);
    RPr rPr = ((RPr)xpathResults.get(0));
    Assert.assertTrue(rPr.getSz().getVal().intValue()==24);
 
   
  }
View Full Code Here

Examples of org.docx4j.wml.RPr

          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) {
View Full Code Here

Examples of org.docx4j.wml.RPr

            </w:p>
          </w:tc>
         */
   
    List<Object> xpathResults = wordMLPackage.getMainDocumentPart().getJAXBNodesViaXPath("//w:rPr", true);
    RPr rPr = ((RPr)xpathResults.get(0));
    Assert.assertTrue(rPr.getSz().getVal().intValue()==EXPECTED_RESULT);
 
   
  }
View Full Code Here

Examples of org.docx4j.wml.RPr

         
    String r = BindingHandler.xpathGetString(pkg, customXmlDataStorageParts, storeItemId, xpathExp, prefixMappings);
   
    try {

      RPr rPrSDT = null;
      Node rPrNode = rPrNodeIt.nextNode();
      if (rPrNode!=null) {
        rPrSDT = (RPr)XmlUtils.unmarshal(rPrNode);
      }
     
      if (r==null || r.trim().equals("")) {
        return createPlaceholder(rPrSDT, sdtParent);
      }

      r = r.trim();
//      log.debug(r);
      //String unescaped = StringEscapeUtils.unescapeHtml(r);
      //log.info("Unescaped: " + unescaped);
     
      // It comes to us unescaped, so the above is unnecessary.
     
     
      if (r.startsWith("<span")) {
        // Wrap the XHTML in a span element with @class, @style as appropriate
        // so FS uses suitable CSS
       
        // Code copied from XsltHTMLFunctions.createBlockForRPr
        Style defaultRunStyle =
            (pkg.getMainDocumentPart().getStyleDefinitionsPart(false) != null ?
                pkg.getMainDocumentPart().getStyleDefinitionsPart(false).getDefaultCharacterStyle() :
            null);
       
          String defaultCharacterStyleId;
          if (defaultRunStyle.getStyleId()==null) // possible, for non MS source docx
            defaultCharacterStyleId = "DefaultParagraphFont";
          else defaultCharacterStyleId = defaultRunStyle.getStyleId();
         
         
          StyleTree styleTree = pkg.getMainDocumentPart().getStyleTree();
       
        // Set @class 
        String classVal =null;
        String rStyleVal = defaultCharacterStyleId;
        if ( rPrSDT!=null && rPrSDT.getRStyle()!=null) {
          rStyleVal = rPrSDT.getRStyle().getVal();
        }
        Tree<AugmentedStyle> cTree = styleTree.getCharacterStylesTree();   
        org.docx4j.model.styles.Node<AugmentedStyle> asn = cTree.get(rStyleVal);
        if (asn==null) {
          log.warn("No style node for: " + rStyleVal);
        } else {
          classVal = StyleTree.getHtmlClassAttributeValue(cTree, asn);   
        }
         
       
        String css = null;
        if ( rPrSDT!=null) {
          StringBuilder result = new StringBuilder();
          HtmlCssHelper.createCss(pkg, rPrSDT, result);
          css = result.toString();
          if (css.equals("")) {
            css =null;
          }
        }
       
        if (css==null && classVal==null) {
          // Do nothing
        } else if (classVal==null) {
          // just @style
          r = "<span style=\"" + css + "\">" + r + "</span>";
        } else if (css==null) {
          // just @class
          r = "<span class=\"" + classVal + "\">" + r + "</span>";
        } else {
          r = "<span style=\"" + css + "\" class=\"" + classVal + "\">" + r + "</span>";          
        }
        log.debug("\nenhanced with css: \n" + r);
       
      } else if (Docx4jProperties.getProperty("docx4j.model.datastorage.BindingTraverser.XHTML.Block.rStyle.Adopt", false)) {
       
        log.debug("Block.rStyle.Adopt..");
       
        // its block level, and we're instructed to apply the paragraph style
        // linked to w:sdtPr/w:rPr/w:rStyle (if any)
        String rStyleVal=null;
        if ( rPrSDT!=null && rPrSDT.getRStyle()!=null) {
          rStyleVal = rPrSDT.getRStyle().getVal();
          log.debug(".." + rStyleVal);
        }
       
        if (rStyleVal==null) {
View Full Code Here

Examples of org.docx4j.wml.RPr

   
   
    try {
      log.info(xpath + " yielded result '" + r + "'");
     
      RPr rPr = null;
      for (Object o : sdtPr.getRPrOrAliasOrLock() ) {
        o = XmlUtils.unwrap(o); // Sun/Oracle JAXB (recent versions?) wraps RPR in JAXBElement
        if (o instanceof RPr) {         
          rPr = (RPr)o;
          break;
View Full Code Here

Examples of org.docx4j.wml.RPr

     
      Format formatter = new SimpleDateFormat(format);
      org.docx4j.wml.ObjectFactory factory = new org.docx4j.wml.ObjectFactory();
     
      Date date;
      RPr rPr = null;
      try {
        date = (Date)dateTimeFormat.parse(r);
      } catch (ParseException e) {
        try {
          // 2012-08-28
          DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
          date = (Date) dateFormat.parse(r);
        } catch (ParseException e2) {
          log.warn(e.getMessage());
          date = new Date();

          // <w:color w:val="FF0000"/>
          rPr = factory.createRPr();
          Color colorRed = factory.createColor();
          colorRed.setVal("FF0000");
          rPr.setColor(colorRed);
        }
      }

      String result = formatter.format(date);
     
View Full Code Here

Examples of org.docx4j.wml.RPr

            </w:p>
          </w:tc>
         */
   
    List<Object> xpathResults = wordMLPackage.getMainDocumentPart().getJAXBNodesViaXPath("//w:rPr", true);
    RPr rPr = ((RPr)xpathResults.get(0));
    Assert.assertTrue(rPr.getSz().getVal().intValue()==24);
 
   
  }
View Full Code Here

Examples of org.docx4j.wml.RPr

            </w:p>
          </w:tc>
         */
   
    List<Object> xpathResults = wordMLPackage.getMainDocumentPart().getJAXBNodesViaXPath("//w:rPr", true);
    RPr rPr = ((RPr)xpathResults.get(0));
    Assert.assertTrue(rPr.getSz().getVal().intValue()==24);
 
   
  }
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.