Class EscherAggregate
- All Implemented Interfaces:
Duplicatable,GenericRecord
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
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEscherAggregate(boolean createDefaultTree) create new EscherAggregateEscherAggregate(EscherAggregate other) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTailRecord(NoteRecord note) Add tail record to existing mapvoidassociateShapeToObjRecord(EscherRecord r, Record objRecord) Associates an escher record to an OBJ record or a TXO record.copy()static EscherAggregatecreateAggregate(List<RecordBase> records, int locFirstDrawingRecord) Collapses the drawing records into an aggregate.static intprotected Stringintgives the current serialized size of the record.shortgetSid()return the non static version of the id for this record.voidRemove echerRecord and associated to it Obj or TextObj recordvoidremoveTailRecord(NoteRecord note) Remove tail record from the existing mapintserialize(int offset, byte[] data) Serializes this aggregate to a byte array.voidsetDgId(short dgId) EscherDgContainer -EscherSpgrContainer -EscherDgRecord - set id for this record set id for DgRecord of DgContainervoidsetMainSpRecordId(int shapeId) EscherDgContainer -EscherSpgrContainer --EscherSpContainer ---EscherSpRecord -set id for this record ---*** --*** -EscherDgRecord set id for the sp record of the first spContainer in main spgrConatinerstatic voidsetMaxRecordLength(int length) Calculates the xml representation of this record.Methods inherited from class org.apache.poi.hssf.record.AbstractEscherHolderRecord
addEscherRecord, addEscherRecord, clearEscherRecords, decode, findFirstWithId, getEscherContainer, getEscherRecord, getEscherRecords, getGenericChildren, getRawData, join, processContinueRecord, setRawDataMethods inherited from class org.apache.poi.hssf.record.Record
cloneViaReserialise, serialize, toString
-
Field Details
-
sid
public static final short sid- See Also:
-
-
Constructor Details
-
EscherAggregate
public EscherAggregate(boolean createDefaultTree) create new EscherAggregate- Parameters:
createDefaultTree- if true creates base tree of the escher records, see EscherAggregate.buildBaseTree() else return empty escher aggregate
-
EscherAggregate
-
-
Method Details
-
setMaxRecordLength
public static void setMaxRecordLength(int length) - Parameters:
length- the max record length allowed for EscherAggregate
-
getMaxRecordLength
public static int getMaxRecordLength()- Returns:
- the max record length allowed for EscherAggregate
-
getSid
public short getSid()Description copied from class:Recordreturn the non static version of the id for this record.- Specified by:
getSidin classAbstractEscherHolderRecord- Returns:
- Returns the current sid.
-
toXml
Calculates the xml representation of this record. This is simply a dump of all the records.- Parameters:
tab- - string which must be added before each line (used by default '\t')- Returns:
- xml representation of the all aggregated records
-
createAggregate
Collapses the drawing records into an aggregate. read Drawing, Obj, TxtObj, Note and Continue records into single byte array, create Escher tree from byte array, create map <EscherRecord, Record>- Parameters:
records- - list of all records inside sheetlocFirstDrawingRecord- - location of the first DrawingRecord inside sheet- Returns:
- new EscherAggregate create from all aggregated records which belong to drawing layer
-
serialize
public int serialize(int offset, byte[] data) Serializes this aggregate to a byte array. Since this is an aggregate record it will effectively serialize the aggregated records.- Overrides:
serializein classAbstractEscherHolderRecord- Parameters:
offset- The offset into the start of the array.data- The byte array to serialize to.- Returns:
- The number of bytes serialized.
-
getRecordSize
public int getRecordSize()Description copied from class:RecordBasegives the current serialized size of the record. Should include the sid and reclength (4 bytes).- Overrides:
getRecordSizein classAbstractEscherHolderRecord- Returns:
- record size, including header size of obj, text, note, drawing, continue records
-
associateShapeToObjRecord
Associates an escher record to an OBJ record or a TXO record.- Parameters:
r- - ClientData or Textbox recordobjRecord- - Obj or TextObj record
-
removeShapeToObjRecord
Remove echerRecord and associated to it Obj or TextObj record- Parameters:
rec- - clientData or textbox record to be removed
-
getRecordName
- Specified by:
getRecordNamein classAbstractEscherHolderRecord- Returns:
- "ESCHERAGGREGATE"
-
setDgId
public void setDgId(short dgId) EscherDgContainer -EscherSpgrContainer -EscherDgRecord - set id for this record set id for DgRecord of DgContainer- Parameters:
dgId- - id which must be set
-
setMainSpRecordId
public void setMainSpRecordId(int shapeId) EscherDgContainer -EscherSpgrContainer --EscherSpContainer ---EscherSpRecord -set id for this record ---*** --*** -EscherDgRecord set id for the sp record of the first spContainer in main spgrConatiner- Parameters:
shapeId- - id which must be set
-
getShapeToObjMapping
- Returns:
- unmodifiable copy of the mapping of
EscherClientDataRecordandEscherTextboxRecordto theirTextObjectRecordorObjRecord.We need to access it outside of EscherAggregate when building shapes
-
getTailRecords
- 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.
-
getNoteRecordByObj
- Parameters:
obj- - ObjRecord with id == NoteRecord.id- Returns:
- null if note record is not found else returns note record with id == obj.id
-
addTailRecord
Add tail record to existing map- Parameters:
note- to be added
-
removeTailRecord
Remove tail record from the existing map- Parameters:
note- to be removed
-
copy
- Specified by:
copyin interfaceDuplicatable- Specified by:
copyin classAbstractEscherHolderRecord- Returns:
- a deep copy of the implementing class / instance
-
getGenericRecordType
- Specified by:
getGenericRecordTypein interfaceGenericRecord- Specified by:
getGenericRecordTypein classRecord
-
getGenericProperties
-