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.

SCLRecord.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. * Specifies the window's zoom magnification.<p>
  22. * If this record isn't present then the windows zoom is 100%. see p384 Excel Dev Kit
  23. */
  24. public final class SCLRecord extends StandardRecord {
  25. public static final short sid = 0x00A0;
  26. private short field_1_numerator;
  27. private short field_2_denominator;
  28. public SCLRecord() {}
  29. public SCLRecord(SCLRecord other) {
  30. super(other);
  31. field_1_numerator = other.field_1_numerator;
  32. field_2_denominator = other.field_2_denominator;
  33. }
  34. public SCLRecord(RecordInputStream in) {
  35. field_1_numerator = in.readShort();
  36. field_2_denominator = in.readShort();
  37. }
  38. @Override
  39. public void serialize(LittleEndianOutput out) {
  40. out.writeShort(field_1_numerator);
  41. out.writeShort(field_2_denominator);
  42. }
  43. @Override
  44. protected int getDataSize() {
  45. return 2 + 2;
  46. }
  47. @Override
  48. public short getSid()
  49. {
  50. return sid;
  51. }
  52. @Override
  53. public SCLRecord copy() {
  54. return new SCLRecord(this);
  55. }
  56. /**
  57. * Get the numerator field for the SCL record.
  58. *
  59. * @return the numerator
  60. */
  61. public short getNumerator()
  62. {
  63. return field_1_numerator;
  64. }
  65. /**
  66. * Set the numerator field for the SCL record.
  67. *
  68. * @param field_1_numerator the numerator
  69. */
  70. public void setNumerator(short field_1_numerator)
  71. {
  72. this.field_1_numerator = field_1_numerator;
  73. }
  74. /**
  75. * Get the denominator field for the SCL record.
  76. *
  77. * @return the denominator
  78. */
  79. public short getDenominator()
  80. {
  81. return field_2_denominator;
  82. }
  83. /**
  84. * Set the denominator field for the SCL record.
  85. *
  86. * @param field_2_denominator the denominator
  87. */
  88. public void setDenominator(short field_2_denominator)
  89. {
  90. this.field_2_denominator = field_2_denominator;
  91. }
  92. @Override
  93. public HSSFRecordTypes getGenericRecordType() {
  94. return HSSFRecordTypes.SCL;
  95. }
  96. @Override
  97. public Map<String, Supplier<?>> getGenericProperties() {
  98. return GenericRecordUtil.getGenericProperties(
  99. "numerator", this::getNumerator,
  100. "denominator", this::getDenominator
  101. );
  102. }
  103. }