Package org.docx4j.wml

Examples of org.docx4j.wml.ObjectFactory


          return null;
        }
               
        private Object createObject(String name, Object id ) throws Exception {
         
      ObjectFactory factory = Context.getWmlObjectFactory();
      log.debug("Looking for method create" + name);
      Method method = factory.getClass().getDeclaredMethod("create" + name);
      Object newObject = method.invoke(factory);
     
      Method setIdMethod = findSetIdMethod(newObject);
      if (setIdMethod==null) {
        log.error( "Couldn't findSetIdMethod for " + newObject.getClass().getName());       
View Full Code Here


 

  private void createDummyHeaderFooter() {
    synchronized (dummyHeaderFooterMutex) {
      if (dummyHeader == null) {
        ObjectFactory factory = new ObjectFactory();
        try {
          dummyHeader = new HeaderPart(new PartName("/word/dummyheader.xml"));
          dummyFooter = new FooterPart(new PartName("/word/dummyfooter.xml"));
        } catch (InvalidFormatException e) {
          //should not happen
        }
        dummyHeader.setJaxbElement(factory.createHdr());
        dummyHeader.getJaxbElement().getContent().add(factory.createP());
        dummyFooter.setJaxbElement(factory.createFtr());
        dummyFooter.getJaxbElement().getContent().add(factory.createP());
      }
    }
  }
View Full Code Here

    }  
 

  protected static void setFormFieldProperties(FieldRef fr, String ffName, String ffTextInputFormat) {
   
    ObjectFactory wmlObjectFactory = Context.getWmlObjectFactory();
   
          // Create object for ffData
          CTFFData ffdata = wmlObjectFactory.createCTFFData();
          fr.setFormFieldProperties(ffdata);
         
              // Create object for name (wrapped in JAXBElement)
              CTFFName ffname = wmlObjectFactory.createCTFFName();
              JAXBElement<org.docx4j.wml.CTFFName> ffnameWrapped = wmlObjectFactory.createCTFFDataName(ffname);
              ffdata.getNameOrEnabledOrCalcOnExit().add( ffnameWrapped);
                  ffname.setVal(ffName);
                 
              // Create object for enabled (wrapped in JAXBElement)
              BooleanDefaultTrue booleandefaulttrue = wmlObjectFactory.createBooleanDefaultTrue();
              JAXBElement<org.docx4j.wml.BooleanDefaultTrue> booleandefaulttrueWrapped = wmlObjectFactory.createCTFFDataEnabled(booleandefaulttrue);
              ffdata.getNameOrEnabledOrCalcOnExit().add( booleandefaulttrueWrapped);
             
              // Create object for calcOnExit (wrapped in JAXBElement)
              BooleanDefaultTrue booleandefaulttrue2 = wmlObjectFactory.createBooleanDefaultTrue();
              JAXBElement<org.docx4j.wml.BooleanDefaultTrue> booleandefaulttrueWrapped2 = wmlObjectFactory.createCTFFDataCalcOnExit(booleandefaulttrue2);
              ffdata.getNameOrEnabledOrCalcOnExit().add( booleandefaulttrueWrapped2);
             
              // Create object for textInput (wrapped in JAXBElement)
              CTFFTextInput fftextinput = wmlObjectFactory.createCTFFTextInput();
              JAXBElement<org.docx4j.wml.CTFFTextInput> fftextinputWrapped = wmlObjectFactory.createCTFFDataTextInput(fftextinput);
              ffdata.getNameOrEnabledOrCalcOnExit().add( fftextinputWrapped);
             
              //Set type to regular
              CTFFTextType ffTextType = wmlObjectFactory.createCTFFTextType();
              ffTextType.setVal(STFFTextType.REGULAR);
              fftextinput.setType(ffTextType);
             
              if (ffTextInputFormat!=null) {
             
                  // Create object for format
                  CTFFTextInput.Format fftextinputformat = wmlObjectFactory.createCTFFTextInputFormat();
                  fftextinput.setFormat(fftextinputformat);
                      fftextinputformat.setVal( ffTextInputFormat)// eg "UPPERCASE"
              }
  }
View Full Code Here

    if (index<0) {
      System.out.println("P does not contain R!");
      return;
    }
   
    ObjectFactory factory = Context.getWmlObjectFactory();
    BigInteger ID = BigInteger.valueOf(id);
   
   
    // Add bookmark end first
    CTMarkupRange mr = factory.createCTMarkupRange();
    mr.setId(ID);
    JAXBElement<CTMarkupRange> bmEnd = factory.createBodyBookmarkEnd(mr);
    p.getContent().add(index+1, bmEnd);
   
    // Next, bookmark start
    CTBookmark bm = factory.createCTBookmark();
    bm.setId(ID);
    bm.setName(name);   
    JAXBElement<CTBookmark> bmStart =  factory.createBodyBookmarkStart(bm);
    p.getContent().add(index, bmStart);
   
  }
View Full Code Here

  public static Style convertToWordStyle(CTTextParagraphProperties lvlPPr,
      String id, String name,
      String basedOn,
      FontScheme fontScheme) {
   
    ObjectFactory factory = Context.getWmlObjectFactory();
    Style style = factory.createStyle();
   
//    <w:style w:type="paragraph" w:styleId="Heading1">
    style.setType("paragraph");
    style.setStyleId(id);
   
    System.out.println("created " + id);
   
//    <w:name w:val="heading 1" />
    Name styleName = factory.createStyleName();
    styleName.setVal(name);
    style.setName(styleName);
   
//    <w:basedOn w:val="Normal" />
    Style.BasedOn basedon = factory.createStyleBasedOn();
    basedon.setVal(basedOn);
    style.setBasedOn(basedon);
   
//    <w:pPr>
    if (lvlPPr ==null) {
View Full Code Here

    return style;
  }
 
  public static PPr getWmlPPr(CTTextParagraphProperties lvlPPr ) {
   
    ObjectFactory factory = Context.getWmlObjectFactory();
    PPr pPr = factory.createPPr();   
   
//    *marL eg 342900 EMU
//    *indent eg -342900
   
//    *algn l|ctr|r
    if (lvlPPr.getAlgn()!=null) {
      Jc jc = factory.createJc();
      String algn = lvlPPr.getAlgn().value();
      log.debug("algn: " + algn);
      if algn.equals("l")) {
        jc.setVal(JcEnumeration.LEFT);
      } else if (algn.equals("ctr")) {
View Full Code Here

  }
 
  public static RPr getWmlRPr(CTTextParagraphProperties lvlPPr,
    FontScheme fontScheme) {
   
    ObjectFactory factory = Context.getWmlObjectFactory();

//    <w:rPr>
    RPr rPr = factory.createRPr();

    if (lvlPPr.getDefRPr()!=null) { 
   
//    *sz hundreds of pt
//    <w:sz w:val="28" />
      if (lvlPPr.getDefRPr().getSz()!=null) {       
        rPr.setSz( convertFontSize(lvlPPr.getDefRPr().getSz()) );
      }
     
//    kern
//    solidFill
   
//    *latin       
//    <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
      if (lvlPPr.getDefRPr().getLatin()!=null ) {
        RFonts rFonts = factory.createRFonts();
        if (lvlPPr.getDefRPr().getLatin().getTypeface().startsWith("+mj") ) {         
          rFonts.setAscii( fontScheme.getMajorFont().getLatin().getTypeface() );
        } else if (lvlPPr.getDefRPr().getLatin().getTypeface().startsWith("+mn") ) {         
          rFonts.setAscii( fontScheme.getMinorFont().getLatin().getTypeface() );
       
View Full Code Here

 
    return rPr;
 
 
  private static HpsMeasure convertFontSize(Integer in) {
    ObjectFactory factory = Context.getWmlObjectFactory();
    HpsMeasure sz = factory.createHpsMeasure();
    int halfPts = Math.round(in/50);
    sz.setVal( BigInteger.valueOf(halfPts) );
    return sz;
  }
View Full Code Here

    return styles;
  }
 
    protected static Style createVirtualStylesForDocDefaults(FontScheme fontScheme) {
     
    ObjectFactory factory = Context.getWmlObjectFactory();
    Style style = factory.createStyle();
     
      String ROOT_NAME = "DocDefaults";
     
      style.setStyleId(ROOT_NAME);
      style.setType("paragraph");
   
    Name styleName = factory.createStyleName();
    styleName.setVal(ROOT_NAME);
    style.setName(styleName);
   
//    <w:rPr>
    RPr rPr = factory.createRPr();
    style.setRPr(rPr);

//    <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
    RFonts rFonts = factory.createRFonts();
    rFonts.setAscii( fontScheme.getMinorFont().getLatin().getTypeface() );
    rPr.setRFonts(rFonts);
 
    return style;
     
View Full Code Here

   
 
   
  public static RPr getWmlRPr(CTTextCharacterProperties in) {
   
    ObjectFactory factory = Context.getWmlObjectFactory();
    RPr rPr = factory.createRPr();

    if (in==null) {
      System.out.println("Was passed null");
      return rPr;
    }
   
//        <a:rPr  i="true" />   
    if (in.isI()!=null && in.isI()) {
      rPr.setI( new BooleanDefaultTrue() );
    }
   
//        <a:rPr  b="true"
    if (in.isB()!=null && in.isB()) {
      rPr.setB( new BooleanDefaultTrue() );
    }
   
//        <a:rPr  u="sng"
    if (in.getU()!=null) {
      U u = factory.createU();
      u.setVal(UnderlineEnumeration.SINGLE);
      rPr.setU(u);
    }
//        <a:rPr  sz="4000"
    if (in.getSz()!=null) {
View Full Code Here

TOP

Related Classes of org.docx4j.wml.ObjectFactory

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.