/** * Generate next id that uniquely relates a custom property * * @return next property id starting with 2 */ protected int nextPid() { int propid = 1; for(CTProperty p : props.getProperties().getPropertyList()) { if(p.getPid() > propid) propid = p.getPid(); } return propid + 1; }
public org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties getUnderlyingProperties() { return props.getProperties(); }
/** * Check if a property with this name already exists in the collection of custom properties * * @param name the name to check * @return whether a property with the given name exists in the custom properties */ public boolean contains(String name) { for(CTProperty p : props.getProperties().getPropertyList()) { if(p.getName().equals(name)) return true; } return false; }
org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties props = properties.getUnderlyingProperties(); for (int i = 0; i < props.sizeOfPropertyArray(); i++) { CTProperty property = props.getPropertyArray(i); String val = null; Date date = null; if (property.isSetLpwstr()) { val = property.getLpwstr(); } else if (property.isSetLpstr()) { val = property.getLpstr(); } else if (property.isSetDate()) { date = property.getDate().getTime(); } else if (property.isSetFiletime()) { date = property.getFiletime().getTime(); } else if (property.isSetBool()) { val = Boolean.toString(property.getBool()); else if (property.isSetI1()) { val = Integer.toString(property.getI1()); } else if (property.isSetI2()) { val = Integer.toString(property.getI2()); } else if (property.isSetI4()) { val = Integer.toString(property.getI4()); } else if (property.isSetI8()) { val = Long.toString(property.getI8()); } else if (property.isSetInt()) { val = Integer.toString(property.getInt());
for (CTProperty property : props.getPropertyList()) { String val = "(not implemented!)"; if (property.isSetLpwstr()) { val = property.getLpwstr(); } else if (property.isSetLpstr()) { val = property.getLpstr(); } else if (property.isSetDate()) { val = property.getDate().toString(); } else if (property.isSetFiletime()) { val = property.getFiletime().toString(); } else if (property.isSetBool()) { val = Boolean.toString(property.getBool()); else if (property.isSetI1()) { val = Integer.toString(property.getI1()); } else if (property.isSetI2()) { val = Integer.toString(property.getI2()); } else if (property.isSetI4()) { val = Integer.toString(property.getI4()); } else if (property.isSetI8()) { val = Long.toString(property.getI8()); } else if (property.isSetInt()) { val = Integer.toString(property.getInt()); else if (property.isSetUi1()) { val = Integer.toString(property.getUi1()); } else if (property.isSetUi2()) { val = Integer.toString(property.getUi2());
/** * Add a new property * * @param name the property name * @throws IllegalArgumentException if a property with this name already exists */ private CTProperty add(String name) { if(contains(name)) { throw new IllegalArgumentException("A property with this name " + "already exists in the custom properties"); } CTProperty p = props.getProperties().addNewProperty(); int pid = nextPid(); p.setPid(pid); p.setFmtid(FORMAT_ID); p.setName(name); return p; }
custPart = pkg.getPart(custRel.getRelationship(0)); if (custPart == null) { cust = new CustomProperties((org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument)NEW_CUST_INSTANCE.copy()); } else { org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props = org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument.Factory.parse( custPart.getInputStream(), DEFAULT_XML_OPTIONS); cust = new CustomProperties(props); cust = new CustomProperties((org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument)NEW_CUST_INSTANCE.copy());
/** * Add a new double property * * @param name the property name * @param value the property value * * @throws IllegalArgumentException if a property with this name already exists */ public void addProperty(String name, double value){ CTProperty p = add(name); p.setR8(value); }
/** * Add a new string property * * @param name the property name * @param value the property value * * @throws IllegalArgumentException if a property with this name already exists */ public void addProperty(String name, String value){ CTProperty p = add(name); p.setLpwstr(value); }
/** * Add a new integer property * * @param name the property name * @param value the property value * * @throws IllegalArgumentException if a property with this name already exists */ public void addProperty(String name, int value){ CTProperty p = add(name); p.setI4(value); }
/** * Add a new boolean property * * @param name the property name * @param value the property value * * @throws IllegalArgumentException if a property with this name already exists */ public void addProperty(String name, boolean value){ CTProperty p = add(name); p.setBool(value); }
cust.props.save(out, DEFAULT_XML_OPTIONS);
/** * Retrieve the custom property with this name, or null if none exists. * * You will need to test the various isSetX methods to work out * what the type of the property is, before fetching the * appropriate value for it. * * @param name the name of the property to fetch * * @return the custom property with this name, or null if none exists */ public CTProperty getProperty(String name) { for(CTProperty p : props.getProperties().getPropertyList()) { if(p.getName().equals(name)) { return p; } } return null; } }
/** * Generate next id that uniquely relates a custom property * * @return next property id starting with 2 */ protected int nextPid(){ int propid = 1; for(CTProperty p : props.getProperties().getPropertyList()){ if(p.getPid() > propid) propid = p.getPid(); } return propid + 1; }
public org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties getUnderlyingProperties() { return props.getProperties(); }
/** * Add a new double property * * @throws IllegalArgumentException if a property with this name already exists */ public void addProperty(String name, double value){ CTProperty p = add(name); p.setR8(value); }
/** * Check if a property with this name already exists in the collection of custom properties * * @param name the name to check * @return whether a property with the given name exists in the custom properties */ public boolean contains(String name) { for(CTProperty p : props.getProperties().getPropertyList()) { if(p.getName().equals(name)) return true; } return false; }
/** * Generate next id that uniquely relates a custom property * * @return next property id starting with 2 */ protected int nextPid() { int propid = 1; for(CTProperty p : props.getProperties().getPropertyList()) { if(p.getPid() > propid) propid = p.getPid(); } return propid + 1; }
public org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProperties getUnderlyingProperties() { return props.getProperties(); }
/** * Check if a property with this name already exists in the collection of custom properties * * @param name the name to check * @return whether a property with the given name exists in the custom properties */ public boolean contains(String name){ for(CTProperty p : props.getProperties().getPropertyList()){ if(p.getName().equals(name)) return true; } return false; } }