* @throws Exception
* @throws IllegalArgumentException
*/
private void updateMetaData() throws IllegalArgumentException, Exception {
if (getOfficeMetadata().hasAutomaticUpdate()) {
OdfOfficeMeta metaData = getOfficeMetadata();
// set creation dateĀ“
if (mCreationDate != null) {
getOfficeMetadata().setCreationDate(mCreationDate);
}
// update late modfied date
Calendar calendar = Calendar.getInstance();
metaData.setDate(calendar);
// update editing-cycles
Integer cycle = metaData.getEditingCycles();
if (cycle != null) {
metaData.setEditingCycles(++cycle);
} else {
metaData.setEditingCycles(1);
}
// update editing-duration
long editingDuration = calendar.getTimeInMillis() - documentOpeningTime;
editingDuration = (editingDuration < 1) ? 1 : editingDuration;
try {
DatatypeFactory aFactory = DatatypeFactory.newInstance();
metaData.setEditingDuration(new Duration(aFactory.newDurationDayTime(editingDuration)));
} catch (DatatypeConfigurationException e) {
Logger.getLogger(OdfDocument.class.getName()).log(Level.SEVERE,
"editing duration update fail as DatatypeFactory can not be instanced", e);
}
}