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

public final Class EscherAggregate

extends AbstractEscherHolderRecord
Class Inheritance
Static Imports
org.apache.poi.hssf.record.RecordInputStream.MAX_RECORD_DATA_SIZE

This class is used to aggregate the MSODRAWING and OBJ record combinations. This is necessary due to the bizare way in which these records are serialized. What happens is that you get a combination of MSODRAWING -> OBJ -> MSODRAWING -> OBJ records but the escher records are serialized _across_ the MSODRAWING records.

It gets even worse when you start looking at TXO records.

So what we do with this class is aggregate lazily. That is we don't aggregate the MSODRAWING -> OBJ records unless we need to modify them.

At first document contains 4 types of records which belong to drawing layer. There are can be such sequence of record:

DrawingRecord ContinueRecord ... ContinueRecord ObjRecord | TextObjectRecord ..... ContinueRecord ... ContinueRecord ObjRecord | TextObjectRecord NoteRecord ... NoteRecord

To work with shapes we have to read data from Drawing and Continue records into single array of bytes and build escher(office art) records tree from this array. Each shape in drawing layer matches corresponding ObjRecord Each textbox matches corresponding TextObjectRecord

ObjRecord contains information about shape. Thus each ObjRecord corresponds EscherContainerRecord(SPGR)

EscherAggrefate contains also NoteRecords NoteRecords must be serial

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final int
private static int
private final Map<EscherRecord, Record>
shapeToObj

Maps shape container objects to their TextObjectRecord or ObjRecord

public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
ST_ARC

Deprecated use ShapeType#ARC
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
ST_BEVEL

Deprecated use ShapeType#BEVEL
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
ST_CAN

Deprecated use ShapeType#CAN
public static final short
public static final short
public static final short
public static final short
ST_CUBE

Deprecated use ShapeType#CUBE
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
ST_DONUT

Deprecated use ShapeType#DONUT
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
ST_HEART

Deprecated use ShapeType#HEART
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
ST_LINE

Deprecated use ShapeType#LINE
public static final short
ST_MIN

Deprecated not used
public static final short
ST_MOON

Deprecated use ShapeType#MOON
public static final short
ST_NIL

Deprecated not used
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
ST_PLAQUE

Deprecated use ShapeType#PLAQUE
public static final short
ST_PLUS

Deprecated use ShapeType#PLUS
public static final short
public static final short
public static final short
public static final short
ST_RIBBON

Deprecated use ShapeType#RIBBON
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
ST_SEAL

Deprecated use ShapeType#SEAL
public static final short
public static final short
public static final short
public static final short
ST_SEAL4

Deprecated use ShapeType#STAR_4
public static final short
ST_SEAL8

Deprecated use ShapeType#STAR_8
public static final short
public static final short
ST_STAR

Deprecated use ShapeType#STAR_5
public static final short
public static final short
public static final short
ST_SUN

Deprecated use ShapeType#SUN
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
public static final short
ST_WAVE

Deprecated use ShapeType#WAVE
public static final short
public static final short
public static final short
private final Map<Integer, NoteRecord>
tailRec

list of "tail" records that need to be serialized after all drawing group records

Constructor Summary

AccessConstructor and Description
public
EscherAggregate(boolean
if true creates base tree of the escher records, see EscherAggregate.buildBaseTree() else return empty escher aggregate
createDefaultTree
)

create new EscherAggregate

public

Method Summary

Modifier and TypeMethod and Description
public void
addTailRecord(NoteRecord
to be added
note
)

Add tail record to existing map

public void
associateShapeToObjRecord(EscherRecord
- ClientData or Textbox record
r
,
Record
- Obj or TextObj record
objRecord
)

Associates an escher record to an OBJ record or a TXO record.

private void
buildBaseTree()

create base tree with such structure: EscherDgContainer -EscherSpgrContainer --EscherSpContainer ---EscherSpRecord ---EscherSpgrRecord ---EscherSpRecord -EscherDgRecord id of DgRecord and SpRecord are empty and must be set later by HSSFPatriarch

public EscherAggregate
public static EscherAggregate

Returns:

new EscherAggregate create from all aggregated records which belong to drawing layer
createAggregate
(final List<RecordBase>
- list of all records inside sheet
records
,
final int
- location of the first DrawingRecord inside sheet
locFirstDrawingRecord
)

Collapses the drawing records into an aggregate.

private int

Returns:

the number of bytes
getEscherRecordSize
(List<EscherRecord>
List of escher records
records
)

How many bytes do the raw escher records contain.

public Map<String, Supplier<?>>
public HSSFRecordTypes
public static int

Returns:

the max record length allowed for EscherAggregate
getMaxRecordLength
()

public NoteRecord

Returns:

null if note record is not found else returns note record with id == obj.id
getNoteRecordByObj
(ObjRecord
- ObjRecord with id == NoteRecord.id
obj
)

protected String
public int

Returns:

record size, including header size of obj, text, note, drawing, continue records
getRecordSize
()

Overrides org.apache.poi.hssf.record.AbstractEscherHolderRecord.getRecordSize.

gives the current serialized size of the record.

public Map<EscherRecord, Record>

Returns:

unmodifiable copy of the mapping of EscherClientDataRecord and EscherTextboxRecord to their TextObjectRecord or ObjRecord .

We need to access it outside of EscherAggregate when building shapes

getShapeToObjMapping
()

public short

Returns:

Returns the current sid.
getSid
()

Implements abstract org.apache.poi.hssf.record.AbstractEscherHolderRecord.getSid.

return the non static version of the id for this record.

public Map<Integer, NoteRecord>

Returns:

unmodifiable copy of tail records. We need to access them when building shapes. Every HSSFComment shape has a link to a NoteRecord from the tailRec collection.
getTailRecords
()

public void
removeShapeToObjRecord(EscherRecord
- clientData or textbox record to be removed
rec
)

Remove echerRecord and associated to it Obj or TextObj record

public void
removeTailRecord(NoteRecord
to be removed
note
)

Remove tail record from the existing map

public int

Returns:

The number of bytes serialized.
serialize
(final int
The offset into the start of the array.
offset
,
final byte[]
The byte array to serialize to.
data
)

Overrides org.apache.poi.hssf.record.AbstractEscherHolderRecord.serialize.

Serializes this aggregate to a byte array.

public void
setDgId(short
- id which must be set
dgId
)

EscherDgContainer -EscherSpgrContainer -EscherDgRecord - set id for this record set id for DgRecord of DgContainer

public void
setMainSpRecordId(int
- id which must be set
shapeId
)

EscherDgContainer -EscherSpgrContainer --EscherSpContainer ---EscherSpRecord -set id for this record ---*** --*** -EscherDgRecord set id for the sp record of the first spContainer in main spgrConatiner

public static void
setMaxRecordLength(int
the max record length allowed for EscherAggregate
length
)

private static short

Returns:

sid of the record
sid
(RecordBase
the record to look into
record
)

public String

Returns:

xml representation of the all aggregated records
toXml
(String
- string which must be added before each line (used by default '\t')
tab
)

Calculates the xml representation of this record.

private int

Returns:

offset of data array after serialization
writeDataIntoDrawingRecord
(final byte[]
- escher records saved into single byte array
drawingData
,
final int
- count of bytes already saved into drawing records (we should know it to decide create drawing or continue record)
writtenEscherBytes
,
final int
current position of data array
pos
,
final byte[]
- array of bytes where drawing records must be serialized
data
,
final boolean
- is it the first shape, saved into data array
isFirst
)

Inherited from org.apache.poi.hssf.record.AbstractEscherHolderRecord:
addEscherRecordaddEscherRecordclearEscherRecordsconvertRawBytesToEscherRecordsdecodefindFirstWithIdgetEscherContainergetEscherRecordgetEscherRecordsgetGenericChildrengetRawDatajoinprocessContinueRecordsetRawData