From ffe9ba52c1e68a3ab1ce152c013a1381ca06bcb1 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Thu, 10 Jan 2008 18:04:38 +0000 Subject: [PATCH] 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 --- src/documentation/content/xdocs/changes.xml | 1 + src/documentation/content/xdocs/status.xml | 1 + .../apache/poi/hssf/record/NoteRecord.java | 11 +++++ .../hssf/record/NoteStructureSubRecord.java | 9 ++++ .../poi/hssf/record/TextObjectRecord.java | 17 ++++++++ .../org/apache/poi/hssf/data/44200.xls | Bin 0 -> 13824 bytes .../poi/hssf/data/TestDataValidation.xls | Bin 21504 -> 21504 bytes .../poi/hssf/record/TestNoteRecord.java | 23 ++++++++++ .../record/TestNoteStructureSubRecord.java | 12 ++++++ .../poi/hssf/record/TestTextObjectRecord.java | 40 ++++++++++++++++++ .../apache/poi/hssf/usermodel/TestBugs.java | 22 +++++++++- 11 files changed, 135 insertions(+), 1 deletion(-) create mode 100755 src/testcases/org/apache/poi/hssf/data/44200.xls diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index e77b99fee..2617fbb43 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -36,6 +36,7 @@ + 44200 - Enable cloning of sheets with notes 43008 - Add a moveCell method to HSSFRow, and deprecate setCellNum(), which didn't update things properly 43058 - Support setting row grouping on files from CR IX, which lack GutsRecords 31795 - Support cloning of sheets with certain drawing objects on them diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 3ccb4ddd1..9e93592fc 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -33,6 +33,7 @@ + 44200 - Enable cloning of sheets with notes 43008 - Add a moveCell method to HSSFRow, and deprecate setCellNum(), which didn't update things properly 43058 - Support setting row grouping on files from CR IX, which lack GutsRecords 31795 - Support cloning of sheets with certain drawing objects on them diff --git a/src/java/org/apache/poi/hssf/record/NoteRecord.java b/src/java/org/apache/poi/hssf/record/NoteRecord.java index 63c0b1d7d..a9e83806f 100644 --- a/src/java/org/apache/poi/hssf/record/NoteRecord.java +++ b/src/java/org/apache/poi/hssf/record/NoteRecord.java @@ -243,4 +243,15 @@ public class NoteRecord extends Record { 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; + } + } diff --git a/src/java/org/apache/poi/hssf/record/NoteStructureSubRecord.java b/src/java/org/apache/poi/hssf/record/NoteStructureSubRecord.java index 6ad3f8eb6..c99f29be3 100644 --- a/src/java/org/apache/poi/hssf/record/NoteStructureSubRecord.java +++ b/src/java/org/apache/poi/hssf/record/NoteStructureSubRecord.java @@ -125,6 +125,15 @@ public class NoteStructureSubRecord { 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; + } + } diff --git a/src/java/org/apache/poi/hssf/record/TextObjectRecord.java b/src/java/org/apache/poi/hssf/record/TextObjectRecord.java index 97685c9ca..c8f6669b0 100644 --- a/src/java/org/apache/poi/hssf/record/TextObjectRecord.java +++ b/src/java/org/apache/poi/hssf/record/TextObjectRecord.java @@ -251,4 +251,21 @@ public class TextObjectRecord 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; + } + } diff --git a/src/testcases/org/apache/poi/hssf/data/44200.xls b/src/testcases/org/apache/poi/hssf/data/44200.xls new file mode 100755 index 0000000000000000000000000000000000000000..691afedb806ec66c4667f4640fb7a2ac417bd83d GIT binary patch literal 13824 zcmeHOYiv|S6#njZ+iq#0+l8VaEbF$0cKfhAgvJ89STGtzvD5%kQlTtDC@i+sRAY22 z;2$x;VB#MP4-rKaUkN5k(vtWCO+aHpjGB<5(ZopNVl+ZT*6*CVx7~$yttKRjGn+Fr z_sp3&XTF)ebI;tlpM6@=zxSPqXK-1Vha6l=79cN;Z!tf?x%PtP$)sF5>GjN$Wx{_5 zfdUT)GA|crOHbr~+{bJVa0V{C?LNjB_=ePi%_stvM<0rH1n!DG-X422aJ9p2YQri^ zZ0O^}o6DSqUF44892Blk%`Q%eOWU4ddTJzC?^;m^=T+Px+*h5?H!%^uNL!Q-4o$C<8My8^954l6z z<#$g)F0KQD<-xM*va-6?%7&H-=c1+3@4k`$;z=3hE1IHfR%QwXk&nrPLbY|7?eJQf znhFnsmrGsNT1s>_LYNM;iYcLhV_E95r9v4kl?^FIuqH^mTPq^1)KZH|{#Z4=UMP@W zDHO=45k@s`%~WRhAXA^3mZmZs9#lFDRYZDFsZ)PIuTxo7r`Mc~{hX6l5N`y6{Idj5 zMr+FWt3xYl&_KklENNkh-#s6%z@M$^3N#^#HCUOYkwzTAl%X4`r48Avu*+>*7U5Nt z|8+CjElO|jVZ4S}umpoa1VTgLlTAWwYfv0B+X!l_Hog)^RL1YF#z9QwFxEJ8r>0>b z-(u%w=14BmTH|;3;C0N)Ze%)$*-Rbm`|t*b5l&5tbfahD5N=L0TIODw-7@nAOy|r? z8Q+g_ap0#&eRAmc;Wk^~K$qj*aJQia0bK7tc*TXvs>qjVtF%9R=mWKqy>n;3<2T%+onzTE433;Ytv96CY7i3-uNqzur?95Ct zzTlA9y*i7NVtwKyC1`mOGSW)eZ4ERZOPh^GF$ucd$^HX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