]> source.dussan.org Git - poi.git/commitdiff
[bug-69434] -- add more properties to AttachmentChunks
authorTim Allison <tallison@apache.org>
Wed, 6 Nov 2024 20:45:12 +0000 (20:45 +0000)
committerTim Allison <tallison@apache.org>
Wed, 6 Nov 2024 20:45:12 +0000 (20:45 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1921800 13f79535-47bb-0310-9956-ffa450edef68

poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/AttachmentChunks.java
poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java

index a171fede40c6dfb31d33b9a961dc47a3475b8404..8993701fbda9dfbaa5c8ff2f3588b91a3c29c887 100644 (file)
 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());
             }
index 9b89718b6309d3b420fa7058196b5196905e14c5..83f59bd7899b707ffd6e3ec5bee1fd79fbee0aa4 100644 (file)
@@ -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
     */