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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 org.apache.poi.util.LittleEndianOutput;
  17. /**
  18. * Title: Calc Mode Record<P>
  19. * Description: Tells the gui whether to calculate formulas
  20. * automatically, manually or automatically
  21. * except for tables.<P>
  22. * REFERENCE: PG 292 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
  23. * @author Andrew C. Oliver (acoliver at apache dot org)
  24. * @author Jason Height (jheight at chariot dot net dot au)
  25. * @version 2.0-pre
  26. * @see org.apache.poi.hssf.record.CalcCountRecord
  27. */
  28. public final class CalcModeRecord
  29. extends StandardRecord
  30. {
  31. public final static short sid = 0xD;
  32. /**
  33. * manually calculate formulas (0)
  34. */
  35. public final static short MANUAL = 0;
  36. /**
  37. * automatically calculate formulas (1)
  38. */
  39. public final static short AUTOMATIC = 1;
  40. /**
  41. * automatically calculate formulas except for tables (-1)
  42. */
  43. public final static short AUTOMATIC_EXCEPT_TABLES = -1;
  44. private short field_1_calcmode;
  45. public CalcModeRecord()
  46. {
  47. }
  48. public CalcModeRecord(RecordInputStream in)
  49. {
  50. field_1_calcmode = in.readShort();
  51. }
  52. /**
  53. * set the calc mode flag for formulas
  54. *
  55. * @see #MANUAL
  56. * @see #AUTOMATIC
  57. * @see #AUTOMATIC_EXCEPT_TABLES
  58. *
  59. * @param calcmode one of the three flags above
  60. */
  61. public void setCalcMode(short calcmode)
  62. {
  63. field_1_calcmode = calcmode;
  64. }
  65. /**
  66. * get the calc mode flag for formulas
  67. *
  68. * @see #MANUAL
  69. * @see #AUTOMATIC
  70. * @see #AUTOMATIC_EXCEPT_TABLES
  71. *
  72. * @return calcmode one of the three flags above
  73. */
  74. public short getCalcMode()
  75. {
  76. return field_1_calcmode;
  77. }
  78. public String toString()
  79. {
  80. StringBuffer buffer = new StringBuffer();
  81. buffer.append("[CALCMODE]\n");
  82. buffer.append(" .calcmode = ")
  83. .append(Integer.toHexString(getCalcMode())).append("\n");
  84. buffer.append("[/CALCMODE]\n");
  85. return buffer.toString();
  86. }
  87. public void serialize(LittleEndianOutput out) {
  88. out.writeShort(getCalcMode());
  89. }
  90. protected int getDataSize() {
  91. return 2;
  92. }
  93. public short getSid()
  94. {
  95. return sid;
  96. }
  97. public Object clone() {
  98. CalcModeRecord rec = new CalcModeRecord();
  99. rec.field_1_calcmode = field_1_calcmode;
  100. return rec;
  101. }
  102. }