source: osm/applications/editors/josm/plugins/opendata/includes/org/apache/poi/hssf/record/WindowOneRecord.java@ 28000

Last change on this file since 28000 was 28000, checked in by donvip, 12 years ago

Import new "opendata" JOSM plugin

File size: 10.6 KB
Line 
1/* ====================================================================
2 Licensed to the Apache Software Foundation (ASF) under one or more
3 contributor license agreements. See the NOTICE file distributed with
4 this work for additional information regarding copyright ownership.
5 The ASF licenses this file to You under the Apache License, Version 2.0
6 (the "License"); you may not use this file except in compliance with
7 the License. You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16==================================================================== */
17
18package org.apache.poi.hssf.record;
19
20import org.apache.poi.util.BitField;
21import org.apache.poi.util.BitFieldFactory;
22import org.apache.poi.util.LittleEndianOutput;
23
24/**
25 * Title: Window1 Record<P>
26 * Description: Stores the attributes of the workbook window. This is basically
27 * so the gui knows how big to make the window holding the spreadsheet
28 * document.<P>
29 * REFERENCE: PG 421 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
30 * @author Andrew C. Oliver (acoliver at apache dot org)
31 * @version 2.0-pre
32 */
33public final class WindowOneRecord extends StandardRecord {
34 public final static short sid = 0x3d;
35
36 // our variable names stolen from old TV sets.
37 private short field_1_h_hold; // horizontal position
38 private short field_2_v_hold; // vertical position
39 private short field_3_width;
40 private short field_4_height;
41 private short field_5_options;
42 static final private BitField hidden =
43 BitFieldFactory.getInstance(0x01); // is this window is hidden
44 static final private BitField iconic =
45 BitFieldFactory.getInstance(0x02); // is this window is an icon
46 static final private BitField hscroll =
47 BitFieldFactory.getInstance(0x08); // display horizontal scrollbar
48 static final private BitField vscroll =
49 BitFieldFactory.getInstance(0x10); // display vertical scrollbar
50 static final private BitField tabs =
51 BitFieldFactory.getInstance(0x20); // display tabs at the bottom
52
53 // all the rest are "reserved"
54 private int field_6_active_sheet;
55 private int field_7_first_visible_tab;
56 private short field_8_num_selected_tabs;
57 private short field_9_tab_width_ratio;
58
59 public WindowOneRecord()
60 {
61 }
62
63 public WindowOneRecord(RecordInputStream in) // NO_UCD
64 {
65 field_1_h_hold = in.readShort();
66 field_2_v_hold = in.readShort();
67 field_3_width = in.readShort();
68 field_4_height = in.readShort();
69 field_5_options = in.readShort();
70 field_6_active_sheet = in.readShort();
71 field_7_first_visible_tab = in.readShort();
72 field_8_num_selected_tabs = in.readShort();
73 field_9_tab_width_ratio = in.readShort();
74 }
75
76 /**
77 * set the horizontal position of the window (in 1/20ths of a point)
78 * @param h - horizontal location
79 */
80
81 public void setHorizontalHold(short h)
82 {
83 field_1_h_hold = h;
84 }
85
86 /**
87 * set the vertical position of the window (in 1/20ths of a point)
88 * @param v - vertical location
89 */
90
91 public void setVerticalHold(short v)
92 {
93 field_2_v_hold = v;
94 }
95
96 /**
97 * set the width of the window
98 * @param w width
99 */
100
101 public void setWidth(short w)
102 {
103 field_3_width = w;
104 }
105
106 /**
107 * set teh height of the window
108 * @param h height
109 */
110
111 public void setHeight(short h)
112 {
113 field_4_height = h;
114 }
115
116 /**
117 * set the options bitmask (see bit setters)
118 *
119 * @param o - the bitmask
120 */
121
122 public void setOptions(short o)
123 {
124 field_5_options = o;
125 }
126
127 // bitfields for options
128
129
130
131 // end bitfields
132
133 public void setActiveSheetIndex(int index) {
134 field_6_active_sheet = index;
135 }
136
137
138 /**
139 * Sets the first visible sheet in the worksheet tab-bar. This method does <b>not</b>
140 * hide, select or focus sheets. It just sets the scroll position in the tab-bar.
141 * @param t the sheet index of the tab that will become the first in the tab-bar
142 */
143 public void setFirstVisibleTab(int t) {
144 field_7_first_visible_tab = t;
145 }
146
147
148 /**
149 * set the number of selected tabs
150 * @param n number of tabs
151 */
152
153 public void setNumSelectedTabs(short n)
154 {
155 field_8_num_selected_tabs = n;
156 }
157
158 /**
159 * ratio of the width of the tabs to the horizontal scrollbar
160 * @param r ratio
161 */
162
163 public void setTabWidthRatio(short r)
164 {
165 field_9_tab_width_ratio = r;
166 }
167
168 /**
169 * get the horizontal position of the window (in 1/20ths of a point)
170 * @return h - horizontal location
171 */
172
173 public short getHorizontalHold()
174 {
175 return field_1_h_hold;
176 }
177
178 /**
179 * get the vertical position of the window (in 1/20ths of a point)
180 * @return v - vertical location
181 */
182
183 public short getVerticalHold()
184 {
185 return field_2_v_hold;
186 }
187
188 /**
189 * get the width of the window
190 * @return width
191 */
192
193 public short getWidth()
194 {
195 return field_3_width;
196 }
197
198 /**
199 * get the height of the window
200 * @return height
201 */
202
203 public short getHeight()
204 {
205 return field_4_height;
206 }
207
208 /**
209 * get the options bitmask (see bit setters)
210 *
211 * @return o - the bitmask
212 */
213
214 public short getOptions()
215 {
216 return field_5_options;
217 }
218
219 // bitfields for options
220
221 /**
222 * get whether the window is hidden or not
223 * @return ishidden or not
224 */
225
226 public boolean getHidden()
227 {
228 return hidden.isSet(field_5_options);
229 }
230
231 /**
232 * get whether the window has been iconized or not
233 * @return iconize or not
234 */
235
236 public boolean getIconic()
237 {
238 return iconic.isSet(field_5_options);
239 }
240
241 /**
242 * get whether to display the horizontal scrollbar or not
243 * @return display or not
244 */
245
246 public boolean getDisplayHorizontalScrollbar()
247 {
248 return hscroll.isSet(field_5_options);
249 }
250
251 /**
252 * get whether to display the vertical scrollbar or not
253 * @return display or not
254 */
255
256 public boolean getDisplayVerticalScrollbar()
257 {
258 return vscroll.isSet(field_5_options);
259 }
260
261 /**
262 * get whether to display the tabs or not
263 * @return display or not
264 */
265
266 public boolean getDisplayTabs()
267 {
268 return tabs.isSet(field_5_options);
269 }
270
271 // end options bitfields
272
273
274 /**
275 * @return the index of the currently displayed sheet
276 */
277 public int getActiveSheetIndex() {
278 return field_6_active_sheet;
279 }
280
281
282 /**
283 * @return the first visible sheet in the worksheet tab-bar.
284 * I.E. the scroll position of the tab-bar.
285 */
286 public int getFirstVisibleTab() {
287 return field_7_first_visible_tab;
288 }
289
290 /**
291 * get the number of selected tabs
292 * @return number of tabs
293 */
294
295 public short getNumSelectedTabs()
296 {
297 return field_8_num_selected_tabs;
298 }
299
300 /**
301 * ratio of the width of the tabs to the horizontal scrollbar
302 * @return ratio
303 */
304
305 public short getTabWidthRatio()
306 {
307 return field_9_tab_width_ratio;
308 }
309
310 public String toString()
311 {
312 StringBuffer buffer = new StringBuffer();
313
314 buffer.append("[WINDOW1]\n");
315 buffer.append(" .h_hold = ")
316 .append(Integer.toHexString(getHorizontalHold())).append("\n");
317 buffer.append(" .v_hold = ")
318 .append(Integer.toHexString(getVerticalHold())).append("\n");
319 buffer.append(" .width = ")
320 .append(Integer.toHexString(getWidth())).append("\n");
321 buffer.append(" .height = ")
322 .append(Integer.toHexString(getHeight())).append("\n");
323 buffer.append(" .options = ")
324 .append(Integer.toHexString(getOptions())).append("\n");
325 buffer.append(" .hidden = ").append(getHidden())
326 .append("\n");
327 buffer.append(" .iconic = ").append(getIconic())
328 .append("\n");
329 buffer.append(" .hscroll = ")
330 .append(getDisplayHorizontalScrollbar()).append("\n");
331 buffer.append(" .vscroll = ")
332 .append(getDisplayVerticalScrollbar()).append("\n");
333 buffer.append(" .tabs = ").append(getDisplayTabs())
334 .append("\n");
335 buffer.append(" .activeSheet = ")
336 .append(Integer.toHexString(getActiveSheetIndex())).append("\n");
337 buffer.append(" .firstVisibleTab = ")
338 .append(Integer.toHexString(getFirstVisibleTab())).append("\n");
339 buffer.append(" .numselectedtabs = ")
340 .append(Integer.toHexString(getNumSelectedTabs())).append("\n");
341 buffer.append(" .tabwidthratio = ")
342 .append(Integer.toHexString(getTabWidthRatio())).append("\n");
343 buffer.append("[/WINDOW1]\n");
344 return buffer.toString();
345 }
346
347 public void serialize(LittleEndianOutput out) {
348 out.writeShort(getHorizontalHold());
349 out.writeShort(getVerticalHold());
350 out.writeShort(getWidth());
351 out.writeShort(getHeight());
352 out.writeShort(getOptions());
353 out.writeShort(getActiveSheetIndex());
354 out.writeShort(getFirstVisibleTab());
355 out.writeShort(getNumSelectedTabs());
356 out.writeShort(getTabWidthRatio());
357 }
358
359 protected int getDataSize() {
360 return 18;
361 }
362
363 public short getSid()
364 {
365 return sid;
366 }
367}
Note: See TracBrowser for help on using the repository browser.