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.

GroupMarkerSubRecord.java 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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;
  16. import java.util.Map;
  17. import java.util.function.Supplier;
  18. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  19. import org.apache.poi.util.GenericRecordUtil;
  20. import org.apache.poi.util.IOUtils;
  21. import org.apache.poi.util.LittleEndianInput;
  22. import org.apache.poi.util.LittleEndianOutput;
  23. /**
  24. * ftGmo (0x0006)<p>
  25. * The group marker record is used as a position holder for groups.
  26. */
  27. public final class GroupMarkerSubRecord extends SubRecord {
  28. public static final short sid = 0x0006;
  29. private static final byte[] EMPTY_BYTE_ARRAY = { };
  30. // would really love to know what goes in here.
  31. private byte[] reserved;
  32. public GroupMarkerSubRecord() {
  33. reserved = EMPTY_BYTE_ARRAY;
  34. }
  35. public GroupMarkerSubRecord(GroupMarkerSubRecord other) {
  36. super(other);
  37. reserved = other.reserved.clone();
  38. }
  39. public GroupMarkerSubRecord(LittleEndianInput in, int size) {
  40. this(in,size,-1);
  41. }
  42. GroupMarkerSubRecord(LittleEndianInput in, int size, int cmoOt) {
  43. byte[] buf = IOUtils.safelyAllocate(size, HSSFWorkbook.getMaxRecordLength());
  44. in.readFully(buf);
  45. reserved = buf;
  46. }
  47. public void serialize(LittleEndianOutput out) {
  48. out.writeShort(sid);
  49. out.writeShort(reserved.length);
  50. out.write(reserved);
  51. }
  52. protected int getDataSize() {
  53. return reserved.length;
  54. }
  55. public short getSid()
  56. {
  57. return sid;
  58. }
  59. @Override
  60. public GroupMarkerSubRecord copy() {
  61. return new GroupMarkerSubRecord(this);
  62. }
  63. @Override
  64. public SubRecordTypes getGenericRecordType() {
  65. return SubRecordTypes.GROUP_MARKER;
  66. }
  67. @Override
  68. public Map<String, Supplier<?>> getGenericProperties() {
  69. return GenericRecordUtil.getGenericProperties("reserved", () -> reserved);
  70. }
  71. }