PageRenderTime 60ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/components/forks/poi/src/loci/poi/hssf/model/Workbook.java

http://github.com/openmicroscopy/bioformats
Java | 2350 lines | 1394 code | 332 blank | 624 comment | 160 complexity | 2f47d8e4aa73ffbba0d056d2a6f68eee MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, Apache-2.0, BSD-2-Clause, MPL-2.0-no-copyleft-exception

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. * #%L
  3. * Fork of Apache Jakarta POI.
  4. * %%
  5. * Copyright (C) 2008 - 2013 Open Microscopy Environment:
  6. * - Board of Regents of the University of Wisconsin-Madison
  7. * - Glencoe Software, Inc.
  8. * - University of Dundee
  9. * %%
  10. * Licensed under the Apache License, Version 2.0 (the "License");
  11. * you may not use this file except in compliance with the License.
  12. * You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS,
  18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. * #L%
  22. */
  23. /* ====================================================================
  24. Licensed to the Apache Software Foundation (ASF) under one or more
  25. contributor license agreements. See the NOTICE file distributed with
  26. this work for additional information regarding copyright ownership.
  27. The ASF licenses this file to You under the Apache License, Version 2.0
  28. (the "License"); you may not use this file except in compliance with
  29. the License. You may obtain a copy of the License at
  30. http://www.apache.org/licenses/LICENSE-2.0
  31. Unless required by applicable law or agreed to in writing, software
  32. distributed under the License is distributed on an "AS IS" BASIS,
  33. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  34. See the License for the specific language governing permissions and
  35. limitations under the License.
  36. ==================================================================== */
  37. package loci.poi.hssf.model;
  38. import loci.poi.ddf.*;
  39. import loci.poi.hssf.record.*;
  40. import loci.poi.hssf.util.HSSFColor;
  41. import loci.poi.hssf.util.SheetReferences;
  42. import loci.poi.util.POILogFactory;
  43. import loci.poi.util.POILogger;
  44. import java.util.ArrayList;
  45. import java.util.Iterator;
  46. import java.util.List;
  47. import java.util.Locale;
  48. /**
  49. * Low level model implementation of a Workbook. Provides creational methods
  50. * for settings and objects contained in the workbook object.
  51. * <P>
  52. * This file contains the low level binary records starting at the workbook's BOF and
  53. * ending with the workbook's EOF. Use HSSFWorkbook for a high level representation.
  54. * <P>
  55. * The structures of the highlevel API use references to this to perform most of their
  56. * operations. Its probably unwise to use these low level structures directly unless you
  57. * really know what you're doing. I recommend you read the Microsoft Excel 97 Developer's
  58. * Kit (Microsoft Press) and the documentation at http://sc.openoffice.org/excelfileformat.pdf
  59. * before even attempting to use this.
  60. *
  61. *
  62. * @author Luc Girardin (luc dot girardin at macrofocus dot com)
  63. * @author Sergei Kozello (sergeikozello at mail.ru)
  64. * @author Shawn Laubach (slaubach at apache dot org) (Data Formats)
  65. * @author Andrew C. Oliver (acoliver at apache dot org)
  66. * @author Brian Sanders (bsanders at risklabs dot com) - custom palette
  67. * @author Dan Sherman (dsherman at isisph.com)
  68. * @author Glen Stampoultzis (glens at apache.org)
  69. * @see loci.poi.hssf.usermodel.HSSFWorkbook
  70. * @version 1.0-pre
  71. */
  72. public class Workbook implements Model
  73. {
  74. private static final int DEBUG = POILogger.DEBUG;
  75. // public static Workbook currentBook = null;
  76. /**
  77. * constant used to set the "codepage" wherever "codepage" is set in records
  78. * (which is duplciated in more than one record)
  79. */
  80. private final static short CODEPAGE = ( short ) 0x4b0;
  81. /**
  82. * this contains the Worksheet record objects
  83. */
  84. protected WorkbookRecordList records = new WorkbookRecordList();
  85. /**
  86. * this contains a reference to the SSTRecord so that new stings can be added
  87. * to it.
  88. */
  89. protected SSTRecord sst = null;
  90. /**
  91. * Holds the Extern Sheet with references to bound sheets
  92. */
  93. protected ExternSheetRecord externSheet= null;
  94. /**
  95. * holds the "boundsheet" records (aka bundlesheet) so that they can have their
  96. * reference to their "BOF" marker
  97. */
  98. protected ArrayList boundsheets = new ArrayList();
  99. protected ArrayList formats = new ArrayList();
  100. protected ArrayList names = new ArrayList();
  101. protected int numxfs = 0; // hold the number of extended format records
  102. protected int numfonts = 0; // hold the number of font records
  103. private short maxformatid = -1; // holds the max format id
  104. private boolean uses1904datewindowing = false; // whether 1904 date windowing is being used
  105. private DrawingManager2 drawingManager;
  106. private List escherBSERecords = new ArrayList(); // EscherBSERecord
  107. private WindowOneRecord windowOne;
  108. private FileSharingRecord fileShare;
  109. private WriteAccessRecord writeAccess;
  110. private WriteProtectRecord writeProtect;
  111. private static POILogger log = POILogFactory.getLogger(Workbook.class);
  112. /**
  113. * Creates new Workbook with no intitialization --useless right now
  114. * @see #createWorkbook(List)
  115. */
  116. public Workbook() {
  117. }
  118. /**
  119. * read support for low level
  120. * API. Pass in an array of Record objects, A Workbook
  121. * object is constructed and passed back with all of its initialization set
  122. * to the passed in records and references to those records held. Unlike Sheet
  123. * workbook does not use an offset (its assumed to be 0) since its first in a file.
  124. * If you need an offset then construct a new array with a 0 offset or write your
  125. * own ;-p.
  126. *
  127. * @param recs an array of Record objects
  128. * @return Workbook object
  129. */
  130. public static Workbook createWorkbook(List recs) {
  131. if (log.check( POILogger.DEBUG ))
  132. log.log(DEBUG, "Workbook (readfile) created with reclen=",
  133. new Integer(recs.size()));
  134. Workbook retval = new Workbook();
  135. ArrayList records = new ArrayList(recs.size() / 3);
  136. for (int k = 0; k < recs.size(); k++) {
  137. Record rec = ( Record ) recs.get(k);
  138. if (rec.getSid() == EOFRecord.sid) {
  139. records.add(rec);
  140. if (log.check( POILogger.DEBUG ))
  141. log.log(DEBUG, "found workbook eof record at " + k);
  142. break;
  143. }
  144. switch (rec.getSid()) {
  145. case BoundSheetRecord.sid :
  146. if (log.check( POILogger.DEBUG ))
  147. log.log(DEBUG, "found boundsheet record at " + k);
  148. retval.boundsheets.add(rec);
  149. retval.records.setBspos( k );
  150. break;
  151. case SSTRecord.sid :
  152. if (log.check( POILogger.DEBUG ))
  153. log.log(DEBUG, "found sst record at " + k);
  154. retval.sst = ( SSTRecord ) rec;
  155. break;
  156. case FontRecord.sid :
  157. if (log.check( POILogger.DEBUG ))
  158. log.log(DEBUG, "found font record at " + k);
  159. retval.records.setFontpos( k );
  160. retval.numfonts++;
  161. break;
  162. case ExtendedFormatRecord.sid :
  163. if (log.check( POILogger.DEBUG ))
  164. log.log(DEBUG, "found XF record at " + k);
  165. retval.records.setXfpos( k );
  166. retval.numxfs++;
  167. break;
  168. case TabIdRecord.sid :
  169. if (log.check( POILogger.DEBUG ))
  170. log.log(DEBUG, "found tabid record at " + k);
  171. retval.records.setTabpos( k );
  172. break;
  173. case ProtectRecord.sid :
  174. if (log.check( POILogger.DEBUG ))
  175. log.log(DEBUG, "found protect record at " + k);
  176. retval.records.setProtpos( k );
  177. break;
  178. case BackupRecord.sid :
  179. if (log.check( POILogger.DEBUG ))
  180. log.log(DEBUG, "found backup record at " + k);
  181. retval.records.setBackuppos( k );
  182. break;
  183. case ExternSheetRecord.sid :
  184. if (log.check( POILogger.DEBUG ))
  185. log.log(DEBUG, "found extern sheet record at " + k);
  186. retval.externSheet = ( ExternSheetRecord ) rec;
  187. break;
  188. case NameRecord.sid :
  189. if (log.check( POILogger.DEBUG ))
  190. log.log(DEBUG, "found name record at " + k);
  191. retval.names.add(rec);
  192. // retval.records.namepos = k;
  193. break;
  194. case SupBookRecord.sid :
  195. if (log.check( POILogger.DEBUG ))
  196. log.log(DEBUG, "found SupBook record at " + k);
  197. // retval.records.supbookpos = k;
  198. break;
  199. case FormatRecord.sid :
  200. if (log.check( POILogger.DEBUG ))
  201. log.log(DEBUG, "found format record at " + k);
  202. retval.formats.add(rec);
  203. retval.maxformatid = retval.maxformatid >= ((FormatRecord)rec).getIndexCode() ? retval.maxformatid : ((FormatRecord)rec).getIndexCode();
  204. break;
  205. case DateWindow1904Record.sid :
  206. if (log.check( POILogger.DEBUG ))
  207. log.log(DEBUG, "found datewindow1904 record at " + k);
  208. retval.uses1904datewindowing = ((DateWindow1904Record)rec).getWindowing() == 1;
  209. break;
  210. case PaletteRecord.sid:
  211. if (log.check( POILogger.DEBUG ))
  212. log.log(DEBUG, "found palette record at " + k);
  213. retval.records.setPalettepos( k );
  214. break;
  215. case WindowOneRecord.sid:
  216. if (log.check( POILogger.DEBUG ))
  217. log.log(DEBUG, "found WindowOneRecord at " + k);
  218. retval.windowOne = (WindowOneRecord) rec;
  219. break;
  220. case WriteAccessRecord.sid:
  221. if (log.check( POILogger.DEBUG ))
  222. log.log(DEBUG, "found WriteAccess at " + k);
  223. retval.writeAccess = (WriteAccessRecord) rec;
  224. break;
  225. case WriteProtectRecord.sid:
  226. if (log.check( POILogger.DEBUG ))
  227. log.log(DEBUG, "found WriteProtect at " + k);
  228. retval.writeProtect = (WriteProtectRecord) rec;
  229. break;
  230. case FileSharingRecord.sid:
  231. if (log.check( POILogger.DEBUG ))
  232. log.log(DEBUG, "found FileSharing at " + k);
  233. retval.fileShare = (FileSharingRecord) rec;
  234. default :
  235. }
  236. records.add(rec);
  237. }
  238. //What if we dont have any ranges and supbooks
  239. // if (retval.records.supbookpos == 0) {
  240. // retval.records.supbookpos = retval.records.bspos + 1;
  241. // retval.records.namepos = retval.records.supbookpos + 1;
  242. // }
  243. retval.records.setRecords(records);
  244. if (retval.windowOne == null) {
  245. retval.windowOne = (WindowOneRecord) retval.createWindowOne();
  246. }
  247. if (log.check( POILogger.DEBUG ))
  248. log.log(DEBUG, "exit create workbook from existing file function");
  249. return retval;
  250. }
  251. /**
  252. * Creates an empty workbook object with three blank sheets and all the empty
  253. * fields. Use this to create a workbook from scratch.
  254. */
  255. public static Workbook createWorkbook()
  256. {
  257. if (log.check( POILogger.DEBUG ))
  258. log.log( DEBUG, "creating new workbook from scratch" );
  259. Workbook retval = new Workbook();
  260. ArrayList records = new ArrayList( 30 );
  261. ArrayList formats = new ArrayList( 8 );
  262. records.add( retval.createBOF() );
  263. records.add( retval.createInterfaceHdr() );
  264. records.add( retval.createMMS() );
  265. records.add( retval.createInterfaceEnd() );
  266. records.add( retval.createWriteAccess() );
  267. records.add( retval.createCodepage() );
  268. records.add( retval.createDSF() );
  269. records.add( retval.createTabId() );
  270. retval.records.setTabpos( records.size() - 1 );
  271. records.add( retval.createFnGroupCount() );
  272. records.add( retval.createWindowProtect() );
  273. records.add( retval.createProtect() );
  274. retval.records.setProtpos( records.size() - 1 );
  275. records.add( retval.createPassword() );
  276. records.add( retval.createProtectionRev4() );
  277. records.add( retval.createPasswordRev4() );
  278. retval.windowOne = (WindowOneRecord) retval.createWindowOne();
  279. records.add( retval.windowOne );
  280. records.add( retval.createBackup() );
  281. retval.records.setBackuppos( records.size() - 1 );
  282. records.add( retval.createHideObj() );
  283. records.add( retval.createDateWindow1904() );
  284. records.add( retval.createPrecision() );
  285. records.add( retval.createRefreshAll() );
  286. records.add( retval.createBookBool() );
  287. records.add( retval.createFont() );
  288. records.add( retval.createFont() );
  289. records.add( retval.createFont() );
  290. records.add( retval.createFont() );
  291. retval.records.setFontpos( records.size() - 1 ); // last font record postion
  292. retval.numfonts = 4;
  293. // set up format records
  294. for ( int i = 0; i <= 7; i++ )
  295. {
  296. Record rec;
  297. rec = retval.createFormat( i );
  298. retval.maxformatid = retval.maxformatid >= ( (FormatRecord) rec ).getIndexCode() ? retval.maxformatid : ( (FormatRecord) rec ).getIndexCode();
  299. formats.add( rec );
  300. records.add( rec );
  301. }
  302. retval.formats = formats;
  303. for ( int k = 0; k < 21; k++ )
  304. {
  305. records.add( retval.createExtendedFormat( k ) );
  306. retval.numxfs++;
  307. }
  308. retval.records.setXfpos( records.size() - 1 );
  309. for ( int k = 0; k < 6; k++ )
  310. {
  311. records.add( retval.createStyle( k ) );
  312. }
  313. records.add( retval.createUseSelFS() );
  314. for ( int k = 0; k < 1; k++ )
  315. { // now just do 1
  316. BoundSheetRecord bsr =
  317. (BoundSheetRecord) retval.createBoundSheet( k );
  318. records.add( bsr );
  319. retval.boundsheets.add( bsr );
  320. retval.records.setBspos( records.size() - 1 );
  321. }
  322. // retval.records.supbookpos = retval.records.bspos + 1;
  323. // retval.records.namepos = retval.records.supbookpos + 2;
  324. records.add( retval.createCountry() );
  325. retval.sst = (SSTRecord) retval.createSST();
  326. records.add( retval.sst );
  327. records.add( retval.createExtendedSST() );
  328. records.add( retval.createEOF() );
  329. retval.records.setRecords(records);
  330. if (log.check( POILogger.DEBUG ))
  331. log.log( DEBUG, "exit create new workbook from scratch" );
  332. return retval;
  333. }
  334. /**Retrieves the Builtin NameRecord that matches the name and index
  335. * There shouldn't be too many names to make the sequential search too slow
  336. * @param name byte representation of the builtin name to match
  337. * @param sheetIndex Index to match
  338. * @return null if no builtin NameRecord matches
  339. */
  340. public NameRecord getSpecificBuiltinRecord(byte name, int sheetIndex)
  341. {
  342. Iterator iterator = names.iterator();
  343. while (iterator.hasNext()) {
  344. NameRecord record = ( NameRecord ) iterator.next();
  345. //print areas are one based
  346. if (record.getBuiltInName() == name && record.getIndexToSheet() == sheetIndex) {
  347. return record;
  348. }
  349. }
  350. return null;
  351. }
  352. /**
  353. * Removes the specified Builtin NameRecord that matches the name and index
  354. * @param name byte representation of the builtin to match
  355. * @param sheetIndex zero-based sheet reference
  356. */
  357. public void removeBuiltinRecord(byte name, int sheetIndex) {
  358. //the name array is smaller so searching through it should be faster than
  359. //using the findFirstXXXX methods
  360. NameRecord record = getSpecificBuiltinRecord(name, sheetIndex);
  361. if (record != null) {
  362. names.remove(record);
  363. }
  364. }
  365. public int getNumRecords() {
  366. return records.size();
  367. }
  368. /**
  369. * gets the font record at the given index in the font table. Remember
  370. * "There is No Four" (someone at M$ must have gone to Rocky Horror one too
  371. * many times)
  372. *
  373. * @param idx the index to look at (0 or greater but NOT 4)
  374. * @return FontRecord located at the given index
  375. */
  376. public FontRecord getFontRecordAt(int idx) {
  377. int index = idx;
  378. if (index > 4) {
  379. index -= 1; // adjust for "There is no 4"
  380. }
  381. if (index > (numfonts - 1)) {
  382. throw new ArrayIndexOutOfBoundsException(
  383. "There are only " + numfonts
  384. + " font records, you asked for " + idx);
  385. }
  386. FontRecord retval =
  387. ( FontRecord ) records.get((records.getFontpos() - (numfonts - 1)) + index);
  388. return retval;
  389. }
  390. /**
  391. * creates a new font record and adds it to the "font table". This causes the
  392. * boundsheets to move down one, extended formats to move down (so this function moves
  393. * those pointers as well)
  394. *
  395. * @return FontRecord that was just created
  396. */
  397. public FontRecord createNewFont() {
  398. FontRecord rec = ( FontRecord ) createFont();
  399. records.add(records.getFontpos()+1, rec);
  400. records.setFontpos( records.getFontpos() + 1 );
  401. numfonts++;
  402. return rec;
  403. }
  404. /**
  405. * gets the number of font records
  406. *
  407. * @return number of font records in the "font table"
  408. */
  409. public int getNumberOfFontRecords() {
  410. return numfonts;
  411. }
  412. /**
  413. * Sets the BOF for a given sheet
  414. *
  415. * @param sheetnum the number of the sheet to set the positing of the bof for
  416. * @param pos the actual bof position
  417. */
  418. public void setSheetBof(int sheetnum, int pos) {
  419. if (log.check( POILogger.DEBUG ))
  420. log.log(DEBUG, "setting bof for sheetnum =", new Integer(sheetnum),
  421. " at pos=", new Integer(pos));
  422. checkSheets(sheetnum);
  423. (( BoundSheetRecord ) boundsheets.get(sheetnum))
  424. .setPositionOfBof(pos);
  425. }
  426. /**
  427. * Returns the position of the backup record.
  428. */
  429. public BackupRecord getBackupRecord() {
  430. return ( BackupRecord ) records.get(records.getBackuppos());
  431. }
  432. /**
  433. * sets the name for a given sheet. If the boundsheet record doesn't exist and
  434. * its only one more than we have, go ahead and create it. If its > 1 more than
  435. * we have, except
  436. *
  437. * @param sheetnum the sheet number (0 based)
  438. * @param sheetname the name for the sheet
  439. */
  440. public void setSheetName(int sheetnum, String sheetname ) {
  441. checkSheets(sheetnum);
  442. BoundSheetRecord sheet = (BoundSheetRecord)boundsheets.get( sheetnum );
  443. sheet.setSheetname(sheetname);
  444. sheet.setSheetnameLength( (byte)sheetname.length() );
  445. }
  446. /**
  447. * Determines whether a workbook contains the privided sheet name.
  448. *
  449. * @param name the name to test
  450. * @param excludeSheetIdx the sheet to exclude from the check or -1 to include all sheets in the check.
  451. * @return true if the sheet contains the name, false otherwise.
  452. */
  453. public boolean doesContainsSheetName( String name, int excludeSheetIdx )
  454. {
  455. for ( int i = 0; i < boundsheets.size(); i++ )
  456. {
  457. BoundSheetRecord boundSheetRecord = (BoundSheetRecord) boundsheets.get( i );
  458. if (excludeSheetIdx != i && name.equals(boundSheetRecord.getSheetname()))
  459. return true;
  460. }
  461. return false;
  462. }
  463. /**
  464. * sets the name for a given sheet forcing the encoding. This is STILL A BAD IDEA.
  465. * Poi now automatically detects unicode
  466. *
  467. *@deprecated 3-Jan-06 Simply use setSheetNam e(int sheetnum, String sheetname)
  468. * @param sheetnum the sheet number (0 based)
  469. * @param sheetname the name for the sheet
  470. */
  471. public void setSheetName(int sheetnum, String sheetname, short encoding ) {
  472. checkSheets(sheetnum);
  473. BoundSheetRecord sheet = (BoundSheetRecord)boundsheets.get( sheetnum );
  474. sheet.setSheetname(sheetname);
  475. sheet.setSheetnameLength( (byte)sheetname.length() );
  476. sheet.setCompressedUnicodeFlag( (byte)encoding );
  477. }
  478. /**
  479. * sets the order of appearance for a given sheet.
  480. *
  481. * @param sheetname the name of the sheet to reorder
  482. * @param pos the position that we want to insert the sheet into (0 based)
  483. */
  484. public void setSheetOrder(String sheetname, int pos ) {
  485. int sheetNumber = getSheetIndex(sheetname);
  486. //remove the sheet that needs to be reordered and place it in the spot we want
  487. boundsheets.add(pos, boundsheets.remove(sheetNumber));
  488. }
  489. /**
  490. * gets the name for a given sheet.
  491. *
  492. * @param sheetnum the sheet number (0 based)
  493. * @return sheetname the name for the sheet
  494. */
  495. public String getSheetName(int sheetnum) {
  496. return (( BoundSheetRecord ) boundsheets.get(sheetnum))
  497. .getSheetname();
  498. }
  499. /**
  500. * get the sheet's index
  501. * @param name sheet name
  502. * @return sheet index or -1 if it was not found.
  503. */
  504. public int getSheetIndex(String name) {
  505. int retval = -1;
  506. for (int k = 0; k < boundsheets.size(); k++) {
  507. String sheet = getSheetName(k);
  508. if (sheet.equalsIgnoreCase(name)) {
  509. retval = k;
  510. break;
  511. }
  512. }
  513. return retval;
  514. }
  515. /**
  516. * if we're trying to address one more sheet than we have, go ahead and add it! if we're
  517. * trying to address >1 more than we have throw an exception!
  518. */
  519. private void checkSheets(int sheetnum) {
  520. if ((boundsheets.size()) <= sheetnum) { // if we're short one add another..
  521. if ((boundsheets.size() + 1) <= sheetnum) {
  522. throw new RuntimeException("Sheet number out of bounds!");
  523. }
  524. BoundSheetRecord bsr = (BoundSheetRecord ) createBoundSheet(sheetnum);
  525. records.add(records.getBspos()+1, bsr);
  526. records.setBspos( records.getBspos() + 1 );
  527. boundsheets.add(bsr);
  528. fixTabIdRecord();
  529. }
  530. }
  531. public void removeSheet(int sheetnum) {
  532. if (boundsheets.size() > sheetnum) {
  533. records.remove(records.getBspos() - (boundsheets.size() - 1) + sheetnum);
  534. // records.bspos--;
  535. boundsheets.remove(sheetnum);
  536. fixTabIdRecord();
  537. }
  538. }
  539. /**
  540. * make the tabid record look like the current situation.
  541. *
  542. */
  543. private void fixTabIdRecord() {
  544. TabIdRecord tir = ( TabIdRecord ) records.get(records.getTabpos());
  545. short[] tia = new short[ boundsheets.size() ];
  546. for (short k = 0; k < tia.length; k++) {
  547. tia[ k ] = k;
  548. }
  549. tir.setTabIdArray(tia);
  550. }
  551. /**
  552. * returns the number of boundsheet objects contained in this workbook.
  553. *
  554. * @return number of BoundSheet records
  555. */
  556. public int getNumSheets() {
  557. if (log.check( POILogger.DEBUG ))
  558. log.log(DEBUG, "getNumSheets=", new Integer(boundsheets.size()));
  559. return boundsheets.size();
  560. }
  561. /**
  562. * get the number of ExtendedFormat records contained in this workbook.
  563. *
  564. * @return int count of ExtendedFormat records
  565. */
  566. public int getNumExFormats() {
  567. if (log.check( POILogger.DEBUG ))
  568. log.log(DEBUG, "getXF=", new Integer(numxfs));
  569. return numxfs;
  570. }
  571. /**
  572. * gets the ExtendedFormatRecord at the given 0-based index
  573. *
  574. * @param index of the Extended format record (0-based)
  575. * @return ExtendedFormatRecord at the given index
  576. */
  577. public ExtendedFormatRecord getExFormatAt(int index) {
  578. int xfptr = records.getXfpos() - (numxfs - 1);
  579. xfptr += index;
  580. ExtendedFormatRecord retval =
  581. ( ExtendedFormatRecord ) records.get(xfptr);
  582. return retval;
  583. }
  584. /**
  585. * creates a new Cell-type Extneded Format Record and adds it to the end of
  586. * ExtendedFormatRecords collection
  587. *
  588. * @return ExtendedFormatRecord that was created
  589. */
  590. public ExtendedFormatRecord createCellXF() {
  591. ExtendedFormatRecord xf = createExtendedFormat();
  592. records.add(records.getXfpos()+1, xf);
  593. records.setXfpos( records.getXfpos() + 1 );
  594. numxfs++;
  595. return xf;
  596. }
  597. /**
  598. * Adds a string to the SST table and returns its index (if its a duplicate
  599. * just returns its index and update the counts) ASSUMES compressed unicode
  600. * (meaning 8bit)
  601. *
  602. * @param string the string to be added to the SSTRecord
  603. *
  604. * @return index of the string within the SSTRecord
  605. */
  606. public int addSSTString(UnicodeString string) {
  607. if (log.check( POILogger.DEBUG ))
  608. log.log(DEBUG, "insert to sst string='", string);
  609. if (sst == null) {
  610. insertSST();
  611. }
  612. return sst.addString(string);
  613. }
  614. /**
  615. * given an index into the SST table, this function returns the corresponding String value
  616. * @return String containing the SST String
  617. */
  618. public UnicodeString getSSTString(int str) {
  619. if (sst == null) {
  620. insertSST();
  621. }
  622. UnicodeString retval = sst.getString(str);
  623. if (log.check( POILogger.DEBUG ))
  624. log.log(DEBUG, "Returning SST for index=", new Integer(str),
  625. " String= ", retval);
  626. return retval;
  627. }
  628. /**
  629. * use this function to add a Shared String Table to an existing sheet (say
  630. * generated by a different java api) without an sst....
  631. * @see #createSST()
  632. * @see loci.poi.hssf.record.SSTRecord
  633. */
  634. public void insertSST() {
  635. if (log.check( POILogger.DEBUG ))
  636. log.log(DEBUG, "creating new SST via insertSST!");
  637. sst = ( SSTRecord ) createSST();
  638. records.add(records.size() - 1, createExtendedSST());
  639. records.add(records.size() - 2, sst);
  640. }
  641. /**
  642. * Serializes all records int the worksheet section into a big byte array. Use
  643. * this to write the Workbook out.
  644. *
  645. * @return byte array containing the HSSF-only portions of the POIFS file.
  646. */
  647. // GJS: Not used so why keep it.
  648. // public byte [] serialize() {
  649. // log.log(DEBUG, "Serializing Workbook!");
  650. // byte[] retval = null;
  651. //
  652. //// ArrayList bytes = new ArrayList(records.size());
  653. // int arraysize = getSize();
  654. // int pos = 0;
  655. //
  656. // retval = new byte[ arraysize ];
  657. // for (int k = 0; k < records.size(); k++) {
  658. //
  659. // Record record = records.get(k);
  660. //// Let's skip RECALCID records, as they are only use for optimization
  661. // if(record.getSid() != RecalcIdRecord.sid || ((RecalcIdRecord)record).isNeeded()) {
  662. // pos += record.serialize(pos, retval); // rec.length;
  663. // }
  664. // }
  665. // log.log(DEBUG, "Exiting serialize workbook");
  666. // return retval;
  667. // }
  668. /**
  669. * Serializes all records int the worksheet section into a big byte array. Use
  670. * this to write the Workbook out.
  671. * @param offset of the data to be written
  672. * @param data array of bytes to write this to
  673. */
  674. public int serialize( int offset, byte[] data )
  675. {
  676. if (log.check( POILogger.DEBUG ))
  677. log.log( DEBUG, "Serializing Workbook with offsets" );
  678. int pos = 0;
  679. SSTRecord sst = null;
  680. int sstPos = 0;
  681. boolean wroteBoundSheets = false;
  682. for ( int k = 0; k < records.size(); k++ )
  683. {
  684. Record record = records.get( k );
  685. // Let's skip RECALCID records, as they are only use for optimization
  686. if ( record.getSid() != RecalcIdRecord.sid || ( (RecalcIdRecord) record ).isNeeded() )
  687. {
  688. int len = 0;
  689. if (record instanceof SSTRecord)
  690. {
  691. sst = (SSTRecord)record;
  692. sstPos = pos;
  693. }
  694. if (record.getSid() == ExtSSTRecord.sid && sst != null)
  695. {
  696. record = sst.createExtSSTRecord(sstPos + offset);
  697. }
  698. if (record instanceof BoundSheetRecord) {
  699. if(!wroteBoundSheets) {
  700. for (int i = 0; i < boundsheets.size(); i++) {
  701. len+= ((BoundSheetRecord)boundsheets.get(i))
  702. .serialize(pos+offset+len, data);
  703. }
  704. wroteBoundSheets = true;
  705. }
  706. } else {
  707. len = record.serialize( pos + offset, data );
  708. }
  709. ///// DEBUG BEGIN /////
  710. // if (len != record.getRecordSize())
  711. // throw new IllegalStateException("Record size does not match serialized bytes. Serialized size = " + len + " but getRecordSize() returns " + record.getRecordSize());
  712. ///// DEBUG END /////
  713. pos += len; // rec.length;
  714. }
  715. }
  716. if (log.check( POILogger.DEBUG ))
  717. log.log( DEBUG, "Exiting serialize workbook" );
  718. return pos;
  719. }
  720. public int getSize()
  721. {
  722. int retval = 0;
  723. SSTRecord sst = null;
  724. for ( int k = 0; k < records.size(); k++ )
  725. {
  726. Record record = records.get( k );
  727. // Let's skip RECALCID records, as they are only use for optimization
  728. if ( record.getSid() != RecalcIdRecord.sid || ( (RecalcIdRecord) record ).isNeeded() )
  729. {
  730. if (record instanceof SSTRecord)
  731. sst = (SSTRecord)record;
  732. if (record.getSid() == ExtSSTRecord.sid && sst != null)
  733. retval += sst.calcExtSSTRecordSize();
  734. else
  735. retval += record.getRecordSize();
  736. }
  737. }
  738. return retval;
  739. }
  740. /**
  741. * creates the BOF record
  742. * @see loci.poi.hssf.record.BOFRecord
  743. * @see loci.poi.hssf.record.Record
  744. * @return record containing a BOFRecord
  745. */
  746. protected Record createBOF() {
  747. BOFRecord retval = new BOFRecord();
  748. retval.setVersion(( short ) 0x600);
  749. retval.setType(( short ) 5);
  750. retval.setBuild(( short ) 0x10d3);
  751. // retval.setBuild((short)0x0dbb);
  752. retval.setBuildYear(( short ) 1996);
  753. retval.setHistoryBitMask(0x41); // was c1 before verify
  754. retval.setRequiredVersion(0x6);
  755. return retval;
  756. }
  757. /**
  758. * creates the InterfaceHdr record
  759. * @see loci.poi.hssf.record.InterfaceHdrRecord
  760. * @see loci.poi.hssf.record.Record
  761. * @return record containing a InterfaceHdrRecord
  762. */
  763. protected Record createInterfaceHdr() {
  764. InterfaceHdrRecord retval = new InterfaceHdrRecord();
  765. retval.setCodepage(CODEPAGE);
  766. return retval;
  767. }
  768. /**
  769. * creates an MMS record
  770. * @see loci.poi.hssf.record.MMSRecord
  771. * @see loci.poi.hssf.record.Record
  772. * @return record containing a MMSRecord
  773. */
  774. protected Record createMMS() {
  775. MMSRecord retval = new MMSRecord();
  776. retval.setAddMenuCount(( byte ) 0);
  777. retval.setDelMenuCount(( byte ) 0);
  778. return retval;
  779. }
  780. /**
  781. * creates the InterfaceEnd record
  782. * @see loci.poi.hssf.record.InterfaceEndRecord
  783. * @see loci.poi.hssf.record.Record
  784. * @return record containing a InterfaceEndRecord
  785. */
  786. protected Record createInterfaceEnd() {
  787. return new InterfaceEndRecord();
  788. }
  789. /**
  790. * creates the WriteAccess record containing the logged in user's name
  791. * @see loci.poi.hssf.record.WriteAccessRecord
  792. * @see loci.poi.hssf.record.Record
  793. * @return record containing a WriteAccessRecord
  794. */
  795. protected Record createWriteAccess() {
  796. WriteAccessRecord retval = new WriteAccessRecord();
  797. try
  798. {
  799. retval.setUsername(System.getProperty("user.name"));
  800. }
  801. catch (java.security.AccessControlException e)
  802. {
  803. // AccessControlException can occur in a restricted context
  804. // (client applet/jws application or restricted security server)
  805. retval.setUsername("POI");
  806. }
  807. return retval;
  808. }
  809. /**
  810. * creates the Codepage record containing the constant stored in CODEPAGE
  811. * @see loci.poi.hssf.record.CodepageRecord
  812. * @see loci.poi.hssf.record.Record
  813. * @return record containing a CodepageRecord
  814. */
  815. protected Record createCodepage() {
  816. CodepageRecord retval = new CodepageRecord();
  817. retval.setCodepage(CODEPAGE);
  818. return retval;
  819. }
  820. /**
  821. * creates the DSF record containing a 0 since HSSF can't even create Dual Stream Files
  822. * @see loci.poi.hssf.record.DSFRecord
  823. * @see loci.poi.hssf.record.Record
  824. * @return record containing a DSFRecord
  825. */
  826. protected Record createDSF() {
  827. DSFRecord retval = new DSFRecord();
  828. retval.setDsf(
  829. ( short ) 0); // we don't even support double stream files
  830. return retval;
  831. }
  832. /**
  833. * creates the TabId record containing an array of 0,1,2. This release of HSSF
  834. * always has the default three sheets, no less, no more.
  835. * @see loci.poi.hssf.record.TabIdRecord
  836. * @see loci.poi.hssf.record.Record
  837. * @return record containing a TabIdRecord
  838. */
  839. protected Record createTabId() {
  840. TabIdRecord retval = new TabIdRecord();
  841. short[] tabidarray = {
  842. 0
  843. };
  844. retval.setTabIdArray(tabidarray);
  845. return retval;
  846. }
  847. /**
  848. * creates the FnGroupCount record containing the Magic number constant of 14.
  849. * @see loci.poi.hssf.record.FnGroupCountRecord
  850. * @see loci.poi.hssf.record.Record
  851. * @return record containing a FnGroupCountRecord
  852. */
  853. protected Record createFnGroupCount() {
  854. FnGroupCountRecord retval = new FnGroupCountRecord();
  855. retval.setCount(( short ) 14);
  856. return retval;
  857. }
  858. /**
  859. * creates the WindowProtect record with protect set to false.
  860. * @see loci.poi.hssf.record.WindowProtectRecord
  861. * @see loci.poi.hssf.record.Record
  862. * @return record containing a WindowProtectRecord
  863. */
  864. protected Record createWindowProtect() {
  865. WindowProtectRecord retval = new WindowProtectRecord();
  866. retval.setProtect(
  867. false); // by default even when we support it we won't
  868. return retval; // want it to be protected
  869. }
  870. /**
  871. * creates the Protect record with protect set to false.
  872. * @see loci.poi.hssf.record.ProtectRecord
  873. * @see loci.poi.hssf.record.Record
  874. * @return record containing a ProtectRecord
  875. */
  876. protected Record createProtect() {
  877. ProtectRecord retval = new ProtectRecord();
  878. retval.setProtect(
  879. false); // by default even when we support it we won't
  880. return retval; // want it to be protected
  881. }
  882. /**
  883. * creates the Password record with password set to 0.
  884. * @see loci.poi.hssf.record.PasswordRecord
  885. * @see loci.poi.hssf.record.Record
  886. * @return record containing a PasswordRecord
  887. */
  888. protected Record createPassword() {
  889. PasswordRecord retval = new PasswordRecord();
  890. retval.setPassword(( short ) 0); // no password by default!
  891. return retval;
  892. }
  893. /**
  894. * creates the ProtectionRev4 record with protect set to false.
  895. * @see loci.poi.hssf.record.ProtectionRev4Record
  896. * @see loci.poi.hssf.record.Record
  897. * @return record containing a ProtectionRev4Record
  898. */
  899. protected Record createProtectionRev4() {
  900. ProtectionRev4Record retval = new ProtectionRev4Record();
  901. retval.setProtect(false);
  902. return retval;
  903. }
  904. /**
  905. * creates the PasswordRev4 record with password set to 0.
  906. * @see loci.poi.hssf.record.PasswordRev4Record
  907. * @see loci.poi.hssf.record.Record
  908. * @return record containing a PasswordRev4Record
  909. */
  910. protected Record createPasswordRev4() {
  911. PasswordRev4Record retval = new PasswordRev4Record();
  912. retval.setPassword(( short ) 0); // no password by default!
  913. return retval;
  914. }
  915. /**
  916. * creates the WindowOne record with the following magic values: <P>
  917. * horizontal hold - 0x168 <P>
  918. * vertical hold - 0x10e <P>
  919. * width - 0x3a5c <P>
  920. * height - 0x23be <P>
  921. * options - 0x38 <P>
  922. * selected tab - 0 <P>
  923. * displayed tab - 0 <P>
  924. * num selected tab- 0 <P>
  925. * tab width ratio - 0x258 <P>
  926. * @see loci.poi.hssf.record.WindowOneRecord
  927. * @see loci.poi.hssf.record.Record
  928. * @return record containing a WindowOneRecord
  929. */
  930. protected Record createWindowOne() {
  931. WindowOneRecord retval = new WindowOneRecord();
  932. retval.setHorizontalHold(( short ) 0x168);
  933. retval.setVerticalHold(( short ) 0x10e);
  934. retval.setWidth(( short ) 0x3a5c);
  935. retval.setHeight(( short ) 0x23be);
  936. retval.setOptions(( short ) 0x38);
  937. retval.setSelectedTab(( short ) 0x0);
  938. retval.setDisplayedTab(( short ) 0x0);
  939. retval.setNumSelectedTabs(( short ) 1);
  940. retval.setTabWidthRatio(( short ) 0x258);
  941. return retval;
  942. }
  943. /**
  944. * creates the Backup record with backup set to 0. (loose the data, who cares)
  945. * @see loci.poi.hssf.record.BackupRecord
  946. * @see loci.poi.hssf.record.Record
  947. * @return record containing a BackupRecord
  948. */
  949. protected Record createBackup() {
  950. BackupRecord retval = new BackupRecord();
  951. retval.setBackup(
  952. ( short ) 0); // by default DONT save backups of files...just loose data
  953. return retval;
  954. }
  955. /**
  956. * creates the HideObj record with hide object set to 0. (don't hide)
  957. * @see loci.poi.hssf.record.HideObjRecord
  958. * @see loci.poi.hssf.record.Record
  959. * @return record containing a HideObjRecord
  960. */
  961. protected Record createHideObj() {
  962. HideObjRecord retval = new HideObjRecord();
  963. retval.setHideObj(( short ) 0); // by default set hide object off
  964. return retval;
  965. }
  966. /**
  967. * creates the DateWindow1904 record with windowing set to 0. (don't window)
  968. * @see loci.poi.hssf.record.DateWindow1904Record
  969. * @see loci.poi.hssf.record.Record
  970. * @return record containing a DateWindow1904Record
  971. */
  972. protected Record createDateWindow1904() {
  973. DateWindow1904Record retval = new DateWindow1904Record();
  974. retval.setWindowing(
  975. ( short ) 0); // don't EVER use 1904 date windowing...tick tock..
  976. return retval;
  977. }
  978. /**
  979. * creates the Precision record with precision set to true. (full precision)
  980. * @see loci.poi.hssf.record.PrecisionRecord
  981. * @see loci.poi.hssf.record.Record
  982. * @return record containing a PrecisionRecord
  983. */
  984. protected Record createPrecision() {
  985. PrecisionRecord retval = new PrecisionRecord();
  986. retval.setFullPrecision(
  987. true); // always use real numbers in calculations!
  988. return retval;
  989. }
  990. /**
  991. * creates the RefreshAll record with refreshAll set to true. (refresh all calcs)
  992. * @see loci.poi.hssf.record.RefreshAllRecord
  993. * @see loci.poi.hssf.record.Record
  994. * @return record containing a RefreshAllRecord
  995. */
  996. protected Record createRefreshAll() {
  997. RefreshAllRecord retval = new RefreshAllRecord();
  998. retval.setRefreshAll(false);
  999. return retval;
  1000. }
  1001. /**
  1002. * creates the BookBool record with saveLinkValues set to 0. (don't save link values)
  1003. * @see loci.poi.hssf.record.BookBoolRecord
  1004. * @see loci.poi.hssf.record.Record
  1005. * @return record containing a BookBoolRecord
  1006. */
  1007. protected Record createBookBool() {
  1008. BookBoolRecord retval = new BookBoolRecord();
  1009. retval.setSaveLinkValues(( short ) 0);
  1010. return retval;
  1011. }
  1012. /**
  1013. * creates a Font record with the following magic values: <P>
  1014. * fontheight = 0xc8<P>
  1015. * attributes = 0x0<P>
  1016. * color palette index = 0x7fff<P>
  1017. * bold weight = 0x190<P>
  1018. * Font Name Length = 5 <P>
  1019. * Font Name = Arial <P>
  1020. *
  1021. * @see loci.poi.hssf.record.FontRecord
  1022. * @see loci.poi.hssf.record.Record
  1023. * @return record containing a FontRecord
  1024. */
  1025. protected Record createFont() {
  1026. FontRecord retval = new FontRecord();
  1027. retval.setFontHeight(( short ) 0xc8);
  1028. retval.setAttributes(( short ) 0x0);
  1029. retval.setColorPaletteIndex(( short ) 0x7fff);
  1030. retval.setBoldWeight(( short ) 0x190);
  1031. retval.setFontNameLength(( byte ) 5);
  1032. retval.setFontName("Arial");
  1033. return retval;
  1034. }
  1035. /**
  1036. * Creates a FormatRecord object
  1037. * @param id the number of the format record to create (meaning its position in
  1038. * a file as M$ Excel would create it.)
  1039. * @return record containing a FormatRecord
  1040. * @see loci.poi.hssf.record.FormatRecord
  1041. * @see loci.poi.hssf.record.Record
  1042. */
  1043. protected Record createFormat(int id) { // we'll need multiple editions for
  1044. FormatRecord retval = new FormatRecord(); // the differnt formats
  1045. switch (id) {
  1046. case 0 :
  1047. retval.setIndexCode(( short ) 5);
  1048. retval.setFormatStringLength(( byte ) 0x17);
  1049. retval.setFormatString("\"$\"#,##0_);\\(\"$\"#,##0\\)");
  1050. break;
  1051. case 1 :
  1052. retval.setIndexCode(( short ) 6);
  1053. retval.setFormatStringLength(( byte ) 0x1c);
  1054. retval.setFormatString("\"$\"#,##0_);[Red]\\(\"$\"#,##0\\)");
  1055. break;
  1056. case 2 :
  1057. retval.setIndexCode(( short ) 7);
  1058. retval.setFormatStringLength(( byte ) 0x1d);
  1059. retval.setFormatString("\"$\"#,##0.00_);\\(\"$\"#,##0.00\\)");
  1060. break;
  1061. case 3 :
  1062. retval.setIndexCode(( short ) 8);
  1063. retval.setFormatStringLength(( byte ) 0x22);
  1064. retval.setFormatString(
  1065. "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)");
  1066. break;
  1067. case 4 :
  1068. retval.setIndexCode(( short ) 0x2a);
  1069. retval.setFormatStringLength(( byte ) 0x32);
  1070. retval.setFormatString(
  1071. "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)");
  1072. break;
  1073. case 5 :
  1074. retval.setIndexCode(( short ) 0x29);
  1075. retval.setFormatStringLength(( byte ) 0x29);
  1076. retval.setFormatString(
  1077. "_(* #,##0_);_(* \\(#,##0\\);_(* \"-\"_);_(@_)");
  1078. break;
  1079. case 6 :
  1080. retval.setIndexCode(( short ) 0x2c);
  1081. retval.setFormatStringLength(( byte ) 0x3a);
  1082. retval.setFormatString(
  1083. "_(\"$\"* #,##0.00_);_(\"$\"* \\(#,##0.00\\);_(\"$\"* \"-\"??_);_(@_)");
  1084. break;
  1085. case 7 :
  1086. retval.setIndexCode(( short ) 0x2b);
  1087. retval.setFormatStringLength(( byte ) 0x31);
  1088. retval.setFormatString(
  1089. "_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)");
  1090. break;
  1091. }
  1092. return retval;
  1093. }
  1094. /**
  1095. * Creates an ExtendedFormatRecord object
  1096. * @param id the number of the extended format record to create (meaning its position in
  1097. * a file as MS Excel would create it.)
  1098. *
  1099. * @return record containing an ExtendedFormatRecord
  1100. * @see loci.poi.hssf.record.ExtendedFormatRecord
  1101. * @see loci.poi.hssf.record.Record
  1102. */
  1103. protected Record createExtendedFormat(int id) { // we'll need multiple editions
  1104. ExtendedFormatRecord retval = new ExtendedFormatRecord();
  1105. switch (id) {
  1106. case 0 :
  1107. retval.setFontIndex(( short ) 0);
  1108. retval.setFormatIndex(( short ) 0);
  1109. retval.setCellOptions(( short ) 0xfffffff5);
  1110. retval.setAlignmentOptions(( short ) 0x20);
  1111. retval.setIndentionOptions(( short ) 0);
  1112. retval.setBorderOptions(( short ) 0);
  1113. retval.setPaletteOptions(( short ) 0);
  1114. retval.setAdtlPaletteOptions(( short ) 0);
  1115. retval.setFillPaletteOptions(( short ) 0x20c0);
  1116. break;
  1117. case 1 :
  1118. retval.setFontIndex(( short ) 1);
  1119. retval.setFormatIndex(( short ) 0);
  1120. retval.setCellOptions(( short ) 0xfffffff5);
  1121. retval.setAlignmentOptions(( short ) 0x20);
  1122. retval.setIndentionOptions(( short ) 0xfffff400);
  1123. retval.setBorderOptions(( short ) 0);
  1124. retval.setPaletteOptions(( short ) 0);
  1125. retval.setAdtlPaletteOptions(( short ) 0);
  1126. retval.setFillPaletteOptions(( short ) 0x20c0);
  1127. break;
  1128. case 2 :
  1129. retval.setFontIndex(( short ) 1);
  1130. retval.setFormatIndex(( short ) 0);
  1131. retval.setCellOptions(( short ) 0xfffffff5);
  1132. retval.setAlignmentOptions(( short ) 0x20);
  1133. retval.setIndentionOptions(( short ) 0xfffff400);
  1134. retval.setBorderOptions(( short ) 0);
  1135. retval.setPaletteOptions(( short ) 0);
  1136. retval.setAdtlPaletteOptions(( short ) 0);
  1137. retval.setFillPaletteOptions(( short ) 0x20c0);
  1138. break;
  1139. case 3 :
  1140. retval.setFontIndex(( short ) 2);
  1141. retval.setFormatIndex(( short ) 0);
  1142. retval.setCellOptions(( short ) 0xfffffff5);
  1143. retval.setAlignmentOptions(( short ) 0x20);
  1144. retval.setIndentionOptions(( short ) 0xfffff400);
  1145. retval.setBorderOptions(( short ) 0);
  1146. retval.setPaletteOptions(( short ) 0);
  1147. retval.setAdtlPaletteOptions(( short ) 0);
  1148. retval.setFillPaletteOptions(( short ) 0x20c0);
  1149. break;
  1150. case 4 :
  1151. retval.setFontIndex(( short ) 2);
  1152. retval.setFormatIndex(( short ) 0);
  1153. retval.setCellOptions(( short ) 0xfffffff5);
  1154. retval.setAlignmentOptions(( short ) 0x20);
  1155. retval.setIndentionOptions(( short ) 0xfffff400);
  1156. retval.setBorderOptions(( short ) 0);
  1157. retval.setPaletteOptions(( short ) 0);
  1158. retval.setAdtlPaletteOptions(( short ) 0);
  1159. retval.setFillPaletteOptions(( short ) 0x20c0);
  1160. break;
  1161. case 5 :
  1162. retval.setFontIndex(( short ) 0);
  1163. retval.setFormatIndex(( short ) 0);
  1164. retval.setCellOptions(( short ) 0xfffffff5);
  1165. retval.setAlignmentOptions(( short ) 0x20);
  1166. retval.setIndentionOptions(( short ) 0xfffff400);
  1167. retval.setBorderOptions(( short ) 0);
  1168. retval.setPaletteOptions(( short ) 0);
  1169. retval.setAdtlPaletteOptions(( short ) 0);
  1170. retval.setFillPaletteOptions(( short ) 0x20c0);
  1171. break;
  1172. case 6 :
  1173. retval.setFontIndex(( short ) 0);
  1174. retval.setFormatIndex(( short ) 0);
  1175. retval.setCellOptions(( short ) 0xfffffff5);
  1176. retval.setAlignmentOptions(( short ) 0x20);
  1177. retval.setIndentionOptions(( short ) 0xfffff400);
  1178. retval.setBorderOptions(( short ) 0);
  1179. retval.setPaletteOptions(( short ) 0);
  1180. retval.setAdtlPaletteOptions(( short ) 0);
  1181. retval.setFillPaletteOptions(( short ) 0x20c0);
  1182. break;
  1183. case 7 :
  1184. retval.setFontIndex(( short ) 0);
  1185. retval.setFormatIndex(( short ) 0);
  1186. retval.setCellOptions(( short ) 0xfffffff5);
  1187. retval.setAlignmentOptions(( short ) 0x20);
  1188. retval.setIndentionOptions(( short ) 0xfffff400);
  1189. retval.setBorderOptions(( short ) 0);
  1190. retval.setPaletteOptions(( short ) 0);
  1191. retval.setAdtlPaletteOptions(( short ) 0);
  1192. retval.setFillPaletteOptions(( short ) 0x20c0);
  1193. break;
  1194. case 8 :
  1195. retval.setFontIndex(( short ) 0);
  1196. retval.setFormatIndex(( short ) 0);
  1197. retval.setCellOptions(( short ) 0xfffffff5);
  1198. retval.setAlignmentOptions(( short ) 0x20);
  1199. retval.setIndentionOptions(( short ) 0xfffff400);
  1200. retval.setBorderOptions(( short ) 0);
  1201. retval.setPaletteOptions(( short ) 0);

Large files files are truncated, but you can click here to view the full file