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.

ExtendedFormatRecord.java 54KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866
  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.record;
  16. import org.apache.poi.util.BitField;
  17. import org.apache.poi.util.BitFieldFactory;
  18. import org.apache.poi.util.LittleEndianOutput;
  19. /**
  20. * Title: Extended Format Record
  21. * Description: Probably one of the more complex records. There are two breeds:
  22. * Style and Cell.
  23. *<P>
  24. * It should be noted that fields in the extended format record are
  25. * somewhat arbitrary. Almost all of the fields are bit-level, but
  26. * we name them as best as possible by functional group. In some
  27. * places this is better than others.
  28. *<P>
  29. *
  30. * REFERENCE: PG 426 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
  31. * @author Andrew C. Oliver (acoliver at apache dot org)
  32. * @version 2.0-pre
  33. */
  34. public final class ExtendedFormatRecord
  35. extends StandardRecord
  36. {
  37. public final static short sid = 0xE0;
  38. // null constant
  39. public final static short NULL = (short)0xfff0;
  40. // xf type
  41. public final static short XF_STYLE = 1;
  42. public final static short XF_CELL = 0;
  43. // borders
  44. public final static short NONE = 0x0;
  45. public final static short THIN = 0x1;
  46. public final static short MEDIUM = 0x2;
  47. public final static short DASHED = 0x3;
  48. public final static short DOTTED = 0x4;
  49. public final static short THICK = 0x5;
  50. public final static short DOUBLE = 0x6;
  51. public final static short HAIR = 0x7;
  52. public final static short MEDIUM_DASHED = 0x8;
  53. public final static short DASH_DOT = 0x9;
  54. public final static short MEDIUM_DASH_DOT = 0xA;
  55. public final static short DASH_DOT_DOT = 0xB;
  56. public final static short MEDIUM_DASH_DOT_DOT = 0xC;
  57. public final static short SLANTED_DASH_DOT = 0xD;
  58. // alignment
  59. public final static short GENERAL = 0x0;
  60. public final static short LEFT = 0x1;
  61. public final static short CENTER = 0x2;
  62. public final static short RIGHT = 0x3;
  63. public final static short FILL = 0x4;
  64. public final static short JUSTIFY = 0x5;
  65. public final static short CENTER_SELECTION = 0x6;
  66. // vertical alignment
  67. public final static short VERTICAL_TOP = 0x0;
  68. public final static short VERTICAL_CENTER = 0x1;
  69. public final static short VERTICAL_BOTTOM = 0x2;
  70. public final static short VERTICAL_JUSTIFY = 0x3;
  71. // fill
  72. public final static short NO_FILL = 0 ;
  73. public final static short SOLID_FILL = 1 ;
  74. public final static short FINE_DOTS = 2 ;
  75. public final static short ALT_BARS = 3 ;
  76. public final static short SPARSE_DOTS = 4 ;
  77. public final static short THICK_HORZ_BANDS = 5 ;
  78. public final static short THICK_VERT_BANDS = 6 ;
  79. public final static short THICK_BACKWARD_DIAG = 7 ;
  80. public final static short THICK_FORWARD_DIAG = 8 ;
  81. public final static short BIG_SPOTS = 9 ;
  82. public final static short BRICKS = 10 ;
  83. public final static short THIN_HORZ_BANDS = 11 ;
  84. public final static short THIN_VERT_BANDS = 12 ;
  85. public final static short THIN_BACKWARD_DIAG = 13 ;
  86. public final static short THIN_FORWARD_DIAG = 14 ;
  87. public final static short SQUARES = 15 ;
  88. public final static short DIAMONDS = 16 ;
  89. // fields in BOTH style and Cell XF records
  90. private short field_1_font_index; // not bit-mapped
  91. private short field_2_format_index; // not bit-mapped
  92. // field_3_cell_options bit map
  93. static final private BitField _locked = BitFieldFactory.getInstance(0x0001);
  94. static final private BitField _hidden = BitFieldFactory.getInstance(0x0002);
  95. static final private BitField _xf_type = BitFieldFactory.getInstance(0x0004);
  96. static final private BitField _123_prefix = BitFieldFactory.getInstance(0x0008);
  97. static final private BitField _parent_index = BitFieldFactory.getInstance(0xFFF0);
  98. private short field_3_cell_options;
  99. // field_4_alignment_options bit map
  100. static final private BitField _alignment = BitFieldFactory.getInstance(0x0007);
  101. static final private BitField _wrap_text = BitFieldFactory.getInstance(0x0008);
  102. static final private BitField _vertical_alignment = BitFieldFactory.getInstance(0x0070);
  103. static final private BitField _justify_last = BitFieldFactory.getInstance(0x0080);
  104. static final private BitField _rotation = BitFieldFactory.getInstance(0xFF00);
  105. private short field_4_alignment_options;
  106. // field_5_indention_options
  107. static final private BitField _indent =
  108. BitFieldFactory.getInstance(0x000F);
  109. static final private BitField _shrink_to_fit =
  110. BitFieldFactory.getInstance(0x0010);
  111. static final private BitField _merge_cells =
  112. BitFieldFactory.getInstance(0x0020);
  113. static final private BitField _reading_order =
  114. BitFieldFactory.getInstance(0x00C0);
  115. // apparently bits 8 and 9 are unused
  116. static final private BitField _indent_not_parent_format =
  117. BitFieldFactory.getInstance(0x0400);
  118. static final private BitField _indent_not_parent_font =
  119. BitFieldFactory.getInstance(0x0800);
  120. static final private BitField _indent_not_parent_alignment =
  121. BitFieldFactory.getInstance(0x1000);
  122. static final private BitField _indent_not_parent_border =
  123. BitFieldFactory.getInstance(0x2000);
  124. static final private BitField _indent_not_parent_pattern =
  125. BitFieldFactory.getInstance(0x4000);
  126. static final private BitField _indent_not_parent_cell_options =
  127. BitFieldFactory.getInstance(0x8000);
  128. private short field_5_indention_options;
  129. // field_6_border_options bit map
  130. static final private BitField _border_left = BitFieldFactory.getInstance(0x000F);
  131. static final private BitField _border_right = BitFieldFactory.getInstance(0x00F0);
  132. static final private BitField _border_top = BitFieldFactory.getInstance(0x0F00);
  133. static final private BitField _border_bottom = BitFieldFactory.getInstance(0xF000);
  134. private short field_6_border_options;
  135. // all three of the following attributes are palette options
  136. // field_7_palette_options bit map
  137. static final private BitField _left_border_palette_idx =
  138. BitFieldFactory.getInstance(0x007F);
  139. static final private BitField _right_border_palette_idx =
  140. BitFieldFactory.getInstance(0x3F80);
  141. static final private BitField _diag =
  142. BitFieldFactory.getInstance(0xC000);
  143. private short field_7_palette_options;
  144. // field_8_adtl_palette_options bit map
  145. static final private BitField _top_border_palette_idx =
  146. BitFieldFactory.getInstance(0x0000007F);
  147. static final private BitField _bottom_border_palette_idx =
  148. BitFieldFactory.getInstance(0x00003F80);
  149. static final private BitField _adtl_diag =
  150. BitFieldFactory.getInstance(0x001fc000);
  151. static final private BitField _adtl_diag_line_style =
  152. BitFieldFactory.getInstance(0x01e00000);
  153. // apparently bit 25 is unused
  154. static final private BitField _adtl_fill_pattern =
  155. BitFieldFactory.getInstance(0xfc000000);
  156. private int field_8_adtl_palette_options; // additional to avoid 2
  157. // field_9_fill_palette_options bit map
  158. static final private BitField _fill_foreground = BitFieldFactory.getInstance(0x007F);
  159. static final private BitField _fill_background = BitFieldFactory.getInstance(0x3f80);
  160. // apparently bits 15 and 14 are unused
  161. private short field_9_fill_palette_options;
  162. /**
  163. * Constructor ExtendedFormatRecord
  164. *
  165. *
  166. */
  167. public ExtendedFormatRecord()
  168. {
  169. }
  170. public ExtendedFormatRecord(RecordInputStream in)
  171. {
  172. field_1_font_index = in.readShort();
  173. field_2_format_index = in.readShort();
  174. field_3_cell_options = in.readShort();
  175. field_4_alignment_options = in.readShort();
  176. field_5_indention_options = in.readShort();
  177. field_6_border_options = in.readShort();
  178. field_7_palette_options = in.readShort();
  179. field_8_adtl_palette_options = in.readInt();
  180. field_9_fill_palette_options = in.readShort();
  181. }
  182. /**
  183. * set the index to the FONT record (which font to use 0 based)
  184. *
  185. *
  186. * @param index to the font
  187. * @see org.apache.poi.hssf.record.FontRecord
  188. */
  189. public void setFontIndex(short index)
  190. {
  191. field_1_font_index = index;
  192. }
  193. /**
  194. * set the index to the Format record (which FORMAT to use 0-based)
  195. *
  196. *
  197. * @param index to the format record
  198. * @see org.apache.poi.hssf.record.FormatRecord
  199. */
  200. public void setFormatIndex(short index)
  201. {
  202. field_2_format_index = index;
  203. }
  204. /**
  205. * sets the options bitmask - you can also use corresponding option bit setters
  206. * (see other methods that reference this one)
  207. *
  208. *
  209. * @param options bitmask to set
  210. *
  211. */
  212. public void setCellOptions(short options)
  213. {
  214. field_3_cell_options = options;
  215. }
  216. // These are the bit fields in cell options
  217. /**
  218. * set whether the cell is locked or not
  219. *
  220. *
  221. * @param locked - if the cell is locked
  222. * @see #setCellOptions(short)
  223. */
  224. public void setLocked(boolean locked)
  225. {
  226. field_3_cell_options = _locked.setShortBoolean(field_3_cell_options,
  227. locked);
  228. }
  229. /**
  230. * set whether the cell is hidden or not
  231. *
  232. *
  233. * @param hidden - if the cell is hidden
  234. * @see #setCellOptions(short)
  235. */
  236. public void setHidden(boolean hidden)
  237. {
  238. field_3_cell_options = _hidden.setShortBoolean(field_3_cell_options,
  239. hidden);
  240. }
  241. /**
  242. * set whether the cell is a cell or style XFRecord
  243. *
  244. *
  245. * @param type - cell or style (0/1)
  246. * @see #XF_STYLE
  247. * @see #XF_CELL
  248. * @see #setCellOptions(short)
  249. */
  250. public void setXFType(short type)
  251. {
  252. field_3_cell_options = _xf_type.setShortValue(field_3_cell_options,
  253. type);
  254. }
  255. /**
  256. * set some old holdover from lotus 123. Who cares, its all over for Lotus.
  257. * RIP Lotus.
  258. *
  259. * @param prefix - the lotus thing to set.
  260. * @see #setCellOptions(short)
  261. */
  262. public void set123Prefix(boolean prefix)
  263. {
  264. field_3_cell_options =
  265. _123_prefix.setShortBoolean(field_3_cell_options, prefix);
  266. }
  267. // present in both but NULL except in cell records
  268. /**
  269. * for cell XF types this is the parent style (usually 0/normal). For
  270. * style this should be NULL.
  271. *
  272. * @param parent index of parent XF
  273. * @see #NULL
  274. * @see #setCellOptions(short)
  275. */
  276. public void setParentIndex(short parent)
  277. {
  278. field_3_cell_options =
  279. _parent_index.setShortValue(field_3_cell_options, parent);
  280. }
  281. // end bitfields in cell options
  282. /**
  283. * set the alignment options bitmask. See corresponding bitsetter methods
  284. * that reference this one.
  285. *
  286. *
  287. * @param options - the bitmask to set
  288. */
  289. public void setAlignmentOptions(short options)
  290. {
  291. field_4_alignment_options = options;
  292. }
  293. /**
  294. * set the horizontal alignment of the cell.
  295. *
  296. *
  297. * @param align - how to align the cell (see constants)
  298. * @see #GENERAL
  299. * @see #LEFT
  300. * @see #CENTER
  301. * @see #RIGHT
  302. * @see #FILL
  303. * @see #JUSTIFY
  304. * @see #CENTER_SELECTION
  305. * @see #setAlignmentOptions(short)
  306. */
  307. public void setAlignment(short align)
  308. {
  309. field_4_alignment_options =
  310. _alignment.setShortValue(field_4_alignment_options, align);
  311. }
  312. /**
  313. * set whether to wrap the text in the cell
  314. *
  315. *
  316. * @param wrapped - whether or not to wrap the cell text
  317. * @see #setAlignmentOptions(short)
  318. */
  319. public void setWrapText(boolean wrapped)
  320. {
  321. field_4_alignment_options =
  322. _wrap_text.setShortBoolean(field_4_alignment_options, wrapped);
  323. }
  324. /**
  325. * set the vertical alignment of text in the cell
  326. *
  327. *
  328. * @param align where to align the text
  329. * @see #VERTICAL_TOP
  330. * @see #VERTICAL_CENTER
  331. * @see #VERTICAL_BOTTOM
  332. * @see #VERTICAL_JUSTIFY
  333. *
  334. * @see #setAlignmentOptions(short)
  335. */
  336. public void setVerticalAlignment(short align)
  337. {
  338. field_4_alignment_options =
  339. _vertical_alignment.setShortValue(field_4_alignment_options,
  340. align);
  341. }
  342. /**
  343. * Dunno. Docs just say this is for far east versions.. (I'm guessing it
  344. * justifies for right-to-left read languages)
  345. *
  346. *
  347. * @param justify
  348. * @see #setAlignmentOptions(short)
  349. */
  350. public void setJustifyLast(short justify)
  351. { // for far east languages supported only for format always 0 for US
  352. field_4_alignment_options =
  353. _justify_last.setShortValue(field_4_alignment_options, justify);
  354. }
  355. /**
  356. * set the degree of rotation. (I've not actually seen this used anywhere)
  357. *
  358. *
  359. * @param rotation the degree of rotation
  360. * @see #setAlignmentOptions(short)
  361. */
  362. public void setRotation(short rotation)
  363. {
  364. field_4_alignment_options =
  365. _rotation.setShortValue(field_4_alignment_options, rotation);
  366. }
  367. /**
  368. * set the indent options bitmask (see corresponding bitmask setters that reference
  369. * this field)
  370. *
  371. *
  372. * @param options bitmask to set.
  373. *
  374. */
  375. public void setIndentionOptions(short options)
  376. {
  377. field_5_indention_options = options;
  378. }
  379. // set bitfields for indention options
  380. /**
  381. * set indention (not sure of the units, think its spaces)
  382. *
  383. * @param indent - how far to indent the cell
  384. * @see #setIndentionOptions(short)
  385. */
  386. public void setIndent(short indent)
  387. {
  388. field_5_indention_options =
  389. _indent.setShortValue(field_5_indention_options, indent);
  390. }
  391. /**
  392. * set whether to shrink the text to fit
  393. *
  394. *
  395. * @param shrink - shrink to fit or not
  396. * @see #setIndentionOptions(short)
  397. */
  398. public void setShrinkToFit(boolean shrink)
  399. {
  400. field_5_indention_options =
  401. _shrink_to_fit.setShortBoolean(field_5_indention_options, shrink);
  402. }
  403. /**
  404. * set whether to merge cells
  405. *
  406. *
  407. * @param merge - merge cells or not
  408. * @see #setIndentionOptions(short)
  409. */
  410. public void setMergeCells(boolean merge)
  411. {
  412. field_5_indention_options =
  413. _merge_cells.setShortBoolean(field_5_indention_options, merge);
  414. }
  415. /**
  416. * set the reading order for far east versions (0 - Context, 1 - Left to right,
  417. * 2 - right to left) - We could use some help with support for the far east.
  418. *
  419. * @param order - the reading order (0,1,2)
  420. * @see #setIndentionOptions(short)
  421. */
  422. public void setReadingOrder(short order)
  423. { // only for far east always 0 in US
  424. field_5_indention_options =
  425. _reading_order.setShortValue(field_5_indention_options, order);
  426. }
  427. /**
  428. * set whether or not to use the format in this XF instead of the parent XF.
  429. *
  430. *
  431. * @param parent - true if this XF has a different format value than its parent,
  432. * false otherwise.
  433. * @see #setIndentionOptions(short)
  434. */
  435. public void setIndentNotParentFormat(boolean parent)
  436. {
  437. field_5_indention_options =
  438. _indent_not_parent_format
  439. .setShortBoolean(field_5_indention_options, parent);
  440. }
  441. /**
  442. * set whether or not to use the font in this XF instead of the parent XF.
  443. *
  444. *
  445. * @param font - true if this XF has a different font value than its parent,
  446. * false otherwise.
  447. * @see #setIndentionOptions(short)
  448. */
  449. public void setIndentNotParentFont(boolean font)
  450. {
  451. field_5_indention_options =
  452. _indent_not_parent_font.setShortBoolean(field_5_indention_options,
  453. font);
  454. }
  455. /**
  456. * set whether or not to use the alignment in this XF instead of the parent XF.
  457. *
  458. *
  459. * @param alignment true if this XF has a different alignment value than its parent,
  460. * false otherwise.
  461. * @see #setIndentionOptions(short)
  462. */
  463. public void setIndentNotParentAlignment(boolean alignment)
  464. {
  465. field_5_indention_options =
  466. _indent_not_parent_alignment
  467. .setShortBoolean(field_5_indention_options, alignment);
  468. }
  469. /**
  470. * set whether or not to use the border in this XF instead of the parent XF.
  471. *
  472. *
  473. * @param border - true if this XF has a different border value than its parent,
  474. * false otherwise.
  475. * @see #setIndentionOptions(short)
  476. */
  477. public void setIndentNotParentBorder(boolean border)
  478. {
  479. field_5_indention_options =
  480. _indent_not_parent_border
  481. .setShortBoolean(field_5_indention_options, border);
  482. }
  483. /**
  484. * <p>Sets whether or not to use the pattern in this XF instead of the
  485. * parent XF (foreground/background).</p>
  486. *
  487. * @param pattern <code>true</code> if this XF has a different pattern
  488. * value than its parent,</code> false</code> otherwise.
  489. * @see #setIndentionOptions(short)
  490. */
  491. public void setIndentNotParentPattern(boolean pattern)
  492. {
  493. field_5_indention_options =
  494. _indent_not_parent_pattern
  495. .setShortBoolean(field_5_indention_options, pattern);
  496. }
  497. /**
  498. * set whether or not to use the locking/hidden in this XF instead of the parent XF.
  499. *
  500. *
  501. * @param options true if this XF has a different locking or hidden value than its parent,
  502. * false otherwise.
  503. * @see #setIndentionOptions(short)
  504. */
  505. public void setIndentNotParentCellOptions(boolean options)
  506. {
  507. field_5_indention_options =
  508. _indent_not_parent_cell_options
  509. .setShortBoolean(field_5_indention_options, options);
  510. }
  511. // end indention options bitmask sets
  512. /**
  513. * set the border options bitmask (see the corresponding bitsetter methods
  514. * that reference back to this one)
  515. *
  516. * @param options - the bit mask to set
  517. *
  518. */
  519. public void setBorderOptions(short options)
  520. {
  521. field_6_border_options = options;
  522. }
  523. // border options bitfields
  524. /**
  525. * set the borderline style for the left border
  526. *
  527. *
  528. * @param border - type of border for the left side of the cell
  529. * @see #NONE
  530. * @see #THIN
  531. * @see #MEDIUM
  532. * @see #DASHED
  533. * @see #DOTTED
  534. * @see #THICK
  535. * @see #DOUBLE
  536. * @see #HAIR
  537. * @see #MEDIUM_DASHED
  538. * @see #DASH_DOT
  539. * @see #MEDIUM_DASH_DOT
  540. * @see #DASH_DOT_DOT
  541. * @see #MEDIUM_DASH_DOT_DOT
  542. * @see #SLANTED_DASH_DOT
  543. * @see #setBorderOptions(short)
  544. */
  545. public void setBorderLeft(short border)
  546. {
  547. field_6_border_options =
  548. _border_left.setShortValue(field_6_border_options, border);
  549. }
  550. /**
  551. * set the border line style for the right border
  552. *
  553. *
  554. * @param border - type of border for the right side of the cell
  555. * @see #NONE
  556. * @see #THIN
  557. * @see #MEDIUM
  558. * @see #DASHED
  559. * @see #DOTTED
  560. * @see #THICK
  561. * @see #DOUBLE
  562. * @see #HAIR
  563. * @see #MEDIUM_DASHED
  564. * @see #DASH_DOT
  565. * @see #MEDIUM_DASH_DOT
  566. * @see #DASH_DOT_DOT
  567. * @see #MEDIUM_DASH_DOT_DOT
  568. * @see #SLANTED_DASH_DOT
  569. * @see #setBorderOptions(short)
  570. */
  571. public void setBorderRight(short border)
  572. {
  573. field_6_border_options =
  574. _border_right.setShortValue(field_6_border_options, border);
  575. }
  576. /**
  577. * set the border line style for the top border
  578. *
  579. *
  580. * @param border - type of border for the top of the cell
  581. * @see #NONE
  582. * @see #THIN
  583. * @see #MEDIUM
  584. * @see #DASHED
  585. * @see #DOTTED
  586. * @see #THICK
  587. * @see #DOUBLE
  588. * @see #HAIR
  589. * @see #MEDIUM_DASHED
  590. * @see #DASH_DOT
  591. * @see #MEDIUM_DASH_DOT
  592. * @see #DASH_DOT_DOT
  593. * @see #MEDIUM_DASH_DOT_DOT
  594. * @see #SLANTED_DASH_DOT
  595. * @see #setBorderOptions(short)
  596. */
  597. public void setBorderTop(short border)
  598. {
  599. field_6_border_options =
  600. _border_top.setShortValue(field_6_border_options, border);
  601. }
  602. /**
  603. * set the border line style for the bottom border
  604. *
  605. *
  606. * @param border - type of border for the bottom of the cell
  607. * @see #NONE
  608. * @see #THIN
  609. * @see #MEDIUM
  610. * @see #DASHED
  611. * @see #DOTTED
  612. * @see #THICK
  613. * @see #DOUBLE
  614. * @see #HAIR
  615. * @see #MEDIUM_DASHED
  616. * @see #DASH_DOT
  617. * @see #MEDIUM_DASH_DOT
  618. * @see #DASH_DOT_DOT
  619. * @see #MEDIUM_DASH_DOT_DOT
  620. * @see #SLANTED_DASH_DOT
  621. * @see #setBorderOptions(short)
  622. */
  623. public void setBorderBottom(short border)
  624. {
  625. field_6_border_options =
  626. _border_bottom.setShortValue(field_6_border_options, border);
  627. }
  628. // end border option bitfields
  629. /**
  630. * set the palette options bitmask (see the individual bitsetter methods that
  631. * reference this one)
  632. *
  633. *
  634. * @param options - the bitmask to set
  635. *
  636. */
  637. public void setPaletteOptions(short options)
  638. {
  639. field_7_palette_options = options;
  640. }
  641. // bitfields for palette options
  642. /**
  643. * set the palette index for the left border color
  644. *
  645. *
  646. * @param border - palette index
  647. * @see #setPaletteOptions(short)
  648. */
  649. public void setLeftBorderPaletteIdx(short border)
  650. {
  651. field_7_palette_options =
  652. _left_border_palette_idx.setShortValue(field_7_palette_options,
  653. border);
  654. }
  655. /**
  656. * set the palette index for the right border color
  657. *
  658. *
  659. * @param border - palette index
  660. * @see #setPaletteOptions(short)
  661. */
  662. public void setRightBorderPaletteIdx(short border)
  663. {
  664. field_7_palette_options =
  665. _right_border_palette_idx.setShortValue(field_7_palette_options,
  666. border);
  667. }
  668. // i've no idea.. possible values are 1 for down, 2 for up and 3 for both...0 for none..
  669. // maybe a diagnal line?
  670. /**
  671. * Not sure what this is for (maybe fill lines?) 1 = down, 2 = up, 3 = both, 0 for none..
  672. *
  673. *
  674. * @param diag - set whatever it is that this is.
  675. * @see #setPaletteOptions(short)
  676. */
  677. public void setDiag(short diag)
  678. {
  679. field_7_palette_options = _diag.setShortValue(field_7_palette_options,
  680. diag);
  681. }
  682. // end of palette options
  683. /**
  684. * set the additional palette options bitmask (see individual bitsetter methods
  685. * that reference this method)
  686. *
  687. *
  688. * @param options - bitmask to set
  689. *
  690. */
  691. public void setAdtlPaletteOptions(short options)
  692. {
  693. field_8_adtl_palette_options = options;
  694. }
  695. // bitfields for additional palette options
  696. /**
  697. * set the palette index for the top border
  698. *
  699. *
  700. * @param border - palette index
  701. * @see #setAdtlPaletteOptions(short)
  702. */
  703. public void setTopBorderPaletteIdx(short border)
  704. {
  705. field_8_adtl_palette_options =
  706. _top_border_palette_idx.setValue(field_8_adtl_palette_options,
  707. border);
  708. }
  709. /**
  710. * set the palette index for the bottom border
  711. *
  712. *
  713. * @param border - palette index
  714. * @see #setAdtlPaletteOptions(short)
  715. */
  716. public void setBottomBorderPaletteIdx(short border)
  717. {
  718. field_8_adtl_palette_options =
  719. _bottom_border_palette_idx.setValue(field_8_adtl_palette_options,
  720. border);
  721. }
  722. /**
  723. * set for diagonal borders? No idea (its a palette color for the other function
  724. * we didn't know what was?)
  725. *
  726. *
  727. * @param diag - the palette index?
  728. * @see #setAdtlPaletteOptions(short)
  729. */
  730. public void setAdtlDiag(short diag)
  731. {
  732. field_8_adtl_palette_options =
  733. _adtl_diag.setValue(field_8_adtl_palette_options, diag);
  734. }
  735. /**
  736. * set the diagonal border line style? Who the heck ever heard of a diagonal border?
  737. *
  738. *
  739. * @param diag - the line style
  740. * @see #NONE
  741. * @see #THIN
  742. * @see #MEDIUM
  743. * @see #DASHED
  744. * @see #DOTTED
  745. * @see #THICK
  746. * @see #DOUBLE
  747. * @see #HAIR
  748. * @see #MEDIUM_DASHED
  749. * @see #DASH_DOT
  750. * @see #MEDIUM_DASH_DOT
  751. * @see #DASH_DOT_DOT
  752. * @see #MEDIUM_DASH_DOT_DOT
  753. * @see #SLANTED_DASH_DOT
  754. * @see #setAdtlPaletteOptions(short)
  755. */
  756. public void setAdtlDiagLineStyle(short diag)
  757. {
  758. field_8_adtl_palette_options =
  759. _adtl_diag_line_style.setValue(field_8_adtl_palette_options,
  760. diag);
  761. }
  762. /**
  763. * set the fill pattern
  764. *
  765. * @see #NO_FILL
  766. * @see #SOLID_FILL
  767. * @see #FINE_DOTS
  768. * @see #ALT_BARS
  769. * @see #SPARSE_DOTS
  770. * @see #THICK_HORZ_BANDS
  771. * @see #THICK_VERT_BANDS
  772. * @see #THICK_BACKWARD_DIAG
  773. * @see #THICK_FORWARD_DIAG
  774. * @see #BIG_SPOTS
  775. * @see #BRICKS
  776. * @see #THIN_HORZ_BANDS
  777. * @see #THIN_VERT_BANDS
  778. * @see #THIN_BACKWARD_DIAG
  779. * @see #THIN_FORWARD_DIAG
  780. * @see #SQUARES
  781. * @see #DIAMONDS
  782. *
  783. * @param fill - fill pattern??
  784. * @see #setAdtlPaletteOptions(short)
  785. */
  786. public void setAdtlFillPattern(short fill)
  787. {
  788. field_8_adtl_palette_options =
  789. _adtl_fill_pattern.setValue(field_8_adtl_palette_options, fill);
  790. }
  791. // end bitfields for additional palette options
  792. /**
  793. * set the fill palette options bitmask (see
  794. *
  795. *
  796. * @param options
  797. *
  798. */
  799. public void setFillPaletteOptions(short options)
  800. {
  801. field_9_fill_palette_options = options;
  802. }
  803. /**
  804. * set the foreground palette color index
  805. *
  806. *
  807. * @param color - palette index
  808. * @see #setFillPaletteOptions(short)
  809. */
  810. public void setFillForeground(short color)
  811. {
  812. field_9_fill_palette_options =
  813. _fill_foreground.setShortValue(field_9_fill_palette_options,
  814. color);
  815. }
  816. /**
  817. * set the background palette color index
  818. *
  819. *
  820. * @param color - palette index
  821. * @see #setFillPaletteOptions(short)
  822. */
  823. public void setFillBackground(short color)
  824. {
  825. field_9_fill_palette_options =
  826. _fill_background.setShortValue(field_9_fill_palette_options,
  827. color);
  828. }
  829. /**
  830. * get the index to the FONT record (which font to use 0 based)
  831. *
  832. *
  833. * @return index to the font
  834. * @see org.apache.poi.hssf.record.FontRecord
  835. */
  836. public short getFontIndex()
  837. {
  838. return field_1_font_index;
  839. }
  840. /**
  841. * get the index to the Format record (which FORMAT to use 0-based)
  842. *
  843. *
  844. * @return index to the format record
  845. * @see org.apache.poi.hssf.record.FormatRecord
  846. */
  847. public short getFormatIndex()
  848. {
  849. return field_2_format_index;
  850. }
  851. /**
  852. * gets the options bitmask - you can also use corresponding option bit getters
  853. * (see other methods that reference this one)
  854. *
  855. *
  856. * @return options bitmask
  857. *
  858. */
  859. public short getCellOptions()
  860. {
  861. return field_3_cell_options;
  862. }
  863. // These are the bit fields in cell options
  864. /**
  865. * get whether the cell is locked or not
  866. *
  867. *
  868. * @return locked - if the cell is locked
  869. * @see #getCellOptions()
  870. */
  871. public boolean isLocked()
  872. {
  873. return _locked.isSet(field_3_cell_options);
  874. }
  875. /**
  876. * get whether the cell is hidden or not
  877. *
  878. *
  879. * @return hidden - if the cell is hidden
  880. * @see #getCellOptions()
  881. */
  882. public boolean isHidden()
  883. {
  884. return _hidden.isSet(field_3_cell_options);
  885. }
  886. /**
  887. * get whether the cell is a cell or style XFRecord
  888. *
  889. *
  890. * @return type - cell or style (0/1)
  891. * @see #XF_STYLE
  892. * @see #XF_CELL
  893. * @see #getCellOptions()
  894. */
  895. public short getXFType()
  896. {
  897. return _xf_type.getShortValue(field_3_cell_options);
  898. }
  899. /**
  900. * get some old holdover from lotus 123. Who cares, its all over for Lotus.
  901. * RIP Lotus.
  902. *
  903. * @return prefix - the lotus thing
  904. * @see #getCellOptions()
  905. */
  906. public boolean get123Prefix()
  907. {
  908. return _123_prefix.isSet(field_3_cell_options);
  909. }
  910. /**
  911. * for cell XF types this is the parent style (usually 0/normal). For
  912. * style this should be NULL.
  913. *
  914. * @return index of parent XF
  915. * @see #NULL
  916. * @see #getCellOptions()
  917. */
  918. public short getParentIndex()
  919. {
  920. return _parent_index.getShortValue(field_3_cell_options);
  921. }
  922. // end bitfields in cell options
  923. /**
  924. * get the alignment options bitmask. See corresponding bitgetter methods
  925. * that reference this one.
  926. *
  927. *
  928. * @return options - the bitmask
  929. */
  930. public short getAlignmentOptions()
  931. {
  932. return field_4_alignment_options;
  933. }
  934. // bitfields in alignment options
  935. /**
  936. * get the horizontal alignment of the cell.
  937. *
  938. *
  939. * @return align - how to align the cell (see constants)
  940. * @see #GENERAL
  941. * @see #LEFT
  942. * @see #CENTER
  943. * @see #RIGHT
  944. * @see #FILL
  945. * @see #JUSTIFY
  946. * @see #CENTER_SELECTION
  947. * @see #getAlignmentOptions()
  948. */
  949. public short getAlignment()
  950. {
  951. return _alignment.getShortValue(field_4_alignment_options);
  952. }
  953. /**
  954. * get whether to wrap the text in the cell
  955. *
  956. *
  957. * @return wrapped - whether or not to wrap the cell text
  958. * @see #getAlignmentOptions()
  959. */
  960. public boolean getWrapText()
  961. {
  962. return _wrap_text.isSet(field_4_alignment_options);
  963. }
  964. /**
  965. * get the vertical alignment of text in the cell
  966. *
  967. *
  968. * @return where to align the text
  969. * @see #VERTICAL_TOP
  970. * @see #VERTICAL_CENTER
  971. * @see #VERTICAL_BOTTOM
  972. * @see #VERTICAL_JUSTIFY
  973. *
  974. * @see #getAlignmentOptions()
  975. */
  976. public short getVerticalAlignment()
  977. {
  978. return _vertical_alignment.getShortValue(field_4_alignment_options);
  979. }
  980. /**
  981. * Dunno. Docs just say this is for far east versions.. (I'm guessing it
  982. * justifies for right-to-left read languages)
  983. *
  984. *
  985. * @return justify
  986. * @see #getAlignmentOptions()
  987. */
  988. public short getJustifyLast()
  989. { // for far east languages supported only for format always 0 for US
  990. return _justify_last.getShortValue(field_4_alignment_options);
  991. }
  992. /**
  993. * get the degree of rotation. (I've not actually seen this used anywhere)
  994. *
  995. *
  996. * @return rotation - the degree of rotation
  997. * @see #getAlignmentOptions()
  998. */
  999. public short getRotation()
  1000. {
  1001. return _rotation.getShortValue(field_4_alignment_options);
  1002. }
  1003. // end alignment options bitfields
  1004. /**
  1005. * get the indent options bitmask (see corresponding bit getters that reference
  1006. * this field)
  1007. *
  1008. *
  1009. * @return options bitmask
  1010. *
  1011. */
  1012. public short getIndentionOptions()
  1013. {
  1014. return field_5_indention_options;
  1015. }
  1016. // bitfields for indention options
  1017. /**
  1018. * get indention (not sure of the units, think its spaces)
  1019. *
  1020. * @return indent - how far to indent the cell
  1021. * @see #getIndentionOptions()
  1022. */
  1023. public short getIndent()
  1024. {
  1025. return _indent.getShortValue(field_5_indention_options);
  1026. }
  1027. /**
  1028. * get whether to shrink the text to fit
  1029. *
  1030. *
  1031. * @return shrink - shrink to fit or not
  1032. * @see #getIndentionOptions()
  1033. */
  1034. public boolean getShrinkToFit()
  1035. {
  1036. return _shrink_to_fit.isSet(field_5_indention_options);
  1037. }
  1038. /**
  1039. * get whether to merge cells
  1040. *
  1041. *
  1042. * @return merge - merge cells or not
  1043. * @see #getIndentionOptions()
  1044. */
  1045. public boolean getMergeCells()
  1046. {
  1047. return _merge_cells.isSet(field_5_indention_options);
  1048. }
  1049. /**
  1050. * get the reading order for far east versions (0 - Context, 1 - Left to right,
  1051. * 2 - right to left) - We could use some help with support for the far east.
  1052. *
  1053. * @return order - the reading order (0,1,2)
  1054. * @see #getIndentionOptions()
  1055. */
  1056. public short getReadingOrder()
  1057. { // only for far east always 0 in US
  1058. return _reading_order.getShortValue(field_5_indention_options);
  1059. }
  1060. /**
  1061. * get whether or not to use the format in this XF instead of the parent XF.
  1062. *
  1063. *
  1064. * @return parent - true if this XF has a different format value than its parent,
  1065. * false otherwise.
  1066. * @see #getIndentionOptions()
  1067. */
  1068. public boolean isIndentNotParentFormat()
  1069. {
  1070. return _indent_not_parent_format.isSet(field_5_indention_options);
  1071. }
  1072. /**
  1073. * get whether or not to use the font in this XF instead of the parent XF.
  1074. *
  1075. *
  1076. * @return font - true if this XF has a different font value than its parent,
  1077. * false otherwise.
  1078. * @see #getIndentionOptions()
  1079. */
  1080. public boolean isIndentNotParentFont()
  1081. {
  1082. return _indent_not_parent_font.isSet(field_5_indention_options);
  1083. }
  1084. /**
  1085. * get whether or not to use the alignment in this XF instead of the parent XF.
  1086. *
  1087. *
  1088. * @return alignment true if this XF has a different alignment value than its parent,
  1089. * false otherwise.
  1090. * @see #getIndentionOptions()
  1091. */
  1092. public boolean isIndentNotParentAlignment()
  1093. {
  1094. return _indent_not_parent_alignment.isSet(field_5_indention_options);
  1095. }
  1096. /**
  1097. * get whether or not to use the border in this XF instead of the parent XF.
  1098. *
  1099. *
  1100. * @return border - true if this XF has a different border value than its parent,
  1101. * false otherwise.
  1102. * @see #getIndentionOptions()
  1103. */
  1104. public boolean isIndentNotParentBorder()
  1105. {
  1106. return _indent_not_parent_border.isSet(field_5_indention_options);
  1107. }
  1108. /**
  1109. * get whether or not to use the pattern in this XF instead of the parent XF.
  1110. * (foregrount/background)
  1111. *
  1112. * @return pattern- true if this XF has a different pattern value than its parent,
  1113. * false otherwise.
  1114. * @see #getIndentionOptions()
  1115. */
  1116. public boolean isIndentNotParentPattern()
  1117. {
  1118. return _indent_not_parent_pattern.isSet(field_5_indention_options);
  1119. }
  1120. /**
  1121. * get whether or not to use the locking/hidden in this XF instead of the parent XF.
  1122. *
  1123. *
  1124. * @return options- true if this XF has a different locking or hidden value than its parent,
  1125. * false otherwise.
  1126. * @see #getIndentionOptions()
  1127. */
  1128. public boolean isIndentNotParentCellOptions()
  1129. {
  1130. return _indent_not_parent_cell_options
  1131. .isSet(field_5_indention_options);
  1132. }
  1133. // end of bitfields for indention options
  1134. // border options
  1135. /**
  1136. * get the border options bitmask (see the corresponding bit getter methods
  1137. * that reference back to this one)
  1138. *
  1139. * @return options - the bit mask to set
  1140. *
  1141. */
  1142. public short getBorderOptions()
  1143. {
  1144. return field_6_border_options;
  1145. }
  1146. // bitfields for border options
  1147. /**
  1148. * get the borderline style for the left border
  1149. *
  1150. *
  1151. * @return border - type of border for the left side of the cell
  1152. * @see #NONE
  1153. * @see #THIN
  1154. * @see #MEDIUM
  1155. * @see #DASHED
  1156. * @see #DOTTED
  1157. * @see #THICK
  1158. * @see #DOUBLE
  1159. * @see #HAIR
  1160. * @see #MEDIUM_DASHED
  1161. * @see #DASH_DOT
  1162. * @see #MEDIUM_DASH_DOT
  1163. * @see #DASH_DOT_DOT
  1164. * @see #MEDIUM_DASH_DOT_DOT
  1165. * @see #SLANTED_DASH_DOT
  1166. * @see #getBorderOptions()
  1167. */
  1168. public short getBorderLeft()
  1169. {
  1170. return _border_left.getShortValue(field_6_border_options);
  1171. }
  1172. /**
  1173. * get the borderline style for the right border
  1174. *
  1175. *
  1176. * @return border - type of border for the right side of the cell
  1177. * @see #NONE
  1178. * @see #THIN
  1179. * @see #MEDIUM
  1180. * @see #DASHED
  1181. * @see #DOTTED
  1182. * @see #THICK
  1183. * @see #DOUBLE
  1184. * @see #HAIR
  1185. * @see #MEDIUM_DASHED
  1186. * @see #DASH_DOT
  1187. * @see #MEDIUM_DASH_DOT
  1188. * @see #DASH_DOT_DOT
  1189. * @see #MEDIUM_DASH_DOT_DOT
  1190. * @see #SLANTED_DASH_DOT
  1191. * @see #getBorderOptions()
  1192. */
  1193. public short getBorderRight()
  1194. {
  1195. return _border_right.getShortValue(field_6_border_options);
  1196. }
  1197. /**
  1198. * get the borderline style for the top border
  1199. *
  1200. *
  1201. * @return border - type of border for the top of the cell
  1202. * @see #NONE
  1203. * @see #THIN
  1204. * @see #MEDIUM
  1205. * @see #DASHED
  1206. * @see #DOTTED
  1207. * @see #THICK
  1208. * @see #DOUBLE
  1209. * @see #HAIR
  1210. * @see #MEDIUM_DASHED
  1211. * @see #DASH_DOT
  1212. * @see #MEDIUM_DASH_DOT
  1213. * @see #DASH_DOT_DOT
  1214. * @see #MEDIUM_DASH_DOT_DOT
  1215. * @see #SLANTED_DASH_DOT
  1216. * @see #getBorderOptions()
  1217. */
  1218. public short getBorderTop()
  1219. {
  1220. return _border_top.getShortValue(field_6_border_options);
  1221. }
  1222. /**
  1223. * get the borderline style for the bottom border
  1224. *
  1225. *
  1226. * @return border - type of border for the bottom of the cell
  1227. * @see #NONE
  1228. * @see #THIN
  1229. * @see #MEDIUM
  1230. * @see #DASHED
  1231. * @see #DOTTED
  1232. * @see #THICK
  1233. * @see #DOUBLE
  1234. * @see #HAIR
  1235. * @see #MEDIUM_DASHED
  1236. * @see #DASH_DOT
  1237. * @see #MEDIUM_DASH_DOT
  1238. * @see #DASH_DOT_DOT
  1239. * @see #MEDIUM_DASH_DOT_DOT
  1240. * @see #SLANTED_DASH_DOT
  1241. * @see #getBorderOptions()
  1242. */
  1243. public short getBorderBottom()
  1244. {
  1245. return _border_bottom.getShortValue(field_6_border_options);
  1246. }
  1247. // record types -- palette options
  1248. /**
  1249. * get the palette options bitmask (see the individual bit getter methods that
  1250. * reference this one)
  1251. *
  1252. *
  1253. * @return options - the bitmask
  1254. *
  1255. */
  1256. public short getPaletteOptions()
  1257. {
  1258. return field_7_palette_options;
  1259. }
  1260. // bitfields for palette options
  1261. /**
  1262. * get the palette index for the left border color
  1263. *
  1264. *
  1265. * @return border - palette index
  1266. * @see #getPaletteOptions()
  1267. */
  1268. public short getLeftBorderPaletteIdx()
  1269. {
  1270. return _left_border_palette_idx
  1271. .getShortValue(field_7_palette_options);
  1272. }
  1273. /**
  1274. * get the palette index for the right border color
  1275. *
  1276. *
  1277. * @return border - palette index
  1278. * @see #getPaletteOptions()
  1279. */
  1280. public short getRightBorderPaletteIdx()
  1281. {
  1282. return _right_border_palette_idx
  1283. .getShortValue(field_7_palette_options);
  1284. }
  1285. // i've no idea.. possible values are 1 for down, 2 for up and 3 for both...0 for none..
  1286. // maybe a diagnal line?
  1287. /**
  1288. * Not sure what this is for (maybe fill lines?) 1 = down, 2 = up, 3 = both, 0 for none..
  1289. *
  1290. *
  1291. * @return diag - whatever it is that this is.
  1292. * @see #getPaletteOptions()
  1293. */
  1294. public short getDiag()
  1295. {
  1296. return _diag.getShortValue(field_7_palette_options);
  1297. }
  1298. // end of style palette options
  1299. // additional palette options
  1300. /**
  1301. * get the additional palette options bitmask (see individual bit getter methods
  1302. * that reference this method)
  1303. *
  1304. *
  1305. * @return options - bitmask to set
  1306. *
  1307. */
  1308. public int getAdtlPaletteOptions()
  1309. {
  1310. return field_8_adtl_palette_options;
  1311. }
  1312. // bitfields for additional palette options
  1313. /**
  1314. * get the palette index for the top border
  1315. *
  1316. *
  1317. * @return border - palette index
  1318. * @see #getAdtlPaletteOptions()
  1319. */
  1320. public short getTopBorderPaletteIdx()
  1321. {
  1322. return ( short ) _top_border_palette_idx
  1323. .getValue(field_8_adtl_palette_options);
  1324. }
  1325. /**
  1326. * get the palette index for the bottom border
  1327. *
  1328. *
  1329. * @return border - palette index
  1330. * @see #getAdtlPaletteOptions()
  1331. */
  1332. public short getBottomBorderPaletteIdx()
  1333. {
  1334. return ( short ) _bottom_border_palette_idx
  1335. .getValue(field_8_adtl_palette_options);
  1336. }
  1337. /**
  1338. * get for diagonal borders? No idea (its a palette color for the other function
  1339. * we didn't know what was?)
  1340. *
  1341. *
  1342. * @return diag - the palette index?
  1343. * @see #getAdtlPaletteOptions()
  1344. */
  1345. public short getAdtlDiag()
  1346. {
  1347. return ( short ) _adtl_diag.getValue(field_8_adtl_palette_options);
  1348. }
  1349. /**
  1350. * get the diagonal border line style? Who the heck ever heard of a diagonal border?
  1351. *
  1352. *
  1353. * @return diag - the line style
  1354. * @see #NONE
  1355. * @see #THIN
  1356. * @see #MEDIUM
  1357. * @see #DASHED
  1358. * @see #DOTTED
  1359. * @see #THICK
  1360. * @see #DOUBLE
  1361. * @see #HAIR
  1362. * @see #MEDIUM_DASHED
  1363. * @see #DASH_DOT
  1364. * @see #MEDIUM_DASH_DOT
  1365. * @see #DASH_DOT_DOT
  1366. * @see #MEDIUM_DASH_DOT_DOT
  1367. * @see #SLANTED_DASH_DOT
  1368. * @see #getAdtlPaletteOptions()
  1369. */
  1370. public short getAdtlDiagLineStyle()
  1371. {
  1372. return ( short ) _adtl_diag_line_style
  1373. .getValue(field_8_adtl_palette_options);
  1374. }
  1375. /**
  1376. * get the additional fill pattern
  1377. *
  1378. * @see #NO_FILL
  1379. * @see #SOLID_FILL
  1380. * @see #FINE_DOTS
  1381. * @see #ALT_BARS
  1382. * @see #SPARSE_DOTS
  1383. * @see #THICK_HORZ_BANDS
  1384. * @see #THICK_VERT_BANDS
  1385. * @see #THICK_BACKWARD_DIAG
  1386. * @see #THICK_FORWARD_DIAG
  1387. * @see #BIG_SPOTS
  1388. * @see #BRICKS
  1389. * @see #THIN_HORZ_BANDS
  1390. * @see #THIN_VERT_BANDS
  1391. * @see #THIN_BACKWARD_DIAG
  1392. * @see #THIN_FORWARD_DIAG
  1393. * @see #SQUARES
  1394. * @see #DIAMONDS
  1395. *
  1396. * @return fill - fill pattern??
  1397. * @see #getAdtlPaletteOptions()
  1398. */
  1399. public short getAdtlFillPattern()
  1400. {
  1401. return ( short ) _adtl_fill_pattern
  1402. .getValue(field_8_adtl_palette_options);
  1403. }
  1404. // end bitfields for additional palette options
  1405. // fill palette options
  1406. /**
  1407. * get the fill palette options bitmask (see indivdual bit getters that
  1408. * reference this method)
  1409. *
  1410. * @return options
  1411. *
  1412. */
  1413. public short getFillPaletteOptions()
  1414. {
  1415. return field_9_fill_palette_options;
  1416. }
  1417. // bitfields for fill palette options
  1418. /**
  1419. * get the foreground palette color index
  1420. *
  1421. *
  1422. * @return color - palette index
  1423. * @see #getFillPaletteOptions()
  1424. */
  1425. public short getFillForeground()
  1426. {
  1427. return _fill_foreground.getShortValue(field_9_fill_palette_options);
  1428. }
  1429. /**
  1430. * get the background palette color index
  1431. *
  1432. * @return color palette index
  1433. * @see #getFillPaletteOptions()
  1434. */
  1435. public short getFillBackground()
  1436. {
  1437. return _fill_background.getShortValue(field_9_fill_palette_options);
  1438. }
  1439. public String toString()
  1440. {
  1441. StringBuffer buffer = new StringBuffer();
  1442. buffer.append("[EXTENDEDFORMAT]\n");
  1443. if (getXFType() == XF_STYLE)
  1444. {
  1445. buffer.append(" STYLE_RECORD_TYPE\n");
  1446. }
  1447. else if (getXFType() == XF_CELL)
  1448. {
  1449. buffer.append(" CELL_RECORD_TYPE\n");
  1450. }
  1451. buffer.append(" .fontindex = ")
  1452. .append(Integer.toHexString(getFontIndex())).append("\n");
  1453. buffer.append(" .formatindex = ")
  1454. .append(Integer.toHexString(getFormatIndex())).append("\n");
  1455. buffer.append(" .celloptions = ")
  1456. .append(Integer.toHexString(getCellOptions())).append("\n");
  1457. buffer.append(" .islocked = ").append(isLocked())
  1458. .append("\n");
  1459. buffer.append(" .ishidden = ").append(isHidden())
  1460. .append("\n");
  1461. buffer.append(" .recordtype= ")
  1462. .append(Integer.toHexString(getXFType())).append("\n");
  1463. buffer.append(" .parentidx = ")
  1464. .append(Integer.toHexString(getParentIndex())).append("\n");
  1465. buffer.append(" .alignmentoptions= ")
  1466. .append(Integer.toHexString(getAlignmentOptions())).append("\n");
  1467. buffer.append(" .alignment = ").append(getAlignment())
  1468. .append("\n");
  1469. buffer.append(" .wraptext = ").append(getWrapText())
  1470. .append("\n");
  1471. buffer.append(" .valignment= ")
  1472. .append(Integer.toHexString(getVerticalAlignment())).append("\n");
  1473. buffer.append(" .justlast = ")
  1474. .append(Integer.toHexString(getJustifyLast())).append("\n");
  1475. buffer.append(" .rotation = ")
  1476. .append(Integer.toHexString(getRotation())).append("\n");
  1477. buffer.append(" .indentionoptions= ")
  1478. .append(Integer.toHexString(getIndentionOptions())).append("\n");
  1479. buffer.append(" .indent = ")
  1480. .append(Integer.toHexString(getIndent())).append("\n");
  1481. buffer.append(" .shrinktoft= ").append(getShrinkToFit())
  1482. .append("\n");
  1483. buffer.append(" .mergecells= ").append(getMergeCells())
  1484. .append("\n");
  1485. buffer.append(" .readngordr= ")
  1486. .append(Integer.toHexString(getReadingOrder())).append("\n");
  1487. buffer.append(" .formatflag= ")
  1488. .append(isIndentNotParentFormat()).append("\n");
  1489. buffer.append(" .fontflag = ")
  1490. .append(isIndentNotParentFont()).append("\n");
  1491. buffer.append(" .prntalgnmt= ")
  1492. .append(isIndentNotParentAlignment()).append("\n");
  1493. buffer.append(" .borderflag= ")
  1494. .append(isIndentNotParentBorder()).append("\n");
  1495. buffer.append(" .paternflag= ")
  1496. .append(isIndentNotParentPattern()).append("\n");
  1497. buffer.append(" .celloption= ")
  1498. .append(isIndentNotParentCellOptions()).append("\n");
  1499. buffer.append(" .borderoptns = ")
  1500. .append(Integer.toHexString(getBorderOptions())).append("\n");
  1501. buffer.append(" .lftln = ")
  1502. .append(Integer.toHexString(getBorderLeft())).append("\n");
  1503. buffer.append(" .rgtln = ")
  1504. .append(Integer.toHexString(getBorderRight())).append("\n");
  1505. buffer.append(" .topln = ")
  1506. .append(Integer.toHexString(getBorderTop())).append("\n");
  1507. buffer.append(" .btmln = ")
  1508. .append(Integer.toHexString(getBorderBottom())).append("\n");
  1509. buffer.append(" .paleteoptns = ")
  1510. .append(Integer.toHexString(getPaletteOptions())).append("\n");
  1511. buffer.append(" .leftborder= ")
  1512. .append(Integer.toHexString(getLeftBorderPaletteIdx()))
  1513. .append("\n");
  1514. buffer.append(" .rghtborder= ")
  1515. .append(Integer.toHexString(getRightBorderPaletteIdx()))
  1516. .append("\n");
  1517. buffer.append(" .diag = ")
  1518. .append(Integer.toHexString(getDiag())).append("\n");
  1519. buffer.append(" .paleteoptn2 = ")
  1520. .append(Integer.toHexString(getAdtlPaletteOptions()))
  1521. .append("\n");
  1522. buffer.append(" .topborder = ")
  1523. .append(Integer.toHexString(getTopBorderPaletteIdx()))
  1524. .append("\n");
  1525. buffer.append(" .botmborder= ")
  1526. .append(Integer.toHexString(getBottomBorderPaletteIdx()))
  1527. .append("\n");
  1528. buffer.append(" .adtldiag = ")
  1529. .append(Integer.toHexString(getAdtlDiag())).append("\n");
  1530. buffer.append(" .diaglnstyl= ")
  1531. .append(Integer.toHexString(getAdtlDiagLineStyle())).append("\n");
  1532. buffer.append(" .fillpattrn= ")
  1533. .append(Integer.toHexString(getAdtlFillPattern())).append("\n");
  1534. buffer.append(" .fillpaloptn = ")
  1535. .append(Integer.toHexString(getFillPaletteOptions()))
  1536. .append("\n");
  1537. buffer.append(" .foreground= ")
  1538. .append(Integer.toHexString(getFillForeground())).append("\n");
  1539. buffer.append(" .background= ")
  1540. .append(Integer.toHexString(getFillBackground())).append("\n");
  1541. buffer.append("[/EXTENDEDFORMAT]\n");
  1542. return buffer.toString();
  1543. }
  1544. public void serialize(LittleEndianOutput out) {
  1545. out.writeShort(getFontIndex());
  1546. out.writeShort(getFormatIndex());
  1547. out.writeShort(getCellOptions());
  1548. out.writeShort(getAlignmentOptions());
  1549. out.writeShort(getIndentionOptions());
  1550. out.writeShort(getBorderOptions());
  1551. out.writeShort(getPaletteOptions());
  1552. out.writeInt(getAdtlPaletteOptions());
  1553. out.writeShort(getFillPaletteOptions());
  1554. }
  1555. protected int getDataSize() {
  1556. return 20;
  1557. }
  1558. public short getSid()
  1559. {
  1560. return sid;
  1561. }
  1562. /**
  1563. * Clones all the style information from another
  1564. * ExtendedFormatRecord, onto this one. This
  1565. * will then hold all the same style options.
  1566. *
  1567. * If The source ExtendedFormatRecord comes from
  1568. * a different Workbook, you will need to sort
  1569. * out the font and format indicies yourself!
  1570. */
  1571. public void cloneStyleFrom(ExtendedFormatRecord source) {
  1572. field_1_font_index = source.field_1_font_index;
  1573. field_2_format_index = source.field_2_format_index;
  1574. field_3_cell_options = source.field_3_cell_options;
  1575. field_4_alignment_options = source.field_4_alignment_options;
  1576. field_5_indention_options = source.field_5_indention_options;
  1577. field_6_border_options = source.field_6_border_options;
  1578. field_7_palette_options = source.field_7_palette_options;
  1579. field_8_adtl_palette_options = source.field_8_adtl_palette_options;
  1580. field_9_fill_palette_options = source.field_9_fill_palette_options;
  1581. }
  1582. public int hashCode() {
  1583. final int prime = 31;
  1584. int result = 1;
  1585. result = prime * result + field_1_font_index;
  1586. result = prime * result + field_2_format_index;
  1587. result = prime * result + field_3_cell_options;
  1588. result = prime * result + field_4_alignment_options;
  1589. result = prime * result + field_5_indention_options;
  1590. result = prime * result + field_6_border_options;
  1591. result = prime * result + field_7_palette_options;
  1592. result = prime * result + field_8_adtl_palette_options;
  1593. result = prime * result + field_9_fill_palette_options;
  1594. return result;
  1595. }
  1596. /**
  1597. * Will consider two different records with the same
  1598. * contents as equals, as the various indexes
  1599. * that matter are embedded in the records
  1600. */
  1601. public boolean equals(Object obj) {
  1602. if (this == obj)
  1603. return true;
  1604. if (obj == null)
  1605. return false;
  1606. if (obj instanceof ExtendedFormatRecord) {
  1607. final ExtendedFormatRecord other = (ExtendedFormatRecord) obj;
  1608. if (field_1_font_index != other.field_1_font_index)
  1609. return false;
  1610. if (field_2_format_index != other.field_2_format_index)
  1611. return false;
  1612. if (field_3_cell_options != other.field_3_cell_options)
  1613. return false;
  1614. if (field_4_alignment_options != other.field_4_alignment_options)
  1615. return false;
  1616. if (field_5_indention_options != other.field_5_indention_options)
  1617. return false;
  1618. if (field_6_border_options != other.field_6_border_options)
  1619. return false;
  1620. if (field_7_palette_options != other.field_7_palette_options)
  1621. return false;
  1622. if (field_8_adtl_palette_options != other.field_8_adtl_palette_options)
  1623. return false;
  1624. if (field_9_fill_palette_options != other.field_9_fill_palette_options)
  1625. return false;
  1626. return true;
  1627. }
  1628. return false;
  1629. }
  1630. }