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.

CalcModeRecord.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. * Tells the gui whether to calculate formulas automatically, manually or automatically except for tables.
  22. *
  23. * @version 2.0-pre
  24. * @see CalcCountRecord
  25. */
  26. public final class CalcModeRecord extends StandardRecord {
  27. public static final short sid = 0xD;
  28. /** manually calculate formulas (0) */
  29. public static final short MANUAL = 0;
  30. /** automatically calculate formulas (1) */
  31. public static final short AUTOMATIC = 1;
  32. /** automatically calculate formulas except for tables (-1) */
  33. public static final short AUTOMATIC_EXCEPT_TABLES = -1;
  34. private short field_1_calcmode;
  35. public CalcModeRecord() {}
  36. public CalcModeRecord(CalcModeRecord other) {
  37. super(other);
  38. field_1_calcmode = other.field_1_calcmode;
  39. }
  40. public CalcModeRecord(RecordInputStream in) {
  41. field_1_calcmode = in.readShort();
  42. }
  43. /**
  44. * set the calc mode flag for formulas
  45. *
  46. * @see #MANUAL
  47. * @see #AUTOMATIC
  48. * @see #AUTOMATIC_EXCEPT_TABLES
  49. *
  50. * @param calcmode one of the three flags above
  51. */
  52. public void setCalcMode(short calcmode)
  53. {
  54. field_1_calcmode = calcmode;
  55. }
  56. /**
  57. * get the calc mode flag for formulas
  58. *
  59. * @see #MANUAL
  60. * @see #AUTOMATIC
  61. * @see #AUTOMATIC_EXCEPT_TABLES
  62. *
  63. * @return calcmode one of the three flags above
  64. */
  65. public short getCalcMode()
  66. {
  67. return field_1_calcmode;
  68. }
  69. public void serialize(LittleEndianOutput out) {
  70. out.writeShort(getCalcMode());
  71. }
  72. protected int getDataSize() {
  73. return 2;
  74. }
  75. public short getSid()
  76. {
  77. return sid;
  78. }
  79. @Override
  80. public CalcModeRecord copy() {
  81. return new CalcModeRecord(this);
  82. }
  83. @Override
  84. public HSSFRecordTypes getGenericRecordType() {
  85. return HSSFRecordTypes.CALC_MODE;
  86. }
  87. @Override
  88. public Map<String, Supplier<?>> getGenericProperties() {
  89. return GenericRecordUtil.getGenericProperties(
  90. "calcMode", this::getCalcMode
  91. );
  92. }
  93. }