1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.millscript.office.excel.records.syntax;
22
23 import org.millscript.commons.alert.reporters.StandardWarningAlertReporter;
24 import org.millscript.office.excel.RecordSyntax;
25 import org.millscript.office.excel.RecordTokenizer;
26 import org.millscript.office.excel.alerts.BIFFAlert;
27 import org.millscript.office.excel.records.Array;
28 import org.millscript.office.excel.versions.BIFF2;
29 import org.millscript.office.excel.versions.BIFF3;
30 import org.millscript.office.excel.versions.BIFF4S;
31 import org.millscript.office.excel.versions.BIFF4W;
32 import org.millscript.office.excel.versions.BIFF5;
33 import org.millscript.office.excel.versions.BIFF7;
34 import org.millscript.office.excel.versions.BIFF8;
35 import org.millscript.office.excel.versions.BIFF8X;
36 import org.millscript.office.excel.versions.BIFFVersion;
37
38 /**
39 *
40 */
41 public class ArrayRecordSyntax extends RecordSyntax implements BIFF2, BIFF3, BIFF4S, BIFF4W, BIFF5, BIFF7, BIFF8, BIFF8X {
42
43 /**
44 * @see org.millscript.office.excel.RecordSyntax#newRecord(RecordTokenizer)
45 */
46 @Override
47 public Array newRecord( final RecordTokenizer tokenizer ) {
48 final Array array = new Array();
49
50
51 array.setCellRangeAddress(
52 tokenizer.readCellRangeAddressPreBIFF8()
53 );
54
55 if ( tokenizer.getBiffVersion() == BIFFVersion.BIFF2 ) {
56 final byte options = tokenizer.readByte();
57 switch ( options ) {
58 case 0:
59 array.setAlwaysRecalculate( false );
60 case 1:
61 array.setAlwaysRecalculate( true );
62 default:
63
64
65 StandardWarningAlertReporter.WARNING_REPORTER.report(
66 new BIFFAlert(
67 "Unknown option flag for ARRAY record"
68 ).culprit( "option flag", options )
69 );
70 }
71 } else {
72 final int options = tokenizer.readUnsigned2Byte();
73 if ( ( options & 0x0001 ) == 1 ) {
74 array.setAlwaysRecalculate( true );
75 } else if ( ( options & 0x0002 ) == 1 ) {
76 array.setAlwaysRecalculate( false );
77 } else {
78
79
80 StandardWarningAlertReporter.WARNING_REPORTER.report(
81 new BIFFAlert(
82 "Unknown option flag for ARRAY record"
83 ).culprit( "option flag", options )
84 );
85 }
86 }
87
88 array.setFormulaExpr(
89 tokenizer.readFormula(
90 tokenizer.getBytesLeftInCurrentRecordData()
91 )
92 );
93 return array;
94 }
95
96 }