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
18
19 package org.apache.poi.hssf.usermodel;
20
21 import org.apache.poi.hssf.record.PrintSetupRecord;
22
23 /**
24 * Used to modify the print setup.
25 * <P>
26 * Paper size constants have been added for the ones I have access
27 * to. They follow as:<br>
28 * public static final short LETTER_PAPERSIZE = 1;<br>
29 * public static final short LEGAL_PAPERSIZE = 5;<br>
30 * public static final short EXECUTIVE_PAPERSIZE = 7;<br>
31 * public static final short A4_PAPERSIZE = 9;<br>
32 * public static final short A5_PAPERSIZE = 11;<br>
33 * public static final short ENVELOPE_10_PAPERSIZE = 20;<br>
34 * public static final short ENVELOPE_DL_PAPERSIZE = 27;<br>
35 * public static final short ENVELOPE_CS_PAPERSIZE = 28;<br>
36 * public static final short ENVELOPE_MONARCH_PAPERSIZE = 37;<br>
37 * <P>
38 * @author Shawn Laubach (slaubach at apache dot org) */
39 public class HSSFPrintSetup extends Object {
40 public static final short LETTER_PAPERSIZE = 1;
41 public static final short LEGAL_PAPERSIZE = 5;
42 public static final short EXECUTIVE_PAPERSIZE = 7;
43 public static final short A4_PAPERSIZE = 9;
44 public static final short A5_PAPERSIZE = 11;
45 public static final short ENVELOPE_10_PAPERSIZE = 20;
46 public static final short ENVELOPE_DL_PAPERSIZE = 27;
47 public static final short ENVELOPE_CS_PAPERSIZE = 28;
48 public static final short ENVELOPE_MONARCH_PAPERSIZE = 37;
49 PrintSetupRecord printSetupRecord;
50
51 /**
52 * Constructor. Takes the low level print setup record.
53 * @param printSetupRecord the low level print setup record
54 */
55 protected HSSFPrintSetup(PrintSetupRecord printSetupRecord) {
56 this.printSetupRecord = printSetupRecord;
57 }
58
59 /**
60 * Set the paper size.
61 * @param size the paper size.
62 */
63 public void setPaperSize(short size) {
64 printSetupRecord.setPaperSize(size);
65 }
66
67 /**
68 * Set the scale.
69 * @param scale the scale to use
70 */
71 public void setScale(short scale) {
72 printSetupRecord.setScale(scale);
73 }
74
75 /**
76 * Set the page numbering start.
77 * @param start the page numbering start
78 */
79 public void setPageStart(short start) {
80 printSetupRecord.setPageStart(start);
81 }
82
83 /**
84 * Set the number of pages wide to fit the sheet in
85 * @param width the number of pages
86 */
87 public void setFitWidth(short width) {
88 printSetupRecord.setFitWidth(width);
89 }
90
91 /**
92 * Set the number of pages high to fit the sheet in
93 * @param height the number of pages
94 */
95 public void setFitHeight(short height) {
96 printSetupRecord.setFitHeight(height);
97 }
98
99 /**
100 * Sets the options flags. Not advisable to do it directly.
101 * @param options The bit flags for the options
102 */
103 public void setOptions(short options) {
104 printSetupRecord.setOptions(options);
105 }
106
107 /**
108 * Set whether to go left to right or top down in ordering
109 * @param ltor left to right
110 */
111 public void setLeftToRight(boolean ltor) {
112 printSetupRecord.setLeftToRight(ltor);
113 }
114
115 /**
116 * Set whether to print in landscape
117 * @param ls landscape
118 */
119 public void setLandscape(boolean ls) {
120 printSetupRecord.setLandscape(!ls);
121 }
122
123 /**
124 * Valid settings. I'm not for sure.
125 * @param valid Valid
126 */
127 public void setValidSettings(boolean valid) {
128 printSetupRecord.setValidSettings(valid);
129 }
130
131 /**
132 * Set whether it is black and white
133 * @param mono Black and white
134 */
135 public void setNoColor(boolean mono) {
136 printSetupRecord.setNoColor(mono);
137 }
138
139 /**
140 * Set whether it is in draft mode
141 * @param d draft
142 */
143 public void setDraft(boolean d) {
144 printSetupRecord.setDraft(d);
145 }
146
147 /**
148 * Print the include notes
149 * @param printnotes print the notes
150 */
151 public void setNotes(boolean printnotes) {
152 printSetupRecord.setNotes(printnotes);
153 }
154
155 /**
156 * Set no orientation. ?
157 * @param orientation Orientation.
158 */
159 public void setNoOrientation(boolean orientation) {
160 printSetupRecord.setNoOrientation(orientation);
161 }
162
163 /**
164 * Set whether to use page start
165 * @param page Use page start
166 */
167 public void setUsePage(boolean page) {
168 printSetupRecord.setUsePage(page);
169 }
170
171 /**
172 * Sets the horizontal resolution.
173 * @param resolution horizontal resolution
174 */
175 public void setHResolution(short resolution) {
176 printSetupRecord.setHResolution(resolution);
177 }
178
179 /**
180 * Sets the vertical resolution.
181 * @param resolution vertical resolution
182 */
183 public void setVResolution(short resolution) {
184 printSetupRecord.setVResolution(resolution);
185 }
186
187 /**
188 * Sets the header margin.
189 * @param headermargin header margin
190 */
191 public void setHeaderMargin(double headermargin) {
192 printSetupRecord.setHeaderMargin(headermargin);
193 }
194
195 /**
196 * Sets the footer margin.
197 * @param footermargin footer margin
198 */
199 public void setFooterMargin(double footermargin) {
200 printSetupRecord.setFooterMargin(footermargin);
201 }
202
203 /**
204 * Sets the number of copies.
205 * @param copies number of copies
206 */
207 public void setCopies(short copies) {
208 printSetupRecord.setCopies(copies);
209 }
210
211 /**
212 * Returns the paper size.
213 * @return paper size
214 */
215 public short getPaperSize() {
216 return printSetupRecord.getPaperSize();
217 }
218
219 /**
220 * Returns the scale.
221 * @return scale
222 */
223 public short getScale() {
224 return printSetupRecord.getScale();
225 }
226
227 /**
228 * Returns the page start.
229 * @return page start
230 */
231 public short getPageStart() {
232 return printSetupRecord.getPageStart();
233 }
234
235 /**
236 * Returns the number of pages wide to fit sheet in.
237 * @return number of pages wide to fit sheet in
238 */
239 public short getFitWidth() {
240 return printSetupRecord.getFitWidth();
241 }
242
243 /**
244 * Returns the number of pages high to fit the sheet in.
245 * @return number of pages high to fit the sheet in
246 */
247 public short getFitHeight() {
248 return printSetupRecord.getFitHeight();
249 }
250
251 /**
252 * Returns the bit flags for the options.
253 * @return bit flags for the options
254 */
255 public short getOptions() {
256 return printSetupRecord.getOptions();
257 }
258
259 /**
260 * Returns the left to right print order.
261 * @return left to right print order
262 */
263 public boolean getLeftToRight() {
264 return printSetupRecord.getLeftToRight();
265 }
266
267 /**
268 * Returns the landscape mode.
269 * @return landscape mode
270 */
271 public boolean getLandscape() {
272 return !printSetupRecord.getLandscape();
273 }
274
275 /**
276 * Returns the valid settings.
277 * @return valid settings
278 */
279 public boolean getValidSettings() {
280 return printSetupRecord.getValidSettings();
281 }
282
283 /**
284 * Returns the black and white setting.
285 * @return black and white setting
286 */
287 public boolean getNoColor() {
288 return printSetupRecord.getNoColor();
289 }
290
291 /**
292 * Returns the draft mode.
293 * @return draft mode
294 */
295 public boolean getDraft() {
296 return printSetupRecord.getDraft();
297 }
298
299 /**
300 * Returns the print notes.
301 * @return print notes
302 */
303 public boolean getNotes() {
304 return printSetupRecord.getNotes();
305 }
306
307 /**
308 * Returns the no orientation.
309 * @return no orientation
310 */
311 public boolean getNoOrientation() {
312 return printSetupRecord.getNoOrientation();
313 }
314
315 /**
316 * Returns the use page numbers.
317 * @return use page numbers
318 */
319 public boolean getUsePage() {
320 return printSetupRecord.getUsePage();
321 }
322
323 /**
324 * Returns the horizontal resolution.
325 * @return horizontal resolution
326 */
327 public short getHResolution() {
328 return printSetupRecord.getHResolution();
329 }
330
331 /**
332 * Returns the vertical resolution.
333 * @return vertical resolution
334 */
335 public short getVResolution() {
336 return printSetupRecord.getVResolution();
337 }
338
339 /**
340 * Returns the header margin.
341 * @return header margin
342 */
343 public double getHeaderMargin() {
344 return printSetupRecord.getHeaderMargin();
345 }
346
347 /**
348 * Returns the footer margin.
349 * @return footer margin
350 */
351 public double getFooterMargin() {
352 return printSetupRecord.getFooterMargin();
353 }
354
355 /**
356 * Returns the number of copies.
357 * @return number of copies
358 */
359 public short getCopies() {
360 return printSetupRecord.getCopies();
361 }
362 }