ASF Bugzilla – Attachment 5238 Details for
Bug 9576
[PATCH] DBCELL, INDEX EXTSST (was Acess 97 import)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Unified Diff Patch. This doesnt address the concerns that people had with the patch. I will do this shortly
unified_patch.patch (text/plain), 37.63 KB, created by
Jason Height
on 2003-03-10 02:38:34 UTC
(
hide
)
Description:
Unified Diff Patch. This doesnt address the concerns that people had with the patch. I will do this shortly
Filename:
MIME Type:
Creator:
Jason Height
Created:
2003-03-10 02:38:34 UTC
Size:
37.63 KB
patch
obsolete
>Index: src/java/org/apache/poi/hssf/model/Sheet.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/model/Sheet.java,v >retrieving revision 1.24 >diff -w -u -r1.24 Sheet.java >--- src/java/org/apache/poi/hssf/model/Sheet.java 6 Feb 2003 10:29:44 -0000 1.24 >+++ src/java/org/apache/poi/hssf/model/Sheet.java 10 Mar 2003 02:03:50 -0000 >@@ -80,7 +80,7 @@ > * @author Andrew C. Oliver (acoliver at apache dot org) > * @author Glen Stampoultzis (glens at apache.org) > * @author Shawn Laubach (slaubach at apache dot org) Gridlines, Headers, Footers, and PrintSetup >- * @author Jason Height (jheight at chariot dot net dot au) Clone support >+ * @author Jason Height (jheight at chariot dot net dot au) Clone support. DBCell & Index Record writing support > * @author Brian Sanders (kestrel at burdell dot org) Active Cell support > * > * @see org.apache.poi.hssf.model.Workbook >@@ -262,6 +262,18 @@ > { > retval.selection = (SelectionRecord) rec; > } >+ else if (rec.getSid() == DBCellRecord.sid) >+ { >+ //Ignore DBCell record, they are only used during serialization >+ //and arent required for the reading process >+ rec = null; >+ } >+ else if (rec.getSid() == IndexRecord.sid) >+ { >+ //Ignore Index record, they are only used during serialization >+ //and arent required for the reading process >+ rec = null; >+ } > > if (rec != null) > { >@@ -603,6 +615,9 @@ > * Serializes all records in the sheet into one big byte array. Use this to write > * the sheet out. > * >+ * JMH I think that this method (hell maybe all of the serialize's that return a byte array) >+ * can be removed... >+ * > * @return byte[] array containing the binary representation of the records in this sheet > * > */ >@@ -611,7 +626,6 @@ > { > log.log(log.DEBUG, "Sheet.serialize"); > >- // addDBCellRecords(); > byte[] retval = null; > > // ArrayList bytes = new ArrayList(4096); >@@ -651,30 +665,14 @@ > * > */ > >- public int serialize(int offset, byte [] data) >+ public int serialize(final int offset, byte [] data) > { > log.log(log.DEBUG, "Sheet.serialize using offsets"); > >- // addDBCellRecords(); >- // ArrayList bytes = new ArrayList(4096); >- // int arraysize = getSize(); // 0; >- int pos = 0; >- >- // for (int k = 0; k < records.size(); k++) >- // { >- // bytes.add((( Record ) records.get(k)).serialize()); >- // >- // } >- // for (int k = 0; k < bytes.size(); k++) >- // { >- // arraysize += (( byte [] ) bytes.get(k)).length; >- // log.debug((new StringBuffer("arraysize=")).append(arraysize) >- // .toString()); >- // } >+ int pos = offset; >+ boolean serializedIndex = false; > for (int k = 0; k < records.size(); k++) > { >-// byte[] rec = (( byte [] ) bytes.get(k)); >- // System.arraycopy(rec, 0, data, offset + pos, rec.length); > Record record = (( Record ) records.get(k)); > > //uncomment to test record sizes >@@ -684,11 +682,89 @@ > // && record instanceof RowRecordsAggregate == false && record instanceof ValueRecordsAggregate == false) > // throw new RuntimeException("Blah!!!"); > >- pos += record.serialize(pos + offset, data ); // rec.length; >+ //Once the rows have been found in the list of records, start >+ //writing out the blocked row information. This includes the DBCell references >+ if (record instanceof RowRecordsAggregate) { >+ int blockCount = rows.getRowBlockCount(); >+ >+ for (int block=0;block<blockCount;block++) { >+ //Serialize a block of rows. >+ //Hold onto the position of the first row in the block >+ final int rowStartPos = pos; >+ //Hold onto the size of this block that was serialized >+ final int rowBlockSize = rows.serializeRowBlock(block, pos, data); >+ pos += rowBlockSize; >+ //Serialize a block of cells for those rows >+ final int startRowNumber = rows.getStartRowNumberOfBlock(block); >+ final int endRowNumber = rows.getEndRowNumberOfBlock(block); >+ DBCellRecord cellRecord = new DBCellRecord(); >+ //Note: Cell references start from the second row... >+ int cellRefOffset = (rowBlockSize-20); >+ for (int row=startRowNumber;row<=endRowNumber;row++) { >+ if (cells.rowHasCells(row)) { >+ final int rowCellSize = cells.serializeCellRow(row, pos, data); >+ pos += rowCellSize; >+ //Add the offset to the first cell for the row into the DBCellRecord. >+ cellRecord.addCellOffset((short)cellRefOffset); >+ cellRefOffset = rowCellSize; >+ } >+ } >+ //Calculate Offset from the start of a DBCellRecord to the first Row >+ cellRecord.setRowOffset(pos - rowStartPos); >+ //We could add an assert here to check that prior to serialization >+ //that the DBCell position matches the offset calculated by the index record >+ //for this block. Would need to save a reference to the index record to do this. >+ pos += cellRecord.serialize(pos, data); >+ } >+ } else if (record instanceof ValueRecordsAggregate) { >+ //Do nothing here. The records were serialized during the RowRecordAggregate block serialization >+ } else { >+ pos += record.serialize(pos, data ); // rec.length; >+ } > >+ //If the BOF record was just serialized then add the IndexRecord >+ if (record.getSid() == BOFRecord.sid) { >+ //Can there be more than one BOF for a sheet? If not then we can >+ //remove this guard. So be safe it is left here. >+ if (!serializedIndex) { >+ serializedIndex = true; >+ IndexRecord index = new IndexRecord(); >+ index.setFirstRow(rows.getFirstRowNum()); >+ index.setLastRowAdd1(rows.getLastRowNum()+1); >+ //Calculate the size of the records from the end of the BOF >+ //and up to the RowRecordsAggregate... >+ int sheetRecSize = 0; >+ for (int j = k+1; j < records.size(); j++) >+ { >+ Record tmpRec = (( Record ) records.get(j)); >+ if (tmpRec instanceof RowRecordsAggregate) >+ break; >+ sheetRecSize+= tmpRec.getRecordSize(); >+ } >+ //Add the references to the DBCells in the IndexRecord (one for each block) >+ int blockCount = rows.getRowBlockCount(); >+ //Calculate the size of this IndexRecord >+ int indexRecSize = index.getRecordSizeForBlockCount(blockCount); >+ >+ int rowBlockOffset = 0; >+ int cellBlockOffset = 0; >+ int dbCellOffset = 0; >+ for (int block=0;block<blockCount;block++) { >+ rowBlockOffset += rows.getRowBlockSize(block); >+ cellBlockOffset += cells.getRowCellBlockSize(rows.getStartRowNumberOfBlock(block), >+ rows.getEndRowNumberOfBlock(block)); >+ //Note: The offsets are relative to the Workbook BOF. Assume that this is >+ //0 for now..... >+ index.addDbcell(pos + indexRecSize + sheetRecSize + dbCellOffset + rowBlockOffset + cellBlockOffset); >+ //Add space required to write the dbcell record(s) (whose references were just added). >+ dbCellOffset += (8 + (rows.getRowCountForBlock(block) * 2)); >+ } >+ pos += index.serialize(pos, data); >+ } >+ } > } > log.log(log.DEBUG, "Sheet.serialize returning "); >- return pos; >+ return pos-offset; > } > > /** >@@ -1252,118 +1328,6 @@ > } > > /** >- * Not currently used method to calculate and add dbcell records >- * >- */ >- >- public void addDBCellRecords() >- { >- int offset = 0; >- int recnum = 0; >- int rownum = 0; >- //int lastrow = 0; >- //long lastrowoffset = 0; >- IndexRecord index = null; >- >- // ArrayList rowOffsets = new ArrayList(); >- IntList rowOffsets = new IntList(); >- >- for (recnum = 0; recnum < records.size(); recnum++) >- { >- Record rec = ( Record ) records.get(recnum); >- >- if (rec.getSid() == IndexRecord.sid) >- { >- index = ( IndexRecord ) rec; >- } >- if (rec.getSid() != RowRecord.sid) >- { >- offset += rec.serialize().length; >- } >- else >- { >- break; >- } >- } >- >- // First Row Record >- for (; recnum < records.size(); recnum++) >- { >- Record rec = ( Record ) records.get(recnum); >- >- if (rec.getSid() == RowRecord.sid) >- { >- rownum++; >- rowOffsets.add(offset); >- if ((rownum % 32) == 0) >- { >- >- // if this is the last rec in a dbcell block >- // find the next row or last value record >- for (int rn = recnum; rn < records.size(); rn++) >- { >- rec = ( Record ) records.get(rn); >- if ((!rec.isInValueSection()) >- || (rec.getSid() == RowRecord.sid)) >- { >- >- // here is the next row or last value record >- records.add(rn, >- createDBCell(offset, rowOffsets, >- index)); >- recnum = rn; >- break; >- } >- } >- } >- else >- { >- } >- } >- if (!rec.isInValueSection()) >- { >- records.add(recnum, createDBCell(offset, rowOffsets, index)); >- break; >- } >- offset += rec.serialize().length; >- } >- } >- >- /** not currently used */ >- >- private DBCellRecord createDBCell(int offset, IntList rowoffsets, >- IndexRecord index) >- { >- DBCellRecord rec = new DBCellRecord(); >- >- rec.setRowOffset(offset - rowoffsets.get(0)); >- >- // test hack >- rec.addCellOffset(( short ) 0x0); >- >- // end test hack >- addDbCellToIndex(offset, index); >- return rec; >- } >- >- /** not currently used */ >- >- private void addDbCellToIndex(int offset, IndexRecord index) >- { >- int numdbcells = index.getNumDbcells() + 1; >- >- index.addDbcell(offset + preoffset); >- >- // stupid but whenever we add an offset that causes everything to be shifted down 4 >- for (int k = 0; k < numdbcells; k++) >- { >- int dbval = index.getDbcellAt(k); >- >- index.setDbcell(k, dbval + 4); >- } >- } >- >- /** > * creates the BOF record > * @see org.apache.poi.hssf.record.BOFRecord > * @see org.apache.poi.hssf.record.Record >@@ -2058,8 +2022,25 @@ > > for (int k = 0; k < records.size(); k++) > { >+ > retval += (( Record ) records.get(k)).getRecordSize(); > } >+ //Add space for the IndexRecord >+ final int blocks = rows.getRowBlockCount(); >+ retval += IndexRecord.getRecordSizeForBlockCount(blocks); >+ >+ //Add space for the DBCell records >+ //Once DBCell per block. >+ //8 bytes per DBCell (non variable section) >+ //2 bytes per row reference >+ int startRetVal = retval; >+ retval += (8 * blocks); >+ for (Iterator itr = rows.getIterator(); itr.hasNext();) { >+ RowRecord row = (RowRecord)itr.next(); >+ if (cells.rowHasCells(row.getRowNumber())) >+ retval += 2; >+ } >+ > return retval; > } > >@@ -2303,6 +2284,9 @@ > m.setMargin( size ); > } > >+ /** Returns the end record number of the list that were processed when the sheet was >+ * created from the list of records. >+ */ > public int getEofLoc() > { > return eofLoc; >Index: src/java/org/apache/poi/hssf/model/Workbook.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/model/Workbook.java,v >retrieving revision 1.25 >diff -w -u -r1.25 Workbook.java >--- src/java/org/apache/poi/hssf/model/Workbook.java 6 Feb 2003 10:29:44 -0000 1.25 >+++ src/java/org/apache/poi/hssf/model/Workbook.java 10 Mar 2003 02:03:59 -0000 >@@ -133,6 +133,7 @@ > protected int numfonts = 0; // hold the number of font records > private short maxformatid = -1; // holds the max format id > private boolean uses1904datewindowing = false; // whether 1904 date windowing is being used >+ protected int eofLoc = 0; > > private static POILogger log = POILogFactory.getLogger(Workbook.class); > >@@ -166,11 +167,11 @@ > > if (rec.getSid() == EOFRecord.sid) { > records.add(rec); >+ retval.eofLoc = k; > log.log(DEBUG, "found workbook eof record at " + k); > break; > } > switch (rec.getSid()) { >- > case BoundSheetRecord.sid : > log.log(DEBUG, "found boundsheet record at " + k); > retval.boundsheets.add(rec); >@@ -233,8 +234,13 @@ > case PaletteRecord.sid: > log.log(DEBUG, "found palette record at " + k); > retval.records.setPalettepos( k ); >+ break; >+ case ExtSSTRecord.sid: >+ rec = null; >+ break; > default : > } >+ if (rec != null) > records.add(rec); > } > //What if we dont have any ranges and supbooks >@@ -256,6 +262,7 @@ > { > log.log( DEBUG, "creating new workbook from scratch" ); > Workbook retval = new Workbook(); >+ > ArrayList records = new ArrayList( 30 ); > ArrayList formats = new ArrayList( 8 ); > >@@ -697,6 +704,18 @@ > Record record = records.get(k); > // Let's skip RECALCID records, as they are only use for optimization > if(record.getSid() != RecalcIdRecord.sid || ((RecalcIdRecord)record).isNeeded()) { >+ if (record.getSid() == SSTRecord.sid) { >+ SSTRecord sstRec = (SSTRecord)record; >+ //The ExtSSTRecord is written directly after the SSTRecord. >+ //The ExtSSTRecord info records are created within the SST serialization >+ //process. >+ //If the bucket size for the ExtSSTRecord is set to anything >+ //other than the default make sure that both the bucket size >+ //here and in the serialize method are the same. >+ ExtSSTRecord extSSTRec = new ExtSSTRecord(); >+ pos += sstRec.serialize(pos + offset, data, extSSTRec); >+ pos += extSSTRec.serialize(pos + offset, data); >+ } else > pos += record.serialize(pos + offset, data); // rec.length; > } > } >@@ -711,6 +730,13 @@ > Record record = records.get(k); > // Let's skip RECALCID records, as they are only use for optimization > if(record.getSid() != RecalcIdRecord.sid || ((RecalcIdRecord)record).isNeeded()) { >+ if (record.getSid() == SSTRecord.sid) { >+ //Include the size to write the ExtSSTRecord. >+ //If the bucket size for the ExtSSTRecord is set to anything >+ //other than the default make sure that both the bucket size >+ //here and in the serialize method are the same. >+ retval += new ExtSSTRecord().getRecordSizeForSST(((SSTRecord)record).getNumUniqueStrings()); >+ } > retval += record.getRecordSize(); > } > } >@@ -1965,6 +1991,15 @@ > return records.getRecords(); > } > >+ /** Returns the end record number of the list that were processed when the sheet was >+ * created from the list of records. >+ */ >+ public int getEofLoc() >+ { >+ return eofLoc; >+ } >+ >+ > // public void insertChartRecords( List chartRecords ) > // { > // backuppos += chartRecords.size(); >Index: src/java/org/apache/poi/hssf/record/DBCellRecord.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/DBCellRecord.java,v >retrieving revision 1.4 >diff -w -u -r1.4 DBCellRecord.java >--- src/java/org/apache/poi/hssf/record/DBCellRecord.java 21 Aug 2002 11:56:49 -0000 1.4 >+++ src/java/org/apache/poi/hssf/record/DBCellRecord.java 10 Mar 2003 02:04:14 -0000 >@@ -58,10 +58,11 @@ > import org.apache.poi.util.LittleEndian; > > /** >- * Title: DBCell Record (Currently read only. Not required.) >- * Description: Used to find rows in blocks...TODO<P> >+ * Title: DBCell Record >+ * Description: Used to find rows in blocks.<P> > * REFERENCE: PG 299/440 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> > * @author Andrew C. Oliver (acoliver at apache dot org) >+ * @author Jason Height (jheight at chariot dot net dot au) > * @version 2.0-pre > */ > >@@ -71,6 +72,7 @@ > public final static short sid = 0xd7; > private int field_1_row_offset; > private short[] field_2_cell_offsets; >+ public final static int BLOCK_SIZE = 32; > > public DBCellRecord() > { >@@ -217,9 +219,15 @@ > LittleEndian.putInt(data, 4 + offset, getRowOffset()); > for (int k = 0; k < getNumCellOffsets(); k++) > { >- LittleEndian.putShort(data, 8 + k + offset, getCellOffsetAt(k)); >+ LittleEndian.putShort(data, 8 + 2*k + offset, getCellOffsetAt(k)); > } > return getRecordSize(); >+ } >+ >+ /** Returns the size of the record when it needs to reference a certain >+ * number of rows */ >+ public static int getRecordSizeForRows(int rows) { >+ return 8 + (rows * 2); > } > > public int getRecordSize() >Index: src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java,v >retrieving revision 1.1.1.1 >diff -w -u -r1.1.1.1 ExtSSTInfoSubRecord.java >--- src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java 31 Jan 2002 02:23:42 -0000 1.1.1.1 >+++ src/java/org/apache/poi/hssf/record/ExtSSTInfoSubRecord.java 10 Mar 2003 02:04:17 -0000 >@@ -65,8 +65,8 @@ > /** > * Extended SST table info subrecord<P> > * contains the elements of "info" in the SST's array field<P> >- * WE HAVE VERY LITTLE INFORMATION ON HOW TO IMPLEMENT THIS RECORD! (EXTSSST)<P> > * @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.ExtSSTRecord > */ >Index: src/java/org/apache/poi/hssf/record/ExtSSTRecord.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/ExtSSTRecord.java,v >retrieving revision 1.2 >diff -w -u -r1.2 ExtSSTRecord.java >--- src/java/org/apache/poi/hssf/record/ExtSSTRecord.java 11 Feb 2002 03:49:39 -0000 1.2 >+++ src/java/org/apache/poi/hssf/record/ExtSSTRecord.java 10 Mar 2003 02:04:17 -0000 >@@ -61,13 +61,14 @@ > > /** > * Title: Extended Static String Table<P> >- * Description: I really don't understand this thing... its supposed to be "a hash >- * table for optimizing external copy operations" -- >- *<P> >- * This sounds like a job for Marc "BitMaster" Johnson aka the >- * "Hawaiian Master Chef".<P> >+ * Description: This record is used for a quick lookup into the SST record. This >+ * record breaks the SST table into a set of buckets. The offsets >+ * to these buckets within the SST record are kept as well as the >+ * position relative to the start of the SST record. >+ * > * REFERENCE: PG 313 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> > * @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.ExtSSTInfoSubRecord > */ >@@ -75,8 +76,9 @@ > public class ExtSSTRecord > extends Record > { >+ public static final int DEFAULT_BUCKET_SIZE = 8; > public final static short sid = 0xff; >- private short field_1_strings_per_bucket; >+ private short field_1_strings_per_bucket = DEFAULT_BUCKET_SIZE; > private ArrayList field_2_sst_info; > > public ExtSSTRecord() >@@ -119,12 +121,11 @@ > } > } > >- // this probably doesn't work but we don't really care at this point > protected void fillFields(byte [] data, short size, int offset) > { > field_2_sst_info = new ArrayList(); > field_1_strings_per_bucket = LittleEndian.getShort(data, 0 + offset); >- for (int k = 2; k < ((data.length - offset) - size); k += 8) >+ for (int k = 2; k < (size-offset); k += 8) > { > byte[] tempdata = new byte[ 8 + offset ]; > >@@ -146,6 +147,15 @@ > field_2_sst_info.add(rec); > } > >+ public void addInfoRecord(int streamPos, short sstOffset) >+ { >+ ExtSSTInfoSubRecord rec = new ExtSSTInfoSubRecord(); >+ rec.setStreamPos(streamPos); >+ rec.setBucketSSTOffset(sstOffset); >+ addInfoRecord(rec); >+ } >+ >+ > public short getNumStringsPerBucket() > { > return field_1_strings_per_bucket; >@@ -189,22 +199,28 @@ > public int serialize(int offset, byte [] data) > { > LittleEndian.putShort(data, 0 + offset, sid); >+ LittleEndian.putShort(data, 2 + offset, ( short ) (getRecordSize() - 4)); > >-// LittleEndian.putShort(data,2,(short)(2 + (getNumInfoRecords() *8))); >- LittleEndian.putShort(data, 2 + offset, ( short ) (2 + (0x3fa - 2))); >- int pos = 4; >- >+ LittleEndian.putShort(data, 4 + offset, ( short ) field_1_strings_per_bucket); >+ int pos = 6; > for (int k = 0; k < getNumInfoRecords(); k++) > { >- System.arraycopy(getInfoRecordAt(k).serialize(), 0, data, >- pos + offset, 8); >+ ExtSSTInfoSubRecord rec = getInfoRecordAt(k); >+ pos += rec.serialize(pos + offset, data); > } >- return getRecordSize(); >+ return pos; >+ } >+ >+ public int getRecordSizeForSST(int numUniqueStrings) { >+ int infoRecs = (numUniqueStrings/field_1_strings_per_bucket); >+ if ((numUniqueStrings % field_1_strings_per_bucket) != 0) >+ infoRecs ++; >+ return 6 + 8*infoRecs; > } > > public int getRecordSize() > { >- return 6 + 0x3fa - 2; >+ return 6 + 8*getNumInfoRecords(); > } > > public short getSid() >Index: src/java/org/apache/poi/hssf/record/IndexRecord.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/IndexRecord.java,v >retrieving revision 1.3 >diff -w -u -r1.3 IndexRecord.java >--- src/java/org/apache/poi/hssf/record/IndexRecord.java 5 Sep 2002 00:26:23 -0000 1.3 >+++ src/java/org/apache/poi/hssf/record/IndexRecord.java 10 Mar 2003 02:04:25 -0000 >@@ -62,7 +62,7 @@ > * Title: Index Record<P> > * Description: Occurs right after BOF, tells you where the DBCELL records are for a sheet > * Important for locating cells<P> >- * NOT USED IN THIS RELEASE >+ * > * REFERENCE: PG 323 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P> > * @author Andrew C. Oliver (acoliver at apache dot org) > * @author Jason Height (jheight at chariot dot net dot au) >@@ -215,6 +215,13 @@ > LittleEndian.putInt(data, (k * 4) + 20 + offset, getDbcellAt(k)); > } > return getRecordSize(); >+ } >+ >+ /** Returns the size of the IndexRecord given a number >+ * of block (ie DBCell) references >+ */ >+ public static int getRecordSizeForBlockCount(int blockCount) { >+ return 20 + (4 * blockCount); > } > > public int getRecordSize() >Index: src/java/org/apache/poi/hssf/record/RecordFactory.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/RecordFactory.java,v >retrieving revision 1.13 >diff -w -u -r1.13 RecordFactory.java >--- src/java/org/apache/poi/hssf/record/RecordFactory.java 28 Nov 2002 19:20:36 -0000 1.13 >+++ src/java/org/apache/poi/hssf/record/RecordFactory.java 10 Mar 2003 02:04:34 -0000 >@@ -249,6 +249,7 @@ > Constructor constructor = > ( Constructor ) recordsMap.get(new Short(rectype)); > >+ > if (constructor != null) > { > retval = ( Record ) constructor.newInstance(new Object[] >@@ -277,10 +278,6 @@ > num.setXFIndex(rk.getXFIndex()); > num.setValue(rk.getRKNumber()); > retval = num; >- } >- else if (retval instanceof DBCellRecord) >- { >- retval = null; > } > else if (retval instanceof MulRKRecord) > { >Index: src/java/org/apache/poi/hssf/record/SSTRecord.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/SSTRecord.java,v >retrieving revision 1.5 >diff -w -u -r1.5 SSTRecord.java >--- src/java/org/apache/poi/hssf/record/SSTRecord.java 17 Jul 2002 14:18:03 -0000 1.5 >+++ src/java/org/apache/poi/hssf/record/SSTRecord.java 10 Mar 2003 02:04:39 -0000 >@@ -512,10 +512,16 @@ > > public int serialize( int offset, byte[] data ) > { >+ return this.serialize(offset, data, null); >+ } >+ >+ public int serialize( int offset, byte[] data, ExtSSTRecord extSST) >+ { > SSTSerializer serializer = new SSTSerializer( > _record_lengths, field_3_strings, getNumStrings(), getNumUniqueStrings() ); >- return serializer.serialize( getRecordSize(), offset, data ); >+ return serializer.serialize( getRecordSize(), offset, data , extSST ); > } >+ > > > public int getRecordSize() >Index: src/java/org/apache/poi/hssf/record/SSTSerializer.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/SSTSerializer.java,v >retrieving revision 1.5 >diff -w -u -r1.5 SSTSerializer.java >--- src/java/org/apache/poi/hssf/record/SSTSerializer.java 17 Jul 2002 14:18:03 -0000 1.5 >+++ src/java/org/apache/poi/hssf/record/SSTSerializer.java 10 Mar 2003 02:04:39 -0000 >@@ -97,14 +97,14 @@ > * > * @return the byte array > */ >- public int serialize( int record_size, int offset, byte[] data ) >+ public int serialize( int record_size, int offset, byte[] data, ExtSSTRecord extSST ) > { > int record_length_index = 0; > > if ( calculateUnicodeSize() > SSTRecord.MAX_DATA_SPACE ) >- serializeLargeRecord( record_size, record_length_index, data, offset ); >+ serializeLargeRecord( record_size, record_length_index, data, offset, extSST ); > else >- serializeSingleSSTRecord( data, offset, record_length_index ); >+ serializeSingleSSTRecord( data, offset, record_length_index, extSST ); > return record_size; > } > >@@ -135,7 +135,7 @@ > * This case is chosen when an SST record does not span over to a continue record. > * > */ >- private void serializeSingleSSTRecord( byte[] data, int offset, int record_length_index ) >+ private void serializeSingleSSTRecord( byte[] data, final int offset, int record_length_index, ExtSSTRecord extSST ) > { > int len = ( (Integer) recordLengths.get( record_length_index ) ).intValue(); > int recordSize = SSTRecord.SST_RECORD_OVERHEAD + len - SSTRecord.STD_RECORD_OVERHEAD; >@@ -144,6 +144,10 @@ > > for ( int k = 0; k < strings.size(); k++ ) > { >+ if ((extSST != null) && ((k % extSST.getNumStringsPerBucket()) ==0)) { >+ extSST.addInfoRecord(pos+offset, (short)(pos)); >+ } >+ > System.arraycopy( getUnicodeString( k ).serialize(), 0, data, pos + offset, getUnicodeString( k ).getRecordSize() ); > pos += getUnicodeString( k ).getRecordSize(); > } >@@ -154,7 +158,7 @@ > * characteristic that they can change the option field when a single string is split across to a > * CONTINUE record. > */ >- private void serializeLargeRecord( int record_size, int record_length_index, byte[] buffer, int offset ) >+ private void serializeLargeRecord( int record_size, int record_length_index, byte[] buffer, final int offset, ExtSSTRecord extSST ) > { > > byte[] stringReminant = null; >@@ -187,6 +191,9 @@ > // some more strings > for ( ; stringIndex < strings.size(); stringIndex++ ) > { >+ if ((extSST != null) && ((stringIndex % extSST.getNumStringsPerBucket()) ==0)) { >+ extSST.addInfoRecord(totalWritten, (short)(totalWritten-offset)); >+ } > UnicodeString unistr = getUnicodeString( stringIndex ); > > if ( unistr.getRecordSize() <= recordProcessor.getAvailable() ) >Index: src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java,v >retrieving revision 1.4 >diff -w -u -r1.4 RowRecordsAggregate.java >--- src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java 5 Sep 2002 00:26:26 -0000 1.4 >+++ src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java 10 Mar 2003 02:04:49 -0000 >@@ -55,6 +55,7 @@ > > package org.apache.poi.hssf.record.aggregates; > >+import org.apache.poi.hssf.record.DBCellRecord; > import org.apache.poi.hssf.record.Record; > import org.apache.poi.hssf.record.RowRecord; > import org.apache.poi.hssf.record.UnknownRecord; >@@ -134,6 +135,84 @@ > { > return lastrow; > } >+ >+ /** Returns the number of row blocks. >+ * The row blocks are groupings of rows that contain the DBCell record >+ * at the end of them. >+ */ >+ public int getRowBlockCount() { >+ int size = records.size()/DBCellRecord.BLOCK_SIZE; >+ if ((records.size() % DBCellRecord.BLOCK_SIZE) != 0) >+ size ++; >+ return size; >+ } >+ >+ /** Returns the size of the row records for a given block*/ >+ public int getRowBlockSize(int block) { >+ return 20 * getRowCountForBlock(block); >+ } >+ >+ /** Returns the number of physical rows within a block*/ >+ public int getRowCountForBlock(int block) { >+ int startIndex = block * DBCellRecord.BLOCK_SIZE; >+ int endIndex = startIndex + DBCellRecord.BLOCK_SIZE - 1; >+ if (endIndex >= records.size()) >+ endIndex = records.size()-1; >+ >+ return endIndex-startIndex+1; >+ } >+ >+ /** Returns the physical row number of the first row in a block*/ >+ public int getStartRowNumberOfBlock(int block) { >+ //Damn! I would like to directly index a record in the map rather than >+ //iterating through it. >+ int startIndex = block * DBCellRecord.BLOCK_SIZE; >+ Iterator rowIter = records.values().iterator(); >+ RowRecord row = null; >+ //Position the iterator at the start of the block >+ for (int i=0; i<=startIndex;i++) { >+ row = (RowRecord)rowIter.next(); >+ } >+ >+ return row.getRowNumber(); >+ } >+ >+ /** Returns the physical row number of the end row in a block*/ >+ public int getEndRowNumberOfBlock(int block) { >+ //Damn! I would like to directly index a record in the map rather than >+ //iterating through it. >+ int endIndex = ((block + 1)*DBCellRecord.BLOCK_SIZE)-1; >+ if (endIndex >= records.size()) >+ endIndex = records.size()-1; >+ >+ Iterator rowIter = records.values().iterator(); >+ RowRecord row = null; >+ for (int i=0; i<=endIndex;i++) { >+ row = (RowRecord)rowIter.next(); >+ } >+ return row.getRowNumber(); >+ } >+ >+ /** Serializes a block of rows */ >+ public int serializeRowBlock(int block, int offset, byte [] data) >+ { >+ int startIndex = block * DBCellRecord.BLOCK_SIZE; >+ int endIndex = startIndex + DBCellRecord.BLOCK_SIZE; >+ >+ Iterator itr = records.values().iterator(); >+ int pos = offset; >+ >+ int i=0; >+ for (; i<startIndex;i++) >+ itr.next(); >+ while (itr.hasNext() && (i++ < endIndex)) >+ { >+ pos += (( Record ) itr.next()).serialize(pos, data); >+ } >+ return pos - offset; >+ } >+ >+ > > public int construct(int offset, List records) > { >Index: src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java,v >retrieving revision 1.6 >diff -w -u -r1.6 ValueRecordsAggregate.java >--- src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java 5 Sep 2002 00:26:26 -0000 1.6 >+++ src/java/org/apache/poi/hssf/record/aggregates/ValueRecordsAggregate.java 10 Mar 2003 02:04:51 -0000 >@@ -134,6 +134,52 @@ > return lastcell; > } > >+ /** Tallies a count of the size of the cell records >+ * that are attached to the rows in the range specified. >+ */ >+ public int getRowCellBlockSize(int startRow, int endRow) { >+ //DAMN! It would be nice to be able to get a set of cells for a given row... >+ Iterator cellRec = records.values().iterator(); >+ int size = 0; >+ while (cellRec.hasNext()) { >+ CellValueRecordInterface cell = (CellValueRecordInterface)cellRec.next(); >+ int row = cell.getRow(); >+ if ((row >=startRow) && (row <= endRow)) >+ size += ((Record)cell).getRecordSize(); >+ } >+ return size; >+ } >+ >+ /** Returns true if the row has cells attached to it */ >+ public boolean rowHasCells(int row) { >+ //DAMN! It would be nice to be able to get a set of cells for a given row... >+ Iterator cellRec = records.values().iterator(); >+ int size = 0; >+ while (cellRec.hasNext()) { >+ CellValueRecordInterface cell = (CellValueRecordInterface)cellRec.next(); >+ if (row ==cell.getRow()) >+ return true; >+ } >+ return false; >+ } >+ >+ /** Serializes the cells that are allocated to a certain row range*/ >+ public int serializeCellRow(final int row, int offset, byte [] data) >+ { >+ //DAMN! It would be nice to be able to get a set of cells for a given row... >+ Iterator itr = records.values().iterator(); >+ int pos = offset; >+ >+ while (itr.hasNext()) >+ { >+ CellValueRecordInterface cell = (CellValueRecordInterface)itr.next(); >+ if (row == cell.getRow()) { >+ pos += (( Record ) cell).serialize(pos, data); >+ } >+ } >+ return pos - offset; >+ } >+ > public int construct(int offset, List records) > { > int k = 0; >Index: src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java,v >retrieving revision 1.19 >diff -w -u -r1.19 HSSFSheet.java >Index: src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java,v >retrieving revision 1.20 >diff -w -u -r1.20 HSSFWorkbook.java >--- src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java 6 Feb 2003 10:29:45 -0000 1.20 >+++ src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java 10 Mar 2003 02:05:07 -0000 >@@ -192,7 +192,7 @@ > > workbook = Workbook.createWorkbook(records); > setPropertiesFromWorkbook(workbook); >- int recOffset = workbook.getNumRecords(); >+ int recOffset = workbook.getEofLoc()+1; > int sheetNum = 0; > > while (recOffset < records.size()) >Index: src/java/org/apache/poi/hssf/util/Region.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/util/Region.java,v >retrieving revision 1.2 >diff -w -u -r1.2 Region.java >--- src/java/org/apache/poi/hssf/util/Region.java 11 Feb 2002 10:45:51 -0000 1.2 >+++ src/java/org/apache/poi/hssf/util/Region.java 10 Mar 2003 02:05:09 -0000 >@@ -55,7 +55,7 @@ > > package org.apache.poi.hssf.util; > >-import org.apache.poi.hssf.record.MergeCellsRecord.MergedRegion; >+import org.apache.poi.hssf.record.MergeCellsRecord; > > /** > * Represents a from/to row/col square. This is a object primitive >@@ -94,7 +94,7 @@ > * okay) that makes a region from a mergedcells's region subrecord. > */ > >- public Region(MergedRegion region) >+ public Region(MergeCellsRecord.MergedRegion region) > { > this(region.row_from, region.col_from, region.row_to, region.col_to); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 9576
:
4661
|
4717
| 5238 |
6514
|
6515