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.

TLPAbstractType.java 7.3KB

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 org.apache.poi.util.BitField;
  17. import org.apache.poi.util.Internal;
  18. import org.apache.poi.util.LittleEndian;
  19. /**
  20. * Table Autoformat Look sPecifier (TLP).
  21. */
  22. @SuppressWarnings("unused")
  23. @Internal
  24. public abstract class TLPAbstractType {
  25. private static final BitField fBorders = new BitField( 0x0001 );
  26. private static final BitField fShading = new BitField( 0x0002 );
  27. private static final BitField fFont = new BitField( 0x0004 );
  28. private static final BitField fColor = new BitField( 0x0008 );
  29. private static final BitField fBestFit = new BitField( 0x0010 );
  30. private static final BitField fHdrRows = new BitField( 0x0020 );
  31. private static final BitField fLastRow = new BitField( 0x0040 );
  32. protected short field_1_itl;
  33. protected byte field_2_tlp_flags;
  34. public TLPAbstractType() {}
  35. public TLPAbstractType(TLPAbstractType other) {
  36. field_1_itl = other.field_1_itl;
  37. field_2_tlp_flags = other.field_2_tlp_flags;
  38. }
  39. protected void fillFields( byte[] data, int offset )
  40. {
  41. field_1_itl = LittleEndian.getShort( data, 0x0 + offset );
  42. field_2_tlp_flags = data[0x2 + offset];
  43. }
  44. public void serialize( byte[] data, int offset )
  45. {
  46. LittleEndian.putShort( data, 0x0 + offset, field_1_itl );
  47. data[0x2 + offset] = field_2_tlp_flags;
  48. }
  49. public String toString() {
  50. return
  51. "[TLP]\n" +
  52. " .itl = (" + getItl() + " )\n" +
  53. " .tlp_flags = (" + getTlp_flags() + " )\n" +
  54. " .fBorders = " + isFBorders() + "\n" +
  55. " .fShading = " + isFShading() + "\n" +
  56. " .fFont = " + isFFont() + "\n" +
  57. " .fColor = " + isFColor() + "\n" +
  58. " .fBestFit = " + isFBestFit() + "\n" +
  59. " .fHdrRows = " + isFHdrRows() + "\n" +
  60. " .fLastRow = " + isFLastRow() + "\n" +
  61. "[/TLP]\n";
  62. }
  63. /**
  64. * Size of record (exluding 4 byte header)
  65. */
  66. public int getSize()
  67. {
  68. return 4 + +2 + 1;
  69. }
  70. /**
  71. * Get the itl field for the TLP record.
  72. */
  73. public short getItl()
  74. {
  75. return field_1_itl;
  76. }
  77. /**
  78. * Set the itl field for the TLP record.
  79. */
  80. public void setItl( short field_1_itl )
  81. {
  82. this.field_1_itl = field_1_itl;
  83. }
  84. /**
  85. * Get the tlp_flags field for the TLP record.
  86. */
  87. public byte getTlp_flags()
  88. {
  89. return field_2_tlp_flags;
  90. }
  91. /**
  92. * Set the tlp_flags field for the TLP record.
  93. */
  94. public void setTlp_flags( byte field_2_tlp_flags )
  95. {
  96. this.field_2_tlp_flags = field_2_tlp_flags;
  97. }
  98. /**
  99. * Sets the fBorders field value. When == 1, use the border properties from
  100. * the selected table look
  101. */
  102. public void setFBorders( boolean value )
  103. {
  104. field_2_tlp_flags = (byte) fBorders.setBoolean( field_2_tlp_flags,
  105. value );
  106. }
  107. /**
  108. * When == 1, use the border properties from the selected table look
  109. *
  110. * @return the fBorders field value.
  111. */
  112. public boolean isFBorders()
  113. {
  114. return fBorders.isSet( field_2_tlp_flags );
  115. }
  116. /**
  117. * Sets the fShading field value. When == 1, use the shading properties from
  118. * the selected table look
  119. */
  120. public void setFShading( boolean value )
  121. {
  122. field_2_tlp_flags = (byte) fShading.setBoolean( field_2_tlp_flags,
  123. value );
  124. }
  125. /**
  126. * When == 1, use the shading properties from the selected table look
  127. *
  128. * @return the fShading field value.
  129. */
  130. public boolean isFShading()
  131. {
  132. return fShading.isSet( field_2_tlp_flags );
  133. }
  134. /**
  135. * Sets the fFont field value. When == 1, use the font from the selected
  136. * table look
  137. */
  138. public void setFFont( boolean value )
  139. {
  140. field_2_tlp_flags = (byte) fFont.setBoolean( field_2_tlp_flags, value );
  141. }
  142. /**
  143. * When == 1, use the font from the selected table look
  144. *
  145. * @return the fFont field value.
  146. */
  147. public boolean isFFont()
  148. {
  149. return fFont.isSet( field_2_tlp_flags );
  150. }
  151. /**
  152. * Sets the fColor field value. When == 1, use the color from the selected
  153. * table look
  154. */
  155. public void setFColor( boolean value )
  156. {
  157. field_2_tlp_flags = (byte) fColor.setBoolean( field_2_tlp_flags, value );
  158. }
  159. /**
  160. * When == 1, use the color from the selected table look
  161. *
  162. * @return the fColor field value.
  163. */
  164. public boolean isFColor()
  165. {
  166. return fColor.isSet( field_2_tlp_flags );
  167. }
  168. /**
  169. * Sets the fBestFit field value. When == 1, do best fit from the selected
  170. * table look
  171. */
  172. public void setFBestFit( boolean value )
  173. {
  174. field_2_tlp_flags = (byte) fBestFit.setBoolean( field_2_tlp_flags,
  175. value );
  176. }
  177. /**
  178. * When == 1, do best fit from the selected table look
  179. *
  180. * @return the fBestFit field value.
  181. */
  182. public boolean isFBestFit()
  183. {
  184. return fBestFit.isSet( field_2_tlp_flags );
  185. }
  186. /**
  187. * Sets the fHdrRows field value. When == 1, apply properties from the
  188. * selected table look to the header rows in the table
  189. */
  190. public void setFHdrRows( boolean value )
  191. {
  192. field_2_tlp_flags = (byte) fHdrRows.setBoolean( field_2_tlp_flags,
  193. value );
  194. }
  195. /**
  196. * When == 1, apply properties from the selected table look to the header
  197. * rows in the table
  198. *
  199. * @return the fHdrRows field value.
  200. */
  201. public boolean isFHdrRows()
  202. {
  203. return fHdrRows.isSet( field_2_tlp_flags );
  204. }
  205. /**
  206. * Sets the fLastRow field value. When == 1, apply properties from the
  207. * selected table look to the last row in the table
  208. */
  209. public void setFLastRow( boolean value )
  210. {
  211. field_2_tlp_flags = (byte) fLastRow.setBoolean( field_2_tlp_flags,
  212. value );
  213. }
  214. /**
  215. * When == 1, apply properties from the selected table look to the last row
  216. * in the table
  217. *
  218. * @return the fLastRow field value.
  219. */
  220. public boolean isFLastRow()
  221. {
  222. return fLastRow.isSet( field_2_tlp_flags );
  223. }
  224. } // END OF CLASS