Package org.docx4j.wml

Examples of org.docx4j.wml.Style


         
          // there is also abstractNum.getStyleLink(), but ignore that
         
          String numStyleId = abstractNum.getNumStyleLink().getVal();
         
          Style s = sdp.getStyleById(numStyleId);
          if (s==null) {
            log.warn("For w:numStyleLink, couldn't find style " + numStyleId);
            continue;
          }
          if (s.getPPr()==null || s.getPPr().getNumPr()==null) {
            log.warn("For w:numStyleLink, style " + numStyleId + " has no w:numPr");
            continue;           
          }
         
          NumPr styleNumPr = s.getPPr().getNumPr();
         
          // Get the concrete list this point to
          if (styleNumPr.getNumId()==null) {
            log.warn("For w:numStyleLink, style " + numStyleId + " w:numPr has no w:numId");
            continue;                       
View Full Code Here


            if (rStyle!=null) {
              // Add it
              if (stylesInUse !=null) {
                stylesInUse.add(rStyle.getVal());
                // and linked p style (if any), useful for OpenDoPE XHTML
                Style pStyle = styleDefinitionsPart.getLinkedStyle(rStyle.getVal());
                if (pStyle!=null) {
                  stylesInUse.add(pStyle.getStyleId());
                }
              }
            }
          }
        }
View Full Code Here

     
    styleDocDefaults.setPPr(documentDefaultPPr);
    styleDocDefaults.setRPr(documentDefaultRPr);
   
    // Now point Normal at this
    Style normal = getDefaultParagraphStyle();
    if (normal==null) {
      log.warn("No default paragraph style!!");
      normal = Context.getWmlObjectFactory().createStyle();
      normal.setType("paragraph");
      normal.setStyleId("Normal");
     
      n = Context.getWmlObjectFactory().createStyleName();
      n.setVal("Normal");
      normal.setName(n);
      this.getJaxbElement().getStyle().add(normal)
     
      normal.setDefault(Boolean.TRUE); // @since 3.2.0
    }
   
    BasedOn based = Context.getWmlObjectFactory().createStyleBasedOn();
    based.setVal(ROOT_NAME);   
    normal.setBasedOn(based);
   
    log.info("Set virtual style, id '" + styleDocDefaults.getStyleId() + "', name '"+ styleDocDefaults.getName().getVal() + "'");
   
    log.debug(XmlUtils.marshaltoString(styleDocDefaults, true, true));
   
View Full Code Here

   * @param rStyleVal
   * @return
   */
  public Style getLinkedStyle(String rStyleVal) {
   
    Style rStyle = getStyleById(rStyleVal);
    if (rStyle==null) {
      log.warn("Couldn't find rStyle " + rStyleVal);
      return null;
    } else {
      // We have a run level style.  Is there a linked pStyle?
      Style.Link linkedStyle = rStyle.getLink();
      if (linkedStyle==null) {
        log.warn("No linked style for rStyle " + rStyleVal);             
        return null;
      } else {
        String pStyleVal = linkedStyle.getVal();
        log.debug(rStyleVal + " is linked to style " + pStyleVal );
        Style pStyle = getStyleById(pStyleVal);
       
        if (pStyle==null) {
          log.warn("Couldn't find linked pStyle " + pStyleVal
              + " for rStyle " + rStyleVal);   
        }
View Full Code Here

        (Styles)XmlUtils.unmarshalString(styles_no_font_sz) );
   
    // NB createVirtualStylesForDocDefaults() puts 10pt there, if nothing is specified!
    // So we need to delete that!
    wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().createVirtualStylesForDocDefaults();
    Style dd = wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().getStyleById("DocDefaults");
    dd.getRPr().setSz(null);
    dd.getRPr().setSzCs(null);
   
    setSetting(wordMLPackage, OVERRIDE)// table style should get overridden
 
    wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
   
    ParagraphStylesInTableFix.process(wordMLPackage);
   
    Style s = getStyle(wordMLPackage, STYLE_NAME);
    Assert.assertTrue(s.getRPr().getSz().getVal().intValue()==40);
  }
View Full Code Here

   
//    // Revert style and save:
//    ppr.setPStyle(ps); // doesn't work - wrong ref!
//    wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
   
    Style ours = null;
    for (Style s : wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().getContents().getStyle()) {
      if ("testStyle-TableGrid-BR".equals(s.getStyleId())) {
        ours = s;
        break;
      }
    }
   
//    Style s = getStyle(wordMLPackage, STYLE_NAME);
    Assert.assertTrue(ours.getRPr().getSz().getVal().intValue()==EXPECTED_RESULT);
  }
View Full Code Here

   
//    // Revert style and save:
//    ppr.setPStyle(ps); // doesn't work - wrong ref!
//    wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
   
    Style ours = null;
    for (Style s : wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().getContents().getStyle()) {
      if ("testStyle-TableGrid-BR".equals(s.getStyleId())) {
        ours = s;
        break;
      }
    }
   
//    Style s = getStyle(wordMLPackage, STYLE_NAME);
    Assert.assertTrue(ours.getRPr().getSz().getVal().intValue()==EXPECTED_RESULT);
  }
View Full Code Here

    wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
   
    // NB createVirtualStylesForDocDefaults() puts 10pt there, if nothing is specified!
    // So we need to delete that!
    wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().createVirtualStylesForDocDefaults();
    Style dd = wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().getStyleById("DocDefaults");
    dd.getRPr().setSz(null);
    dd.getRPr().setSzCs(null);
   
    ParagraphStylesInTableFix.process(wordMLPackage);
   
    Style s = getStyle(wordMLPackage, STYLE_NAME);
    Assert.assertTrue(s.getRPr().getSz().getVal().intValue()==EXPECTED_RESULT);
  }
View Full Code Here

   
//    // Revert style and save:
//    ppr.setPStyle(ps); // doesn't work - wrong ref!
//    wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
   
    Style ours = null;
    for (Style s : wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().getContents().getStyle()) {
      if ("testStyle-TableGrid-BR".equals(s.getStyleId())) {
        ours = s;
        break;
      }
    }
   
//    Style s = getStyle(wordMLPackage, STYLE_NAME);
    Assert.assertTrue(ours.getRPr().getSz().getVal().intValue()==22);
  }
View Full Code Here

   
//    // Revert style and save:
//    ppr.setPStyle(ps); // doesn't work - wrong ref!
//    wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_PStyleInTableTest.docx"));
   
    Style ours = null;
    for (Style s : wordMLPackage.getMainDocumentPart().getStyleDefinitionsPart().getContents().getStyle()) {
      if ("testStyle-TableGrid-BR".equals(s.getStyleId())) {
        ours = s;
        break;
      }
    }
   
//    Style s = getStyle(wordMLPackage, STYLE_NAME);
    Assert.assertTrue(ours.getRPr().getSz().getVal().intValue()==22);
  }
View Full Code Here

TOP

Related Classes of org.docx4j.wml.Style

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.