01: /* ====================================================================
02: Licensed to the Apache Software Foundation (ASF) under one or more
03: contributor license agreements. See the NOTICE file distributed with
04: this work for additional information regarding copyright ownership.
05: The ASF licenses this file to You under the Apache License, Version 2.0
06: (the "License"); you may not use this file except in compliance with
07: the License. You may obtain a copy of the License at
08:
09: 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.hwpf.model;
19:
20: import java.io.IOException;
21:
22: import org.apache.poi.util.LittleEndian;
23:
24: public class FIBLongHandler {
25: public static final int CBMAC = 0;
26: public static final int PRODUCTCREATED = 1;
27: public static final int PRODUCTREVISED = 2;
28: public static final int CCPTEXT = 3;
29: public static final int CCPFTN = 4;
30: public static final int CCPHDD = 5;
31: public static final int CCPMCR = 6;
32: public static final int CCPATN = 7;
33: public static final int CCPEDN = 8;
34: public static final int CCPTXBX = 9;
35: public static final int CCPHDRTXBX = 10;
36: public static final int PNFBPCHPFIRST = 11;
37: public static final int PNCHPFIRST = 12;
38: public static final int CPNBTECHP = 13;
39: public static final int PNFBPPAPFIRST = 14;
40: public static final int PNPAPFIRST = 15;
41: public static final int CPNBTEPAP = 16;
42: public static final int PNFBPLVCFIRST = 17;
43: public static final int PNLVCFIRST = 18;
44: public static final int CPNBTELVC = 19;
45: public static final int FCISLANDFIRST = 20;
46: public static final int FCISLANDLIM = 21;
47:
48: int[] _longs;
49:
50: public FIBLongHandler(byte[] mainStream, int offset) {
51: int longCount = LittleEndian.getShort(mainStream, offset);
52: offset += LittleEndian.SHORT_SIZE;
53: _longs = new int[longCount];
54:
55: for (int x = 0; x < longCount; x++) {
56: _longs[x] = LittleEndian.getInt(mainStream, offset
57: + (x * LittleEndian.INT_SIZE));
58: }
59: }
60:
61: /**
62: * Refers to a 32 bit windows "long" same as a Java int
63: * @param longCode FIXME: Document this!
64: * @return FIXME: Document this!
65: */
66: public int getLong(int longCode) {
67: return _longs[longCode];
68: }
69:
70: public void setLong(int longCode, int value) {
71: _longs[longCode] = value;
72: }
73:
74: void serialize(byte[] mainStream, int offset) throws IOException {
75: LittleEndian
76: .putShort(mainStream, offset, (short) _longs.length);
77: offset += LittleEndian.SHORT_SIZE;
78:
79: for (int x = 0; x < _longs.length; x++) {
80: LittleEndian.putInt(mainStream, offset, _longs[x]);
81: offset += LittleEndian.INT_SIZE;
82: }
83: }
84:
85: int sizeInBytes() {
86: return (_longs.length * LittleEndian.INT_SIZE)
87: + LittleEndian.SHORT_SIZE;
88: }
89:
90: }
|