Package org.docx4j.model.datastorage

Examples of org.docx4j.model.datastorage.OpenDoPEHandler


    StringBuilder timingSummary = new StringBuilder();
   

    // Process conditionals and repeats
    long startTime = System.currentTimeMillis();
    OpenDoPEHandler odh = new OpenDoPEHandler(wordMLPackage);
    odh.preprocess();
    long endTime = System.currentTimeMillis();
    timingSummary.append("OpenDoPEHandler: " + (endTime-startTime));

    System.out.println(
        XmlUtils.marshaltoString(wordMLPackage.getMainDocumentPart().getJaxbElement(), true, true)
        );   
   
    startTime = System.currentTimeMillis();
    OpenDoPEIntegrity odi = new OpenDoPEIntegrity();
    odi.process(wordMLPackage);
    endTime = System.currentTimeMillis();
    timingSummary.append("\nOpenDoPEIntegrity: " + (endTime-startTime));
   
    System.out.println(
        XmlUtils.marshaltoString(wordMLPackage.getMainDocumentPart().getJaxbElement(), true, true)
        );   
    SaveToZipFile saver = new SaveToZipFile(wordMLPackage);
    saver.save(filepathprefix + "_preprocessed.docx");
    System.out.println("Saved: " + filepathprefix + "_preprocessed.docx");
   
    // Apply the bindings
    BindingHandler.setHyperlinkStyle("Hyperlink");           
    startTime = System.currentTimeMillis();
   
    AtomicInteger bookmarkId = odh.getNextBookmarkId();
    BindingHandler bh = new BindingHandler(wordMLPackage);
    bh.setStartingIdForNewBookmarks(bookmarkId);
    bh.applyBindings(wordMLPackage.getMainDocumentPart());
   
    endTime = System.currentTimeMillis();
View Full Code Here


  /**
   *  Bind the content controls of the passed document to the xml.
   */ 
  public static void bind(WordprocessingMLPackage wmlPackage, Document xmlDocument, int flags) throws Docx4JException {
   
    OpenDoPEHandler  openDoPEHandler = null;
    CustomXmlDataStoragePart customXmlDataStoragePart = null;
    RemovalHandler removalHandler = null;
    //String xpathStorageItemId = null;
   
    AtomicInteger bookmarkId = null;

    if (flags == FLAG_NONE) {
      //do everything
      flags = (FLAG_BIND_INSERT_XML |
           FLAG_BIND_BIND_XML |
           FLAG_BIND_REMOVE_SDT |
           FLAG_BIND_REMOVE_XML);
    }
   
    customXmlDataStoragePart
      = CustomXmlDataStoragePartSelector.getCustomXmlDataStoragePart(wmlPackage);
    if (customXmlDataStoragePart==null) {
      throw new Docx4JException("Couldn't find CustomXmlDataStoragePart! exiting..");
    }
 
    if ((flags & FLAG_BIND_INSERT_XML) == FLAG_BIND_INSERT_XML) {
     
      StartEvent startEvent = new StartEvent( WellKnownJobTypes.BIND, wmlPackage, WellKnownProcessSteps.BIND_INSERT_XML );
      startEvent.publish();
     
      insertXMLData(customXmlDataStoragePart, xmlDocument);
     
      new EventFinished(startEvent).publish();
    }
    if ((flags & FLAG_BIND_BIND_XML) == FLAG_BIND_BIND_XML) {
     
      StartEvent startEvent = new StartEvent( WellKnownJobTypes.BIND, wmlPackage, WellKnownProcessSteps.BIND_BIND_XML );
      startEvent.publish();
     
      if (wmlPackage.getMainDocumentPart().getXPathsPart()!=null) {
        openDoPEHandler = new OpenDoPEHandler(wmlPackage);
        openDoPEHandler.preprocess();
       
        bookmarkId = openDoPEHandler.getNextBookmarkId();
      }
      BindingHandler bh = new BindingHandler(wmlPackage);
      bh.setStartingIdForNewBookmarks(bookmarkId);
      bh.applyBindings();
     
View Full Code Here

TOP

Related Classes of org.docx4j.model.datastorage.OpenDoPEHandler

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.