From 1a74a0c1146e30ca2ddecf8ef484a645289171ee Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Wed, 4 May 2011 03:11:28 +0000 Subject: [PATCH] Fix bug #51143 - Correct NameCommentRecord to properly serialise strings git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1099313 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/status.xml | 1 + .../poi/hssf/record/NameCommentRecord.java | 4 ++-- .../org/apache/poi/hssf/usermodel/TestBugs.java | 11 +++++++++++ test-data/spreadsheet/51143.xls | Bin 0 -> 17408 bytes 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 test-data/spreadsheet/51143.xls diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 7b1b3bbfd4..a87636e9f7 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 51143 - NameCommentRecord correction for writing non ASCII strings 51112 - Correct XWPFTable tracking of new rows 51113 - Correct XWPFParagraph tracking of inserted runs 51111 - Correct XWPFParagraph tracking of new runs diff --git a/src/java/org/apache/poi/hssf/record/NameCommentRecord.java b/src/java/org/apache/poi/hssf/record/NameCommentRecord.java index 36d6132d0b..ed33c2d1f2 100644 --- a/src/java/org/apache/poi/hssf/record/NameCommentRecord.java +++ b/src/java/org/apache/poi/hssf/record/NameCommentRecord.java @@ -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 diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 2dfe1a01ae..8341f465a5 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -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 index 0000000000000000000000000000000000000000..a89a109808d5483a33be0312115f52ad9ad63516 GIT binary patch literal 17408 zcmeHO3vgW3dH#2`l2#Afk}SV%d6DqjRwS)#41TPQ1E~i&_QVe4VaAc=yY|+y&Th?8< zd>9gXln#cffeX`THRRj2mnxtB>asfWsw7%*MY-HF|JlkPpf|5T=FcTA-%gytS>&IQ zcFIBa1KB;s-htfSzR#!r501-~4&5>8Fa}-M;cBKl9-G2mXve`R4 zI&?E+L@?kyRh{owMW0aTb;vnqo-@~8b<>R1;NY;;RJK9!{fRm^tMg=>V{%%R`I(}$ zqx1Sc_|5BYwj5R-+lWBPAvk*Fe>*n;V=0#k`Q;|$;)vXW&c3ou@-i$+spQ9S`iOgiNWR!M}E&IvF?)=$XMI3dT{2|4N~;D||P0$bu3^i-6D zSi27$#d;6M0n6vz%InJmIC@bdPQ4^1#T0SO*?2&6D05X`C%yR>@LUxpNZ+=r^ zGfZ!eh6vNd5B6DEDyt;63l=Yh2ZF3-p7u#JhmFw;{$`gyb$OmQ2+vK4{jx;TVM2GI z5_Az(gI}bRPcG&=0*mu(aW|kU*9VF7x+6?%Fki9w3>udcLmG)^TZuoEW$F1>U$>$( zC937GIInJNZEI_5N=%k-ax}%=&eRplNU4>(INw(JyidyAoKN7sDN!T$a6Yc{czZ8z zTXv>eT3VVCljJ04=~hXwPmynNx^5G+y!$M95U(_tB=@sa3pG$MweoE$(9&w%SIYxb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