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
9 http://www.apache.org/licenses/LICENSE-2.0
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 ==================================================================== */
18 package org.apache.poi.hwpf.usermodel;
20 import org.apache.poi.util.BitField;
21 import org.apache.poi.util.BitFieldFactory;
22 import org.apache.poi.util.LittleEndian;
25 * This data structure is used by a paragraph to determine how it should drop
26 * its first letter. I think its the visual effect that will show a giant first
27 * letter to a paragraph. I've seen this used in the first paragraph of a book
31 public final class DropCapSpecifier
34 private static BitField _lines = BitFieldFactory.getInstance( 0xf8 );
35 private static BitField _type = BitFieldFactory.getInstance( 0x07 );
37 public DropCapSpecifier()
42 public DropCapSpecifier( byte[] buf, int offset )
44 this( LittleEndian.getShort( buf, offset ) );
47 public DropCapSpecifier( short fdct )
53 public DropCapSpecifier clone()
55 return new DropCapSpecifier( _fdct );
59 public boolean equals( Object obj )
65 if ( getClass() != obj.getClass() )
67 DropCapSpecifier other = (DropCapSpecifier) obj;
68 if ( _fdct != other._fdct )
73 public byte getCountOfLinesToDrop()
75 return (byte) _lines.getValue( _fdct );
78 public byte getDropCapType()
80 return (byte) _type.getValue( _fdct );
89 public boolean isEmpty()
94 public void setCountOfLinesToDrop( byte value )
96 _fdct = (short) _lines.setValue( _fdct, value );
99 public void setDropCapType( byte value )
101 _fdct = (short) _type.setValue( _fdct, value );
104 public short toShort()
110 public String toString()
113 return "[DCS] EMPTY";
115 return "[DCS] (type: " + getDropCapType() + "; count: "
116 + getCountOfLinesToDrop() + ")";