You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HSSFPrintSetup.java 9.8KB

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