KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > biff > WorkspaceInformationRecord


1 /*********************************************************************
2 *
3 * Copyright (C) 2002 Andrew Khan
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ***************************************************************************/

19
20 package jxl.biff;
21
22 import jxl.read.biff.Record;
23
24 /**
25  * A record detailing whether the sheet is protected
26  */

27 public class WorkspaceInformationRecord extends WritableRecordData
28 {
29   /**
30    * The options byte
31    */

32   private int wsoptions;
33
34   // the masks
35
private static final int fitToPages = 0x100;
36   private static final int defaultOptions = 0x4c1;
37
38   /**
39    * Constructs this object from the raw data
40    *
41    * @param t the raw data
42    */

43   public WorkspaceInformationRecord(Record t)
44   {
45     super(t);
46     byte[] data = getRecord().getData();
47
48     wsoptions = IntegerHelper.getInt(data[0], data[1]);
49   }
50
51   /**
52    * Constructs this object from the raw data
53    */

54   public WorkspaceInformationRecord()
55   {
56     super(Type.WSBOOL);
57     wsoptions = defaultOptions;
58   }
59
60   /**
61    * Gets the fit to pages flag
62    *
63    * @return TRUE if fit to pages is set
64    */

65   public boolean getFitToPages()
66   {
67     return ((wsoptions & fitToPages) != 0);
68   }
69
70   /**
71    * Sets the fit to page flag
72    *
73    * @param b fit to page indicator
74    */

75   public void setFitToPages(boolean b)
76   {
77     wsoptions = b ? wsoptions | fitToPages :
78                     wsoptions & ~fitToPages;
79   }
80
81   /**
82    * Gets the binary data for output to file
83    *
84    * @return the binary data
85    */

86   public byte[] getData()
87   {
88     byte[] data = new byte[2];
89
90     // Hard code in the information for now
91
IntegerHelper.getTwoBytes(wsoptions, data, 0);
92
93     return data;
94   }
95 }
96
97
98
99
100
101
102
103
104
105
Popular Tags