PageRenderTime 105ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/src/org/apache/poi/hwpf/model/types/FFDataBaseAbstractType.java

https://github.com/minstrelsy/SimpleAndroidDocView
Java | 428 lines | 243 code | 42 blank | 143 comment | 14 complexity | 1dcd6a5f95e73cf81088a202b468698a MD5 | raw file
Possible License(s): Apache-2.0
  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.hwpf.model.types;
  16. import org.apache.poi.util.BitField;
  17. import org.apache.poi.util.Internal;
  18. import org.apache.poi.util.LittleEndian;
  19. /**
  20. * The FFData structure specifies form field data for a text
  21. box, check box, or drop-down list box. <p>Class and fields
  22. descriptions are quoted from [MS-DOC] -- v20121003 Word (.doc) Binary
  23. File Format; Copyright (c) 2012 Microsoft Corporation; Release:
  24. October 8, 2012
  25. * <p>
  26. * NOTE: This source is automatically generated please do not modify this file. Either subclass or
  27. * remove the record in src/types/definitions.
  28. * <p>
  29. * This class is internal. It content or properties may change without notice
  30. * due to changes in our knowledge of internal Microsoft Word binary structures.
  31. * @author Sergey Vladimirov; according to [MS-DOC] -- v20121003 Word
  32. (.doc) Binary File Format; Copyright (c) 2012 Microsoft Corporation;
  33. Release: October 8, 2012
  34. */
  35. @Internal
  36. public abstract class FFDataBaseAbstractType
  37. {
  38. protected long field_1_version;
  39. protected short field_2_bits;
  40. /**/private static final BitField iType = new BitField(0x0003);
  41. /** Specifies that the form field is a textbox. */
  42. /* */public final static byte ITYPE_TEXT = 0;
  43. /** Specifies that the form field is a checkbox. */
  44. /* */public final static byte ITYPE_CHCK = 1;
  45. /** Specifies that the form field is a dropdown list box. */
  46. /* */public final static byte ITYPE_DROP = 2;
  47. /**/private static final BitField iRes = new BitField(0x007C);
  48. /**/private static final BitField fOwnHelp = new BitField(0x0080);
  49. /**/private static final BitField fOwnStat = new BitField(0x0100);
  50. /**/private static final BitField fProt = new BitField(0x0200);
  51. /**/private static final BitField iSize = new BitField(0x0400);
  52. /**/private static final BitField iTypeTxt = new BitField(0x3800);
  53. /** Specifies that the textbox value is regular text. */
  54. /* */public final static byte ITYPETXT_REG = 0;
  55. /** Specifies that the textbox value is a number. */
  56. /* */public final static byte ITYPETXT_NUM = 0;
  57. /** Specifies that the textbox value is a date or time. */
  58. /* */public final static byte ITYPETXT_DATE = 0;
  59. /** Specifies that the textbox value is the current date. */
  60. /* */public final static byte ITYPETXT_CURDATE = 0;
  61. /** Specifies that the textbox value is the current time. */
  62. /* */public final static byte ITYPETXT_CURTIME = 0;
  63. /** Specifies that the textbox value is calculated from an expression. The expression is given by FFData.xstzTextDef. */
  64. /* */protected final static byte ITYPETXT_CALC = 0;
  65. /**/private static final BitField fRecalc = new BitField(0x4000);
  66. /**/private static final BitField fHasListBox = new BitField(0x8000);
  67. protected int field_3_cch;
  68. protected int field_4_hps;
  69. protected FFDataBaseAbstractType()
  70. {
  71. }
  72. protected void fillFields( byte[] data, int offset )
  73. {
  74. field_1_version = LittleEndian.getUInt( data, 0x0 + offset );
  75. field_2_bits = LittleEndian.getShort( data, 0x4 + offset );
  76. field_3_cch = LittleEndian.getShort( data, 0x6 + offset );
  77. field_4_hps = LittleEndian.getShort( data, 0x8 + offset );
  78. }
  79. public void serialize( byte[] data, int offset )
  80. {
  81. LittleEndian.putUInt( data, 0x0 + offset, field_1_version );
  82. LittleEndian.putShort( data, 0x4 + offset, field_2_bits );
  83. LittleEndian.putUShort( data, 0x6 + offset, field_3_cch );
  84. LittleEndian.putUShort( data, 0x8 + offset, field_4_hps );
  85. }
  86. public byte[] serialize()
  87. {
  88. final byte[] result = new byte[ getSize() ];
  89. serialize( result, 0 );
  90. return result;
  91. }
  92. /**
  93. * Size of record
  94. */
  95. public static int getSize()
  96. {
  97. return 0 + 4 + 2 + 2 + 2;
  98. }
  99. @Override
  100. public boolean equals( Object obj )
  101. {
  102. if ( this == obj )
  103. return true;
  104. if ( obj == null )
  105. return false;
  106. if ( getClass() != obj.getClass() )
  107. return false;
  108. FFDataBaseAbstractType other = (FFDataBaseAbstractType) obj;
  109. if ( field_1_version != other.field_1_version )
  110. return false;
  111. if ( field_2_bits != other.field_2_bits )
  112. return false;
  113. if ( field_3_cch != other.field_3_cch )
  114. return false;
  115. if ( field_4_hps != other.field_4_hps )
  116. return false;
  117. return true;
  118. }
  119. @Override
  120. public int hashCode()
  121. {
  122. final int prime = 31;
  123. int result = 1;
  124. result = prime * result
  125. + (int) ( field_1_version ^ ( field_1_version >>> 32 ) );
  126. result = prime * result + field_2_bits;
  127. result = prime * result + field_3_cch;
  128. result = prime * result + field_4_hps;
  129. return result;
  130. }
  131. public String toString()
  132. {
  133. StringBuilder builder = new StringBuilder();
  134. builder.append("[FFDataBase]\n");
  135. builder.append( " .version = " );
  136. builder.append(" ( ").append( field_1_version ).append( " )\n" );
  137. builder.append( " .bits = " );
  138. builder.append(" ( ").append( field_2_bits ).append( " )\n" );
  139. builder.append(" .iType = ").append(getIType()).append('\n');
  140. builder.append(" .iRes = ").append(getIRes()).append('\n');
  141. builder.append(" .fOwnHelp = ").append(isFOwnHelp()).append('\n');
  142. builder.append(" .fOwnStat = ").append(isFOwnStat()).append('\n');
  143. builder.append(" .fProt = ").append(isFProt()).append('\n');
  144. builder.append(" .iSize = ").append(isISize()).append('\n');
  145. builder.append(" .iTypeTxt = ").append(getITypeTxt()).append('\n');
  146. builder.append(" .fRecalc = ").append(isFRecalc()).append('\n');
  147. builder.append(" .fHasListBox = ").append(isFHasListBox()).append('\n');
  148. builder.append( " .cch = " );
  149. builder.append(" ( ").append( field_3_cch ).append( " )\n" );
  150. builder.append( " .hps = " );
  151. builder.append(" ( ").append( field_4_hps ).append( " )\n" );
  152. builder.append("[/FFDataBase]");
  153. return builder.toString();
  154. }
  155. /**
  156. * An unsigned integer that MUST be 0xFFFFFFFF.
  157. */
  158. @Internal
  159. public long getVersion()
  160. {
  161. return field_1_version;
  162. }
  163. /**
  164. * An unsigned integer that MUST be 0xFFFFFFFF.
  165. */
  166. @Internal
  167. public void setVersion( long field_1_version )
  168. {
  169. this.field_1_version = field_1_version;
  170. }
  171. /**
  172. * An FFDataBits that specifies the type and state of this form field.
  173. */
  174. @Internal
  175. public short getBits()
  176. {
  177. return field_2_bits;
  178. }
  179. /**
  180. * An FFDataBits that specifies the type and state of this form field.
  181. */
  182. @Internal
  183. public void setBits( short field_2_bits )
  184. {
  185. this.field_2_bits = field_2_bits;
  186. }
  187. /**
  188. * An unsigned integer that specifies the maximum length, in characters, of the value of the textbox. This value MUST NOT exceed 32767. A value of 0 means there is no maximum length of the value of the textbox. If bits.iType is not iTypeText (0), this value MUST be 0..
  189. */
  190. @Internal
  191. public int getCch()
  192. {
  193. return field_3_cch;
  194. }
  195. /**
  196. * An unsigned integer that specifies the maximum length, in characters, of the value of the textbox. This value MUST NOT exceed 32767. A value of 0 means there is no maximum length of the value of the textbox. If bits.iType is not iTypeText (0), this value MUST be 0..
  197. */
  198. @Internal
  199. public void setCch( int field_3_cch )
  200. {
  201. this.field_3_cch = field_3_cch;
  202. }
  203. /**
  204. * An unsigned integer. If bits.iType is iTypeChck (1), hps specifies the size, in half-points, of the checkbox and MUST be between 2 and 3168, inclusive. If bits.iType is not iTypeChck (1), hps is undefined and MUST be ignored..
  205. */
  206. @Internal
  207. public int getHps()
  208. {
  209. return field_4_hps;
  210. }
  211. /**
  212. * An unsigned integer. If bits.iType is iTypeChck (1), hps specifies the size, in half-points, of the checkbox and MUST be between 2 and 3168, inclusive. If bits.iType is not iTypeChck (1), hps is undefined and MUST be ignored..
  213. */
  214. @Internal
  215. public void setHps( int field_4_hps )
  216. {
  217. this.field_4_hps = field_4_hps;
  218. }
  219. /**
  220. * Sets the iType field value.
  221. * An unsigned integer that specifies the type of the form field.
  222. */
  223. @Internal
  224. public void setIType( byte value )
  225. {
  226. field_2_bits = (short)iType.setValue(field_2_bits, value);
  227. }
  228. /**
  229. * An unsigned integer that specifies the type of the form field.
  230. * @return the iType field value.
  231. */
  232. @Internal
  233. public byte getIType()
  234. {
  235. return ( byte )iType.getValue(field_2_bits);
  236. }
  237. /**
  238. * Sets the iRes field value.
  239. * An unsigned integer. If iType is iTypeText (0), then iRes MUST be 0. If iType is iTypeChck (1), iRes specifies the state of the checkbox and MUST be 0 (unchecked), 1 (checked), or 25 (undefined). Undefined checkboxes are treated as unchecked. If iType is iTypeDrop (2), iRes specifies the current selected list box item. A value of 25 specifies the selection is undefined. Otherwise, iRes is a zero-based index into FFData.hsttbDropList.
  240. */
  241. @Internal
  242. public void setIRes( byte value )
  243. {
  244. field_2_bits = (short)iRes.setValue(field_2_bits, value);
  245. }
  246. /**
  247. * An unsigned integer. If iType is iTypeText (0), then iRes MUST be 0. If iType is iTypeChck (1), iRes specifies the state of the checkbox and MUST be 0 (unchecked), 1 (checked), or 25 (undefined). Undefined checkboxes are treated as unchecked. If iType is iTypeDrop (2), iRes specifies the current selected list box item. A value of 25 specifies the selection is undefined. Otherwise, iRes is a zero-based index into FFData.hsttbDropList.
  248. * @return the iRes field value.
  249. */
  250. @Internal
  251. public byte getIRes()
  252. {
  253. return ( byte )iRes.getValue(field_2_bits);
  254. }
  255. /**
  256. * Sets the fOwnHelp field value.
  257. * A bit that specifies whether the form field has custom help text in FFData.xstzHelpText. If fOwnHelp is 0, FFData.xstzHelpText contains an empty or auto-generated string.
  258. */
  259. @Internal
  260. public void setFOwnHelp( boolean value )
  261. {
  262. field_2_bits = (short)fOwnHelp.setBoolean(field_2_bits, value);
  263. }
  264. /**
  265. * A bit that specifies whether the form field has custom help text in FFData.xstzHelpText. If fOwnHelp is 0, FFData.xstzHelpText contains an empty or auto-generated string.
  266. * @return the fOwnHelp field value.
  267. */
  268. @Internal
  269. public boolean isFOwnHelp()
  270. {
  271. return fOwnHelp.isSet(field_2_bits);
  272. }
  273. /**
  274. * Sets the fOwnStat field value.
  275. * A bit that specifies whether the form field has custom status bar text in FFData.xstzStatText. If fOwnStat is 0, FFData.xstzStatText contains an empty or auto-generated string.
  276. */
  277. @Internal
  278. public void setFOwnStat( boolean value )
  279. {
  280. field_2_bits = (short)fOwnStat.setBoolean(field_2_bits, value);
  281. }
  282. /**
  283. * A bit that specifies whether the form field has custom status bar text in FFData.xstzStatText. If fOwnStat is 0, FFData.xstzStatText contains an empty or auto-generated string.
  284. * @return the fOwnStat field value.
  285. */
  286. @Internal
  287. public boolean isFOwnStat()
  288. {
  289. return fOwnStat.isSet(field_2_bits);
  290. }
  291. /**
  292. * Sets the fProt field value.
  293. * A bit that specifies whether the form field is protected and its value cannot be changed.
  294. */
  295. @Internal
  296. public void setFProt( boolean value )
  297. {
  298. field_2_bits = (short)fProt.setBoolean(field_2_bits, value);
  299. }
  300. /**
  301. * A bit that specifies whether the form field is protected and its value cannot be changed.
  302. * @return the fProt field value.
  303. */
  304. @Internal
  305. public boolean isFProt()
  306. {
  307. return fProt.isSet(field_2_bits);
  308. }
  309. /**
  310. * Sets the iSize field value.
  311. * A bit that specifies whether the size of a checkbox is automatically determined by the text size where the checkbox is located. This value MUST be 0 if iType is not iTypeChck (1).
  312. */
  313. @Internal
  314. public void setISize( boolean value )
  315. {
  316. field_2_bits = (short)iSize.setBoolean(field_2_bits, value);
  317. }
  318. /**
  319. * A bit that specifies whether the size of a checkbox is automatically determined by the text size where the checkbox is located. This value MUST be 0 if iType is not iTypeChck (1).
  320. * @return the iSize field value.
  321. */
  322. @Internal
  323. public boolean isISize()
  324. {
  325. return iSize.isSet(field_2_bits);
  326. }
  327. /**
  328. * Sets the iTypeTxt field value.
  329. * An unsigned integer that specifies the type of the textbox. If iType is not iTypeText (0), iTypeTxt MUST be 0 and MUST be ignored.
  330. */
  331. @Internal
  332. public void setITypeTxt( byte value )
  333. {
  334. field_2_bits = (short)iTypeTxt.setValue(field_2_bits, value);
  335. }
  336. /**
  337. * An unsigned integer that specifies the type of the textbox. If iType is not iTypeText (0), iTypeTxt MUST be 0 and MUST be ignored.
  338. * @return the iTypeTxt field value.
  339. */
  340. @Internal
  341. public byte getITypeTxt()
  342. {
  343. return ( byte )iTypeTxt.getValue(field_2_bits);
  344. }
  345. /**
  346. * Sets the fRecalc field value.
  347. * A bit that specifies whether the value of the field is automatically calculated after the field is modified.
  348. */
  349. @Internal
  350. public void setFRecalc( boolean value )
  351. {
  352. field_2_bits = (short)fRecalc.setBoolean(field_2_bits, value);
  353. }
  354. /**
  355. * A bit that specifies whether the value of the field is automatically calculated after the field is modified.
  356. * @return the fRecalc field value.
  357. */
  358. @Internal
  359. public boolean isFRecalc()
  360. {
  361. return fRecalc.isSet(field_2_bits);
  362. }
  363. /**
  364. * Sets the fHasListBox field value.
  365. * A bit that specifies that the form field has a list box. This value MUST be 1 if iType is iTypeDrop (2). Otherwise, this value MUST be 0.
  366. */
  367. @Internal
  368. public void setFHasListBox( boolean value )
  369. {
  370. field_2_bits = (short)fHasListBox.setBoolean(field_2_bits, value);
  371. }
  372. /**
  373. * A bit that specifies that the form field has a list box. This value MUST be 1 if iType is iTypeDrop (2). Otherwise, this value MUST be 0.
  374. * @return the fHasListBox field value.
  375. */
  376. @Internal
  377. public boolean isFHasListBox()
  378. {
  379. return fHasListBox.isSet(field_2_bits);
  380. }
  381. } // END OF CLASS