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.

FeatHdrRecord.java 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.util.LittleEndianOutput;
  18. /**
  19. * Title: FeatHdr (Feature Header) Record
  20. * <P>
  21. * This record specifies common information for Shared Features, and
  22. * specifies the beginning of a collection of records to define them.
  23. * The collection of data (Globals Substream ABNF, macro sheet substream
  24. * ABNF or worksheet substream ABNF) specifies Shared Feature data.
  25. */
  26. public final class FeatHdrRecord extends StandardRecord {
  27. /**
  28. * Specifies the enhanced protection type. Used to protect a
  29. * shared workbook by restricting access to some areas of it
  30. */
  31. public static final int SHAREDFEATURES_ISFPROTECTION = 0x02;
  32. /**
  33. * Specifies that formula errors should be ignored
  34. */
  35. public static final int SHAREDFEATURES_ISFFEC2 = 0x03;
  36. /**
  37. * Specifies the smart tag type. Recognises certain
  38. * types of entries (proper names, dates/times etc) and
  39. * flags them for action
  40. */
  41. public static final int SHAREDFEATURES_ISFFACTOID = 0x04;
  42. /**
  43. * Specifies the shared list type. Used for a table
  44. * within a sheet
  45. */
  46. public static final int SHAREDFEATURES_ISFLIST = 0x05;
  47. public final static short sid = 0x0867;
  48. private FtrHeader futureHeader;
  49. private int isf_sharedFeatureType; // See SHAREDFEATURES_
  50. private byte reserved; // Should always be one
  51. /**
  52. * 0x00000000 = rgbHdrData not present
  53. * 0xffffffff = rgbHdrData present
  54. */
  55. private long cbHdrData;
  56. /** We need a BOFRecord to make sense of this... */
  57. private byte[] rgbHdrData;
  58. public FeatHdrRecord() {
  59. futureHeader = new FtrHeader();
  60. futureHeader.setRecordType(sid);
  61. }
  62. public short getSid() {
  63. return sid;
  64. }
  65. public FeatHdrRecord(RecordInputStream in) {
  66. futureHeader = new FtrHeader(in);
  67. isf_sharedFeatureType = in.readShort();
  68. reserved = in.readByte();
  69. cbHdrData = in.readInt();
  70. // Don't process this just yet, need the BOFRecord
  71. rgbHdrData = in.readRemainder();
  72. }
  73. public String toString() {
  74. StringBuffer buffer = new StringBuffer();
  75. buffer.append("[FEATURE HEADER]\n");
  76. // TODO ...
  77. buffer.append("[/FEATURE HEADER]\n");
  78. return buffer.toString();
  79. }
  80. public void serialize(LittleEndianOutput out) {
  81. futureHeader.serialize(out);
  82. out.writeShort(isf_sharedFeatureType);
  83. out.writeByte(reserved);
  84. out.writeInt((int)cbHdrData);
  85. out.write(rgbHdrData);
  86. }
  87. protected int getDataSize() {
  88. return 12 + 2+1+4+rgbHdrData.length;
  89. }
  90. }