View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript-Excel: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2005 Open World Ltd, Kevin Rogers
4   //
5   // This file is part of MillScript-Excel.
6   //
7   // MillScript-Excel is free software; you can redistribute it and/or modify it under
8   // the terms of the GNU General Public License as published by the Free
9   // Software Foundation; either version 2 of the License, or (at your option)
10  // any later version.
11  //
12  // MillScript-Excel is distributed in the hope that it will be useful, but WITHOUT
13  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  // more details.
16  //
17  // You should have received a copy of the GNU General Public License along with
18  // MillScript-Excel; if not, write to the Free Software Foundation, Inc., 59 Temple
19  // Place, Suite 330, Boston, MA  02111-1307  USA
20  ////////////////////////////////////////////////////////////////////////////////
21  package org.millscript.office.excel.records;
22  
23  import org.millscript.office.excel.Record;
24  import org.millscript.office.excel.alerts.BIFFAlert;
25  import org.millscript.office.excel.versions.BIFFVersion;
26  
27  /**
28   * 
29   */
30  public class BOF extends Record {
31  
32      /**
33       * 
34       */
35      public enum Type {
36  
37          WorkbookGlobals, VisualBasicModule, Worksheet, Chart, MacroSheet, WorkspaceFile;
38  
39          public static Type getType( final BIFFVersion version, final int type ) {
40              switch ( type ) {
41                  case 0x0010:
42                      return Worksheet;
43                  case 0x0020:
44                      return Chart;
45                  case 0x0040:
46                      return MacroSheet;
47                  case 0x0005:
48                      return WorkbookGlobals; // BIFF5+
49                  case 0x0006:
50                      return VisualBasicModule;
51                  case 0x0100:
52                      switch ( version ) {
53                          case BIFF4S:
54                          case BIFF4W:
55                              return WorkbookGlobals; // BIFF4 only
56                          default:
57                              return WorkspaceFile;   // BIFF5+
58                      }
59                  default:
60                      throw new BIFFAlert(
61                          "Unknown type for BOF record"
62                      ).culprit( "type", type ).mishap();
63              }
64          }
65  
66      }
67  
68      private short buildIdentifier;
69  
70      private short buildYear;
71  
72      private int fileHistoryFlags;
73  
74      private int lowestExcelVersion;
75  
76      private Type type;
77  
78      /**
79       * @param version
80       * @param recordData
81       */
82      public BOF( final Type t ) {
83          this.type = t;
84      }
85  
86      /**
87       * @return Returns the type.
88       */
89      public Type getType() {
90          return type;
91      }
92  
93      /**
94       * @param id The buildIdentifier to set.
95       */
96      public void setBuildIdentifier( final short id ) {
97          this.buildIdentifier = id;
98      }
99  
100     /**
101      * @param year The buildYear to set.
102      */
103     public void setBuildYear( final short year ) {
104         this.buildYear = year;
105     }
106 
107     
108     /**
109      * @param flags The fileHistoryFlags to set.
110      */
111     public void setFileHistoryFlags( final int flags ) {
112         this.fileHistoryFlags = flags;
113     }
114 
115     
116     /**
117      * @param version The lowestExcelVersion to set.
118      */
119     public void setLowestExcelVersion( final int version ) {
120         this.lowestExcelVersion = version;
121     }
122 
123 }