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.usermodel;
19:
20: import org.apache.poi.util.LittleEndian;
21:
22: /**
23: * This class is used to determine line spacing for a paragraph.
24: *
25: * @author Ryan Ackley
26: */
27: public class LineSpacingDescriptor implements Cloneable {
28: short _dyaLine;
29: short _fMultiLinespace;
30:
31: public LineSpacingDescriptor() {
32: }
33:
34: public LineSpacingDescriptor(byte[] buf, int offset) {
35: _dyaLine = LittleEndian.getShort(buf, offset);
36: _fMultiLinespace = LittleEndian.getShort(buf, offset
37: + LittleEndian.SHORT_SIZE);
38: }
39:
40: public Object clone() throws CloneNotSupportedException {
41: return super .clone();
42: }
43:
44: public void setMultiLinespace(short fMultiLinespace) {
45: _fMultiLinespace = fMultiLinespace;
46: }
47:
48: public int toInt() {
49: byte[] intHolder = new byte[4];
50: serialize(intHolder, 0);
51: return LittleEndian.getInt(intHolder);
52: }
53:
54: public void serialize(byte[] buf, int offset) {
55: LittleEndian.putShort(buf, offset, _dyaLine);
56: LittleEndian.putShort(buf, offset + LittleEndian.SHORT_SIZE,
57: _fMultiLinespace);
58: }
59:
60: public void setDyaLine(short dyaLine) {
61: _dyaLine = dyaLine;
62: }
63:
64: public boolean equals(Object o) {
65: LineSpacingDescriptor lspd = (LineSpacingDescriptor) o;
66:
67: return _dyaLine == lspd._dyaLine
68: && _fMultiLinespace == lspd._fMultiLinespace;
69: }
70: }
|