From 1a74a0c1146e30ca2ddecf8ef484a645289171ee Mon Sep 17 00:00:00 2001 From: Nick Burch <nick@apache.org> 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 @@ <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> 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<mf@1 zHXcNi%w!tM5Sy3^+^K0w!^44K9tJ{!Oj}5rC8i04l0t_xkcmjA9lLZ&GQjQkopbNr zyZ5Da`WhJS&bfQ<fBy6RkMp1Bz4y7Z^{?LX!0exk=U6Xg@~&AW6)t)V*G%fD6Pbq# z-oI;_rY4Hu@`K|&<bijfYYLTDhLk`mM`E2<A|;WkkgAbtkZO@8Ax%b_f`kx|dZY%V zsYs1T(~zbk%|M!oGz)1q(j26@NQ@Px`L65tkh|V@s(wuR@f(tqTp@k<ACS+ZW=cP% zBVuf)#8E7j<XL1)o#jgYRU03f-CLE9Jr|c;KmMCYWWeFL2GR#)zwB0e?AOE#I5$W< z#<;b0D5WShyrENbmdkb-mIL^8E89223t6QTDMOOObzcPNV#sG7NOPz|1Zz>&Th?8< zd>9gXln#cffeX`THRRj2mnxtB>asfWsw7%*MY-HF|JlkPpf|5T=FcTA-%gytS>&IQ zcFIBa1KB;s-htfSzR#!r501-~4&5>8Fa}-M;cBKl9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