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.

ChartEndBlockRecord.java 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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.hssf.record.chart;
  16. import org.apache.poi.hssf.record.RecordInputStream;
  17. import org.apache.poi.hssf.record.StandardRecord;
  18. import org.apache.poi.util.HexDump;
  19. import org.apache.poi.util.LittleEndianOutput;
  20. /**
  21. * ENDBLOCK - Chart Future Record Type End Block (0x0853)<br/>
  22. *
  23. * @author Patrick Cheng
  24. */
  25. public final class ChartEndBlockRecord extends StandardRecord {
  26. public static final short sid = 0x0853;
  27. private short rt;
  28. private short grbitFrt;
  29. private short iObjectKind;
  30. private byte[] unused;
  31. public ChartEndBlockRecord() {
  32. }
  33. public ChartEndBlockRecord(RecordInputStream in) {
  34. rt = in.readShort();
  35. grbitFrt = in.readShort();
  36. iObjectKind = in.readShort();
  37. // Often, but not always has 6 unused bytes at the end
  38. if(in.available() == 0) {
  39. unused = new byte[0];
  40. } else {
  41. unused = new byte[6];
  42. in.readFully(unused);
  43. }
  44. }
  45. @Override
  46. protected int getDataSize() {
  47. return 2 + 2 + 2 + unused.length;
  48. }
  49. @Override
  50. public short getSid() {
  51. return sid;
  52. }
  53. @Override
  54. public void serialize(LittleEndianOutput out) {
  55. out.writeShort(rt);
  56. out.writeShort(grbitFrt);
  57. out.writeShort(iObjectKind);
  58. // 6 bytes unused
  59. out.write(unused);
  60. }
  61. @Override
  62. public String toString() {
  63. StringBuffer buffer = new StringBuffer();
  64. buffer.append("[ENDBLOCK]\n");
  65. buffer.append(" .rt =").append(HexDump.shortToHex(rt)).append('\n');
  66. buffer.append(" .grbitFrt =").append(HexDump.shortToHex(grbitFrt)).append('\n');
  67. buffer.append(" .iObjectKind=").append(HexDump.shortToHex(iObjectKind)).append('\n');
  68. buffer.append(" .unused =").append(HexDump.toHex(unused)).append('\n');
  69. buffer.append("[/ENDBLOCK]\n");
  70. return buffer.toString();
  71. }
  72. @Override
  73. public ChartEndBlockRecord clone() {
  74. ChartEndBlockRecord record = new ChartEndBlockRecord();
  75. record.rt = rt ;
  76. record.grbitFrt = grbitFrt ;
  77. record.iObjectKind = iObjectKind ;
  78. record.unused = unused.clone() ;
  79. return record;
  80. }
  81. }