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: Gridset Record.<P>
024: * Description: flag denoting whether the user specified that gridlines are used when
025: * printing.<P>
026: * REFERENCE: PG 320 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
027: *
028: * @author Andrew C. Oliver (acoliver at apache dot org)
029: * @author Glen Stampoultzis (glens at apache.org)
030: * @author Jason Height (jheight at chariot dot net dot au)
031: *
032: * @version 2.0-pre
033: */
034:
035: public class GridsetRecord extends Record {
036: public final static short sid = 0x82;
037: public short field_1_gridset_flag;
038:
039: public GridsetRecord() {
040: }
041:
042: /**
043: * Constructs a GridSet record and sets its fields appropriately.
044: * @param in the RecordInputstream to read the record from
045: */
046:
047: public GridsetRecord(RecordInputStream in) {
048: super (in);
049: }
050:
051: protected void validateSid(short id) {
052: if (id != sid) {
053: throw new RecordFormatException("NOT A Gridset RECORD");
054: }
055: }
056:
057: protected void fillFields(RecordInputStream in) {
058: field_1_gridset_flag = in.readShort();
059: }
060:
061: /**
062: * set whether gridlines are visible when printing
063: *
064: * @param gridset - <b>true</b> if no gridlines are print, <b>false</b> if gridlines are not print.
065: */
066:
067: public void setGridset(boolean gridset) {
068: if (gridset == true) {
069: field_1_gridset_flag = 1;
070: } else {
071: field_1_gridset_flag = 0;
072: }
073: }
074:
075: /**
076: * get whether the gridlines are shown during printing.
077: *
078: * @return gridset - true if gridlines are NOT printed, false if they are.
079: */
080:
081: public boolean getGridset() {
082: return (field_1_gridset_flag == 1);
083: }
084:
085: public String toString() {
086: StringBuffer buffer = new StringBuffer();
087:
088: buffer.append("[GRIDSET]\n");
089: buffer.append(" .gridset = ").append(getGridset())
090: .append("\n");
091: buffer.append("[/GRIDSET]\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) 0x2);
098: LittleEndian.putShort(data, 4 + offset, field_1_gridset_flag);
099: return getRecordSize();
100: }
101:
102: public int getRecordSize() {
103: return 6;
104: }
105:
106: public short getSid() {
107: return sid;
108: }
109:
110: public Object clone() {
111: GridsetRecord rec = new GridsetRecord();
112: rec.field_1_gridset_flag = field_1_gridset_flag;
113: return rec;
114: }
115: }
|