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.

FeatRecord.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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.hssf.record.common.FtrHeader;
  17. import org.apache.poi.hssf.record.common.Ref8U;
  18. import org.apache.poi.util.LittleEndianOutput;
  19. /**
  20. * Title: Feat (Feature) Record
  21. * <P>
  22. * This record specifies Shared Features data. It is normally paired
  23. * up with a {@link FeatHdrRecord}.
  24. */
  25. public final class FeatRecord extends StandardRecord {
  26. public final static short sid = 0x0868;
  27. private FtrHeader futureHeader;
  28. /**
  29. * See SHAREDFEATURES_* on {@link FeatHdrRecord}
  30. */
  31. private int isf_sharedFeatureType;
  32. private byte reserved1; // Should always be zero
  33. private long reserved2; // Should always be zero
  34. /** Only matters if type is ISFFEC2 */
  35. private long cbFeatData;
  36. private int reserved3; // Should always be zero
  37. private Ref8U[] cellRefs;
  38. private byte[] rgbFeat;
  39. public FeatRecord() {
  40. futureHeader = new FtrHeader();
  41. futureHeader.setRecordType(sid);
  42. }
  43. public short getSid() {
  44. return sid;
  45. }
  46. public FeatRecord(RecordInputStream in) {
  47. futureHeader = new FtrHeader(in);
  48. isf_sharedFeatureType = in.readShort();
  49. reserved1 = in.readByte();
  50. reserved2 = in.readInt();
  51. int cref = in.readUShort();
  52. cbFeatData = in.readInt();
  53. reserved3 = in.readShort();
  54. cellRefs = new Ref8U[cref];
  55. for(int i=0; i<cellRefs.length; i++) {
  56. cellRefs[i] = new Ref8U(in);
  57. }
  58. rgbFeat = in.readRemainder();
  59. }
  60. public String toString() {
  61. StringBuffer buffer = new StringBuffer();
  62. buffer.append("[SHARED FEATURE]\n");
  63. // TODO ...
  64. buffer.append("[/SHARED FEATURE]\n");
  65. return buffer.toString();
  66. }
  67. public void serialize(LittleEndianOutput out) {
  68. futureHeader.serialize(out);
  69. out.writeShort(isf_sharedFeatureType);
  70. out.writeByte(reserved1);
  71. out.writeInt((int)reserved2);
  72. out.writeShort(cellRefs.length);
  73. out.writeInt((int)cbFeatData);
  74. out.writeShort(reserved3);
  75. for(int i=0; i<cellRefs.length; i++) {
  76. cellRefs[i].serialize(out);
  77. }
  78. out.write(rgbFeat);
  79. }
  80. protected int getDataSize() {
  81. return 12 + 2+1+4+2+4+2+Ref8U.getDataSize()+rgbFeat.length;
  82. }
  83. }