KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hwpf > model > ParagraphHeight


1
2 /* ====================================================================
3    Copyright 2002-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    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
19
20 package org.apache.poi.hwpf.model;
21
22 import java.io.OutputStream JavaDoc;
23 import java.io.IOException JavaDoc;
24
25 import org.apache.poi.util.BitField;
26 import org.apache.poi.util.LittleEndian;
27
28 public class ParagraphHeight
29 {
30   private short infoField;
31     private BitField fSpare = new BitField(0x0001);
32     private BitField fUnk = new BitField(0x0002);
33     private BitField fDiffLines = new BitField(0x0004);
34     private BitField clMac = new BitField(0xff00);
35   private short reserved;
36   private int dxaCol;
37   private int dymLineOrHeight;
38
39   public ParagraphHeight(byte[] buf, int offset)
40   {
41     infoField = LittleEndian.getShort(buf, offset);
42     offset += LittleEndian.SHORT_SIZE;
43     reserved = LittleEndian.getShort(buf, offset);
44     offset += LittleEndian.SHORT_SIZE;
45     dxaCol = LittleEndian.getInt(buf, offset);
46     offset += LittleEndian.INT_SIZE;
47     dymLineOrHeight = LittleEndian.getInt(buf, offset);
48   }
49
50   public ParagraphHeight()
51   {
52
53   }
54
55   public void write(OutputStream JavaDoc out)
56     throws IOException JavaDoc
57   {
58     out.write(toByteArray());
59   }
60
61   protected byte[] toByteArray()
62   {
63     byte[] buf = new byte[12];
64     int offset = 0;
65     LittleEndian.putShort(buf, offset, infoField);
66     offset += LittleEndian.SHORT_SIZE;
67     LittleEndian.putShort(buf, offset, reserved);
68     offset += LittleEndian.SHORT_SIZE;
69     LittleEndian.putInt(buf, offset, dxaCol);
70     offset += LittleEndian.INT_SIZE;
71     LittleEndian.putInt(buf, offset, dymLineOrHeight);
72
73     return buf;
74   }
75
76   public boolean equals(Object JavaDoc o)
77   {
78     ParagraphHeight ph = (ParagraphHeight)o;
79
80     return infoField == ph.infoField && reserved == ph.reserved &&
81            dxaCol == ph.dxaCol && dymLineOrHeight == ph.dymLineOrHeight;
82   }
83 }
84
Popular Tags