Top Description Inners Fields Constructors Methods
org.apache.poi.hssf.record.aggregates

public final Class SharedValueManager

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collections, .HashMap, .List, .Map, org.apache.poi.hssf.record.ArrayRecord, .FormulaRecord, .SharedFormulaRecord, .SharedValueRecordBase, .TableRecord, org.apache.poi.ss.formula.ptg.ExpPtg, org.apache.poi.hssf.util.CellRangeAddress8Bit, org.apache.poi.ss.util.CellReference

Manages various auxiliary records while constructing a RowRecordsAggregate:

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final List<ArrayRecord>
private final Map<SharedFormulaRecord, SharedValueManager.SharedFormulaGroup>
private Map<Integer, SharedValueManager.SharedFormulaGroup>
_groupsCache

cached for optimization purposes

private final TableRecord[]

Constructor Summary

AccessConstructor and Description
private
SharedValueManager(SharedFormulaRecord[] sharedFormulaRecords, CellReference[] firstCells, ArrayRecord[] arrayRecords, TableRecord[] tableRecords)

Method Summary

Modifier and TypeMethod and Description
public void
addArrayRecord(ArrayRecord ar)

Add specified Array Record.

public static SharedValueManager
create(SharedFormulaRecord[] sharedFormulaRecords, CellReference[] firstCells, ArrayRecord[] arrayRecords, TableRecord[] tableRecords)

public static SharedValueManager

Returns:

a new empty SharedValueManager.
createEmpty
()

private SharedValueManager.SharedFormulaGroup
public ArrayRecord

Returns:

the shared ArrayRecord identified by (firstRow, firstColumn). never null.
getArrayRecord
(int firstRow, int firstColumn)

private Integer
public SharedValueRecordBase

Returns:

the SHRFMLA, TABLE or ARRAY record for the formula cell, if it is the first cell of a table or array region. null if the formula cell is not shared/array/table, or if the specified formula is not the first in the group.
getRecordForFirstCell
(FormulaRecordAggregate agg)

Gets the SharedValueRecordBase record if it should be encoded immediately after the formula record contained in the specified FormulaRecordAggregate agg.

public SharedFormulaRecord

Returns:

never null
linkSharedFormulaRecord
(CellReference
as extracted from the ExpPtg from the cell's formula.
firstCell
,
FormulaRecordAggregate agg)

public CellRangeAddress8Bit

Returns:

the range of the array formula which was just removed. Never null.
removeArrayFormula
(int rowIndex, int columnIndex)

Removes the ArrayRecord for the cell group containing the specified cell.

private static <Z> List<Z>

Returns:

a modifiable list, independent of the supplied array
toList
(Z[] zz)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_arrayRecordsback to summary
private final List<ArrayRecord> _arrayRecords
_groupsBySharedFormulaRecordback to summary
private final Map<SharedFormulaRecord, SharedValueManager.SharedFormulaGroup> _groupsBySharedFormulaRecord
_groupsCacheback to summary
private Map<Integer, SharedValueManager.SharedFormulaGroup> _groupsCache

cached for optimization purposes

_tableRecordsback to summary
private final TableRecord[] _tableRecords

Constructor Detail

SharedValueManagerback to summary
private SharedValueManager(SharedFormulaRecord[] sharedFormulaRecords, CellReference[] firstCells, ArrayRecord[] arrayRecords, TableRecord[] tableRecords)

Method Detail

addArrayRecordback to summary
public void addArrayRecord(ArrayRecord ar)

Add specified Array Record.

createback to summary
public static SharedValueManager create(SharedFormulaRecord[] sharedFormulaRecords, CellReference[] firstCells, ArrayRecord[] arrayRecords, TableRecord[] tableRecords)
createEmptyback to summary
public static SharedValueManager createEmpty()
Returns:SharedValueManager

a new empty SharedValueManager.

findFormulaGroupForCellback to summary
private SharedValueManager.SharedFormulaGroup findFormulaGroupForCell(final CellReference cellRef)
getArrayRecordback to summary
public ArrayRecord getArrayRecord(int firstRow, int firstColumn)
Returns:ArrayRecord

the shared ArrayRecord identified by (firstRow, firstColumn). never null.

getKeyForCacheback to summary
private Integer getKeyForCache(final CellReference cellRef)
getRecordForFirstCellback to summary
public SharedValueRecordBase getRecordForFirstCell(FormulaRecordAggregate agg)

Gets the SharedValueRecordBase record if it should be encoded immediately after the formula record contained in the specified FormulaRecordAggregate agg. Note - the shared value record always appears after the first formula record in the group. For arrays and tables the first formula is always the in the top left cell. However, since shared formula groups can be sparse and/or overlap, the first formula may not actually be in the top left cell.

Returns:SharedValueRecordBase

the SHRFMLA, TABLE or ARRAY record for the formula cell, if it is the first cell of a table or array region. null if the formula cell is not shared/array/table, or if the specified formula is not the first in the group.

linkSharedFormulaRecordback to summary
public SharedFormulaRecord linkSharedFormulaRecord(CellReference firstCell, FormulaRecordAggregate agg)
Parameters
firstCell:CellReference

as extracted from the ExpPtg from the cell's formula.

Returns:SharedFormulaRecord

never null

removeArrayFormulaback to summary
public CellRangeAddress8Bit removeArrayFormula(int rowIndex, int columnIndex)

Removes the ArrayRecord for the cell group containing the specified cell. The caller should clear (set blank) all cells in the returned range.

Returns:CellRangeAddress8Bit

the range of the array formula which was just removed. Never null.

toListback to summary
private static <Z> List<Z> toList(Z[] zz)
Returns:List<Z>

a modifiable list, independent of the supplied array

org.apache.poi.hssf.record.aggregates back to summary

private final Class SharedValueManager.SharedFormulaGroup

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.poi.hssf.record.aggregates.SharedValueManager.SharedFormulaGroup

Field Summary

Modifier and TypeField and Description
private final CellReference
_firstCell

Coordinates of the first cell having a formula that uses this shared formula.

private final FormulaRecordAggregate[]
private int
private final SharedFormulaRecord

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public SharedFormulaRecord
public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_firstCellback to summary
private final CellReference _firstCell

Coordinates of the first cell having a formula that uses this shared formula. This is often but not always the top left cell in the range covered by _sfr

_frAggsback to summary
private final FormulaRecordAggregate[] _frAggs
_numberOfFormulasback to summary
private int _numberOfFormulas
_sfrback to summary
private final SharedFormulaRecord _sfr

Constructor Detail

SharedFormulaGroupback to summary
public SharedFormulaGroup(SharedFormulaRecord sfr, CellReference firstCell)

Method Detail

addback to summary
public void add(FormulaRecordAggregate agg)
getSFRback to summary
public SharedFormulaRecord getSFR()
toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

unlinkSharedFormulasback to summary
public void unlinkSharedFormulas()