Package org.docx4j.openpackaging.parts

Examples of org.docx4j.openpackaging.parts.CustomXmlDataStoragePropertiesPart


  }

  protected String addPropertiesPart(JaxbCustomXmlDataStoragePart<?> customXmlDataStoragePart, String ns)
      throws InvalidFormatException {

    CustomXmlDataStoragePropertiesPart part = new CustomXmlDataStoragePropertiesPart();

    org.docx4j.customXmlProperties.ObjectFactory of = new org.docx4j.customXmlProperties.ObjectFactory();

    DatastoreItem dsi = of.createDatastoreItem();
    String newItemId = "{" + UUID.randomUUID().toString().toUpperCase() + "}";
    dsi.setItemID(newItemId);
   
    SchemaRefs srefs = of.createSchemaRefs();
    dsi.setSchemaRefs(srefs);
   
    SchemaRef sref = of.createSchemaRefsSchemaRef();
    sref.setUri(ns);
   
    srefs.getSchemaRef().add(sref);
   
    part.setJaxbElement(dsi);

    customXmlDataStoragePart.addTargetPart(part, AddPartBehaviour.RENAME_IF_NAME_EXISTS);
   
    return newItemId;
  }
View Full Code Here


  

  public String addPropertiesPart(JaxbCustomXmlDataStoragePart<?> customXmlDataStoragePart, String ns)
      throws InvalidFormatException {

    CustomXmlDataStoragePropertiesPart part = new CustomXmlDataStoragePropertiesPart();

    org.docx4j.customXmlProperties.ObjectFactory of = new org.docx4j.customXmlProperties.ObjectFactory();

    DatastoreItem dsi = of.createDatastoreItem();
    String newItemId = "{" + UUID.randomUUID().toString().toUpperCase() + "}";
    dsi.setItemID(newItemId);
   
    SchemaRefs srefs = of.createSchemaRefs();
    dsi.setSchemaRefs(srefs);
   
    SchemaRef sref = of.createSchemaRefsSchemaRef();
    sref.setUri(ns);
   
    srefs.getSchemaRef().add(sref);
   
    part.setJaxbElement(dsi);

    customXmlDataStoragePart.addTargetPart(part, AddPartBehaviour.RENAME_IF_NAME_EXISTS);
   
    return newItemId;
  }
View Full Code Here

              Namespaces.CUSTOM_XML_DATA_STORAGE_PROPERTIES);
          if (r==null) {
            log.debug(".. but that doesn't point to a  customXmlProps part");
            continue;
          }
          CustomXmlDataStoragePropertiesPart customXmlProps =
            (CustomXmlDataStoragePropertiesPart)entry.getRelationshipsPart().getPart(r);
          if (customXmlProps==null) {
            log.error(".. but the target seems to be missing?");
           
            if (entry instanceof CustomXmlDataStoragePart) {
              try {
                org.w3c.dom.Document document = ((CustomXmlDataStoragePart)entry).getData().getDocument();
                String localName = document.getDocumentElement().getLocalName();
                log.debug(localName);
                if (document.getDocumentElement().isDefaultNamespace("http://schemas.microsoft.com/?office/?2006/?coverPageProps")
                    || localName.equals("CoverPageProperties" ) ) {
                  // Special case: CoverPageProperties
                  // See "Office Well Defined Custom XML Parts"; see documentinteropinitiative.org/additionalinfo/IS29500/sect5.aspx
                  // Has a rels part, but sometimes no target?  Sometimes it definitely does ...
                  // Give it the store item id, Word 2007 seems to consistently allocate 
                  itemId = BindingHandler.COVERPAGE_PROPERTIES_STOREITEMID.toLowerCase();
                } else {
                  continue;
                }
              } catch (Docx4JException e) {
                e.printStackTrace();
                continue;
              }
            }
          } else {
            itemId = customXmlProps.getItemId().toLowerCase();
          }
        }
        log.info("Identified/registered ds:itemId " + itemId);
        if (pkg.getCustomXmlDataStorageParts().get(itemId.toLowerCase())!=null) {
          log.warn("Duplicate CustomXML itemId " + itemId + "; check your source docx!");
View Full Code Here

    return new CommentsPart(new PartName(partName));
  }

  public Part CreateCustomXmlDataStoragePropertiesPartObject(String partName)
      throws InvalidFormatException {
    return new CustomXmlDataStoragePropertiesPart(new PartName(partName));
  }
View Full Code Here

      return customXmlDataStoragePart;
  }
 
  public static void addProperties(CustomXmlDataStoragePart customXmlDataStoragePart) throws InvalidFormatException {

    CustomXmlDataStoragePropertiesPart part = new CustomXmlDataStoragePropertiesPart();
   
    org.docx4j.customXmlProperties.ObjectFactory of = new org.docx4j.customXmlProperties.ObjectFactory();
   
    DatastoreItem dsi = of.createDatastoreItem();
    String newItemId = "{" + UUID.randomUUID().toString() + "}";         
    dsi.setItemID(newItemId);
   
    part.setJaxbElement(dsi );
   
    customXmlDataStoragePart.addTargetPart(part);
  }
View Full Code Here

      sb.append("\n" + indent + p.getClass().getName() + ": " + indent + p.getPartName().getName()  )
      sb.append("\n" + indent + "root element: " + ((CustomXmlDataStoragePart)p).getData().getDocument().getDocumentElement().getLocalName() );
    } else if ( p instanceof JaxbCustomXmlDataStoragePart) {
        sb.append("\n" + indent + p.getClass().getName() + ": " + indent + p.getPartName().getName()  );
    } else if (p instanceof CustomXmlDataStoragePropertiesPart) { 
      CustomXmlDataStoragePropertiesPart pp = (CustomXmlDataStoragePropertiesPart)p;
      sb.append("\n" + indent +  p.getPartName().getName()
          "  item id: " + pp.getItemId()   );
    }
  }
View Full Code Here

            Namespaces.CUSTOM_XML_DATA_STORAGE_PROPERTIES);
        if (r==null) {
          sb.append("\n.. but that doesn't point to a  customXmlProps part");
          continue;
        }
        CustomXmlDataStoragePropertiesPart customXmlProps =
          (CustomXmlDataStoragePropertiesPart)entry.getRelationshipsPart().getPart(r);
        if (customXmlProps==null) {
          sb.append("\n.. but the target seems to be missing?");
          continue;
        }
        String itemId = customXmlProps.getItemId().toLowerCase();
        sb.append("\nIdentified/registered ds:itemId " + itemId);
        if (tmp.get(itemId.toLowerCase())!=null) {
          sb.append("\nDuplicate CustomXML itemId " + itemId + "; check your source docx!");
        }
        tmp.put(itemId, entry );
View Full Code Here

          Namespaces.CUSTOM_XML_DATA_STORAGE_PROPERTIES);
      if (r==null) {
        log.warn(".. but that doesn't point to a  customXmlProps part");
        return null;
      }
      CustomXmlDataStoragePropertiesPart customXmlProps =
        (CustomXmlDataStoragePropertiesPart)this.getRelationshipsPart().getPart(r);
      if (customXmlProps==null) {
        log.warn(".. but the target seems to be missing?");
        return null;
      } else {
        return customXmlProps.getItemId().toLowerCase();
      }
    }
  } 
View Full Code Here

TOP

Related Classes of org.docx4j.openpackaging.parts.CustomXmlDataStoragePropertiesPart

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.