You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2007/12/21 13:16:55 UTC
svn commit: r606169 - in /poi/trunk/src: documentation/content/xdocs/
scratchpad/src/org/apache/poi/hsmf/
scratchpad/src/org/apache/poi/hsmf/datatypes/
scratchpad/testcases/org/apache/poi/hsmf/model/
Author: nick
Date: Fri Dec 21 04:16:54 2007
New Revision: 606169
URL: http://svn.apache.org/viewvc?rev=606169&view=rev
Log:
Patch from bug #44055 - support reading the from field from HSMF messages
Modified:
poi/trunk/src/documentation/content/xdocs/changes.xml
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java
Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=606169&r1=606168&r2=606169&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Fri Dec 21 04:16:54 2007
@@ -36,6 +36,7 @@
<!-- Don't forget to update status.xml too! -->
<release version="3.0.2-FINAL" date="2007-??-??">
+ <action dev="POI-DEVELOPERS" type="add">44055 - [PATCH] Support for getting the from field from HSMF messages</action>
<action dev="POI-DEVELOPERS" type="add">43551 - [PATCH] Support for 1904 date windowing in HSSF (previously only supported 1900 date windowing)</action>
<action dev="POI-DEVELOPERS" type="add">41064 - [PATCH] Support for String continue records</action>
<action dev="POI-DEVELOPERS" type="add">27511 - [PATCH] Support for data validation, via DVRecord and DVALRecord</action>
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=606169&r1=606168&r2=606169&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Dec 21 04:16:54 2007
@@ -33,6 +33,7 @@
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.0.2-FINAL" date="2007-??-??">
+ <action dev="POI-DEVELOPERS" type="add">44055 - [PATCH] Support for getting the from field from HSMF messages</action>
<action dev="POI-DEVELOPERS" type="add">43551 - [PATCH] Support for 1904 date windowing in HSSF (previously only supported 1900 date windowing)</action>
<action dev="POI-DEVELOPERS" type="add">41064 - [PATCH] Support for String continue records</action>
<action dev="POI-DEVELOPERS" type="add">27511 - [PATCH] Support for data validation, via DVRecord and DVALRecord</action>
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java?rev=606169&r1=606168&r2=606169&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java Fri Dec 21 04:16:54 2007
@@ -48,15 +48,24 @@
/**
- * Constructor for reading MSG Files.
+ * Constructor for reading MSG Files from the file system.
* @param filename
* @throws IOException
*/
public MAPIMessage(String filename) throws IOException {
- InputStream in = new FileInputStream(new File(filename));
+ this(new FileInputStream(new File(filename)));
+ }
+
+ /**
+ * Constructor for reading MSG Files from an input stream.
+ * @param in
+ * @throws IOException
+ */
+ public MAPIMessage(InputStream in) throws IOException {
this.fs = new POIFSFileSystem(in);
chunkParser = new POIFSChunkParser(this.fs);
}
+
/**
* Gets a string value based on the passed chunk.
@@ -99,6 +108,16 @@
*/
public String getDisplayTo() throws ChunkNotFoundException {
return getStringFromChunk(Chunks.getInstance().displayToChunk);
+ }
+
+ /**
+ * Gets the display value of the "FROM" line of the outlook message
+ * This is not the actual address that was sent from but the formated display of the user name.
+ * @return
+ * @throws ChunkNotFoundException
+ */
+ public String getDisplayFrom() throws ChunkNotFoundException {
+ return getStringFromChunk(Chunks.getInstance().displayFromChunk);
}
/**
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java?rev=606169&r1=606168&r2=606169&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java Fri Dec 21 04:16:54 2007
@@ -29,6 +29,7 @@
public StringChunk textBodyChunk = new StringChunk(0x1000); //BODY Chunk, for plain/text messages
public StringChunk subjectChunk = new StringChunk(0x0037); //Subject link chunk, in plain/text
public StringChunk displayToChunk = new StringChunk(0x0E04); //Value that is in the TO field (not actually the addresses as they are stored in recip directory nodes
+ public StringChunk displayFromChunk = new StringChunk(0x0C1A); //Value that is in the FROM field
public StringChunk displayCCChunk = new StringChunk(0x0E03); //value that shows in the CC field
public StringChunk displayBCCChunk = new StringChunk(0x0E02); //Value that shows in the BCC field
public StringChunk conversationTopic = new StringChunk(0x0070); //Sort of like the subject line, but without the RE: and FWD: parts.
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java?rev=606169&r1=606168&r2=606169&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java Fri Dec 21 04:16:54 2007
@@ -84,6 +84,21 @@
}
/**
+ * Test to see if we can read the FROM Chunk.
+ * @throws ChunkNotFoundException
+ *
+ */
+ public void testReadDisplayFrom() throws ChunkNotFoundException {
+ try {
+ mapiMessage.getDisplayFrom();
+ } catch(ChunkNotFoundException exp) {
+ return;
+ }
+
+ TestCase.fail("Should have thrown a ChunkNotFoundException but didn't");
+ }
+
+ /**
* Test to see if we can read the CC Chunk.
* @throws ChunkNotFoundException
*
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java?rev=606169&r1=606168&r2=606169&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestSimpleFileRead.java Fri Dec 21 04:16:54 2007
@@ -67,6 +67,18 @@
}
/**
+ * Test to see if we can read the From Chunk.
+ * @throws ChunkNotFoundException
+ *
+ */
+ public void testReadDisplayFrom() throws ChunkNotFoundException {
+ String obtained = mapiMessage.getDisplayFrom();
+ String expected = "Travis Ferguson";
+
+ TestCase.assertEquals(obtained, expected);
+ }
+
+ /**
* Test to see if we can read the CC Chunk.
* @throws ChunkNotFoundException
*
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org