From: Andrew C. Oliver Date: Thu, 5 Sep 2002 00:26:28 +0000 (+0000) Subject: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11721 clone for sheets X-Git-Tag: REL_1_10~173 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=744ffde73d282e8254b70d76aa0c1e400872563f;p=poi.git http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11721 clone for sheets PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352836 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/model/Sheet.java b/src/java/org/apache/poi/hssf/model/Sheet.java index 0fc37939a8..ff1ebab8e9 100644 --- a/src/java/org/apache/poi/hssf/model/Sheet.java +++ b/src/java/org/apache/poi/hssf/model/Sheet.java @@ -80,6 +80,7 @@ import org.apache.poi.hssf.record * @author Andrew C. Oliver (acoliver at apache dot org) * @author Glen Stampoultzis (glens at apache.org) * @author Shawn Laubach (laubach at acm.org) Just Gridlines, Headers, Footers, and PrintSetup + * @author Jason Height (jheight at chariot dot net dot au) Clone support * * @see org.apache.poi.hssf.model.Workbook * @see org.apache.poi.hssf.usermodel.HSSFSheet @@ -271,6 +272,46 @@ public class Sheet return retval; } + /** + * Clones the low level records of this sheet and returns the new sheet instance. + */ + public Sheet cloneSheet() + { + ArrayList clonedRecords = new ArrayList(this.records.size()); + for (int i=0; i * REFERENCE: PG 289 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -358,4 +359,15 @@ public class BOFRecord { return this.sid; } + + public Object clone() { + BOFRecord rec = new BOFRecord(); + rec.field_1_version = field_1_version; + rec.field_2_type = field_2_type; + rec.field_3_build = field_3_build; + rec.field_4_year = field_4_year; + rec.field_5_history = field_5_history; + rec.field_6_rversion = field_6_rversion; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/BarRecord.java b/src/java/org/apache/poi/hssf/record/BarRecord.java index 89df90b74b..15af139713 100644 --- a/src/java/org/apache/poi/hssf/record/BarRecord.java +++ b/src/java/org/apache/poi/hssf/record/BarRecord.java @@ -190,6 +190,16 @@ public class BarRecord return this.sid; } + public Object clone() { + BarRecord rec = new BarRecord(); + + rec.field_1_barSpace = field_1_barSpace; + rec.field_2_categorySpace = field_2_categorySpace; + rec.field_3_formatFlags = field_3_formatFlags; + + return rec; + } + /** * Get the bar space field for the Bar record. diff --git a/src/java/org/apache/poi/hssf/record/BlankRecord.java b/src/java/org/apache/poi/hssf/record/BlankRecord.java index 88213623b8..b2889bfa58 100644 --- a/src/java/org/apache/poi/hssf/record/BlankRecord.java +++ b/src/java/org/apache/poi/hssf/record/BlankRecord.java @@ -67,6 +67,7 @@ import org.apache.poi.util.LittleEndian; * Description: Represents a column in a row with no value but with styling.

* REFERENCE: PG 287 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -349,4 +350,12 @@ public class BlankRecord } return false; } + + public Object clone() { + BlankRecord rec = new BlankRecord(); + rec.field_1_row = field_1_row; + rec.field_2_col = field_2_col; + rec.field_3_xf = field_3_xf; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/BoolErrRecord.java b/src/java/org/apache/poi/hssf/record/BoolErrRecord.java index 78f1cd0229..fff9cdd448 100644 --- a/src/java/org/apache/poi/hssf/record/BoolErrRecord.java +++ b/src/java/org/apache/poi/hssf/record/BoolErrRecord.java @@ -66,6 +66,7 @@ import org.apache.poi.util.LittleEndian; * Creates new BoolErrRecord.

* REFERENCE: PG ??? Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Michael P. Harhen + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -413,4 +414,14 @@ public class BoolErrRecord } return false; } + + public Object clone() { + BoolErrRecord rec = new BoolErrRecord(); + rec.field_1_row = field_1_row; + rec.field_2_column = field_2_column; + rec.field_3_xf_index = field_3_xf_index; + rec.field_4_bBoolErr = field_4_bBoolErr; + rec.field_5_fError = field_5_fError; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/CalcCountRecord.java b/src/java/org/apache/poi/hssf/record/CalcCountRecord.java index bee2522a02..a67d464db7 100644 --- a/src/java/org/apache/poi/hssf/record/CalcCountRecord.java +++ b/src/java/org/apache/poi/hssf/record/CalcCountRecord.java @@ -66,6 +66,7 @@ import org.apache.poi.util.LittleEndian; * loop in the event the formulas are not independant.

* REFERENCE: PG 292 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre * @see org.apache.poi.hssf.record.CalcModeRecord */ @@ -169,4 +170,10 @@ public class CalcCountRecord { return this.sid; } + + public Object clone() { + CalcCountRecord rec = new CalcCountRecord(); + rec.field_1_iterations = field_1_iterations; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/CalcModeRecord.java b/src/java/org/apache/poi/hssf/record/CalcModeRecord.java index 46ab942318..2881114de2 100644 --- a/src/java/org/apache/poi/hssf/record/CalcModeRecord.java +++ b/src/java/org/apache/poi/hssf/record/CalcModeRecord.java @@ -64,6 +64,7 @@ import org.apache.poi.util.LittleEndian; * except for tables.

* REFERENCE: PG 292 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre * @see org.apache.poi.hssf.record.CalcCountRecord */ @@ -194,4 +195,10 @@ public class CalcModeRecord { return this.sid; } + + public Object clone() { + CalcModeRecord rec = new CalcModeRecord(); + rec.field_1_calcmode = field_1_calcmode; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/CategorySeriesAxisRecord.java b/src/java/org/apache/poi/hssf/record/CategorySeriesAxisRecord.java index 38c853a8e0..9459ffb93c 100644 --- a/src/java/org/apache/poi/hssf/record/CategorySeriesAxisRecord.java +++ b/src/java/org/apache/poi/hssf/record/CategorySeriesAxisRecord.java @@ -195,6 +195,17 @@ public class CategorySeriesAxisRecord return this.sid; } + public Object clone() { + CategorySeriesAxisRecord rec = new CategorySeriesAxisRecord(); + + rec.field_1_crossingPoint = field_1_crossingPoint; + rec.field_2_labelFrequency = field_2_labelFrequency; + rec.field_3_tickMarkFrequency = field_3_tickMarkFrequency; + rec.field_4_options = field_4_options; + + return rec; + } + /** * Get the crossing point field for the CategorySeriesAxis record. diff --git a/src/java/org/apache/poi/hssf/record/CellValueRecordInterface.java b/src/java/org/apache/poi/hssf/record/CellValueRecordInterface.java index 91759df6d2..500d1891cc 100644 --- a/src/java/org/apache/poi/hssf/record/CellValueRecordInterface.java +++ b/src/java/org/apache/poi/hssf/record/CellValueRecordInterface.java @@ -66,6 +66,7 @@ package org.apache.poi.hssf.record; * them. * * @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * * @see org.apache.poi.hssf.model.Sheet * @see org.apache.poi.hssf.record.Record @@ -138,4 +139,6 @@ public interface CellValueRecordInterface */ public boolean isEqual(CellValueRecordInterface i); + + public Object clone(); } diff --git a/src/java/org/apache/poi/hssf/record/ChartRecord.java b/src/java/org/apache/poi/hssf/record/ChartRecord.java index 132e91b3b2..87a876884c 100644 --- a/src/java/org/apache/poi/hssf/record/ChartRecord.java +++ b/src/java/org/apache/poi/hssf/record/ChartRecord.java @@ -189,6 +189,17 @@ public class ChartRecord return this.sid; } + public Object clone() { + ChartRecord rec = new ChartRecord(); + + rec.field_1_x = field_1_x; + rec.field_2_y = field_2_y; + rec.field_3_width = field_3_width; + rec.field_4_height = field_4_height; + + return rec; + } + /** * Get the x field for the Chart record. diff --git a/src/java/org/apache/poi/hssf/record/DatRecord.java b/src/java/org/apache/poi/hssf/record/DatRecord.java index 52c283d3a8..9203faae83 100644 --- a/src/java/org/apache/poi/hssf/record/DatRecord.java +++ b/src/java/org/apache/poi/hssf/record/DatRecord.java @@ -173,6 +173,14 @@ public class DatRecord return this.sid; } + public Object clone() { + DatRecord rec = new DatRecord(); + + rec.field_1_options = field_1_options; + + return rec; + } + /** * Get the options field for the Dat record. diff --git a/src/java/org/apache/poi/hssf/record/DataFormatRecord.java b/src/java/org/apache/poi/hssf/record/DataFormatRecord.java index ccbf0b8bcd..ddd6a558dd 100644 --- a/src/java/org/apache/poi/hssf/record/DataFormatRecord.java +++ b/src/java/org/apache/poi/hssf/record/DataFormatRecord.java @@ -191,6 +191,17 @@ public class DataFormatRecord return this.sid; } + public Object clone() { + DataFormatRecord rec = new DataFormatRecord(); + + rec.field_1_pointNumber = field_1_pointNumber; + rec.field_2_seriesIndex = field_2_seriesIndex; + rec.field_3_seriesNumber = field_3_seriesNumber; + rec.field_4_formatFlags = field_4_formatFlags; + + return rec; + } + /** * Get the point number field for the DataFormat record. diff --git a/src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java b/src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java index a5a5234de0..8d85b78599 100644 --- a/src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java +++ b/src/java/org/apache/poi/hssf/record/DefaultColWidthRecord.java @@ -63,6 +63,7 @@ import org.apache.poi.util.LittleEndian; * width set.

* REFERENCE: PG 302 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -165,4 +166,10 @@ public class DefaultColWidthRecord { return this.sid; } + + public Object clone() { + DefaultColWidthRecord rec = new DefaultColWidthRecord(); + rec.field_1_col_width = field_1_col_width; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/DefaultDataLabelTextPropertiesRecord.java b/src/java/org/apache/poi/hssf/record/DefaultDataLabelTextPropertiesRecord.java index 08c9a9a40c..0074ba4d94 100644 --- a/src/java/org/apache/poi/hssf/record/DefaultDataLabelTextPropertiesRecord.java +++ b/src/java/org/apache/poi/hssf/record/DefaultDataLabelTextPropertiesRecord.java @@ -168,6 +168,14 @@ public class DefaultDataLabelTextPropertiesRecord return this.sid; } + public Object clone() { + DefaultDataLabelTextPropertiesRecord rec = new DefaultDataLabelTextPropertiesRecord(); + + rec.field_1_categoryDataType = field_1_categoryDataType; + + return rec; + } + /** * Get the category data type field for the DefaultDataLabelTextProperties record. diff --git a/src/java/org/apache/poi/hssf/record/DefaultRowHeightRecord.java b/src/java/org/apache/poi/hssf/record/DefaultRowHeightRecord.java index 4486373f41..5431a2f13d 100644 --- a/src/java/org/apache/poi/hssf/record/DefaultRowHeightRecord.java +++ b/src/java/org/apache/poi/hssf/record/DefaultRowHeightRecord.java @@ -63,6 +63,7 @@ import org.apache.poi.util.LittleEndian; * heights. * REFERENCE: PG 301 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -190,4 +191,11 @@ public class DefaultRowHeightRecord { return this.sid; } + + public Object clone() { + DefaultRowHeightRecord rec = new DefaultRowHeightRecord(); + rec.field_1_option_flags = field_1_option_flags; + rec.field_2_row_height = field_2_row_height; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/DeltaRecord.java b/src/java/org/apache/poi/hssf/record/DeltaRecord.java index ee5d52e443..56555edc46 100644 --- a/src/java/org/apache/poi/hssf/record/DeltaRecord.java +++ b/src/java/org/apache/poi/hssf/record/DeltaRecord.java @@ -62,6 +62,7 @@ import org.apache.poi.util.LittleEndian; * Description: controls the accuracy of the calculations

* REFERENCE: PG 303 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -167,4 +168,10 @@ public class DeltaRecord { return this.sid; } + + public Object clone() { + DeltaRecord rec = new DeltaRecord(); + rec.field_1_max_change = field_1_max_change; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/DimensionsRecord.java b/src/java/org/apache/poi/hssf/record/DimensionsRecord.java index bbc034df43..2e3354d5e8 100644 --- a/src/java/org/apache/poi/hssf/record/DimensionsRecord.java +++ b/src/java/org/apache/poi/hssf/record/DimensionsRecord.java @@ -63,6 +63,7 @@ import org.apache.poi.util.LittleEndian; * of a sheet.

* REFERENCE: PG 303 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -244,4 +245,14 @@ public class DimensionsRecord { return this.sid; } + + public Object clone() { + DimensionsRecord rec = new DimensionsRecord(); + rec.field_1_first_row = field_1_first_row; + rec.field_2_last_row = field_2_last_row; + rec.field_3_first_col = field_3_first_col; + rec.field_4_last_col = field_4_last_col; + rec.field_5_zero = field_5_zero; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/EOFRecord.java b/src/java/org/apache/poi/hssf/record/EOFRecord.java index 80ea80c954..e9e683ee86 100644 --- a/src/java/org/apache/poi/hssf/record/EOFRecord.java +++ b/src/java/org/apache/poi/hssf/record/EOFRecord.java @@ -64,6 +64,7 @@ import org.apache.poi.util.LittleEndian; * HSSF File

* REFERENCE: PG 307 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -141,4 +142,9 @@ public class EOFRecord { return this.sid; } + + public Object clone() { + EOFRecord rec = new EOFRecord(); + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/FontBasisRecord.java b/src/java/org/apache/poi/hssf/record/FontBasisRecord.java index 1a08544bd9..4fce96de14 100644 --- a/src/java/org/apache/poi/hssf/record/FontBasisRecord.java +++ b/src/java/org/apache/poi/hssf/record/FontBasisRecord.java @@ -197,6 +197,18 @@ public class FontBasisRecord return this.sid; } + public Object clone() { + FontBasisRecord rec = new FontBasisRecord(); + + rec.field_1_xBasis = field_1_xBasis; + rec.field_2_yBasis = field_2_yBasis; + rec.field_3_heightBasis = field_3_heightBasis; + rec.field_4_scale = field_4_scale; + rec.field_5_indexToFontTable = field_5_indexToFontTable; + + return rec; + } + /** * Get the x Basis field for the FontBasis record. diff --git a/src/java/org/apache/poi/hssf/record/FontIndexRecord.java b/src/java/org/apache/poi/hssf/record/FontIndexRecord.java index 2615d027c7..f06d9af629 100644 --- a/src/java/org/apache/poi/hssf/record/FontIndexRecord.java +++ b/src/java/org/apache/poi/hssf/record/FontIndexRecord.java @@ -165,6 +165,14 @@ public class FontIndexRecord return this.sid; } + public Object clone() { + FontIndexRecord rec = new FontIndexRecord(); + + rec.field_1_fontIndex = field_1_fontIndex; + + return rec; + } + /** * Get the font index field for the FontIndex record. diff --git a/src/java/org/apache/poi/hssf/record/FooterRecord.java b/src/java/org/apache/poi/hssf/record/FooterRecord.java index 10cf9ab12c..cd3abb2e29 100644 --- a/src/java/org/apache/poi/hssf/record/FooterRecord.java +++ b/src/java/org/apache/poi/hssf/record/FooterRecord.java @@ -64,6 +64,7 @@ import org.apache.poi.util.StringUtil; * REFERENCE: PG 317 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) * @author Shawn Laubach (laubach@acm.org) Modified 3/14/02 + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -218,4 +219,11 @@ public class FooterRecord { return this.sid; } + + public Object clone() { + FooterRecord rec = new FooterRecord(); + rec.field_1_footer_len = field_1_footer_len; + rec.field_2_footer = field_2_footer; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/FormulaRecord.java b/src/java/org/apache/poi/hssf/record/FormulaRecord.java index 836bd08d97..f790b605a0 100644 --- a/src/java/org/apache/poi/hssf/record/FormulaRecord.java +++ b/src/java/org/apache/poi/hssf/record/FormulaRecord.java @@ -70,6 +70,7 @@ import org.apache.poi.hssf.record.formula.*; * Formula Record. * REFERENCE: PG 317/444 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -568,4 +569,25 @@ public class FormulaRecord return buffer.toString(); } + public Object clone() { + FormulaRecord rec = new FormulaRecord(); + rec.field_1_row = field_1_row; + rec.field_2_column = field_2_column; + rec.field_3_xf = field_3_xf; + rec.field_4_value = field_4_value; + rec.field_5_options = field_5_options; + rec.field_6_zero = field_6_zero; + rec.field_7_expression_len = field_7_expression_len; + rec.field_8_parsed_expr = new Stack(); + int size = 0; + if (field_8_parsed_expr != null) + size = field_8_parsed_expr.size(); + for (int i=0; i< size; i++) { + Ptg ptg = (Ptg)((Ptg)field_8_parsed_expr.get(i)).clone(); + rec.field_8_parsed_expr.set(i, ptg); + } + rec.all_data = all_data; + return rec; + } + } diff --git a/src/java/org/apache/poi/hssf/record/FrameRecord.java b/src/java/org/apache/poi/hssf/record/FrameRecord.java index ea48cdc97c..94893f2530 100644 --- a/src/java/org/apache/poi/hssf/record/FrameRecord.java +++ b/src/java/org/apache/poi/hssf/record/FrameRecord.java @@ -179,6 +179,15 @@ public class FrameRecord return this.sid; } + public Object clone() { + FrameRecord rec = new FrameRecord(); + + rec.field_1_borderType = field_1_borderType; + rec.field_2_options = field_2_options; + + return rec; + } + /** * Get the border type field for the Frame record. diff --git a/src/java/org/apache/poi/hssf/record/GridsetRecord.java b/src/java/org/apache/poi/hssf/record/GridsetRecord.java index b4a3faba9d..aaf1a66076 100644 --- a/src/java/org/apache/poi/hssf/record/GridsetRecord.java +++ b/src/java/org/apache/poi/hssf/record/GridsetRecord.java @@ -65,6 +65,7 @@ import org.apache.poi.util.LittleEndian; * * @author Andrew C. Oliver (acoliver at apache dot org) * @author Glen Stampoultzis (glens at apache.org) + * @author Jason Height (jheight at chariot dot net dot au) * * @version 2.0-pre */ @@ -176,4 +177,10 @@ public class GridsetRecord { return this.sid; } + + public Object clone() { + GridsetRecord rec = new GridsetRecord(); + rec.field_1_gridset_flag = field_1_gridset_flag; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/GutsRecord.java b/src/java/org/apache/poi/hssf/record/GutsRecord.java index 64e770ddc5..b4dad616cb 100644 --- a/src/java/org/apache/poi/hssf/record/GutsRecord.java +++ b/src/java/org/apache/poi/hssf/record/GutsRecord.java @@ -62,6 +62,7 @@ import org.apache.poi.util.LittleEndian; * Description: Row/column gutter sizes

* REFERENCE: PG 320 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -246,4 +247,13 @@ public class GutsRecord { return this.sid; } + + public Object clone() { + GutsRecord rec = new GutsRecord(); + rec.field_1_left_row_gutter = field_1_left_row_gutter; + rec.field_2_top_col_gutter = field_2_top_col_gutter; + rec.field_3_row_level_max = field_3_row_level_max; + rec.field_4_col_level_max = field_4_col_level_max; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/HCenterRecord.java b/src/java/org/apache/poi/hssf/record/HCenterRecord.java index 2797c4cbff..a657f7561e 100644 --- a/src/java/org/apache/poi/hssf/record/HCenterRecord.java +++ b/src/java/org/apache/poi/hssf/record/HCenterRecord.java @@ -62,6 +62,7 @@ import org.apache.poi.util.LittleEndian; * Description: whether to center between horizontal margins

* REFERENCE: PG 320 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -170,4 +171,10 @@ public class HCenterRecord { return this.sid; } + + public Object clone() { + HCenterRecord rec = new HCenterRecord(); + rec.field_1_hcenter = field_1_hcenter; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/HeaderRecord.java b/src/java/org/apache/poi/hssf/record/HeaderRecord.java index 07413df7fa..897af1273a 100644 --- a/src/java/org/apache/poi/hssf/record/HeaderRecord.java +++ b/src/java/org/apache/poi/hssf/record/HeaderRecord.java @@ -64,6 +64,7 @@ import org.apache.poi.util.StringUtil; * REFERENCE: PG 321 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) * @author Shawn Laubach (laubach@acm.org) Modified 3/14/02 + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -220,4 +221,11 @@ public class HeaderRecord { return this.sid; } + + public Object clone() { + HeaderRecord rec = new HeaderRecord(); + rec.field_1_header_len = field_1_header_len; + rec.field_2_header = field_2_header; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/IndexRecord.java b/src/java/org/apache/poi/hssf/record/IndexRecord.java index a90a3bedc6..7971eadbed 100644 --- a/src/java/org/apache/poi/hssf/record/IndexRecord.java +++ b/src/java/org/apache/poi/hssf/record/IndexRecord.java @@ -65,6 +65,7 @@ import org.apache.poi.util.LittleEndian; * NOT USED IN THIS RELEASE * REFERENCE: PG 323 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -225,4 +226,15 @@ public class IndexRecord { return this.sid; } + + public Object clone() { + IndexRecord rec = new IndexRecord(); + rec.field_1_zero = field_1_zero; + rec.field_2_first_row = field_2_first_row; + rec.field_3_last_row_add1 = field_3_last_row_add1; + rec.field_4_zero = field_4_zero; + rec.field_5_dbcells = new IntList(); + rec.field_5_dbcells.addAll(field_5_dbcells); + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/IterationRecord.java b/src/java/org/apache/poi/hssf/record/IterationRecord.java index 8e0717ebf8..4104ddbc4e 100644 --- a/src/java/org/apache/poi/hssf/record/IterationRecord.java +++ b/src/java/org/apache/poi/hssf/record/IterationRecord.java @@ -65,6 +65,7 @@ import org.apache.poi.util.LittleEndian; * a formula!)

* REFERENCE: PG 325 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -174,4 +175,10 @@ public class IterationRecord { return this.sid; } + + public Object clone() { + IterationRecord rec = new IterationRecord(); + rec.field_1_iteration = field_1_iteration; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/LabelRecord.java b/src/java/org/apache/poi/hssf/record/LabelRecord.java index bfb231391e..9a7d73dd2e 100644 --- a/src/java/org/apache/poi/hssf/record/LabelRecord.java +++ b/src/java/org/apache/poi/hssf/record/LabelRecord.java @@ -68,6 +68,7 @@ import org.apache.poi.util.StringUtil; * use this (except to read), use LabelSST instead

* REFERENCE: PG 325 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre * @see org.apache.poi.hssf.record.LabelSSTRecord */ @@ -314,4 +315,15 @@ public class LabelRecord public void setXFIndex(short xf) { } + + public Object clone() { + LabelRecord rec = new LabelRecord(); + rec.field_1_row = field_1_row; + rec.field_2_column = field_2_column; + rec.field_3_xf_index = field_3_xf_index; + rec.field_4_string_len = field_4_string_len; + rec.field_5_unicode_flag = field_5_unicode_flag; + rec.field_6_value = field_6_value; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/LabelSSTRecord.java b/src/java/org/apache/poi/hssf/record/LabelSSTRecord.java index cfd4115b85..187e80ef90 100644 --- a/src/java/org/apache/poi/hssf/record/LabelSSTRecord.java +++ b/src/java/org/apache/poi/hssf/record/LabelSSTRecord.java @@ -63,6 +63,7 @@ import org.apache.poi.util.LittleEndian; * value.

* REFERENCE: PG 325 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -331,4 +332,13 @@ public class LabelSSTRecord } return false; } + + public Object clone() { + LabelSSTRecord rec = new LabelSSTRecord(); + rec.field_1_row = field_1_row; + rec.field_2_column = field_2_column; + rec.field_3_xf_index = field_3_xf_index; + rec.field_4_sst_index = field_4_sst_index; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/LegendRecord.java b/src/java/org/apache/poi/hssf/record/LegendRecord.java index 7026293bda..32a0df01a5 100644 --- a/src/java/org/apache/poi/hssf/record/LegendRecord.java +++ b/src/java/org/apache/poi/hssf/record/LegendRecord.java @@ -234,6 +234,20 @@ public class LegendRecord return this.sid; } + public Object clone() { + LegendRecord rec = new LegendRecord(); + + rec.field_1_xAxisUpperLeft = field_1_xAxisUpperLeft; + rec.field_2_yAxisUpperLeft = field_2_yAxisUpperLeft; + rec.field_3_xSize = field_3_xSize; + rec.field_4_ySize = field_4_ySize; + rec.field_5_type = field_5_type; + rec.field_6_spacing = field_6_spacing; + rec.field_7_options = field_7_options; + + return rec; + } + /** * Get the x axis upper left field for the Legend record. diff --git a/src/java/org/apache/poi/hssf/record/LineFormatRecord.java b/src/java/org/apache/poi/hssf/record/LineFormatRecord.java index cad6dd1454..3bbec3859d 100644 --- a/src/java/org/apache/poi/hssf/record/LineFormatRecord.java +++ b/src/java/org/apache/poi/hssf/record/LineFormatRecord.java @@ -216,6 +216,18 @@ public class LineFormatRecord return this.sid; } + public Object clone() { + LineFormatRecord rec = new LineFormatRecord(); + + rec.field_1_lineColor = field_1_lineColor; + rec.field_2_linePattern = field_2_linePattern; + rec.field_3_weight = field_3_weight; + rec.field_4_format = field_4_format; + rec.field_5_colourPaletteIndex = field_5_colourPaletteIndex; + + return rec; + } + /** * Get the line color field for the LineFormat record. diff --git a/src/java/org/apache/poi/hssf/record/LinkedDataRecord.java b/src/java/org/apache/poi/hssf/record/LinkedDataRecord.java index d34f4a0f20..45118d7bc4 100644 --- a/src/java/org/apache/poi/hssf/record/LinkedDataRecord.java +++ b/src/java/org/apache/poi/hssf/record/LinkedDataRecord.java @@ -207,6 +207,18 @@ public class LinkedDataRecord return this.sid; } + public Object clone() { + LinkedDataRecord rec = new LinkedDataRecord(); + + rec.field_1_linkType = field_1_linkType; + rec.field_2_referenceType = field_2_referenceType; + rec.field_3_options = field_3_options; + rec.field_4_indexNumberFmtRecord = field_4_indexNumberFmtRecord; + rec.field_5_formulaOfLink = field_5_formulaOfLink; + + return rec; + } + /** * Get the link type field for the LinkedData record. diff --git a/src/java/org/apache/poi/hssf/record/NumberFormatIndexRecord.java b/src/java/org/apache/poi/hssf/record/NumberFormatIndexRecord.java index 74ec663bc3..eb5c9bfb55 100644 --- a/src/java/org/apache/poi/hssf/record/NumberFormatIndexRecord.java +++ b/src/java/org/apache/poi/hssf/record/NumberFormatIndexRecord.java @@ -165,6 +165,14 @@ public class NumberFormatIndexRecord return this.sid; } + public Object clone() { + NumberFormatIndexRecord rec = new NumberFormatIndexRecord(); + + rec.field_1_formatIndex = field_1_formatIndex; + + return rec; + } + /** * Get the format index field for the NumberFormatIndex record. diff --git a/src/java/org/apache/poi/hssf/record/NumberRecord.java b/src/java/org/apache/poi/hssf/record/NumberRecord.java index 9aeef7feb7..7b1b8092e5 100644 --- a/src/java/org/apache/poi/hssf/record/NumberRecord.java +++ b/src/java/org/apache/poi/hssf/record/NumberRecord.java @@ -67,6 +67,7 @@ import org.apache.poi.hssf.record.Record; * Contains a numeric cell value.

* REFERENCE: PG 334 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -355,4 +356,13 @@ public class NumberRecord } return false; } + + public Object clone() { + NumberRecord rec = new NumberRecord(); + rec.field_1_row = field_1_row; + rec.field_2_col = field_2_col; + rec.field_3_xf = field_3_xf; + rec.field_4_value = field_4_value; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/ObjectLinkRecord.java b/src/java/org/apache/poi/hssf/record/ObjectLinkRecord.java index 653772eb34..07da0a220e 100644 --- a/src/java/org/apache/poi/hssf/record/ObjectLinkRecord.java +++ b/src/java/org/apache/poi/hssf/record/ObjectLinkRecord.java @@ -186,6 +186,16 @@ public class ObjectLinkRecord return this.sid; } + public Object clone() { + ObjectLinkRecord rec = new ObjectLinkRecord(); + + rec.field_1_anchorId = field_1_anchorId; + rec.field_2_link1 = field_2_link1; + rec.field_3_link2 = field_3_link2; + + return rec; + } + /** * Get the anchor id field for the ObjectLink record. diff --git a/src/java/org/apache/poi/hssf/record/PlotAreaRecord.java b/src/java/org/apache/poi/hssf/record/PlotAreaRecord.java index 3b4854d116..0aa312dad4 100644 --- a/src/java/org/apache/poi/hssf/record/PlotAreaRecord.java +++ b/src/java/org/apache/poi/hssf/record/PlotAreaRecord.java @@ -157,6 +157,13 @@ public class PlotAreaRecord return this.sid; } + public Object clone() { + PlotAreaRecord rec = new PlotAreaRecord(); + + + return rec; + } + } // END OF CLASS diff --git a/src/java/org/apache/poi/hssf/record/PlotGrowthRecord.java b/src/java/org/apache/poi/hssf/record/PlotGrowthRecord.java index 547f8687dd..77ba0e6614 100644 --- a/src/java/org/apache/poi/hssf/record/PlotGrowthRecord.java +++ b/src/java/org/apache/poi/hssf/record/PlotGrowthRecord.java @@ -173,6 +173,15 @@ public class PlotGrowthRecord return this.sid; } + public Object clone() { + PlotGrowthRecord rec = new PlotGrowthRecord(); + + rec.field_1_horizontalScale = field_1_horizontalScale; + rec.field_2_verticalScale = field_2_verticalScale; + + return rec; + } + /** * Get the horizontalScale field for the PlotGrowth record. diff --git a/src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java b/src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java index 1a2b758579..1b25aafa31 100644 --- a/src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java +++ b/src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java @@ -62,6 +62,7 @@ import org.apache.poi.util.LittleEndian; * Description: whether to print the gridlines when you enjoy you spreadsheet on paper.

* REFERENCE: PG 373 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -173,4 +174,10 @@ public class PrintGridlinesRecord { return this.sid; } + + public Object clone() { + PrintGridlinesRecord rec = new PrintGridlinesRecord(); + rec.field_1_print_gridlines = field_1_print_gridlines; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java b/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java index d471b01b20..390d3dc60c 100644 --- a/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java +++ b/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java @@ -63,6 +63,7 @@ import org.apache.poi.util.LittleEndian; * enjoy your spreadsheet in the physical form.

* REFERENCE: PG 373 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -171,4 +172,10 @@ public class PrintHeadersRecord { return this.sid; } + + public Object clone() { + PrintHeadersRecord rec = new PrintHeadersRecord(); + rec.field_1_print_headers = field_1_print_headers; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/PrintSetupRecord.java b/src/java/org/apache/poi/hssf/record/PrintSetupRecord.java index 8bbe1986ee..6ebdf589a2 100644 --- a/src/java/org/apache/poi/hssf/record/PrintSetupRecord.java +++ b/src/java/org/apache/poi/hssf/record/PrintSetupRecord.java @@ -63,6 +63,7 @@ import org.apache.poi.util.BitField; * Description: Stores print setup options -- bogus for HSSF (and marked as such)

* REFERENCE: PG 385 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -423,4 +424,20 @@ public class PrintSetupRecord { return this.sid; } + + public Object clone() { + PrintSetupRecord rec = new PrintSetupRecord(); + rec.field_1_paper_size = field_1_paper_size; + rec.field_2_scale = field_2_scale; + rec.field_3_page_start = field_3_page_start; + rec.field_4_fit_width = field_4_fit_width; + rec.field_5_fit_height = field_5_fit_height; + rec.field_6_options = field_6_options; + rec.field_7_hresolution = field_7_hresolution; + rec.field_8_vresolution = field_8_vresolution; + rec.field_9_headermargin = field_9_headermargin; + rec.field_10_footermargin = field_10_footermargin; + rec.field_11_copies = field_11_copies; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/RKRecord.java b/src/java/org/apache/poi/hssf/record/RKRecord.java index 917a7774d0..87f0614038 100644 --- a/src/java/org/apache/poi/hssf/record/RKRecord.java +++ b/src/java/org/apache/poi/hssf/record/RKRecord.java @@ -71,6 +71,7 @@ import org.apache.poi.hssf.util.RKUtil; * * REFERENCE: PG 376 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre * @see org.apache.poi.hssf.record.NumberRecord */ @@ -339,4 +340,13 @@ public class RKRecord public void setXFIndex(short xf) { } + + public Object clone() { + RKRecord rec = new RKRecord(); + rec.field_1_row = field_1_row; + rec.field_2_col = field_2_col; + rec.field_3_xf_index = field_3_xf_index; + rec.field_4_rk_number = field_4_rk_number; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/Record.java b/src/java/org/apache/poi/hssf/record/Record.java index 867f61f687..f06f55efbb 100644 --- a/src/java/org/apache/poi/hssf/record/Record.java +++ b/src/java/org/apache/poi/hssf/record/Record.java @@ -63,6 +63,7 @@ package org.apache.poi.hssf.record; * Company: * @author Andrew C. Oliver * @author Marc Johnson (mjohnson at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -241,4 +242,8 @@ public abstract class Record */ public abstract short getSid(); + + public Object clone() { + throw new RuntimeException("The class "+getClass().getName()+" needs to define a clone method"); + } } diff --git a/src/java/org/apache/poi/hssf/record/RefModeRecord.java b/src/java/org/apache/poi/hssf/record/RefModeRecord.java index 438397a4f6..acf39f66b9 100644 --- a/src/java/org/apache/poi/hssf/record/RefModeRecord.java +++ b/src/java/org/apache/poi/hssf/record/RefModeRecord.java @@ -62,6 +62,7 @@ import org.apache.poi.util.LittleEndian; * Description: Describes which reference mode to use

* REFERENCE: PG 376 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -170,4 +171,10 @@ public class RefModeRecord { return this.sid; } + + public Object clone() { + RefModeRecord rec = new RefModeRecord(); + rec.field_1_mode = field_1_mode; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/RowRecord.java b/src/java/org/apache/poi/hssf/record/RowRecord.java index 5c693e28df..0d78dc7038 100644 --- a/src/java/org/apache/poi/hssf/record/RowRecord.java +++ b/src/java/org/apache/poi/hssf/record/RowRecord.java @@ -63,6 +63,7 @@ import org.apache.poi.util.LittleEndian; * Description: stores the row information for the sheet.

* REFERENCE: PG 379 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -512,4 +513,17 @@ public class RowRecord } return false; } + + public Object clone() { + RowRecord rec = new RowRecord(); + rec.field_1_row_number = field_1_row_number; + rec.field_2_first_col = field_2_first_col; + rec.field_3_last_col = field_3_last_col; + rec.field_4_height = field_4_height; + rec.field_5_optimize = field_5_optimize; + rec.field_6_reserved = field_6_reserved; + rec.field_7_option_flags = field_7_option_flags; + rec.field_8_xf_index = field_8_xf_index; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/SCLRecord.java b/src/java/org/apache/poi/hssf/record/SCLRecord.java index 841a12d037..cec3a73db9 100644 --- a/src/java/org/apache/poi/hssf/record/SCLRecord.java +++ b/src/java/org/apache/poi/hssf/record/SCLRecord.java @@ -173,6 +173,15 @@ public class SCLRecord return this.sid; } + public Object clone() { + SCLRecord rec = new SCLRecord(); + + rec.field_1_numerator = field_1_numerator; + rec.field_2_denominator = field_2_denominator; + + return rec; + } + /** * Get the numerator field for the SCL record. diff --git a/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java b/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java index c445479db6..36fa70a068 100644 --- a/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java +++ b/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java @@ -62,6 +62,7 @@ import org.apache.poi.util.LittleEndian; * Description: defines whether to recalculate before saving (set to true)

* REFERENCE: PG 381 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -164,4 +165,10 @@ public class SaveRecalcRecord { return this.sid; } + + public Object clone() { + SaveRecalcRecord rec = new SaveRecalcRecord(); + rec.field_1_recalc = field_1_recalc; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/SelectionRecord.java b/src/java/org/apache/poi/hssf/record/SelectionRecord.java index c26d681950..9db020fd5a 100644 --- a/src/java/org/apache/poi/hssf/record/SelectionRecord.java +++ b/src/java/org/apache/poi/hssf/record/SelectionRecord.java @@ -67,6 +67,7 @@ import org.apache.poi.util.LittleEndian; * TODO : Implement reference subrecords * REFERENCE: PG 291 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -279,4 +280,15 @@ public class SelectionRecord { return this.sid; } + + public Object clone() { + SelectionRecord rec = new SelectionRecord(); + rec.field_1_pane = field_1_pane; + rec.field_2_row_active_cell = field_2_row_active_cell; + rec.field_3_col_active_cell = field_3_col_active_cell; + rec.field_4_ref_active_cell = field_4_ref_active_cell; + rec.field_5_num_refs = field_5_num_refs; + rec.field_6_refs = field_6_refs; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/SeriesChartGroupIndexRecord.java b/src/java/org/apache/poi/hssf/record/SeriesChartGroupIndexRecord.java index cfad9dc381..e0414e1372 100644 --- a/src/java/org/apache/poi/hssf/record/SeriesChartGroupIndexRecord.java +++ b/src/java/org/apache/poi/hssf/record/SeriesChartGroupIndexRecord.java @@ -165,6 +165,14 @@ public class SeriesChartGroupIndexRecord return this.sid; } + public Object clone() { + SeriesChartGroupIndexRecord rec = new SeriesChartGroupIndexRecord(); + + rec.field_1_chartGroupIndex = field_1_chartGroupIndex; + + return rec; + } + /** * Get the chart group index field for the SeriesChartGroupIndex record. diff --git a/src/java/org/apache/poi/hssf/record/SeriesIndexRecord.java b/src/java/org/apache/poi/hssf/record/SeriesIndexRecord.java index d7f2f66969..6e920b41ff 100644 --- a/src/java/org/apache/poi/hssf/record/SeriesIndexRecord.java +++ b/src/java/org/apache/poi/hssf/record/SeriesIndexRecord.java @@ -165,6 +165,14 @@ public class SeriesIndexRecord return this.sid; } + public Object clone() { + SeriesIndexRecord rec = new SeriesIndexRecord(); + + rec.field_1_index = field_1_index; + + return rec; + } + /** * Get the index field for the SeriesIndex record. diff --git a/src/java/org/apache/poi/hssf/record/SeriesLabelsRecord.java b/src/java/org/apache/poi/hssf/record/SeriesLabelsRecord.java index 0b7beb375a..da800664cc 100644 --- a/src/java/org/apache/poi/hssf/record/SeriesLabelsRecord.java +++ b/src/java/org/apache/poi/hssf/record/SeriesLabelsRecord.java @@ -177,6 +177,14 @@ public class SeriesLabelsRecord return this.sid; } + public Object clone() { + SeriesLabelsRecord rec = new SeriesLabelsRecord(); + + rec.field_1_formatFlags = field_1_formatFlags; + + return rec; + } + /** * Get the format flags field for the SeriesLabels record. diff --git a/src/java/org/apache/poi/hssf/record/SeriesListRecord.java b/src/java/org/apache/poi/hssf/record/SeriesListRecord.java index b80bc85039..284ad16507 100644 --- a/src/java/org/apache/poi/hssf/record/SeriesListRecord.java +++ b/src/java/org/apache/poi/hssf/record/SeriesListRecord.java @@ -163,6 +163,14 @@ public class SeriesListRecord return this.sid; } + public Object clone() { + SeriesListRecord rec = new SeriesListRecord(); + + rec.field_1_seriesNumbers = field_1_seriesNumbers; + + return rec; + } + /** * Get the series numbers field for the SeriesList record. diff --git a/src/java/org/apache/poi/hssf/record/SeriesRecord.java b/src/java/org/apache/poi/hssf/record/SeriesRecord.java index 1e96fb0bfb..780bf0064c 100644 --- a/src/java/org/apache/poi/hssf/record/SeriesRecord.java +++ b/src/java/org/apache/poi/hssf/record/SeriesRecord.java @@ -217,6 +217,19 @@ public class SeriesRecord return this.sid; } + public Object clone() { + SeriesRecord rec = new SeriesRecord(); + + rec.field_1_categoryDataType = field_1_categoryDataType; + rec.field_2_valuesDataType = field_2_valuesDataType; + rec.field_3_numCategories = field_3_numCategories; + rec.field_4_numValues = field_4_numValues; + rec.field_5_bubbleSeriesType = field_5_bubbleSeriesType; + rec.field_6_numBubbleValues = field_6_numBubbleValues; + + return rec; + } + /** * Get the category data type field for the Series record. diff --git a/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java b/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java index ff45ec14a2..cf60c6dfdf 100644 --- a/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java +++ b/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java @@ -187,6 +187,17 @@ public class SeriesTextRecord return this.sid; } + public Object clone() { + SeriesTextRecord rec = new SeriesTextRecord(); + + rec.field_1_id = field_1_id; + rec.field_2_textLength = field_2_textLength; + rec.field_3_undocumented = field_3_undocumented; + rec.field_4_text = field_4_text; + + return rec; + } + /** * Get the id field for the SeriesText record. diff --git a/src/java/org/apache/poi/hssf/record/SeriesToChartGroupRecord.java b/src/java/org/apache/poi/hssf/record/SeriesToChartGroupRecord.java index ad5cdf58a3..291240c85b 100644 --- a/src/java/org/apache/poi/hssf/record/SeriesToChartGroupRecord.java +++ b/src/java/org/apache/poi/hssf/record/SeriesToChartGroupRecord.java @@ -165,6 +165,14 @@ public class SeriesToChartGroupRecord return this.sid; } + public Object clone() { + SeriesToChartGroupRecord rec = new SeriesToChartGroupRecord(); + + rec.field_1_chartGroupIndex = field_1_chartGroupIndex; + + return rec; + } + /** * Get the chart group index field for the SeriesToChartGroup record. diff --git a/src/java/org/apache/poi/hssf/record/SheetPropertiesRecord.java b/src/java/org/apache/poi/hssf/record/SheetPropertiesRecord.java index d3cf4cf393..20635089b9 100644 --- a/src/java/org/apache/poi/hssf/record/SheetPropertiesRecord.java +++ b/src/java/org/apache/poi/hssf/record/SheetPropertiesRecord.java @@ -186,6 +186,15 @@ public class SheetPropertiesRecord return this.sid; } + public Object clone() { + SheetPropertiesRecord rec = new SheetPropertiesRecord(); + + rec.field_1_flags = field_1_flags; + rec.field_2_empty = field_2_empty; + + return rec; + } + /** * Get the flags field for the SheetProperties record. diff --git a/src/java/org/apache/poi/hssf/record/TextRecord.java b/src/java/org/apache/poi/hssf/record/TextRecord.java index 73da6e2f32..5d82762472 100644 --- a/src/java/org/apache/poi/hssf/record/TextRecord.java +++ b/src/java/org/apache/poi/hssf/record/TextRecord.java @@ -306,6 +306,25 @@ public class TextRecord return this.sid; } + public Object clone() { + TextRecord rec = new TextRecord(); + + rec.field_1_horizontalAlignment = field_1_horizontalAlignment; + rec.field_2_verticalAlignment = field_2_verticalAlignment; + rec.field_3_displayMode = field_3_displayMode; + rec.field_4_rgbColor = field_4_rgbColor; + rec.field_5_x = field_5_x; + rec.field_6_y = field_6_y; + rec.field_7_width = field_7_width; + rec.field_8_height = field_8_height; + rec.field_9_options1 = field_9_options1; + rec.field_10_indexOfColorValue = field_10_indexOfColorValue; + rec.field_11_options2 = field_11_options2; + rec.field_12_textRotation = field_12_textRotation; + + return rec; + } + /** * Get the horizontal alignment field for the Text record. diff --git a/src/java/org/apache/poi/hssf/record/TickRecord.java b/src/java/org/apache/poi/hssf/record/TickRecord.java index efead73f80..f1359fabc4 100644 --- a/src/java/org/apache/poi/hssf/record/TickRecord.java +++ b/src/java/org/apache/poi/hssf/record/TickRecord.java @@ -245,6 +245,23 @@ public class TickRecord return this.sid; } + public Object clone() { + TickRecord rec = new TickRecord(); + + rec.field_1_majorTickType = field_1_majorTickType; + rec.field_2_minorTickType = field_2_minorTickType; + rec.field_3_labelPosition = field_3_labelPosition; + rec.field_4_background = field_4_background; + rec.field_5_labelColorRgb = field_5_labelColorRgb; + rec.field_6_zero1 = field_6_zero1; + rec.field_7_zero2 = field_7_zero2; + rec.field_8_options = field_8_options; + rec.field_9_tickColor = field_9_tickColor; + rec.field_10_zero3 = field_10_zero3; + + return rec; + } + /** * Get the major tick type field for the Tick record. diff --git a/src/java/org/apache/poi/hssf/record/UnitsRecord.java b/src/java/org/apache/poi/hssf/record/UnitsRecord.java index 8c34a126c7..00710fb29e 100644 --- a/src/java/org/apache/poi/hssf/record/UnitsRecord.java +++ b/src/java/org/apache/poi/hssf/record/UnitsRecord.java @@ -165,6 +165,14 @@ public class UnitsRecord return this.sid; } + public Object clone() { + UnitsRecord rec = new UnitsRecord(); + + rec.field_1_units = field_1_units; + + return rec; + } + /** * Get the units field for the Units record. diff --git a/src/java/org/apache/poi/hssf/record/UnknownRecord.java b/src/java/org/apache/poi/hssf/record/UnknownRecord.java index e3ace48fbc..e027361b21 100644 --- a/src/java/org/apache/poi/hssf/record/UnknownRecord.java +++ b/src/java/org/apache/poi/hssf/record/UnknownRecord.java @@ -64,6 +64,7 @@ import org.apache.poi.util.LittleEndian; * don't know all the records to. (HSSF leaves these alone!)

* Company: SuperLink Software, Inc.

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -174,4 +175,14 @@ public class UnknownRecord throw new RecordFormatException( "Unknown record cannot be constructed via offset -- we need a copy of the data"); } + + /** Unlike the other Record.clone methods this is a shallow clone*/ + public Object clone() { + UnknownRecord rec = new UnknownRecord(); + rec.offset = offset; + rec.sid = sid; + rec.size = size; + rec.thedata = thedata; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/VCenterRecord.java b/src/java/org/apache/poi/hssf/record/VCenterRecord.java index a8f55b8bf1..6e3a856394 100644 --- a/src/java/org/apache/poi/hssf/record/VCenterRecord.java +++ b/src/java/org/apache/poi/hssf/record/VCenterRecord.java @@ -62,6 +62,7 @@ import org.apache.poi.util.LittleEndian; * Description: tells whether to center the sheet between vertical margins

* REFERENCE: PG 420 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -170,4 +171,10 @@ public class VCenterRecord { return this.sid; } + + public Object clone() { + VCenterRecord rec = new VCenterRecord(); + rec.field_1_vcenter = field_1_vcenter; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/WSBoolRecord.java b/src/java/org/apache/poi/hssf/record/WSBoolRecord.java index 9819bbb8b3..9f5f02625e 100644 --- a/src/java/org/apache/poi/hssf/record/WSBoolRecord.java +++ b/src/java/org/apache/poi/hssf/record/WSBoolRecord.java @@ -65,6 +65,7 @@ import org.apache.poi.util.LittleEndian; * REFERENCE: PG 425 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) * @author Glen Stampoultzis (gstamp@iprimus.com.au) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -415,4 +416,11 @@ public class WSBoolRecord { return this.sid; } + + public Object clone() { + WSBoolRecord rec = new WSBoolRecord(); + rec.field_1_wsbool = field_1_wsbool; + rec.field_2_wsbool = field_2_wsbool; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/WindowTwoRecord.java b/src/java/org/apache/poi/hssf/record/WindowTwoRecord.java index 57fe5d6157..45305bf042 100644 --- a/src/java/org/apache/poi/hssf/record/WindowTwoRecord.java +++ b/src/java/org/apache/poi/hssf/record/WindowTwoRecord.java @@ -63,6 +63,7 @@ import org.apache.poi.util.LittleEndian; * Description: sheet window settings

* REFERENCE: PG 422 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)

* @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) * @version 2.0-pre */ @@ -615,4 +616,16 @@ public class WindowTwoRecord { return this.sid; } + + public Object clone() { + WindowTwoRecord rec = new WindowTwoRecord(); + rec.field_1_options = field_1_options; + rec.field_2_top_row = field_2_top_row; + rec.field_3_left_col = field_3_left_col; + rec.field_4_header_color = field_4_header_color; + rec.field_5_page_break_zoom = field_5_page_break_zoom; + rec.field_6_normal_zoom = field_6_normal_zoom; + rec.field_7_reserved = field_7_reserved; + return rec; + } } diff --git a/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java index 1176943c7c..ed3edfba24 100644 --- a/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java +++ b/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java @@ -67,6 +67,7 @@ import java.util.List; /** * * @author andy + * @author Jason Height (jheight at chariot dot net dot au) */ public class RowRecordsAggregate @@ -219,5 +220,16 @@ public class RowRecordsAggregate return records.values().iterator(); } + /** Performs a deep clone of the record*/ + public Object clone() { + RowRecordsAggregate rec = new RowRecordsAggregate(); + for (Iterator rowIter = getIterator(); rowIter.hasNext();) { + //return the cloned Row Record & insert + RowRecord row = (RowRecord)((RowRecord)rowIter.next()).clone(); + rec.insertRow(row); + } + return rec; + } + } diff --git a/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java index f30a5afd5a..db9ab481cc 100644 --- a/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java +++ b/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java @@ -67,6 +67,7 @@ import java.util.TreeMap; * * @author andy * @author Glen Stampoultzis (glens at apache.org) + * @author Jason Height (jheight at chariot dot net dot au) */ public class ValueRecordsAggregate @@ -235,6 +236,16 @@ public class ValueRecordsAggregate { return records.values().iterator(); } + + /** Performs a deep clone of the record*/ + public Object clone() { + ValueRecordsAggregate rec = new ValueRecordsAggregate(); + for (Iterator valIter = getIterator(); valIter.hasNext();) { + CellValueRecordInterface val = (CellValueRecordInterface)((CellValueRecordInterface)valIter.next()).clone(); + rec.insertCell(val); + } + return rec; + } } /* diff --git a/src/java/org/apache/poi/hssf/record/formula/AddPtg.java b/src/java/org/apache/poi/hssf/record/formula/AddPtg.java index 521584b2cb..5d691bd318 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AddPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AddPtg.java @@ -68,6 +68,7 @@ import org.apache.poi.hssf.util.SheetReferences; * Addition operator PTG the "+" binomial operator. If you need more * explanation than that then well...We really can't help you here. * @author Andrew C. Oliver (acoliver@apache.org) + * @author Jason Height (jheight at chariot dot net dot au) */ public class AddPtg @@ -129,4 +130,8 @@ public class AddPtg public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;} + public Object clone() { + return new AddPtg(); + } + } diff --git a/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java b/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java index 861f59919f..5e4ed7f738 100644 --- a/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java @@ -70,6 +70,7 @@ import org.apache.poi.util.BitField; * REFERENCE:

* @author Libin Roman (Vista Portal LDT. Developer) * @author avik + * @author Jason Height (jheight at chariot dot net dot au) * @version 1.0-pre */ @@ -304,4 +305,14 @@ public class Area3DPtg extends Ptg return Ptg.CLASS_REF; } + public Object clone() { + Area3DPtg ptg = new Area3DPtg(); + ptg.field_1_index_extern_sheet = field_1_index_extern_sheet; + ptg.field_2_first_row = field_2_first_row; + ptg.field_3_last_row = field_3_last_row; + ptg.field_4_first_column = field_4_first_column; + ptg.field_5_last_column = field_5_last_column; + return ptg; + } + } diff --git a/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java b/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java index 4b20bd43cc..43cb92cd0f 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java @@ -70,6 +70,7 @@ import org.apache.poi.hssf.util.SheetReferences; /** * Specifies a rectangular area of cells A1:A4 for instance. * @author andy + * @author Jason Height (jheight at chariot dot net dot au) */ public class AreaPtg @@ -86,7 +87,9 @@ public class AreaPtg private BitField colRelative = new BitField(0x4000); private BitField column = new BitField(0x3FFF); - + private AreaPtg() { + //Required for clone methods + } public AreaPtg(String arearef) { AreaReference ar = new AreaReference(arearef); @@ -312,4 +315,13 @@ public class AreaPtg return Ptg.CLASS_REF; } + public Object clone() { + AreaPtg ptg = new AreaPtg(); + ptg.field_1_first_row = field_1_first_row; + ptg.field_2_last_row = field_2_last_row; + ptg.field_3_first_column = field_3_first_column; + ptg.field_4_last_column = field_4_last_column; + return ptg; + } + } diff --git a/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java b/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java index 2e2c4b9fe4..91b8b997ab 100644 --- a/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/AttrPtg.java @@ -72,6 +72,7 @@ import java.util.List; * This seems to be a Misc Stuff and Junk record. One function it serves is * in SUM functions (i.e. SUM(A1:A3) causes an area PTG then an ATTR with the SUM option set) * @author andy + * @author Jason Height (jheight at chariot dot net dot au) */ public class AttrPtg @@ -246,4 +247,11 @@ public class AttrPtg public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;} + + public Object clone() { + AttrPtg ptg = new AttrPtg(); + ptg.field_1_options = field_1_options; + ptg.field_2_data = field_2_data; + return ptg; + } } diff --git a/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java b/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java index 4c053b7fd0..f6fb7df665 100644 --- a/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java @@ -67,6 +67,7 @@ import org.apache.poi.hssf.util.SheetReferences; /** * * @author andy + * @author Jason Height (jheight at chariot dot net dot au) */ public class ConcatPtg @@ -122,4 +123,8 @@ public class ConcatPtg return buffer.toString(); } + public Object clone() { + return new ConcatPtg(); + } + } diff --git a/src/java/org/apache/poi/hssf/record/formula/DividePtg.java b/src/java/org/apache/poi/hssf/record/formula/DividePtg.java index 002f7c541a..92a3544353 100644 --- a/src/java/org/apache/poi/hssf/record/formula/DividePtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/DividePtg.java @@ -67,6 +67,7 @@ import org.apache.poi.hssf.util.SheetReferences; /** * This PTG implements the standard binomial divide "/" * @author Andrew C. Oliver acoliver at apache dot org + * @author Jason Height (jheight at chariot dot net dot au) */ public class DividePtg @@ -120,4 +121,9 @@ public class DividePtg buffer.append(operands[ 1 ]); return buffer.toString(); } + + public Object clone() { + DividePtg ptg = new DividePtg(); + return ptg; + } } diff --git a/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java b/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java index eca0d5e2bf..aba044e4ee 100644 --- a/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/EqualPtg.java @@ -122,4 +122,9 @@ public class EqualPtg return buffer.toString(); } + public Object clone() { + return new EqualPtg(); + } + + } diff --git a/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java b/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java index 03a773d9d1..019179ae1b 100644 --- a/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/ExpPtg.java @@ -65,6 +65,7 @@ import org.apache.poi.hssf.util.SheetReferences; /** * * @author andy + * @author Jason Height (jheight at chariot dot net dot au) */ public class ExpPtg @@ -101,4 +102,8 @@ public class ExpPtg public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;} + public Object clone() { + throw new RuntimeException("NO IDEA SHARED FORMULA EXP PTG"); + } + } diff --git a/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java b/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java index 73729fb361..f71d5ca7f1 100644 --- a/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java @@ -1,10 +1,19 @@ package org.apache.poi.hssf.record.formula; import org.apache.poi.util.LittleEndian; +/** + * + * @author Jason Height (jheight at chariot dot net dot au) + */ public class FuncPtg extends AbstractFunctionPtg{ public final static byte sid = 0x21; private int numParams=0; + + private FuncPtg() { + //Required for clone methods + } + /**Creates new function pointer from a byte array * usually called while reading an excel file. */ @@ -28,4 +37,11 @@ public class FuncPtg extends AbstractFunctionPtg{ public int getNumberOfOperands() { return numParams; } + + public Object clone() { + FuncPtg ptg = new FuncPtg(); + ptg.field_1_num_args = field_1_num_args; + ptg.field_2_fnc_index = field_2_fnc_index; + return ptg; + } } \ No newline at end of file diff --git a/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java b/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java index 12330ebaf5..0200ffda75 100644 --- a/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java @@ -1,9 +1,18 @@ package org.apache.poi.hssf.record.formula; import org.apache.poi.util.LittleEndian; + +/** + * + * @author Jason Height (jheight at chariot dot net dot au) + */ public class FuncVarPtg extends AbstractFunctionPtg{ public final static byte sid = 0x22; + private FuncVarPtg() { + //Required for clone methods + } + /**Creates new function pointer from a byte array * usually called while reading an excel file. */ @@ -38,5 +47,12 @@ public class FuncVarPtg extends AbstractFunctionPtg{ return field_1_num_args; } + public Object clone() { + FuncVarPtg ptg = new FuncVarPtg(); + ptg.field_1_num_args = field_1_num_args; + ptg.field_2_fnc_index = field_2_fnc_index; + return ptg; + } + } diff --git a/src/java/org/apache/poi/hssf/record/formula/IntPtg.java b/src/java/org/apache/poi/hssf/record/formula/IntPtg.java index d3202bf6bc..e6b8a4d6b3 100644 --- a/src/java/org/apache/poi/hssf/record/formula/IntPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/IntPtg.java @@ -67,6 +67,7 @@ import org.apache.poi.hssf.util.SheetReferences; * Integer (short intger) * Stores a (java) short value in a formula * @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) */ public class IntPtg @@ -79,6 +80,10 @@ public class IntPtg private String val; private int strlen = 0; + private IntPtg() { + //Required for clone methods + } + public IntPtg(byte [] data, int offset) { setValue(LittleEndian.getShort(data, offset + 1)); @@ -116,4 +121,10 @@ public class IntPtg return "" + getValue(); } public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;} + + public Object clone() { + IntPtg ptg = new IntPtg(); + ptg.field_1_value = field_1_value; + return ptg; + } } diff --git a/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java b/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java index 2afd885a7d..0c315e7e8e 100644 --- a/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/MemErrPtg.java @@ -66,6 +66,7 @@ import org.apache.poi.hssf.util.SheetReferences; /** * * @author andy + * @author Jason Height (jheight at chariot dot net dot au) */ public class MemErrPtg @@ -122,4 +123,11 @@ public class MemErrPtg return "ERR#"; } public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;} + + public Object clone() { + MemErrPtg ptg = new MemErrPtg(); + ptg.field_1_reserved = field_1_reserved; + ptg.field_2_subex_len = field_2_subex_len; + return ptg; + } } diff --git a/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java b/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java index 492caa4bb1..9e734a836a 100644 --- a/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/MissingArgPtg.java @@ -60,6 +60,7 @@ import org.apache.poi.hssf.util.SheetReferences; * Missing Function Arguments * * Avik Sengupta + * @author Jason Height (jheight at chariot dot net dot au) */ public class MissingArgPtg extends Ptg @@ -97,6 +98,10 @@ public class MissingArgPtg public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;} + public Object clone() { + return new MissingArgPtg(); + } + } diff --git a/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java b/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java index ac3fc1fb9a..b2ba9b4d71 100644 --- a/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/MultiplyPtg.java @@ -66,6 +66,7 @@ import org.apache.poi.hssf.util.SheetReferences; /** * Implements the standard mathmatical multiplication - * * @author Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) */ public class MultiplyPtg @@ -136,4 +137,8 @@ public class MultiplyPtg buffer.append(operands[ 1 ]); return buffer.toString(); } + + public Object clone() { + return new MultiplyPtg(); + } } diff --git a/src/java/org/apache/poi/hssf/record/formula/NamePtg.java b/src/java/org/apache/poi/hssf/record/formula/NamePtg.java index 24ea66f61f..e159f39f78 100644 --- a/src/java/org/apache/poi/hssf/record/formula/NamePtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/NamePtg.java @@ -66,6 +66,7 @@ import org.apache.poi.hssf.util.SheetReferences; /** * * @author andy + * @author Jason Height (jheight at chariot dot net dot au) */ public class NamePtg @@ -77,6 +78,11 @@ public class NamePtg private short field_2_label_index; private short field_3_zero; // reserved must be 0 + + private NamePtg() { + //Required for clone methods + } + /** Creates new NamePtg */ public NamePtg(String name) @@ -109,4 +115,12 @@ public class NamePtg } public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;} + + public Object clone() { + NamePtg ptg = new NamePtg(); + ptg.field_1_ixti = field_1_ixti; + ptg.field_2_label_index = field_2_label_index; + ptg.field_3_zero = field_3_zero; + return ptg; + } } diff --git a/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java b/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java index f713268056..f2213d3562 100644 --- a/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/NumberPtg.java @@ -61,6 +61,7 @@ import org.apache.poi.hssf.util.SheetReferences; * Stores a floating point value in a formula * value stored in a 8 byte field using IEEE notation * @author Avik Sengupta + * @author Jason Height (jheight at chariot dot net dot au) */ public class NumberPtg @@ -70,6 +71,9 @@ public class NumberPtg public final static byte sid = 0x1f; private double field_1_value; + private NumberPtg() { + //Required for clone methods + } /** Create a NumberPtg from a byte array read from disk */ public NumberPtg(byte [] data, int offset) @@ -114,5 +118,11 @@ public class NumberPtg return "" + getValue(); } public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;} + + public Object clone() { + NumberPtg ptg = new NumberPtg(); + ptg.field_1_value = field_1_value; + return ptg; + } } diff --git a/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java b/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java index 0975c656d8..6957a2fc5c 100644 --- a/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/ParenthesisPtg.java @@ -66,6 +66,7 @@ import org.apache.poi.hssf.util.SheetReferences; * * Avik Sengupta * Andrew C. Oliver (acoliver at apache dot org) + * @author Jason Height (jheight at chariot dot net dot au) */ public class ParenthesisPtg extends OperationPtg @@ -118,5 +119,9 @@ public class ParenthesisPtg public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;} + public Object clone() { + return new ParenthesisPtg(); + } + } diff --git a/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java b/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java index 19148992f0..609732f2c1 100644 --- a/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/PowerPtg.java @@ -67,6 +67,7 @@ import org.apache.poi.hssf.util.SheetReferences; /** * * @author andy + * @author Jason Height (jheight at chariot dot net dot au) */ public class PowerPtg @@ -122,4 +123,8 @@ public class PowerPtg return buffer.toString(); } + public Object clone() { + return new PowerPtg(); + } + } diff --git a/src/java/org/apache/poi/hssf/record/formula/Ptg.java b/src/java/org/apache/poi/hssf/record/formula/Ptg.java index 6aaa69bf52..305d9e7697 100644 --- a/src/java/org/apache/poi/hssf/record/formula/Ptg.java +++ b/src/java/org/apache/poi/hssf/record/formula/Ptg.java @@ -69,6 +69,7 @@ import org.apache.poi.hssf.util.SheetReferences; * * @author andy * @author avik + * @author Jason Height (jheight at chariot dot net dot au) */ public abstract class Ptg @@ -334,6 +335,8 @@ public abstract class Ptg public abstract byte getDefaultOperandClass(); + public abstract Object clone(); + } diff --git a/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java b/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java index a00183f348..29013a6213 100644 --- a/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java @@ -69,6 +69,7 @@ import org.apache.poi.hssf.model.Workbook; * Description: Defined a cell in extern sheet.

* REFERENCE:

* @author Libin Roman (Vista Portal LDT. Developer) + * @author Jason Height (jheight at chariot dot net dot au) * @version 1.0-pre */ @@ -204,4 +205,12 @@ public class Ref3DPtg extends Ptg { public byte getDefaultOperandClass() {return Ptg.CLASS_REF;} + public Object clone() { + Ref3DPtg ptg = new Ref3DPtg(); + ptg.field_1_index_extern_sheet = field_1_index_extern_sheet; + ptg.field_2_row = field_2_row; + ptg.field_3_column = field_3_column; + return ptg; + } + } diff --git a/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java b/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java index 375d2984ea..b718bbd2f7 100644 --- a/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java @@ -69,6 +69,7 @@ import org.apache.poi.hssf.util.SheetReferences; /** * ReferencePtg - handles references (such as A1, A2, IA4) * @author Andrew C. Oliver (acoliver@apache.org) + * @author Jason Height (jheight at chariot dot net dot au) */ public class ReferencePtg extends Ptg @@ -81,7 +82,9 @@ public class ReferencePtg extends Ptg private BitField rowRelative = new BitField(0x8000); private BitField colRelative = new BitField(0x4000); - + private ReferencePtg() { + //Required for clone methods + } /** * Takes in a String represnetation of a cell reference and fills out the @@ -186,4 +189,10 @@ public class ReferencePtg extends Ptg return Ptg.CLASS_REF; } + public Object clone() { + ReferencePtg ptg = new ReferencePtg(); + ptg.field_1_row = field_1_row; + ptg.field_2_col = field_2_col; + return ptg; + } } diff --git a/src/java/org/apache/poi/hssf/record/formula/StringPtg.java b/src/java/org/apache/poi/hssf/record/formula/StringPtg.java index 2a5e5b764a..76580c4b17 100644 --- a/src/java/org/apache/poi/hssf/record/formula/StringPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/StringPtg.java @@ -62,6 +62,7 @@ import org.apache.poi.hssf.util.SheetReferences; * Number * Stores a String value in a formula value stored in the format char[] * @author Werner Froidevaux + * @author Jason Height (jheight at chariot dot net dot au) */ public class StringPtg @@ -71,6 +72,9 @@ public class StringPtg public final static byte sid = 0x17; private String field_1_value; + private StringPtg() { + //Required for clone methods + } /** Create a StringPtg from a byte array read from disk */ public StringPtg(byte [] data, int offset) @@ -120,5 +124,11 @@ public class StringPtg return Ptg.CLASS_VALUE; } + public Object clone() { + StringPtg ptg = new StringPtg(); + ptg.field_1_value = field_1_value; + return ptg; + } + } diff --git a/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java b/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java index 4be753c0cb..012e872cf4 100644 --- a/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/SubtractPtg.java @@ -66,6 +66,7 @@ import org.apache.poi.hssf.util.SheetReferences; /** * * @author andy + * @author Jason Height (jheight at chariot dot net dot au) */ public class SubtractPtg @@ -118,4 +119,8 @@ public class SubtractPtg buffer.append(operands[ 1 ]); return buffer.toString(); } + + public Object clone() { + return new SubtractPtg(); + } } diff --git a/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java b/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java index f912da2360..40733a06d4 100644 --- a/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java +++ b/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java @@ -65,6 +65,7 @@ import org.apache.poi.hssf.util.SheetReferences; /** * * @author andy + * @author Jason Height (jheight at chariot dot net dot au) */ public class UnknownPtg @@ -99,5 +100,9 @@ public class UnknownPtg } public byte getDefaultOperandClass() {return Ptg.CLASS_VALUE;} + public Object clone() { + return new UnknownPtg(); + } + } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 9229547d53..0cedfc2b04 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -143,6 +143,10 @@ public class HSSFSheet setPropertiesFromSheet(sheet); } + HSSFSheet cloneSheet(Workbook book) { + return new HSSFSheet(book, sheet.cloneSheet()); + } + /** * used internally to set the properties given a Sheet object diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java index 27a188dcbf..a345c44336 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java @@ -291,6 +291,28 @@ public class HSSFWorkbook return sheet; } + /** + * create an HSSFSheet from an existing sheet in the HSSFWorkbook. + * + * @return HSSFSheet representing the cloned sheet. + */ + + public HSSFSheet cloneSheet(int sheetNum) { + HSSFSheet srcSheet = (HSSFSheet)sheets.get(sheetNum); + String srcName = workbook.getSheetName(sheetNum); + if (srcSheet != null) { + HSSFSheet clonedSheet = srcSheet.cloneSheet(workbook); + WindowTwoRecord windowTwo = (WindowTwoRecord) clonedSheet.getSheet().findFirstRecordBySid(WindowTwoRecord.sid); + windowTwo.setSelected(sheets.size() == 1); + windowTwo.setPaged(sheets.size() == 1); + + sheets.add(clonedSheet); + workbook.setSheetName(sheets.size()-1, srcName+"[1]"); + return clonedSheet; + } + return null; + } + /** * create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns * the high level representation. Use this to create new sheets. diff --git a/src/records/styles/record.xsl b/src/records/styles/record.xsl index d4ae2ac80d..685af43c72 100644 --- a/src/records/styles/record.xsl +++ b/src/records/styles/record.xsl @@ -177,6 +177,16 @@ public class Record return this.sid; } + public Object clone() { + Record rec = new Record(); + + rec. = ; + + return rec; + } + + + diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index ddaedd922e..5ce12b4618 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -199,4 +199,20 @@ public class TestHSSFSheet sheet.removeRow(row); } + public void testCloneSheet() { + HSSFWorkbook workbook = new HSSFWorkbook(); + HSSFSheet sheet = workbook.createSheet("Test Clone"); + HSSFRow row = sheet.createRow((short) 0); + HSSFCell cell = row.createCell((short) 0); + cell.setCellValue("clone_test"); + HSSFSheet cloned = workbook.cloneSheet(0); + + //Check for a good clone + assertEquals(cloned.getRow((short)0).getCell((short)0).getStringCellValue(), "clone_test"); + + //Check that the cells are not somehow linked + cell.setCellValue("Difference Check"); + assertEquals(cloned.getRow((short)0).getCell((short)0).getStringCellValue(), "clone_test"); + } + }