Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

LSTFAbstractType.java 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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 java.util.Arrays;
  17. import org.apache.poi.hwpf.model.Grfhic;
  18. import org.apache.poi.util.BitField;
  19. import org.apache.poi.util.Internal;
  20. import org.apache.poi.util.LittleEndian;
  21. /**
  22. * The LSTF structure contains formatting properties that apply to an entire list.
  23. */
  24. @Internal
  25. public abstract class LSTFAbstractType
  26. {
  27. protected int field_1_lsid;
  28. protected int field_2_tplc;
  29. protected short[] field_3_rgistdPara;
  30. protected byte field_4_flags;
  31. /**/private static final BitField fSimpleList = new BitField(0x01);
  32. /**/private static final BitField unused1 = new BitField(0x02);
  33. /**/private static final BitField fAutoNum = new BitField(0x04);
  34. /**/private static final BitField unused2 = new BitField(0x08);
  35. /**/private static final BitField fHybrid = new BitField(0x10);
  36. /**/private static final BitField reserved1 = new BitField(0xE0);
  37. protected Grfhic field_5_grfhic;
  38. protected LSTFAbstractType()
  39. {
  40. this.field_3_rgistdPara = new short[0];
  41. this.field_5_grfhic = new Grfhic();
  42. }
  43. protected void fillFields( byte[] data, int offset )
  44. {
  45. field_1_lsid = LittleEndian.getInt( data, 0x0 + offset );
  46. field_2_tplc = LittleEndian.getInt( data, 0x4 + offset );
  47. field_3_rgistdPara = LittleEndian.getShortArray( data, 0x8 + offset, 18 );
  48. field_4_flags = data[ 0x1a + offset ];
  49. field_5_grfhic = new Grfhic( data, 0x1b + offset );
  50. }
  51. public void serialize( byte[] data, int offset )
  52. {
  53. LittleEndian.putInt( data, 0x0 + offset, field_1_lsid );
  54. LittleEndian.putInt( data, 0x4 + offset, field_2_tplc );
  55. LittleEndian.putShortArray( data, 0x8 + offset, field_3_rgistdPara );
  56. data[ 0x1a + offset ] = field_4_flags;
  57. field_5_grfhic.serialize( data, 0x1b + offset );
  58. }
  59. public byte[] serialize()
  60. {
  61. final byte[] result = new byte[ getSize() ];
  62. serialize( result, 0 );
  63. return result;
  64. }
  65. /**
  66. * Size of record
  67. */
  68. public static int getSize()
  69. {
  70. return 0 + 4 + 4 + 18 + 1 + 1;
  71. }
  72. @Override
  73. public boolean equals( Object obj )
  74. {
  75. if ( this == obj )
  76. return true;
  77. if ( obj == null )
  78. return false;
  79. if ( getClass() != obj.getClass() )
  80. return false;
  81. LSTFAbstractType other = (LSTFAbstractType) obj;
  82. if ( field_1_lsid != other.field_1_lsid )
  83. return false;
  84. if ( field_2_tplc != other.field_2_tplc )
  85. return false;
  86. if ( !Arrays.equals( field_3_rgistdPara, other.field_3_rgistdPara ) )
  87. return false;
  88. if ( field_4_flags != other.field_4_flags )
  89. return false;
  90. if ( field_5_grfhic == null )
  91. {
  92. if ( other.field_5_grfhic != null )
  93. return false;
  94. }
  95. else if ( !field_5_grfhic.equals( other.field_5_grfhic ) )
  96. return false;
  97. return true;
  98. }
  99. @Override
  100. public int hashCode() {
  101. return Arrays.deepHashCode(new Object[]{field_1_lsid, field_2_tplc, field_3_rgistdPara, field_4_flags, field_5_grfhic});
  102. }
  103. public String toString()
  104. {
  105. StringBuilder builder = new StringBuilder();
  106. builder.append("[LSTF]\n");
  107. builder.append(" .lsid = ");
  108. builder.append(" (").append(getLsid()).append(" )\n");
  109. builder.append(" .tplc = ");
  110. builder.append(" (").append(getTplc()).append(" )\n");
  111. builder.append(" .rgistdPara = ");
  112. builder.append(" (").append(Arrays.toString(getRgistdPara())).append(" )\n");
  113. builder.append(" .flags = ");
  114. builder.append(" (").append(getFlags()).append(" )\n");
  115. builder.append(" .fSimpleList = ").append(isFSimpleList()).append('\n');
  116. builder.append(" .unused1 = ").append(isUnused1()).append('\n');
  117. builder.append(" .fAutoNum = ").append(isFAutoNum()).append('\n');
  118. builder.append(" .unused2 = ").append(isUnused2()).append('\n');
  119. builder.append(" .fHybrid = ").append(isFHybrid()).append('\n');
  120. builder.append(" .reserved1 = ").append(getReserved1()).append('\n');
  121. builder.append(" .grfhic = ");
  122. builder.append(" (").append(getGrfhic()).append(" )\n");
  123. builder.append("[/LSTF]\n");
  124. return builder.toString();
  125. }
  126. /**
  127. * A signed integer that specifies the list identifier. This MUST be unique for each LSTF. This value MUST not be 0xFFFFFFFF.
  128. */
  129. @Internal
  130. public int getLsid()
  131. {
  132. return field_1_lsid;
  133. }
  134. /**
  135. * A signed integer that specifies the list identifier. This MUST be unique for each LSTF. This value MUST not be 0xFFFFFFFF.
  136. */
  137. @Internal
  138. public void setLsid( int field_1_lsid )
  139. {
  140. this.field_1_lsid = field_1_lsid;
  141. }
  142. /**
  143. * A Tplc that specifies a unique identifier for this LSTF that MAY be used for user interface purposes. If fHybrid is nonzero, this MUST be ignored.
  144. */
  145. @Internal
  146. public int getTplc()
  147. {
  148. return field_2_tplc;
  149. }
  150. /**
  151. * A Tplc that specifies a unique identifier for this LSTF that MAY be used for user interface purposes. If fHybrid is nonzero, this MUST be ignored.
  152. */
  153. @Internal
  154. public void setTplc( int field_2_tplc )
  155. {
  156. this.field_2_tplc = field_2_tplc;
  157. }
  158. /**
  159. * An array of nine 16-bit signed integers. Each element of rgistdPara specifies the ISTD of the style that is linked to the corresponding level in the list. If no style is linked to a given level, the value of the corresponding element of rgistdPara MUST be 0x0FFF.
  160. */
  161. @Internal
  162. public short[] getRgistdPara()
  163. {
  164. return field_3_rgistdPara;
  165. }
  166. /**
  167. * An array of nine 16-bit signed integers. Each element of rgistdPara specifies the ISTD of the style that is linked to the corresponding level in the list. If no style is linked to a given level, the value of the corresponding element of rgistdPara MUST be 0x0FFF.
  168. */
  169. @Internal
  170. public void setRgistdPara( short[] field_3_rgistdPara )
  171. {
  172. this.field_3_rgistdPara = field_3_rgistdPara;
  173. }
  174. /**
  175. * Get the flags field for the LSTF record.
  176. */
  177. @Internal
  178. public byte getFlags()
  179. {
  180. return field_4_flags;
  181. }
  182. /**
  183. * Set the flags field for the LSTF record.
  184. */
  185. @Internal
  186. public void setFlags( byte field_4_flags )
  187. {
  188. this.field_4_flags = field_4_flags;
  189. }
  190. /**
  191. * A grfhic that specifies the HTML incompatibilities of the list..
  192. */
  193. @Internal
  194. public Grfhic getGrfhic()
  195. {
  196. return field_5_grfhic;
  197. }
  198. /**
  199. * A grfhic that specifies the HTML incompatibilities of the list..
  200. */
  201. @Internal
  202. public void setGrfhic( Grfhic field_5_grfhic )
  203. {
  204. this.field_5_grfhic = field_5_grfhic;
  205. }
  206. /**
  207. * Sets the fSimpleList field value.
  208. * A bit that, when set to 0x1, specifies that this LSTF represents a simple (one-level) list that has one corresponding LVL (see the fcPlfLst field of FibRgFcLcb97). Otherwise, this LSTF represents a multi-level list that has nine corresponding LVLs
  209. */
  210. @Internal
  211. public void setFSimpleList( boolean value )
  212. {
  213. field_4_flags = (byte)fSimpleList.setBoolean(field_4_flags, value);
  214. }
  215. /**
  216. * A bit that, when set to 0x1, specifies that this LSTF represents a simple (one-level) list that has one corresponding LVL (see the fcPlfLst field of FibRgFcLcb97). Otherwise, this LSTF represents a multi-level list that has nine corresponding LVLs
  217. * @return the fSimpleList field value.
  218. */
  219. @Internal
  220. public boolean isFSimpleList()
  221. {
  222. return fSimpleList.isSet(field_4_flags);
  223. }
  224. /**
  225. * Sets the unused1 field value.
  226. * This bit MUST be ignored
  227. */
  228. @Internal
  229. public void setUnused1( boolean value )
  230. {
  231. field_4_flags = (byte)unused1.setBoolean(field_4_flags, value);
  232. }
  233. /**
  234. * This bit MUST be ignored
  235. * @return the unused1 field value.
  236. * @deprecated This field should not be used according to specification
  237. */
  238. @Internal
  239. @Deprecated
  240. public boolean isUnused1()
  241. {
  242. return unused1.isSet(field_4_flags);
  243. }
  244. /**
  245. * Sets the fAutoNum field value.
  246. * A bit that specifies whether the list that this LSTF represents is used for the AUTONUMOUT, AUTONUMLGL, and AUTONUM fields (see AUTONUMOUT, AUTONUMLGL, and AUTONUM in flt)
  247. */
  248. @Internal
  249. public void setFAutoNum( boolean value )
  250. {
  251. field_4_flags = (byte)fAutoNum.setBoolean(field_4_flags, value);
  252. }
  253. /**
  254. * A bit that specifies whether the list that this LSTF represents is used for the AUTONUMOUT, AUTONUMLGL, and AUTONUM fields (see AUTONUMOUT, AUTONUMLGL, and AUTONUM in flt)
  255. * @return the fAutoNum field value.
  256. */
  257. @Internal
  258. public boolean isFAutoNum()
  259. {
  260. return fAutoNum.isSet(field_4_flags);
  261. }
  262. /**
  263. * Sets the unused2 field value.
  264. * This bit MUST be ignored
  265. */
  266. @Internal
  267. public void setUnused2( boolean value )
  268. {
  269. field_4_flags = (byte)unused2.setBoolean(field_4_flags, value);
  270. }
  271. /**
  272. * This bit MUST be ignored
  273. * @return the unused2 field value.
  274. * @deprecated This field should not be used according to specification
  275. */
  276. @Internal
  277. @Deprecated
  278. public boolean isUnused2()
  279. {
  280. return unused2.isSet(field_4_flags);
  281. }
  282. /**
  283. * Sets the fHybrid field value.
  284. * A bit that specifies whether the list this LSTF defines is a hybrid list
  285. */
  286. @Internal
  287. public void setFHybrid( boolean value )
  288. {
  289. field_4_flags = (byte)fHybrid.setBoolean(field_4_flags, value);
  290. }
  291. /**
  292. * A bit that specifies whether the list this LSTF defines is a hybrid list
  293. * @return the fHybrid field value.
  294. */
  295. @Internal
  296. public boolean isFHybrid()
  297. {
  298. return fHybrid.isSet(field_4_flags);
  299. }
  300. /**
  301. * Sets the reserved1 field value.
  302. * This MUST be zero, and MUST be ignored.
  303. */
  304. @Internal
  305. public void setReserved1( byte value )
  306. {
  307. field_4_flags = (byte)reserved1.setValue(field_4_flags, value);
  308. }
  309. /**
  310. * This MUST be zero, and MUST be ignored.
  311. * @return the reserved1 field value.
  312. * @deprecated This field should not be used according to specification
  313. */
  314. @Internal
  315. @Deprecated
  316. public byte getReserved1()
  317. {
  318. return ( byte )reserved1.getValue(field_4_flags);
  319. }
  320. } // END OF CLASS