Package org.docx4j.openpackaging.parts.WordprocessingML

Examples of org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart


  public  void testFont() throws Exception {
   
    boolean save = false;
   
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
    MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
   
    // Styles part
    StyleDefinitionsPart sdp = mdp.getStyleDefinitionsPart();
    Styles styles = (Styles)XmlUtils.unmarshalString(stylesXML)
    sdp.setJaxbElement(styles);

    // Theme part
    ThemePart themePart = new ThemePart();   
    Theme theme = (Theme)XmlUtils.unmarshalString(themeXML);     
    themePart.setJaxbElement(theme);
    mdp.addTargetPart(themePart);
   
    // Settings
    DocumentSettingsPart dsp = new DocumentSettingsPart();
    dsp.setJaxbElement(createSettings());
    mdp.addTargetPart(dsp);
   
   
    Document document = (Document)XmlUtils.unmarshalString(documentXML);   
    wordMLPackage.getMainDocumentPart().setJaxbElement(document);   
View Full Code Here


 
  public static void process(WordprocessingMLPackage wmlPackage) {
    //TODO: Convert to visitor
    //behaviour here like TraversalUtil.visit with onlyBody = false
   
    MainDocumentPart mainDocument = null;
    RelationshipsPart relPart = null;
    List<Relationship> relList = null;
    List<Object> elementList = null;
   
    mainDocument = wmlPackage.getMainDocumentPart();
    groupAdjacentBorders(mainDocument.getJaxbElement().getBody().getContent());

    relPart = mainDocument.getRelationshipsPart();
    relList = relPart.getRelationships().getRelationship();
    for (Relationship rs : relList) {
      elementList = null;
      if (Namespaces.HEADER.equals(rs.getType())) {
        elementList = ((HeaderPart) relPart.getPart(rs))
View Full Code Here

  public  void testFont() throws Exception {
   
    boolean save = false;
   
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
    MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
   
    // Styles part
    StyleDefinitionsPart sdp = mdp.getStyleDefinitionsPart();
    Styles styles = (Styles)XmlUtils.unmarshalString(stylesXML)
    sdp.setJaxbElement(styles);

    // Theme part
    ThemePart themePart = new ThemePart();   
    Theme theme = (Theme)XmlUtils.unmarshalString(themeXML);     
    themePart.setJaxbElement(theme);
    mdp.addTargetPart(themePart);
   
//    // Settings
//    DocumentSettingsPart dsp = new DocumentSettingsPart();
//    dsp.setJaxbElement(createSettings());
//    mdp.addTargetPart(dsp);
View Full Code Here

  @Override
  protected void appendDocumentFooter(
      HTMLConversionContext conversionContext, Document document,
      Element documentRoot) throws Docx4JException {
  MainDocumentPart mainDocumentPart = conversionContext.getWmlPackage().getMainDocumentPart();
    if (mainDocumentPart.hasFootnotesPart()) {
      appendFootnotesEndnotes(
        conversionContext, document,
        documentRoot,
        "footnotes",
        mainDocumentPart.getFootnotesPart(),
        mainDocumentPart.getFootnotesPart().getJaxbElement().getFootnote());
    }
    if (mainDocumentPart.hasEndnotesPart()) {
      appendFootnotesEndnotes(
        conversionContext, document,
        documentRoot,
        "endnotes",
        mainDocumentPart.getEndNotesPart(),
        mainDocumentPart.getEndNotesPart().getJaxbElement().getEndnote());
    }
  }
View Full Code Here

  @Test
  public  void singleList() throws Exception
   
    WordprocessingMLPackage wordMLPackage = createPkg();
   
    MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();

    mdp.getContent().add(createUnnumberedP());
   
    mdp.getContent().add(createNumberedP(1,0));
    mdp.getContent().add(createNumberedP(1,0));

    mdp.getContent().add(createUnnumberedP());
   
    //wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_simpleTest.docx"));
   
    ListsToContentControls.process(wordMLPackage);
   
    System.out.println(mdp.getXML());
   
  }
View Full Code Here

  @Test
  public  void singleListTwice() throws Exception
   
    WordprocessingMLPackage wordMLPackage = createPkg();
   
    MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();

    mdp.getContent().add(createUnnumberedP());
   
    mdp.getContent().add(createNumberedP(1,0));
    mdp.getContent().add(createNumberedP(1,0));

    mdp.getContent().add(createUnnumberedP());

    mdp.getContent().add(createNumberedP(1,0));
    mdp.getContent().add(createNumberedP(1,0));

    mdp.getContent().add(createUnnumberedP());
   
    //wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_simpleTest.docx"));
   
    ListsToContentControls.process(wordMLPackage);
   
    System.out.println(mdp.getXML());
   
 
View Full Code Here

  @Test
  public  void singleList2Levels() throws Exception
   
    WordprocessingMLPackage wordMLPackage = createPkg();
   
    MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();

    mdp.getContent().add(createUnnumberedP());
   
    mdp.getContent().add(createNumberedP(1,0));
    mdp.getContent().add(createNumberedP(1,1)); // nested

    mdp.getContent().add(createUnnumberedP());
   
    //wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_simpleTest.docx"));
   
    ListsToContentControls.process(wordMLPackage);
   
    System.out.println(mdp.getXML());
   
 
View Full Code Here

  public  void testFont() throws Exception {
   
    boolean save = false;
   
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
    MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();
   
    // Styles part
    StyleDefinitionsPart sdp = mdp.getStyleDefinitionsPart();
    Styles styles = (Styles)XmlUtils.unmarshalString(stylesXML)
    sdp.setJaxbElement(styles);

    // Theme part
    ThemePart themePart = new ThemePart();   
    Theme theme = (Theme)XmlUtils.unmarshalString(themeXML);     
    themePart.setJaxbElement(theme);
    mdp.addTargetPart(themePart);
   
//    // Settings
//    DocumentSettingsPart dsp = new DocumentSettingsPart();
//    dsp.setJaxbElement(createSettings());
//    mdp.addTargetPart(dsp);
View Full Code Here

  @Test
  public  void singleList2LevelsPop() throws Exception
   
    WordprocessingMLPackage wordMLPackage = createPkg();
   
    MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();

    mdp.getContent().add(createUnnumberedP());
   
    mdp.getContent().add(createNumberedP(1,0));
    mdp.getContent().add(createNumberedP(1,1)); // nested
    mdp.getContent().add(createNumberedP(1,0)); // then back

    mdp.getContent().add(createUnnumberedP());
   
    //wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_simpleTest.docx"));
   
    ListsToContentControls.process(wordMLPackage);
   
    System.out.println(mdp.getXML());
   
  }
View Full Code Here

  @Test
  public  void singleListStartLvl2() throws Exception
   
    WordprocessingMLPackage wordMLPackage = createPkg();
   
    MainDocumentPart mdp = wordMLPackage.getMainDocumentPart();

    mdp.getContent().add(createUnnumberedP());
   
    mdp.getContent().add(createNumberedP(1,1));
    mdp.getContent().add(createNumberedP(1,0));
    mdp.getContent().add(createNumberedP(1,2));

    mdp.getContent().add(createUnnumberedP());
   
    //wordMLPackage.save(new File(System.getProperty("user.dir") + "/OUT_simpleTest.docx"));
   
    ListsToContentControls.process(wordMLPackage);
   
    System.out.println(mdp.getXML());
   
  }
View Full Code Here

TOP

Related Classes of org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart

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.