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.

StshifAbstractType.java 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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 Stshif structure specifies general stylesheet information.
  21. */
  22. @Internal
  23. public abstract class StshifAbstractType
  24. {
  25. protected int field_1_cstd;
  26. protected int field_2_cbSTDBaseInFile;
  27. protected int field_3_info3;
  28. /**/private static final BitField fHasOriginalStyle = new BitField(0x0001);
  29. /**/private static final BitField fReserved = new BitField(0xFFFE);
  30. protected int field_4_stiMaxWhenSaved;
  31. protected int field_5_istdMaxFixedWhenSaved;
  32. protected int field_6_nVerBuiltInNamesWhenSaved;
  33. protected short field_7_ftcAsci;
  34. protected short field_8_ftcFE;
  35. protected short field_9_ftcOther;
  36. protected StshifAbstractType()
  37. {
  38. }
  39. protected void fillFields( byte[] data, int offset )
  40. {
  41. field_1_cstd = LittleEndian.getShort(data, 0x0 + offset);
  42. field_2_cbSTDBaseInFile = LittleEndian.getShort(data, 0x2 + offset);
  43. field_3_info3 = LittleEndian.getShort(data, 0x4 + offset);
  44. field_4_stiMaxWhenSaved = LittleEndian.getShort(data, 0x6 + offset);
  45. field_5_istdMaxFixedWhenSaved = LittleEndian.getShort(data, 0x8 + offset);
  46. field_6_nVerBuiltInNamesWhenSaved = LittleEndian.getShort(data, 0xa + offset);
  47. field_7_ftcAsci = LittleEndian.getShort(data, 0xc + offset);
  48. field_8_ftcFE = LittleEndian.getShort(data, 0xe + offset);
  49. field_9_ftcOther = LittleEndian.getShort(data, 0x10 + offset);
  50. }
  51. public void serialize( byte[] data, int offset )
  52. {
  53. LittleEndian.putUShort(data, 0x0 + offset, field_1_cstd);
  54. LittleEndian.putUShort(data, 0x2 + offset, field_2_cbSTDBaseInFile);
  55. LittleEndian.putUShort(data, 0x4 + offset, field_3_info3);
  56. LittleEndian.putUShort(data, 0x6 + offset, field_4_stiMaxWhenSaved);
  57. LittleEndian.putUShort(data, 0x8 + offset, field_5_istdMaxFixedWhenSaved);
  58. LittleEndian.putUShort(data, 0xa + offset, field_6_nVerBuiltInNamesWhenSaved);
  59. LittleEndian.putShort(data, 0xc + offset, field_7_ftcAsci);
  60. LittleEndian.putShort(data, 0xe + offset, field_8_ftcFE);
  61. LittleEndian.putShort(data, 0x10 + offset, field_9_ftcOther);
  62. }
  63. /**
  64. * Size of record
  65. */
  66. public static int getSize()
  67. {
  68. return 0 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2;
  69. }
  70. public String toString()
  71. {
  72. StringBuilder builder = new StringBuilder();
  73. builder.append("[Stshif]\n");
  74. builder.append(" .cstd = ");
  75. builder.append(" (").append(getCstd()).append(" )\n");
  76. builder.append(" .cbSTDBaseInFile = ");
  77. builder.append(" (").append(getCbSTDBaseInFile()).append(" )\n");
  78. builder.append(" .info3 = ");
  79. builder.append(" (").append(getInfo3()).append(" )\n");
  80. builder.append(" .fHasOriginalStyle = ").append(isFHasOriginalStyle()).append('\n');
  81. builder.append(" .fReserved = ").append(getFReserved()).append('\n');
  82. builder.append(" .stiMaxWhenSaved = ");
  83. builder.append(" (").append(getStiMaxWhenSaved()).append(" )\n");
  84. builder.append(" .istdMaxFixedWhenSaved = ");
  85. builder.append(" (").append(getIstdMaxFixedWhenSaved()).append(" )\n");
  86. builder.append(" .nVerBuiltInNamesWhenSaved = ");
  87. builder.append(" (").append(getNVerBuiltInNamesWhenSaved()).append(" )\n");
  88. builder.append(" .ftcAsci = ");
  89. builder.append(" (").append(getFtcAsci()).append(" )\n");
  90. builder.append(" .ftcFE = ");
  91. builder.append(" (").append(getFtcFE()).append(" )\n");
  92. builder.append(" .ftcOther = ");
  93. builder.append(" (").append(getFtcOther()).append(" )\n");
  94. builder.append("[/Stshif]\n");
  95. return builder.toString();
  96. }
  97. /**
  98. * An unsigned integer that specifies the count of elements in STSH.rglpstd. This value MUST be equal to or greater than 0x000F, and MUST be less than 0x0FFE.
  99. */
  100. @Internal
  101. public int getCstd()
  102. {
  103. return field_1_cstd;
  104. }
  105. /**
  106. * An unsigned integer that specifies the count of elements in STSH.rglpstd. This value MUST be equal to or greater than 0x000F, and MUST be less than 0x0FFE.
  107. */
  108. @Internal
  109. public void setCstd( int field_1_cstd )
  110. {
  111. this.field_1_cstd = field_1_cstd;
  112. }
  113. /**
  114. * An unsigned integer that specifies the size, in bytes, of the Stdf structure. The Stdf structure contains an StdfBase structure that is followed by a StdfPost2000OrNone structure which contains an optional StdfPost2000 structure. This value MUST be 0x000A when the Stdf structure does not contain an StdfPost2000 structure and MUST be 0x0012 when the Stdf structure does contain an StdfPost2000 structure..
  115. */
  116. @Internal
  117. public int getCbSTDBaseInFile()
  118. {
  119. return field_2_cbSTDBaseInFile;
  120. }
  121. /**
  122. * An unsigned integer that specifies the size, in bytes, of the Stdf structure. The Stdf structure contains an StdfBase structure that is followed by a StdfPost2000OrNone structure which contains an optional StdfPost2000 structure. This value MUST be 0x000A when the Stdf structure does not contain an StdfPost2000 structure and MUST be 0x0012 when the Stdf structure does contain an StdfPost2000 structure..
  123. */
  124. @Internal
  125. public void setCbSTDBaseInFile( int field_2_cbSTDBaseInFile )
  126. {
  127. this.field_2_cbSTDBaseInFile = field_2_cbSTDBaseInFile;
  128. }
  129. /**
  130. * Get the info3 field for the Stshif record.
  131. */
  132. @Internal
  133. public int getInfo3()
  134. {
  135. return field_3_info3;
  136. }
  137. /**
  138. * Set the info3 field for the Stshif record.
  139. */
  140. @Internal
  141. public void setInfo3( int field_3_info3 )
  142. {
  143. this.field_3_info3 = field_3_info3;
  144. }
  145. /**
  146. * An unsigned integer that specifies a value that is 1 larger than the largest StdfBase.sti index of any application-defined style. This SHOULD be equal to the largest sti index that is defined in the application, incremented by 1.
  147. */
  148. @Internal
  149. public int getStiMaxWhenSaved()
  150. {
  151. return field_4_stiMaxWhenSaved;
  152. }
  153. /**
  154. * An unsigned integer that specifies a value that is 1 larger than the largest StdfBase.sti index of any application-defined style. This SHOULD be equal to the largest sti index that is defined in the application, incremented by 1.
  155. */
  156. @Internal
  157. public void setStiMaxWhenSaved( int field_4_stiMaxWhenSaved )
  158. {
  159. this.field_4_stiMaxWhenSaved = field_4_stiMaxWhenSaved;
  160. }
  161. /**
  162. * An unsigned integer that specifies the count of elements at the start of STSH.rglpstd that are reserved for fixed-index application-defined styles. This value MUST be 0x000F.
  163. */
  164. @Internal
  165. public int getIstdMaxFixedWhenSaved()
  166. {
  167. return field_5_istdMaxFixedWhenSaved;
  168. }
  169. /**
  170. * An unsigned integer that specifies the count of elements at the start of STSH.rglpstd that are reserved for fixed-index application-defined styles. This value MUST be 0x000F.
  171. */
  172. @Internal
  173. public void setIstdMaxFixedWhenSaved( int field_5_istdMaxFixedWhenSaved )
  174. {
  175. this.field_5_istdMaxFixedWhenSaved = field_5_istdMaxFixedWhenSaved;
  176. }
  177. /**
  178. * An unsigned integer that specifies the version number of the style names as defined by the application that writes the file.
  179. */
  180. @Internal
  181. public int getNVerBuiltInNamesWhenSaved()
  182. {
  183. return field_6_nVerBuiltInNamesWhenSaved;
  184. }
  185. /**
  186. * An unsigned integer that specifies the version number of the style names as defined by the application that writes the file.
  187. */
  188. @Internal
  189. public void setNVerBuiltInNamesWhenSaved( int field_6_nVerBuiltInNamesWhenSaved )
  190. {
  191. this.field_6_nVerBuiltInNamesWhenSaved = field_6_nVerBuiltInNamesWhenSaved;
  192. }
  193. /**
  194. * A signed integer that specifies an operand value for the sprmCRgFtc0 for default document formatting.
  195. */
  196. @Internal
  197. public short getFtcAsci()
  198. {
  199. return field_7_ftcAsci;
  200. }
  201. /**
  202. * A signed integer that specifies an operand value for the sprmCRgFtc0 for default document formatting.
  203. */
  204. @Internal
  205. public void setFtcAsci( short field_7_ftcAsci )
  206. {
  207. this.field_7_ftcAsci = field_7_ftcAsci;
  208. }
  209. /**
  210. * A signed integer that specifies an operand value for the sprmCRgFtc1 for default document formatting, as defined in the section Determining Formatting Properties.
  211. */
  212. @Internal
  213. public short getFtcFE()
  214. {
  215. return field_8_ftcFE;
  216. }
  217. /**
  218. * A signed integer that specifies an operand value for the sprmCRgFtc1 for default document formatting, as defined in the section Determining Formatting Properties.
  219. */
  220. @Internal
  221. public void setFtcFE( short field_8_ftcFE )
  222. {
  223. this.field_8_ftcFE = field_8_ftcFE;
  224. }
  225. /**
  226. * A signed integer that specifies an operand value for the sprmCRgFtc2 for default document formatting, as defined in the section Determining Formatting Properties.
  227. */
  228. @Internal
  229. public short getFtcOther()
  230. {
  231. return field_9_ftcOther;
  232. }
  233. /**
  234. * A signed integer that specifies an operand value for the sprmCRgFtc2 for default document formatting, as defined in the section Determining Formatting Properties.
  235. */
  236. @Internal
  237. public void setFtcOther( short field_9_ftcOther )
  238. {
  239. this.field_9_ftcOther = field_9_ftcOther;
  240. }
  241. /**
  242. * Sets the fHasOriginalStyle field value.
  243. * This value MUST be 1 and MUST be ignored
  244. */
  245. @Internal
  246. public void setFHasOriginalStyle( boolean value )
  247. {
  248. field_3_info3 = fHasOriginalStyle.setBoolean(field_3_info3, value);
  249. }
  250. /**
  251. * This value MUST be 1 and MUST be ignored
  252. * @return the fHasOriginalStyle field value.
  253. */
  254. @Internal
  255. public boolean isFHasOriginalStyle()
  256. {
  257. return fHasOriginalStyle.isSet(field_3_info3);
  258. }
  259. /**
  260. * Sets the fReserved field value.
  261. * This value MUST be zero and MUST be ignored
  262. */
  263. @Internal
  264. public void setFReserved( short value )
  265. {
  266. field_3_info3 = fReserved.setValue(field_3_info3, value);
  267. }
  268. /**
  269. * This value MUST be zero and MUST be ignored
  270. * @return the fReserved field value.
  271. */
  272. @Internal
  273. public short getFReserved()
  274. {
  275. return ( short )fReserved.getValue(field_3_info3);
  276. }
  277. } // END OF CLASS