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.

LFOAbstractType.java 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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.Objects;
  17. import org.apache.poi.hwpf.model.Grfhic;
  18. import org.apache.poi.util.Internal;
  19. import org.apache.poi.util.LittleEndian;
  20. /**
  21. * List Format Override (LFO).
  22. */
  23. @Internal
  24. public abstract class LFOAbstractType
  25. {
  26. protected int field_1_lsid;
  27. protected int field_2_unused1;
  28. protected int field_3_unused2;
  29. protected byte field_4_clfolvl;
  30. protected byte field_5_ibstFltAutoNum;
  31. protected Grfhic field_6_grfhic;
  32. protected byte field_7_unused3;
  33. protected LFOAbstractType()
  34. {
  35. this.field_6_grfhic = new Grfhic();
  36. }
  37. protected void fillFields( byte[] data, int offset )
  38. {
  39. field_1_lsid = LittleEndian.getInt( data, 0x0 + offset );
  40. field_2_unused1 = LittleEndian.getInt( data, 0x4 + offset );
  41. field_3_unused2 = LittleEndian.getInt( data, 0x8 + offset );
  42. field_4_clfolvl = data[ 0xc + offset ];
  43. field_5_ibstFltAutoNum = data[ 0xd + offset ];
  44. field_6_grfhic = new Grfhic( data, 0xe + offset );
  45. field_7_unused3 = data[ 0xf + offset ];
  46. }
  47. public void serialize( byte[] data, int offset )
  48. {
  49. LittleEndian.putInt( data, 0x0 + offset, field_1_lsid );
  50. LittleEndian.putInt( data, 0x4 + offset, field_2_unused1 );
  51. LittleEndian.putInt( data, 0x8 + offset, field_3_unused2 );
  52. data[ 0xc + offset ] = field_4_clfolvl;
  53. data[ 0xd + offset ] = field_5_ibstFltAutoNum;
  54. field_6_grfhic.serialize( data, 0xe + offset );
  55. data[ 0xf + offset ] = field_7_unused3;
  56. }
  57. public byte[] serialize()
  58. {
  59. final byte[] result = new byte[ getSize() ];
  60. serialize( result, 0 );
  61. return result;
  62. }
  63. /**
  64. * Size of record
  65. */
  66. public static int getSize()
  67. {
  68. return 0 + 4 + 4 + 4 + 1 + 1 + 1 + 1;
  69. }
  70. @Override
  71. public boolean equals( Object obj )
  72. {
  73. if ( this == obj )
  74. return true;
  75. if ( obj == null )
  76. return false;
  77. if ( getClass() != obj.getClass() )
  78. return false;
  79. LFOAbstractType other = (LFOAbstractType) obj;
  80. if ( field_1_lsid != other.field_1_lsid )
  81. return false;
  82. if ( field_2_unused1 != other.field_2_unused1 )
  83. return false;
  84. if ( field_3_unused2 != other.field_3_unused2 )
  85. return false;
  86. if ( field_4_clfolvl != other.field_4_clfolvl )
  87. return false;
  88. if ( field_5_ibstFltAutoNum != other.field_5_ibstFltAutoNum )
  89. return false;
  90. if ( field_6_grfhic == null )
  91. {
  92. if ( other.field_6_grfhic != null )
  93. return false;
  94. }
  95. else if ( !field_6_grfhic.equals( other.field_6_grfhic ) )
  96. return false;
  97. if ( field_7_unused3 != other.field_7_unused3 )
  98. return false;
  99. return true;
  100. }
  101. @Override
  102. public int hashCode() {
  103. return Objects.hash(field_1_lsid, field_2_unused1, field_3_unused2, field_4_clfolvl, field_5_ibstFltAutoNum,
  104. field_6_grfhic, field_7_unused3);
  105. }
  106. public String toString()
  107. {
  108. StringBuilder builder = new StringBuilder();
  109. builder.append("[LFO]\n");
  110. builder.append( " .lsid = " );
  111. builder.append(" ( ").append( field_1_lsid ).append( " )\n" );
  112. builder.append( " .unused1 = " );
  113. builder.append(" ( ").append( field_2_unused1 ).append( " )\n" );
  114. builder.append( " .unused2 = " );
  115. builder.append(" ( ").append( field_3_unused2 ).append( " )\n" );
  116. builder.append( " .clfolvl = " );
  117. builder.append(" ( ").append( field_4_clfolvl ).append( " )\n" );
  118. builder.append( " .ibstFltAutoNum = " );
  119. builder.append(" ( ").append( field_5_ibstFltAutoNum ).append( " )\n" );
  120. builder.append( " .grfhic = " );
  121. builder.append(" ( ").append( field_6_grfhic == null ? "null" : field_6_grfhic.toString().replaceAll( "\n", "\n " ) ).append( " )\n" );
  122. builder.append( " .unused3 = " );
  123. builder.append(" ( ").append( field_7_unused3 ).append( " )\n" );
  124. builder.append("[/LFO]");
  125. return builder.toString();
  126. }
  127. /**
  128. * A signed integer that specifies the list identifier of an LSTF. This LFO corresponds to the LSTF in PlfLst.rgLstf that has an lsid whose value is equal to this value..
  129. */
  130. @Internal
  131. public int getLsid()
  132. {
  133. return field_1_lsid;
  134. }
  135. /**
  136. * A signed integer that specifies the list identifier of an LSTF. This LFO corresponds to the LSTF in PlfLst.rgLstf that has an lsid whose value is equal to this value..
  137. */
  138. @Internal
  139. public void setLsid( int field_1_lsid )
  140. {
  141. this.field_1_lsid = field_1_lsid;
  142. }
  143. /**
  144. * This field MUST be ignored.
  145. */
  146. @Internal
  147. public int getUnused1()
  148. {
  149. return field_2_unused1;
  150. }
  151. /**
  152. * This field MUST be ignored.
  153. */
  154. @Internal
  155. public void setUnused1( int field_2_unused1 )
  156. {
  157. this.field_2_unused1 = field_2_unused1;
  158. }
  159. /**
  160. * This field MUST be ignored.
  161. */
  162. @Internal
  163. public int getUnused2()
  164. {
  165. return field_3_unused2;
  166. }
  167. /**
  168. * This field MUST be ignored.
  169. */
  170. @Internal
  171. public void setUnused2( int field_3_unused2 )
  172. {
  173. this.field_3_unused2 = field_3_unused2;
  174. }
  175. /**
  176. * An unsigned integer that specifies the field that this LFO represents..
  177. */
  178. @Internal
  179. public byte getClfolvl()
  180. {
  181. return field_4_clfolvl;
  182. }
  183. /**
  184. * An unsigned integer that specifies the field that this LFO represents..
  185. */
  186. @Internal
  187. public void setClfolvl( byte field_4_clfolvl )
  188. {
  189. this.field_4_clfolvl = field_4_clfolvl;
  190. }
  191. /**
  192. * Used for AUTONUM field emulation.
  193. */
  194. @Internal
  195. public byte getIbstFltAutoNum()
  196. {
  197. return field_5_ibstFltAutoNum;
  198. }
  199. /**
  200. * Used for AUTONUM field emulation.
  201. */
  202. @Internal
  203. public void setIbstFltAutoNum( byte field_5_ibstFltAutoNum )
  204. {
  205. this.field_5_ibstFltAutoNum = field_5_ibstFltAutoNum;
  206. }
  207. /**
  208. * HTML compatibility flags.
  209. */
  210. @Internal
  211. public Grfhic getGrfhic()
  212. {
  213. return field_6_grfhic;
  214. }
  215. /**
  216. * HTML compatibility flags.
  217. */
  218. @Internal
  219. public void setGrfhic( Grfhic field_6_grfhic )
  220. {
  221. this.field_6_grfhic = field_6_grfhic;
  222. }
  223. /**
  224. * This field MUST be ignored.
  225. */
  226. @Internal
  227. public byte getUnused3()
  228. {
  229. return field_7_unused3;
  230. }
  231. /**
  232. * This field MUST be ignored.
  233. */
  234. @Internal
  235. public void setUnused3( byte field_7_unused3 )
  236. {
  237. this.field_7_unused3 = field_7_unused3;
  238. }
  239. } // END OF CLASS