diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/AttachmentChunks.java b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/AttachmentChunks.java index a171fede40..8993701fbd 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/AttachmentChunks.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/AttachmentChunks.java @@ -17,12 +17,17 @@ package org.apache.poi.hsmf.datatypes; import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_CONTENT_ID; +import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_CONTENT_LOCATION; import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_DATA; import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_EXTENSION; import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_FILENAME; import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_LONG_FILENAME; +import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_LONG_PATHNAME; import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_MIME_TAG; import static org.apache.poi.hsmf.datatypes.MAPIProperty.ATTACH_RENDERING; +import static org.apache.poi.hsmf.datatypes.MAPIProperty.DISPLAY_NAME; +import static org.apache.poi.hsmf.datatypes.MAPIProperty.LANGUAGE; +import static org.apache.poi.hsmf.datatypes.MAPIProperty.RECORD_KEY; import java.io.IOException; import java.io.Serializable; @@ -46,9 +51,14 @@ public class AttachmentChunks implements ChunkGroup { private StringChunk attachExtension; private StringChunk attachFileName; private StringChunk attachLongFileName; + private StringChunk attachLongPathName; + private StringChunk attachDisplayName; private StringChunk attachMimeTag; private DirectoryChunk attachmentDirectory; private StringChunk attachContentId; + private StringChunk attachLanguage; + private StringChunk attachContentLocation; + private ByteChunk attachRecordKey; /** * This is in WMF Format. You'll probably want to pass it to Apache Batik to @@ -138,6 +148,35 @@ public class AttachmentChunks implements ChunkGroup { return attachLongFileName; } + /** + * @return long path name for the attachment + */ + public StringChunk getAttachLongPathName() { + return attachLongPathName; + } + + /** + * @return attachment content location -- relative or absolute URI matching reference in html body + */ + public StringChunk getAttachContentLocation() { + return attachContentLocation; + } + + /** + * + * @return the display name of the attachment + */ + public StringChunk getAttachDisplayName() { + return attachDisplayName; + } + + /** + * @return the language property for the attachment + */ + public StringChunk getAttachLanguage() { + return attachLanguage; + } + /** * @return the attachment mimetag */ @@ -166,6 +205,13 @@ public class AttachmentChunks implements ChunkGroup { return attachContentId; } + /** + * @return record key + */ + public ByteChunk getAttachRecordKey() { + return attachRecordKey; + } + /** * Called by the parser whenever a chunk is found. */ @@ -178,7 +224,6 @@ public class AttachmentChunks implements ChunkGroup { // - ATTACH_DISPOSITION // - ATTACH_ENCODING // - ATTACH_FLAGS - // - ATTACH_LONG_PATHNAME // - ATTACH_SIZE final int chunkId = chunk.getChunkId(); @@ -203,6 +248,16 @@ public class AttachmentChunks implements ChunkGroup { attachRenderingWMF = (ByteChunk) chunk; } else if (chunkId == ATTACH_CONTENT_ID.id) { attachContentId = (StringChunk) chunk; + } else if (chunkId == DISPLAY_NAME.id) { + attachDisplayName = (StringChunk) chunk; + } else if (chunkId == LANGUAGE.id) { + attachLanguage = (StringChunk) chunk; + } else if (chunkId == ATTACH_LONG_PATHNAME.id) { + attachLongPathName = (StringChunk) chunk; + } else if (chunkId == ATTACH_CONTENT_LOCATION.id) { + attachContentLocation = (StringChunk) chunk; + } else if (chunkId == RECORD_KEY.id) { + attachRecordKey = (ByteChunk) chunk; } else { LOG.atWarn().log("Currently unsupported attachment chunk property will be ignored. {}", chunk.getEntryName()); } diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java b/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java index 9b89718b63..83f59bd789 100644 --- a/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java +++ b/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java @@ -193,6 +193,15 @@ public final class TestBasics { noRecipientAddress.setReturnNullOnMissingChunk(false); } + @Test + public void testAttachmentProperties() { + AttachmentChunks[] attachmentChunks = noRecipientAddress.getAttachmentFiles(); + assertEquals(11, attachmentChunks.length); + assertEquals("1.jpg", attachmentChunks[0].getAttachContentLocation().toString()); + assertEquals("1.jpg", attachmentChunks[0].getAttachDisplayName().toString()); + assertEquals(4, attachmentChunks[0].getAttachRecordKey().getValue().length); + } + /** * Test the 7 bit detection */