public void addDocPropsCustomPart() { if (docPropsCustomPart==null) { try { docPropsCustomPart = new org.docx4j.openpackaging.parts.DocPropsCustomPart(); docPropsCustomPart.setJaxbElement(new Properties()); this.addTargetPart(docPropsCustomPart); } catch (InvalidFormatException e) { //Won't happen, so don't throw log.error(e.getMessage(), e); } } }
public void setProperty(String propName, String propValue) { // does it exist already? org.docx4j.docProps.custom.Properties.Property newProp = getProperty(propName); // If not, let's add one. if (newProp==null) { org.docx4j.docProps.custom.ObjectFactory factory = new org.docx4j.docProps.custom.ObjectFactory(); newProp = factory.createPropertiesProperty(); newProp.setName(propName); newProp.setFmtid(fmtidValLpwstr ); // Magic string newProp.setPid( getNextPid() ); getJaxbElement().getProperty().add(newProp); } if (!newProp.getFmtid().equals(fmtidValLpwstr )) { log.warn("Wrong fmtid? This might not work..."); } // set the value newProp.setLpwstr(propValue); }
/** * @since 3.3.0 */ public boolean getMarkAsFinal() { if (pkg.getDocPropsCustomPart()==null) return false; return pkg.getDocPropsCustomPart().getMarkAsFinal(); }
public void init() { setJAXBContext(Context.jcDocPropsCustom); // Used if this Part is added to [Content_Types].xml setContentType(new org.docx4j.openpackaging.contenttype.ContentType( org.docx4j.openpackaging.contenttype.ContentTypes.OFFICEDOCUMENT_CUSTOMPROPERTIES)); // Used when this Part is added to a rels setRelationshipType(Namespaces.PROPERTIES_CUSTOM); }
/** * @since 3.3.0 */ public boolean getMarkAsFinal() { Property prop = getProperty(MARK_AS_FINAL); if (prop==null) return false; return prop.isBool(); }
/** * @throws InvalidFormatException */ public DocPropsCustomPart(PartName partName) throws InvalidFormatException { super(partName); init(); }
public Property getProperty(String propName) { for (org.docx4j.docProps.custom.Properties.Property prop: getJaxbElement().getProperty() ) { if (prop.getName().equals(propName)) { return prop; } } return null; }
public Part CreateDocPropsCustomPartObject(String partName) throws InvalidFormatException { log.info("Using DocPropsCustomPart ..."); return new DocPropsCustomPart(new PartName(partName)); }
pkg.getRelationshipsPart().removePart(pkg.getDocPropsCustomPart().getPartName());
setJAXBContext(org.docx4j.jaxb.Context.jcDocPropsCustom); Unmarshaller u = jc.createUnmarshaller();
public void init() { setJAXBContext(Context.jcDocPropsCustom); // Used if this Part is added to [Content_Types].xml setContentType(new org.docx4j.openpackaging.contenttype.ContentType( org.docx4j.openpackaging.contenttype.ContentTypes.OFFICEDOCUMENT_CUSTOMPROPERTIES)); // Used when this Part is added to a rels setRelationshipType(Namespaces.PROPERTIES_CUSTOM); }
value = docPropsCustomPart.getProperty(key);
public DocPropsCustomPart() throws InvalidFormatException { super(new PartName("/docProps/custom.xml")); init(); }
/** * Find the first available Pid * * @return */ public int getNextPid() { int highestSeen = 1; // Lowest number Word 2007 seems to like is 2 (!) org.docx4j.docProps.custom.Properties customProps = (org.docx4j.docProps.custom.Properties)getJaxbElement(); for (org.docx4j.docProps.custom.Properties.Property prop: customProps.getProperty() ) { if (prop.getPid()>highestSeen) { highestSeen =prop.getPid(); } } log.debug("Returning " + highestSeen+1); return highestSeen+1; }
public Part CreateDocPropsCustomPartObject(String partName) throws InvalidFormatException { log.info("Using DocPropsCustomPart ..."); return new DocPropsCustomPart(new PartName(partName)); }
pkg.getRelationshipsPart().removePart(pkg.getDocPropsCustomPart().getPartName());
setJAXBContext(org.docx4j.jaxb.Context.jcDocPropsCustom); Unmarshaller u = jc.createUnmarshaller();
/** * @param propName * @param propValue * * @since 3.3.0 */ public void setProperty(String propName, boolean propValue) { // does it exist already? org.docx4j.docProps.custom.Properties.Property newProp = getProperty(propName); // If not, let's add one. if (newProp==null) { org.docx4j.docProps.custom.ObjectFactory factory = new org.docx4j.docProps.custom.ObjectFactory(); newProp = factory.createPropertiesProperty(); newProp.setName(propName); newProp.setFmtid(fmtidValLpwstr ); // Magic string newProp.setPid( getNextPid() ); getJaxbElement().getProperty().add(newProp); } if (!newProp.getFmtid().equals(fmtidValLpwstr )) { log.warn("Wrong fmtid? This might not work..."); } // set the value newProp.setBool(propValue); }
public void addDocPropsCustomPart() { if (docPropsCustomPart==null) { try { docPropsCustomPart = new org.docx4j.openpackaging.parts.DocPropsCustomPart(); docPropsCustomPart.setJaxbElement(new Properties()); this.addTargetPart(docPropsCustomPart); } catch (InvalidFormatException e) { //Won't happen, so don't throw log.error(e.getMessage(), e); } } }
/** * @since 3.3.0 */ public boolean getMarkAsFinal() { Property prop = getProperty(MARK_AS_FINAL); if (prop==null) return false; return prop.isBool(); }