Source Code Cross Referenced for PrintSetupRecord.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.LittleEndian;
021:        import org.apache.poi.util.BitField;
022:        import org.apache.poi.util.BitFieldFactory;
023:
024:        /**
025:         * Title:        Print Setup Record<P>
026:         * Description:  Stores print setup options -- bogus for HSSF (and marked as such)<P>
027:         * REFERENCE:  PG 385 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
028:         * @author Andrew C. Oliver (acoliver at apache dot org)
029:         * @author Jason Height (jheight at chariot dot net dot au)
030:         * @version 2.0-pre
031:         */
032:
033:        public class PrintSetupRecord extends Record {
034:            public final static short sid = 0xa1;
035:            private short field_1_paper_size;
036:            private short field_2_scale;
037:            private short field_3_page_start;
038:            private short field_4_fit_width;
039:            private short field_5_fit_height;
040:            private short field_6_options;
041:            static final private BitField lefttoright = BitFieldFactory
042:                    .getInstance(0x01); // print over then down
043:            static final private BitField landscape = BitFieldFactory
044:                    .getInstance(0x02); // landscape mode
045:            static final private BitField validsettings = BitFieldFactory
046:                    .getInstance(0x04); // if papersize, scale, resolution, copies, landscape
047:
048:            // weren't obtained from the print consider them
049:            // mere bunk
050:            static final private BitField nocolor = BitFieldFactory
051:                    .getInstance(0x08); // print mono/b&w, colorless
052:            static final private BitField draft = BitFieldFactory
053:                    .getInstance(0x10); // print draft quality
054:            static final private BitField notes = BitFieldFactory
055:                    .getInstance(0x20); // print the notes
056:            static final private BitField noOrientation = BitFieldFactory
057:                    .getInstance(0x40); // the orientation is not set
058:            static final private BitField usepage = BitFieldFactory
059:                    .getInstance(0x80); // use a user set page no, instead of auto
060:            private short field_7_hresolution;
061:            private short field_8_vresolution;
062:            private double field_9_headermargin;
063:            private double field_10_footermargin;
064:            private short field_11_copies;
065:
066:            public PrintSetupRecord() {
067:            }
068:
069:            /**
070:             * Constructs a PrintSetup (SETUP) record and sets its fields appropriately.
071:             * @param in the RecordInputstream to read the record from
072:             */
073:
074:            public PrintSetupRecord(RecordInputStream in) {
075:                super (in);
076:            }
077:
078:            protected void validateSid(short id) {
079:                if (id != sid) {
080:                    throw new RecordFormatException(
081:                            "NOT A valid PrintSetup record RECORD");
082:                }
083:            }
084:
085:            protected void fillFields(RecordInputStream in) {
086:                field_1_paper_size = in.readShort();
087:                field_2_scale = in.readShort();
088:                field_3_page_start = in.readShort();
089:                field_4_fit_width = in.readShort();
090:                field_5_fit_height = in.readShort();
091:                field_6_options = in.readShort();
092:                field_7_hresolution = in.readShort();
093:                field_8_vresolution = in.readShort();
094:                field_9_headermargin = in.readDouble();
095:                field_10_footermargin = in.readDouble();
096:                field_11_copies = in.readShort();
097:            }
098:
099:            public void setPaperSize(short size) {
100:                field_1_paper_size = size;
101:            }
102:
103:            public void setScale(short scale) {
104:                field_2_scale = scale;
105:            }
106:
107:            public void setPageStart(short start) {
108:                field_3_page_start = start;
109:            }
110:
111:            public void setFitWidth(short width) {
112:                field_4_fit_width = width;
113:            }
114:
115:            public void setFitHeight(short height) {
116:                field_5_fit_height = height;
117:            }
118:
119:            public void setOptions(short options) {
120:                field_6_options = options;
121:            }
122:
123:            // option bitfields
124:            public void setLeftToRight(boolean ltor) {
125:                field_6_options = lefttoright.setShortBoolean(field_6_options,
126:                        ltor);
127:            }
128:
129:            public void setLandscape(boolean ls) {
130:                field_6_options = landscape
131:                        .setShortBoolean(field_6_options, ls);
132:            }
133:
134:            public void setValidSettings(boolean valid) {
135:                field_6_options = validsettings.setShortBoolean(
136:                        field_6_options, valid);
137:            }
138:
139:            public void setNoColor(boolean mono) {
140:                field_6_options = nocolor
141:                        .setShortBoolean(field_6_options, mono);
142:            }
143:
144:            public void setDraft(boolean d) {
145:                field_6_options = draft.setShortBoolean(field_6_options, d);
146:            }
147:
148:            public void setNotes(boolean printnotes) {
149:                field_6_options = notes.setShortBoolean(field_6_options,
150:                        printnotes);
151:            }
152:
153:            public void setNoOrientation(boolean orientation) {
154:                field_6_options = noOrientation.setShortBoolean(
155:                        field_6_options, orientation);
156:            }
157:
158:            public void setUsePage(boolean page) {
159:                field_6_options = usepage
160:                        .setShortBoolean(field_6_options, page);
161:            }
162:
163:            // end option bitfields
164:            public void setHResolution(short resolution) {
165:                field_7_hresolution = resolution;
166:            }
167:
168:            public void setVResolution(short resolution) {
169:                field_8_vresolution = resolution;
170:            }
171:
172:            public void setHeaderMargin(double headermargin) {
173:                field_9_headermargin = headermargin;
174:            }
175:
176:            public void setFooterMargin(double footermargin) {
177:                field_10_footermargin = footermargin;
178:            }
179:
180:            public void setCopies(short copies) {
181:                field_11_copies = copies;
182:            }
183:
184:            public short getPaperSize() {
185:                return field_1_paper_size;
186:            }
187:
188:            public short getScale() {
189:                return field_2_scale;
190:            }
191:
192:            public short getPageStart() {
193:                return field_3_page_start;
194:            }
195:
196:            public short getFitWidth() {
197:                return field_4_fit_width;
198:            }
199:
200:            public short getFitHeight() {
201:                return field_5_fit_height;
202:            }
203:
204:            public short getOptions() {
205:                return field_6_options;
206:            }
207:
208:            // option bitfields
209:            public boolean getLeftToRight() {
210:                return lefttoright.isSet(field_6_options);
211:            }
212:
213:            public boolean getLandscape() {
214:                return landscape.isSet(field_6_options);
215:            }
216:
217:            public boolean getValidSettings() {
218:                return validsettings.isSet(field_6_options);
219:            }
220:
221:            public boolean getNoColor() {
222:                return nocolor.isSet(field_6_options);
223:            }
224:
225:            public boolean getDraft() {
226:                return draft.isSet(field_6_options);
227:            }
228:
229:            public boolean getNotes() {
230:                return notes.isSet(field_6_options);
231:            }
232:
233:            public boolean getNoOrientation() {
234:                return noOrientation.isSet(field_6_options);
235:            }
236:
237:            public boolean getUsePage() {
238:                return usepage.isSet(field_6_options);
239:            }
240:
241:            // end option bitfields
242:            public short getHResolution() {
243:                return field_7_hresolution;
244:            }
245:
246:            public short getVResolution() {
247:                return field_8_vresolution;
248:            }
249:
250:            public double getHeaderMargin() {
251:                return field_9_headermargin;
252:            }
253:
254:            public double getFooterMargin() {
255:                return field_10_footermargin;
256:            }
257:
258:            public short getCopies() {
259:                return field_11_copies;
260:            }
261:
262:            public String toString() {
263:                StringBuffer buffer = new StringBuffer();
264:
265:                buffer.append("[PRINTSETUP]\n");
266:                buffer.append("    .papersize      = ").append(getPaperSize())
267:                        .append("\n");
268:                buffer.append("    .scale          = ").append(getScale())
269:                        .append("\n");
270:                buffer.append("    .pagestart      = ").append(getPageStart())
271:                        .append("\n");
272:                buffer.append("    .fitwidth       = ").append(getFitWidth())
273:                        .append("\n");
274:                buffer.append("    .fitheight      = ").append(getFitHeight())
275:                        .append("\n");
276:                buffer.append("    .options        = ").append(getOptions())
277:                        .append("\n");
278:                buffer.append("        .ltor       = ")
279:                        .append(getLeftToRight()).append("\n");
280:                buffer.append("        .landscape  = ").append(getLandscape())
281:                        .append("\n");
282:                buffer.append("        .valid      = ").append(
283:                        getValidSettings()).append("\n");
284:                buffer.append("        .mono       = ").append(getNoColor())
285:                        .append("\n");
286:                buffer.append("        .draft      = ").append(getDraft())
287:                        .append("\n");
288:                buffer.append("        .notes      = ").append(getNotes())
289:                        .append("\n");
290:                buffer.append("        .noOrientat = ").append(
291:                        getNoOrientation()).append("\n");
292:                buffer.append("        .usepage    = ").append(getUsePage())
293:                        .append("\n");
294:                buffer.append("    .hresolution    = ")
295:                        .append(getHResolution()).append("\n");
296:                buffer.append("    .vresolution    = ")
297:                        .append(getVResolution()).append("\n");
298:                buffer.append("    .headermargin   = ").append(
299:                        getHeaderMargin()).append("\n");
300:                buffer.append("    .footermargin   = ").append(
301:                        getFooterMargin()).append("\n");
302:                buffer.append("    .copies         = ").append(getCopies())
303:                        .append("\n");
304:                buffer.append("[/PRINTSETUP]\n");
305:                return buffer.toString();
306:            }
307:
308:            public int serialize(int offset, byte[] data) {
309:                LittleEndian.putShort(data, 0 + offset, sid);
310:                LittleEndian.putShort(data, 2 + offset, (short) 34);
311:                LittleEndian.putShort(data, 4 + offset, getPaperSize());
312:                LittleEndian.putShort(data, 6 + offset, getScale());
313:                LittleEndian.putShort(data, 8 + offset, getPageStart());
314:                LittleEndian.putShort(data, 10 + offset, getFitWidth());
315:                LittleEndian.putShort(data, 12 + offset, getFitHeight());
316:                LittleEndian.putShort(data, 14 + offset, getOptions());
317:                LittleEndian.putShort(data, 16 + offset, getHResolution());
318:                LittleEndian.putShort(data, 18 + offset, getVResolution());
319:                LittleEndian.putDouble(data, 20 + offset, getHeaderMargin());
320:                LittleEndian.putDouble(data, 28 + offset, getFooterMargin());
321:                LittleEndian.putShort(data, 36 + offset, getCopies());
322:                return getRecordSize();
323:            }
324:
325:            public int getRecordSize() {
326:                return 38;
327:            }
328:
329:            public short getSid() {
330:                return sid;
331:            }
332:
333:            public Object clone() {
334:                PrintSetupRecord rec = new PrintSetupRecord();
335:                rec.field_1_paper_size = field_1_paper_size;
336:                rec.field_2_scale = field_2_scale;
337:                rec.field_3_page_start = field_3_page_start;
338:                rec.field_4_fit_width = field_4_fit_width;
339:                rec.field_5_fit_height = field_5_fit_height;
340:                rec.field_6_options = field_6_options;
341:                rec.field_7_hresolution = field_7_hresolution;
342:                rec.field_8_vresolution = field_8_vresolution;
343:                rec.field_9_headermargin = field_9_headermargin;
344:                rec.field_10_footermargin = field_10_footermargin;
345:                rec.field_11_copies = field_11_copies;
346:                return rec;
347:            }
348:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.