fixed bug 44200: Sheet not cloneable when Note added to excel cell
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@610855 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ae4a40d8ba
commit
ffe9ba52c1
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
<!-- Don't forget to update status.xml too! -->
|
<!-- Don't forget to update status.xml too! -->
|
||||||
<release version="3.0.2-FINAL" date="2008-??-??">
|
<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="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">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>
|
<action dev="POI-DEVELOPERS" type="fix">31795 - Support cloning of sheets with certain drawing objects on them</action>
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
<!-- Don't forget to update changes.xml too! -->
|
<!-- Don't forget to update changes.xml too! -->
|
||||||
<changes>
|
<changes>
|
||||||
<release version="3.0.2-FINAL" date="2008-??-??">
|
<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="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">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>
|
<action dev="POI-DEVELOPERS" type="fix">31795 - Support cloning of sheets with certain drawing objects on them</action>
|
||||||
|
@ -243,4 +243,15 @@ public class NoteRecord extends Record {
|
|||||||
public void setAuthor(String author){
|
public void setAuthor(String author){
|
||||||
field_5_author = 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,15 @@ public class NoteStructureSubRecord
|
|||||||
{
|
{
|
||||||
return sid;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -251,4 +251,21 @@ public class TextObjectRecord
|
|||||||
buffer.append( "[/TXO]\n" );
|
buffer.append( "[/TXO]\n" );
|
||||||
return buffer.toString();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
BIN
src/testcases/org/apache/poi/hssf/data/44200.xls
Executable file
BIN
src/testcases/org/apache/poi/hssf/data/44200.xls
Executable file
Binary file not shown.
Binary file not shown.
@ -79,4 +79,27 @@ public class TestNoteRecord
|
|||||||
System.arraycopy(ser, 4, recdata, 0, recdata.length);
|
System.arraycopy(ser, 4, recdata, 0, recdata.length);
|
||||||
assertTrue(Arrays.equals(data, recdata));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,4 +65,16 @@ public class TestNoteStructureSubRecord
|
|||||||
assertEquals(ser.length - 4, data.length);
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,4 +117,44 @@ public class TestTextObjectRecord extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test cloning
|
||||||
|
*/
|
||||||
|
public void testClone() {
|
||||||
|
String text = "Hello, World";
|
||||||
|
HSSFRichTextString str = new HSSFRichTextString(text);
|
||||||
|
|
||||||
|
TextObjectRecord obj = new TextObjectRecord();
|
||||||
|
int frLength = ( str.numFormattingRuns() + 1 ) * 8;
|
||||||
|
obj.setFormattingRunLength( (short) frLength );
|
||||||
|
obj.setTextLength( (short) str.length() );
|
||||||
|
obj.setReserved1(true);
|
||||||
|
obj.setReserved2((short)2);
|
||||||
|
obj.setReserved3((short)3);
|
||||||
|
obj.setReserved4((short)4);
|
||||||
|
obj.setReserved5((short)5);
|
||||||
|
obj.setReserved6((short)6);
|
||||||
|
obj.setReserved7((short)7);
|
||||||
|
obj.setStr( str );
|
||||||
|
|
||||||
|
|
||||||
|
TextObjectRecord cloned = (TextObjectRecord)obj.clone();
|
||||||
|
assertEquals(obj.getReserved2(), cloned.getReserved2());
|
||||||
|
assertEquals(obj.getReserved3(), cloned.getReserved3());
|
||||||
|
assertEquals(obj.getReserved4(), cloned.getReserved4());
|
||||||
|
assertEquals(obj.getReserved5(), cloned.getReserved5());
|
||||||
|
assertEquals(obj.getReserved6(), cloned.getReserved6());
|
||||||
|
assertEquals(obj.getReserved7(), cloned.getReserved7());
|
||||||
|
assertEquals(obj.getRecordSize(), cloned.getRecordSize());
|
||||||
|
assertEquals(obj.getOptions(), cloned.getOptions());
|
||||||
|
assertEquals(obj.getHorizontalTextAlignment(), cloned.getHorizontalTextAlignment());
|
||||||
|
assertEquals(obj.getFormattingRunLength(), cloned.getFormattingRunLength());
|
||||||
|
assertEquals(obj.getStr().getString(), cloned.getStr().getString());
|
||||||
|
|
||||||
|
//finally check that the serialized data is the same
|
||||||
|
byte[] src = obj.serialize();
|
||||||
|
byte[] cln = cloned.serialize();
|
||||||
|
assertTrue(Arrays.equals(src, cln));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -913,6 +913,26 @@ extends TestCase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user