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 2009/05/16 21:12:30 UTC

svn commit: r775508 - in /poi/trunk/src: documentation/content/xdocs/changes.xml documentation/content/xdocs/status.xml scratchpad/src/org/apache/poi/hsmf/datatypes/StringChunk.java scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.java

Author: nick
Date: Sat May 16 19:12:30 2009
New Revision: 775508

URL: http://svn.apache.org/viewvc?rev=775508&view=rev
Log:
47179 - Fix string encoding issues with HSMF chunks on non-windows platforms

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/datatypes/StringChunk.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/model/TestBlankFileRead.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=775508&r1=775507&r2=775508&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Sat May 16 19:12:30 2009
@@ -37,6 +37,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.5-beta6" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">47179 - Fix string encoding issues with HSMF chunks on non-windows platforms</action>
            <action dev="POI-DEVELOPERS" type="add">47183 - Attachment support for HSMF</action>
            <action dev="POI-DEVELOPERS" type="fix">47154 - Handle the cell format @ as the same as General</action>
            <action dev="POI-DEVELOPERS" type="fix">47048 - Fixed evaluation of defined names with the 'complex' flag set</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=775508&r1=775507&r2=775508&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Sat May 16 19:12:30 2009
@@ -34,6 +34,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.5-beta6" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">47179 - Fix string encoding issues with HSMF chunks on non-windows platforms</action>
            <action dev="POI-DEVELOPERS" type="add">47183 - Attachment support for HSMF</action>
            <action dev="POI-DEVELOPERS" type="fix">47154 - Handle the cell format @ as the same as General</action>
            <action dev="POI-DEVELOPERS" type="fix">47048 - Fixed evaluation of defined names with the 'complex' flag set</action>

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/StringChunk.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/StringChunk.java?rev=775508&r1=775507&r2=775508&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/StringChunk.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/StringChunk.java Sat May 16 19:12:30 2009
@@ -18,6 +18,9 @@
 package org.apache.poi.hsmf.datatypes;
 
 import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.poi.hsmf.datatypes.Types;
 
 /**
  * A Chunk made up of a single string.
@@ -61,7 +64,21 @@
 	 * @see org.apache.poi.hsmf.Chunk.Chunk#setValue(java.io.ByteArrayOutputStream)
 	 */
 	public void setValue(ByteArrayOutputStream value) {
-		this.value = value.toString().replaceAll("\0", "");
+		String tmpValue;
+		if (type == Types.NEW_STRING) {
+			try {
+				tmpValue = new String(value.toByteArray(), "UTF-16LE");
+			} catch (UnsupportedEncodingException e) {
+				throw new RuntimeException("Core encoding not found, JVM broken?", e);
+			}
+		} else {
+			try {
+				tmpValue = new String(value.toByteArray(), "CP1252");
+			} catch (UnsupportedEncodingException e) {
+				throw new RuntimeException("Core encoding not found, JVM broken?", e);
+			}
+		}
+		this.value = tmpValue.replace("\0", "");
 	}
 
 	public String toString() {

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=775508&r1=775507&r2=775508&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 Sat May 16 19:12:30 2009
@@ -68,7 +68,7 @@
 		String obtained = mapiMessage.getDisplayCC();
 		String expected = "";
 		
-		TestCase.assertEquals(obtained, expected);
+		TestCase.assertEquals(expected, obtained);
 	}
 	
 	/**
@@ -80,7 +80,7 @@
 		String obtained = mapiMessage.getDisplayTo();
 		String expected = "";
 		
-		TestCase.assertEquals(obtained, expected);
+		TestCase.assertEquals(expected, obtained);
 	}
 	
 	/**
@@ -107,7 +107,7 @@
 		String obtained = mapiMessage.getDisplayBCC();
 		String expected = "";
 		
-		TestCase.assertEquals(obtained, expected);
+		TestCase.assertEquals(expected, obtained);
 	}
 	
 	



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org