Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* ====================================================================
     Licensed to the Apache Software Foundation (ASF) under one or more
     contributor license agreements.  See the NOTICE file distributed with
     this work for additional information regarding copyright ownership.
     The ASF licenses this file to You under the Apache License, Version 2.0
     (the "License"); you may not use this file except in compliance with
     the License.  You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
 
 package org.apache.poi.hwpf.usermodel;
 
Mapping class for BRC80 structure (Border Code for Word 97)

Comments are copied out from the binary format specification.

 
 public final class BorderCode implements Cloneable {
   
   public static final int SIZE = 4;
   
   private short _info;
     private static final BitField _dptLineWidth = BitFieldFactory.getInstance(0x00ff);
     private static final BitField _brcType = BitFieldFactory.getInstance(0xff00);
     
   private short _info2;
     private static final BitField _ico = BitFieldFactory.getInstance(0x00ff);
     private static final BitField _dptSpace = BitFieldFactory.getInstance(0x1f00);
     private static final BitField _fShadow = BitFieldFactory.getInstance(0x2000);
     private static final BitField _fFrame = BitFieldFactory.getInstance(0x4000);
     
   public BorderCode()
   {
   }
 
   public BorderCode(byte[] bufint offset)
   {
      = LittleEndian.getShort(bufoffset);
      = LittleEndian.getShort(bufoffset + .);
   }
 
   public void serialize(byte[] bufint offset)
   {
     LittleEndian.putShort(bufoffset);
     LittleEndian.putShort(bufoffset + .);
   }
 
   public int toInt()
   {
     byte[] buf = new byte[4];
     serialize(buf, 0);
     return LittleEndian.getInt(buf);
   }
 
   public boolean isEmpty()
   {
     return  == 0 &&  == 0 ||  == -1;
   }
 
   @Override
   public boolean equals(Object o)
   {
     if (!(o instanceof BorderCode)) return false;
     BorderCode brc = (BorderCode)o;
     return  == brc._info &&  == brc._info2;
   }
 
   @Override
   public int hashCode() {
       assert false : "hashCode not designed";
       return 42; // any arbitrary constant will do
   }
   
   public Object clone()
   {
     return super.clone();
   }
  
  
Width of a single line in 1/8 pt, max of 32 pt.
 
   public int getLineWidth() {
     return .getShortValue();
   }
   
   public void setLineWidth(int lineWidth) {
     .setValue(lineWidth);
  }

  
Border type code:
  • 0 none
  • 1 single
  • 2 thick
  • 3 double
  • 5 hairline
  • 6 dot
  • 7 dash large gap
  • 8 dot dash
  • 9 dot dot dash
  • 10 triple
  • 11 thin-thick small gap
  • 12 thick-thin small gap
  • 13 thin-thick-thin small gap
  • 14 thin-thick medium gap
  • 15 thick-thin medium gap
  • 16 thin-thick-thin medium gap
  • 17 thin-thick large gap
  • 18 thick-thin large gap
  • 19 thin-thick-thin large gap
  • 20 wave
  • 21 double wave
  • 22 dash small gap
  • 23 dash dot stroked
  • 24 emboss 3D
  • 25 engrave 3D
  • codes 64 - 230 represent border art types and are used only for page borders
  •   public int getBorderType() {
        return .getShortValue();
      }
      
      public void setBorderType(int borderType) {
        .setValue(borderType);
      }
      
      
    Color:
  • 0 Auto
  • 1 Black
  • 2 Blue
  • 3 Cyan
  • 4 Green
  • 5 Magenta
  • 6 Red
  • 7 Yellow
  • 8 White
  • 9 DkBlue
  • 10 DkCyan
  • 11 DkGreen
  • 12 DkMagenta
  • 13 DkRed
  • 14 DkYellow
  • 15 DkGray
  • 16 LtGray
  •   public short getColor() {
        return .getShortValue();
      }
      
      public void setColor(short color) {
        .setValue(color);
      }
      
      
    Width of space to maintain between border and text within border.

    Must be 0 when BRC is a substructure of TC.

    Stored in points.

      public int getSpace() {
      }
      
      public void setSpace(int space) {
        .setValue(space);
      }
      
      
    When true, border is drawn with shadow Must be false when BRC is a substructure of the TC.
      public boolean isShadow() {
        return .getValue() != 0;
      }
      
      public void setShadow(boolean shadow) {
        .setValue(shadow ? 1 : 0);
      }
      
      
    Don't reverse the border.
      public boolean isFrame() {
        return .getValue() != 0;
      }
      
      public void setFrame(boolean frame) {
        .setValue(frame ? 1 : 0);
      }
        @Override
        public String toString()
        {
            if ( isEmpty() )
                return "[BRC] EMPTY";
            StringBuffer buffer = new StringBuffer();
            buffer.append"[BRC]\n" );
            buffer.append"        .dptLineWidth         = " );
            buffer.append" (" ).appendgetLineWidth() ).append" )\n" );
            buffer.append"        .brcType              = " );
            buffer.append" (" ).appendgetBorderType() ).append" )\n" );
            buffer.append"        .ico                  = " );
            buffer.append" (" ).appendgetColor() ).append" )\n" );
            buffer.append"        .dptSpace             = " );
            buffer.append" (" ).appendgetSpace() ).append" )\n" );
            buffer.append"        .fShadow              = " );
            buffer.append" (" ).appendisShadow() ).append" )\n" );
            buffer.append"        .fFrame               = " );
            buffer.append" (" ).appendisFrame() ).append" )\n" );
            return buffer.toString();
        }
    New to GrepCode? Check out our FAQ X