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.

TableStylesRecord.java 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. import org.apache.poi.util.StringUtil;
  21. /**
  22. * TABLESTYLES (0x088E)
  23. */
  24. public final class TableStylesRecord extends StandardRecord {
  25. public static final short sid = 0x088E;
  26. private int rt;
  27. private int grbitFrt;
  28. private final byte[] unused = new byte[8];
  29. private int cts;
  30. private String rgchDefListStyle;
  31. private String rgchDefPivotStyle;
  32. public TableStylesRecord(TableStylesRecord other) {
  33. super(other);
  34. rt = other.rt;
  35. grbitFrt = other.grbitFrt;
  36. System.arraycopy(other.unused, 0, unused, 0, unused.length);
  37. cts = other.cts;
  38. rgchDefListStyle = other.rgchDefListStyle;
  39. rgchDefPivotStyle = other.rgchDefPivotStyle;
  40. }
  41. public TableStylesRecord(RecordInputStream in) {
  42. rt = in.readUShort();
  43. grbitFrt = in.readUShort();
  44. in.readFully(unused);
  45. cts = in.readInt();
  46. int cchDefListStyle = in.readUShort();
  47. int cchDefPivotStyle = in.readUShort();
  48. rgchDefListStyle = in.readUnicodeLEString(cchDefListStyle);
  49. rgchDefPivotStyle = in.readUnicodeLEString(cchDefPivotStyle);
  50. }
  51. @Override
  52. protected void serialize(LittleEndianOutput out) {
  53. out.writeShort(rt);
  54. out.writeShort(grbitFrt);
  55. out.write(unused);
  56. out.writeInt(cts);
  57. out.writeShort(rgchDefListStyle.length());
  58. out.writeShort(rgchDefPivotStyle.length());
  59. StringUtil.putUnicodeLE(rgchDefListStyle, out);
  60. StringUtil.putUnicodeLE(rgchDefPivotStyle, out);
  61. }
  62. @Override
  63. protected int getDataSize() {
  64. return 2 + 2 + 8 + 4 + 2 + 2
  65. + (2*rgchDefListStyle.length()) + (2*rgchDefPivotStyle.length());
  66. }
  67. @Override
  68. public short getSid() {
  69. return sid;
  70. }
  71. @Override
  72. public TableStylesRecord copy() {
  73. return new TableStylesRecord(this);
  74. }
  75. @Override
  76. public HSSFRecordTypes getGenericRecordType() {
  77. return HSSFRecordTypes.TABLE_STYLES;
  78. }
  79. @Override
  80. public Map<String, Supplier<?>> getGenericProperties() {
  81. return GenericRecordUtil.getGenericProperties(
  82. "rt", () -> rt,
  83. "grbitFrt", () -> grbitFrt,
  84. "unused", () -> unused,
  85. "cts", () -> cts,
  86. "rgchDefListStyle", () -> rgchDefListStyle,
  87. "rgchDefPivotStyle", () -> rgchDefPivotStyle
  88. );
  89. }
  90. }