1 19 20 package jxl.write.biff; 21 22 import common.Logger; 23 import jxl.SheetSettings; 24 import jxl.biff.Type; 25 import jxl.biff.IntegerHelper; 26 import jxl.biff.StringHelper; 27 import jxl.biff.DoubleHelper; 28 import jxl.biff.WritableRecordData; 29 import jxl.format.PageOrientation; 30 import jxl.format.PaperSize; 31 32 35 class SetupRecord extends WritableRecordData 36 { 37 40 Logger logger = Logger.getLogger(SetupRecord.class); 41 42 45 private byte[] data; 46 47 50 private double headerMargin; 51 52 55 private double footerMargin; 56 57 60 private PageOrientation orientation; 61 62 65 private int paperSize; 66 67 70 private int scaleFactor; 71 72 75 private int pageStart; 76 77 80 private int fitWidth; 81 82 85 private int fitHeight; 86 87 90 private int horizontalPrintResolution; 91 92 95 private int verticalPrintResolution; 96 97 100 private int copies; 101 102 107 public SetupRecord() 108 { 109 super(Type.SETUP); 110 111 orientation = PageOrientation.PORTRAIT; 112 headerMargin = 0.5; 113 footerMargin = 0.5; 114 paperSize = PaperSize.A4.getValue(); 115 horizontalPrintResolution = 0x12c; 116 verticalPrintResolution = 0x12c; 117 copies = 1; 118 } 119 120 126 public SetupRecord(SheetSettings s) 127 { 128 super(Type.SETUP); 129 130 orientation = s.getOrientation(); 131 headerMargin = s.getHeaderMargin(); 132 footerMargin = s.getFooterMargin(); 133 paperSize = s.getPaperSize().getValue(); 134 horizontalPrintResolution = s.getHorizontalPrintResolution(); 135 verticalPrintResolution = s.getVerticalPrintResolution(); 136 fitWidth = s.getFitWidth(); 137 fitHeight = s.getFitHeight(); 138 pageStart = s.getPageStart(); 139 scaleFactor = s.getScaleFactor(); 140 copies = s.getCopies(); 141 } 142 143 147 public SetupRecord(jxl.read.biff.SetupRecord sr) 148 { 149 super(Type.SETUP); 150 151 orientation = sr.isPortrait() ? 152 PageOrientation.PORTRAIT : PageOrientation.LANDSCAPE; 153 154 paperSize = sr.getPaperSize(); 155 headerMargin = sr.getHeaderMargin(); 156 footerMargin = sr.getFooterMargin(); 157 scaleFactor = sr.getScaleFactor(); 158 pageStart = sr.getPageStart(); 159 fitWidth = sr.getFitWidth(); 160 fitHeight = sr.getFitHeight(); 161 horizontalPrintResolution = sr.getHorizontalPrintResolution(); 162 verticalPrintResolution = sr.getVerticalPrintResolution(); 163 copies = sr.getCopies(); 164 } 165 166 171 public void setOrientation(PageOrientation o) 172 { 173 orientation = o; 174 } 175 176 182 public void setMargins(double hm, double fm) 183 { 184 headerMargin = hm; 185 footerMargin = fm; 186 } 187 188 193 public void setPaperSize(PaperSize ps) 194 { 195 paperSize = ps.getValue(); 196 } 197 198 203 public byte[] getData() 204 { 205 data = new byte[34]; 206 207 IntegerHelper.getTwoBytes(paperSize, data, 0); 209 210 IntegerHelper.getTwoBytes(scaleFactor, data, 2); 212 213 IntegerHelper.getTwoBytes(pageStart, data, 4); 215 216 IntegerHelper.getTwoBytes(fitWidth, data, 6); 218 219 IntegerHelper.getTwoBytes(fitHeight, data, 8); 221 222 if (orientation == PageOrientation.PORTRAIT) 224 { 225 IntegerHelper.getTwoBytes(2, data, 10); 226 } 227 228 IntegerHelper.getTwoBytes(horizontalPrintResolution, data, 12); 230 231 IntegerHelper.getTwoBytes(verticalPrintResolution, data, 14); 233 234 DoubleHelper.getIEEEBytes(headerMargin, data, 16); 236 237 DoubleHelper.getIEEEBytes(footerMargin, data, 24); 239 240 IntegerHelper.getTwoBytes(copies, data, 32); 242 243 return data; 244 } 245 } 246 247 | Popular Tags |