001: /* ====================================================================
002: Licensed to the Apache Software Foundation (ASF) under one or more
003: contributor license agreements. See the NOTICE file distributed with
004: this work for additional information regarding copyright ownership.
005: The ASF licenses this file to You under the Apache License, Version 2.0
006: (the "License"); you may not use this file except in compliance with
007: the License. You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016: ==================================================================== */
017:
018: package org.apache.poi.hssf.record;
019:
020: import org.apache.poi.util.LittleEndian;
021:
022: /**
023: * Title: Hide Object Record<P>
024: * Description: flag defines whether to hide placeholders and object<P>
025: * REFERENCE: PG 321 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
026: * @author Andrew C. Oliver (acoliver at apache dot org)
027: * @version 2.0-pre
028: */
029:
030: public class HideObjRecord extends Record {
031: public final static short sid = 0x8d;
032: public final static short HIDE_ALL = 2;
033: public final static short SHOW_PLACEHOLDERS = 1;
034: public final static short SHOW_ALL = 0;
035: private short field_1_hide_obj;
036:
037: public HideObjRecord() {
038: }
039:
040: /**
041: * Constructs an HideObj record and sets its fields appropriately.
042: * @param in the RecordInputstream to read the record from
043: */
044:
045: public HideObjRecord(RecordInputStream in) {
046: super (in);
047: }
048:
049: protected void validateSid(short id) {
050: if (id != sid) {
051: throw new RecordFormatException("NOT A HIDEOBJ RECORD");
052: }
053: }
054:
055: protected void fillFields(RecordInputStream in) {
056: field_1_hide_obj = in.readShort();
057: }
058:
059: /**
060: * set hide object options
061: *
062: * @param hide options
063: * @see #HIDE_ALL
064: * @see #SHOW_PLACEHOLDERS
065: * @see #SHOW_ALL
066: */
067:
068: public void setHideObj(short hide) {
069: field_1_hide_obj = hide;
070: }
071:
072: /**
073: * get hide object options
074: *
075: * @return hide options
076: * @see #HIDE_ALL
077: * @see #SHOW_PLACEHOLDERS
078: * @see #SHOW_ALL
079: */
080:
081: public short getHideObj() {
082: return field_1_hide_obj;
083: }
084:
085: public String toString() {
086: StringBuffer buffer = new StringBuffer();
087:
088: buffer.append("[HIDEOBJ]\n");
089: buffer.append(" .hideobj = ").append(
090: Integer.toHexString(getHideObj())).append("\n");
091: buffer.append("[/HIDEOBJ]\n");
092: return buffer.toString();
093: }
094:
095: public int serialize(int offset, byte[] data) {
096: LittleEndian.putShort(data, 0 + offset, sid);
097: LittleEndian.putShort(data, 2 + offset, ((short) 0x02)); // 2 bytes (6 total)
098: LittleEndian.putShort(data, 4 + offset, getHideObj());
099: return getRecordSize();
100: }
101:
102: public int getRecordSize() {
103: return 6;
104: }
105:
106: public short getSid() {
107: return sid;
108: }
109: }
|