bug 56154: get and set last modified by user property; patch from Danil Lopatin

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751948 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-07-08 17:56:54 +00:00
parent f8fcefcd13
commit 9e383edf35
2 changed files with 15 additions and 1 deletions

View File

@ -301,6 +301,12 @@ public class POIXMLProperties {
public void setLastPrinted(String date) {
part.setLastPrintedProperty(date);
}
public String getLastModifiedBy() {
return part.getLastModifiedByProperty().getValue();
}
public void setLastModifiedBy(String user) {
part.setLastModifiedByProperty(user);
}
public Date getModified() {
return part.getModifiedProperty().getValue();
}

View File

@ -192,7 +192,7 @@ public final class TestPOIXMLProperties {
XWPFDocument doc2 = XWPFTestDataSamples.writeOutAndReadBack(doc);
doc.close();
cp = doc.getProperties().getCoreProperties();
cp = doc2.getProperties().getCoreProperties();
Date dt3 = cp.getCreated();
assertEquals(dateCreated, dt3);
doc2.close();
@ -208,6 +208,14 @@ public final class TestPOIXMLProperties {
assertEquals("20", _coreProperties.getRevision());
}
@Test
public void testLastModifiedByProperty() {
String lastModifiedBy = _coreProperties.getLastModifiedBy();
assertEquals("Paolo Mottadelli", lastModifiedBy);
_coreProperties.setLastModifiedBy("Test User");
assertEquals("Test User", _coreProperties.getLastModifiedBy());
}
public static boolean dateTimeEqualToUTCString(Date dateTime, String utcString) {
Calendar utcCalendar = LocaleUtil.getLocaleCalendar(LocaleUtil.TIMEZONE_UTC);
utcCalendar.setTimeInMillis(dateTime.getTime());