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.

ChartEndObjectRecord.java 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. * ENDOBJECT - Chart Future Record Type End Object (0x0855)<br/>
  22. *
  23. * @author Patrick Cheng
  24. */
  25. public final class ChartEndObjectRecord extends StandardRecord {
  26. public static final short sid = 0x0855;
  27. private short rt;
  28. private short grbitFrt;
  29. private short iObjectKind;
  30. private byte[] reserved;
  31. public ChartEndObjectRecord(RecordInputStream in) {
  32. rt = in.readShort();
  33. grbitFrt = in.readShort();
  34. iObjectKind = in.readShort();
  35. // The spec says that there should be 6 bytes at the
  36. // end, which must be there and must be zero
  37. // However, sometimes Excel forgets them...
  38. reserved = new byte[6];
  39. if(in.available() == 0) {
  40. // They've gone missing...
  41. } else {
  42. // Read the reserved bytes
  43. in.readFully(reserved);
  44. }
  45. }
  46. @Override
  47. protected int getDataSize() {
  48. return 2 + 2 + 2 + 6;
  49. }
  50. @Override
  51. public short getSid() {
  52. return sid;
  53. }
  54. @Override
  55. public void serialize(LittleEndianOutput out) {
  56. out.writeShort(rt);
  57. out.writeShort(grbitFrt);
  58. out.writeShort(iObjectKind);
  59. // 6 bytes unused
  60. out.write(reserved);
  61. }
  62. @Override
  63. public String toString() {
  64. StringBuffer buffer = new StringBuffer();
  65. buffer.append("[ENDOBJECT]\n");
  66. buffer.append(" .rt =").append(HexDump.shortToHex(rt)).append('\n');
  67. buffer.append(" .grbitFrt =").append(HexDump.shortToHex(grbitFrt)).append('\n');
  68. buffer.append(" .iObjectKind=").append(HexDump.shortToHex(iObjectKind)).append('\n');
  69. buffer.append(" .reserved =").append(HexDump.toHex(reserved)).append('\n');
  70. buffer.append("[/ENDOBJECT]\n");
  71. return buffer.toString();
  72. }
  73. }