<!-- Don't forget to update status.xml too! -->
<release version="3.0.2-FINAL" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">44200 - Enable cloning of sheets with notes </action>
<action dev="POI-DEVELOPERS" type="add">43008 - Add a moveCell method to HSSFRow, and deprecate setCellNum(), which didn't update things properly</action>
<action dev="POI-DEVELOPERS" type="fix">43058 - Support setting row grouping on files from CR IX, which lack GutsRecords</action>
<action dev="POI-DEVELOPERS" type="fix">31795 - Support cloning of sheets with certain drawing objects on them</action>
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.0.2-FINAL" date="2008-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">44200 - Enable cloning of sheets with notes </action>
<action dev="POI-DEVELOPERS" type="add">43008 - Add a moveCell method to HSSFRow, and deprecate setCellNum(), which didn't update things properly</action>
<action dev="POI-DEVELOPERS" type="fix">43058 - Support setting row grouping on files from CR IX, which lack GutsRecords</action>
<action dev="POI-DEVELOPERS" type="fix">31795 - Support cloning of sheets with certain drawing objects on them</action>
public void setAuthor(String author){
field_5_author = author;
}
+
+ public Object clone() {
+ NoteRecord rec = new NoteRecord();
+ rec.field_1_row = field_1_row;
+ rec.field_2_col = field_2_col;
+ rec.field_3_flags = field_3_flags;
+ rec.field_4_shapeid = field_4_shapeid;
+ rec.field_5_author = field_5_author;
+ return rec;
+ }
+
}
{
return sid;
}
+
+ public Object clone() {
+ NoteStructureSubRecord rec = new NoteStructureSubRecord();
+ byte[] recdata = new byte[reserved.length];
+ System.arraycopy(reserved, 0, recdata, 0, recdata.length);
+ rec.reserved = recdata;
+ return rec;
+ }
+
}
buffer.append( "[/TXO]\n" );
return buffer.toString();
}
+
+ public Object clone() {
+
+ TextObjectRecord rec = new TextObjectRecord();
+ rec.str = str;
+
+ rec.setOptions(getOptions());
+ rec.setTextOrientation(getTextOrientation());
+ rec.setReserved4(getReserved4());
+ rec.setReserved5(getReserved5());
+ rec.setReserved6(getReserved6());
+ rec.setTextLength(getTextLength());
+ rec.setFormattingRunLength(getFormattingRunLength());
+ rec.setReserved7(getReserved7());
+ return rec;
+ }
+
}
System.arraycopy(ser, 4, recdata, 0, recdata.length);
assertTrue(Arrays.equals(data, recdata));
}
+
+ public void testClone()
+ {
+ NoteRecord record = new NoteRecord();
+
+ record.setRow((short)1);
+ record.setColumn((short)2);
+ record.setFlags(NoteRecord.NOTE_VISIBLE);
+ record.setShapeId((short)1026);
+ record.setAuthor("Apache Software Foundation");
+
+ NoteRecord cloned = (NoteRecord)record.clone();
+ assertEquals(record.getRow(), cloned.getRow());
+ assertEquals(record.getColumn(), cloned.getColumn());
+ assertEquals(record.getFlags(), cloned.getFlags());
+ assertEquals(record.getShapeId(), cloned.getShapeId());
+ assertEquals(record.getAuthor(), cloned.getAuthor());
+
+ //finally check that the serialized data is the same
+ byte[] src = record.serialize();
+ byte[] cln = cloned.serialize();
+ assertTrue(Arrays.equals(src, cln));
+ }
}
assertEquals(ser.length - 4, data.length);
}
+
+ public void testClone()
+ {
+ NoteStructureSubRecord record = new NoteStructureSubRecord();
+ byte[] src = record.serialize();
+
+ NoteStructureSubRecord cloned = (NoteStructureSubRecord)record.clone();
+ byte[] cln = cloned.serialize();
+
+ assertEquals(record.getRecordSize(), cloned.getRecordSize());
+ assertTrue(Arrays.equals(src, cln));
+ }
}
}\r
\r
}\r
+\r
+ /**\r
+ * Test cloning\r
+ */\r
+ public void testClone() {\r
+ String text = "Hello, World";\r
+ HSSFRichTextString str = new HSSFRichTextString(text);\r
+\r
+ TextObjectRecord obj = new TextObjectRecord();\r
+ int frLength = ( str.numFormattingRuns() + 1 ) * 8;\r
+ obj.setFormattingRunLength( (short) frLength );\r
+ obj.setTextLength( (short) str.length() );\r
+ obj.setReserved1(true);\r
+ obj.setReserved2((short)2);\r
+ obj.setReserved3((short)3);\r
+ obj.setReserved4((short)4);\r
+ obj.setReserved5((short)5);\r
+ obj.setReserved6((short)6);\r
+ obj.setReserved7((short)7);\r
+ obj.setStr( str );\r
+\r
+\r
+ TextObjectRecord cloned = (TextObjectRecord)obj.clone();\r
+ assertEquals(obj.getReserved2(), cloned.getReserved2());\r
+ assertEquals(obj.getReserved3(), cloned.getReserved3());\r
+ assertEquals(obj.getReserved4(), cloned.getReserved4());\r
+ assertEquals(obj.getReserved5(), cloned.getReserved5());\r
+ assertEquals(obj.getReserved6(), cloned.getReserved6());\r
+ assertEquals(obj.getReserved7(), cloned.getReserved7());\r
+ assertEquals(obj.getRecordSize(), cloned.getRecordSize());\r
+ assertEquals(obj.getOptions(), cloned.getOptions());\r
+ assertEquals(obj.getHorizontalTextAlignment(), cloned.getHorizontalTextAlignment());\r
+ assertEquals(obj.getFormattingRunLength(), cloned.getFormattingRunLength());\r
+ assertEquals(obj.getStr().getString(), cloned.getStr().getString());\r
+\r
+ //finally check that the serialized data is the same\r
+ byte[] src = obj.serialize();\r
+ byte[] cln = cloned.serialize();\r
+ assertTrue(Arrays.equals(src, cln));\r
+ }\r
}\r
}
-
+ /**
+ * Bug 44200: Sheet not cloneable when Note added to excel cell
+ */
+ public void test44200() throws Exception {
+ FileInputStream in = new FileInputStream(new File(cwd, "44200.xls"));
+ HSSFWorkbook wb = new HSSFWorkbook(in);
+ in.close();
+
+ wb.cloneSheet(0);
+ assertTrue("No Exceptions while cloning sheet", true);
+
+ //serialize and read again
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ wb.write(out);
+ out.close();
+
+ wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray()));
+ assertTrue("No Exceptions while reading file", true);
+
+ }
+
}