aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Allison <tallison@apache.org>2024-11-06 20:45:12 +0000
committerTim Allison <tallison@apache.org>2024-11-06 20:45:12 +0000
commit157512d437863fc684d338cf316e6658cb16c2cf (patch)
tree09bca17e8de6859457c7bf0495a76924b0247452
parentb9eabbb477952e763cbe7d1ba2f96a87434d7653 (diff)
downloadpoi-157512d437863fc684d338cf316e6658cb16c2cf.tar.gz
poi-157512d437863fc684d338cf316e6658cb16c2cf.zip
[bug-69434] -- add more properties to AttachmentChunks
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1921800 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/AttachmentChunks.java57
-rw-r--r--poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java9
2 files changed, 65 insertions, 1 deletions
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
@@ -139,6 +149,35 @@ public class AttachmentChunks implements ChunkGroup {
}
/**
+ * @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
*/
public StringChunk getAttachMimeTag() {
@@ -167,6 +206,13 @@ public class AttachmentChunks implements ChunkGroup {
}
/**
+ * @return record key
+ */
+ public ByteChunk getAttachRecordKey() {
+ return attachRecordKey;
+ }
+
+ /**
* Called by the parser whenever a chunk is found.
*/
@Override
@@ -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
*/