Package org.docx4j.wml

Examples of org.docx4j.wml.Style


        (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);

    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()==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()==24);
  }
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()==null);
  }
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-TableNormal-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-TableNormal-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

      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) {

          log.debug("No rStyle specified ");
         
        } else {
         
          Style pStyle = pkg.getMainDocumentPart().getStyleDefinitionsPart(false).getLinkedStyle(rStyleVal);
         
          if (pStyle==null) {
           
            log.warn("No linked style for " + rStyleVal);
           
          } else {
           
            // Got the pStyle .. now apply it in the XHTML
              StyleTree styleTree = pkg.getMainDocumentPart().getStyleTree();
             
              String pStyleVal = pStyle.getStyleId();
            log.debug(".." + pStyleVal);
                             
            // Set @class 
            String classVal =null;
            Tree<AugmentedStyle> pTree = styleTree.getParagraphStylesTree();   
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()==24);
  }
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

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.