Package org.docx4j.wml

Examples of org.docx4j.wml.DocDefaults


    org.docx4j.wml.Style.Name n = Context.getWmlObjectFactory().createStyleName();
      n.setVal(ROOT_NAME);
      styleDocDefaults.setName(n);
         
    // Initialise docDefaults   
    DocDefaults docDefaults = this.getJaxbElement().getDocDefaults();    
   
    if (docDefaults == null) {
      log.warn("No DocDefaults present");
      // The only way this can happen is if the
      // styles definition part is missing the docDefaults element
      // (these are present in docs created from Word, and
      // in our default styles, so maybe the user created it using
      // some 3rd party program?)
      try {

        docDefaults = (DocDefaults) XmlUtils
            .unmarshalString(docDefaultsString);
      } catch (JAXBException e) {
        throw new Docx4JException("Problem unmarshalling "
            + docDefaultsString, e);
      }
    }

    // Setup documentDefaultPPr
    PPr documentDefaultPPr;
    if (docDefaults.getPPrDefault() == null) {
      log.warn("No PPrDefault present");
      try {
        documentDefaultPPr = (PPr) XmlUtils
            .unmarshalString(pPrDefaultsString);
      } catch (JAXBException e) {
        throw new Docx4JException("Problem unmarshalling "
            + pPrDefaultsString, e);
      }

    } else {
      documentDefaultPPr = docDefaults.getPPrDefault().getPPr();
      if (documentDefaultPPr==null) {
        documentDefaultPPr = Context.getWmlObjectFactory().createPPr();
      }
    }
   
    // If the docDefaults have no setting for w:spacing
    // then add it:
    if (documentDefaultPPr.getSpacing()==null) {
      Spacing spacing = Context.getWmlObjectFactory().createPPrBaseSpacing();
      documentDefaultPPr.setSpacing(spacing);
      spacing.setBefore(BigInteger.ZERO);
      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
View Full Code Here

TOP

Related Classes of org.docx4j.wml.DocDefaults

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.