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 |
|
---|
9 | http://www.apache.org/licenses/LICENSE-2.0
|
---|
10 |
|
---|
11 | Unless required by applicable law or agreed to in writing, software
|
---|
12 | distributed under the License is distributed on an "AS IS" BASIS,
|
---|
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
14 | See the License for the specific language governing permissions and
|
---|
15 | limitations under the License.
|
---|
16 | ==================================================================== */
|
---|
17 |
|
---|
18 | package org.apache.poi.hssf.record;
|
---|
19 |
|
---|
20 | import org.apache.poi.util.HexDump;
|
---|
21 | import org.apache.poi.util.LittleEndianInput;
|
---|
22 | import org.apache.poi.util.LittleEndianOutput;
|
---|
23 |
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * This structure appears as part of an Obj record that represents a checkbox or radio button.
|
---|
27 | *
|
---|
28 | * @author Yegor Kozlov
|
---|
29 | */
|
---|
30 | public final class FtCblsSubRecord extends SubRecord {
|
---|
31 | public final static short sid = 0x0C;
|
---|
32 | private static final int ENCODED_SIZE = 20;
|
---|
33 |
|
---|
34 | private byte[] reserved;
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Construct a new <code>FtCblsSubRecord</code> and
|
---|
38 | * fill its data with the default values
|
---|
39 | */
|
---|
40 | public FtCblsSubRecord()
|
---|
41 | {
|
---|
42 | reserved = new byte[ENCODED_SIZE];
|
---|
43 | }
|
---|
44 |
|
---|
45 | public FtCblsSubRecord(LittleEndianInput in, int size) {
|
---|
46 | if (size != ENCODED_SIZE) {
|
---|
47 | throw new RecordFormatException("Unexpected size (" + size + ")");
|
---|
48 | }
|
---|
49 | //just grab the raw data
|
---|
50 | byte[] buf = new byte[size];
|
---|
51 | in.readFully(buf);
|
---|
52 | reserved = buf;
|
---|
53 | }
|
---|
54 |
|
---|
55 | /**
|
---|
56 | * Convert this record to string.
|
---|
57 | * Used by BiffViewer and other utilities.
|
---|
58 | */
|
---|
59 | public String toString()
|
---|
60 | {
|
---|
61 | StringBuffer buffer = new StringBuffer();
|
---|
62 |
|
---|
63 | buffer.append("[FtCbls ]").append("\n");
|
---|
64 | buffer.append(" size = ").append(getDataSize()).append("\n");
|
---|
65 | buffer.append(" reserved = ").append(HexDump.toHex(reserved)).append("\n");
|
---|
66 | buffer.append("[/FtCbls ]").append("\n");
|
---|
67 | return buffer.toString();
|
---|
68 | }
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Serialize the record data into the supplied array of bytes
|
---|
72 | *
|
---|
73 | * @param out the stream to serialize into
|
---|
74 | */
|
---|
75 | public void serialize(LittleEndianOutput out) {
|
---|
76 | out.writeShort(sid);
|
---|
77 | out.writeShort(reserved.length);
|
---|
78 | out.write(reserved);
|
---|
79 | }
|
---|
80 |
|
---|
81 | protected int getDataSize() {
|
---|
82 | return reserved.length;
|
---|
83 | }
|
---|
84 |
|
---|
85 | /**
|
---|
86 | * @return id of this record.
|
---|
87 | */
|
---|
88 | public short getSid() // NO_UCD
|
---|
89 | {
|
---|
90 | return sid;
|
---|
91 | }
|
---|
92 |
|
---|
93 | public Object clone() {
|
---|
94 | FtCblsSubRecord rec = new FtCblsSubRecord();
|
---|
95 | byte[] recdata = new byte[reserved.length];
|
---|
96 | System.arraycopy(reserved, 0, recdata, 0, recdata.length);
|
---|
97 | rec.reserved = recdata;
|
---|
98 | return rec;
|
---|
99 | }
|
---|
100 |
|
---|
101 | }
|
---|