case VerticalPageBreakRecord.sid:
retval = new VerticalPageBreakRecord( in);
break;
+ case WriteProtectRecord.sid:
+ retval = new WriteProtectRecord( in);
+ break;
+ case FilePassRecord.sid:
+ retval = new FilePassRecord(in);
+ break;
default:
retval = new UnknownRecord( in );
}
import org.apache.poi.hssf.record.WindowProtectRecord;
import org.apache.poi.hssf.record.WindowTwoRecord;
import org.apache.poi.hssf.record.WriteAccessRecord;
+import org.apache.poi.hssf.record.WriteProtectRecord;
+import org.apache.poi.hssf.record.FilePassRecord;
/**
BoolErrRecord.class, ExternSheetRecord.class, NameRecord.class,
LeftMarginRecord.class, RightMarginRecord.class,
TopMarginRecord.class, BottomMarginRecord.class,
- PaletteRecord.class, StringRecord.class, SharedFormulaRecord.class
+ PaletteRecord.class, StringRecord.class, SharedFormulaRecord.class,
+ WriteProtectRecord.class, FilePassRecord.class
};
}
--- /dev/null
+\r
+/* ====================================================================\r
+ Copyright 2002-2004 Apache Software Foundation\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+==================================================================== */\r
+ \r
+\r
+package org.apache.poi.hssf.record;\r
+\r
+import org.apache.poi.util.LittleEndian;\r
+\r
+/**\r
+ * Title: File Pass Record<P>\r
+ * Description: Indicates that the record after this record are encrypted. HSSF does not support encrypted excel workbooks\r
+ * and the presence of this record will cause processing to be aborted.<p>\r
+ * REFERENCE: PG 420 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>\r
+ * @author Jason Height (jheight at chariot dot net dot au)\r
+ * @version 3.0-pre\r
+ */\r
+\r
+public class FilePassRecord\r
+ extends Record\r
+{\r
+ public final static short sid = 0x2F;\r
+ private int field_1_encryptedpassword;\r
+\r
+ public FilePassRecord()\r
+ {\r
+ }\r
+\r
+ /**\r
+ * Constructs a FILEPASS record and sets its fields appropriately.\r
+ *\r
+ * @param id id must be 0x84 or an exception will be throw upon validation\r
+ * @param size the size of the data area of the record\r
+ * @param data data of the record (should not contain sid/len)\r
+ */\r
+\r
+ public FilePassRecord(RecordInputStream in)\r
+ {\r
+ super(in);\r
+ }\r
+\r
+ protected void validateSid(short id)\r
+ {\r
+ if (id != sid)\r
+ {\r
+ throw new RecordFormatException("NOT A FILEPASS RECORD");\r
+ }\r
+ }\r
+\r
+ protected void fillFields(RecordInputStream in)\r
+ {\r
+ field_1_encryptedpassword = in.readInt();\r
+ \r
+ //Whilst i have read in the password, HSSF currently has no plans to support/decrypt the remainder\r
+ //of this workbook\r
+ throw new RecordFormatException("HSSF does not currently support encrypted workbooks");\r
+ }\r
+\r
+ public String toString()\r
+ {\r
+ StringBuffer buffer = new StringBuffer();\r
+\r
+ buffer.append("[FILEPASS]\n");\r
+ buffer.append(" .password = ").append(field_1_encryptedpassword)\r
+ .append("\n");\r
+ buffer.append("[/FILEPASS]\n");\r
+ return buffer.toString();\r
+ }\r
+\r
+ public int serialize(int offset, byte [] data)\r
+ {\r
+ LittleEndian.putShort(data, 0 + offset, sid);\r
+ LittleEndian.putShort(data, 2 + offset, ( short ) 0x4);\r
+ LittleEndian.putInt(data, 4 + offset, ( short ) field_1_encryptedpassword);\r
+ return getRecordSize();\r
+ }\r
+\r
+ public int getRecordSize()\r
+ {\r
+ return 8;\r
+ }\r
+\r
+ public short getSid()\r
+ {\r
+ return sid;\r
+ }\r
+\r
+ public Object clone() {\r
+ FilePassRecord rec = new FilePassRecord();\r
+ rec.field_1_encryptedpassword = field_1_encryptedpassword;\r
+ return rec;\r
+ }\r
+}\r
DrawingRecord.class, DrawingGroupRecord.class, DrawingSelectionRecord.class,
ObjRecord.class, TextObjectRecord.class,
PaletteRecord.class, StringRecord.class, RecalcIdRecord.class, SharedFormulaRecord.class,
- HorizontalPageBreakRecord.class, VerticalPageBreakRecord.class
+ HorizontalPageBreakRecord.class, VerticalPageBreakRecord.class,
+ WriteProtectRecord.class, FilePassRecord.class
};
} else {
records = new Class[]
PaletteRecord.class, StringRecord.class, RecalcIdRecord.class, SharedFormulaRecord.class,
DrawingRecord.class, DrawingGroupRecord.class, DrawingSelectionRecord.class,
ObjRecord.class, TextObjectRecord.class,
- HorizontalPageBreakRecord.class, VerticalPageBreakRecord.class
+ HorizontalPageBreakRecord.class, VerticalPageBreakRecord.class,
+ WriteProtectRecord.class, FilePassRecord.class
};
}
{
sid = in.getSid();
thedata = in.readRemainder();
+
+ //System.out.println("UnknownRecord: 0x"+Integer.toHexString(sid));
}
/**
--- /dev/null
+\r
+/* ====================================================================\r
+ Copyright 2002-2004 Apache Software Foundation\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+==================================================================== */\r
+ \r
+\r
+package org.apache.poi.hssf.record;\r
+\r
+import org.apache.poi.util.LittleEndian;\r
+import org.apache.poi.util.StringUtil;\r
+\r
+/**\r
+ * Title: Write Protect Record<P>\r
+ * Description: Indicated that the sheet/workbook is write protected. \r
+ * REFERENCE: PG 425 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>\r
+ * @version 3.0-pre\r
+ */\r
+\r
+public class WriteProtectRecord\r
+ extends Record\r
+{\r
+ public final static short sid = 0x86;\r
+\r
+ public WriteProtectRecord()\r
+ {\r
+ }\r
+\r
+ /**\r
+ * Constructs a WriteAccess record and sets its fields appropriately.\r
+ *\r
+ * @param id id must be 0x5c or an exception will be throw upon validation\r
+ * @param size the size of the data area of the record\r
+ * @param data data of the record (should not contain sid/len)\r
+ */\r
+\r
+ public WriteProtectRecord(RecordInputStream in)\r
+ {\r
+ super(in);\r
+ }\r
+\r
+ protected void validateSid(short id)\r
+ {\r
+ if (id != sid)\r
+ {\r
+ throw new RecordFormatException("NOT A WRITEPROTECT RECORD");\r
+ }\r
+ }\r
+\r
+ protected void fillFields(RecordInputStream in)\r
+ {\r
+ }\r
+\r
+ public String toString()\r
+ {\r
+ StringBuffer buffer = new StringBuffer();\r
+\r
+ buffer.append("[WRITEPROTECT]\n");\r
+ buffer.append("[/WRITEPROTECT]\n");\r
+ return buffer.toString();\r
+ }\r
+\r
+ public int serialize(int offset, byte [] data)\r
+ {\r
+ LittleEndian.putShort(data, 0 + offset, sid);\r
+ LittleEndian.putShort(data, 2 + offset, (short)0);\r
+\r
+ return getRecordSize();\r
+ }\r
+\r
+ public int getRecordSize()\r
+ {\r
+ return 4;\r
+ }\r
+\r
+ public short getSid()\r
+ {\r
+ return sid;\r
+ }\r
+}\r