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.OutputStream;
21: import java.io.IOException;
22:
23: import org.apache.poi.util.BitField;
24: import org.apache.poi.util.BitFieldFactory;
25: import org.apache.poi.util.LittleEndian;
26:
27: public class ParagraphHeight {
28: private short infoField;
29: private BitField fSpare = BitFieldFactory.getInstance(0x0001);
30: private BitField fUnk = BitFieldFactory.getInstance(0x0002);
31: private BitField fDiffLines = BitFieldFactory.getInstance(0x0004);
32: private BitField clMac = BitFieldFactory.getInstance(0xff00);
33: private short reserved;
34: private int dxaCol;
35: private int dymLineOrHeight;
36:
37: public ParagraphHeight(byte[] buf, int offset) {
38: infoField = LittleEndian.getShort(buf, offset);
39: offset += LittleEndian.SHORT_SIZE;
40: reserved = LittleEndian.getShort(buf, offset);
41: offset += LittleEndian.SHORT_SIZE;
42: dxaCol = LittleEndian.getInt(buf, offset);
43: offset += LittleEndian.INT_SIZE;
44: dymLineOrHeight = LittleEndian.getInt(buf, offset);
45: }
46:
47: public ParagraphHeight() {
48:
49: }
50:
51: public void write(OutputStream out) throws IOException {
52: out.write(toByteArray());
53: }
54:
55: protected byte[] toByteArray() {
56: byte[] buf = new byte[12];
57: int offset = 0;
58: LittleEndian.putShort(buf, offset, infoField);
59: offset += LittleEndian.SHORT_SIZE;
60: LittleEndian.putShort(buf, offset, reserved);
61: offset += LittleEndian.SHORT_SIZE;
62: LittleEndian.putInt(buf, offset, dxaCol);
63: offset += LittleEndian.INT_SIZE;
64: LittleEndian.putInt(buf, offset, dymLineOrHeight);
65:
66: return buf;
67: }
68:
69: public boolean equals(Object o) {
70: ParagraphHeight ph = (ParagraphHeight) o;
71:
72: return infoField == ph.infoField && reserved == ph.reserved
73: && dxaCol == ph.dxaCol
74: && dymLineOrHeight == ph.dymLineOrHeight;
75: }
76: }
|