Examples of RelationshipsPart


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

    pkg.handled.put(resolvedPartUri, resolvedPartUri);

   
//    unusedZipEntries.put(resolvedPartUri, new Boolean(false));
   
    RelationshipsPart rrp = getRelationshipsPart(part);
    if (rrp!=null) {
      // recurse via this parts relationships, if it has any
      addPartsFromRelationships(part, rrp, ctm );
//      String relPart = PartName.getRelationshipsPartName(
//          part.getPartName().getName().substring(1) );
View Full Code Here

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

   * @throws InvalidFormatException
   */
  public RelationshipsPart getRelationshipsPart(Part part)
  throws Docx4JException, InvalidFormatException {
   
    RelationshipsPart rrp = null;
    // recurse via this parts relationships, if it has any
    //String relPart = PartName.getRelationshipsPartName(target);
    String relPart = PartName.getRelationshipsPartName(
        part.getPartName().getName().substring(1) );

View Full Code Here

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

      CTSettings settings = Context.getWmlObjectFactory().createCTSettings();
      dsp.setJaxbElement(settings);
      wordMLPackage.getMainDocumentPart().addTargetPart(dsp);
     
      // Create external rel
      RelationshipsPart rp = RelationshipsPart.createRelationshipsPartForPart(dsp);    
      org.docx4j.relationships.Relationship rel = new org.docx4j.relationships.ObjectFactory().createRelationship();
      rel.setType( Namespaces.ATTACHED_TEMPLATE  );
      rel.setTarget(templatePath);
      rel.setTargetMode("External");     
      rp.addRelationship(rel); // addRelationship sets the rel's @Id
     
      settings.setAttachedTemplate(
          (CTRel)XmlUtils.unmarshalString("<w:attachedTemplate xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"" + rel.getId() + "\"/>", Context.jc, CTRel.class)
          );
      
View Full Code Here

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

    }
  }

  protected static void removeDefinedCustomXmlParts(WordprocessingMLPackage wmlPackage, CustomXmlDataStoragePart customXmlDataStoragePart) {
  List<PartName> partsToRemove = new ArrayList<PartName>();
  RelationshipsPart relationshipsPart = wmlPackage.getMainDocumentPart().getRelationshipsPart();
  List<Relationship> relationshipsList = ((relationshipsPart != null) &&
                        (relationshipsPart.getRelationships() != null) ?
                        relationshipsPart.getRelationships().getRelationship() : null);
  Part part = null;
    if (relationshipsList != null) {
      for (Relationship relationship : relationshipsList) {
        if (Namespaces.CUSTOM_XML_DATA_STORAGE.equals(relationship.getType())) {
          part = relationshipsPart.getPart(relationship);
          if (part==customXmlDataStoragePart) {
            partsToRemove.add(part.getPartName());
          }
        }
      }
    }
    if (!partsToRemove.isEmpty()) {
      for (int i=0; i<partsToRemove.size(); i++) {
        relationshipsPart.removePart(partsToRemove.get(i));
      }
    }
  }
View Full Code Here

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

  //      <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>   
     
      String partName = "_rels/.rels";
      RelationshipsPart rp = getRelationshipsPartFromJCR(p, jcrSession, docxContentNode,  partName);
      p.setRelationships(rp);
      //rp.setPackageRelationshipPart(true);
//      unusedJCRNodes.put(partName, new Boolean(false));
     
     
View Full Code Here

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

      InputStream is = getInputStreamFromJCRPart( nodeMapper, contentNode);
     

      //return new RelationshipsPart(p, new PartName("/" + partName), is );
     
      RelationshipsPart rp = new RelationshipsPart(new PartName("/" + partName) );
      rp.setSourceP(p);
      rp.unmarshal(is);
      return rp;
     
     
    } catch (Exception e) {
      // TODO Auto-generated catch block
View Full Code Here

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

    }       
   
//    unusedJCRNodes.put(resolvedPartUri, new Boolean(false));
    log.info(".. added part '" + part.getPartName() + "'" );
   
    RelationshipsPart rrp = getRelationshipsPart(jcrSession, docxNode, part);
    if (rrp!=null) {
      // recurse via this parts relationships, if it has any
      addPartsFromRelationships(jcrSession, docxNode, part, rrp );         
      String relPart = PartName.getRelationshipsPartName(
          part.getPartName().getName().substring(1) );
View Full Code Here

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

      Node docxNode, Part part)
      throws Docx4JException, RepositoryException, InvalidFormatException {
    //String relPart = PartName.getRelationshipsPartName(target);
    String relPart = PartName.getRelationshipsPartName(
        part.getPartName().getName().substring(1) );
    RelationshipsPart rrp = null;
    try {
      docxNode.getNode(encodeSlashes(nodeMapper, relPart)); // if null,
      //throws javax.jcr.PathNotFoundException
     
      log.info("Found relationships " + relPart );
      log.info("Recursing ... " );
      rrp = getRelationshipsPartFromJCR(
          part, jcrSession, docxNode,  relPart);
      part.setRelationships(rrp);
      log.info("set its RelationshipsPart to '" + rrp.getPartName() + "'");
    } catch (javax.jcr.PathNotFoundException e) {
      log.info("No relationships " + relPart )
      return null;
    }
    return rrp;
View Full Code Here

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

  public static void visit(WordprocessingMLPackage wmlPackage,
      boolean bodyOnly, Callback callback) {
   
    MainDocumentPart mainDocument = null;
    RelationshipsPart relPart = null;
    List<Relationship> relList = null;
    List<Object> elementList = null;
   
    if ((wmlPackage != null) && (callback != null)) {
      mainDocument = wmlPackage.getMainDocumentPart();
      callback.walkJAXBElements(mainDocument.getJaxbElement().getBody());
      if (!bodyOnly) {
        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="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>   
     
      String partName = "_rels/.rels";
      RelationshipsPart rp = p.getRelationshipsPart();
      saveRawXmlPart(rp );
     
      // 5. Now recursively
//      addPartsFromRelationships(out, "", rp );
      addPartsFromRelationships(rp );
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.