<changes>
<release version="3.7-beta2" date="2010-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">49599 - Correct writing of NoteRecord author text when switching between ASCII and Unicode</action>
<action dev="POI-DEVELOPERS" type="fix">HWPF: Improve reading of auto-saved ("complex") documents</action>
<action dev="POI-DEVELOPERS" type="add">Paragraph level as well as whole-file text extraction for Word 6/95 files through HWPF</action>
<action dev="POI-DEVELOPERS" type="add">Text Extraction support for older Word 6 and Word 95 files via HWPF</action>
public void setFlags(short flags) {
field_3_flags = flags;
}
+
+ /**
+ * For unit testing only!
+ */
+ protected boolean authorIsMultibyte() {
+ return field_5_hasMultibyte;
+ }
/**
* Object id for OBJ record that contains the comment
*/
public void setAuthor(String author) {
field_6_author = author;
+ field_5_hasMultibyte = StringUtil.hasMultibyte(author);
}
public Object clone() {
throw new AssertionFailedError("Identified bug in reading note with unicode author");
}
assertEquals("\u30A2\u30D1\u30C3\u30C1\u65CF", nr.getAuthor());
+ assertTrue(nr.authorIsMultibyte());
byte[] ser = nr.serialize();
TestcaseRecordInputStream.confirmRecordEncoding(NoteRecord.sid, data, ser);
+
+ // Re-check
+ in = TestcaseRecordInputStream.create(ser);
+ nr = new NoteRecord(in);
+ assertEquals("\u30A2\u30D1\u30C3\u30C1\u65CF", nr.getAuthor());
+ assertTrue(nr.authorIsMultibyte());
+
+
+ // Change to a non unicode author, will stop being unicode
+ nr.setAuthor("Simple");
+ ser = nr.serialize();
+ in = TestcaseRecordInputStream.create(ser);
+ nr = new NoteRecord(in);
+
+ assertEquals("Simple", nr.getAuthor());
+ assertFalse(nr.authorIsMultibyte());
+
+ // Now set it back again
+ nr.setAuthor("Unicode\u1234");
+ ser = nr.serialize();
+ in = TestcaseRecordInputStream.create(ser);
+ nr = new NoteRecord(in);
+
+ assertEquals("Unicode\u1234", nr.getAuthor());
+ assertTrue(nr.authorIsMultibyte());
}
}