Examples of RelationshipsPart


Examples of org.docx4j.openpackaging.parts.relationships.RelationshipsPart

    Set<ContentAccessor> partList = new HashSet<ContentAccessor>();

    partList.add(srcPackage.getMainDocumentPart());

    // Add headers/footers
    RelationshipsPart rp = srcPackage.getMainDocumentPart()
        .getRelationshipsPart();
    for (Relationship r : rp.getRelationships().getRelationship()) {

      if (r.getType().equals(Namespaces.HEADER)) {
        partList.add((HeaderPart) rp.getPart(r));
      } else if (r.getType().equals(Namespaces.FOOTER)) {
        partList.add((FooterPart) rp.getPart(r));
      }
    }

    return partList;
  }
View Full Code Here

Examples of org.docx4j.openpackaging.parts.relationships.RelationshipsPart

    input.getMainDocumentPart().getContent().clear();
    input.getMainDocumentPart().getContent().addAll(mdpResults);
   
    if (processHeadersAndFooters) {
     
      RelationshipsPart rp = input.getMainDocumentPart().getRelationshipsPart();
      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 );
View Full Code Here

Examples of org.docx4j.openpackaging.parts.relationships.RelationshipsPart

  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))
            .getJaxbElement().getContent();
      } else if (Namespaces.FOOTER.equals(rs.getType())) {
        elementList = ((FooterPart) relPart.getPart(rs))
            .getJaxbElement().getContent();
      } else if (Namespaces.ENDNOTES.equals(rs.getType())) {
        //elementList = ((EndnotesPart) relPart.getPart(rs)).getContent();
        elementList = new ArrayList();
        elementList.addAll(
            ((EndnotesPart) relPart.getPart(rs)).getJaxbElement().getEndnote() );
      } else if (Namespaces.FOOTNOTES.equals(rs.getType())) {
        //elementList =  ((FootnotesPart) relPart.getPart(rs)).getContent();
        elementList = new ArrayList();
        elementList.addAll(
            ((FootnotesPart) relPart.getPart(rs)).getJaxbElement().getFootnote() );
      } else if (Namespaces.COMMENTS.equals(rs.getType())) {
        elementList = new ArrayList();
        for (Comment comment : ((CommentsPart) relPart
            .getPart(rs)).getJaxbElement().getComment()) {
          elementList.addAll(comment.getEGBlockLevelElts());
        }
      }
      if ((elementList != null) && (!elementList.isEmpty())) {
View Full Code Here

Examples of org.docx4j.openpackaging.parts.relationships.RelationshipsPart

//        <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>
//        <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>
//        <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
//      </Relationships>   
     
      RelationshipsPart rp = packageIn.getRelationshipsPart();
      saveRawXmlPart(rp );      
     
      // Now recursively
      addPartsFromRelationships(rp );
     
View Full Code Here

Examples of org.docx4j.openpackaging.parts.relationships.RelationshipsPart

    // recurse via this parts relationships, if it has any
    if (part.getRelationshipsPart()!= null
        && part.getRelationshipsPart().getJaxbElement()!=null
        && part.getRelationshipsPart().getJaxbElement().getRelationship()!=null
        && part.getRelationshipsPart().getJaxbElement().getRelationship().size()>0) {
      RelationshipsPart rrp = part.getRelationshipsPart();
      log.info("Found relationships " + rrp.getPartName() );
      String relPart = PartName.getRelationshipsPartName(resolvedPartUri);
      log.info("Cf constructed name " + relPart );
     
      saveRawXmlPart( rrp);
      //, "/" + relPart );  // '/' necessary for Xml Pkg format.
View Full Code Here

Examples of org.docx4j.openpackaging.parts.relationships.RelationshipsPart

   
    updatePart(wordMLPackage.getMainDocumentPart() );

    if (processHeadersAndFooters) {
     
      RelationshipsPart rp = wordMLPackage.getMainDocumentPart().getRelationshipsPart();
      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 );
View Full Code Here

Examples of org.docx4j.openpackaging.parts.relationships.RelationshipsPart

 
 
  public static OpcPackage process(OpcPackage opcPackage, Set<String> relationshipTypes) throws Docx4JException {
   
    OpcPackage ret = null;
    RelationshipsPart relPart = null;
    if (opcPackage != null) {
      if ((relationshipTypes != null) && (relationshipTypes.isEmpty())) {
        ret = opcPackage;
      }
      else {
View Full Code Here

Examples of org.docx4j.openpackaging.parts.relationships.RelationshipsPart

  protected static void deepCopyRelationships(OpcPackage opcPackage,
      Base sourcePart,
      Base targetPart,
      Set<String> relationshipTypes) throws Docx4JException {
   
    RelationshipsPart sourceRelationshipsPart = sourcePart.getRelationshipsPart(false);
    Relationships sourceRelationships = (sourceRelationshipsPart != null ?
                          sourceRelationshipsPart.getRelationships() :
                     null);
    List<Relationship> sourceRelationshipList = (sourceRelationships != null ?
                              sourceRelationships.getRelationship() :
                           null);
   
    RelationshipsPart targetRelationshipsPart = null;
    Relationships targetRelationships = null;
   
    Relationship sourceRelationship = null;
    Relationship targetRelationship = null;
   
    Part sourceChild = null;
    Part targetChild = null;
   
    if ((sourceRelationshipList != null) &&
      (!sourceRelationshipList.isEmpty())) {
     
      targetRelationshipsPart = targetPart.getRelationshipsPart(); //create if needed
      targetRelationships = targetRelationshipsPart.getRelationships();
     
      for (int i=0; i<sourceRelationshipList.size(); i++) {
       
        sourceRelationship = sourceRelationshipList.get(i);
        //the Relationship doesn't have any references to parts, therefore it can be reused
View Full Code Here

Examples of org.docx4j.openpackaging.parts.relationships.RelationshipsPart

 
  public static ConversionSectionWrappers process(WordprocessingMLPackage wmlPackage, boolean dummySections, boolean dummyPageNumbering) throws Docx4JException {
   
    List<ConversionSectionWrapper> conversionSections = null;
    Document document = wmlPackage.getMainDocumentPart().getContents();
    RelationshipsPart rels = wmlPackage.getMainDocumentPart().getRelationshipsPart();
    BooleanDefaultTrue evenAndOddHeaders = null;

    if ((wmlPackage.getMainDocumentPart().getDocumentSettingsPart() != null) &&
      (wmlPackage.getMainDocumentPart().getDocumentSettingsPart().getContents() != null)) {
      evenAndOddHeaders = wmlPackage.getMainDocumentPart().getDocumentSettingsPart().getContents().getEvenAndOddHeaders();
View Full Code Here

Examples of org.docx4j.openpackaging.parts.relationships.RelationshipsPart

    // Open a document from the file system
    // 1. Load the Package - .docx or Flat OPC .xml
    WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(inputfile);   
   
    // List the parts by walking the rels tree
    RelationshipsPart rp = wordMLPackage.getRelationshipsPart();
    StringBuilder sb = new StringBuilder();
    printInfo(rp, sb, "");
    traverseRelationships(wordMLPackage, rp, sb, "    ");
   
    System.out.println(sb.toString());
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.