Author: tallison
Date: Wed Nov  6 20:45:12 2024
New Revision: 1921800

URL: http://svn.apache.org/viewvc?rev=1921800&view=rev
Log:
[bug-69434] -- add more properties to AttachmentChunks

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

Modified: 
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/AttachmentChunks.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/AttachmentChunks.java?rev=1921800&r1=1921799&r2=1921800&view=diff
==============================================================================
--- 
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/AttachmentChunks.java
 (original)
+++ 
poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/AttachmentChunks.java
 Wed Nov  6 20:45:12 2024
@@ -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
     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
     }
 
     /**
+     * @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
     }
 
     /**
+     * @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
         // - ATTACH_DISPOSITION
         // - ATTACH_ENCODING
         // - ATTACH_FLAGS
-        // - ATTACH_LONG_PATHNAME
         // - ATTACH_SIZE
         final int chunkId = chunk.getChunkId();
 
@@ -203,6 +248,16 @@ public class AttachmentChunks implements
                 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());
             }

Modified: 
poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java?rev=1921800&r1=1921799&r2=1921800&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java 
(original)
+++ poi/trunk/poi-scratchpad/src/test/java/org/apache/poi/hsmf/TestBasics.java 
Wed Nov  6 20:45:12 2024
@@ -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
     */



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to