Source Code Cross Referenced for WindowOneRecord.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hssf » record » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » poi 3.0.2 beta2 » org.apache.poi.hssf.record 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:         Licensed to the Apache Software Foundation (ASF) under one or more
003:         contributor license agreements.  See the NOTICE file distributed with
004:         this work for additional information regarding copyright ownership.
005:         The ASF licenses this file to You under the Apache License, Version 2.0
006:         (the "License"); you may not use this file except in compliance with
007:         the License.  You may obtain a copy of the License at
008:
009:         http://www.apache.org/licenses/LICENSE-2.0
010:
011:         Unless required by applicable law or agreed to in writing, software
012:         distributed under the License is distributed on an "AS IS" BASIS,
013:         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         See the License for the specific language governing permissions and
015:         limitations under the License.
016:         ==================================================================== */
017:
018:        package org.apache.poi.hssf.record;
019:
020:        import org.apache.poi.util.BitField;
021:        import org.apache.poi.util.BitFieldFactory;
022:        import org.apache.poi.util.LittleEndian;
023:
024:        /**
025:         * Title:        Window1 Record<P>
026:         * Description:  Stores the attributes of the workbook window.  This is basically
027:         *               so the gui knows how big to make the window holding the spreadsheet
028:         *               document.<P>
029:         * REFERENCE:  PG 421 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
030:         * @author Andrew C. Oliver (acoliver at apache dot org)
031:         * @version 2.0-pre
032:         */
033:
034:        public class WindowOneRecord extends Record {
035:            public final static short sid = 0x3d;
036:
037:            // our variable names stolen from old TV sets.
038:            private short field_1_h_hold; // horizontal position
039:            private short field_2_v_hold; // vertical position
040:            private short field_3_width;
041:            private short field_4_height;
042:            private short field_5_options;
043:            static final private BitField hidden = BitFieldFactory
044:                    .getInstance(0x01); // is this window is hidden
045:            static final private BitField iconic = BitFieldFactory
046:                    .getInstance(0x02); // is this window is an icon
047:            static final private BitField reserved = BitFieldFactory
048:                    .getInstance(0x04); // reserved
049:            static final private BitField hscroll = BitFieldFactory
050:                    .getInstance(0x08); // display horizontal scrollbar
051:            static final private BitField vscroll = BitFieldFactory
052:                    .getInstance(0x10); // display vertical scrollbar
053:            static final private BitField tabs = BitFieldFactory
054:                    .getInstance(0x20); // display tabs at the bottom
055:
056:            // all the rest are "reserved"
057:            private short field_6_selected_tab;
058:            private short field_7_displayed_tab;
059:            private short field_8_num_selected_tabs;
060:            private short field_9_tab_width_ratio;
061:
062:            public WindowOneRecord() {
063:            }
064:
065:            /**
066:             * Constructs a WindowOne record and sets its fields appropriately.
067:             * @param in the RecordInputstream to read the record from
068:             */
069:
070:            public WindowOneRecord(RecordInputStream in) {
071:                super (in);
072:            }
073:
074:            protected void validateSid(short id) {
075:                if (id != sid) {
076:                    throw new RecordFormatException("NOT A WINDOW1 RECORD");
077:                }
078:            }
079:
080:            protected void fillFields(RecordInputStream in) {
081:                field_1_h_hold = in.readShort();
082:                field_2_v_hold = in.readShort();
083:                field_3_width = in.readShort();
084:                field_4_height = in.readShort();
085:                field_5_options = in.readShort();
086:                field_6_selected_tab = in.readShort();
087:                field_7_displayed_tab = in.readShort();
088:                field_8_num_selected_tabs = in.readShort();
089:                field_9_tab_width_ratio = in.readShort();
090:            }
091:
092:            /**
093:             * set the horizontal position of the window (in 1/20ths of a point)
094:             * @param h - horizontal location
095:             */
096:
097:            public void setHorizontalHold(short h) {
098:                field_1_h_hold = h;
099:            }
100:
101:            /**
102:             * set the vertical position of the window (in 1/20ths of a point)
103:             * @param v - vertical location
104:             */
105:
106:            public void setVerticalHold(short v) {
107:                field_2_v_hold = v;
108:            }
109:
110:            /**
111:             * set the width of the window
112:             * @param w  width
113:             */
114:
115:            public void setWidth(short w) {
116:                field_3_width = w;
117:            }
118:
119:            /**
120:             * set teh height of the window
121:             * @param h  height
122:             */
123:
124:            public void setHeight(short h) {
125:                field_4_height = h;
126:            }
127:
128:            /**
129:             * set the options bitmask (see bit setters)
130:             *
131:             * @param o - the bitmask
132:             */
133:
134:            public void setOptions(short o) {
135:                field_5_options = o;
136:            }
137:
138:            // bitfields for options
139:
140:            /**
141:             * set whether the window is hidden or not
142:             * @param ishidden or not
143:             */
144:
145:            public void setHidden(boolean ishidden) {
146:                field_5_options = hidden.setShortBoolean(field_5_options,
147:                        ishidden);
148:            }
149:
150:            /**
151:             * set whether the window has been iconized or not
152:             * @param isiconic  iconize  or not
153:             */
154:
155:            public void setIconic(boolean isiconic) {
156:                field_5_options = iconic.setShortBoolean(field_5_options,
157:                        isiconic);
158:            }
159:
160:            /**
161:             * set whether to display the horizontal scrollbar or not
162:             * @param scroll display or not
163:             */
164:
165:            public void setDisplayHorizonalScrollbar(boolean scroll) {
166:                field_5_options = hscroll.setShortBoolean(field_5_options,
167:                        scroll);
168:            }
169:
170:            /**
171:             * set whether to display the vertical scrollbar or not
172:             * @param scroll  display or not
173:             */
174:
175:            public void setDisplayVerticalScrollbar(boolean scroll) {
176:                field_5_options = vscroll.setShortBoolean(field_5_options,
177:                        scroll);
178:            }
179:
180:            /**
181:             * set whether to display the tabs or not
182:             * @param disptabs  display or not
183:             */
184:
185:            public void setDisplayTabs(boolean disptabs) {
186:                field_5_options = tabs.setShortBoolean(field_5_options,
187:                        disptabs);
188:            }
189:
190:            // end bitfields
191:
192:            /**
193:             * set the selected tab number
194:             * @param s  tab number
195:             */
196:
197:            public void setSelectedTab(short s) {
198:                field_6_selected_tab = s;
199:            }
200:
201:            /**
202:             * set the displayed tab number
203:             * @param t  tab number
204:             */
205:
206:            public void setDisplayedTab(short t) {
207:                field_7_displayed_tab = t;
208:            }
209:
210:            /**
211:             * set the number of selected tabs
212:             * @param n  number of tabs
213:             */
214:
215:            public void setNumSelectedTabs(short n) {
216:                field_8_num_selected_tabs = n;
217:            }
218:
219:            /**
220:             * ratio of the width of the tabs to the horizontal scrollbar
221:             * @param r  ratio
222:             */
223:
224:            public void setTabWidthRatio(short r) {
225:                field_9_tab_width_ratio = r;
226:            }
227:
228:            /**
229:             * get the horizontal position of the window (in 1/20ths of a point)
230:             * @return h - horizontal location
231:             */
232:
233:            public short getHorizontalHold() {
234:                return field_1_h_hold;
235:            }
236:
237:            /**
238:             * get the vertical position of the window (in 1/20ths of a point)
239:             * @return v - vertical location
240:             */
241:
242:            public short getVerticalHold() {
243:                return field_2_v_hold;
244:            }
245:
246:            /**
247:             * get the width of the window
248:             * @return width
249:             */
250:
251:            public short getWidth() {
252:                return field_3_width;
253:            }
254:
255:            /**
256:             * get the height of the window
257:             * @return height
258:             */
259:
260:            public short getHeight() {
261:                return field_4_height;
262:            }
263:
264:            /**
265:             * get the options bitmask (see bit setters)
266:             *
267:             * @return o - the bitmask
268:             */
269:
270:            public short getOptions() {
271:                return field_5_options;
272:            }
273:
274:            // bitfields for options
275:
276:            /**
277:             * get whether the window is hidden or not
278:             * @return ishidden or not
279:             */
280:
281:            public boolean getHidden() {
282:                return hidden.isSet(field_5_options);
283:            }
284:
285:            /**
286:             * get whether the window has been iconized or not
287:             * @return iconize  or not
288:             */
289:
290:            public boolean getIconic() {
291:                return iconic.isSet(field_5_options);
292:            }
293:
294:            /**
295:             * get whether to display the horizontal scrollbar or not
296:             * @return display or not
297:             */
298:
299:            public boolean getDisplayHorizontalScrollbar() {
300:                return hscroll.isSet(field_5_options);
301:            }
302:
303:            /**
304:             * get whether to display the vertical scrollbar or not
305:             * @return display or not
306:             */
307:
308:            public boolean getDisplayVerticalScrollbar() {
309:                return vscroll.isSet(field_5_options);
310:            }
311:
312:            /**
313:             * get whether to display the tabs or not
314:             * @return display or not
315:             */
316:
317:            public boolean getDisplayTabs() {
318:                return tabs.isSet(field_5_options);
319:            }
320:
321:            // end options bitfields
322:
323:            /**
324:             * get the selected tab number
325:             * @return Tab number
326:             */
327:
328:            public short getSelectedTab() {
329:                return field_6_selected_tab;
330:            }
331:
332:            /**
333:             * get the displayed tab number
334:             * @return Tab number
335:             */
336:
337:            public short getDisplayedTab() {
338:                return field_7_displayed_tab;
339:            }
340:
341:            /**
342:             * get the number of selected tabs
343:             * @return number of tabs
344:             */
345:
346:            public short getNumSelectedTabs() {
347:                return field_8_num_selected_tabs;
348:            }
349:
350:            /**
351:             * ratio of the width of the tabs to the horizontal scrollbar
352:             * @return ratio
353:             */
354:
355:            public short getTabWidthRatio() {
356:                return field_9_tab_width_ratio;
357:            }
358:
359:            public String toString() {
360:                StringBuffer buffer = new StringBuffer();
361:
362:                buffer.append("[WINDOW1]\n");
363:                buffer.append("    .h_hold          = ").append(
364:                        Integer.toHexString(getHorizontalHold())).append("\n");
365:                buffer.append("    .v_hold          = ").append(
366:                        Integer.toHexString(getVerticalHold())).append("\n");
367:                buffer.append("    .width           = ").append(
368:                        Integer.toHexString(getWidth())).append("\n");
369:                buffer.append("    .height          = ").append(
370:                        Integer.toHexString(getHeight())).append("\n");
371:                buffer.append("    .options         = ").append(
372:                        Integer.toHexString(getOptions())).append("\n");
373:                buffer.append("        .hidden      = ").append(getHidden())
374:                        .append("\n");
375:                buffer.append("        .iconic      = ").append(getIconic())
376:                        .append("\n");
377:                buffer.append("        .hscroll     = ").append(
378:                        getDisplayHorizontalScrollbar()).append("\n");
379:                buffer.append("        .vscroll     = ").append(
380:                        getDisplayVerticalScrollbar()).append("\n");
381:                buffer.append("        .tabs        = ").append(
382:                        getDisplayTabs()).append("\n");
383:                buffer.append("    .selectedtab     = ").append(
384:                        Integer.toHexString(getSelectedTab())).append("\n");
385:                buffer.append("    .displayedtab    = ").append(
386:                        Integer.toHexString(getDisplayedTab())).append("\n");
387:                buffer.append("    .numselectedtabs = ").append(
388:                        Integer.toHexString(getNumSelectedTabs())).append("\n");
389:                buffer.append("    .tabwidthratio   = ").append(
390:                        Integer.toHexString(getTabWidthRatio())).append("\n");
391:                buffer.append("[/WINDOW1]\n");
392:                return buffer.toString();
393:            }
394:
395:            public int serialize(int offset, byte[] data) {
396:                LittleEndian.putShort(data, 0 + offset, sid);
397:                LittleEndian.putShort(data, 2 + offset, ((short) 0x12)); // 18 bytes (22 total)
398:                LittleEndian.putShort(data, 4 + offset, getHorizontalHold());
399:                LittleEndian.putShort(data, 6 + offset, getVerticalHold());
400:                LittleEndian.putShort(data, 8 + offset, getWidth());
401:                LittleEndian.putShort(data, 10 + offset, getHeight());
402:                LittleEndian.putShort(data, 12 + offset, getOptions());
403:                LittleEndian.putShort(data, 14 + offset, getSelectedTab());
404:                LittleEndian.putShort(data, 16 + offset, getDisplayedTab());
405:                LittleEndian.putShort(data, 18 + offset, getNumSelectedTabs());
406:                LittleEndian.putShort(data, 20 + offset, getTabWidthRatio());
407:                return getRecordSize();
408:            }
409:
410:            public int getRecordSize() {
411:                return 22;
412:            }
413:
414:            public short getSid() {
415:                return sid;
416:            }
417:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.