]> source.dussan.org Git - poi.git/commitdiff
Fix bug #51143 - Correct NameCommentRecord to properly serialise strings
authorNick Burch <nick@apache.org>
Wed, 4 May 2011 03:11:28 +0000 (03:11 +0000)
committerNick Burch <nick@apache.org>
Wed, 4 May 2011 03:11:28 +0000 (03:11 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1099313 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/status.xml
src/java/org/apache/poi/hssf/record/NameCommentRecord.java
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
test-data/spreadsheet/51143.xls [new file with mode: 0644]

index 7b1b3bbfd45f21a8f4f7e9cdfc2873f95b134188..a87636e9f7860c09247de01cf7406f2afc170474 100644 (file)
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.8-beta3" date="2011-??-??">
+           <action dev="poi-developers" type="fix">51143 - NameCommentRecord correction for writing non ASCII strings</action>
            <action dev="poi-developers" type="fix">51112 - Correct XWPFTable tracking of new rows</action>
            <action dev="poi-developers" type="fix">51113 - Correct XWPFParagraph tracking of inserted runs</action>
            <action dev="poi-developers" type="fix">51111 - Correct XWPFParagraph tracking of new runs</action>
index 36d6132d0beb4c4b5999fa66011236472fc08142..ed33c2d1f232ceb01157e4d1d16f1ea5abf68907 100644 (file)
@@ -63,9 +63,9 @@ public final class NameCommentRecord extends StandardRecord {
     out.writeShort(field_5_comment_length);
 
     out.writeByte(0);
-    out.write(field_6_name_text.getBytes());
+    StringUtil.putCompressedUnicode(field_6_name_text, out);
     out.writeByte(0);
-    out.write(field_7_comment_text.getBytes());
+    StringUtil.putCompressedUnicode(field_7_comment_text, out);
   }
 
   @Override
index 2dfe1a01aeb9ebbf5bce65e13103f5bbf90c6cd0..8341f465a58377ae276cba3491811d20c537391d 100644 (file)
@@ -2112,4 +2112,15 @@ if(1==2) {
        c.setCellFormula("HLOOKUP(\"v A1\", A1:B2, 1, )");
        assertEquals("v A1", eval.evaluate(c).getStringValue());
     }
+    
+    /**
+     * Mixture of Ascii and Unicode strings in a 
+     *  NameComment record
+     */
+    public void test51143() throws Exception {
+       HSSFWorkbook wb = openSample("51143.xls");
+       assertEquals(1, wb.getNumberOfSheets());
+       wb = writeOutAndReadBack(wb);
+       assertEquals(1, wb.getNumberOfSheets());
+    }
 }
diff --git a/test-data/spreadsheet/51143.xls b/test-data/spreadsheet/51143.xls
new file mode 100644 (file)
index 0000000..a89a109
Binary files /dev/null and b/test-data/spreadsheet/51143.xls differ