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.

DefaultRowHeightRecord.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. * Row height for rows with undefined or not explicitly defined heights.
  22. *
  23. * @version 2.0-pre
  24. */
  25. public final class DefaultRowHeightRecord extends StandardRecord {
  26. public static final short sid = 0x225;
  27. /** The default row height for empty rows is 255 twips (255 / 20 == 12.75 points) */
  28. public static final short DEFAULT_ROW_HEIGHT = 0xFF;
  29. private short field_1_option_flags;
  30. private short field_2_row_height;
  31. public DefaultRowHeightRecord() {
  32. field_1_option_flags = 0x0000;
  33. field_2_row_height = DEFAULT_ROW_HEIGHT;
  34. }
  35. public DefaultRowHeightRecord(DefaultRowHeightRecord other) {
  36. super(other);
  37. field_1_option_flags = other.field_1_option_flags;
  38. field_2_row_height = other.field_2_row_height;
  39. }
  40. public DefaultRowHeightRecord(RecordInputStream in) {
  41. field_1_option_flags = in.readShort();
  42. field_2_row_height = in.readShort();
  43. }
  44. /**
  45. * set the (currently unimportant to HSSF) option flags
  46. * @param flags the bitmask to set
  47. */
  48. public void setOptionFlags(short flags)
  49. {
  50. field_1_option_flags = flags;
  51. }
  52. /**
  53. * set the default row height
  54. * @param height for undefined rows/rows w/undefined height
  55. */
  56. public void setRowHeight(short height)
  57. {
  58. field_2_row_height = height;
  59. }
  60. /**
  61. * get the (currently unimportant to HSSF) option flags
  62. * @return flags - the current bitmask
  63. */
  64. public short getOptionFlags()
  65. {
  66. return field_1_option_flags;
  67. }
  68. /**
  69. * get the default row height
  70. * @return rowheight for undefined rows/rows w/undefined height
  71. */
  72. public short getRowHeight()
  73. {
  74. return field_2_row_height;
  75. }
  76. public void serialize(LittleEndianOutput out) {
  77. out.writeShort(getOptionFlags());
  78. out.writeShort(getRowHeight());
  79. }
  80. protected int getDataSize() {
  81. return 4;
  82. }
  83. public short getSid()
  84. {
  85. return sid;
  86. }
  87. @Override
  88. public DefaultRowHeightRecord copy() {
  89. return new DefaultRowHeightRecord(this);
  90. }
  91. @Override
  92. public HSSFRecordTypes getGenericRecordType() {
  93. return HSSFRecordTypes.DEFAULT_ROW_HEIGHT;
  94. }
  95. @Override
  96. public Map<String, Supplier<?>> getGenericProperties() {
  97. return GenericRecordUtil.getGenericProperties(
  98. "optionFlags", this::getOptionFlags,
  99. "rowHeight", this::getRowHeight
  100. );
  101. }
  102. }