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.

MMSRecord.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. * defines how many add menu and del menu options are stored in the file.
  22. * Should always be set to 0 for HSSF workbooks.
  23. *
  24. * @version 2.0-pre
  25. */
  26. public final class MMSRecord extends StandardRecord {
  27. public static final short sid = 0xC1;
  28. private byte field_1_addMenuCount;
  29. private byte field_2_delMenuCount;
  30. public MMSRecord() {}
  31. public MMSRecord(MMSRecord other) {
  32. field_1_addMenuCount = other.field_1_addMenuCount;
  33. field_2_delMenuCount = other.field_2_delMenuCount;
  34. }
  35. public MMSRecord(RecordInputStream in) {
  36. if (in.remaining()==0) {
  37. return;
  38. }
  39. field_1_addMenuCount = in.readByte();
  40. field_2_delMenuCount = in.readByte();
  41. }
  42. /**
  43. * set number of add menu options (set to 0)
  44. * @param am number of add menu options
  45. */
  46. public void setAddMenuCount(byte am)
  47. {
  48. field_1_addMenuCount = am;
  49. }
  50. /**
  51. * set number of del menu options (set to 0)
  52. * @param dm number of del menu options
  53. */
  54. public void setDelMenuCount(byte dm)
  55. {
  56. field_2_delMenuCount = dm;
  57. }
  58. /**
  59. * get number of add menu options (should be 0)
  60. * @return number of add menu options
  61. */
  62. public byte getAddMenuCount()
  63. {
  64. return field_1_addMenuCount;
  65. }
  66. /**
  67. * get number of add del options (should be 0)
  68. * @return number of add menu options
  69. */
  70. public byte getDelMenuCount()
  71. {
  72. return field_2_delMenuCount;
  73. }
  74. public void serialize(LittleEndianOutput out) {
  75. out.writeByte(getAddMenuCount());
  76. out.writeByte(getDelMenuCount());
  77. }
  78. protected int getDataSize() {
  79. return 2;
  80. }
  81. public short getSid()
  82. {
  83. return sid;
  84. }
  85. @Override
  86. public MMSRecord copy() {
  87. return new MMSRecord(this);
  88. }
  89. @Override
  90. public HSSFRecordTypes getGenericRecordType() {
  91. return HSSFRecordTypes.MMS;
  92. }
  93. @Override
  94. public Map<String, Supplier<?>> getGenericProperties() {
  95. return GenericRecordUtil.getGenericProperties(
  96. "addMenuCount", this::getAddMenuCount,
  97. "delMenuCount", this::getDelMenuCount
  98. );
  99. }
  100. }