Performance and memory improvements:

1) using BitFieldFactory
2) HSSFCell doesnt hold onto stale UnicodeString values (gets latest from SST)
3) Default for Encoding in HSSFCell is "do nothing". This will mean duplicate copies of the UnicodeString will not be required, just to change the encoding. The default "string" encoding will be used.


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353778 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason Height 2005-09-02 03:48:31 +00:00
parent d462aa3f80
commit b0f692b92c
39 changed files with 249 additions and 204 deletions

View File

@ -1033,6 +1033,12 @@ public class Sheet implements Model
setLoc(dimsloc); setLoc(dimsloc);
if (log.check( POILogger.DEBUG )) if (log.check( POILogger.DEBUG ))
log.log(POILogger.DEBUG, "replaceValueRecord "); log.log(POILogger.DEBUG, "replaceValueRecord ");
//The ValueRecordsAggregate use a tree map underneath.
//The tree Map uses the CellValueRecordInterface as both the
//key and the value, if we dont do a remove, then
//the previous instance of the key is retained, effectively using
//double the memory
cells.removeCell(newval);
cells.insertCell(newval); cells.insertCell(newval);
/* /*

View File

@ -216,6 +216,7 @@ public class Workbook implements Model
if (log.check( POILogger.DEBUG )) if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found palette record at " + k); log.log(DEBUG, "found palette record at " + k);
retval.records.setPalettepos( k ); retval.records.setPalettepos( k );
break;
case WindowOneRecord.sid: case WindowOneRecord.sid:
if (log.check( POILogger.DEBUG )) if (log.check( POILogger.DEBUG ))
log.log(DEBUG, "found WindowOneRecord at " + k); log.log(DEBUG, "found WindowOneRecord at " + k);

View File

@ -37,8 +37,8 @@ public class AreaFormatRecord
private int field_2_backgroundColor; private int field_2_backgroundColor;
private short field_3_pattern; private short field_3_pattern;
private short field_4_formatFlags; private short field_4_formatFlags;
private BitField automatic = new BitField(0x1); private BitField automatic = BitFieldFactory.getInstance(0x1);
private BitField invert = new BitField(0x2); private BitField invert = BitFieldFactory.getInstance(0x2);
private short field_5_forecolorIndex; private short field_5_forecolorIndex;
private short field_6_backcolorIndex; private short field_6_backcolorIndex;

View File

@ -34,9 +34,9 @@ public class AreaRecord
{ {
public final static short sid = 0x101A; public final static short sid = 0x101A;
private short field_1_formatFlags; private short field_1_formatFlags;
private BitField stacked = new BitField(0x1); private BitField stacked = BitFieldFactory.getInstance(0x1);
private BitField displayAsPercentage = new BitField(0x2); private BitField displayAsPercentage = BitFieldFactory.getInstance(0x2);
private BitField shadow = new BitField(0x4); private BitField shadow = BitFieldFactory.getInstance(0x4);
public AreaRecord() public AreaRecord()

View File

@ -42,14 +42,14 @@ public class AxisOptionsRecord
private short field_7_baseUnit; private short field_7_baseUnit;
private short field_8_crossingPoint; private short field_8_crossingPoint;
private short field_9_options; private short field_9_options;
private BitField defaultMinimum = new BitField(0x1); private BitField defaultMinimum = BitFieldFactory.getInstance(0x1);
private BitField defaultMaximum = new BitField(0x2); private BitField defaultMaximum = BitFieldFactory.getInstance(0x2);
private BitField defaultMajor = new BitField(0x4); private BitField defaultMajor = BitFieldFactory.getInstance(0x4);
private BitField defaultMinorUnit = new BitField(0x8); private BitField defaultMinorUnit = BitFieldFactory.getInstance(0x8);
private BitField isDate = new BitField(0x10); private BitField isDate = BitFieldFactory.getInstance(0x10);
private BitField defaultBase = new BitField(0x20); private BitField defaultBase = BitFieldFactory.getInstance(0x20);
private BitField defaultCross = new BitField(0x40); private BitField defaultCross = BitFieldFactory.getInstance(0x40);
private BitField defaultDateSettings = new BitField(0x80); private BitField defaultDateSettings = BitFieldFactory.getInstance(0x80);
public AxisOptionsRecord() public AxisOptionsRecord()

View File

@ -36,10 +36,10 @@ public class BarRecord
private short field_1_barSpace; private short field_1_barSpace;
private short field_2_categorySpace; private short field_2_categorySpace;
private short field_3_formatFlags; private short field_3_formatFlags;
private BitField horizontal = new BitField(0x1); private BitField horizontal = BitFieldFactory.getInstance(0x1);
private BitField stacked = new BitField(0x2); private BitField stacked = BitFieldFactory.getInstance(0x2);
private BitField displayAsPercentage = new BitField(0x4); private BitField displayAsPercentage = BitFieldFactory.getInstance(0x4);
private BitField shadow = new BitField(0x8); private BitField shadow = BitFieldFactory.getInstance(0x8);
public BarRecord() public BarRecord()

View File

@ -37,9 +37,9 @@ public class CategorySeriesAxisRecord
private short field_2_labelFrequency; private short field_2_labelFrequency;
private short field_3_tickMarkFrequency; private short field_3_tickMarkFrequency;
private short field_4_options; private short field_4_options;
private BitField valueAxisCrossing = new BitField(0x1); private BitField valueAxisCrossing = BitFieldFactory.getInstance(0x1);
private BitField crossesFarRight = new BitField(0x2); private BitField crossesFarRight = BitFieldFactory.getInstance(0x2);
private BitField reversed = new BitField(0x4); private BitField reversed = BitFieldFactory.getInstance(0x4);
public CategorySeriesAxisRecord() public CategorySeriesAxisRecord()

View File

@ -20,6 +20,7 @@ package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
/** /**
* Class ChartFormatRecord * Class ChartFormatRecord
@ -40,7 +41,7 @@ public class ChartFormatRecord
private int field3_width; private int field3_width;
private int field4_height; private int field4_height;
private short field5_grbit; private short field5_grbit;
private BitField varyDisplayPattern = new BitField(0x01); private BitField varyDisplayPattern = BitFieldFactory.getInstance(0x01);
public ChartFormatRecord() public ChartFormatRecord()
{ {

View File

@ -25,6 +25,7 @@ package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
/** /**
* Title: ColumnInfo Record<P> * Title: ColumnInfo Record<P>
@ -43,9 +44,9 @@ public class ColumnInfoRecord
private short field_3_col_width; private short field_3_col_width;
private short field_4_xf_index; private short field_4_xf_index;
private short field_5_options; private short field_5_options;
static final private BitField hidden = new BitField(0x01); static final private BitField hidden = BitFieldFactory.getInstance(0x01);
static final private BitField outlevel = new BitField(0x0700); static final private BitField outlevel = BitFieldFactory.getInstance(0x0700);
static final private BitField collapsed = new BitField(0x1000); static final private BitField collapsed = BitFieldFactory.getInstance(0x1000);
private short field_6_reserved; private short field_6_reserved;
public ColumnInfoRecord() public ColumnInfoRecord()

View File

@ -67,10 +67,10 @@ public class CommonObjectDataSubRecord
public final static short OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING = 30; public final static short OBJECT_TYPE_MICROSOFT_OFFICE_DRAWING = 30;
private short field_2_objectId; private short field_2_objectId;
private short field_3_option; private short field_3_option;
private BitField locked = new BitField(0x1); private BitField locked = BitFieldFactory.getInstance(0x1);
private BitField printable = new BitField(0x10); private BitField printable = BitFieldFactory.getInstance(0x10);
private BitField autofill = new BitField(0x2000); private BitField autofill = BitFieldFactory.getInstance(0x2000);
private BitField autoline = new BitField(0x4000); private BitField autoline = BitFieldFactory.getInstance(0x4000);
private int field_4_reserved1; private int field_4_reserved1;
private int field_5_reserved2; private int field_5_reserved2;
private int field_6_reserved3; private int field_6_reserved3;

View File

@ -34,10 +34,10 @@ public class DatRecord
{ {
public final static short sid = 0x1063; public final static short sid = 0x1063;
private short field_1_options; private short field_1_options;
private BitField horizontalBorder = new BitField(0x1); private BitField horizontalBorder = BitFieldFactory.getInstance(0x1);
private BitField verticalBorder = new BitField(0x2); private BitField verticalBorder = BitFieldFactory.getInstance(0x2);
private BitField border = new BitField(0x4); private BitField border = BitFieldFactory.getInstance(0x4);
private BitField showSeriesKey = new BitField(0x8); private BitField showSeriesKey = BitFieldFactory.getInstance(0x8);
public DatRecord() public DatRecord()

View File

@ -37,7 +37,7 @@ public class DataFormatRecord
private short field_2_seriesIndex; private short field_2_seriesIndex;
private short field_3_seriesNumber; private short field_3_seriesNumber;
private short field_4_formatFlags; private short field_4_formatFlags;
private BitField useExcel4Colors = new BitField(0x1); private BitField useExcel4Colors = BitFieldFactory.getInstance(0x1);
public DataFormatRecord() public DataFormatRecord()

View File

@ -19,6 +19,7 @@
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
/** /**
@ -104,81 +105,81 @@ public class ExtendedFormatRecord
private short field_2_format_index; // not bit-mapped private short field_2_format_index; // not bit-mapped
// field_3_cell_options bit map // field_3_cell_options bit map
static final private BitField _locked = new BitField(0x0001); static final private BitField _locked = BitFieldFactory.getInstance(0x0001);
static final private BitField _hidden = new BitField(0x0002); static final private BitField _hidden = BitFieldFactory.getInstance(0x0002);
static final private BitField _xf_type = new BitField(0x0004); static final private BitField _xf_type = BitFieldFactory.getInstance(0x0004);
static final private BitField _123_prefix = new BitField(0x0008); static final private BitField _123_prefix = BitFieldFactory.getInstance(0x0008);
static final private BitField _parent_index = new BitField(0xFFF0); static final private BitField _parent_index = BitFieldFactory.getInstance(0xFFF0);
private short field_3_cell_options; private short field_3_cell_options;
// field_4_alignment_options bit map // field_4_alignment_options bit map
static final private BitField _alignment = new BitField(0x0007); static final private BitField _alignment = BitFieldFactory.getInstance(0x0007);
static final private BitField _wrap_text = new BitField(0x0008); static final private BitField _wrap_text = BitFieldFactory.getInstance(0x0008);
static final private BitField _vertical_alignment = new BitField(0x0070); static final private BitField _vertical_alignment = BitFieldFactory.getInstance(0x0070);
static final private BitField _justify_last = new BitField(0x0080); static final private BitField _justify_last = BitFieldFactory.getInstance(0x0080);
static final private BitField _rotation = new BitField(0xFF00); static final private BitField _rotation = BitFieldFactory.getInstance(0xFF00);
private short field_4_alignment_options; private short field_4_alignment_options;
// field_5_indention_options // field_5_indention_options
static final private BitField _indent = static final private BitField _indent =
new BitField(0x000F); BitFieldFactory.getInstance(0x000F);
static final private BitField _shrink_to_fit = static final private BitField _shrink_to_fit =
new BitField(0x0010); BitFieldFactory.getInstance(0x0010);
static final private BitField _merge_cells = static final private BitField _merge_cells =
new BitField(0x0020); BitFieldFactory.getInstance(0x0020);
static final private BitField _reading_order = static final private BitField _reading_order =
new BitField(0x00C0); BitFieldFactory.getInstance(0x00C0);
// apparently bits 8 and 9 are unused // apparently bits 8 and 9 are unused
static final private BitField _indent_not_parent_format = static final private BitField _indent_not_parent_format =
new BitField(0x0400); BitFieldFactory.getInstance(0x0400);
static final private BitField _indent_not_parent_font = static final private BitField _indent_not_parent_font =
new BitField(0x0800); BitFieldFactory.getInstance(0x0800);
static final private BitField _indent_not_parent_alignment = static final private BitField _indent_not_parent_alignment =
new BitField(0x1000); BitFieldFactory.getInstance(0x1000);
static final private BitField _indent_not_parent_border = static final private BitField _indent_not_parent_border =
new BitField(0x2000); BitFieldFactory.getInstance(0x2000);
static final private BitField _indent_not_parent_pattern = static final private BitField _indent_not_parent_pattern =
new BitField(0x4000); BitFieldFactory.getInstance(0x4000);
static final private BitField _indent_not_parent_cell_options = static final private BitField _indent_not_parent_cell_options =
new BitField(0x8000); BitFieldFactory.getInstance(0x8000);
private short field_5_indention_options; private short field_5_indention_options;
// field_6_border_options bit map // field_6_border_options bit map
static final private BitField _border_left = new BitField(0x000F); static final private BitField _border_left = BitFieldFactory.getInstance(0x000F);
static final private BitField _border_right = new BitField(0x00F0); static final private BitField _border_right = BitFieldFactory.getInstance(0x00F0);
static final private BitField _border_top = new BitField(0x0F00); static final private BitField _border_top = BitFieldFactory.getInstance(0x0F00);
static final private BitField _border_bottom = new BitField(0xF000); static final private BitField _border_bottom = BitFieldFactory.getInstance(0xF000);
private short field_6_border_options; private short field_6_border_options;
// all three of the following attributes are palette options // all three of the following attributes are palette options
// field_7_palette_options bit map // field_7_palette_options bit map
static final private BitField _left_border_palette_idx = static final private BitField _left_border_palette_idx =
new BitField(0x007F); BitFieldFactory.getInstance(0x007F);
static final private BitField _right_border_palette_idx = static final private BitField _right_border_palette_idx =
new BitField(0x3F80); BitFieldFactory.getInstance(0x3F80);
static final private BitField _diag = static final private BitField _diag =
new BitField(0xC000); BitFieldFactory.getInstance(0xC000);
private short field_7_palette_options; private short field_7_palette_options;
// field_8_adtl_palette_options bit map // field_8_adtl_palette_options bit map
static final private BitField _top_border_palette_idx = static final private BitField _top_border_palette_idx =
new BitField(0x0000007F); BitFieldFactory.getInstance(0x0000007F);
static final private BitField _bottom_border_palette_idx = static final private BitField _bottom_border_palette_idx =
new BitField(0x00003F80); BitFieldFactory.getInstance(0x00003F80);
static final private BitField _adtl_diag = static final private BitField _adtl_diag =
new BitField(0x001fc000); BitFieldFactory.getInstance(0x001fc000);
static final private BitField _adtl_diag_line_style = static final private BitField _adtl_diag_line_style =
new BitField(0x01e00000); BitFieldFactory.getInstance(0x01e00000);
// apparently bit 25 is unused // apparently bit 25 is unused
static final private BitField _adtl_fill_pattern = static final private BitField _adtl_fill_pattern =
new BitField(0xfc000000); BitFieldFactory.getInstance(0xfc000000);
private int field_8_adtl_palette_options; // additional to avoid 2 private int field_8_adtl_palette_options; // additional to avoid 2
// field_9_fill_palette_options bit map // field_9_fill_palette_options bit map
static final private BitField _fill_foreground = new BitField(0x007F); static final private BitField _fill_foreground = BitFieldFactory.getInstance(0x007F);
static final private BitField _fill_background = new BitField(0x3f80); static final private BitField _fill_background = BitFieldFactory.getInstance(0x3f80);
// apparently bits 15 and 14 are unused // apparently bits 15 and 14 are unused
private short field_9_fill_palette_options; private short field_9_fill_palette_options;

View File

@ -21,6 +21,7 @@ package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
/** /**
* Title: Font Record - descrbes a font in the workbook (index = 0-3,5-infinity - skip 4)<P> * Title: Font Record - descrbes a font in the workbook (index = 0-3,5-infinity - skip 4)<P>
@ -48,14 +49,14 @@ public class FontRecord
// 0 0x01 - Reserved bit must be 0 // 0 0x01 - Reserved bit must be 0
static final private BitField italic = static final private BitField italic =
new BitField(0x02); // is this font in italics BitFieldFactory.getInstance(0x02); // is this font in italics
// 2 0x04 - reserved bit must be 0 // 2 0x04 - reserved bit must be 0
static final private BitField strikeout = static final private BitField strikeout =
new BitField(0x08); // is this font has a line through the center BitFieldFactory.getInstance(0x08); // is this font has a line through the center
static final private BitField macoutline = new BitField( static final private BitField macoutline = BitFieldFactory.getInstance(
0x10); // some weird macintosh thing....but who understands those mac people anyhow 0x10); // some weird macintosh thing....but who understands those mac people anyhow
static final private BitField macshadow = new BitField( static final private BitField macshadow = BitFieldFactory.getInstance(
0x20); // some weird macintosh thing....but who understands those mac people anyhow 0x20); // some weird macintosh thing....but who understands those mac people anyhow
// 7-6 - reserved bits must be 0 // 7-6 - reserved bits must be 0

View File

@ -37,8 +37,8 @@ public class FrameRecord
public final static short BORDER_TYPE_REGULAR = 0; public final static short BORDER_TYPE_REGULAR = 0;
public final static short BORDER_TYPE_SHADOW = 1; public final static short BORDER_TYPE_SHADOW = 1;
private short field_2_options; private short field_2_options;
private BitField autoSize = new BitField(0x1); private BitField autoSize = BitFieldFactory.getInstance(0x1);
private BitField autoPosition = new BitField(0x2); private BitField autoPosition = BitFieldFactory.getInstance(0x2);
public FrameRecord() public FrameRecord()

View File

@ -49,12 +49,12 @@ public class LegendRecord
public final static byte SPACING_MEDIUM = 1; public final static byte SPACING_MEDIUM = 1;
public final static byte SPACING_OPEN = 2; public final static byte SPACING_OPEN = 2;
private short field_7_options; private short field_7_options;
private BitField autoPosition = new BitField(0x1); private BitField autoPosition = BitFieldFactory.getInstance(0x1);
private BitField autoSeries = new BitField(0x2); private BitField autoSeries = BitFieldFactory.getInstance(0x2);
private BitField autoXPositioning = new BitField(0x4); private BitField autoXPositioning = BitFieldFactory.getInstance(0x4);
private BitField autoYPositioning = new BitField(0x8); private BitField autoYPositioning = BitFieldFactory.getInstance(0x8);
private BitField vertical = new BitField(0x10); private BitField vertical = BitFieldFactory.getInstance(0x10);
private BitField dataTable = new BitField(0x20); private BitField dataTable = BitFieldFactory.getInstance(0x20);
public LegendRecord() public LegendRecord()

View File

@ -50,9 +50,9 @@ public class LineFormatRecord
public final static short WEIGHT_MEDIUM = 1; public final static short WEIGHT_MEDIUM = 1;
public final static short WEIGHT_WIDE = 2; public final static short WEIGHT_WIDE = 2;
private short field_4_format; private short field_4_format;
private BitField auto = new BitField(0x1); private BitField auto = BitFieldFactory.getInstance(0x1);
private BitField drawTicks = new BitField(0x4); private BitField drawTicks = BitFieldFactory.getInstance(0x4);
private BitField unknown = new BitField(0x4); private BitField unknown = BitFieldFactory.getInstance(0x4);
private short field_5_colourPaletteIndex; private short field_5_colourPaletteIndex;

View File

@ -44,7 +44,7 @@ public class LinkedDataRecord
public final static byte REFERENCE_TYPE_NOT_USED = 3; public final static byte REFERENCE_TYPE_NOT_USED = 3;
public final static byte REFERENCE_TYPE_ERROR_REPORTED = 4; public final static byte REFERENCE_TYPE_ERROR_REPORTED = 4;
private short field_3_options; private short field_3_options;
private BitField customNumberFormat = new BitField(0x1); private BitField customNumberFormat = BitFieldFactory.getInstance(0x1);
private short field_4_indexNumberFmtRecord; private short field_4_indexNumberFmtRecord;
private LinkedDataFormulaField field_5_formulaOfLink; private LinkedDataFormulaField field_5_formulaOfLink;

View File

@ -20,6 +20,7 @@ package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
/** /**
* Title: Print Setup Record<P> * Title: Print Setup Record<P>
@ -41,24 +42,24 @@ public class PrintSetupRecord
private short field_5_fit_height; private short field_5_fit_height;
private short field_6_options; private short field_6_options;
static final private BitField lefttoright = static final private BitField lefttoright =
new BitField(0x01); // print over then down BitFieldFactory.getInstance(0x01); // print over then down
static final private BitField landscape = static final private BitField landscape =
new BitField(0x02); // landscape mode BitFieldFactory.getInstance(0x02); // landscape mode
static final private BitField validsettings = new BitField( static final private BitField validsettings = BitFieldFactory.getInstance(
0x04); // if papersize, scale, resolution, copies, landscape 0x04); // if papersize, scale, resolution, copies, landscape
// weren't obtained from the print consider them // weren't obtained from the print consider them
// mere bunk // mere bunk
static final private BitField nocolor = static final private BitField nocolor =
new BitField(0x08); // print mono/b&w, colorless BitFieldFactory.getInstance(0x08); // print mono/b&w, colorless
static final private BitField draft = static final private BitField draft =
new BitField(0x10); // print draft quality BitFieldFactory.getInstance(0x10); // print draft quality
static final private BitField notes = static final private BitField notes =
new BitField(0x20); // print the notes BitFieldFactory.getInstance(0x20); // print the notes
static final private BitField noOrientation = static final private BitField noOrientation =
new BitField(0x40); // the orientation is not set BitFieldFactory.getInstance(0x40); // the orientation is not set
static final private BitField usepage = static final private BitField usepage =
new BitField(0x80); // use a user set page no, instead of auto BitFieldFactory.getInstance(0x80); // use a user set page no, instead of auto
private short field_7_hresolution; private short field_7_hresolution;
private short field_8_vresolution; private short field_8_vresolution;
private double field_9_headermargin; private double field_9_headermargin;

View File

@ -19,6 +19,7 @@
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
/** /**
@ -51,13 +52,13 @@ public class RowRecord
// for generated sheets. // for generated sheets.
private short field_6_reserved; private short field_6_reserved;
private short field_7_option_flags; private short field_7_option_flags;
private BitField outlineLevel = new BitField(0x07); private BitField outlineLevel = BitFieldFactory.getInstance(0x07);
// bit 3 reserved // bit 3 reserved
private BitField colapsed = new BitField(0x10); private BitField colapsed = BitFieldFactory.getInstance(0x10);
private BitField zeroHeight = new BitField(0x20); private BitField zeroHeight = BitFieldFactory.getInstance(0x20);
private BitField badFontHeight = new BitField(0x40); private BitField badFontHeight = BitFieldFactory.getInstance(0x40);
private BitField formatted = new BitField(0x80); private BitField formatted = BitFieldFactory.getInstance(0x80);
private short field_8_xf_index; // only if isFormatted private short field_8_xf_index; // only if isFormatted
public RowRecord() public RowRecord()

View File

@ -34,12 +34,12 @@ public class SeriesLabelsRecord
{ {
public final static short sid = 0x100c; public final static short sid = 0x100c;
private short field_1_formatFlags; private short field_1_formatFlags;
private BitField showActual = new BitField(0x1); private BitField showActual = BitFieldFactory.getInstance(0x1);
private BitField showPercent = new BitField(0x2); private BitField showPercent = BitFieldFactory.getInstance(0x2);
private BitField labelAsPercentage = new BitField(0x4); private BitField labelAsPercentage = BitFieldFactory.getInstance(0x4);
private BitField smoothedLine = new BitField(0x8); private BitField smoothedLine = BitFieldFactory.getInstance(0x8);
private BitField showLabel = new BitField(0x10); private BitField showLabel = BitFieldFactory.getInstance(0x10);
private BitField showBubbleSizes = new BitField(0x20); private BitField showBubbleSizes = BitFieldFactory.getInstance(0x20);
public SeriesLabelsRecord() public SeriesLabelsRecord()

View File

@ -34,11 +34,11 @@ public class SheetPropertiesRecord
{ {
public final static short sid = 0x1044; public final static short sid = 0x1044;
private short field_1_flags; private short field_1_flags;
private BitField chartTypeManuallyFormatted = new BitField(0x1); private BitField chartTypeManuallyFormatted = BitFieldFactory.getInstance(0x1);
private BitField plotVisibleOnly = new BitField(0x2); private BitField plotVisibleOnly = BitFieldFactory.getInstance(0x2);
private BitField doNotSizeWithWindow = new BitField(0x4); private BitField doNotSizeWithWindow = BitFieldFactory.getInstance(0x4);
private BitField defaultPlotDimensions = new BitField(0x8); private BitField defaultPlotDimensions = BitFieldFactory.getInstance(0x8);
private BitField autoPlotArea = new BitField(0x10); private BitField autoPlotArea = BitFieldFactory.getInstance(0x10);
private byte field_2_empty; private byte field_2_empty;
public final static byte EMPTY_NOT_PLOTTED = 0; public final static byte EMPTY_NOT_PLOTTED = 0;
public final static byte EMPTY_ZERO = 1; public final static byte EMPTY_ZERO = 1;

View File

@ -21,6 +21,7 @@ package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
/** /**
* Title: Style Record<P> * Title: Style Record<P>
@ -78,7 +79,7 @@ public class StyleRecord
protected void fillFields(RecordInputStream in) protected void fillFields(RecordInputStream in)
{ {
fHighByte = new BitField(0x01); //have to init here, since we are being called fHighByte = BitFieldFactory.getInstance(0x01); //have to init here, since we are being called
//from super, and class level init hasnt been done. //from super, and class level init hasnt been done.
field_1_xf_index = in.readShort(); field_1_xf_index = in.readShort();
if (getType() == STYLE_BUILT_IN) if (getType() == STYLE_BUILT_IN)

View File

@ -36,20 +36,20 @@ public class TextObjectBaseRecord
{ {
public final static short sid = 0x1B6; public final static short sid = 0x1B6;
private short field_1_options; private short field_1_options;
private BitField reserved1 = new BitField(0x1); private BitField reserved1 = BitFieldFactory.getInstance(0x1);
private BitField HorizontalTextAlignment = new BitField(0x000E); private BitField HorizontalTextAlignment = BitFieldFactory.getInstance(0x000E);
public final static short HORIZONTAL_TEXT_ALIGNMENT_LEFT_ALIGNED = 1; public final static short HORIZONTAL_TEXT_ALIGNMENT_LEFT_ALIGNED = 1;
public final static short HORIZONTAL_TEXT_ALIGNMENT_CENTERED = 2; public final static short HORIZONTAL_TEXT_ALIGNMENT_CENTERED = 2;
public final static short HORIZONTAL_TEXT_ALIGNMENT_RIGHT_ALIGNED = 3; public final static short HORIZONTAL_TEXT_ALIGNMENT_RIGHT_ALIGNED = 3;
public final static short HORIZONTAL_TEXT_ALIGNMENT_JUSTIFIED = 4; public final static short HORIZONTAL_TEXT_ALIGNMENT_JUSTIFIED = 4;
private BitField VerticalTextAlignment = new BitField(0x0070); private BitField VerticalTextAlignment = BitFieldFactory.getInstance(0x0070);
public final static short VERTICAL_TEXT_ALIGNMENT_TOP = 1; public final static short VERTICAL_TEXT_ALIGNMENT_TOP = 1;
public final static short VERTICAL_TEXT_ALIGNMENT_CENTER = 2; public final static short VERTICAL_TEXT_ALIGNMENT_CENTER = 2;
public final static short VERTICAL_TEXT_ALIGNMENT_BOTTOM = 3; public final static short VERTICAL_TEXT_ALIGNMENT_BOTTOM = 3;
public final static short VERTICAL_TEXT_ALIGNMENT_JUSTIFY = 4; public final static short VERTICAL_TEXT_ALIGNMENT_JUSTIFY = 4;
private BitField reserved2 = new BitField(0x0180); private BitField reserved2 = BitFieldFactory.getInstance(0x0180);
private BitField textLocked = new BitField(0x200); private BitField textLocked = BitFieldFactory.getInstance(0x200);
private BitField reserved3 = new BitField(0xFC00); private BitField reserved3 = BitFieldFactory.getInstance(0xFC00);
private short field_2_textOrientation; private short field_2_textOrientation;
public final static short TEXT_ORIENTATION_NONE = 0; public final static short TEXT_ORIENTATION_NONE = 0;
public final static short TEXT_ORIENTATION_TOP_TO_BOTTOM = 1; public final static short TEXT_ORIENTATION_TOP_TO_BOTTOM = 1;

View File

@ -38,16 +38,20 @@ public class TextObjectRecord
protected void fillFields(RecordInputStream in) protected void fillFields(RecordInputStream in)
{ {
super.fillFields(in); super.fillFields(in);
if (getTextLength() > 0) {
if (in.isContinueNext() && in.remaining() == 0) { if (in.isContinueNext() && in.remaining() == 0) {
//1st Continue //1st Continue
in.nextRecord(); in.nextRecord();
processRawString(in); processRawString(in);
} else
throw new RecordFormatException("Expected Continue record to hold string data for TextObjectRecord");
}
if (getFormattingRunLength() > 0) {
if (in.isContinueNext() && in.remaining() == 0) { if (in.isContinueNext() && in.remaining() == 0) {
in.nextRecord(); in.nextRecord();
processFontRuns(in); processFontRuns(in);
} else throw new RecordFormatException("Expected Continue Record to hold font runs for TextObjectRecord"); } else throw new RecordFormatException("Expected Continue Record to hold font runs for TextObjectRecord");
} else }
throw new RecordFormatException("Expected Continue record to hold string data for TextObjectRecord");
} }

View File

@ -52,26 +52,26 @@ public class TextRecord
private int field_7_width; private int field_7_width;
private int field_8_height; private int field_8_height;
private short field_9_options1; private short field_9_options1;
private BitField autoColor = new BitField(0x1); private BitField autoColor = BitFieldFactory.getInstance(0x1);
private BitField showKey = new BitField(0x2); private BitField showKey = BitFieldFactory.getInstance(0x2);
private BitField showValue = new BitField(0x4); private BitField showValue = BitFieldFactory.getInstance(0x4);
private BitField vertical = new BitField(0x8); private BitField vertical = BitFieldFactory.getInstance(0x8);
private BitField autoGeneratedText = new BitField(0x10); private BitField autoGeneratedText = BitFieldFactory.getInstance(0x10);
private BitField generated = new BitField(0x20); private BitField generated = BitFieldFactory.getInstance(0x20);
private BitField autoLabelDeleted = new BitField(0x40); private BitField autoLabelDeleted = BitFieldFactory.getInstance(0x40);
private BitField autoBackground = new BitField(0x80); private BitField autoBackground = BitFieldFactory.getInstance(0x80);
private BitField rotation = new BitField(0x0700); private BitField rotation = BitFieldFactory.getInstance(0x0700);
public final static short ROTATION_NONE = 0; public final static short ROTATION_NONE = 0;
public final static short ROTATION_TOP_TO_BOTTOM = 1; public final static short ROTATION_TOP_TO_BOTTOM = 1;
public final static short ROTATION_ROTATED_90_DEGREES = 2; public final static short ROTATION_ROTATED_90_DEGREES = 2;
public final static short ROTATION_ROTATED_90_DEGREES_CLOCKWISE = 3; public final static short ROTATION_ROTATED_90_DEGREES_CLOCKWISE = 3;
private BitField showCategoryLabelAsPercentage = new BitField(0x800); private BitField showCategoryLabelAsPercentage = BitFieldFactory.getInstance(0x800);
private BitField showValueAsPercentage = new BitField(0x1000); private BitField showValueAsPercentage = BitFieldFactory.getInstance(0x1000);
private BitField showBubbleSizes = new BitField(0x2000); private BitField showBubbleSizes = BitFieldFactory.getInstance(0x2000);
private BitField showLabel = new BitField(0x4000); private BitField showLabel = BitFieldFactory.getInstance(0x4000);
private short field_10_indexOfColorValue; private short field_10_indexOfColorValue;
private short field_11_options2; private short field_11_options2;
private BitField dataLabelPlacement = new BitField(0x000F); private BitField dataLabelPlacement = BitFieldFactory.getInstance(0x000F);
public final static short DATA_LABEL_PLACEMENT_CHART_DEPENDENT = 0; public final static short DATA_LABEL_PLACEMENT_CHART_DEPENDENT = 0;
public final static short DATA_LABEL_PLACEMENT_OUTSIDE = 1; public final static short DATA_LABEL_PLACEMENT_OUTSIDE = 1;
public final static short DATA_LABEL_PLACEMENT_INSIDE = 2; public final static short DATA_LABEL_PLACEMENT_INSIDE = 2;

View File

@ -43,10 +43,10 @@ public class TickRecord
private int field_8_zero3; private int field_8_zero3;
private int field_9_zero4; private int field_9_zero4;
private short field_10_options; private short field_10_options;
private BitField autoTextColor = new BitField(0x1); private BitField autoTextColor = BitFieldFactory.getInstance(0x1);
private BitField autoTextBackground = new BitField(0x2); private BitField autoTextBackground = BitFieldFactory.getInstance(0x2);
private BitField rotation = new BitField(0x1c); private BitField rotation = BitFieldFactory.getInstance(0x1c);
private BitField autorotate = new BitField(0x20); private BitField autorotate = BitFieldFactory.getInstance(0x20);
private short field_11_tickColor; private short field_11_tickColor;
private short field_12_zero5; private short field_12_zero5;

View File

@ -39,15 +39,15 @@ public class ValueRangeRecord
private double field_4_minorIncrement; private double field_4_minorIncrement;
private double field_5_categoryAxisCross; private double field_5_categoryAxisCross;
private short field_6_options; private short field_6_options;
private BitField automaticMinimum = new BitField(0x1); private BitField automaticMinimum = BitFieldFactory.getInstance(0x1);
private BitField automaticMaximum = new BitField(0x2); private BitField automaticMaximum = BitFieldFactory.getInstance(0x2);
private BitField automaticMajor = new BitField(0x4); private BitField automaticMajor = BitFieldFactory.getInstance(0x4);
private BitField automaticMinor = new BitField(0x8); private BitField automaticMinor = BitFieldFactory.getInstance(0x8);
private BitField automaticCategoryCrossing = new BitField(0x10); private BitField automaticCategoryCrossing = BitFieldFactory.getInstance(0x10);
private BitField logarithmicScale = new BitField(0x20); private BitField logarithmicScale = BitFieldFactory.getInstance(0x20);
private BitField valuesInReverse = new BitField(0x40); private BitField valuesInReverse = BitFieldFactory.getInstance(0x40);
private BitField crossCategoryAxisAtMaximum = new BitField(0x80); private BitField crossCategoryAxisAtMaximum = BitFieldFactory.getInstance(0x80);
private BitField reserved = new BitField(0x100); private BitField reserved = BitFieldFactory.getInstance(0x100);
public ValueRangeRecord() public ValueRangeRecord()

View File

@ -19,6 +19,7 @@
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
/** /**
@ -41,29 +42,29 @@ public class WSBoolRecord
// I decided to be consistant in this way. // I decided to be consistant in this way.
static final private BitField autobreaks = static final private BitField autobreaks =
new BitField(0x01); // are automatic page breaks visible BitFieldFactory.getInstance(0x01); // are automatic page breaks visible
// bits 1 to 3 unused // bits 1 to 3 unused
static final private BitField dialog = static final private BitField dialog =
new BitField(0x10); // is sheet dialog sheet BitFieldFactory.getInstance(0x10); // is sheet dialog sheet
static final private BitField applystyles = static final private BitField applystyles =
new BitField(0x20); // whether to apply automatic styles to outlines BitFieldFactory.getInstance(0x20); // whether to apply automatic styles to outlines
static final private BitField rowsumsbelow = new BitField( static final private BitField rowsumsbelow = BitFieldFactory.getInstance(
0x40); // whether summary rows will appear below detail in outlines 0x40); // whether summary rows will appear below detail in outlines
static final private BitField rowsumsright = new BitField( static final private BitField rowsumsright = BitFieldFactory.getInstance(
0x80); // whether summary rows will appear right of the detail in outlines 0x80); // whether summary rows will appear right of the detail in outlines
static final private BitField fittopage = static final private BitField fittopage =
new BitField(0x01); // whether to fit stuff to the page BitFieldFactory.getInstance(0x01); // whether to fit stuff to the page
// bit 2 reserved // bit 2 reserved
static final private BitField displayguts = new BitField( static final private BitField displayguts = BitFieldFactory.getInstance(
0x06); // whether to display outline symbols (in the gutters) 0x06); // whether to display outline symbols (in the gutters)
// bits 4-5 reserved // bits 4-5 reserved
static final private BitField alternateexpression = // whether to use alternate expression eval static final private BitField alternateexpression = // whether to use alternate expression eval
new BitField(0x40); BitFieldFactory.getInstance(0x40);
static final private BitField alternateformula = // whether to use alternate formula entry static final private BitField alternateformula = // whether to use alternate formula entry
new BitField(0x80); BitFieldFactory.getInstance(0x80);
public WSBoolRecord() public WSBoolRecord()
{ {

View File

@ -19,6 +19,7 @@
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
/** /**
@ -43,16 +44,16 @@ public class WindowOneRecord
private short field_4_height; private short field_4_height;
private short field_5_options; private short field_5_options;
static final private BitField hidden = static final private BitField hidden =
new BitField(0x01); // is this window is hidden BitFieldFactory.getInstance(0x01); // is this window is hidden
static final private BitField iconic = static final private BitField iconic =
new BitField(0x02); // is this window is an icon BitFieldFactory.getInstance(0x02); // is this window is an icon
static final private BitField reserved = new BitField(0x04); // reserved static final private BitField reserved = BitFieldFactory.getInstance(0x04); // reserved
static final private BitField hscroll = static final private BitField hscroll =
new BitField(0x08); // display horizontal scrollbar BitFieldFactory.getInstance(0x08); // display horizontal scrollbar
static final private BitField vscroll = static final private BitField vscroll =
new BitField(0x10); // display vertical scrollbar BitFieldFactory.getInstance(0x10); // display vertical scrollbar
static final private BitField tabs = static final private BitField tabs =
new BitField(0x20); // display tabs at the bottom BitFieldFactory.getInstance(0x20); // display tabs at the bottom
// all the rest are "reserved" // all the rest are "reserved"
private short field_6_selected_tab; private short field_6_selected_tab;

View File

@ -19,6 +19,7 @@
package org.apache.poi.hssf.record; package org.apache.poi.hssf.record;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
/** /**
@ -37,23 +38,23 @@ public class WindowTwoRecord
private short field_1_options; private short field_1_options;
// bitfields // bitfields
private BitField displayFormulas = new BitField(0x01); private BitField displayFormulas = BitFieldFactory.getInstance(0x01);
private BitField displayGridlines = new BitField(0x02); private BitField displayGridlines = BitFieldFactory.getInstance(0x02);
private BitField displayRowColHeadings = new BitField(0x04); private BitField displayRowColHeadings = BitFieldFactory.getInstance(0x04);
private BitField freezePanes = new BitField(0x08); private BitField freezePanes = BitFieldFactory.getInstance(0x08);
private BitField displayZeros = new BitField(0x10); private BitField displayZeros = BitFieldFactory.getInstance(0x10);
private BitField defaultHeader = private BitField defaultHeader =
new BitField(0x20); // if false use color in field 4 BitFieldFactory.getInstance(0x20); // if false use color in field 4
// if true use default foreground // if true use default foreground
// for headers // for headers
private BitField arabic = private BitField arabic =
new BitField(0x40); // for our desert dwelling friends BitFieldFactory.getInstance(0x40); // for our desert dwelling friends
private BitField displayGuts = new BitField(0x80); private BitField displayGuts = BitFieldFactory.getInstance(0x80);
private BitField freezePanesNoSplit = new BitField(0x100); private BitField freezePanesNoSplit = BitFieldFactory.getInstance(0x100);
private BitField selected = new BitField(0x200); private BitField selected = BitFieldFactory.getInstance(0x200);
private BitField paged = new BitField(0x400); private BitField paged = BitFieldFactory.getInstance(0x400);
private BitField savedInPageBreakPreview = new BitField(0x800); private BitField savedInPageBreakPreview = BitFieldFactory.getInstance(0x800);
// 4-7 reserved // 4-7 reserved
// end bitfields // end bitfields

View File

@ -25,6 +25,8 @@ import org.apache.poi.hssf.util.SheetReferences;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
/** /**
* Title: Area 3D Ptg - 3D referecnce (Sheet + Area)<P> * Title: Area 3D Ptg - 3D referecnce (Sheet + Area)<P>
@ -46,8 +48,8 @@ public class Area3DPtg extends Ptg
private short field_4_first_column; private short field_4_first_column;
private short field_5_last_column; private short field_5_last_column;
private BitField rowRelative = new BitField( 0x8000 ); private BitField rowRelative = BitFieldFactory.getInstance( 0x8000 );
private BitField colRelative = new BitField( 0x4000 ); private BitField colRelative = BitFieldFactory.getInstance( 0x4000 );
/** Creates new AreaPtg */ /** Creates new AreaPtg */
public Area3DPtg() public Area3DPtg()

View File

@ -19,6 +19,7 @@ package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.hssf.util.AreaReference; import org.apache.poi.hssf.util.AreaReference;
import org.apache.poi.hssf.util.CellReference; import org.apache.poi.hssf.util.CellReference;
@ -41,9 +42,9 @@ public class AreaPtg
private short field_3_first_column; private short field_3_first_column;
private short field_4_last_column; private short field_4_last_column;
private BitField rowRelative = new BitField(0x8000); private BitField rowRelative = BitFieldFactory.getInstance(0x8000);
private BitField colRelative = new BitField(0x4000); private BitField colRelative = BitFieldFactory.getInstance(0x4000);
private BitField column = new BitField(0x3FFF); private BitField column = BitFieldFactory.getInstance(0x3FFF);
private AreaPtg() { private AreaPtg() {
//Required for clone methods //Required for clone methods

View File

@ -22,6 +22,7 @@ import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import java.util.List; import java.util.List;
@ -40,13 +41,13 @@ public class AttrPtg
private final static int SIZE = 4; private final static int SIZE = 4;
private byte field_1_options; private byte field_1_options;
private short field_2_data; private short field_2_data;
private BitField semiVolatile = new BitField(0x01); private BitField semiVolatile = BitFieldFactory.getInstance(0x01);
private BitField optiIf = new BitField(0x02); private BitField optiIf = BitFieldFactory.getInstance(0x02);
private BitField optiChoose = new BitField(0x04); private BitField optiChoose = BitFieldFactory.getInstance(0x04);
private BitField optGoto = new BitField(0x08); private BitField optGoto = BitFieldFactory.getInstance(0x08);
private BitField sum = new BitField(0x10); private BitField sum = BitFieldFactory.getInstance(0x10);
private BitField baxcel = new BitField(0x20); private BitField baxcel = BitFieldFactory.getInstance(0x20);
private BitField space = new BitField(0x40); private BitField space = BitFieldFactory.getInstance(0x40);
public AttrPtg() { public AttrPtg() {
} }

View File

@ -24,6 +24,7 @@ import org.apache.poi.hssf.util.CellReference;
import org.apache.poi.hssf.util.SheetReferences; import org.apache.poi.hssf.util.SheetReferences;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.record.RecordInputStream;
@ -42,8 +43,8 @@ public class Ref3DPtg extends Ptg {
private short field_1_index_extern_sheet; private short field_1_index_extern_sheet;
private short field_2_row; private short field_2_row;
private short field_3_column; private short field_3_column;
private BitField rowRelative = new BitField(0x8000); private BitField rowRelative = BitFieldFactory.getInstance(0x8000);
private BitField colRelative = new BitField(0x4000); private BitField colRelative = BitFieldFactory.getInstance(0x4000);
/** Creates new AreaPtg */ /** Creates new AreaPtg */
public Ref3DPtg() {} public Ref3DPtg() {}

View File

@ -18,6 +18,7 @@ package org.apache.poi.hssf.record.formula;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.hssf.util.CellReference; import org.apache.poi.hssf.util.CellReference;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.Workbook;
@ -36,8 +37,8 @@ public class ReferencePtg extends Ptg
//public final static byte sid = 0x44; //public final static byte sid = 0x44;
private short field_1_row; private short field_1_row;
private short field_2_col; private short field_2_col;
private BitField rowRelative = new BitField(0x8000); private BitField rowRelative = BitFieldFactory.getInstance(0x8000);
private BitField colRelative = new BitField(0x4000); private BitField colRelative = BitFieldFactory.getInstance(0x4000);
private ReferencePtg() { private ReferencePtg() {
//Required for clone methods //Required for clone methods

View File

@ -18,6 +18,7 @@ package org.apache.poi.hssf.record.formula;
import org.apache.poi.hssf.model.Workbook; import org.apache.poi.hssf.model.Workbook;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.hssf.record.RecordInputStream;
@ -38,7 +39,7 @@ public class StringPtg
// Book says something totally different, so dont look there! // Book says something totally different, so dont look there!
int field_1_length; int field_1_length;
byte field_2_options; byte field_2_options;
BitField fHighByte = new BitField(0x01); BitField fHighByte = BitFieldFactory.getInstance(0x01);
private String field_3_string; private String field_3_string;
private StringPtg() { private StringPtg() {

View File

@ -103,6 +103,7 @@ public class HSSFCell
*/ */
public final static int CELL_TYPE_ERROR = 5; public final static int CELL_TYPE_ERROR = 5;
public final static short ENCODING_UNCHANGED = -1;
public final static short ENCODING_COMPRESSED_UNICODE = 0; public final static short ENCODING_COMPRESSED_UNICODE = 0;
public final static short ENCODING_UTF_16 = 1; public final static short ENCODING_UTF_16 = 1;
private short cellNum; private short cellNum;
@ -112,7 +113,7 @@ public class HSSFCell
private HSSFRichTextString stringValue; private HSSFRichTextString stringValue;
private boolean booleanValue; private boolean booleanValue;
private byte errorValue; private byte errorValue;
private short encoding = ENCODING_COMPRESSED_UNICODE; private short encoding = ENCODING_UNCHANGED;
private Workbook book; private Workbook book;
private Sheet sheet; private Sheet sheet;
//private short row; //private short row;
@ -467,19 +468,17 @@ public class HSSFCell
{ {
int sst = 0; int sst = 0;
UnicodeString str = getRichStringCellValue().getUnicodeString();
if (encoding == ENCODING_COMPRESSED_UNICODE) if (encoding == ENCODING_COMPRESSED_UNICODE)
{ {
UnicodeString str = getRichStringCellValue().getUnicodeString();
str.setCompressedUnicode(); str.setCompressedUnicode();
sst = book.addSSTString(str); } else if (encoding == ENCODING_UTF_16)
}
if (encoding == ENCODING_UTF_16)
{ {
UnicodeString str = getRichStringCellValue().getUnicodeString();
str.setUncompressedUnicode(); str.setUncompressedUnicode();
sst = book.addSSTString(str);
} }
sst = book.addSSTString(str);
lrec.setSSTIndex(sst); lrec.setSSTIndex(sst);
getRichStringCellValue().setUnicodeString(book.getSSTString(sst));
} }
} }
record = lrec; record = lrec;
@ -661,21 +660,19 @@ public class HSSFCell
} }
int index = 0; int index = 0;
UnicodeString str = value.getUnicodeString();
if (encoding == ENCODING_COMPRESSED_UNICODE) if (encoding == ENCODING_COMPRESSED_UNICODE)
{ {
UnicodeString str = value.getUnicodeString();
str.setCompressedUnicode(); str.setCompressedUnicode();
index = book.addSSTString(str); } else if (encoding == ENCODING_UTF_16)
}
if (encoding == ENCODING_UTF_16)
{ {
UnicodeString str = value.getUnicodeString();
str.setUncompressedUnicode(); str.setUncompressedUnicode();
index = book.addSSTString(str);
} }
index = book.addSSTString(str);
(( LabelSSTRecord ) record).setSSTIndex(index); (( LabelSSTRecord ) record).setSSTIndex(index);
stringValue = value; stringValue = value;
stringValue.setWorkbookReferences(book, (( LabelSSTRecord ) record)); stringValue.setWorkbookReferences(book, (( LabelSSTRecord ) record));
stringValue.setUnicodeString(book.getSSTString(index));
} }
} }
@ -924,14 +921,14 @@ public class HSSFCell
} }
/** /**
* used for internationalization, currently 0 for compressed unicode or 1 for 16-bit * used for internationalization, currently -1 for unchanged, 0 for compressed unicode or 1 for 16-bit
* *
* @see #ENCODING_UNCHANGED
* @see #ENCODING_COMPRESSED_UNICODE * @see #ENCODING_COMPRESSED_UNICODE
* @see #ENCODING_UTF_16 * @see #ENCODING_UTF_16
* *
* @return 1 or 0 for compressed or uncompressed (used only with String type) * @return -1, 1 or 0 for unchanged, compressed or uncompressed (used only with String type)
*/ */
public short getEncoding() public short getEncoding()
{ {
return encoding; return encoding;
@ -940,6 +937,7 @@ public class HSSFCell
/** /**
* set the encoding to either 8 or 16 bit. (US/UK use 8-bit, rest of the western world use 16bit) * set the encoding to either 8 or 16 bit. (US/UK use 8-bit, rest of the western world use 16bit)
* *
* @see #ENCODING_UNCHANGED
* @see #ENCODING_COMPRESSED_UNICODE * @see #ENCODING_COMPRESSED_UNICODE
* @see #ENCODING_UTF_16 * @see #ENCODING_UTF_16
* *

View File

@ -77,7 +77,11 @@ public class HSSFRichTextString
private void addToSSTIfRequired() { private void addToSSTIfRequired() {
if (book != null) { if (book != null) {
record.setSSTIndex(book.addSSTString(string)); int index = book.addSSTString(string);
record.setSSTIndex(index);
//The act of adding the string to the SST record may have meant that
//a extsing string was returned for the index, so update our local version
string = book.getSSTString(index);
} }
} }
@ -162,10 +166,17 @@ public class HSSFRichTextString
return string.getString(); return string.getString();
} }
/** Used internally by the HSSFCell to get the internal string value*/
UnicodeString getUnicodeString() { UnicodeString getUnicodeString() {
return cloneStringIfRequired(); return cloneStringIfRequired();
} }
/** Used internally by the HSSFCell to set the internal string value*/
void setUnicodeString(UnicodeString str) {
this.string = str;
}
/** /**
* @return the number of characters in the font. * @return the number of characters in the font.
*/ */
@ -240,6 +251,14 @@ public class HSSFRichTextString
return string.compareTo(r.string); return string.compareTo(r.string);
} }
public boolean equals(Object o) {
if (o instanceof HSSFRichTextString) {
return string.equals(((HSSFRichTextString)o).string);
}
return false;
}
/** /**
* @return the plain text representation of this string. * @return the plain text representation of this string.
*/ */