KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > read > biff > SetupRecord


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.read.biff;
21
22 import jxl.biff.Type;
23 import jxl.biff.IntegerHelper;
24 import jxl.biff.RecordData;
25 import jxl.biff.DoubleHelper;
26
27 /**
28  * Contains the page set up for a sheet
29  */

30 public class SetupRecord extends RecordData
31 {
32   /**
33    * The raw data
34    */

35   private byte[] data;
36
37   /**
38    * The orientation flag
39    */

40   private boolean portraitOrientation;
41
42   /**
43    * The header margin
44    */

45   private double headerMargin;
46
47   /**
48    * The footer margin
49    */

50   private double footerMargin;
51
52   /**
53    * The paper size
54    */

55   private int paperSize;
56
57   /**
58    * The scale factor
59    */

60   private int scaleFactor;
61
62   /**
63    * The page start
64    */

65   private int pageStart;
66
67   /**
68    * The fit width
69    */

70   private int fitWidth;
71
72   /**
73    * The fit height
74    */

75   private int fitHeight;
76
77   /**
78    * The horizontal print resolution
79    */

80   private int horizontalPrintResolution;
81
82   /**
83    * The vertical print resolution
84    */

85   private int verticalPrintResolution;
86
87   /**
88    * The number of copies
89    */

90   private int copies;
91
92   /**
93    * Constructor which creates this object from the binary data
94    *
95    * @param t the record
96    */

97   SetupRecord(Record t)
98   {
99     super(Type.SETUP);
100
101     data = t.getData();
102
103     paperSize = IntegerHelper.getInt(data[0], data[1]);
104     scaleFactor = IntegerHelper.getInt(data[2], data[3]);
105     pageStart = IntegerHelper.getInt(data[4], data[5]);
106     fitWidth = IntegerHelper.getInt(data[6], data[7]);
107     fitHeight = IntegerHelper.getInt(data[8], data[9]);
108     horizontalPrintResolution = IntegerHelper.getInt(data[12], data[13]);
109     verticalPrintResolution = IntegerHelper.getInt(data[14], data[15]);
110     copies = IntegerHelper.getInt(data[32], data[33]);
111
112     headerMargin = DoubleHelper.getIEEEDouble(data, 16);
113     footerMargin = DoubleHelper.getIEEEDouble(data, 24);
114
115
116
117     int grbit = IntegerHelper.getInt(data[10], data[11]);
118     portraitOrientation = ((grbit & 0x02) != 0);
119   }
120
121   /**
122    * Accessor for the orientation. Called when copying sheets
123    *
124    * @return TRUE if the orientation is portrait, FALSE if it is landscape
125    */

126   public boolean isPortrait()
127   {
128     return portraitOrientation;
129   }
130
131   /**
132    * Accessor for the header. Called when copying sheets
133    *
134    * @return the header margin
135    */

136   public double getHeaderMargin()
137   {
138     return headerMargin;
139   }
140
141   /**
142    * Accessor for the footer. Called when copying sheets
143    *
144    * @return the footer margin
145    */

146   public double getFooterMargin()
147   {
148     return footerMargin;
149   }
150
151   /**
152    * Accessor for the paper size. Called when copying sheets
153    *
154    * @return the footer margin
155    */

156   public int getPaperSize()
157   {
158     return paperSize;
159   }
160
161   /**
162    * Accessor for the scale factor. Called when copying sheets
163    *
164    * @return the scale factor
165    */

166   public int getScaleFactor()
167   {
168     return scaleFactor;
169   }
170
171   /**
172    * Accessor for the page height. called when copying sheets
173    *
174    * @return the page to start printing at
175    */

176   public int getPageStart()
177   {
178     return pageStart;
179   }
180
181   /**
182    * Accessor for the fit width. Called when copying sheets
183    *
184    * @return the fit width
185    */

186   public int getFitWidth()
187   {
188     return fitWidth;
189   }
190
191   /**
192    * Accessor for the fit height. Called when copying sheets
193    *
194    * @return the fit height
195    */

196   public int getFitHeight()
197   {
198     return fitHeight;
199   }
200
201   /**
202    * The horizontal print resolution. Called when copying sheets
203    *
204    * @return the horizontal print resolution
205    */

206   public int getHorizontalPrintResolution()
207   {
208     return horizontalPrintResolution;
209   }
210
211   /**
212    * Accessor for the vertical print resolution. Called when copying sheets
213    *
214    * @return an vertical print resolution
215    */

216   public int getVerticalPrintResolution()
217   {
218     return verticalPrintResolution;
219   }
220
221   /**
222    * Accessor for the number of copies
223    *
224    * @return the number of copies
225    */

226   public int getCopies()
227   {
228     return copies;
229   }
230 }
231
Popular Tags