Examples of JaxbXmlPart


Examples of org.docx4j.openpackaging.parts.JaxbXmlPart

     
      for (CTRel rel : hdrFtrRefs) {
        String relId = rel.getId();
        log.debug("for h|f relId: " + relId);
       
        JaxbXmlPart part = (JaxbXmlPart)input.getMainDocumentPart().getRelationshipsPart().getPart(relId);
        FieldsPreprocessor.complexifyFields(part );
       
        log.debug("complexified: " + XmlUtils.marshaltoString(part.getJaxbElement(), true));
       
        hfTemplates.put(rel, part);
      }
    }
   
    // Create WordprocessingMLPackage target, by cloning
    OpcPackage result = null;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SaveToZipFile saver = new SaveToZipFile(input);
    saver.save(baos);
    byte[] template = baos.toByteArray();
    WordprocessingMLPackage target = WordprocessingMLPackage.load(
        new ByteArrayInputStream(template));
   
   
    // populate main document part
    SectPr documentSeparator = getDocumentSeparator(target);
    if (processHeadersAndFooters) {
      if (titlePage!=null
          && titlePage.isVal()) {
        documentSeparator.setTitlePg(titlePage);
      }
      documentSeparator.getEGHdrFtrReferences().clear();
    }
    target.getMainDocumentPart().getContent().clear();
   
    /*
     * What we're doing, effectively, is doing the
     * main content in a single hit (ie for all
     * instances), and then, for each instance,
     * doing the headers/footers.
     *
     * It is this way because that is how the code
     * has evolved.
     *
     * Since we have to do the headers/footers
     * instance by instance, it would probably
     * be neater to do the main content at
     * the same time (ie instead of using
     * performOverList at the start of this method).
     */
   
    int i = 0;
    for (List<Object> content : mdpResults) {
     
           
      // now inject the content
      target.getMainDocumentPart().getContent().addAll(content);

      log.debug(XmlUtils.marshaltoString(target.getMainDocumentPart().getJaxbElement(), true, true) );
     
      // add sectPr to final paragraph
      Object last = content.get( content.size()-1);
      P lastP = null;
      if (last instanceof P) {
        lastP = (P)last;
      } else {
        lastP = Context.getWmlObjectFactory().createP();
        target.getMainDocumentPart().getContent().add(lastP)
      }
      if (lastP.getPPr()==null) {
        lastP.setPPr(Context.getWmlObjectFactory().createPPr());       
      }
      SectPr thisSection = XmlUtils.deepCopy(documentSeparator);
      lastP.getPPr().setSectPr(thisSection);
     
      if (processHeadersAndFooters) {
        for( CTRel ctRel : hfTemplates.keySet()) {
         
          // Create a suitable part
          JaxbXmlPart part = hfTemplates.get(ctRel);
          JaxbXmlPart clonedPart = null;
          if (part instanceof HeaderPart) {
            clonedPart = new HeaderPart();
            clonedPart.setJaxbElement(Context.getWmlObjectFactory().createHdr());
          } else if (part instanceof FooterPart) {
            clonedPart = new FooterPart();
            clonedPart.setJaxbElement(Context.getWmlObjectFactory().createFtr());
          }
         
          // Populate it
          List<Object> newContent = performOnInstance(input,
              ((ContentAccessor)part).getContent(),
View Full Code Here

Examples of org.docx4j.openpackaging.parts.JaxbXmlPart

      for ( Relationship r : rp.getJaxbElement().getRelationship()  ) {
       
        if (r.getType().equals(Namespaces.HEADER)
            || r.getType().equals(Namespaces.FOOTER)) {
         
          JaxbXmlPart part = (JaxbXmlPart)rp.getPart(r);

          log.debug("\n\n BEFORE " + part.getPartName().getName() + "\n\n"
              + XmlUtils.marshaltoString(part.getJaxbElement(), true, true) + "\n");
         
          FieldsPreprocessor.complexifyFields(part );
         
          log.debug("\n\n COMPLEXIFIED " + part.getPartName().getName() + "\n\n"
              + XmlUtils.marshaltoString(part.getJaxbElement(), true, true) + "\n");
         
          List<Object> results = performOnInstance(input,
              ((ContentAccessor)part).getContent(), data, formTextFieldNames );
          ((ContentAccessor)part).getContent().clear();
          ((ContentAccessor)part).getContent().addAll(results);
         
          log.debug("\n\n AFTER " + part.getPartName().getName() + "\n\n"
              + XmlUtils.marshaltoString(part.getJaxbElement(), true, true) + "\n");
         
        }     
      }   
    }
     
View Full Code Here

Examples of org.docx4j.openpackaging.parts.JaxbXmlPart

      for ( Relationship r : rp.getJaxbElement().getRelationship()  ) {
       
        if (r.getType().equals(Namespaces.HEADER)
            || r.getType().equals(Namespaces.FOOTER)) {
         
          JaxbXmlPart part = (JaxbXmlPart)rp.getPart(r);
         
          report.append("\n" + part.getPartName() + "\n");
                   
          log.debug("\n" + part.getPartName() + "\n");
          updatePart(part );
//            performOnInstance(
//                ((ContentAccessor)part).getContent() );
         
        }     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.