View | Details | Raw Unified | Return to bug 8114
Collapse All | Expand All

(-)Workbook.java (-439 / +541 lines)
Lines 85-146 Link Here
85
 * @version 1.0-pre
85
 * @version 1.0-pre
86
 */
86
 */
87
87
88
public class Workbook
88
public class Workbook {
89
{
90
    private static final int   DEBUG       = POILogger.DEBUG;
89
    private static final int   DEBUG       = POILogger.DEBUG;
91
90
    
92
    /**
91
    /**
93
     * constant used to set the "codepage" wherever "codepage" is set in records
92
     * constant used to set the "codepage" wherever "codepage" is set in records
94
     * (which is duplciated in more than one record)
93
     * (which is duplciated in more than one record)
95
     */
94
     */
96
95
    
97
    private final static short CODEPAGE    = ( short ) 0x4b0;
96
    private final static short CODEPAGE    = ( short ) 0x4b0;
98
97
    
99
    /**
98
    /**
100
     * this contains the Worksheet record objects
99
     * this contains the Worksheet record objects
101
     */
100
     */
102
101
    
103
    protected ArrayList        records     = null;
102
    protected ArrayList        records     = null;
104
103
    
105
    /**
104
    /**
106
     * this contains a reference to the SSTRecord so that new stings can be added
105
     * this contains a reference to the SSTRecord so that new stings can be added
107
     * to it.
106
     * to it.
108
     */
107
     */
109
108
    
110
    protected SSTRecord        sst         = null;
109
    protected SSTRecord        sst         = null;
111
110
    
111
    /**
112
     * Holds the Extern Sheet with referenced to bound sheets
113
     */
114
    
115
    protected ExternSheetRecord externSheet= null;
116
    
112
    /**
117
    /**
113
     * holds the "boundsheet" records (aka bundlesheet) so that they can have their
118
     * holds the "boundsheet" records (aka bundlesheet) so that they can have their
114
     * reference to their "BOF" marker
119
     * reference to their "BOF" marker
115
     */
120
     */
116
121
    
122
    
117
    protected ArrayList        boundsheets = new ArrayList();
123
    protected ArrayList        boundsheets = new ArrayList();
124
    
125
    protected ArrayList        names = new ArrayList();
126
    
118
    protected int              bspos       =
127
    protected int              bspos       =
119
        0;   // holds the position of the last bound sheet.
128
    0;   // holds the position of the last bound sheet.
120
    protected int              tabpos      =
129
    protected int              tabpos      =
121
        0;   // holds the position of the tabid record
130
    0;   // holds the position of the tabid record
122
    protected int              fontpos     =
131
    protected int              fontpos     =
123
        0;   // hold the position of the last font record
132
    0;   // hold the position of the last font record
124
    protected int              numfonts    =
133
    protected int              numfonts    =
125
        0;   // hold the number of font records
134
    0;   // hold the number of font records
126
    protected int              xfpos       =
135
    protected int              xfpos       =
127
        0;   // hold the position of the last extended font record
136
    0;   // hold the position of the last extended font record
128
    protected int              numxfs      =
137
    protected int              numxfs      =
129
        0;   // hold the number of extended format records
138
    0;   // hold the number of extended format records
130
    private int                backuppos   =
139
    private int                backuppos   =
131
        0;   // holds the position of the backup record.
140
    0;   // holds the position of the backup record.
141
    private int                namepos   =
142
    0;   // holds the position of last name record
143
    private int                supbookpos   =
144
    0;   // holds the position of sup book
145
    
132
    private static POILogger   log         =
146
    private static POILogger   log         =
133
        POILogFactory.getLogger(Workbook.class);
147
    POILogFactory.getLogger(Workbook.class);
134
148
    
135
    /**
149
    /**
136
     * Creates new Workbook with no intitialization --useless right now
150
     * Creates new Workbook with no intitialization --useless right now
137
     * @see #createWorkbook(List)
151
     * @see #createWorkbook(List)
138
     */
152
     */
139
153
    
140
    public Workbook()
154
    public Workbook() {
141
    {
142
    }
155
    }
143
156
    
144
    /**
157
    /**
145
     * read support  for low level
158
     * read support  for low level
146
     * API.  Pass in an array of Record objects, A Workbook
159
     * API.  Pass in an array of Record objects, A Workbook
Lines 153-232 Link Here
153
     * @param recs an array of Record objects
166
     * @param recs an array of Record objects
154
     * @return Workbook object
167
     * @return Workbook object
155
     */
168
     */
156
169
    
157
    public static Workbook createWorkbook(List recs)
170
    public static Workbook createWorkbook(List recs) {
158
    {
159
        log.log(DEBUG, "Workbook (readfile) created with reclen=",
171
        log.log(DEBUG, "Workbook (readfile) created with reclen=",
160
                new Integer(recs.size()));
172
        new Integer(recs.size()));
161
        Workbook  retval  = new Workbook();
173
        Workbook  retval  = new Workbook();
162
        ArrayList records = new ArrayList(recs.size() / 3);
174
        ArrayList records = new ArrayList(recs.size() / 3);
163
175
        
164
        for (int k = 0; k < recs.size(); k++)
176
        for (int k = 0; k < recs.size(); k++) {
165
        {
166
            Record rec = ( Record ) recs.get(k);
177
            Record rec = ( Record ) recs.get(k);
167
178
            
168
            if (rec.getSid() == EOFRecord.sid)
179
            if (rec.getSid() == EOFRecord.sid) {
169
            {
170
                records.add(rec);
180
                records.add(rec);
171
                log.log(DEBUG, "found workbook eof record at " + k);
181
                log.log(DEBUG, "found workbook eof record at " + k);
172
                break;
182
                break;
173
            }
183
            }
174
            switch (rec.getSid())
184
            switch (rec.getSid()) {
175
            {
185
                
176
177
                case BoundSheetRecord.sid :
186
                case BoundSheetRecord.sid :
178
                    log.log(DEBUG, "found boundsheet record at " + k);
187
                    log.log(DEBUG, "found boundsheet record at " + k);
179
                    retval.boundsheets.add(rec);
188
                    retval.boundsheets.add(rec);
180
                    retval.bspos = k;
189
                    retval.bspos = k;
181
                    break;
190
                    break;
182
191
                    
183
                case SSTRecord.sid :
192
                case SSTRecord.sid :
184
                    log.log(DEBUG, "found sst record at " + k);
193
                    log.log(DEBUG, "found sst record at " + k);
185
                    retval.sst = ( SSTRecord ) rec;
194
                    retval.sst = ( SSTRecord ) rec;
186
                    break;
195
                    break;
187
196
                    
188
                case FontRecord.sid :
197
                case FontRecord.sid :
189
                    log.log(DEBUG, "found font record at " + k);
198
                    log.log(DEBUG, "found font record at " + k);
190
                    retval.fontpos = k;
199
                    retval.fontpos = k;
191
                    retval.numfonts++;
200
                    retval.numfonts++;
192
                    break;
201
                    break;
193
202
                    
194
                case ExtendedFormatRecord.sid :
203
                case ExtendedFormatRecord.sid :
195
                    log.log(DEBUG, "found XF record at " + k);
204
                    log.log(DEBUG, "found XF record at " + k);
196
                    retval.xfpos = k;
205
                    retval.xfpos = k;
197
                    retval.numxfs++;
206
                    retval.numxfs++;
198
                    break;
207
                    break;
199
208
                    
200
                case TabIdRecord.sid :
209
                case TabIdRecord.sid :
201
                    log.log(DEBUG, "found tabid record at " + k);
210
                    log.log(DEBUG, "found tabid record at " + k);
202
                    retval.tabpos = k;
211
                    retval.tabpos = k;
203
                    break;
212
                    break;
204
213
                    
205
                case BackupRecord.sid :
214
                case BackupRecord.sid :
206
                    log.log(DEBUG, "found backup record at " + k);
215
                    log.log(DEBUG, "found backup record at " + k);
207
                    retval.backuppos = k;
216
                    retval.backuppos = k;
208
                    break;
217
                    break;
209
218
                case ExternSheetRecord.sid :
219
                    log.log(DEBUG, "found extern sheet record at " + k);
220
                    retval.externSheet = ( ExternSheetRecord ) rec;
221
                    break;
222
                case NameRecord.sid :
223
                    log.log(DEBUG, "found name record at " + k);
224
                    retval.names.add(rec);
225
                    retval.namepos = k;
226
                    break;
227
                case 0x1AE :
228
                    //Havent Implement the sup book , because we dont need extern ranges
229
                    //for now
230
                    log.log(DEBUG, "found SupBook record at " + k);
231
                    retval.supbookpos = k;
232
                    break;
233
                    
210
                default :
234
                default :
211
            }
235
            }
212
            records.add(rec);
236
            records.add(rec);
213
        }
237
        }
238
        //What if we dont have any ranges and supbooks
239
        if (retval.supbookpos == 0) {
240
            retval.supbookpos = retval.bspos + 1;
241
            retval.namepos    = retval.supbookpos + 1;
242
        }
243
        
214
        retval.records = records;
244
        retval.records = records;
215
        log.log(DEBUG, "exit create workbook from existing file function");
245
        log.log(DEBUG, "exit create workbook from existing file function");
216
        return retval;
246
        return retval;
217
    }
247
    }
218
248
    
219
    /**
249
    /**
220
     * Creates an empty workbook object with three blank sheets and all the empty
250
     * Creates an empty workbook object with three blank sheets and all the empty
221
     * fields.  Use this to create a workbook from scratch.
251
     * fields.  Use this to create a workbook from scratch.
222
     */
252
     */
223
253
    
224
    public static Workbook createWorkbook()
254
    public static Workbook createWorkbook() {
225
    {
226
        log.log(DEBUG, "creating new workbook from scratch");
255
        log.log(DEBUG, "creating new workbook from scratch");
227
        Workbook  retval  = new Workbook();
256
        Workbook  retval  = new Workbook();
228
        ArrayList records = new ArrayList(30);
257
        ArrayList records = new ArrayList(30);
229
258
        
230
        records.add(retval.createBOF());
259
        records.add(retval.createBOF());
231
        records.add(retval.createInterfaceHdr());
260
        records.add(retval.createInterfaceHdr());
232
        records.add(retval.createMMS());
261
        records.add(retval.createMMS());
Lines 264-285 Link Here
264
        records.add(retval.createFormat(5));
293
        records.add(retval.createFormat(5));
265
        records.add(retval.createFormat(6));
294
        records.add(retval.createFormat(6));
266
        records.add(retval.createFormat(7));
295
        records.add(retval.createFormat(7));
267
        for (int k = 0; k < 21; k++)
296
        for (int k = 0; k < 21; k++) {
268
        {
269
            records.add(retval.createExtendedFormat(k));
297
            records.add(retval.createExtendedFormat(k));
270
            retval.numxfs++;
298
            retval.numxfs++;
271
        }
299
        }
272
        retval.xfpos = records.size() - 1;
300
        retval.xfpos = records.size() - 1;
273
        for (int k = 0; k < 6; k++)
301
        for (int k = 0; k < 6; k++) {
274
        {
275
            records.add(retval.createStyle(k));
302
            records.add(retval.createStyle(k));
276
        }
303
        }
277
        records.add(retval.createUseSelFS());
304
        records.add(retval.createUseSelFS());
278
        for (int k = 0; k < 1; k++)
305
        for (int k = 0; k < 1; k++) {   // now just do 1
279
        {   // now just do 1
280
            BoundSheetRecord bsr =
306
            BoundSheetRecord bsr =
281
                ( BoundSheetRecord ) retval.createBoundSheet(k);
307
            ( BoundSheetRecord ) retval.createBoundSheet(k);
282
308
            
283
            records.add(bsr);
309
            records.add(bsr);
284
            retval.boundsheets.add(bsr);
310
            retval.boundsheets.add(bsr);
285
            retval.bspos = records.size() - 1;
311
            retval.bspos = records.size() - 1;
Lines 288-306 Link Here
288
        retval.sst = ( SSTRecord ) retval.createSST();
314
        retval.sst = ( SSTRecord ) retval.createSST();
289
        records.add(retval.sst);
315
        records.add(retval.sst);
290
        records.add(retval.createExtendedSST());
316
        records.add(retval.createExtendedSST());
291
317
        
292
        // TODO
318
        // TODO
293
        records.add(retval.createEOF());
319
        records.add(retval.createEOF());
294
        retval.records = records;
320
        retval.records = records;
295
        log.log(DEBUG, "exit create new workbook from scratch");
321
        log.log(DEBUG, "exit create new workbook from scratch");
296
        return retval;
322
        return retval;
297
    }
323
    }
298
324
    
299
    public int getNumRecords()
325
    public int getNumRecords() {
300
    {
301
        return records.size();
326
        return records.size();
302
    }
327
    }
303
328
    
304
    /**
329
    /**
305
     * gets the font record at the given index in the font table.  Remember
330
     * gets the font record at the given index in the font table.  Remember
306
     * "There is No Four" (someone at M$ must have gone to Rocky Horror one too
331
     * "There is No Four" (someone at M$ must have gone to Rocky Horror one too
Lines 309-335 Link Here
309
     * @param idx the index to look at (0 or greater but NOT 4)
334
     * @param idx the index to look at (0 or greater but NOT 4)
310
     * @return FontRecord located at the given index
335
     * @return FontRecord located at the given index
311
     */
336
     */
312
337
    
313
    public FontRecord getFontRecordAt(int idx)
338
    public FontRecord getFontRecordAt(int idx) {
314
    {
315
        int index = idx;
339
        int index = idx;
316
340
        
317
        if (index > 4)
341
        if (index > 4) {
318
        {
319
            index -= 1;   // adjust for "There is no 4"
342
            index -= 1;   // adjust for "There is no 4"
320
        }
343
        }
321
        if (index > (numfonts - 1))
344
        if (index > (numfonts - 1)) {
322
        {
323
            throw new ArrayIndexOutOfBoundsException(
345
            throw new ArrayIndexOutOfBoundsException(
324
                "There are only " + numfonts
346
            "There are only " + numfonts
325
                + " font records, you asked for " + idx);
347
            + " font records, you asked for " + idx);
326
        }
348
        }
327
        FontRecord retval =
349
        FontRecord retval =
328
            ( FontRecord ) records.get((fontpos - (numfonts - 1)) + index);
350
        ( FontRecord ) records.get((fontpos - (numfonts - 1)) + index);
329
351
        
330
        return retval;
352
        return retval;
331
    }
353
    }
332
354
    
333
    /**
355
    /**
334
     * creates a new font record and adds it to the "font table".  This causes the
356
     * creates a new font record and adds it to the "font table".  This causes the
335
     * boundsheets to move down one, extended formats to move down (so this function moves
357
     * boundsheets to move down one, extended formats to move down (so this function moves
Lines 337-347 Link Here
337
     *
359
     *
338
     * @return FontRecord that was just created
360
     * @return FontRecord that was just created
339
     */
361
     */
340
362
    
341
    public FontRecord createNewFont()
363
    public FontRecord createNewFont() {
342
    {
343
        FontRecord rec = ( FontRecord ) createFont();
364
        FontRecord rec = ( FontRecord ) createFont();
344
365
        
345
        ++fontpos;
366
        ++fontpos;
346
        ++bspos;
367
        ++bspos;
347
        ++xfpos;
368
        ++xfpos;
Lines 349-391 Link Here
349
        numfonts++;
370
        numfonts++;
350
        return rec;
371
        return rec;
351
    }
372
    }
352
373
    
353
    /**
374
    /**
354
     * gets the number of font records
375
     * gets the number of font records
355
     *
376
     *
356
     * @return   number of font records in the "font table"
377
     * @return   number of font records in the "font table"
357
     */
378
     */
358
379
    
359
    public int getNumberOfFontRecords()
380
    public int getNumberOfFontRecords() {
360
    {
361
        return numfonts;
381
        return numfonts;
362
    }
382
    }
363
383
    
364
    /**
384
    /**
365
     * Sets the BOF for a given sheet
385
     * Sets the BOF for a given sheet
366
     *
386
     *
367
     * @param sheetnum the number of the sheet to set the positing of the bof for
387
     * @param sheetnum the number of the sheet to set the positing of the bof for
368
     * @param pos the actual bof position
388
     * @param pos the actual bof position
369
     */
389
     */
370
390
    
371
    public void setSheetBof(int sheetnum, int pos)
391
    public void setSheetBof(int sheetnum, int pos) {
372
    {
373
        log.log(DEBUG, "setting bof for sheetnum =", new Integer(sheetnum),
392
        log.log(DEBUG, "setting bof for sheetnum =", new Integer(sheetnum),
374
                " at pos=", new Integer(pos));
393
        " at pos=", new Integer(pos));
375
        checkSheets(sheetnum);
394
        checkSheets(sheetnum);
376
        (( BoundSheetRecord ) boundsheets.get(sheetnum))
395
        (( BoundSheetRecord ) boundsheets.get(sheetnum))
377
            .setPositionOfBof(pos);
396
        .setPositionOfBof(pos);
378
    }
397
    }
379
398
    
380
    /**
399
    /**
381
     * Returns the position of the backup record.
400
     * Returns the position of the backup record.
382
     */
401
     */
383
402
    
384
    public BackupRecord getBackupRecord()
403
    public BackupRecord getBackupRecord() {
385
    {
386
        return ( BackupRecord ) records.get(backuppos);
404
        return ( BackupRecord ) records.get(backuppos);
387
    }
405
    }
388
406
    
389
    /**
407
    /**
390
     * sets the name for a given sheet.  If the boundsheet record doesn't exist and
408
     * sets the name for a given sheet.  If the boundsheet record doesn't exist and
391
     * its only one more than we have, go ahead and create it.  If its > 1 more than
409
     * its only one more than we have, go ahead and create it.  If its > 1 more than
Lines 394-532 Link Here
394
     * @param sheetnum the sheet number (0 based)
412
     * @param sheetnum the sheet number (0 based)
395
     * @param sheetname the name for the sheet
413
     * @param sheetname the name for the sheet
396
     */
414
     */
397
415
    
398
    public void setSheetName(int sheetnum, String sheetname)
416
    public void setSheetName(int sheetnum, String sheetname) {
399
    {
400
        checkSheets(sheetnum);
417
        checkSheets(sheetnum);
401
        (( BoundSheetRecord ) boundsheets.get(sheetnum))
418
        (( BoundSheetRecord ) boundsheets.get(sheetnum))
402
            .setSheetname(sheetname);
419
        .setSheetname(sheetname);
403
        (( BoundSheetRecord ) boundsheets.get(sheetnum))
420
        (( BoundSheetRecord ) boundsheets.get(sheetnum))
404
            .setSheetnameLength(( byte ) sheetname.length());
421
        .setSheetnameLength(( byte ) sheetname.length());
405
    }
422
    }
406
423
    
407
    /**
424
    /**
408
     * gets the name for a given sheet.
425
     * gets the name for a given sheet.
409
     *
426
     *
410
     * @param sheetnum the sheet number (0 based)
427
     * @param sheetnum the sheet number (0 based)
411
     * @return sheetname the name for the sheet
428
     * @return sheetname the name for the sheet
412
     */
429
     */
413
430
    
414
    public String getSheetName(int sheetnum)
431
    public String getSheetName(int sheetnum) {
415
    {
416
        return (( BoundSheetRecord ) boundsheets.get(sheetnum))
432
        return (( BoundSheetRecord ) boundsheets.get(sheetnum))
417
            .getSheetname();
433
        .getSheetname();
418
    }
434
    }
419
435
    
436
    /**
437
     * get the sheet's index
438
     * @param name  sheet name
439
     * @return sheet index or -1 if it was not found.
440
     */
441
    
442
    public int getSheetIndex(String name) {
443
        int retval = -1;
444
        
445
        for (int k = 0; k < boundsheets.size(); k++) {
446
            String sheet = getSheetName(k);
447
            
448
            if (sheet.equals(name)) {
449
                retval = k;
450
                break;
451
            }
452
        }
453
        return retval;
454
    }
455
    
420
    /**
456
    /**
421
     * if we're trying to address one more sheet than we have, go ahead and add it!  if we're
457
     * if we're trying to address one more sheet than we have, go ahead and add it!  if we're
422
     * trying to address >1 more than we have throw an exception!
458
     * trying to address >1 more than we have throw an exception!
423
     */
459
     */
424
460
    
425
    private void checkSheets(int sheetnum)
461
    private void checkSheets(int sheetnum) {
426
    {
462
        if ((boundsheets.size()) <= sheetnum) {   // if we're short one add another..
427
        if ((boundsheets.size()) <= sheetnum)
463
            if ((boundsheets.size() + 1) <= sheetnum) {
428
        {   // if we're short one add another..
429
            if ((boundsheets.size() + 1) <= sheetnum)
430
            {
431
                throw new RuntimeException("Sheet number out of bounds!");
464
                throw new RuntimeException("Sheet number out of bounds!");
432
            }
465
            }
433
            BoundSheetRecord bsr =
466
            BoundSheetRecord bsr =
434
                ( BoundSheetRecord ) createBoundSheet(sheetnum);
467
            ( BoundSheetRecord ) createBoundSheet(sheetnum);
435
468
            
436
            records.add(++bspos, bsr);
469
            records.add(++bspos, bsr);
437
            boundsheets.add(bsr);
470
            boundsheets.add(bsr);
438
            fixTabIdRecord();
471
            fixTabIdRecord();
439
        }
472
        }
440
    }
473
    }
441
474
    
442
    public void removeSheet(int sheetnum)
475
    public void removeSheet(int sheetnum) {
443
    {
476
        if (boundsheets.size() > sheetnum) {
444
        if (boundsheets.size() > sheetnum)
445
        {
446
            records.remove(bspos - (boundsheets.size() - 1) + sheetnum);
477
            records.remove(bspos - (boundsheets.size() - 1) + sheetnum);
447
            bspos--;
478
            bspos--;
448
            boundsheets.remove(sheetnum);
479
            boundsheets.remove(sheetnum);
449
            fixTabIdRecord();
480
            fixTabIdRecord();
450
        }
481
        }
451
    }
482
    }
452
483
    
453
    /**
484
    /**
454
     * make the tabid record look like the current situation.
485
     * make the tabid record look like the current situation.
455
     *
486
     *
456
     */
487
     */
457
488
    
458
    private void fixTabIdRecord()
489
    private void fixTabIdRecord() {
459
    {
460
        TabIdRecord tir = ( TabIdRecord ) records.get(tabpos);
490
        TabIdRecord tir = ( TabIdRecord ) records.get(tabpos);
461
        short[]     tia = new short[ boundsheets.size() ];
491
        short[]     tia = new short[ boundsheets.size() ];
462
492
        
463
        for (short k = 0; k < tia.length; k++)
493
        for (short k = 0; k < tia.length; k++) {
464
        {
465
            tia[ k ] = k;
494
            tia[ k ] = k;
466
        }
495
        }
467
        tir.setTabIdArray(tia);
496
        tir.setTabIdArray(tia);
468
    }
497
    }
469
498
    
470
    /**
499
    /**
471
     * returns the number of boundsheet objects contained in this workbook.
500
     * returns the number of boundsheet objects contained in this workbook.
472
     *
501
     *
473
     * @return number of BoundSheet records
502
     * @return number of BoundSheet records
474
     */
503
     */
475
504
    
476
    public int getNumSheets()
505
    public int getNumSheets() {
477
    {
478
        log.log(DEBUG, "getNumSheets=", new Integer(boundsheets.size()));
506
        log.log(DEBUG, "getNumSheets=", new Integer(boundsheets.size()));
479
        return boundsheets.size();
507
        return boundsheets.size();
480
    }
508
    }
481
509
    
482
    /**
510
    /**
483
     * get the number of ExtendedFormat records contained in this workbook.
511
     * get the number of ExtendedFormat records contained in this workbook.
484
     *
512
     *
485
     * @return int count of ExtendedFormat records
513
     * @return int count of ExtendedFormat records
486
     */
514
     */
487
515
    
488
    public int getNumExFormats()
516
    public int getNumExFormats() {
489
    {
490
        log.log(DEBUG, "getXF=", new Integer(boundsheets.size()));
517
        log.log(DEBUG, "getXF=", new Integer(boundsheets.size()));
491
        return numxfs;
518
        return numxfs;
492
    }
519
    }
493
520
    
494
    /**
521
    /**
495
     * gets the ExtendedFormatRecord at the given 0-based index
522
     * gets the ExtendedFormatRecord at the given 0-based index
496
     *
523
     *
497
     * @param index of the Extended format record (0-based)
524
     * @param index of the Extended format record (0-based)
498
     * @return ExtendedFormatRecord at the given index
525
     * @return ExtendedFormatRecord at the given index
499
     */
526
     */
500
527
    
501
    public ExtendedFormatRecord getExFormatAt(int index)
528
    public ExtendedFormatRecord getExFormatAt(int index) {
502
    {
503
        int xfptr = xfpos - (numxfs - 1);
529
        int xfptr = xfpos - (numxfs - 1);
504
530
        
505
        xfptr += index;
531
        xfptr += index;
506
        ExtendedFormatRecord retval =
532
        ExtendedFormatRecord retval =
507
            ( ExtendedFormatRecord ) records.get(xfptr);
533
        ( ExtendedFormatRecord ) records.get(xfptr);
508
534
        
509
        return retval;
535
        return retval;
510
    }
536
    }
511
537
    
512
    /**
538
    /**
513
     * creates a new Cell-type Extneded Format Record and adds it to the end of
539
     * creates a new Cell-type Extneded Format Record and adds it to the end of
514
     *  ExtendedFormatRecords collection
540
     *  ExtendedFormatRecords collection
515
     *
541
     *
516
     * @return ExtendedFormatRecord that was created
542
     * @return ExtendedFormatRecord that was created
517
     */
543
     */
518
544
    
519
    public ExtendedFormatRecord createCellXF()
545
    public ExtendedFormatRecord createCellXF() {
520
    {
521
        ExtendedFormatRecord xf = createExtendedFormat();
546
        ExtendedFormatRecord xf = createExtendedFormat();
522
547
        
523
        ++xfpos;
548
        ++xfpos;
524
        ++bspos;
549
        ++bspos;
525
        records.add(xfpos, xf);
550
        records.add(xfpos, xf);
526
        numxfs++;
551
        numxfs++;
527
        return xf;
552
        return xf;
528
    }
553
    }
529
554
    
530
    /**
555
    /**
531
     * Adds a string to the SST table and returns its index (if its a duplicate
556
     * Adds a string to the SST table and returns its index (if its a duplicate
532
     * just returns its index and update the counts)
557
     * just returns its index and update the counts)
Lines 535-552 Link Here
535
     * @param use16bits whether to use utf 16 or false for compressed unicode
560
     * @param use16bits whether to use utf 16 or false for compressed unicode
536
     * @return index of the string within the SSTRecord
561
     * @return index of the string within the SSTRecord
537
     */
562
     */
538
563
    
539
    public int addSSTString(String string, boolean use16bits)
564
    public int addSSTString(String string, boolean use16bits) {
540
    {
541
        log.log(DEBUG, "insert to sst string='", string, "' and use16bits= ",
565
        log.log(DEBUG, "insert to sst string='", string, "' and use16bits= ",
542
                new Boolean(use16bits));
566
        new Boolean(use16bits));
543
        if (sst == null)
567
        if (sst == null) {
544
        {
545
            insertSST();
568
            insertSST();
546
        }
569
        }
547
        return sst.addString(string, use16bits);
570
        return sst.addString(string, use16bits);
548
    }
571
    }
549
572
    
550
    /**
573
    /**
551
     * Adds a string to the SST table and returns its index (if its a duplicate
574
     * Adds a string to the SST table and returns its index (if its a duplicate
552
     * just returns its index and update the counts) ASSUMES compressed unicode
575
     * just returns its index and update the counts) ASSUMES compressed unicode
Lines 556-795 Link Here
556
     *
579
     *
557
     * @return index of the string within the SSTRecord
580
     * @return index of the string within the SSTRecord
558
     */
581
     */
559
582
    
560
    public int addSSTString(String string)
583
    public int addSSTString(String string) {
561
    {
562
        return addSSTString(string, false);
584
        return addSSTString(string, false);
563
    }
585
    }
564
586
    
565
    /**
587
    /**
566
     * given an index into the SST table, this function returns the corresponding String value
588
     * given an index into the SST table, this function returns the corresponding String value
567
     * @return String containing the SST String
589
     * @return String containing the SST String
568
     */
590
     */
569
591
    
570
    public String getSSTString(int str)
592
    public String getSSTString(int str) {
571
    {
593
        if (sst == null) {
572
        if (sst == null)
573
        {
574
            insertSST();
594
            insertSST();
575
        }
595
        }
576
        String retval = sst.getString(str);
596
        String retval = sst.getString(str);
577
597
        
578
        log.log(DEBUG, "Returning SST for index=", new Integer(str),
598
        log.log(DEBUG, "Returning SST for index=", new Integer(str),
579
                " String= ", retval);
599
        " String= ", retval);
580
        return retval;
600
        return retval;
581
    }
601
    }
582
602
    
583
    /**
603
    /**
584
     * use this function to add a Shared String Table to an existing sheet (say
604
     * use this function to add a Shared String Table to an existing sheet (say
585
     * generated by a different java api) without an sst....
605
     * generated by a different java api) without an sst....
586
     * @see #createSST()
606
     * @see #createSST()
587
     * @see org.apache.poi.hssf.record.SSTRecord
607
     * @see org.apache.poi.hssf.record.SSTRecord
588
     */
608
     */
589
609
    
590
    public void insertSST()
610
    public void insertSST() {
591
    {
592
        log.log(DEBUG, "creating new SST via insertSST!");
611
        log.log(DEBUG, "creating new SST via insertSST!");
593
        sst = ( SSTRecord ) createSST();
612
        sst = ( SSTRecord ) createSST();
594
        records.add(records.size() - 1, createExtendedSST());
613
        records.add(records.size() - 1, createExtendedSST());
595
        records.add(records.size() - 2, sst);
614
        records.add(records.size() - 2, sst);
596
    }
615
    }
597
616
    
598
    /**
617
    /**
599
     * Serializes all records int the worksheet section into a big byte array. Use
618
     * Serializes all records int the worksheet section into a big byte array. Use
600
     * this to write the Workbook out.
619
     * this to write the Workbook out.
601
     *
620
     *
602
     * @return byte array containing the HSSF-only portions of the POIFS file.
621
     * @return byte array containing the HSSF-only portions of the POIFS file.
603
     */
622
     */
604
623
    
605
    public byte [] serialize()
624
    public byte [] serialize() {
606
    {
607
        log.log(DEBUG, "Serializing Workbook!");
625
        log.log(DEBUG, "Serializing Workbook!");
608
        byte[] retval    = null;
626
        byte[] retval    = null;
609
627
        
610
        // ArrayList bytes     = new ArrayList(records.size());
628
        // ArrayList bytes     = new ArrayList(records.size());
611
        int    arraysize = getSize();
629
        int    arraysize = getSize();
612
        int    pos       = 0;
630
        int    pos       = 0;
613
631
        
614
        // for (int k = 0; k < records.size(); k++)
632
        // for (int k = 0; k < records.size(); k++)
615
        // {
633
        // {
616
        // bytes.add((( Record ) records.get(k)).serialize());
634
        // bytes.add((( Record ) records.get(k)).serialize());
617
//        }
635
        //        }
618
        // for (int k = 0; k < bytes.size(); k++)
636
        // for (int k = 0; k < bytes.size(); k++)
619
        // {
637
        // {
620
        // arraysize += (( byte [] ) bytes.get(k)).length;
638
        // arraysize += (( byte [] ) bytes.get(k)).length;
621
        // }
639
        // }
622
        retval = new byte[ arraysize ];
640
        retval = new byte[ arraysize ];
623
        for (int k = 0; k < records.size(); k++)
641
        for (int k = 0; k < records.size(); k++) {
624
        {
642
            
625
626
            // byte[] rec = (( byte [] ) bytes.get(k));
643
            // byte[] rec = (( byte [] ) bytes.get(k));
627
            // System.arraycopy(rec, 0, retval, pos, rec.length);
644
            // System.arraycopy(rec, 0, retval, pos, rec.length);
628
            pos += (( Record ) records.get(k)).serialize(pos,
645
            pos += (( Record ) records.get(k)).serialize(pos,
629
                    retval);   // rec.length;
646
            retval);   // rec.length;
630
        }
647
        }
631
        log.log(DEBUG, "Exiting serialize workbook");
648
        log.log(DEBUG, "Exiting serialize workbook");
632
        return retval;
649
        return retval;
633
    }
650
    }
634
651
    
635
    /**
652
    /**
636
     * Serializes all records int the worksheet section into a big byte array. Use
653
     * Serializes all records int the worksheet section into a big byte array. Use
637
     * this to write the Workbook out.
654
     * this to write the Workbook out.
638
     * @param offset of the data to be written
655
     * @param offset of the data to be written
639
     * @param data array of bytes to write this to
656
     * @param data array of bytes to write this to
640
     */
657
     */
641
658
    
642
    public int serialize(int offset, byte [] data)
659
    public int serialize(int offset, byte [] data) {
643
    {
644
        log.log(DEBUG, "Serializing Workbook with offsets");
660
        log.log(DEBUG, "Serializing Workbook with offsets");
645
661
        
646
        // ArrayList bytes     = new ArrayList(records.size());
662
        // ArrayList bytes     = new ArrayList(records.size());
647
//        int arraysize = getSize();   // 0;
663
        //        int arraysize = getSize();   // 0;
648
        int pos       = 0;
664
        int pos       = 0;
649
665
        
650
//        for (int k = 0; k < records.size(); k++)
666
        //        for (int k = 0; k < records.size(); k++)
651
//        {
667
        //        {
652
//            bytes.add((( Record ) records.get(k)).serialize());
668
        //            bytes.add((( Record ) records.get(k)).serialize());
653
//
669
        //
654
//        }
670
        //        }
655
//        for (int k = 0; k < bytes.size(); k++)
671
        //        for (int k = 0; k < bytes.size(); k++)
656
//       {
672
        //       {
657
//            arraysize += (( byte [] ) bytes.get(k)).length;
673
        //            arraysize += (( byte [] ) bytes.get(k)).length;
658
//        }
674
        //        }
659
        for (int k = 0; k < records.size(); k++)
675
        for (int k = 0; k < records.size(); k++) {
660
        {
676
            
661
662
            // byte[] rec = (( byte [] ) bytes.get(k));
677
            // byte[] rec = (( byte [] ) bytes.get(k));
663
            // System.arraycopy(rec, 0, data, offset + pos, rec.length);
678
            // System.arraycopy(rec, 0, data, offset + pos, rec.length);
664
            pos += (( Record ) records.get(k)).serialize(pos + offset,
679
            pos += (( Record ) records.get(k)).serialize(pos + offset,
665
                    data);   // rec.length;
680
            data);   // rec.length;
666
        }
681
        }
667
        log.log(DEBUG, "Exiting serialize workbook");
682
        log.log(DEBUG, "Exiting serialize workbook");
668
        return pos;
683
        return pos;
669
    }
684
    }
670
685
    
671
    public int getSize()
686
    public int getSize() {
672
    {
673
        int retval = 0;
687
        int retval = 0;
674
688
        
675
        for (int k = 0; k < records.size(); k++)
689
        for (int k = 0; k < records.size(); k++) {
676
        {
677
            retval += (( Record ) records.get(k)).getRecordSize();
690
            retval += (( Record ) records.get(k)).getRecordSize();
678
        }
691
        }
679
        return retval;
692
        return retval;
680
    }
693
    }
681
694
    
682
    /**
695
    /**
683
     * creates the BOF record
696
     * creates the BOF record
684
     * @see org.apache.poi.hssf.record.BOFRecord
697
     * @see org.apache.poi.hssf.record.BOFRecord
685
     * @see org.apache.poi.hssf.record.Record
698
     * @see org.apache.poi.hssf.record.Record
686
     * @return record containing a BOFRecord
699
     * @return record containing a BOFRecord
687
     */
700
     */
688
701
    
689
    protected Record createBOF()
702
    protected Record createBOF() {
690
    {
691
        BOFRecord retval = new BOFRecord();
703
        BOFRecord retval = new BOFRecord();
692
704
        
693
        retval.setVersion(( short ) 0x600);
705
        retval.setVersion(( short ) 0x600);
694
        retval.setType(( short ) 5);
706
        retval.setType(( short ) 5);
695
        retval.setBuild(( short ) 0x10d3);
707
        retval.setBuild(( short ) 0x10d3);
696
708
        
697
//        retval.setBuild((short)0x0dbb);        
709
        //        retval.setBuild((short)0x0dbb);
698
        retval.setBuildYear(( short ) 1996);
710
        retval.setBuildYear(( short ) 1996);
699
        retval.setHistoryBitMask(0x41);   // was c1 before verify
711
        retval.setHistoryBitMask(0x41);   // was c1 before verify
700
        retval.setRequiredVersion(0x6);
712
        retval.setRequiredVersion(0x6);
701
        return retval;
713
        return retval;
702
    }
714
    }
703
715
    
704
    /**
716
    /**
705
     * creates the InterfaceHdr record
717
     * creates the InterfaceHdr record
706
     * @see org.apache.poi.hssf.record.InterfaceHdrRecord
718
     * @see org.apache.poi.hssf.record.InterfaceHdrRecord
707
     * @see org.apache.poi.hssf.record.Record
719
     * @see org.apache.poi.hssf.record.Record
708
     * @return record containing a InterfaceHdrRecord
720
     * @return record containing a InterfaceHdrRecord
709
     */
721
     */
710
722
    
711
    protected Record createInterfaceHdr()
723
    protected Record createInterfaceHdr() {
712
    {
713
        InterfaceHdrRecord retval = new InterfaceHdrRecord();
724
        InterfaceHdrRecord retval = new InterfaceHdrRecord();
714
725
        
715
        retval.setCodepage(CODEPAGE);
726
        retval.setCodepage(CODEPAGE);
716
        return retval;
727
        return retval;
717
    }
728
    }
718
729
    
719
    /**
730
    /**
720
     * creates an MMS record
731
     * creates an MMS record
721
     * @see org.apache.poi.hssf.record.MMSRecord
732
     * @see org.apache.poi.hssf.record.MMSRecord
722
     * @see org.apache.poi.hssf.record.Record
733
     * @see org.apache.poi.hssf.record.Record
723
     * @return record containing a MMSRecord
734
     * @return record containing a MMSRecord
724
     */
735
     */
725
736
    
726
    protected Record createMMS()
737
    protected Record createMMS() {
727
    {
728
        MMSRecord retval = new MMSRecord();
738
        MMSRecord retval = new MMSRecord();
729
739
        
730
        retval.setAddMenuCount(( byte ) 0);
740
        retval.setAddMenuCount(( byte ) 0);
731
        retval.setDelMenuCount(( byte ) 0);
741
        retval.setDelMenuCount(( byte ) 0);
732
        return retval;
742
        return retval;
733
    }
743
    }
734
744
    
735
    /**
745
    /**
736
     * creates the InterfaceEnd record
746
     * creates the InterfaceEnd record
737
     * @see org.apache.poi.hssf.record.InterfaceEndRecord
747
     * @see org.apache.poi.hssf.record.InterfaceEndRecord
738
     * @see org.apache.poi.hssf.record.Record
748
     * @see org.apache.poi.hssf.record.Record
739
     * @return record containing a InterfaceEndRecord
749
     * @return record containing a InterfaceEndRecord
740
     */
750
     */
741
751
    
742
    protected Record createInterfaceEnd()
752
    protected Record createInterfaceEnd() {
743
    {
744
        return new InterfaceEndRecord();
753
        return new InterfaceEndRecord();
745
    }
754
    }
746
755
    
747
    /**
756
    /**
748
     * creates the WriteAccess record containing the logged in user's name
757
     * creates the WriteAccess record containing the logged in user's name
749
     * @see org.apache.poi.hssf.record.WriteAccessRecord
758
     * @see org.apache.poi.hssf.record.WriteAccessRecord
750
     * @see org.apache.poi.hssf.record.Record
759
     * @see org.apache.poi.hssf.record.Record
751
     * @return record containing a WriteAccessRecord
760
     * @return record containing a WriteAccessRecord
752
     */
761
     */
753
762
    
754
    protected Record createWriteAccess()
763
    protected Record createWriteAccess() {
755
    {
756
        WriteAccessRecord retval = new WriteAccessRecord();
764
        WriteAccessRecord retval = new WriteAccessRecord();
757
765
        
758
        retval.setUsername(System.getProperty("user.name"));
766
        retval.setUsername(System.getProperty("user.name"));
759
        return retval;
767
        return retval;
760
    }
768
    }
761
769
    
762
    /**
770
    /**
763
     * creates the Codepage record containing the constant stored in CODEPAGE
771
     * creates the Codepage record containing the constant stored in CODEPAGE
764
     * @see org.apache.poi.hssf.record.CodepageRecord
772
     * @see org.apache.poi.hssf.record.CodepageRecord
765
     * @see org.apache.poi.hssf.record.Record
773
     * @see org.apache.poi.hssf.record.Record
766
     * @return record containing a CodepageRecord
774
     * @return record containing a CodepageRecord
767
     */
775
     */
768
776
    
769
    protected Record createCodepage()
777
    protected Record createCodepage() {
770
    {
771
        CodepageRecord retval = new CodepageRecord();
778
        CodepageRecord retval = new CodepageRecord();
772
779
        
773
        retval.setCodepage(CODEPAGE);
780
        retval.setCodepage(CODEPAGE);
774
        return retval;
781
        return retval;
775
    }
782
    }
776
783
    
777
    /**
784
    /**
778
     * creates the DSF record containing a 0 since HSSF can't even create Dual Stream Files
785
     * creates the DSF record containing a 0 since HSSF can't even create Dual Stream Files
779
     * @see org.apache.poi.hssf.record.DSFRecord
786
     * @see org.apache.poi.hssf.record.DSFRecord
780
     * @see org.apache.poi.hssf.record.Record
787
     * @see org.apache.poi.hssf.record.Record
781
     * @return record containing a DSFRecord
788
     * @return record containing a DSFRecord
782
     */
789
     */
783
790
    
784
    protected Record createDSF()
791
    protected Record createDSF() {
785
    {
786
        DSFRecord retval = new DSFRecord();
792
        DSFRecord retval = new DSFRecord();
787
793
        
788
        retval.setDsf(
794
        retval.setDsf(
789
            ( short ) 0);   // we don't even support double stream files
795
        ( short ) 0);   // we don't even support double stream files
790
        return retval;
796
        return retval;
791
    }
797
    }
792
798
    
793
    /**
799
    /**
794
     * creates the TabId record containing an array of 0,1,2.  This release of HSSF
800
     * creates the TabId record containing an array of 0,1,2.  This release of HSSF
795
     * always has the default three sheets, no less, no more.
801
     * always has the default three sheets, no less, no more.
Lines 797-907 Link Here
797
     * @see org.apache.poi.hssf.record.Record
803
     * @see org.apache.poi.hssf.record.Record
798
     * @return record containing a TabIdRecord
804
     * @return record containing a TabIdRecord
799
     */
805
     */
800
806
    
801
    protected Record createTabId()
807
    protected Record createTabId() {
802
    {
803
        TabIdRecord retval     = new TabIdRecord();
808
        TabIdRecord retval     = new TabIdRecord();
804
        short[]     tabidarray =
809
        short[]     tabidarray = {
805
        {
806
            0
810
            0
807
        };
811
        };
808
812
        
809
        retval.setTabIdArray(tabidarray);
813
        retval.setTabIdArray(tabidarray);
810
        return retval;
814
        return retval;
811
    }
815
    }
812
816
    
813
    /**
817
    /**
814
     * creates the FnGroupCount record containing the Magic number constant of 14.
818
     * creates the FnGroupCount record containing the Magic number constant of 14.
815
     * @see org.apache.poi.hssf.record.FnGroupCountRecord
819
     * @see org.apache.poi.hssf.record.FnGroupCountRecord
816
     * @see org.apache.poi.hssf.record.Record
820
     * @see org.apache.poi.hssf.record.Record
817
     * @return record containing a FnGroupCountRecord
821
     * @return record containing a FnGroupCountRecord
818
     */
822
     */
819
823
    
820
    protected Record createFnGroupCount()
824
    protected Record createFnGroupCount() {
821
    {
822
        FnGroupCountRecord retval = new FnGroupCountRecord();
825
        FnGroupCountRecord retval = new FnGroupCountRecord();
823
826
        
824
        retval.setCount(( short ) 14);
827
        retval.setCount(( short ) 14);
825
        return retval;
828
        return retval;
826
    }
829
    }
827
830
    
828
    /**
831
    /**
829
     * creates the WindowProtect record with protect set to false.
832
     * creates the WindowProtect record with protect set to false.
830
     * @see org.apache.poi.hssf.record.WindowProtectRecord
833
     * @see org.apache.poi.hssf.record.WindowProtectRecord
831
     * @see org.apache.poi.hssf.record.Record
834
     * @see org.apache.poi.hssf.record.Record
832
     * @return record containing a WindowProtectRecord
835
     * @return record containing a WindowProtectRecord
833
     */
836
     */
834
837
    
835
    protected Record createWindowProtect()
838
    protected Record createWindowProtect() {
836
    {
837
        WindowProtectRecord retval = new WindowProtectRecord();
839
        WindowProtectRecord retval = new WindowProtectRecord();
838
840
        
839
        retval.setProtect(
841
        retval.setProtect(
840
            false);   // by default even when we support it we won't
842
        false);   // by default even when we support it we won't
841
        return retval;   // want it to be protected
843
        return retval;   // want it to be protected
842
    }
844
    }
843
845
    
844
    /**
846
    /**
845
     * creates the Protect record with protect set to false.
847
     * creates the Protect record with protect set to false.
846
     * @see org.apache.poi.hssf.record.ProtectRecord
848
     * @see org.apache.poi.hssf.record.ProtectRecord
847
     * @see org.apache.poi.hssf.record.Record
849
     * @see org.apache.poi.hssf.record.Record
848
     * @return record containing a ProtectRecord
850
     * @return record containing a ProtectRecord
849
     */
851
     */
850
852
    
851
    protected Record createProtect()
853
    protected Record createProtect() {
852
    {
853
        ProtectRecord retval = new ProtectRecord();
854
        ProtectRecord retval = new ProtectRecord();
854
855
        
855
        retval.setProtect(
856
        retval.setProtect(
856
            false);   // by default even when we support it we won't
857
        false);   // by default even when we support it we won't
857
        return retval;   // want it to be protected
858
        return retval;   // want it to be protected
858
    }
859
    }
859
860
    
860
    /**
861
    /**
861
     * creates the Password record with password set to 0.
862
     * creates the Password record with password set to 0.
862
     * @see org.apache.poi.hssf.record.PasswordRecord
863
     * @see org.apache.poi.hssf.record.PasswordRecord
863
     * @see org.apache.poi.hssf.record.Record
864
     * @see org.apache.poi.hssf.record.Record
864
     * @return record containing a PasswordRecord
865
     * @return record containing a PasswordRecord
865
     */
866
     */
866
867
    
867
    protected Record createPassword()
868
    protected Record createPassword() {
868
    {
869
        PasswordRecord retval = new PasswordRecord();
869
        PasswordRecord retval = new PasswordRecord();
870
870
        
871
        retval.setPassword(( short ) 0);   // no password by default!
871
        retval.setPassword(( short ) 0);   // no password by default!
872
        return retval;
872
        return retval;
873
    }
873
    }
874
874
    
875
    /**
875
    /**
876
     * creates the ProtectionRev4 record with protect set to false.
876
     * creates the ProtectionRev4 record with protect set to false.
877
     * @see org.apache.poi.hssf.record.ProtectionRev4Record
877
     * @see org.apache.poi.hssf.record.ProtectionRev4Record
878
     * @see org.apache.poi.hssf.record.Record
878
     * @see org.apache.poi.hssf.record.Record
879
     * @return record containing a ProtectionRev4Record
879
     * @return record containing a ProtectionRev4Record
880
     */
880
     */
881
881
    
882
    protected Record createProtectionRev4()
882
    protected Record createProtectionRev4() {
883
    {
884
        ProtectionRev4Record retval = new ProtectionRev4Record();
883
        ProtectionRev4Record retval = new ProtectionRev4Record();
885
884
        
886
        retval.setProtect(false);
885
        retval.setProtect(false);
887
        return retval;
886
        return retval;
888
    }
887
    }
889
888
    
890
    /**
889
    /**
891
     * creates the PasswordRev4 record with password set to 0.
890
     * creates the PasswordRev4 record with password set to 0.
892
     * @see org.apache.poi.hssf.record.PasswordRev4Record
891
     * @see org.apache.poi.hssf.record.PasswordRev4Record
893
     * @see org.apache.poi.hssf.record.Record
892
     * @see org.apache.poi.hssf.record.Record
894
     * @return record containing a PasswordRev4Record
893
     * @return record containing a PasswordRev4Record
895
     */
894
     */
896
895
    
897
    protected Record createPasswordRev4()
896
    protected Record createPasswordRev4() {
898
    {
899
        PasswordRev4Record retval = new PasswordRev4Record();
897
        PasswordRev4Record retval = new PasswordRev4Record();
900
898
        
901
        retval.setPassword(( short ) 0);   // no password by default!
899
        retval.setPassword(( short ) 0);   // no password by default!
902
        return retval;
900
        return retval;
903
    }
901
    }
904
902
    
905
    /**
903
    /**
906
     * creates the WindowOne record with the following magic values: <P>
904
     * creates the WindowOne record with the following magic values: <P>
907
     * horizontal hold - 0x168 <P>
905
     * horizontal hold - 0x168 <P>
Lines 917-927 Link Here
917
     * @see org.apache.poi.hssf.record.Record
915
     * @see org.apache.poi.hssf.record.Record
918
     * @return record containing a WindowOneRecord
916
     * @return record containing a WindowOneRecord
919
     */
917
     */
920
918
    
921
    protected Record createWindowOne()
919
    protected Record createWindowOne() {
922
    {
923
        WindowOneRecord retval = new WindowOneRecord();
920
        WindowOneRecord retval = new WindowOneRecord();
924
921
        
925
        retval.setHorizontalHold(( short ) 0x168);
922
        retval.setHorizontalHold(( short ) 0x168);
926
        retval.setVerticalHold(( short ) 0x10e);
923
        retval.setVerticalHold(( short ) 0x10e);
927
        retval.setWidth(( short ) 0x3a5c);
924
        retval.setWidth(( short ) 0x3a5c);
Lines 933-1032 Link Here
933
        retval.setTabWidthRatio(( short ) 0x258);
930
        retval.setTabWidthRatio(( short ) 0x258);
934
        return retval;
931
        return retval;
935
    }
932
    }
936
933
    
937
    /**
934
    /**
938
     * creates the Backup record with backup set to 0. (loose the data, who cares)
935
     * creates the Backup record with backup set to 0. (loose the data, who cares)
939
     * @see org.apache.poi.hssf.record.BackupRecord
936
     * @see org.apache.poi.hssf.record.BackupRecord
940
     * @see org.apache.poi.hssf.record.Record
937
     * @see org.apache.poi.hssf.record.Record
941
     * @return record containing a BackupRecord
938
     * @return record containing a BackupRecord
942
     */
939
     */
943
940
    
944
    protected Record createBackup()
941
    protected Record createBackup() {
945
    {
946
        BackupRecord retval = new BackupRecord();
942
        BackupRecord retval = new BackupRecord();
947
943
        
948
        retval.setBackup(
944
        retval.setBackup(
949
            ( short ) 0);   // by default DONT save backups of files...just loose data
945
        ( short ) 0);   // by default DONT save backups of files...just loose data
950
        return retval;
946
        return retval;
951
    }
947
    }
952
948
    
953
    /**
949
    /**
954
     * creates the HideObj record with hide object set to 0. (don't hide)
950
     * creates the HideObj record with hide object set to 0. (don't hide)
955
     * @see org.apache.poi.hssf.record.HideObjRecord
951
     * @see org.apache.poi.hssf.record.HideObjRecord
956
     * @see org.apache.poi.hssf.record.Record
952
     * @see org.apache.poi.hssf.record.Record
957
     * @return record containing a HideObjRecord
953
     * @return record containing a HideObjRecord
958
     */
954
     */
959
955
    
960
    protected Record createHideObj()
956
    protected Record createHideObj() {
961
    {
962
        HideObjRecord retval = new HideObjRecord();
957
        HideObjRecord retval = new HideObjRecord();
963
958
        
964
        retval.setHideObj(( short ) 0);   // by default set hide object off
959
        retval.setHideObj(( short ) 0);   // by default set hide object off
965
        return retval;
960
        return retval;
966
    }
961
    }
967
962
    
968
    /**
963
    /**
969
     * creates the DateWindow1904 record with windowing set to 0. (don't window)
964
     * creates the DateWindow1904 record with windowing set to 0. (don't window)
970
     * @see org.apache.poi.hssf.record.DateWindow1904Record
965
     * @see org.apache.poi.hssf.record.DateWindow1904Record
971
     * @see org.apache.poi.hssf.record.Record
966
     * @see org.apache.poi.hssf.record.Record
972
     * @return record containing a DateWindow1904Record
967
     * @return record containing a DateWindow1904Record
973
     */
968
     */
974
969
    
975
    protected Record createDateWindow1904()
970
    protected Record createDateWindow1904() {
976
    {
977
        DateWindow1904Record retval = new DateWindow1904Record();
971
        DateWindow1904Record retval = new DateWindow1904Record();
978
972
        
979
        retval.setWindowing(
973
        retval.setWindowing(
980
            ( short ) 0);   // don't EVER use 1904 date windowing...tick tock..
974
        ( short ) 0);   // don't EVER use 1904 date windowing...tick tock..
981
        return retval;
975
        return retval;
982
    }
976
    }
983
977
    
984
    /**
978
    /**
985
     * creates the Precision record with precision set to true. (full precision)
979
     * creates the Precision record with precision set to true. (full precision)
986
     * @see org.apache.poi.hssf.record.PrecisionRecord
980
     * @see org.apache.poi.hssf.record.PrecisionRecord
987
     * @see org.apache.poi.hssf.record.Record
981
     * @see org.apache.poi.hssf.record.Record
988
     * @return record containing a PrecisionRecord
982
     * @return record containing a PrecisionRecord
989
     */
983
     */
990
984
    
991
    protected Record createPrecision()
985
    protected Record createPrecision() {
992
    {
993
        PrecisionRecord retval = new PrecisionRecord();
986
        PrecisionRecord retval = new PrecisionRecord();
994
987
        
995
        retval.setFullPrecision(
988
        retval.setFullPrecision(
996
            true);   // always use real numbers in calculations!
989
        true);   // always use real numbers in calculations!
997
        return retval;
990
        return retval;
998
    }
991
    }
999
992
    
1000
    /**
993
    /**
1001
     * creates the RefreshAll record with refreshAll set to true. (refresh all calcs)
994
     * creates the RefreshAll record with refreshAll set to true. (refresh all calcs)
1002
     * @see org.apache.poi.hssf.record.RefreshAllRecord
995
     * @see org.apache.poi.hssf.record.RefreshAllRecord
1003
     * @see org.apache.poi.hssf.record.Record
996
     * @see org.apache.poi.hssf.record.Record
1004
     * @return record containing a RefreshAllRecord
997
     * @return record containing a RefreshAllRecord
1005
     */
998
     */
1006
999
    
1007
    protected Record createRefreshAll()
1000
    protected Record createRefreshAll() {
1008
    {
1009
        RefreshAllRecord retval = new RefreshAllRecord();
1001
        RefreshAllRecord retval = new RefreshAllRecord();
1010
1002
        
1011
        retval.setRefreshAll(false);
1003
        retval.setRefreshAll(false);
1012
        return retval;
1004
        return retval;
1013
    }
1005
    }
1014
1006
    
1015
    /**
1007
    /**
1016
     * creates the BookBool record with saveLinkValues set to 0. (don't save link values)
1008
     * creates the BookBool record with saveLinkValues set to 0. (don't save link values)
1017
     * @see org.apache.poi.hssf.record.BookBoolRecord
1009
     * @see org.apache.poi.hssf.record.BookBoolRecord
1018
     * @see org.apache.poi.hssf.record.Record
1010
     * @see org.apache.poi.hssf.record.Record
1019
     * @return record containing a BookBoolRecord
1011
     * @return record containing a BookBoolRecord
1020
     */
1012
     */
1021
1013
    
1022
    protected Record createBookBool()
1014
    protected Record createBookBool() {
1023
    {
1024
        BookBoolRecord retval = new BookBoolRecord();
1015
        BookBoolRecord retval = new BookBoolRecord();
1025
1016
        
1026
        retval.setSaveLinkValues(( short ) 0);
1017
        retval.setSaveLinkValues(( short ) 0);
1027
        return retval;
1018
        return retval;
1028
    }
1019
    }
1029
1020
    
1030
    /**
1021
    /**
1031
     * creates a Font record with the following magic values: <P>
1022
     * creates a Font record with the following magic values: <P>
1032
     * fontheight           = 0xc8<P>
1023
     * fontheight           = 0xc8<P>
Lines 1040-1050 Link Here
1040
     * @see org.apache.poi.hssf.record.Record
1031
     * @see org.apache.poi.hssf.record.Record
1041
     * @return record containing a FontRecord
1032
     * @return record containing a FontRecord
1042
     */
1033
     */
1043
1034
    
1044
    protected Record createFont()
1035
    protected Record createFont() {
1045
    {
1046
        FontRecord retval = new FontRecord();
1036
        FontRecord retval = new FontRecord();
1047
1037
        
1048
        retval.setFontHeight(( short ) 0xc8);
1038
        retval.setFontHeight(( short ) 0xc8);
1049
        retval.setAttributes(( short ) 0x0);
1039
        retval.setAttributes(( short ) 0x0);
1050
        retval.setColorPaletteIndex(( short ) 0x7fff);
1040
        retval.setColorPaletteIndex(( short ) 0x7fff);
Lines 1053-1059 Link Here
1053
        retval.setFontName("Arial");
1043
        retval.setFontName("Arial");
1054
        return retval;
1044
        return retval;
1055
    }
1045
    }
1056
1046
    
1057
    /**
1047
    /**
1058
     * Creates a FormatRecord object
1048
     * Creates a FormatRecord object
1059
     * @param id    the number of the format record to create (meaning its position in
1049
     * @param id    the number of the format record to create (meaning its position in
Lines 1062-1131 Link Here
1062
     * @see org.apache.poi.hssf.record.FormatRecord
1052
     * @see org.apache.poi.hssf.record.FormatRecord
1063
     * @see org.apache.poi.hssf.record.Record
1053
     * @see org.apache.poi.hssf.record.Record
1064
     */
1054
     */
1065
1055
    
1066
    protected Record createFormat(int id)
1056
    protected Record createFormat(int id) {   // we'll need multiple editions for
1067
    {   // we'll need multiple editions for
1068
        FormatRecord retval = new FormatRecord();   // the differnt formats
1057
        FormatRecord retval = new FormatRecord();   // the differnt formats
1069
1058
        
1070
        switch (id)
1059
        switch (id) {
1071
        {
1060
            
1072
1073
            case 0 :
1061
            case 0 :
1074
                retval.setIndexCode(( short ) 5);
1062
                retval.setIndexCode(( short ) 5);
1075
                retval.setFormatStringLength(( byte ) 0x17);
1063
                retval.setFormatStringLength(( byte ) 0x17);
1076
                retval.setFormatString("\"$\"#,##0_);\\(\"$\"#,##0\\)");
1064
                retval.setFormatString("\"$\"#,##0_);\\(\"$\"#,##0\\)");
1077
                break;
1065
                break;
1078
1066
                
1079
            case 1 :
1067
            case 1 :
1080
                retval.setIndexCode(( short ) 6);
1068
                retval.setIndexCode(( short ) 6);
1081
                retval.setFormatStringLength(( byte ) 0x1c);
1069
                retval.setFormatStringLength(( byte ) 0x1c);
1082
                retval.setFormatString("\"$\"#,##0_);[Red]\\(\"$\"#,##0\\)");
1070
                retval.setFormatString("\"$\"#,##0_);[Red]\\(\"$\"#,##0\\)");
1083
                break;
1071
                break;
1084
1072
                
1085
            case 2 :
1073
            case 2 :
1086
                retval.setIndexCode(( short ) 7);
1074
                retval.setIndexCode(( short ) 7);
1087
                retval.setFormatStringLength(( byte ) 0x1d);
1075
                retval.setFormatStringLength(( byte ) 0x1d);
1088
                retval.setFormatString("\"$\"#,##0.00_);\\(\"$\"#,##0.00\\)");
1076
                retval.setFormatString("\"$\"#,##0.00_);\\(\"$\"#,##0.00\\)");
1089
                break;
1077
                break;
1090
1078
                
1091
            case 3 :
1079
            case 3 :
1092
                retval.setIndexCode(( short ) 8);
1080
                retval.setIndexCode(( short ) 8);
1093
                retval.setFormatStringLength(( byte ) 0x22);
1081
                retval.setFormatStringLength(( byte ) 0x22);
1094
                retval.setFormatString(
1082
                retval.setFormatString(
1095
                    "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)");
1083
                "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)");
1096
                break;
1084
                break;
1097
1085
                
1098
            case 4 :
1086
            case 4 :
1099
                retval.setIndexCode(( short ) 0x2a);
1087
                retval.setIndexCode(( short ) 0x2a);
1100
                retval.setFormatStringLength(( byte ) 0x32);
1088
                retval.setFormatStringLength(( byte ) 0x32);
1101
                retval.setFormatString(
1089
                retval.setFormatString(
1102
                    "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)");
1090
                "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)");
1103
                break;
1091
                break;
1104
1092
                
1105
            case 5 :
1093
            case 5 :
1106
                retval.setIndexCode(( short ) 0x29);
1094
                retval.setIndexCode(( short ) 0x29);
1107
                retval.setFormatStringLength(( byte ) 0x29);
1095
                retval.setFormatStringLength(( byte ) 0x29);
1108
                retval.setFormatString(
1096
                retval.setFormatString(
1109
                    "_(* #,##0_);_(* \\(#,##0\\);_(* \"-\"_);_(@_)");
1097
                "_(* #,##0_);_(* \\(#,##0\\);_(* \"-\"_);_(@_)");
1110
                break;
1098
                break;
1111
1099
                
1112
            case 6 :
1100
            case 6 :
1113
                retval.setIndexCode(( short ) 0x2c);
1101
                retval.setIndexCode(( short ) 0x2c);
1114
                retval.setFormatStringLength(( byte ) 0x3a);
1102
                retval.setFormatStringLength(( byte ) 0x3a);
1115
                retval.setFormatString(
1103
                retval.setFormatString(
1116
                    "_(\"$\"* #,##0.00_);_(\"$\"* \\(#,##0.00\\);_(\"$\"* \"-\"??_);_(@_)");
1104
                "_(\"$\"* #,##0.00_);_(\"$\"* \\(#,##0.00\\);_(\"$\"* \"-\"??_);_(@_)");
1117
                break;
1105
                break;
1118
1106
                
1119
            case 7 :
1107
            case 7 :
1120
                retval.setIndexCode(( short ) 0x2b);
1108
                retval.setIndexCode(( short ) 0x2b);
1121
                retval.setFormatStringLength(( byte ) 0x31);
1109
                retval.setFormatStringLength(( byte ) 0x31);
1122
                retval.setFormatString(
1110
                retval.setFormatString(
1123
                    "_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)");
1111
                "_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)");
1124
                break;
1112
                break;
1125
        }
1113
        }
1126
        return retval;
1114
        return retval;
1127
    }
1115
    }
1128
1116
    
1129
    /**
1117
    /**
1130
     * Creates an ExtendedFormatRecord object
1118
     * Creates an ExtendedFormatRecord object
1131
     * @param id    the number of the extended format record to create (meaning its position in
1119
     * @param id    the number of the extended format record to create (meaning its position in
Lines 1135-1148 Link Here
1135
     * @see org.apache.poi.hssf.record.ExtendedFormatRecord
1123
     * @see org.apache.poi.hssf.record.ExtendedFormatRecord
1136
     * @see org.apache.poi.hssf.record.Record
1124
     * @see org.apache.poi.hssf.record.Record
1137
     */
1125
     */
1138
1126
    
1139
    protected Record createExtendedFormat(int id)
1127
    protected Record createExtendedFormat(int id) {   // we'll need multiple editions
1140
    {   // we'll need multiple editions
1141
        ExtendedFormatRecord retval = new ExtendedFormatRecord();
1128
        ExtendedFormatRecord retval = new ExtendedFormatRecord();
1142
1129
        
1143
        switch (id)
1130
        switch (id) {
1144
        {
1131
            
1145
1146
            case 0 :
1132
            case 0 :
1147
                retval.setFontIndex(( short ) 0);
1133
                retval.setFontIndex(( short ) 0);
1148
                retval.setFormatIndex(( short ) 0);
1134
                retval.setFormatIndex(( short ) 0);
Lines 1154-1160 Link Here
1154
                retval.setAdtlPaletteOptions(( short ) 0);
1140
                retval.setAdtlPaletteOptions(( short ) 0);
1155
                retval.setFillPaletteOptions(( short ) 0x20c0);
1141
                retval.setFillPaletteOptions(( short ) 0x20c0);
1156
                break;
1142
                break;
1157
1143
                
1158
            case 1 :
1144
            case 1 :
1159
                retval.setFontIndex(( short ) 1);
1145
                retval.setFontIndex(( short ) 1);
1160
                retval.setFormatIndex(( short ) 0);
1146
                retval.setFormatIndex(( short ) 0);
Lines 1166-1172 Link Here
1166
                retval.setAdtlPaletteOptions(( short ) 0);
1152
                retval.setAdtlPaletteOptions(( short ) 0);
1167
                retval.setFillPaletteOptions(( short ) 0x20c0);
1153
                retval.setFillPaletteOptions(( short ) 0x20c0);
1168
                break;
1154
                break;
1169
1155
                
1170
            case 2 :
1156
            case 2 :
1171
                retval.setFontIndex(( short ) 1);
1157
                retval.setFontIndex(( short ) 1);
1172
                retval.setFormatIndex(( short ) 0);
1158
                retval.setFormatIndex(( short ) 0);
Lines 1178-1184 Link Here
1178
                retval.setAdtlPaletteOptions(( short ) 0);
1164
                retval.setAdtlPaletteOptions(( short ) 0);
1179
                retval.setFillPaletteOptions(( short ) 0x20c0);
1165
                retval.setFillPaletteOptions(( short ) 0x20c0);
1180
                break;
1166
                break;
1181
1167
                
1182
            case 3 :
1168
            case 3 :
1183
                retval.setFontIndex(( short ) 2);
1169
                retval.setFontIndex(( short ) 2);
1184
                retval.setFormatIndex(( short ) 0);
1170
                retval.setFormatIndex(( short ) 0);
Lines 1190-1196 Link Here
1190
                retval.setAdtlPaletteOptions(( short ) 0);
1176
                retval.setAdtlPaletteOptions(( short ) 0);
1191
                retval.setFillPaletteOptions(( short ) 0x20c0);
1177
                retval.setFillPaletteOptions(( short ) 0x20c0);
1192
                break;
1178
                break;
1193
1179
                
1194
            case 4 :
1180
            case 4 :
1195
                retval.setFontIndex(( short ) 2);
1181
                retval.setFontIndex(( short ) 2);
1196
                retval.setFormatIndex(( short ) 0);
1182
                retval.setFormatIndex(( short ) 0);
Lines 1202-1208 Link Here
1202
                retval.setAdtlPaletteOptions(( short ) 0);
1188
                retval.setAdtlPaletteOptions(( short ) 0);
1203
                retval.setFillPaletteOptions(( short ) 0x20c0);
1189
                retval.setFillPaletteOptions(( short ) 0x20c0);
1204
                break;
1190
                break;
1205
1191
                
1206
            case 5 :
1192
            case 5 :
1207
                retval.setFontIndex(( short ) 0);
1193
                retval.setFontIndex(( short ) 0);
1208
                retval.setFormatIndex(( short ) 0);
1194
                retval.setFormatIndex(( short ) 0);
Lines 1214-1220 Link Here
1214
                retval.setAdtlPaletteOptions(( short ) 0);
1200
                retval.setAdtlPaletteOptions(( short ) 0);
1215
                retval.setFillPaletteOptions(( short ) 0x20c0);
1201
                retval.setFillPaletteOptions(( short ) 0x20c0);
1216
                break;
1202
                break;
1217
1203
                
1218
            case 6 :
1204
            case 6 :
1219
                retval.setFontIndex(( short ) 0);
1205
                retval.setFontIndex(( short ) 0);
1220
                retval.setFormatIndex(( short ) 0);
1206
                retval.setFormatIndex(( short ) 0);
Lines 1226-1232 Link Here
1226
                retval.setAdtlPaletteOptions(( short ) 0);
1212
                retval.setAdtlPaletteOptions(( short ) 0);
1227
                retval.setFillPaletteOptions(( short ) 0x20c0);
1213
                retval.setFillPaletteOptions(( short ) 0x20c0);
1228
                break;
1214
                break;
1229
1215
                
1230
            case 7 :
1216
            case 7 :
1231
                retval.setFontIndex(( short ) 0);
1217
                retval.setFontIndex(( short ) 0);
1232
                retval.setFormatIndex(( short ) 0);
1218
                retval.setFormatIndex(( short ) 0);
Lines 1238-1244 Link Here
1238
                retval.setAdtlPaletteOptions(( short ) 0);
1224
                retval.setAdtlPaletteOptions(( short ) 0);
1239
                retval.setFillPaletteOptions(( short ) 0x20c0);
1225
                retval.setFillPaletteOptions(( short ) 0x20c0);
1240
                break;
1226
                break;
1241
1227
                
1242
            case 8 :
1228
            case 8 :
1243
                retval.setFontIndex(( short ) 0);
1229
                retval.setFontIndex(( short ) 0);
1244
                retval.setFormatIndex(( short ) 0);
1230
                retval.setFormatIndex(( short ) 0);
Lines 1250-1256 Link Here
1250
                retval.setAdtlPaletteOptions(( short ) 0);
1236
                retval.setAdtlPaletteOptions(( short ) 0);
1251
                retval.setFillPaletteOptions(( short ) 0x20c0);
1237
                retval.setFillPaletteOptions(( short ) 0x20c0);
1252
                break;
1238
                break;
1253
1239
                
1254
            case 9 :
1240
            case 9 :
1255
                retval.setFontIndex(( short ) 0);
1241
                retval.setFontIndex(( short ) 0);
1256
                retval.setFormatIndex(( short ) 0);
1242
                retval.setFormatIndex(( short ) 0);
Lines 1262-1268 Link Here
1262
                retval.setAdtlPaletteOptions(( short ) 0);
1248
                retval.setAdtlPaletteOptions(( short ) 0);
1263
                retval.setFillPaletteOptions(( short ) 0x20c0);
1249
                retval.setFillPaletteOptions(( short ) 0x20c0);
1264
                break;
1250
                break;
1265
1251
                
1266
            case 10 :
1252
            case 10 :
1267
                retval.setFontIndex(( short ) 0);
1253
                retval.setFontIndex(( short ) 0);
1268
                retval.setFormatIndex(( short ) 0);
1254
                retval.setFormatIndex(( short ) 0);
Lines 1274-1280 Link Here
1274
                retval.setAdtlPaletteOptions(( short ) 0);
1260
                retval.setAdtlPaletteOptions(( short ) 0);
1275
                retval.setFillPaletteOptions(( short ) 0x20c0);
1261
                retval.setFillPaletteOptions(( short ) 0x20c0);
1276
                break;
1262
                break;
1277
1263
                
1278
            case 11 :
1264
            case 11 :
1279
                retval.setFontIndex(( short ) 0);
1265
                retval.setFontIndex(( short ) 0);
1280
                retval.setFormatIndex(( short ) 0);
1266
                retval.setFormatIndex(( short ) 0);
Lines 1286-1292 Link Here
1286
                retval.setAdtlPaletteOptions(( short ) 0);
1272
                retval.setAdtlPaletteOptions(( short ) 0);
1287
                retval.setFillPaletteOptions(( short ) 0x20c0);
1273
                retval.setFillPaletteOptions(( short ) 0x20c0);
1288
                break;
1274
                break;
1289
1275
                
1290
            case 12 :
1276
            case 12 :
1291
                retval.setFontIndex(( short ) 0);
1277
                retval.setFontIndex(( short ) 0);
1292
                retval.setFormatIndex(( short ) 0);
1278
                retval.setFormatIndex(( short ) 0);
Lines 1298-1304 Link Here
1298
                retval.setAdtlPaletteOptions(( short ) 0);
1284
                retval.setAdtlPaletteOptions(( short ) 0);
1299
                retval.setFillPaletteOptions(( short ) 0x20c0);
1285
                retval.setFillPaletteOptions(( short ) 0x20c0);
1300
                break;
1286
                break;
1301
1287
                
1302
            case 13 :
1288
            case 13 :
1303
                retval.setFontIndex(( short ) 0);
1289
                retval.setFontIndex(( short ) 0);
1304
                retval.setFormatIndex(( short ) 0);
1290
                retval.setFormatIndex(( short ) 0);
Lines 1310-1316 Link Here
1310
                retval.setAdtlPaletteOptions(( short ) 0);
1296
                retval.setAdtlPaletteOptions(( short ) 0);
1311
                retval.setFillPaletteOptions(( short ) 0x20c0);
1297
                retval.setFillPaletteOptions(( short ) 0x20c0);
1312
                break;
1298
                break;
1313
1299
                
1314
            case 14 :
1300
            case 14 :
1315
                retval.setFontIndex(( short ) 0);
1301
                retval.setFontIndex(( short ) 0);
1316
                retval.setFormatIndex(( short ) 0);
1302
                retval.setFormatIndex(( short ) 0);
Lines 1322-1329 Link Here
1322
                retval.setAdtlPaletteOptions(( short ) 0);
1308
                retval.setAdtlPaletteOptions(( short ) 0);
1323
                retval.setFillPaletteOptions(( short ) 0x20c0);
1309
                retval.setFillPaletteOptions(( short ) 0x20c0);
1324
                break;
1310
                break;
1325
1311
                
1326
            // cell records
1312
                // cell records
1327
            case 15 :
1313
            case 15 :
1328
                retval.setFontIndex(( short ) 0);
1314
                retval.setFontIndex(( short ) 0);
1329
                retval.setFormatIndex(( short ) 0);
1315
                retval.setFormatIndex(( short ) 0);
Lines 1335-1342 Link Here
1335
                retval.setAdtlPaletteOptions(( short ) 0);
1321
                retval.setAdtlPaletteOptions(( short ) 0);
1336
                retval.setFillPaletteOptions(( short ) 0x20c0);
1322
                retval.setFillPaletteOptions(( short ) 0x20c0);
1337
                break;
1323
                break;
1338
1324
                
1339
            // style
1325
                // style
1340
            case 16 :
1326
            case 16 :
1341
                retval.setFontIndex(( short ) 1);
1327
                retval.setFontIndex(( short ) 1);
1342
                retval.setFormatIndex(( short ) 0x2b);
1328
                retval.setFormatIndex(( short ) 0x2b);
Lines 1348-1354 Link Here
1348
                retval.setAdtlPaletteOptions(( short ) 0);
1334
                retval.setAdtlPaletteOptions(( short ) 0);
1349
                retval.setFillPaletteOptions(( short ) 0x20c0);
1335
                retval.setFillPaletteOptions(( short ) 0x20c0);
1350
                break;
1336
                break;
1351
1337
                
1352
            case 17 :
1338
            case 17 :
1353
                retval.setFontIndex(( short ) 1);
1339
                retval.setFontIndex(( short ) 1);
1354
                retval.setFormatIndex(( short ) 0x29);
1340
                retval.setFormatIndex(( short ) 0x29);
Lines 1360-1366 Link Here
1360
                retval.setAdtlPaletteOptions(( short ) 0);
1346
                retval.setAdtlPaletteOptions(( short ) 0);
1361
                retval.setFillPaletteOptions(( short ) 0x20c0);
1347
                retval.setFillPaletteOptions(( short ) 0x20c0);
1362
                break;
1348
                break;
1363
1349
                
1364
            case 18 :
1350
            case 18 :
1365
                retval.setFontIndex(( short ) 1);
1351
                retval.setFontIndex(( short ) 1);
1366
                retval.setFormatIndex(( short ) 0x2c);
1352
                retval.setFormatIndex(( short ) 0x2c);
Lines 1372-1378 Link Here
1372
                retval.setAdtlPaletteOptions(( short ) 0);
1358
                retval.setAdtlPaletteOptions(( short ) 0);
1373
                retval.setFillPaletteOptions(( short ) 0x20c0);
1359
                retval.setFillPaletteOptions(( short ) 0x20c0);
1374
                break;
1360
                break;
1375
1361
                
1376
            case 19 :
1362
            case 19 :
1377
                retval.setFontIndex(( short ) 1);
1363
                retval.setFontIndex(( short ) 1);
1378
                retval.setFormatIndex(( short ) 0x2a);
1364
                retval.setFormatIndex(( short ) 0x2a);
Lines 1384-1390 Link Here
1384
                retval.setAdtlPaletteOptions(( short ) 0);
1370
                retval.setAdtlPaletteOptions(( short ) 0);
1385
                retval.setFillPaletteOptions(( short ) 0x20c0);
1371
                retval.setFillPaletteOptions(( short ) 0x20c0);
1386
                break;
1372
                break;
1387
1373
                
1388
            case 20 :
1374
            case 20 :
1389
                retval.setFontIndex(( short ) 1);
1375
                retval.setFontIndex(( short ) 1);
1390
                retval.setFormatIndex(( short ) 0x9);
1376
                retval.setFormatIndex(( short ) 0x9);
Lines 1396-1403 Link Here
1396
                retval.setAdtlPaletteOptions(( short ) 0);
1382
                retval.setAdtlPaletteOptions(( short ) 0);
1397
                retval.setFillPaletteOptions(( short ) 0x20c0);
1383
                retval.setFillPaletteOptions(( short ) 0x20c0);
1398
                break;
1384
                break;
1399
1385
                
1400
            // unused from this point down
1386
                // unused from this point down
1401
            case 21 :
1387
            case 21 :
1402
                retval.setFontIndex(( short ) 5);
1388
                retval.setFontIndex(( short ) 5);
1403
                retval.setFormatIndex(( short ) 0x0);
1389
                retval.setFormatIndex(( short ) 0x0);
Lines 1409-1415 Link Here
1409
                retval.setAdtlPaletteOptions(( short ) 0);
1395
                retval.setAdtlPaletteOptions(( short ) 0);
1410
                retval.setFillPaletteOptions(( short ) 0x20c0);
1396
                retval.setFillPaletteOptions(( short ) 0x20c0);
1411
                break;
1397
                break;
1412
1398
                
1413
            case 22 :
1399
            case 22 :
1414
                retval.setFontIndex(( short ) 6);
1400
                retval.setFontIndex(( short ) 6);
1415
                retval.setFormatIndex(( short ) 0x0);
1401
                retval.setFormatIndex(( short ) 0x0);
Lines 1421-1427 Link Here
1421
                retval.setAdtlPaletteOptions(( short ) 0);
1407
                retval.setAdtlPaletteOptions(( short ) 0);
1422
                retval.setFillPaletteOptions(( short ) 0x20c0);
1408
                retval.setFillPaletteOptions(( short ) 0x20c0);
1423
                break;
1409
                break;
1424
1410
                
1425
            case 23 :
1411
            case 23 :
1426
                retval.setFontIndex(( short ) 0);
1412
                retval.setFontIndex(( short ) 0);
1427
                retval.setFormatIndex(( short ) 0x31);
1413
                retval.setFormatIndex(( short ) 0x31);
Lines 1433-1439 Link Here
1433
                retval.setAdtlPaletteOptions(( short ) 0);
1419
                retval.setAdtlPaletteOptions(( short ) 0);
1434
                retval.setFillPaletteOptions(( short ) 0x20c0);
1420
                retval.setFillPaletteOptions(( short ) 0x20c0);
1435
                break;
1421
                break;
1436
1422
                
1437
            case 24 :
1423
            case 24 :
1438
                retval.setFontIndex(( short ) 0);
1424
                retval.setFontIndex(( short ) 0);
1439
                retval.setFormatIndex(( short ) 0x8);
1425
                retval.setFormatIndex(( short ) 0x8);
Lines 1445-1451 Link Here
1445
                retval.setAdtlPaletteOptions(( short ) 0);
1431
                retval.setAdtlPaletteOptions(( short ) 0);
1446
                retval.setFillPaletteOptions(( short ) 0x20c0);
1432
                retval.setFillPaletteOptions(( short ) 0x20c0);
1447
                break;
1433
                break;
1448
1434
                
1449
            case 25 :
1435
            case 25 :
1450
                retval.setFontIndex(( short ) 6);
1436
                retval.setFontIndex(( short ) 6);
1451
                retval.setFormatIndex(( short ) 0x8);
1437
                retval.setFormatIndex(( short ) 0x8);
Lines 1460-1475 Link Here
1460
        }
1446
        }
1461
        return retval;
1447
        return retval;
1462
    }
1448
    }
1463
1449
    
1464
    /**
1450
    /**
1465
     * creates an default cell type ExtendedFormatRecord object.
1451
     * creates an default cell type ExtendedFormatRecord object.
1466
     * @return ExtendedFormatRecord with intial defaults (cell-type)
1452
     * @return ExtendedFormatRecord with intial defaults (cell-type)
1467
     */
1453
     */
1468
1454
    
1469
    protected ExtendedFormatRecord createExtendedFormat()
1455
    protected ExtendedFormatRecord createExtendedFormat() {
1470
    {
1471
        ExtendedFormatRecord retval = new ExtendedFormatRecord();
1456
        ExtendedFormatRecord retval = new ExtendedFormatRecord();
1472
1457
        
1473
        retval.setFontIndex(( short ) 0);
1458
        retval.setFontIndex(( short ) 0);
1474
        retval.setFormatIndex(( short ) 0x0);
1459
        retval.setFormatIndex(( short ) 0x0);
1475
        retval.setCellOptions(( short ) 0x1);
1460
        retval.setCellOptions(( short ) 0x1);
Lines 1481-1487 Link Here
1481
        retval.setFillPaletteOptions(( short ) 0x20c0);
1466
        retval.setFillPaletteOptions(( short ) 0x20c0);
1482
        return retval;
1467
        return retval;
1483
    }
1468
    }
1484
1469
    
1485
    /**
1470
    /**
1486
     * Creates a StyleRecord object
1471
     * Creates a StyleRecord object
1487
     * @param id        the number of the style record to create (meaning its position in
1472
     * @param id        the number of the style record to create (meaning its position in
Lines 1490-1533 Link Here
1490
     * @see org.apache.poi.hssf.record.StyleRecord
1475
     * @see org.apache.poi.hssf.record.StyleRecord
1491
     * @see org.apache.poi.hssf.record.Record
1476
     * @see org.apache.poi.hssf.record.Record
1492
     */
1477
     */
1493
1478
    
1494
    protected Record createStyle(int id)
1479
    protected Record createStyle(int id) {   // we'll need multiple editions
1495
    {   // we'll need multiple editions
1496
        StyleRecord retval = new StyleRecord();
1480
        StyleRecord retval = new StyleRecord();
1497
1481
        
1498
        switch (id)
1482
        switch (id) {
1499
        {
1483
            
1500
1501
            case 0 :
1484
            case 0 :
1502
                retval.setIndex(( short ) 0xffff8010);
1485
                retval.setIndex(( short ) 0xffff8010);
1503
                retval.setBuiltin(( byte ) 3);
1486
                retval.setBuiltin(( byte ) 3);
1504
                retval.setOutlineStyleLevel(( byte ) 0xffffffff);
1487
                retval.setOutlineStyleLevel(( byte ) 0xffffffff);
1505
                break;
1488
                break;
1506
1489
                
1507
            case 1 :
1490
            case 1 :
1508
                retval.setIndex(( short ) 0xffff8011);
1491
                retval.setIndex(( short ) 0xffff8011);
1509
                retval.setBuiltin(( byte ) 6);
1492
                retval.setBuiltin(( byte ) 6);
1510
                retval.setOutlineStyleLevel(( byte ) 0xffffffff);
1493
                retval.setOutlineStyleLevel(( byte ) 0xffffffff);
1511
                break;
1494
                break;
1512
1495
                
1513
            case 2 :
1496
            case 2 :
1514
                retval.setIndex(( short ) 0xffff8012);
1497
                retval.setIndex(( short ) 0xffff8012);
1515
                retval.setBuiltin(( byte ) 4);
1498
                retval.setBuiltin(( byte ) 4);
1516
                retval.setOutlineStyleLevel(( byte ) 0xffffffff);
1499
                retval.setOutlineStyleLevel(( byte ) 0xffffffff);
1517
                break;
1500
                break;
1518
1501
                
1519
            case 3 :
1502
            case 3 :
1520
                retval.setIndex(( short ) 0xffff8013);
1503
                retval.setIndex(( short ) 0xffff8013);
1521
                retval.setBuiltin(( byte ) 7);
1504
                retval.setBuiltin(( byte ) 7);
1522
                retval.setOutlineStyleLevel(( byte ) 0xffffffff);
1505
                retval.setOutlineStyleLevel(( byte ) 0xffffffff);
1523
                break;
1506
                break;
1524
1507
                
1525
            case 4 :
1508
            case 4 :
1526
                retval.setIndex(( short ) 0xffff8000);
1509
                retval.setIndex(( short ) 0xffff8000);
1527
                retval.setBuiltin(( byte ) 0);
1510
                retval.setBuiltin(( byte ) 0);
1528
                retval.setOutlineStyleLevel(( byte ) 0xffffffff);
1511
                retval.setOutlineStyleLevel(( byte ) 0xffffffff);
1529
                break;
1512
                break;
1530
1513
                
1531
            case 5 :
1514
            case 5 :
1532
                retval.setIndex(( short ) 0xffff8014);
1515
                retval.setIndex(( short ) 0xffff8014);
1533
                retval.setBuiltin(( byte ) 5);
1516
                retval.setBuiltin(( byte ) 5);
Lines 1536-1557 Link Here
1536
        }
1519
        }
1537
        return retval;
1520
        return retval;
1538
    }
1521
    }
1539
1522
    
1540
    /**
1523
    /**
1541
     * Creates the UseSelFS object with the use natural language flag set to 0 (false)
1524
     * Creates the UseSelFS object with the use natural language flag set to 0 (false)
1542
     * @return record containing a UseSelFSRecord
1525
     * @return record containing a UseSelFSRecord
1543
     * @see org.apache.poi.hssf.record.UseSelFSRecord
1526
     * @see org.apache.poi.hssf.record.UseSelFSRecord
1544
     * @see org.apache.poi.hssf.record.Record
1527
     * @see org.apache.poi.hssf.record.Record
1545
     */
1528
     */
1546
1529
    
1547
    protected Record createUseSelFS()
1530
    protected Record createUseSelFS() {
1548
    {
1549
        UseSelFSRecord retval = new UseSelFSRecord();
1531
        UseSelFSRecord retval = new UseSelFSRecord();
1550
1532
        
1551
        retval.setFlag(( short ) 0);
1533
        retval.setFlag(( short ) 0);
1552
        return retval;
1534
        return retval;
1553
    }
1535
    }
1554
1536
    
1555
    /**
1537
    /**
1556
     * create a "bound sheet" or "bundlesheet" (depending who you ask) record
1538
     * create a "bound sheet" or "bundlesheet" (depending who you ask) record
1557
     * Always sets the sheet's bof to 0.  You'll need to set that yourself.
1539
     * Always sets the sheet's bof to 0.  You'll need to set that yourself.
Lines 1560-1573 Link Here
1560
     * @see org.apache.poi.hssf.record.BoundSheetRecord
1542
     * @see org.apache.poi.hssf.record.BoundSheetRecord
1561
     * @see org.apache.poi.hssf.record.Record
1543
     * @see org.apache.poi.hssf.record.Record
1562
     */
1544
     */
1563
1545
    
1564
    protected Record createBoundSheet(int id)
1546
    protected Record createBoundSheet(int id) {   // 1,2,3 sheets
1565
    {   // 1,2,3 sheets
1566
        BoundSheetRecord retval = new BoundSheetRecord();
1547
        BoundSheetRecord retval = new BoundSheetRecord();
1567
1548
        
1568
        switch (id)
1549
        switch (id) {
1569
        {
1550
            
1570
1571
            case 0 :
1551
            case 0 :
1572
                retval.setPositionOfBof(0x0);   // should be set later
1552
                retval.setPositionOfBof(0x0);   // should be set later
1573
                retval.setOptionFlags(( short ) 0);
1553
                retval.setOptionFlags(( short ) 0);
Lines 1575-1581 Link Here
1575
                retval.setCompressedUnicodeFlag(( byte ) 0);
1555
                retval.setCompressedUnicodeFlag(( byte ) 0);
1576
                retval.setSheetname("Sheet1");
1556
                retval.setSheetname("Sheet1");
1577
                break;
1557
                break;
1578
1558
                
1579
            case 1 :
1559
            case 1 :
1580
                retval.setPositionOfBof(0x0);   // should be set later
1560
                retval.setPositionOfBof(0x0);   // should be set later
1581
                retval.setOptionFlags(( short ) 0);
1561
                retval.setOptionFlags(( short ) 0);
Lines 1583-1589 Link Here
1583
                retval.setCompressedUnicodeFlag(( byte ) 0);
1563
                retval.setCompressedUnicodeFlag(( byte ) 0);
1584
                retval.setSheetname("Sheet2");
1564
                retval.setSheetname("Sheet2");
1585
                break;
1565
                break;
1586
1566
                
1587
            case 2 :
1567
            case 2 :
1588
                retval.setPositionOfBof(0x0);   // should be set later
1568
                retval.setPositionOfBof(0x0);   // should be set later
1589
                retval.setOptionFlags(( short ) 0);
1569
                retval.setOptionFlags(( short ) 0);
Lines 1594-1628 Link Here
1594
        }
1574
        }
1595
        return retval;
1575
        return retval;
1596
    }
1576
    }
1597
1577
    
1598
    /**
1578
    /**
1599
     * Creates the Country record with the default and current country set to 1
1579
     * Creates the Country record with the default and current country set to 1
1600
     * @return record containing a CountryRecord
1580
     * @return record containing a CountryRecord
1601
     * @see org.apache.poi.hssf.record.CountryRecord
1581
     * @see org.apache.poi.hssf.record.CountryRecord
1602
     * @see org.apache.poi.hssf.record.Record
1582
     * @see org.apache.poi.hssf.record.Record
1603
     */
1583
     */
1604
1584
    
1605
    protected Record createCountry()
1585
    protected Record createCountry() {   // what a novel idea, create your own!
1606
    {   // what a novel idea, create your own!
1607
        CountryRecord retval = new CountryRecord();
1586
        CountryRecord retval = new CountryRecord();
1608
1587
        
1609
        retval.setDefaultCountry(( short ) 1);
1588
        retval.setDefaultCountry(( short ) 1);
1610
        retval.setCurrentCountry(( short ) 1);
1589
        retval.setCurrentCountry(( short ) 1);
1611
        return retval;
1590
        return retval;
1612
    }
1591
    }
1613
1592
    
1614
    /**
1593
    /**
1615
     * Creates the SST record with no strings and the unique/num string set to 0
1594
     * Creates the SST record with no strings and the unique/num string set to 0
1616
     * @return record containing a SSTRecord
1595
     * @return record containing a SSTRecord
1617
     * @see org.apache.poi.hssf.record.SSTRecord
1596
     * @see org.apache.poi.hssf.record.SSTRecord
1618
     * @see org.apache.poi.hssf.record.Record
1597
     * @see org.apache.poi.hssf.record.Record
1619
     */
1598
     */
1620
1599
    
1621
    protected Record createSST()
1600
    protected Record createSST() {
1622
    {
1623
        return new SSTRecord();
1601
        return new SSTRecord();
1624
    }
1602
    }
1625
1603
    
1626
    /**
1604
    /**
1627
     * Creates the ExtendedSST record with numstrings per bucket set to 0x8.  HSSF
1605
     * Creates the ExtendedSST record with numstrings per bucket set to 0x8.  HSSF
1628
     * doesn't yet know what to do with this thing, but we create it with nothing in
1606
     * doesn't yet know what to do with this thing, but we create it with nothing in
Lines 1632-1670 Link Here
1632
     * @see org.apache.poi.hssf.record.ExtSSTRecord
1610
     * @see org.apache.poi.hssf.record.ExtSSTRecord
1633
     * @see org.apache.poi.hssf.record.Record
1611
     * @see org.apache.poi.hssf.record.Record
1634
     */
1612
     */
1635
1613
    
1636
    protected Record createExtendedSST()
1614
    protected Record createExtendedSST() {
1637
    {
1638
        ExtSSTRecord retval = new ExtSSTRecord();
1615
        ExtSSTRecord retval = new ExtSSTRecord();
1639
1616
        
1640
        retval.setNumStringsPerBucket(( short ) 0x8);
1617
        retval.setNumStringsPerBucket(( short ) 0x8);
1641
        return retval;
1618
        return retval;
1642
    }
1619
    }
1643
1620
    
1644
    /**
1621
    /**
1645
     * creates the EOF record
1622
     * creates the EOF record
1646
     * @see org.apache.poi.hssf.record.EOFRecord
1623
     * @see org.apache.poi.hssf.record.EOFRecord
1647
     * @see org.apache.poi.hssf.record.Record
1624
     * @see org.apache.poi.hssf.record.Record
1648
     * @return record containing a EOFRecord
1625
     * @return record containing a EOFRecord
1649
     */
1626
     */
1650
1627
    
1651
    protected Record createEOF()
1628
    protected Record createEOF() {
1652
    {
1653
        return new EOFRecord();
1629
        return new EOFRecord();
1654
    }
1630
    }
1655
1631
    
1632
    /** fins the sheet name by his extern sheet index
1633
     * @param num extern sheet index
1634
     * @return sheet name
1635
     */
1636
    public String findSheetNameFromExternSheet(short num){
1637
        String result;
1638
        
1639
        short indexToSheet = externSheet.getREFRecordAt(num).getIndexToFirstSupBook();
1640
        result = getSheetName(indexToSheet);
1641
        
1642
        return result;
1643
    }
1644
    
1645
    /** returns the extern sheet number for specific sheet number ,
1646
     *  if this sheet doesn't exist in extern sheet , add it
1647
     * @param sheetNumber sheet number
1648
     * @return index to extern sheet
1649
     */
1650
    public short checkExternSheet(int sheetNumber){
1651
        
1652
        int i = 0;
1653
        boolean flag = false;
1654
        short result = 0;
1655
        
1656
        if (externSheet == null) {
1657
            externSheet = createExternSheet();
1658
        }
1659
        
1660
        //Trying to find reference to this sheet
1661
        while (i < externSheet.getNumOfREFStructures() && !flag){
1662
            ExternSheetSubRecord record = externSheet.getREFRecordAt(i);
1663
            
1664
            if (record.getIndexToFirstSupBook() ==  sheetNumber &&
1665
            record.getIndexToLastSupBook() == sheetNumber){
1666
                flag = true;
1667
                result = (short) i;
1668
            }
1669
            
1670
            ++i;
1671
        }
1672
        
1673
        //We Havent found reference to this sheet
1674
        if (!flag) {
1675
            result = addSheetIndexToExternSheet((short) sheetNumber);
1676
        }
1677
        
1678
        return result;
1679
    }
1680
    
1681
    private short addSheetIndexToExternSheet(short sheetNumber){
1682
        short result;
1683
        
1684
        ExternSheetSubRecord record = new ExternSheetSubRecord();
1685
        record.setIndexToFirstSupBook(sheetNumber);
1686
        record.setIndexToLastSupBook(sheetNumber);
1687
        externSheet.addREFRecord(record);
1688
        externSheet.setNumOfREFStructures((short)(externSheet.getNumOfREFStructures() + 1));
1689
        result = (short)(externSheet.getNumOfREFStructures() - 1);
1690
        
1691
        return result;
1692
    }
1693
    
1694
    
1695
    
1696
    /** gets the total number of names
1697
     * @return number of names
1698
     */
1699
    public int getNumNames(){
1700
        int result = names.size();
1701
        
1702
        return result;
1703
    }
1704
    
1705
    /** gets the name record
1706
     * @param index name index
1707
     * @return name record
1708
     */
1709
    public NameRecord getNameRecord(int index){
1710
        NameRecord result = (NameRecord) names.get(index);
1711
        
1712
        return result;
1713
        
1714
    }
1715
    
1716
    /** creates new name
1717
     * @return new name record
1718
     */
1719
    public NameRecord createName(){
1720
        
1721
        NameRecord name = new NameRecord();
1722
        
1723
        records.add(++namepos, name);
1724
        names.add(name);
1725
        
1726
        return name;
1727
    }
1728
    
1729
    /** removes the name
1730
     * @param namenum name index
1731
     */
1732
    public void removeName(int namenum){
1733
        if (names.size() > namenum) {
1734
            records.remove(namepos - (names.size() - 1) + namenum);
1735
            namepos--;
1736
            names.remove(namenum);
1737
        }
1738
        
1739
    }
1740
    
1741
    /** creates a new extern sheet record
1742
     * @return the new extern sheet record
1743
     */
1744
    protected ExternSheetRecord createExternSheet(){
1745
        ExternSheetRecord rec = new ExternSheetRecord();
1746
        
1747
        records.add(supbookpos + 1 , rec);
1748
        
1749
        //We also adds the supBook for internal reference
1750
        SupBookRecord supbook = new SupBookRecord();
1751
        
1752
        supbook.setNumberOfSheets((short)getNumSheets());
1753
        supbook.setFlag();
1754
        
1755
        records.add(supbookpos + 1 , supbook);
1756
        
1757
        return rec;
1758
    }
1759
    
1760
    
1656
    /**
1761
    /**
1657
     * Returns the first occurance of a record matching a particular sid.
1762
     * Returns the first occurance of a record matching a particular sid.
1658
     */
1763
     */
1659
1764
    
1660
    public Record findFirstRecordBySid(short sid)
1765
    public Record findFirstRecordBySid(short sid) {
1661
    {
1766
        for (Iterator iterator = records.iterator(); iterator.hasNext(); ) {
1662
        for (Iterator iterator = records.iterator(); iterator.hasNext(); )
1663
        {
1664
            Record record = ( Record ) iterator.next();
1767
            Record record = ( Record ) iterator.next();
1665
1768
            
1666
            if (record.getSid() == sid)
1769
            if (record.getSid() == sid) {
1667
            {
1668
                return record;
1770
                return record;
1669
            }
1771
            }
1670
        }
1772
        }

Return to bug 8114