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.

CRNCountRecord.java 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.util.GenericRecordUtil;
  19. import org.apache.poi.util.LittleEndianOutput;
  20. /**
  21. * XCT - CRN Count
  22. */
  23. public final class CRNCountRecord extends StandardRecord {
  24. public static final short sid = 0x59;
  25. private static final short DATA_SIZE = 4;
  26. private int field_1_number_crn_records;
  27. private int field_2_sheet_table_index;
  28. public CRNCountRecord(CRNCountRecord other) {
  29. super(other);
  30. field_1_number_crn_records = other.field_1_number_crn_records;
  31. field_2_sheet_table_index = other.field_2_sheet_table_index;
  32. }
  33. public CRNCountRecord(RecordInputStream in) {
  34. field_1_number_crn_records = in.readShort();
  35. if(field_1_number_crn_records < 0) {
  36. // TODO - seems like the sign bit of this field might be used for some other purpose
  37. // see example file for test case "TestBugs.test19599()"
  38. field_1_number_crn_records = (short)-field_1_number_crn_records;
  39. }
  40. field_2_sheet_table_index = in.readShort();
  41. }
  42. public int getNumberOfCRNs() {
  43. return field_1_number_crn_records;
  44. }
  45. public void serialize(LittleEndianOutput out) {
  46. out.writeShort((short)field_1_number_crn_records);
  47. out.writeShort((short)field_2_sheet_table_index);
  48. }
  49. protected int getDataSize() {
  50. return DATA_SIZE;
  51. }
  52. /**
  53. * return the non static version of the id for this record.
  54. */
  55. public short getSid() {
  56. return sid;
  57. }
  58. @Override
  59. public CRNCountRecord copy() {
  60. return new CRNCountRecord(this);
  61. }
  62. @Override
  63. public HSSFRecordTypes getGenericRecordType() {
  64. return HSSFRecordTypes.CRN_COUNT;
  65. }
  66. @Override
  67. public Map<String, Supplier<?>> getGenericProperties() {
  68. return GenericRecordUtil.getGenericProperties(
  69. "numberOfCRNs", this::getNumberOfCRNs,
  70. "sheetTableIndex", () -> field_2_sheet_table_index
  71. );
  72. }
  73. }