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.

BlankRecord.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. * Represents a column in a row with no value but with styling.
  22. *
  23. * @version 2.0-pre
  24. */
  25. public final class BlankRecord extends StandardRecord implements CellValueRecordInterface {
  26. public static final short sid = 0x0201;
  27. private int field_1_row;
  28. private short field_2_col;
  29. private short field_3_xf;
  30. /** Creates a new instance of BlankRecord */
  31. public BlankRecord() {}
  32. public BlankRecord(BlankRecord other) {
  33. super(other);
  34. field_1_row = other.field_1_row;
  35. field_2_col = other.field_2_col;
  36. field_3_xf = other.field_3_xf;
  37. }
  38. public BlankRecord(RecordInputStream in) {
  39. field_1_row = in.readUShort();
  40. field_2_col = in.readShort();
  41. field_3_xf = in.readShort();
  42. }
  43. /**
  44. * set the row this cell occurs on
  45. * @param row the row this cell occurs within
  46. */
  47. public void setRow(int row)
  48. {
  49. field_1_row = row;
  50. }
  51. /**
  52. * get the row this cell occurs on
  53. *
  54. * @return the row
  55. */
  56. public int getRow()
  57. {
  58. return field_1_row;
  59. }
  60. /**
  61. * get the column this cell defines within the row
  62. *
  63. * @return the column
  64. */
  65. public short getColumn()
  66. {
  67. return field_2_col;
  68. }
  69. /**
  70. * set the index of the extended format record to style this cell with
  71. *
  72. * @param xf - the 0-based index of the extended format
  73. * @see org.apache.poi.hssf.record.ExtendedFormatRecord
  74. */
  75. public void setXFIndex(short xf)
  76. {
  77. field_3_xf = xf;
  78. }
  79. /**
  80. * get the index of the extended format record to style this cell with
  81. *
  82. * @return extended format index
  83. */
  84. public short getXFIndex()
  85. {
  86. return field_3_xf;
  87. }
  88. /**
  89. * set the column this cell defines within the row
  90. *
  91. * @param col the column this cell defines
  92. */
  93. public void setColumn(short col)
  94. {
  95. field_2_col = col;
  96. }
  97. /**
  98. * return the non static version of the id for this record.
  99. */
  100. public short getSid()
  101. {
  102. return sid;
  103. }
  104. public void serialize(LittleEndianOutput out) {
  105. out.writeShort(getRow());
  106. out.writeShort(getColumn());
  107. out.writeShort(getXFIndex());
  108. }
  109. protected int getDataSize() {
  110. return 6;
  111. }
  112. @Override
  113. public BlankRecord copy() {
  114. return new BlankRecord(this);
  115. }
  116. @Override
  117. public HSSFRecordTypes getGenericRecordType() {
  118. return HSSFRecordTypes.BLANK;
  119. }
  120. @Override
  121. public Map<String, Supplier<?>> getGenericProperties() {
  122. return GenericRecordUtil.getGenericProperties(
  123. "row", this::getRow,
  124. "col", this::getColumn,
  125. "xfIndex", this::getXFIndex
  126. );
  127. }
  128. }