PageRenderTime 54ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

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

https://github.com/minstrelsy/SimpleAndroidDocView
Java | 182 lines | 109 code | 21 blank | 52 comment | 12 complexity | cff38231427191a9dd1411f318316301 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.hwpf.model.Colorref;
  17. import org.apache.poi.util.Internal;
  18. import org.apache.poi.util.LittleEndian;
  19. /**
  20. * The Shd structure specifies the colors and pattern that are used for background shading. <p>Class
  21. and
  22. fields descriptions are quoted from Word (.doc) Binary File Format by Microsoft Corporation
  23. * <p>
  24. * NOTE: This source is automatically generated please do not modify this file. Either subclass or
  25. * remove the record in src/types/definitions.
  26. * <p>
  27. * This class is internal. It content or properties may change without notice
  28. * due to changes in our knowledge of internal Microsoft Word binary structures.
  29. * @author Sergey Vladimirov; according to Word (.doc) Binary File Format by Microsoft Corporation.
  30. */
  31. @Internal
  32. public abstract class SHDAbstractType
  33. {
  34. protected Colorref field_1_cvFore;
  35. protected Colorref field_2_cvBack;
  36. protected int field_3_ipat;
  37. protected SHDAbstractType()
  38. {
  39. this.field_1_cvFore = new Colorref();
  40. this.field_2_cvBack = new Colorref();
  41. }
  42. protected void fillFields( byte[] data, int offset )
  43. {
  44. field_1_cvFore = new Colorref( data, 0x0 + offset );
  45. field_2_cvBack = new Colorref( data, 0x4 + offset );
  46. field_3_ipat = LittleEndian.getShort( data, 0x8 + offset );
  47. }
  48. public void serialize( byte[] data, int offset )
  49. {
  50. field_1_cvFore.serialize( data, 0x0 + offset );
  51. field_2_cvBack.serialize( data, 0x4 + offset );
  52. LittleEndian.putUShort( data, 0x8 + offset, field_3_ipat );
  53. }
  54. public byte[] serialize()
  55. {
  56. final byte[] result = new byte[ getSize() ];
  57. serialize( result, 0 );
  58. return result;
  59. }
  60. /**
  61. * Size of record
  62. */
  63. public static int getSize()
  64. {
  65. return 0 + 4 + 4 + 2;
  66. }
  67. @Override
  68. public boolean equals( Object obj )
  69. {
  70. if ( this == obj )
  71. return true;
  72. if ( obj == null )
  73. return false;
  74. if ( getClass() != obj.getClass() )
  75. return false;
  76. SHDAbstractType other = (SHDAbstractType) obj;
  77. if ( field_1_cvFore != other.field_1_cvFore )
  78. return false;
  79. if ( field_2_cvBack != other.field_2_cvBack )
  80. return false;
  81. if ( field_3_ipat != other.field_3_ipat )
  82. return false;
  83. return true;
  84. }
  85. @Override
  86. public int hashCode()
  87. {
  88. final int prime = 31;
  89. int result = 1;
  90. result = prime * result + field_1_cvFore.hashCode();
  91. result = prime * result + field_2_cvBack.hashCode();
  92. result = prime * result + field_3_ipat;
  93. return result;
  94. }
  95. public String toString()
  96. {
  97. StringBuilder builder = new StringBuilder();
  98. builder.append("[SHD]\n");
  99. builder.append(" .cvFore = ");
  100. builder.append(" (").append(getCvFore()).append(" )\n");
  101. builder.append(" .cvBack = ");
  102. builder.append(" (").append(getCvBack()).append(" )\n");
  103. builder.append(" .ipat = ");
  104. builder.append(" (").append(getIpat()).append(" )\n");
  105. builder.append("[/SHD]\n");
  106. return builder.toString();
  107. }
  108. /**
  109. * A COLORREF that specifies the foreground color of ipat.
  110. */
  111. @Internal
  112. public Colorref getCvFore()
  113. {
  114. return field_1_cvFore;
  115. }
  116. /**
  117. * A COLORREF that specifies the foreground color of ipat.
  118. */
  119. @Internal
  120. public void setCvFore( Colorref field_1_cvFore )
  121. {
  122. this.field_1_cvFore = field_1_cvFore;
  123. }
  124. /**
  125. * A COLORREF that specifies the background color of ipat.
  126. */
  127. @Internal
  128. public Colorref getCvBack()
  129. {
  130. return field_2_cvBack;
  131. }
  132. /**
  133. * A COLORREF that specifies the background color of ipat.
  134. */
  135. @Internal
  136. public void setCvBack( Colorref field_2_cvBack )
  137. {
  138. this.field_2_cvBack = field_2_cvBack;
  139. }
  140. /**
  141. * An Ipat that specifies the pattern used for shading.
  142. */
  143. @Internal
  144. public int getIpat()
  145. {
  146. return field_3_ipat;
  147. }
  148. /**
  149. * An Ipat that specifies the pattern used for shading.
  150. */
  151. @Internal
  152. public void setIpat( int field_3_ipat )
  153. {
  154. this.field_3_ipat = field_3_ipat;
  155. }
  156. } // END OF CLASS