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: Print Gridlines Record<P>
024: * Description: whether to print the gridlines when you enjoy you spreadsheet on paper.<P>
025: * REFERENCE: PG 373 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
026: * @author Andrew C. Oliver (acoliver at apache dot org)
027: * @author Jason Height (jheight at chariot dot net dot au)
028: * @version 2.0-pre
029: */
030:
031: public class PrintGridlinesRecord extends Record {
032: public final static short sid = 0x2b;
033: private short field_1_print_gridlines;
034:
035: public PrintGridlinesRecord() {
036: }
037:
038: /**
039: * Constructs a PrintGridlines record and sets its fields appropriately.
040: * @param in the RecordInputstream to read the record from
041: */
042:
043: public PrintGridlinesRecord(RecordInputStream in) {
044: super (in);
045: }
046:
047: protected void validateSid(short id) {
048: if (id != sid) {
049: throw new RecordFormatException(
050: "NOT A PrintGridlines RECORD");
051: }
052: }
053:
054: protected void fillFields(RecordInputStream in) {
055: field_1_print_gridlines = in.readShort();
056: }
057:
058: /**
059: * set whether or not to print the gridlines (and make your spreadsheet ugly)
060: *
061: * @param pg make spreadsheet ugly - Y/N
062: */
063:
064: public void setPrintGridlines(boolean pg) {
065: if (pg == true) {
066: field_1_print_gridlines = 1;
067: } else {
068: field_1_print_gridlines = 0;
069: }
070: }
071:
072: /**
073: * get whether or not to print the gridlines (and make your spreadsheet ugly)
074: *
075: * @return make spreadsheet ugly - Y/N
076: */
077:
078: public boolean getPrintGridlines() {
079: return (field_1_print_gridlines == 1);
080: }
081:
082: public String toString() {
083: StringBuffer buffer = new StringBuffer();
084:
085: buffer.append("[PRINTGRIDLINES]\n");
086: buffer.append(" .printgridlines = ").append(
087: getPrintGridlines()).append("\n");
088: buffer.append("[/PRINTGRIDLINES]\n");
089: return buffer.toString();
090: }
091:
092: public int serialize(int offset, byte[] data) {
093: LittleEndian.putShort(data, 0 + offset, sid);
094: LittleEndian.putShort(data, 2 + offset, (short) 0x2);
095: LittleEndian
096: .putShort(data, 4 + offset, field_1_print_gridlines);
097: return getRecordSize();
098: }
099:
100: public int getRecordSize() {
101: return 6;
102: }
103:
104: public short getSid() {
105: return sid;
106: }
107:
108: public Object clone() {
109: PrintGridlinesRecord rec = new PrintGridlinesRecord();
110: rec.field_1_print_gridlines = field_1_print_gridlines;
111: return rec;
112: }
113: }
|