Fixing compiler warnings - unnecessary typecasts

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@805284 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2009-08-18 05:29:53 +00:00
parent 995d8fe73f
commit c83d6bfa24
73 changed files with 3081 additions and 4444 deletions

View File

@ -238,7 +238,6 @@ public class AddDimensionedImage {
String imageFile, double reqImageWidthMM, double reqImageHeightMM,
int resizeBehaviour) throws FileNotFoundException, IOException,
IllegalArgumentException {
HSSFRow row = null;
HSSFClientAnchor anchor = null;
HSSFPatriarch patriarch = null;
ClientAnchorDetail rowClientAnchorDetail = null;
@ -485,7 +484,6 @@ public class AddDimensionedImage {
double colWidthMM = 0.0D;
double overlapMM = 0.0D;
double coordinatePositionsPerMM = 0.0D;
int fromNumber = startingColumn;
int toColumn = startingColumn;
int inset = 0;
@ -706,8 +704,6 @@ public class AddDimensionedImage {
* @param args the command line arguments
*/
public static void main(String[] args) {
File file = null;
FileInputStream fis = null;
FileOutputStream fos = null;
HSSFWorkbook workbook = null;
HSSFSheet sheet = null;
@ -892,7 +888,7 @@ public class AddDimensionedImage {
int pixels = (widthUnits / EXCEL_COLUMN_WIDTH_FACTOR)
* UNIT_OFFSET_LENGTH;
int offsetWidthUnits = widthUnits % EXCEL_COLUMN_WIDTH_FACTOR;
pixels += Math.round((float) offsetWidthUnits /
pixels += Math.round(offsetWidthUnits /
((float) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH));
return pixels;
}

View File

@ -211,10 +211,10 @@ public class Util
* @return <code>true</code> if the collections are equal, else
* <code>false</code>.
*/
public static boolean equals(final Collection c1, final Collection c2)
public static boolean equals(Collection<?> c1, Collection<?> c2)
{
final Object[] o1 = c1.toArray();
final Object[] o2 = c2.toArray();
Object[] o1 = c1.toArray();
Object[] o2 = c2.toArray();
return internalEquals(o1, o2);
}
@ -229,14 +229,14 @@ public class Util
* @return <code>true</code> if the object arrays are equal,
* <code>false</code> if they are not.
*/
public static boolean equals(final Object[] c1, final Object[] c2)
public static boolean equals(Object[] c1, Object[] c2)
{
final Object[] o1 = (Object[]) c1.clone();
final Object[] o2 = (Object[]) c2.clone();
final Object[] o1 = c1.clone();
final Object[] o2 = c2.clone();
return internalEquals(o1, o2);
}
private static boolean internalEquals(final Object[] o1, final Object[] o2)
private static boolean internalEquals(Object[] o1, Object[] o2)
{
for (int i1 = 0; i1 < o1.length; i1++)
{

View File

@ -49,7 +49,7 @@ public final class EventRecordFactory {
if (sids == null) {
_sids = null;
} else {
_sids = (short[]) sids.clone();
_sids = sids.clone();
Arrays.sort(_sids); // for faster binary search
}
}

View File

@ -84,7 +84,7 @@ final class LinkTable {
_crns = crns;
}
public CRNRecord[] getCrns() {
return (CRNRecord[]) _crns.clone();
return _crns.clone();
}
}
@ -95,7 +95,7 @@ final class LinkTable {
public ExternalBookBlock(RecordStream rs) {
_externalBookRecord = (SupBookRecord) rs.getNext();
List temp = new ArrayList();
List<Object> temp = new ArrayList<Object>();
while(rs.peekNextClass() == ExternalNameRecord.class) {
temp.add(rs.getNext());
}
@ -141,7 +141,7 @@ final class LinkTable {
private final ExternalBookBlock[] _externalBookBlocks;
private final ExternSheetRecord _externSheetRecord;
private final List _definedNames;
private final List<NameRecord> _definedNames;
private final int _recordCount;
private final WorkbookRecordList _workbookRecordList; // TODO - would be nice to remove this
@ -150,7 +150,7 @@ final class LinkTable {
_workbookRecordList = workbookRecordList;
RecordStream rs = new RecordStream(inputList, startIndex);
List temp = new ArrayList();
List<ExternalBookBlock> temp = new ArrayList<ExternalBookBlock>();
while(rs.peekNextClass() == SupBookRecord.class) {
temp.add(new ExternalBookBlock(rs));
}
@ -171,7 +171,7 @@ final class LinkTable {
_externSheetRecord = null;
}
_definedNames = new ArrayList();
_definedNames = new ArrayList<NameRecord>();
// collect zero or more DEFINEDNAMEs id=0x18
while(rs.peekNextClass() == NameRecord.class) {
NameRecord nr = (NameRecord)rs.getNext();
@ -183,9 +183,9 @@ final class LinkTable {
}
private static ExternSheetRecord readExtSheetRecord(RecordStream rs) {
List temp = new ArrayList(2);
List<ExternSheetRecord> temp = new ArrayList<ExternSheetRecord>(2);
while(rs.peekNextClass() == ExternSheetRecord.class) {
temp.add(rs.getNext());
temp.add((ExternSheetRecord) rs.getNext());
}
int nItems = temp.size();
@ -195,7 +195,7 @@ final class LinkTable {
}
if (nItems == 1) {
// this is the normal case. There should be just one ExternSheetRecord
return (ExternSheetRecord) temp.get(0);
return temp.get(0);
}
// Some apps generate multiple ExternSheetRecords (see bug 45698).
// It seems like the best thing to do might be to combine these into one
@ -206,7 +206,7 @@ final class LinkTable {
public LinkTable(int numberOfSheets, WorkbookRecordList workbookRecordList) {
_workbookRecordList = workbookRecordList;
_definedNames = new ArrayList();
_definedNames = new ArrayList<NameRecord>();
_externalBookBlocks = new ExternalBookBlock[] {
new ExternalBookBlock(numberOfSheets),
};
@ -267,7 +267,7 @@ final class LinkTable {
}
public NameRecord getNameRecord(int index) {
return (NameRecord) _definedNames.get(index);
return _definedNames.get(index);
}
public void addName(NameRecord name) {

View File

@ -465,7 +465,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
pos += temp;
// Write the matching OBJ record
Record obj = (Record) shapeToObj.get( shapes.get( i ) );
Record obj = shapeToObj.get( shapes.get( i ) );
temp = obj.serialize( pos, data );
pos += temp;
@ -552,8 +552,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
if(topContainer == null) {
return;
}
topContainer = (EscherContainerRecord)
topContainer.getChildContainers().get(0);
topContainer = topContainer.getChildContainers().get(0);
List tcc = topContainer.getChildContainers();
if(tcc.size() == 0) {

View File

@ -68,9 +68,6 @@ public final class SSTRecord extends ContinuableRecord {
/** Offsets relative the start of the current SST or continue record */
int[] bucketRelativeOffsets;
/**
* default constructor
*/
public SSTRecord()
{
field_1_num_strings = 0;
@ -86,8 +83,7 @@ public final class SSTRecord extends ContinuableRecord {
*
* @return the index of that string in the table
*/
public int addString( final UnicodeString string )
public int addString(UnicodeString string)
{
field_1_num_strings++;
UnicodeString ucs = ( string == null ) ? EMPTY_STRING
@ -95,12 +91,9 @@ public final class SSTRecord extends ContinuableRecord {
int rval;
int index = field_3_strings.getIndex(ucs);
if ( index != -1 )
{
if ( index != -1 ) {
rval = index;
}
else
{
} else {
// This is a new string -- we didn't see it among the
// strings we've already collected
rval = field_3_strings.size();
@ -113,7 +106,6 @@ public final class SSTRecord extends ContinuableRecord {
/**
* @return number of strings
*/
public int getNumStrings()
{
return field_1_num_strings;
@ -122,7 +114,6 @@ public final class SSTRecord extends ContinuableRecord {
/**
* @return number of unique strings
*/
public int getNumUniqueStrings()
{
return field_2_num_unique_strings;
@ -136,8 +127,7 @@ public final class SSTRecord extends ContinuableRecord {
*
* @return the desired string
*/
public UnicodeString getString( final int id )
public UnicodeString getString(int id )
{
return (UnicodeString) field_3_strings.get( id );
}
@ -148,9 +138,7 @@ public final class SSTRecord extends ContinuableRecord {
*
* @return string representation
*/
public String toString()
{
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append( "[SST]\n" );
@ -168,11 +156,7 @@ public final class SSTRecord extends ContinuableRecord {
return buffer.toString();
}
/**
* @return sid
*/
public short getSid()
{
public short getSid() {
return sid;
}
@ -254,9 +238,7 @@ public final class SSTRecord extends ContinuableRecord {
*
* @param in the RecordInputstream to read the record from
*/
public SSTRecord( RecordInputStream in )
{
public SSTRecord(RecordInputStream in) {
// this method is ALWAYS called after construction -- using
// the nontrivial constructor, of course -- so this is where
// we initialize our fields
@ -272,7 +254,6 @@ public final class SSTRecord extends ContinuableRecord {
* @return an iterator of the strings we hold. All instances are
* UnicodeStrings
*/
Iterator getStrings()
{
return field_3_strings.iterator();
@ -281,9 +262,7 @@ public final class SSTRecord extends ContinuableRecord {
/**
* @return count of the strings we hold.
*/
int countStrings()
{
int countStrings() {
return field_3_strings.size();
}
@ -294,8 +273,7 @@ public final class SSTRecord extends ContinuableRecord {
bucketRelativeOffsets = serializer.getBucketRelativeOffsets();
}
SSTDeserializer getDeserializer()
{
SSTDeserializer getDeserializer() {
return deserializer;
}
@ -312,15 +290,14 @@ public final class SSTRecord extends ContinuableRecord {
* SST record.
* @return The new SST record.
*/
public ExtSSTRecord createExtSSTRecord(int sstOffset)
{
public ExtSSTRecord createExtSSTRecord(int sstOffset) {
if (bucketAbsoluteOffsets == null || bucketAbsoluteOffsets == null)
throw new IllegalStateException("SST record has not yet been serialized.");
ExtSSTRecord extSST = new ExtSSTRecord();
extSST.setNumStringsPerBucket((short)8);
int[] absoluteOffsets = (int[]) bucketAbsoluteOffsets.clone();
int[] relativeOffsets = (int[]) bucketRelativeOffsets.clone();
int[] absoluteOffsets = bucketAbsoluteOffsets.clone();
int[] relativeOffsets = bucketRelativeOffsets.clone();
for ( int i = 0; i < absoluteOffsets.length; i++ )
absoluteOffsets[i] += sstOffset;
extSST.setBucketOffsets(absoluteOffsets, relativeOffsets);
@ -333,8 +310,7 @@ public final class SSTRecord extends ContinuableRecord {
*
* @return The size of the ExtSST record in bytes.
*/
public int calcExtSSTRecordSize()
{
public int calcExtSSTRecordSize() {
return ExtSSTRecord.getRecordSizeForStrings(field_3_strings.size());
}
}

View File

@ -543,7 +543,7 @@ public final class FontFormatting
public Object clone()
{
byte[] rawData = (byte[]) _rawData.clone();
byte[] rawData = _rawData.clone();
return new FontFormatting(rawData);
}
}

View File

@ -53,10 +53,7 @@ public final class OperandResolver {
if (result instanceof ErrorEval) {
throw new EvaluationException((ErrorEval) result);
}
if (result instanceof ValueEval) {
return (ValueEval) result;
}
throw new RuntimeException("Unexpected eval type (" + result.getClass().getName() + ")");
return result;
}
/**

View File

@ -283,7 +283,7 @@ public class EscherGraphics
excelFont = new Font( font.getName(), font.getStyle(), (int) ( font.getSize() / verticalPixelsPerPoint ));
}
FontDetails d = StaticFontMetrics.getFontDetails( excelFont );
int width = (int) ( (d.getStringWidth( str ) * 8) + 12 );
int width = d.getStringWidth( str ) * 8 + 12;
int height = (int) ( ( font.getSize() / verticalPixelsPerPoint ) + 6 ) * 2;
y -= ( font.getSize() / verticalPixelsPerPoint ) + 2 * verticalPixelsPerPoint; // we want to draw the shape from the top-left
HSSFTextbox textbox = escherGroup.createTextbox( new HSSFChildAnchor( x, y, x + width, y + height ) );
@ -454,7 +454,7 @@ public class EscherGraphics
public void setClip(int x, int y, int width, int height)
{
setClip(((Shape) (new Rectangle(x,y,width,height))));
setClip(new Rectangle(x,y,width,height));
}
public void setClip(Shape shape)

View File

@ -70,14 +70,13 @@ import java.util.Map;
*
* @author Glen Stampoultzis (glens at apache.org)
*/
public class EscherGraphics2d extends Graphics2D
{
private EscherGraphics escherGraphics;
private BufferedImage img;
private AffineTransform trans;
private Stroke stroke;
private Paint paint;
private Shape deviceclip;
public final class EscherGraphics2d extends Graphics2D {
private EscherGraphics _escherGraphics;
private BufferedImage _img;
private AffineTransform _trans;
private Stroke _stroke;
private Paint _paint;
private Shape _deviceclip;
private POILogger logger = POILogFactory.getLogger(getClass());
/**
@ -87,7 +86,7 @@ public class EscherGraphics2d extends Graphics2D
*/
public EscherGraphics2d(EscherGraphics escherGraphics)
{
this.escherGraphics = escherGraphics;
this._escherGraphics = escherGraphics;
setImg( new BufferedImage(1, 1, 2) );
setColor(Color.black);
}
@ -130,7 +129,7 @@ public class EscherGraphics2d extends Graphics2D
public Graphics create()
{
EscherGraphics2d g2d = new EscherGraphics2d(escherGraphics);
EscherGraphics2d g2d = new EscherGraphics2d(_escherGraphics);
return g2d;
}
@ -148,8 +147,8 @@ public class EscherGraphics2d extends Graphics2D
Line2D shape2d = (Line2D) shape;
int width = 0;
if (stroke != null && stroke instanceof BasicStroke) {
width = (int) ((BasicStroke)stroke).getLineWidth() * 12700;
if (_stroke != null && _stroke instanceof BasicStroke) {
width = (int) ((BasicStroke)_stroke).getLineWidth() * 12700;
}
drawLine((int)shape2d.getX1(), (int)shape2d.getY1(), (int)shape2d.getX2(), (int)shape2d.getY2(), width);
@ -223,7 +222,7 @@ public class EscherGraphics2d extends Graphics2D
public void drawImage(BufferedImage bufferedimage, BufferedImageOp op, int x, int y)
{
BufferedImage img = op.filter(bufferedimage, null);
drawImage(((Image) (img)), new AffineTransform(1.0F, 0.0F, 0.0F, 1.0F, x, y), null);
drawImage(img, new AffineTransform(1.0F, 0.0F, 0.0F, 1.0F, x, y), null);
}
public void drawLine(int x1, int y1, int x2, int y2, int width)
@ -234,8 +233,8 @@ public class EscherGraphics2d extends Graphics2D
public void drawLine(int x1, int y1, int x2, int y2)
{
int width = 0;
if (stroke != null && stroke instanceof BasicStroke) {
width = (int) ((BasicStroke)stroke).getLineWidth() * 12700;
if (_stroke != null && _stroke instanceof BasicStroke) {
width = (int) ((BasicStroke)_stroke).getLineWidth() * 12700;
}
getEscherGraphics().drawLine(x1,y1,x2,y2, width);
// draw(new GeneralPath(new java.awt.geom.Line2D.Float(x1, y1, x2, y2)));
@ -268,7 +267,7 @@ public class EscherGraphics2d extends Graphics2D
public void drawRect(int x, int y, int width, int height)
{
escherGraphics.drawRect(x,y,width,height);
_escherGraphics.drawRect(x,y,width,height);
}
public void drawRenderableImage(RenderableImage renderableimage, AffineTransform affinetransform)
@ -325,7 +324,7 @@ public class EscherGraphics2d extends Graphics2D
public void fillOval(int x, int y, int width, int height)
{
escherGraphics.fillOval(x,y,width,height);
_escherGraphics.fillOval(x,y,width,height);
}
/**
@ -349,7 +348,7 @@ public class EscherGraphics2d extends Graphics2D
*/
public void fillPolygon(int xPoints[], int yPoints[], int nPoints)
{
escherGraphics.fillPolygon(xPoints, yPoints, nPoints);
_escherGraphics.fillPolygon(xPoints, yPoints, nPoints);
}
public void fillRect(int x, int y, int width, int height)
@ -382,15 +381,15 @@ public class EscherGraphics2d extends Graphics2D
public Rectangle getClipBounds()
{
if(getDeviceclip() != null)
if(getDeviceclip() != null) {
return getClip().getBounds();
else
}
return null;
}
public Color getColor()
{
return escherGraphics.getColor();
return _escherGraphics.getColor();
}
public Composite getComposite()
@ -421,7 +420,7 @@ public class EscherGraphics2d extends Graphics2D
public Paint getPaint()
{
return paint;
return _paint;
}
public Object getRenderingHint(java.awt.RenderingHints.Key key)
@ -436,7 +435,7 @@ public class EscherGraphics2d extends Graphics2D
public Stroke getStroke()
{
return stroke;
return _stroke;
}
public AffineTransform getTransform()
@ -474,7 +473,7 @@ public class EscherGraphics2d extends Graphics2D
public void setClip(int i, int j, int k, int l)
{
setClip(((Shape) (new Rectangle(i, j, k, l))));
setClip(new Rectangle(i, j, k, l));
}
public void setClip(Shape shape)
@ -484,7 +483,7 @@ public class EscherGraphics2d extends Graphics2D
public void setColor(Color c)
{
escherGraphics.setColor(c);
_escherGraphics.setColor(c);
}
public void setComposite(Composite composite)
@ -501,7 +500,7 @@ public class EscherGraphics2d extends Graphics2D
{
if(paint1 != null)
{
paint = paint1;
_paint = paint1;
if(paint1 instanceof Color)
setColor( (Color)paint1 );
}
@ -524,7 +523,7 @@ public class EscherGraphics2d extends Graphics2D
public void setStroke(Stroke s)
{
stroke = s;
_stroke = s;
}
public void setTransform(AffineTransform affinetransform)
@ -571,42 +570,42 @@ public class EscherGraphics2d extends Graphics2D
private EscherGraphics getEscherGraphics()
{
return escherGraphics;
return _escherGraphics;
}
private BufferedImage getImg()
{
return img;
return _img;
}
private void setImg( BufferedImage img )
{
this.img = img;
this._img = img;
}
private Graphics2D getG2D()
{
return (Graphics2D) img.getGraphics();
return (Graphics2D) _img.getGraphics();
}
private AffineTransform getTrans()
{
return trans;
return _trans;
}
private void setTrans( AffineTransform trans )
{
this.trans = trans;
this._trans = trans;
}
private Shape getDeviceclip()
{
return deviceclip;
return _deviceclip;
}
private void setDeviceclip( Shape deviceclip )
{
this.deviceclip = deviceclip;
this._deviceclip = deviceclip;
}
}

View File

@ -28,13 +28,12 @@ import org.apache.poi.hssf.util.HSSFColor;
*
* @author Brian Sanders (bsanders at risklabs dot com)
*/
public class HSSFPalette
{
private PaletteRecord palette;
public final class HSSFPalette {
private PaletteRecord _palette;
protected HSSFPalette(PaletteRecord palette)
{
this.palette = palette;
_palette = palette;
}
/**
@ -46,15 +45,14 @@ public class HSSFPalette
public HSSFColor getColor(short index)
{
//Handle the special AUTOMATIC case
if (index == HSSFColor.AUTOMATIC.index)
if (index == HSSFColor.AUTOMATIC.index) {
return HSSFColor.AUTOMATIC.getInstance();
else {
byte[] b = palette.getColor(index);
}
byte[] b = _palette.getColor(index);
if (b != null)
{
return new CustomColor(index, b);
}
}
return null;
}
/**
@ -77,9 +75,9 @@ public class HSSFPalette
*/
public HSSFColor findColor(byte red, byte green, byte blue)
{
byte[] b = palette.getColor(PaletteRecord.FIRST_COLOR_INDEX);
for (short i = (short) PaletteRecord.FIRST_COLOR_INDEX; b != null;
b = palette.getColor(++i))
byte[] b = _palette.getColor(PaletteRecord.FIRST_COLOR_INDEX);
for (short i = PaletteRecord.FIRST_COLOR_INDEX; b != null;
b = _palette.getColor(++i))
{
if (b[0] == red && b[1] == green && b[2] == blue)
{
@ -104,9 +102,9 @@ public class HSSFPalette
{
HSSFColor result = null;
int minColorDistance = Integer.MAX_VALUE;
byte[] b = palette.getColor(PaletteRecord.FIRST_COLOR_INDEX);
for (short i = (short) PaletteRecord.FIRST_COLOR_INDEX; b != null;
b = palette.getColor(++i))
byte[] b = _palette.getColor(PaletteRecord.FIRST_COLOR_INDEX);
for (short i = PaletteRecord.FIRST_COLOR_INDEX; b != null;
b = _palette.getColor(++i))
{
int colorDistance = Math.abs(red - b[0]) +
Math.abs(green - b[1]) + Math.abs(blue - b[2]);
@ -129,7 +127,7 @@ public class HSSFPalette
*/
public void setColorAtIndex(short index, byte red, byte green, byte blue)
{
palette.setColor(index, red, green, blue);
_palette.setColor(index, red, green, blue);
}
/**
@ -144,9 +142,9 @@ public class HSSFPalette
*/
public HSSFColor addColor( byte red, byte green, byte blue )
{
byte[] b = palette.getColor(PaletteRecord.FIRST_COLOR_INDEX);
byte[] b = _palette.getColor(PaletteRecord.FIRST_COLOR_INDEX);
short i;
for (i = (short) PaletteRecord.FIRST_COLOR_INDEX; i < PaletteRecord.STANDARD_PALETTE_SIZE + PaletteRecord.FIRST_COLOR_INDEX; b = palette.getColor(++i))
for (i = PaletteRecord.FIRST_COLOR_INDEX; i < PaletteRecord.STANDARD_PALETTE_SIZE + PaletteRecord.FIRST_COLOR_INDEX; b = _palette.getColor(++i))
{
if (b == null)
{
@ -157,49 +155,48 @@ public class HSSFPalette
throw new RuntimeException("Could not find free color index");
}
private static class CustomColor extends HSSFColor
{
private short byteOffset;
private byte red;
private byte green;
private byte blue;
private static final class CustomColor extends HSSFColor {
private short _byteOffset;
private byte _red;
private byte _green;
private byte _blue;
private CustomColor(short byteOffset, byte[] colors)
public CustomColor(short byteOffset, byte[] colors)
{
this(byteOffset, colors[0], colors[1], colors[2]);
}
private CustomColor(short byteOffset, byte red, byte green, byte blue)
{
this.byteOffset = byteOffset;
this.red = red;
this.green = green;
this.blue = blue;
_byteOffset = byteOffset;
_red = red;
_green = green;
_blue = blue;
}
public short getIndex()
{
return byteOffset;
return _byteOffset;
}
public short[] getTriplet()
{
return new short[]
{
(short) (red & 0xff),
(short) (green & 0xff),
(short) (blue & 0xff)
(short) (_red & 0xff),
(short) (_green & 0xff),
(short) (_blue & 0xff)
};
}
public String getHexString()
{
StringBuffer sb = new StringBuffer();
sb.append(getGnumericPart(red));
sb.append(getGnumericPart(_red));
sb.append(':');
sb.append(getGnumericPart(green));
sb.append(getGnumericPart(_green));
sb.append(':');
sb.append(getGnumericPart(blue));
sb.append(getGnumericPart(_blue));
return sb.toString();
}

View File

@ -1136,7 +1136,7 @@ public class HSSFWorkbook extends POIDocument implements org.apache.poi.ss.userm
*/
public HSSFCellStyle getCellStyleAt(short idx)
{
ExtendedFormatRecord xfr = workbook.getExFormatAt((int)idx);
ExtendedFormatRecord xfr = workbook.getExFormatAt(idx);
HSSFCellStyle style = new HSSFCellStyle(idx, xfr, this);
return style;

View File

@ -27,19 +27,16 @@ package org.apache.poi.hssf.util;
* @see org.apache.poi.hssf.record.MulRKRecord
* @see org.apache.poi.hssf.record.RKRecord
*/
public class RKUtil
{
private RKUtil()
{
public final class RKUtil {
private RKUtil() {
// no instances of this class
}
/**
* Do the dirty work of decoding; made a private static method to
* facilitate testing the algorithm
*/
public static double decodeNumber(int number)
{
public static double decodeNumber(int number) {
long raw_number = number;
// mask off the two low-order bits, 'cause they're not part of
@ -51,7 +48,7 @@ public class RKUtil
{
// ok, it's just a plain ol' int; we can handle this
// trivially by casting
rvalue = ( double ) (raw_number);
rvalue = raw_number;
}
else
{
@ -72,5 +69,4 @@ public class RKUtil
return rvalue;
}
}

View File

@ -127,7 +127,7 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView
* @param stream the InputStream we read data from
*/
public POIFSDocument(String name, InputStream stream) throws IOException {
List blocks = new ArrayList();
List<DocumentBlock> blocks = new ArrayList<DocumentBlock>();
_size = 0;
while (true) {
@ -142,7 +142,7 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView
break;
}
}
DocumentBlock[] bigBlocks = (DocumentBlock[]) blocks.toArray(new DocumentBlock[blocks.size()]);
DocumentBlock[] bigBlocks = blocks.toArray(new DocumentBlock[blocks.size()]);
_big_store = new BigBlockStore(bigBlocks);
_property = new DocumentProperty(name, _size);
@ -249,9 +249,8 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView
}
if (_property.shouldUseSmallBlocks()) {
return SmallDocumentBlock.getDataInputBlock(_small_store.getBlocks(), offset);
} else {
return DocumentBlock.getDataInputBlock(_big_store.getBlocks(), offset);
}
return DocumentBlock.getDataInputBlock(_big_store.getBlocks(), offset);
}
/**
@ -377,11 +376,11 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView
/* ********** END begin implementation of POIFSViewable ********** */
private static final class SmallBlockStore {
private SmallDocumentBlock[] smallBlocks;
private final POIFSDocumentPath path;
private final String name;
private final int size;
private final POIFSWriterListener writer;
private SmallDocumentBlock[] _smallBlocks;
private final POIFSDocumentPath _path;
private final String _name;
private final int _size;
private final POIFSWriterListener _writer;
/**
* Constructor
@ -389,11 +388,11 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView
* @param blocks blocks to construct the store from
*/
SmallBlockStore(SmallDocumentBlock[] blocks) {
smallBlocks = (SmallDocumentBlock[]) blocks.clone();
this.path = null;
this.name = null;
this.size = -1;
this.writer = null;
_smallBlocks = blocks.clone();
this._path = null;
this._name = null;
this._size = -1;
this._writer = null;
}
/**
@ -405,41 +404,41 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView
* @param writer the object that will eventually write the document
*/
SmallBlockStore(POIFSDocumentPath path, String name, int size, POIFSWriterListener writer) {
smallBlocks = new SmallDocumentBlock[0];
this.path = path;
this.name = name;
this.size = size;
this.writer = writer;
_smallBlocks = new SmallDocumentBlock[0];
this._path = path;
this._name = name;
this._size = size;
this._writer = writer;
}
/**
* @return <code>true</code> if this store is a valid source of data
*/
boolean isValid() {
return smallBlocks.length > 0 || writer != null;
return _smallBlocks.length > 0 || _writer != null;
}
/**
* @return the SmallDocumentBlocks
*/
SmallDocumentBlock[] getBlocks() {
if (isValid() && writer != null) {
ByteArrayOutputStream stream = new ByteArrayOutputStream(size);
DocumentOutputStream dstream = new DocumentOutputStream(stream, size);
if (isValid() && _writer != null) {
ByteArrayOutputStream stream = new ByteArrayOutputStream(_size);
DocumentOutputStream dstream = new DocumentOutputStream(stream, _size);
writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, path, name, size));
smallBlocks = SmallDocumentBlock.convert(stream.toByteArray(), size);
_writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, _path, _name, _size));
_smallBlocks = SmallDocumentBlock.convert(stream.toByteArray(), _size);
}
return smallBlocks;
return _smallBlocks;
}
} // end private class SmallBlockStore
private static final class BigBlockStore {
private DocumentBlock[] bigBlocks;
private final POIFSDocumentPath path;
private final String name;
private final int size;
private final POIFSWriterListener writer;
private final POIFSDocumentPath _path;
private final String _name;
private final int _size;
private final POIFSWriterListener _writer;
/**
* Constructor
@ -447,11 +446,11 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView
* @param blocks the blocks making up the store
*/
BigBlockStore(DocumentBlock[] blocks) {
bigBlocks = (DocumentBlock[]) blocks.clone();
this.path = null;
this.name = null;
this.size = -1;
this.writer = null;
bigBlocks = blocks.clone();
_path = null;
_name = null;
_size = -1;
_writer = null;
}
/**
@ -464,29 +463,29 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView
*/
BigBlockStore(POIFSDocumentPath path, String name, int size, POIFSWriterListener writer) {
bigBlocks = new DocumentBlock[0];
this.path = path;
this.name = name;
this.size = size;
this.writer = writer;
_path = path;
_name = name;
_size = size;
_writer = writer;
}
/**
* @return <code>true</code> if this store is a valid source of data
*/
boolean isValid() {
return bigBlocks.length > 0 || writer != null;
return bigBlocks.length > 0 || _writer != null;
}
/**
* @return the DocumentBlocks
*/
DocumentBlock[] getBlocks() {
if (isValid() && writer != null) {
ByteArrayOutputStream stream = new ByteArrayOutputStream(size);
DocumentOutputStream dstream = new DocumentOutputStream(stream, size);
if (isValid() && _writer != null) {
ByteArrayOutputStream stream = new ByteArrayOutputStream(_size);
DocumentOutputStream dstream = new DocumentOutputStream(stream, _size);
writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, path, name, size));
bigBlocks = DocumentBlock.convert(stream.toByteArray(), size);
_writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, _path, _name, _size));
bigBlocks = DocumentBlock.convert(stream.toByteArray(), _size);
}
return bigBlocks;
}
@ -498,10 +497,10 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView
*/
void writeBlocks(OutputStream stream) throws IOException {
if (isValid()) {
if (writer != null) {
DocumentOutputStream dstream = new DocumentOutputStream(stream, size);
if (_writer != null) {
DocumentOutputStream dstream = new DocumentOutputStream(stream, _size);
writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, path, name, size));
_writer.processPOIFSWriterEvent(new POIFSWriterEvent(dstream, _path, _name, _size));
dstream.writeFiller(countBlocks() * POIFSConstants.BIG_BLOCK_SIZE,
DocumentBlock.getFillByte());
} else {
@ -518,10 +517,10 @@ public final class POIFSDocument implements BATManaged, BlockWritable, POIFSView
int countBlocks() {
if (isValid()) {
if (writer == null) {
if (_writer == null) {
return bigBlocks.length;
}
return (size + POIFSConstants.BIG_BLOCK_SIZE - 1)
return (_size + POIFSConstants.BIG_BLOCK_SIZE - 1)
/ POIFSConstants.BIG_BLOCK_SIZE;
}
return 0;

View File

@ -39,9 +39,7 @@ import org.apache.poi.util.ShortField;
* @author Marc Johnson (mjohnson at apache dot org)
*/
public abstract class Property
implements Child, POIFSViewable
{
public abstract class Property implements Child, POIFSViewable {
static final private byte _default_fill = ( byte ) 0x00;
static final private int _name_size_offset = 0x40;
static final private int _max_name_length =
@ -88,10 +86,6 @@ public abstract class Property
private Child _next_child;
private Child _previous_child;
/**
* Default constructor
*/
protected Property()
{
_raw_data = new byte[ POIFSConstants.PROPERTY_SIZE ];
@ -129,8 +123,7 @@ public abstract class Property
* @param array byte data
* @param offset offset into byte data
*/
protected Property(final int index, final byte [] array, final int offset)
protected Property(int index, byte [] array, int offset)
{
_raw_data = new byte[ POIFSConstants.PROPERTY_SIZE ];
System.arraycopy(array, offset, _raw_data, 0,
@ -187,8 +180,7 @@ public abstract class Property
* @exception IOException on problems writing to the specified
* stream.
*/
public void writeData(final OutputStream stream)
public void writeData(OutputStream stream)
throws IOException
{
stream.write(_raw_data);
@ -200,8 +192,7 @@ public abstract class Property
*
* @param startBlock the start block index
*/
public void setStartBlock(final int startBlock)
public void setStartBlock(int startBlock)
{
_start_block.set(startBlock, _raw_data);
}
@ -209,7 +200,6 @@ public abstract class Property
/**
* @return the start block
*/
public int getStartBlock()
{
return _start_block.get();
@ -220,7 +210,6 @@ public abstract class Property
*
* @return size in bytes
*/
public int getSize()
{
return _size.get();
@ -232,7 +221,6 @@ public abstract class Property
*
* @return true if the size is less than _big_block_minimum_bytes
*/
public boolean shouldUseSmallBlocks()
{
return Property.isSmall(_size.get());
@ -246,8 +234,7 @@ public abstract class Property
* @return true if the length is less than
* _big_block_minimum_bytes
*/
public static boolean isSmall(final int length)
public static boolean isSmall(int length)
{
return length < _big_block_minimum_bytes;
}
@ -257,7 +244,6 @@ public abstract class Property
*
* @return property name as String
*/
public String getName()
{
return _name;
@ -266,7 +252,6 @@ public abstract class Property
/**
* @return true if a directory type Property
*/
abstract public boolean isDirectory();
/**
@ -284,7 +269,7 @@ public abstract class Property
*
* @param name the new name
*/
protected final void setName(final String name)
protected void setName(String name)
{
char[] char_array = name.toCharArray();
int limit = Math.min(char_array.length, _max_name_length);
@ -329,8 +314,7 @@ public abstract class Property
*
* @param propertyType the property type (root, file, directory)
*/
protected void setPropertyType(final byte propertyType)
protected void setPropertyType(byte propertyType)
{
_property_type.set(propertyType, _raw_data);
}
@ -340,8 +324,7 @@ public abstract class Property
*
* @param nodeColor the node color (red or black)
*/
protected void setNodeColor(final byte nodeColor)
protected void setNodeColor(byte nodeColor)
{
_node_color.set(nodeColor, _raw_data);
}
@ -351,8 +334,7 @@ public abstract class Property
*
* @param child the child property's index in the Property Table
*/
protected void setChildProperty(final int child)
protected void setChildProperty(int child)
{
_child_property.set(child, _raw_data);
}
@ -362,7 +344,6 @@ public abstract class Property
*
* @return child property index
*/
protected int getChildIndex()
{
return _child_property.get();
@ -373,8 +354,7 @@ public abstract class Property
*
* @param size the size of the document, in bytes
*/
protected void setSize(final int size)
protected void setSize(int size)
{
_size.set(size, _raw_data);
}
@ -385,8 +365,7 @@ public abstract class Property
* @param index this Property's index within its containing
* Property Table
*/
protected void setIndex(final int index)
protected void setIndex(int index)
{
_index = index;
}
@ -396,7 +375,6 @@ public abstract class Property
*
* @return the index of this Property within its Property Table
*/
protected int getIndex()
{
return _index;
@ -406,7 +384,6 @@ public abstract class Property
* Perform whatever activities need to be performed prior to
* writing
*/
abstract protected void preWrite();
/**
@ -414,7 +391,6 @@ public abstract class Property
*
* @return index of next sibling
*/
int getNextChildIndex()
{
return _next_property.get();
@ -425,7 +401,6 @@ public abstract class Property
*
* @return index of previous sibling
*/
int getPreviousChildIndex()
{
return _previous_property.get();
@ -438,20 +413,16 @@ public abstract class Property
*
* @return true if the index is valid
*/
static boolean isValidIndex(int index)
{
return index != _NO_INDEX;
}
/* ********** START implementation of Child ********** */
/**
* Get the next Child, if any
*
* @return the next Child; may return null
*/
public Child getNextChild()
{
return _next_child;
@ -462,7 +433,6 @@ public abstract class Property
*
* @return the previous Child; may return null
*/
public Child getPreviousChild()
{
return _previous_child;
@ -474,8 +444,7 @@ public abstract class Property
* @param child the new 'next' child; may be null, which has the
* effect of saying there is no 'next' child
*/
public void setNextChild(final Child child)
public void setNextChild(Child child)
{
_next_child = child;
_next_property.set((child == null) ? _NO_INDEX
@ -489,8 +458,7 @@ public abstract class Property
* @param child the new 'previous' child; may be null, which has
* the effect of saying there is no 'previous' child
*/
public void setPreviousChild(final Child child)
public void setPreviousChild(Child child)
{
_previous_child = child;
_previous_property.set((child == null) ? _NO_INDEX
@ -498,16 +466,12 @@ public abstract class Property
.getIndex(), _raw_data);
}
/* ********** END implementation of Child ********** */
/* ********** START begin implementation of POIFSViewable ********** */
/**
* Get an array of objects, some of which may implement
* POIFSViewable
*
* @return an array of Object; may not be null, but may be empty
*/
public Object [] getViewableArray()
{
Object[] results = new Object[ 5 ];
@ -518,11 +482,11 @@ public abstract class Property
long time = _days_1.get();
time <<= 32;
time += (( long ) _seconds_1.get()) & 0x0000FFFFL;
time += _seconds_1.get() & 0x0000FFFFL;
results[ 3 ] = "Time 1 = " + time;
time = _days_2.get();
time <<= 32;
time += (( long ) _seconds_2.get()) & 0x0000FFFFL;
time += _seconds_2.get() & 0x0000FFFFL;
results[ 4 ] = "Time 2 = " + time;
return results;
}
@ -534,7 +498,6 @@ public abstract class Property
* @return an Iterator; may not be null, but may have an empty
* back end store
*/
public Iterator getViewableIterator()
{
return Collections.EMPTY_LIST.iterator();
@ -547,7 +510,6 @@ public abstract class Property
* @return true if a viewer should call getViewableArray, false if
* a viewer should call getViewableIterator
*/
public boolean preferArray()
{
return true;
@ -559,7 +521,6 @@ public abstract class Property
*
* @return short description
*/
public String getShortDescription()
{
StringBuffer buffer = new StringBuffer();
@ -567,7 +528,4 @@ public abstract class Property
buffer.append("Property: \"").append(getName()).append("\"");
return buffer.toString();
}
/* ********** END begin implementation of POIFSViewable ********** */
} // end public abstract class Property
}

View File

@ -393,8 +393,7 @@ public final class WorkbookEvaluator {
return fe.getFreeRefFunction().evaluate(ops, workbook, sheetIndex, srcRowNum, srcColNum);
}
}
// TODO - fix return type of this evaluate method:
return (ValueEval) operation.evaluate(ops, srcRowNum, (short)srcColNum);
return operation.evaluate(ops, srcRowNum, (short)srcColNum);
}
private SheetRefEvaluator createExternSheetRefEvaluator(EvaluationTracker tracker,
ExternSheetReferenceToken ptg) {

View File

@ -26,35 +26,34 @@ package org.apache.poi.ss.util;
* @author Andrew C. Oliver acoliver at apache dot org
* @deprecated (Aug-2008) use {@link CellRangeAddress}
*/
public class Region implements Comparable {
private int rowFrom;
private short colFrom;
private int rowTo;
private short colTo;
public class Region implements Comparable<Region> {
private int _rowFrom;
private short _colFrom;
private int _rowTo;
private short _colTo;
/**
* Creates a new instance of Region (0,0 - 0,0)
*/
public Region()
{
}
public Region(int rowFrom, short colFrom, int rowTo, short colTo)
{
this.rowFrom = rowFrom;
this.rowTo = rowTo;
this.colFrom = colFrom;
this.colTo = colTo;
this._rowFrom = rowFrom;
this._rowTo = rowTo;
this._colFrom = colFrom;
this._colTo = colTo;
}
public Region(String ref) {
CellReference cellReferenceFrom = new CellReference(ref.substring(0, ref.indexOf(":")));
CellReference cellReferenceTo = new CellReference(ref.substring(ref.indexOf(":") + 1));
this.rowFrom = cellReferenceFrom.getRow();
this.colFrom = (short) cellReferenceFrom.getCol();
this.rowTo = cellReferenceTo.getRow();
this.colTo = (short) cellReferenceTo.getCol();
this._rowFrom = cellReferenceFrom.getRow();
this._colFrom = cellReferenceFrom.getCol();
this._rowTo = cellReferenceTo.getRow();
this._colTo = cellReferenceTo.getCol();
}
@ -63,10 +62,9 @@ public class Region implements Comparable {
*
* @return column number for the upper left hand corner
*/
public short getColumnFrom()
{
return colFrom;
return _colFrom;
}
/**
@ -74,10 +72,9 @@ public class Region implements Comparable {
*
* @return row number for the upper left hand corner
*/
public int getRowFrom()
{
return rowFrom;
return _rowFrom;
}
/**
@ -88,7 +85,7 @@ public class Region implements Comparable {
public short getColumnTo()
{
return colTo;
return _colTo;
}
/**
@ -96,10 +93,9 @@ public class Region implements Comparable {
*
* @return row number for the lower right hand corner
*/
public int getRowTo()
{
return rowTo;
return _rowTo;
}
/**
@ -107,10 +103,9 @@ public class Region implements Comparable {
*
* @param colFrom column number for the upper left hand corner
*/
public void setColumnFrom(short colFrom)
{
this.colFrom = colFrom;
this._colFrom = colFrom;
}
/**
@ -118,10 +113,9 @@ public class Region implements Comparable {
*
* @param rowFrom row number for the upper left hand corner
*/
public void setRowFrom(int rowFrom)
{
this.rowFrom = rowFrom;
this._rowFrom = rowFrom;
}
/**
@ -132,7 +126,7 @@ public class Region implements Comparable {
public void setColumnTo(short colTo)
{
this.colTo = colTo;
this._colTo = colTo;
}
/**
@ -140,10 +134,9 @@ public class Region implements Comparable {
*
* @param rowTo row number for the lower right hand corner
*/
public void setRowTo(int rowTo)
{
this.rowTo = rowTo;
this._rowTo = rowTo;
}
@ -153,11 +146,10 @@ public class Region implements Comparable {
* @return <code>true</code> if the cell is in the range and
* <code>false</code> if it is not
*/
public boolean contains(int row, short col)
{
if ((this.rowFrom <= row) && (this.rowTo >= row)
&& (this.colFrom <= col) && (this.colTo >= col))
if ((this._rowFrom <= row) && (this._rowTo >= row)
&& (this._colFrom <= col) && (this._colTo >= col))
{
// System.out.println("Region ("+rowFrom+","+colFrom+","+rowTo+","+
@ -181,7 +173,6 @@ public class Region implements Comparable {
* @param r region
* @see #compareTo(Object)
*/
public int compareTo(Region r)
{
if ((this.getRowFrom() == r.getRowFrom())
@ -201,16 +192,11 @@ public class Region implements Comparable {
return -1;
}
public int compareTo(Object o)
{
return compareTo(( Region ) o);
}
/**
* @return the size of the region (number of cells in the area).
*/
public int getArea() {
return (rowTo - rowFrom + 1) * (colTo - colFrom + 1);
return (_rowTo - _rowFrom + 1) * (_colTo - _colFrom + 1);
}
@ -263,8 +249,8 @@ public class Region implements Comparable {
* @return the string reference for this region
*/
public String getRegionRef() {
CellReference cellRefFrom = new CellReference(rowFrom, colFrom);
CellReference cellRefTo = new CellReference(rowTo, colTo);
CellReference cellRefFrom = new CellReference(_rowFrom, _colFrom);
CellReference cellRefTo = new CellReference(_rowTo, _colTo);
String ref = cellRefFrom.formatAsString() + ":" + cellRefTo.formatAsString();
return ref;
}

View File

@ -1,4 +1,3 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@ -16,7 +15,6 @@
limitations under the License.
==================================================================== */
package org.apache.poi.util;
import java.util.*;
@ -89,34 +87,20 @@ import java.util.*;
*
* @author Marc Johnson (mjohnson at apache dot org)
*/
public final class BinaryTree // final for performance
extends AbstractMap
{
private Node[] _root = new Node[]
{
null, null
};
private int _size = 0;
private int _modifications = 0;
private Set[] _key_set = new Set[]
{
null, null
};
private Set[] _entry_set = new Set[]
{
null, null
};
private Collection[] _value_collection = new Collection[]
{
null, null
};
private static final int _KEY = 0;
private static final int _VALUE = 1;
private static final int _INDEX_SUM = _KEY + _VALUE;
private static final int _MINIMUM_INDEX = 0;
private static final int _INDEX_COUNT = 2;
private static final String[] _data_name = new String[]
//for performance
public class BinaryTree extends AbstractMap {
final Node[] _root;
int _size = 0;
int _modifications = 0;
private final Set[] _key_set = new Set[] { null, null };
private final Set[] _entry_set = new Set[] { null, null };
private final Collection[] _value_collection = new Collection[] { null, null };
static int _KEY = 0;
static int _VALUE = 1;
private static int _INDEX_SUM = _KEY + _VALUE;
private static int _MINIMUM_INDEX = 0;
private static int _INDEX_COUNT = 2;
private static String[] _data_name = new String[]
{
"key", "value"
};
@ -124,9 +108,8 @@ public final class BinaryTree // final for performance
/**
* Construct a new BinaryTree
*/
public BinaryTree()
{
public BinaryTree() {
_root = new Node[]{ null, null, };
}
/**
@ -146,11 +129,11 @@ public final class BinaryTree // final for performance
* or duplicate values in the
* map
*/
public BinaryTree(final Map map)
public BinaryTree(Map map)
throws ClassCastException, NullPointerException,
IllegalArgumentException
{
this();
putAll(map);
}
@ -167,8 +150,7 @@ public final class BinaryTree // final for performance
* inappropriate type for this map.
* @exception NullPointerException if the value is null
*/
public Object getKeyForValue(final Object value)
public Object getKeyForValue(Object value)
throws ClassCastException, NullPointerException
{
return doGet(( Comparable ) value, _VALUE);
@ -182,8 +164,7 @@ public final class BinaryTree // final for performance
* @return previous key associated with specified value, or null
* if there was no mapping for value.
*/
public Object removeValue(final Object value)
public Object removeValue(Object value)
{
return doRemove(( Comparable ) value, _VALUE);
}
@ -207,7 +188,6 @@ public final class BinaryTree // final for performance
*
* @return a set view of the mappings contained in this map.
*/
public Set entrySetByValue()
{
if (_entry_set[ _VALUE ] == null)
@ -423,8 +403,7 @@ public final class BinaryTree // final for performance
* key. null if the specified key or value could not be
* found
*/
private Object doRemove(final Comparable o, final int index)
private Object doRemove(Comparable o, int index)
{
Node node = lookup(o, index);
Object rval = null;
@ -447,8 +426,7 @@ public final class BinaryTree // final for performance
* key was mapped); null if we couldn't find the specified
* object
*/
private Object doGet(final Comparable o, final int index)
private Object doGet(Comparable o, int index)
{
checkNonNullComparable(o, index);
Node node = lookup(o, index);
@ -464,8 +442,7 @@ public final class BinaryTree // final for performance
*
* @return _VALUE (if _KEY was specified), else _KEY
*/
private int oppositeIndex(final int index)
private int oppositeIndex(int index)
{
// old trick ... to find the opposite of a value, m or n,
@ -483,8 +460,7 @@ public final class BinaryTree // final for performance
* @return the desired Node, or null if there is no mapping of the
* specified data
*/
private Node lookup(final Comparable data, final int index)
public Node lookup(Comparable data, int index)
{
Node rval = null;
Node node = _root[ index ];
@ -498,12 +474,9 @@ public final class BinaryTree // final for performance
rval = node;
break;
}
else
{
node = (cmp < 0) ? node.getLeft(index)
: node.getRight(index);
}
}
return rval;
}
@ -516,10 +489,9 @@ public final class BinaryTree // final for performance
* @return negative value if o1 < o2; 0 if o1 == o2; positive
* value if o1 > o2
*/
private static int compare(final Comparable o1, final Comparable o2)
private static int compare(Comparable o1, Comparable o2)
{
return (( Comparable ) o1).compareTo(o2);
return o1.compareTo(o2);
}
/**
@ -532,8 +504,7 @@ public final class BinaryTree // final for performance
* @return the smallest node, from the specified node, in the
* specified mapping
*/
private static Node leastNode(final Node node, final int index)
static Node leastNode(Node node, int index)
{
Node rval = node;
@ -555,8 +526,7 @@ public final class BinaryTree // final for performance
*
* @return the specified node
*/
private Node nextGreater(final Node node, final int index)
static Node nextGreater(Node node, int index)
{
Node rval = null;
@ -601,9 +571,7 @@ public final class BinaryTree // final for performance
* @param to the node whose color we're changing; may be null
* @param index _KEY or _VALUE
*/
private static void copyColor(final Node from, final Node to,
final int index)
private static void copyColor(Node from, Node to, int index)
{
if (to != null)
{
@ -627,11 +595,9 @@ public final class BinaryTree // final for performance
* @param node the node (may be null) in question
* @param index _KEY or _VALUE
*/
private static boolean isRed(final Node node, final int index)
private static boolean isRed(Node node, int index)
{
return ((node == null) ? false
: node.isRed(index));
return node == null ? false : node.isRed(index);
}
/**
@ -641,11 +607,9 @@ public final class BinaryTree // final for performance
* @param node the node (may be null) in question
* @param index _KEY or _VALUE
*/
private static boolean isBlack(final Node node, final int index)
private static boolean isBlack(Node node, int index)
{
return ((node == null) ? true
: node.isBlack(index));
return node == null ? true : node.isBlack(index);
}
/**
@ -654,8 +618,7 @@ public final class BinaryTree // final for performance
* @param node the node (may be null) in question
* @param index _KEY or _VALUE
*/
private static void makeRed(final Node node, final int index)
private static void makeRed(Node node, int index)
{
if (node != null)
{
@ -669,8 +632,7 @@ public final class BinaryTree // final for performance
* @param node the node (may be null) in question
* @param index _KEY or _VALUE
*/
private static void makeBlack(final Node node, final int index)
private static void makeBlack(Node node, int index)
{
if (node != null)
{
@ -685,8 +647,7 @@ public final class BinaryTree // final for performance
* @param node the node (may be null) in question
* @param index _KEY or _VALUE
*/
private static Node getGrandParent(final Node node, final int index)
private static Node getGrandParent(Node node, int index)
{
return getParent(getParent(node, index), index);
}
@ -698,8 +659,7 @@ public final class BinaryTree // final for performance
* @param node the node (may be null) in question
* @param index _KEY or _VALUE
*/
private static Node getParent(final Node node, final int index)
private static Node getParent(Node node, int index)
{
return ((node == null) ? null
: node.getParent(index));
@ -712,8 +672,7 @@ public final class BinaryTree // final for performance
* @param node the node (may be null) in question
* @param index _KEY or _VALUE
*/
private static Node getRightChild(final Node node, final int index)
private static Node getRightChild(Node node, int index)
{
return (node == null) ? null
: node.getRight(index);
@ -726,8 +685,7 @@ public final class BinaryTree // final for performance
* @param node the node (may be null) in question
* @param index _KEY or _VALUE
*/
private static Node getLeftChild(final Node node, final int index)
private static Node getLeftChild(Node node, int index)
{
return (node == null) ? null
: node.getLeft(index);
@ -744,15 +702,14 @@ public final class BinaryTree // final for performance
* @param node the node (may be null) in question
* @param index _KEY or _VALUE
*/
private static boolean isLeftChild(final Node node, final int index)
{
return (node == null) ? true
: ((node.getParent(index) == null) ? false
: (node
== node.getParent(
index).getLeft(
index)));
private static boolean isLeftChild(Node node, int index) {
if (node == null) {
return true;
}
if (node.getParent(index) == null) {
return false;
}
return node == node.getParent(index).getLeft(index);
}
/**
@ -766,15 +723,15 @@ public final class BinaryTree // final for performance
* @param node the node (may be null) in question
* @param index _KEY or _VALUE
*/
private static boolean isRightChild(final Node node, final int index)
private static boolean isRightChild(Node node, int index)
{
return (node == null) ? true
: ((node.getParent(index) == null) ? false
: (node
== node.getParent(
index).getRight(
index)));
if (node == null) {
return true;
}
if (node.getParent(index) == null) {
return false;
}
return node == node.getParent(index).getRight(index);
}
/**
@ -783,8 +740,7 @@ public final class BinaryTree // final for performance
* @param node the node to be rotated
* @param index _KEY or _VALUE
*/
private void rotateLeft(final Node node, final int index)
private void rotateLeft(Node node, int index)
{
Node right_child = node.getRight(index);
@ -818,8 +774,7 @@ public final class BinaryTree // final for performance
* @param node the node to be rotated
* @param index _KEY or _VALUE
*/
private void rotateRight(final Node node, final int index)
private void rotateRight(Node node, int index)
{
Node left_child = node.getLeft(index);
@ -854,8 +809,7 @@ public final class BinaryTree // final for performance
* @param inserted_node the node to be inserted
* @param index _KEY or _VALUE
*/
private void doRedBlackInsert(final Node inserted_node, final int index)
private void doRedBlackInsert(Node inserted_node, int index)
{
Node current_node = inserted_node;
@ -931,8 +885,7 @@ public final class BinaryTree // final for performance
*
* @param deleted_node the node to be deleted
*/
private void doRedBlackDelete(final Node deleted_node)
void doRedBlackDelete(Node deleted_node)
{
for (int index = _MINIMUM_INDEX; index < _INDEX_COUNT; index++)
{
@ -1023,9 +976,8 @@ public final class BinaryTree // final for performance
* @param replacement_node the node being replaced
* @param index _KEY or _VALUE
*/
private void doRedBlackDeleteFixup(final Node replacement_node,
final int index)
private void doRedBlackDeleteFixup(Node replacement_node,
int index)
{
Node current_node = replacement_node;
@ -1121,8 +1073,7 @@ public final class BinaryTree // final for performance
* @param y another node
* @param index _KEY or _VALUE
*/
private void swapPosition(final Node x, final Node y, final int index)
private void swapPosition(Node x, Node y, int index)
{
// Save initial values.
@ -1244,9 +1195,8 @@ public final class BinaryTree // final for performance
* @exception NullPointerException if o is null
* @exception ClassCastException if o is not Comparable
*/
private static void checkNonNullComparable(final Object o,
final int index)
private static void checkNonNullComparable(Object o,
int index)
{
if (o == null)
{
@ -1268,8 +1218,7 @@ public final class BinaryTree // final for performance
* @exception NullPointerException if key is null
* @exception ClassCastException if key is not Comparable
*/
private static void checkKey(final Object key)
private static void checkKey(Object key)
{
checkNonNullComparable(key, _KEY);
}
@ -1282,8 +1231,7 @@ public final class BinaryTree // final for performance
* @exception NullPointerException if value is null
* @exception ClassCastException if value is not Comparable
*/
private static void checkValue(final Object value)
private static void checkValue(Object value)
{
checkNonNullComparable(value, _VALUE);
}
@ -1298,8 +1246,7 @@ public final class BinaryTree // final for performance
* @exception NullPointerException if key or value is null
* @exception ClassCastException if key or value is not Comparable
*/
private static void checkKeyAndValue(final Object key, final Object value)
private static void checkKeyAndValue(Object key, Object value)
{
checkKey(key);
checkValue(value);
@ -1310,7 +1257,6 @@ public final class BinaryTree // final for performance
* concurrent modification of the map through the map and through
* an Iterator from one of its Set or Collection views
*/
private void modify()
{
_modifications++;
@ -1319,7 +1265,6 @@ public final class BinaryTree // final for performance
/**
* bump up the size and note that the map has changed
*/
private void grow()
{
modify();
@ -1329,7 +1274,6 @@ public final class BinaryTree // final for performance
/**
* decrement the size and note that the map has changed
*/
private void shrink()
{
modify();
@ -1344,8 +1288,7 @@ public final class BinaryTree // final for performance
* @exception IllegalArgumentException if the node already exists
* in the value mapping
*/
private void insertValue(final Node newNode)
private void insertValue(Node newNode)
throws IllegalArgumentException
{
Node node = _root[ _VALUE ];
@ -1400,7 +1343,6 @@ public final class BinaryTree // final for performance
*
* @return the number of key-value mappings in this map.
*/
public int size()
{
return _size;
@ -1419,8 +1361,7 @@ public final class BinaryTree // final for performance
* type for this map.
* @exception NullPointerException if the key is null
*/
public boolean containsKey(final Object key)
public boolean containsKey(Object key)
throws ClassCastException, NullPointerException
{
checkKey(key);
@ -1436,8 +1377,7 @@ public final class BinaryTree // final for performance
* @return true if this map maps one or more keys to the specified
* value.
*/
public boolean containsValue(final Object value)
public boolean containsValue(Object value)
{
checkValue(value);
return lookup(( Comparable ) value, _VALUE) != null;
@ -1456,8 +1396,7 @@ public final class BinaryTree // final for performance
* type for this map.
* @exception NullPointerException if the key is null
*/
public Object get(final Object key)
public Object get(Object key)
throws ClassCastException, NullPointerException
{
return doGet(( Comparable ) key, _KEY);
@ -1483,8 +1422,7 @@ public final class BinaryTree // final for performance
* value duplicates an
* existing value
*/
public Object put(final Object key, final Object value)
public Object put(Object key, Object value)
throws ClassCastException, NullPointerException,
IllegalArgumentException
{
@ -1562,8 +1500,7 @@ public final class BinaryTree // final for performance
* @return previous value associated with specified key, or null
* if there was no mapping for key.
*/
public Object remove(final Object key)
public Object remove(Object key)
{
return doRemove(( Comparable ) key, _KEY);
}
@ -1571,7 +1508,6 @@ public final class BinaryTree // final for performance
/**
* Removes all mappings from this map
*/
public void clear()
{
modify();
@ -1592,7 +1528,6 @@ public final class BinaryTree // final for performance
*
* @return a set view of the keys contained in this map.
*/
public Set keySet()
{
if (_key_set[ _KEY ] == null)
@ -1650,7 +1585,6 @@ public final class BinaryTree // final for performance
*
* @return a collection view of the values contained in this map.
*/
public Collection values()
{
if (_value_collection[ _KEY ] == null)
@ -1723,7 +1657,6 @@ public final class BinaryTree // final for performance
*
* @return a set view of the mappings contained in this map.
*/
public Set entrySet()
{
if (_entry_set[ _KEY ] == null)
@ -1803,8 +1736,7 @@ public final class BinaryTree // final for performance
*
* @param type
*/
BinaryTreeIterator(final int type)
BinaryTreeIterator(int type)
{
_type = type;
_expected_modifications = BinaryTree.this._modifications;
@ -1825,7 +1757,7 @@ public final class BinaryTree // final for performance
* @return true if the iterator has more elements.
*/
public final boolean hasNext()
public boolean hasNext()
{
return _next_node != null;
}
@ -1842,7 +1774,7 @@ public final class BinaryTree // final for performance
* back
*/
public final Object next()
public Object next()
throws NoSuchElementException, ConcurrentModificationException
{
if (_next_node == null)
@ -1878,7 +1810,7 @@ public final class BinaryTree // final for performance
* back
*/
public final void remove()
public void remove()
throws IllegalStateException, ConcurrentModificationException
{
if (_last_returned_node == null)
@ -1897,7 +1829,7 @@ public final class BinaryTree // final for performance
/* ********** END implementation of Iterator ********** */
} // end private abstract class BinaryTreeIterator
// final for performance
// for performance
private static final class Node
implements Map.Entry
{
@ -1917,7 +1849,7 @@ public final class BinaryTree // final for performance
* @param value
*/
Node(final Comparable key, final Comparable value)
Node(Comparable key, Comparable value)
{
_data = new Comparable[]
{
@ -1949,8 +1881,7 @@ public final class BinaryTree // final for performance
*
* @return the key or value
*/
private Comparable getData(final int index)
public Comparable getData(int index)
{
return _data[ index ];
}
@ -1961,8 +1892,7 @@ public final class BinaryTree // final for performance
* @param node the new left node
* @param index _KEY or _VALUE
*/
private void setLeft(final Node node, final int index)
public void setLeft(Node node, int index)
{
_left[ index ] = node;
}
@ -1975,7 +1905,7 @@ public final class BinaryTree // final for performance
* @return the left node -- may be null
*/
private Node getLeft(final int index)
public Node getLeft(int index)
{
return _left[ index ];
}
@ -1986,8 +1916,7 @@ public final class BinaryTree // final for performance
* @param node the new right node
* @param index _KEY or _VALUE
*/
private void setRight(final Node node, final int index)
public void setRight(Node node, int index)
{
_right[ index ] = node;
}
@ -2000,7 +1929,7 @@ public final class BinaryTree // final for performance
* @return the right node -- may be null
*/
private Node getRight(final int index)
public Node getRight(int index)
{
return _right[ index ];
}
@ -2011,8 +1940,7 @@ public final class BinaryTree // final for performance
* @param node the new parent node
* @param index _KEY or _VALUE
*/
private void setParent(final Node node, final int index)
public void setParent(Node node, int index)
{
_parent[ index ] = node;
}
@ -2024,8 +1952,7 @@ public final class BinaryTree // final for performance
*
* @return the parent node -- may be null
*/
private Node getParent(final int index)
public Node getParent(int index)
{
return _parent[ index ];
}
@ -2036,8 +1963,7 @@ public final class BinaryTree // final for performance
* @param node the node to swap with
* @param index _KEY or _VALUE
*/
private void swapColors(final Node node, final int index)
public void swapColors(Node node, int index)
{
// Swap colors -- old hacker's trick
@ -2053,8 +1979,7 @@ public final class BinaryTree // final for performance
*
* @return true if black (which is represented as a true boolean)
*/
private boolean isBlack(final int index)
public boolean isBlack(int index)
{
return _black[ index ];
}
@ -2066,8 +1991,7 @@ public final class BinaryTree // final for performance
*
* @return true if non-black
*/
private boolean isRed(final int index)
public boolean isRed(int index)
{
return !_black[ index ];
}
@ -2077,8 +2001,7 @@ public final class BinaryTree // final for performance
*
* @param index _KEY or _VALUE
*/
private void setBlack(final int index)
public void setBlack(int index)
{
_black[ index ] = true;
}
@ -2088,8 +2011,7 @@ public final class BinaryTree // final for performance
*
* @param index _KEY or _VALUE
*/
private void setRed(final int index)
public void setRed(int index)
{
_black[ index ] = false;
}
@ -2100,8 +2022,7 @@ public final class BinaryTree // final for performance
* @param node the node whose color we're adopting
* @param index _KEY or _VALUE
*/
private void copyColor(final Node node, final int index)
public void copyColor(Node node, int index)
{
_black[ index ] = node._black[ index ];
}
@ -2111,7 +2032,6 @@ public final class BinaryTree // final for performance
/**
* @return the key corresponding to this entry.
*/
public Object getKey()
{
return _data[ _KEY ];
@ -2120,7 +2040,6 @@ public final class BinaryTree // final for performance
/**
* @return the value corresponding to this entry.
*/
public Object getValue()
{
return _data[ _VALUE ];
@ -2133,10 +2052,7 @@ public final class BinaryTree // final for performance
* @param ignored
*
* @return does not return
*
* @exception UnsupportedOperationException
*/
public Object setValue(Object ignored)
throws UnsupportedOperationException
{
@ -2154,7 +2070,6 @@ public final class BinaryTree // final for performance
* @return true if the specified object is equal to this map
* entry.
*/
public boolean equals(Object o)
{
if (this == o)
@ -2188,5 +2103,4 @@ public final class BinaryTree // final for performance
/* ********** END implementation of Map.Entry ********** */
}
} // end public class BinaryTree
}

View File

@ -1,4 +1,3 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@ -16,7 +15,6 @@
limitations under the License.
==================================================================== */
package org.apache.poi.util;
import java.util.*;
@ -31,25 +29,23 @@ import java.util.*;
* @author Glen Stampoultzis (glens at apache.org)
* @author Nicola Ken Barozzi (nicolaken at apache.org)
*/
public abstract class POILogger {
public abstract class POILogger
{
public static final int DEBUG = 1;
public static final int INFO = 3;
public static final int WARN = 5;
public static final int ERROR = 7;
public static final int FATAL = 9;
public static int DEBUG = 1;
public static int INFO = 3;
public static int WARN = 5;
public static int ERROR = 7;
public static int FATAL = 9;
/**
* package scope so it cannot be instantiated outside of the util
* package. You need a POILogger? Go to the POILogFactory for one
*
*/
POILogger()
{}
POILogger() {
// no fields to initialise
}
abstract public void initialize(final String cat);
abstract public void initialize(String cat);
/**
* Log a message
@ -57,7 +53,7 @@ public abstract class POILogger
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
* @param obj1 The object to log. This is converted to a string.
*/
abstract public void log(final int level, final Object obj1);
abstract public void log(int level, Object obj1);
/**
* Log a message
@ -66,7 +62,7 @@ public abstract class POILogger
* @param obj1 The object to log. This is converted to a string.
* @param exception An exception to be logged
*/
abstract public void log(final int level, final Object obj1,
abstract public void log(int level, Object obj1,
final Throwable exception);
@ -75,7 +71,7 @@ public abstract class POILogger
*
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
*/
abstract public boolean check(final int level);
abstract public boolean check(int level);
/**
* Log a message. Lazily appends Object parameters together.
@ -84,16 +80,7 @@ public abstract class POILogger
* @param obj1 first object to place in the message
* @param obj2 second object to place in the message
*/
/**
* Log a message. Lazily appends Object parameters together.
*
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
* @param obj1 first object to place in the message
* @param obj2 second object to place in the message
*/
public void log(final int level, final Object obj1, final Object obj2)
public void log(int level, Object obj1, Object obj2)
{
if (check(level))
{
@ -109,9 +96,8 @@ public abstract class POILogger
* @param obj2 second Object to place in the message
* @param obj3 third Object to place in the message
*/
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3)
public void log(int level, Object obj1, Object obj2,
Object obj3)
{
@ -132,9 +118,8 @@ public abstract class POILogger
* @param obj3 third Object to place in the message
* @param obj4 fourth Object to place in the message
*/
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4)
public void log(int level, Object obj1, Object obj2,
Object obj3, Object obj4)
{
@ -156,9 +141,8 @@ public abstract class POILogger
* @param obj4 fourth Object to place in the message
* @param obj5 fifth Object to place in the message
*/
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5)
public void log(int level, Object obj1, Object obj2,
Object obj3, Object obj4, Object obj5)
{
@ -181,10 +165,9 @@ public abstract class POILogger
* @param obj5 fifth Object to place in the message
* @param obj6 sixth Object to place in the message
*/
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
final Object obj6)
public void log(int level, Object obj1, Object obj2,
Object obj3, Object obj4, Object obj5,
Object obj6)
{
@ -208,10 +191,9 @@ public abstract class POILogger
* @param obj6 sixth Object to place in the message
* @param obj7 seventh Object to place in the message
*/
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
final Object obj6, final Object obj7)
public void log(int level, Object obj1, Object obj2,
Object obj3, Object obj4, Object obj5,
Object obj6, Object obj7)
{
@ -237,10 +219,9 @@ public abstract class POILogger
* @param obj7 seventh Object to place in the message
* @param obj8 eighth Object to place in the message
*/
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
final Object obj6, final Object obj7, final Object obj8)
public void log(int level, Object obj1, Object obj2,
Object obj3, Object obj4, Object obj5,
Object obj6, Object obj7, Object obj8)
{
@ -259,8 +240,7 @@ public abstract class POILogger
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
* @param exception An exception to be logged
*/
public void log(final int level, final Throwable exception)
public void log(int level, final Throwable exception)
{
log(level, null, exception);
}
@ -273,8 +253,7 @@ public abstract class POILogger
* @param obj2 second Object to place in the message
* @param exception An exception to be logged
*/
public void log(final int level, final Object obj1, final Object obj2,
public void log(int level, Object obj1, Object obj2,
final Throwable exception)
{
@ -295,9 +274,8 @@ public abstract class POILogger
* @param obj3 third object to place in the message
* @param exception An error message to be logged
*/
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Throwable exception)
public void log(int level, Object obj1, Object obj2,
Object obj3, final Throwable exception)
{
@ -318,9 +296,8 @@ public abstract class POILogger
* @param obj4 fourth object to place in the message
* @param exception An exception to be logged
*/
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4,
public void log(int level, Object obj1, Object obj2,
Object obj3, Object obj4,
final Throwable exception)
{
@ -343,9 +320,8 @@ public abstract class POILogger
* @param obj5 fifth object to place in the message
* @param exception An exception to be logged
*/
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
public void log(int level, Object obj1, Object obj2,
Object obj3, Object obj4, Object obj5,
final Throwable exception)
{
@ -369,10 +345,9 @@ public abstract class POILogger
* @param obj6 sixth object to place in the message
* @param exception An exception to be logged
*/
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
final Object obj6, final Throwable exception)
public void log(int level, Object obj1, Object obj2,
Object obj3, Object obj4, Object obj5,
Object obj6, final Throwable exception)
{
@ -397,10 +372,9 @@ public abstract class POILogger
* @param obj7 seventh object to place in the message
* @param exception An exception to be logged
*/
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
final Object obj6, final Object obj7,
public void log(int level, Object obj1, Object obj2,
Object obj3, Object obj4, Object obj5,
Object obj6, Object obj7,
final Throwable exception)
{
@ -427,10 +401,9 @@ public abstract class POILogger
* @param obj8 eighth object to place in the message
* @param exception An exception to be logged
*/
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
final Object obj6, final Object obj7, final Object obj8,
public void log(int level, Object obj1, Object obj2,
Object obj3, Object obj4, Object obj5,
Object obj6, Object obj7, Object obj8,
final Throwable exception)
{
@ -467,9 +440,8 @@ public abstract class POILogger
* @param message The message to log.
* @param obj1 The first object to match against.
*/
public void logFormatted(final int level, final String message,
final Object obj1)
public void logFormatted(int level, String message,
Object obj1)
{
commonLogFormatted(level, message, new Object[]
{
@ -502,9 +474,8 @@ public abstract class POILogger
* @param obj1 The first object to match against.
* @param obj2 The second object to match against.
*/
public void logFormatted(final int level, final String message,
final Object obj1, final Object obj2)
public void logFormatted(int level, String message,
Object obj1, Object obj2)
{
commonLogFormatted(level, message, new Object[]
{
@ -538,10 +509,9 @@ public abstract class POILogger
* @param obj2 The second object to match against.
* @param obj3 The third object to match against.
*/
public void logFormatted(final int level, final String message,
final Object obj1, final Object obj2,
final Object obj3)
public void logFormatted(int level, String message,
Object obj1, Object obj2,
Object obj3)
{
commonLogFormatted(level, message, new Object[]
{
@ -576,10 +546,9 @@ public abstract class POILogger
* @param obj3 The third object to match against.
* @param obj4 The forth object to match against.
*/
public void logFormatted(final int level, final String message,
final Object obj1, final Object obj2,
final Object obj3, final Object obj4)
public void logFormatted(int level, String message,
Object obj1, Object obj2,
Object obj3, Object obj4)
{
commonLogFormatted(level, message, new Object[]
{
@ -587,8 +556,8 @@ public abstract class POILogger
});
}
private void commonLogFormatted(final int level, final String message,
final Object [] unflatParams)
private void commonLogFormatted(int level, String message,
Object [] unflatParams)
{
@ -611,21 +580,20 @@ public abstract class POILogger
/**
* Flattens any contained objects. Only tranverses one level deep.
*/
private Object [] flattenArrays(final Object [] objects)
private Object [] flattenArrays(Object [] objects)
{
List results = new ArrayList();
List<Object> results = new ArrayList<Object>();
for (int i = 0; i < objects.length; i++)
{
results.addAll(objectToObjectArray(objects[ i ]));
}
return ( Object [] ) results.toArray(new Object[ results.size() ]);
return results.toArray(new Object[ results.size() ]);
}
private List objectToObjectArray(Object object)
private List<Object> objectToObjectArray(Object object)
{
List results = new ArrayList();
List<Object> results = new ArrayList<Object>();
if (object instanceof byte [])
{
@ -705,6 +673,4 @@ public abstract class POILogger
}
return results;
}
} // end package scope abstract class POILogger
}

View File

@ -588,10 +588,10 @@ public abstract class OPCPackage implements RelationshipSource {
PackagePart[] parts = this.getPartsImpl();
this.partList = new PackagePartCollection();
for (PackagePart part : parts) {
if (partList.containsKey(part.partName))
if (partList.containsKey(part._partName))
throw new InvalidFormatException(
"A part with the name '"
+ part.partName
+ part._partName
+ "' already exist : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12]");
// Check OPC compliance rule M4.1
@ -605,29 +605,29 @@ public abstract class OPCPackage implements RelationshipSource {
}
PartUnmarshaller partUnmarshaller = partUnmarshallers
.get(part.contentType);
.get(part._contentType);
if (partUnmarshaller != null) {
UnmarshallContext context = new UnmarshallContext(this,
part.partName);
part._partName);
try {
PackagePart unmarshallPart = partUnmarshaller
.unmarshall(context, part.getInputStream());
partList.put(unmarshallPart.partName, unmarshallPart);
partList.put(unmarshallPart._partName, unmarshallPart);
// Core properties case
if (unmarshallPart instanceof PackagePropertiesPart)
this.packageProperties = (PackagePropertiesPart) unmarshallPart;
} catch (IOException ioe) {
logger.log(POILogger.WARN, "Unmarshall operation : IOException for "
+ part.partName);
+ part._partName);
continue;
} catch (InvalidOperationException invoe) {
throw new InvalidFormatException(invoe.getMessage());
}
} else {
try {
partList.put(part.partName, part);
partList.put(part._partName, part);
} catch (InvalidOperationException e) {
throw new InvalidFormatException(e.getMessage());
}
@ -779,20 +779,20 @@ public abstract class OPCPackage implements RelationshipSource {
throw new IllegalArgumentException("part");
}
if (partList.containsKey(part.partName)) {
if (!partList.get(part.partName).isDeleted()) {
if (partList.containsKey(part._partName)) {
if (!partList.get(part._partName).isDeleted()) {
throw new InvalidOperationException(
"A part with the name '"
+ part.partName.getName()
+ part._partName.getName()
+ "' already exists : Packages shall not contain equivalent part names and package implementers shall neither create nor recognize packages with equivalent part names. [M1.12]");
}
// If the specified partis flagged as deleted, we make it
// available
part.setDeleted(false);
// and delete the old part to replace it thereafeter
this.partList.remove(part.partName);
this.partList.remove(part._partName);
}
this.partList.put(part.partName, part);
this.partList.put(part._partName, part);
this.isDirty = true;
return part;
}
@ -893,11 +893,11 @@ public abstract class OPCPackage implements RelationshipSource {
}
// Finally delete its relationship part if one exists
this.removePart(relPart.partName);
this.removePart(relPart._partName);
}
// Delete the specified part
this.removePart(partToRemove.partName);
this.removePart(partToRemove._partName);
}
/**

View File

@ -39,32 +39,32 @@ public abstract class PackagePart implements RelationshipSource {
/**
* This part's container.
*/
protected OPCPackage container;
protected OPCPackage _container;
/**
* The part name. (required by the specification [M1.1])
*/
protected PackagePartName partName;
protected PackagePartName _partName;
/**
* The type of content of this part. (required by the specification [M1.2])
*/
protected ContentType contentType;
protected ContentType _contentType;
/**
* Flag to know if this part is a relationship.
*/
private boolean isRelationshipPart;
private boolean _isRelationshipPart;
/**
* Flag to know if this part has been logically deleted.
*/
private boolean isDeleted;
private boolean _isDeleted;
/**
* This part's relationships.
*/
private PackageRelationshipCollection relationships;
private PackageRelationshipCollection _relationships;
/**
* Constructor.
@ -100,12 +100,12 @@ public abstract class PackagePart implements RelationshipSource {
protected PackagePart(OPCPackage pack, PackagePartName partName,
ContentType contentType, boolean loadRelationships)
throws InvalidFormatException {
this.partName = partName;
this.contentType = contentType;
this.container = (ZipPackage) pack; // TODO - enforcing ZipPackage here - perhaps should change constructor signature
_partName = partName;
_contentType = contentType;
_container = pack;
// Check if this part is a relationship part
isRelationshipPart = this.partName.isRelationshipPartURI();
_isRelationshipPart = this._partName.isRelationshipPartURI();
// Load relationships if any
if (loadRelationships)
@ -174,8 +174,8 @@ public abstract class PackagePart implements RelationshipSource {
throw new IllegalArgumentException("relationshipType");
}
if (relationships == null) {
relationships = new PackageRelationshipCollection();
if (_relationships == null) {
_relationships = new PackageRelationshipCollection();
}
URI targetURI;
@ -185,7 +185,7 @@ public abstract class PackagePart implements RelationshipSource {
throw new IllegalArgumentException("Invalid target - " + e);
}
return relationships.addRelationship(targetURI, TargetMode.EXTERNAL,
return _relationships.addRelationship(targetURI, TargetMode.EXTERNAL,
relationshipType, id);
}
@ -235,7 +235,7 @@ public abstract class PackagePart implements RelationshipSource {
*/
public PackageRelationship addRelationship(PackagePartName targetPartName,
TargetMode targetMode, String relationshipType, String id) {
container.throwExceptionIfReadOnly();
_container.throwExceptionIfReadOnly();
if (targetPartName == null) {
throw new IllegalArgumentException("targetPartName");
@ -247,16 +247,16 @@ public abstract class PackagePart implements RelationshipSource {
throw new IllegalArgumentException("relationshipType");
}
if (this.isRelationshipPart || targetPartName.isRelationshipPartURI()) {
if (this._isRelationshipPart || targetPartName.isRelationshipPartURI()) {
throw new InvalidOperationException(
"Rule M1.25: The Relationships part shall not have relationships to any other part.");
}
if (relationships == null) {
relationships = new PackageRelationshipCollection();
if (_relationships == null) {
_relationships = new PackageRelationshipCollection();
}
return relationships.addRelationship(targetPartName.getURI(),
return _relationships.addRelationship(targetPartName.getURI(),
targetMode, relationshipType, id);
}
@ -305,7 +305,7 @@ public abstract class PackagePart implements RelationshipSource {
*/
public PackageRelationship addRelationship(URI targetURI,
TargetMode targetMode, String relationshipType, String id) {
container.throwExceptionIfReadOnly();
_container.throwExceptionIfReadOnly();
if (targetURI == null) {
throw new IllegalArgumentException("targetPartName");
@ -319,17 +319,17 @@ public abstract class PackagePart implements RelationshipSource {
// Try to retrieve the target part
if (this.isRelationshipPart
if (this._isRelationshipPart
|| PackagingURIHelper.isRelationshipPartURI(targetURI)) {
throw new InvalidOperationException(
"Rule M1.25: The Relationships part shall not have relationships to any other part.");
}
if (relationships == null) {
relationships = new PackageRelationshipCollection();
if (_relationships == null) {
_relationships = new PackageRelationshipCollection();
}
return relationships.addRelationship(targetURI,
return _relationships.addRelationship(targetURI,
targetMode, relationshipType, id);
}
@ -337,8 +337,8 @@ public abstract class PackagePart implements RelationshipSource {
* @see org.apache.poi.openxml4j.opc.RelationshipSource#clearRelationships()
*/
public void clearRelationships() {
if (relationships != null) {
relationships.clear();
if (_relationships != null) {
_relationships.clear();
}
}
@ -350,9 +350,9 @@ public abstract class PackagePart implements RelationshipSource {
* @see org.apache.poi.openxml4j.opc.RelationshipSource#removeRelationship(java.lang.String)
*/
public void removeRelationship(String id) {
this.container.throwExceptionIfReadOnly();
if (this.relationships != null)
this.relationships.removeRelationship(id);
this._container.throwExceptionIfReadOnly();
if (this._relationships != null)
this._relationships.removeRelationship(id);
}
/**
@ -376,7 +376,7 @@ public abstract class PackagePart implements RelationshipSource {
* @see org.apache.poi.openxml4j.opc.RelationshipSource#getRelationship(java.lang.String)
*/
public PackageRelationship getRelationship(String id) {
return this.relationships.getRelationshipByID(id);
return this._relationships.getRelationshipByID(id);
}
/**
@ -394,7 +394,7 @@ public abstract class PackagePart implements RelationshipSource {
*/
public PackageRelationshipCollection getRelationshipsByType(
String relationshipType) throws InvalidFormatException {
container.throwExceptionIfWriteOnly();
_container.throwExceptionIfWriteOnly();
return getRelationshipsCore(relationshipType);
}
@ -415,12 +415,12 @@ public abstract class PackagePart implements RelationshipSource {
*/
private PackageRelationshipCollection getRelationshipsCore(String filter)
throws InvalidFormatException {
this.container.throwExceptionIfWriteOnly();
if (relationships == null) {
this._container.throwExceptionIfWriteOnly();
if (_relationships == null) {
this.throwExceptionIfRelationship();
relationships = new PackageRelationshipCollection(this);
_relationships = new PackageRelationshipCollection(this);
}
return new PackageRelationshipCollection(relationships, filter);
return new PackageRelationshipCollection(_relationships, filter);
}
/**
@ -431,7 +431,7 @@ public abstract class PackagePart implements RelationshipSource {
* @see org.apache.poi.openxml4j.opc.RelationshipSource#hasRelationships()
*/
public boolean hasRelationships() {
return (!this.isRelationshipPart && (relationships != null && relationships
return (!this._isRelationshipPart && (_relationships != null && _relationships
.size() > 0));
}
@ -466,8 +466,8 @@ public abstract class PackagePart implements RelationshipSource {
InputStream inStream = this.getInputStreamImpl();
if (inStream == null) {
throw new IOException("Can't obtain the input stream from "
+ partName.getName());
} else
+ _partName.getName());
}
return inStream;
}
@ -485,12 +485,12 @@ public abstract class PackagePart implements RelationshipSource {
// this part into a MemoryPackagePart instance for write purpose.
if (this instanceof ZipPackagePart) {
// Delete logically this part
this.container.removePart(this.partName);
_container.removePart(this._partName);
// Create a memory part
PackagePart part = container.createPart(this.partName,
this.contentType.toString(), false);
part.relationships = this.relationships;
PackagePart part = _container.createPart(this._partName,
this._contentType.toString(), false);
part._relationships = this._relationships;
if (part == null) {
throw new InvalidOperationException(
"Can't create a temporary part !");
@ -510,7 +510,7 @@ public abstract class PackagePart implements RelationshipSource {
*/
private void throwExceptionIfRelationship()
throws InvalidOperationException {
if (this.isRelationshipPart)
if (this._isRelationshipPart)
throw new InvalidOperationException(
"Can do this operation on a relationship part !");
}
@ -522,9 +522,9 @@ public abstract class PackagePart implements RelationshipSource {
* Throws if
*/
private void loadRelationships() throws InvalidFormatException {
if (this.relationships == null && !this.isRelationshipPart) {
if (this._relationships == null && !this._isRelationshipPart) {
this.throwExceptionIfRelationship();
relationships = new PackageRelationshipCollection(this);
_relationships = new PackageRelationshipCollection(this);
}
}
@ -536,14 +536,14 @@ public abstract class PackagePart implements RelationshipSource {
* @return the uri
*/
public PackagePartName getPartName() {
return partName;
return _partName;
}
/**
* @return the contentType
*/
public String getContentType() {
return contentType.toString();
return _contentType.toString();
}
/**
@ -560,29 +560,29 @@ public abstract class PackagePart implements RelationshipSource {
*/
public void setContentType(String contentType)
throws InvalidFormatException {
if (container == null)
this.contentType = new ContentType(contentType);
if (_container == null)
this._contentType = new ContentType(contentType);
else
throw new InvalidOperationException(
"You can't change the content type of a part.");
}
public OPCPackage getPackage() {
return container;
return _container;
}
/**
* @return true if this part is a relationship
*/
public boolean isRelationshipPart() {
return this.isRelationshipPart;
return this._isRelationshipPart;
}
/**
* @return true if this part has been logically deleted
*/
public boolean isDeleted() {
return isDeleted;
return _isDeleted;
}
/**
@ -590,13 +590,13 @@ public abstract class PackagePart implements RelationshipSource {
* the isDeleted to set
*/
public void setDeleted(boolean isDeleted) {
this.isDeleted = isDeleted;
this._isDeleted = isDeleted;
}
@Override
public String toString() {
return "Name: " + this.partName + " - Content Type: "
+ this.contentType.toString();
return "Name: " + this._partName + " - Content Type: "
+ this._contentType.toString();
}
/*-------------- Abstract methods ------------- */

View File

@ -178,7 +178,7 @@ public final class PackageRelationship {
if (source == null) {
return PackagingURIHelper.PACKAGE_ROOT_URI;
}
return source.partName.getURI();
return source._partName.getURI();
}
/**

View File

@ -121,7 +121,7 @@ public final class PackageRelationshipCollection implements
*/
public PackageRelationshipCollection(PackagePart part)
throws InvalidFormatException {
this(part.container, part);
this(part._container, part);
}
/**
@ -429,15 +429,15 @@ public final class PackageRelationshipCollection implements
} else {
str = relationshipsByID.size() + " relationship(s) = [";
}
if ((relationshipPart != null) && (relationshipPart.partName != null)) {
str = str + "," + relationshipPart.partName;
if ((relationshipPart != null) && (relationshipPart._partName != null)) {
str = str + "," + relationshipPart._partName;
} else {
str = str + ",relationshipPart=null";
}
// Source of this relationship
if ((sourcePart != null) && (sourcePart.partName != null)) {
str = str + "," + sourcePart.partName;
if ((sourcePart != null) && (sourcePart._partName != null)) {
str = str + "," + sourcePart._partName;
} else {
str = str + ",sourcePart=null";
}

View File

@ -160,7 +160,6 @@ public interface RelationshipSource {
* @return <b>true</b> if the specified relationship exists in this part,
* else returns <b>false</b>
*/
@SuppressWarnings("finally")
public abstract boolean isRelationshipExists(PackageRelationship rel);
}

View File

@ -423,7 +423,7 @@ public final class ZipPackage extends Package {
+ ZipHelper.getZipItemNameFromOPCName(part
.getPartName().getName()) + "'");
PartMarshaller marshaller = partMarshallers
.get(part.contentType);
.get(part._contentType);
if (marshaller != null) {
if (!marshaller.marshall(part, zos)) {
throw new OpenXML4JException(

View File

@ -98,7 +98,7 @@ public class ZipPackagePart extends PackagePart {
protected InputStream getInputStreamImpl() throws IOException {
// We use the getInputStream() method from java.util.zip.ZipFile
// class which return an InputStream to this part zip entry.
return ((ZipPackage) container).getZipArchive()
return ((ZipPackage) _container).getZipArchive()
.getInputStream(zipEntry);
}
@ -119,7 +119,7 @@ public class ZipPackagePart extends PackagePart {
}
@Override
public boolean load(InputStream ios) throws InvalidFormatException {
public boolean load(InputStream ios) {
throw new InvalidOperationException("Method not implemented !");
}

View File

@ -45,7 +45,6 @@ import org.dom4j.io.SAXReader;
* Manage package content types ([Content_Types].xml part).
*
* @author Julien Chable
* @version 1.0
*/
public abstract class ContentTypeManager {
@ -342,9 +341,8 @@ public abstract class ContentTypeManager {
if (this.container != null && this.container.getPart(partName) != null) {
throw new OpenXML4JRuntimeException(
"Rule M2.4 exception : this error should NEVER happen, if so please send a mail to the developers team, thanks !");
} else {
return null;
}
return null;
}
/**
@ -459,8 +457,8 @@ public abstract class ContentTypeManager {
Entry<PackagePartName, String> entry) {
root.addElement(OVERRIDE_TAG_NAME).addAttribute(
PART_NAME_ATTRIBUTE_NAME,
((PackagePartName) entry.getKey()).getName()).addAttribute(
CONTENT_TYPE_ATTRIBUTE_NAME, (String) entry.getValue());
entry.getKey().getName()).addAttribute(
CONTENT_TYPE_ATTRIBUTE_NAME, entry.getValue());
}
/**
@ -474,9 +472,9 @@ public abstract class ContentTypeManager {
*/
private void appendDefaultType(Element root, Entry<String, String> entry) {
root.addElement(DEFAULT_TAG_NAME).addAttribute(
EXTENSION_ATTRIBUTE_NAME, (String) entry.getKey())
EXTENSION_ATTRIBUTE_NAME, entry.getKey())
.addAttribute(CONTENT_TYPE_ATTRIBUTE_NAME,
(String) entry.getValue());
entry.getValue());
}

View File

@ -97,7 +97,7 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor implements org.apach
StringBuffer text = new StringBuffer();
for(int i=0; i<workbook.getNumberOfSheets(); i++) {
XSSFSheet sheet = (XSSFSheet)workbook.getSheetAt(i);
XSSFSheet sheet = workbook.getSheetAt(i);
if(includeSheetNames) {
text.append(workbook.getSheetName(i) + "\n");
}

View File

@ -585,9 +585,11 @@ public final class XSSFCell implements Cell {
*/
public byte getErrorCellValue() {
String code = getErrorCellString();
if(code == null) return 0;
if (code == null) {
return 0;
}
return (byte)FormulaError.forString(code).getCode();
return FormulaError.forString(code).getCode();
}
/**

View File

@ -145,9 +145,8 @@ public class XSSFCellStyle implements CellStyle {
CTCellAlignment align = cellXf.getAlignment();
if(align != null && align.isSetHorizontal()) {
return HorizontalAlignment.values()[align.getHorizontal().intValue()-1];
} else {
return HorizontalAlignment.GENERAL;
}
return HorizontalAlignment.GENERAL;
}
/**
@ -865,7 +864,7 @@ public class XSSFCellStyle implements CellStyle {
*/
public void setDataFormat(short fmt) {
cellXf.setApplyNumberFormat(true);
cellXf.setNumFmtId((long)fmt);
cellXf.setNumFmtId(fmt);
}
/**

View File

@ -285,7 +285,7 @@ public class XSSFPrintSetup implements PrintSetup {
* @see PaperSize
*/
public PaperSize getPaperSizeEnum() {
return PaperSize.values()[((int) getPaperSize() - 1)];
return PaperSize.values()[getPaperSize() - 1];
}
/**

View File

@ -1333,7 +1333,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
.getOutlineLevel(), true);
// write collapse field
setColumn((int) (lastColMax + 1), null, 0, null, null, Boolean.TRUE);
setColumn(lastColMax + 1, null, 0, null, null, Boolean.TRUE);
}
@ -1895,8 +1895,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
endLevel = 0;
endHidden = false;
} else {
endLevel = (int) (getRow(endOfOutlineGroupIdx).getCTRow()
.getOutlineLevel());
endLevel = getRow(endOfOutlineGroupIdx).getCTRow().getOutlineLevel();
endHidden = getRow(endOfOutlineGroupIdx).getCTRow().getHidden();
}

View File

@ -35,6 +35,7 @@ import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
@ -135,7 +136,9 @@ public class TestCommentsTable extends TestCase {
break;
}
}
assertNotNull(ct);
if (ct == null) {
throw new AssertionFailedError("didn't find comments table");
}
assertEquals(2, ct.getNumberOfComments());
assertEquals(1, ct.getNumberOfAuthors());
@ -153,7 +156,9 @@ public class TestCommentsTable extends TestCase {
break;
}
}
assertNotNull(ct);
if (ct == null) {
throw new AssertionFailedError("didn't find comments table");
}
assertEquals(2, ct.getNumberOfComments());
assertEquals(1, ct.getNumberOfAuthors());
@ -209,11 +214,11 @@ public class TestCommentsTable extends TestCase {
assertTrue(xml.exists());
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
Sheet sheet1 = workbook.getSheetAt(0);
XSSFSheet sheet2 = (XSSFSheet)workbook.getSheetAt(1);
XSSFSheet sheet1 = workbook.getSheetAt(0);
XSSFSheet sheet2 = workbook.getSheetAt(1);
assertTrue( ((XSSFSheet)sheet1).hasComments() );
assertFalse( ((XSSFSheet)sheet2).hasComments() );
assertTrue( sheet1.hasComments() );
assertFalse( sheet2.hasComments() );
// Change on comment on sheet 1, and add another into
// sheet 2
@ -237,7 +242,7 @@ public class TestCommentsTable extends TestCase {
// Check we still have comments where we should do
sheet1 = workbook.getSheetAt(0);
sheet2 = (XSSFSheet)workbook.getSheetAt(1);
sheet2 = workbook.getSheetAt(1);
assertNotNull(sheet1.getRow(4).getCell(2).getCellComment());
assertNotNull(sheet1.getRow(6).getCell(2).getCellComment());
assertNotNull(sheet2.getRow(2).getCell(1).getCellComment());
@ -262,11 +267,11 @@ public class TestCommentsTable extends TestCase {
assertTrue(xml.exists());
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
Sheet sheet1 = workbook.getSheetAt(0);
XSSFSheet sheet2 = (XSSFSheet)workbook.getSheetAt(1);
XSSFSheet sheet1 = workbook.getSheetAt(0);
XSSFSheet sheet2 = workbook.getSheetAt(1);
assertTrue( ((XSSFSheet)sheet1).hasComments() );
assertFalse( ((XSSFSheet)sheet2).hasComments() );
assertTrue( sheet1.hasComments() );
assertFalse( sheet2.hasComments() );
assertEquals("Nick Burch",
sheet1.getRow(4).getCell(2).getCellComment().getAuthor());

View File

@ -48,7 +48,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
assertEquals(3, workbook.getNumberOfSheets());
XSSFSheet sheet = (XSSFSheet)workbook.getSheetAt(0);
XSSFSheet sheet = workbook.getSheetAt(0);
// Check the hyperlinks
assertEquals(4, sheet.getNumHyperlinks());
@ -65,7 +65,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
XSSFWorkbook workbook = new XSSFWorkbook(xml.toString());
CreationHelper createHelper = workbook.getCreationHelper();
assertEquals(3, workbook.getNumberOfSheets());
XSSFSheet sheet = (XSSFSheet)workbook.getSheetAt(0);
XSSFSheet sheet = workbook.getSheetAt(0);
// Check hyperlinks
assertEquals(4, sheet.getNumHyperlinks());
@ -81,7 +81,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
assertNotNull(wb2.getSheetAt(1));
assertNotNull(wb2.getSheetAt(2));
sheet = (XSSFSheet)wb2.getSheetAt(0);
sheet = wb2.getSheetAt(0);
// Check hyperlinks again

View File

@ -167,8 +167,8 @@ public final class StyleSheet {
break;
case 0x9:
newCHP._fSpec = true;
newCHP._ftcSym = (short)Utils.convertBytesToShort(varParam, 0);
newCHP._xchSym = (short)Utils.convertBytesToShort(varParam, 2);
newCHP._ftcSym = Utils.convertBytesToShort(varParam, 0);
newCHP._xchSym = Utils.convertBytesToShort(varParam, 2);
break;
case 0xa:
newCHP._fOle2 = getFlag(param);
@ -453,8 +453,8 @@ public final class StyleSheet {
doCHPOperation(oldCHP, newCHP, 0x47, param, varParam, grpprl, offset, styleSheet);
break;
case 0x4d:
float percentage = (float)param/100.0f;
int add = (int)((float)percentage * (float)newCHP._hps);
float percentage = param/100.0f;
int add = (int)(percentage * newCHP._hps);
newCHP._hps += add;
break;
case 0x4e:
@ -485,7 +485,7 @@ public final class StyleSheet {
break;
case 0x57:
newCHP._fPropMark = getFlag(varParam[0]);
newCHP._ibstPropRMark = (short)Utils.convertBytesToShort(varParam, 1);
newCHP._ibstPropRMark = Utils.convertBytesToShort(varParam, 1);
newCHP._dttmPropRMark = Utils.convertBytesToInt(varParam, 3);
break;
case 0x58:
@ -512,7 +512,7 @@ public final class StyleSheet {
break;
case 0x62:
newCHP._fDispFldRMark = getFlag(varParam[0]);
newCHP._ibstDispFldRMark = (short)Utils.convertBytesToShort(varParam, 1);
newCHP._ibstDispFldRMark = Utils.convertBytesToShort(varParam, 1);
newCHP._dttmDispFldRMark = Utils.convertBytesToInt(varParam, 3);
System.arraycopy(varParam, 7, newCHP._xstDispFldRMark, 0, 32);
break;
@ -524,8 +524,8 @@ public final class StyleSheet {
newCHP._dttmRMarkDel[1] = Utils.convertBytesToShort(grpprl, offset - 2);
break;
case 0x65:
newCHP._brc[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4);
newCHP._brc[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2);
newCHP._brc[0] = Utils.convertBytesToShort(grpprl, offset - 4);
newCHP._brc[1] = Utils.convertBytesToShort(grpprl, offset - 2);
break;
case 0x66:
newCHP._shd = (short)param;
@ -834,28 +834,28 @@ public final class StyleSheet {
newPAP._wr = (byte)param;
break;
case 0x24:
newPAP._brcTop[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4);
newPAP._brcTop[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2);
newPAP._brcTop[0] = Utils.convertBytesToShort(grpprl, offset - 4);
newPAP._brcTop[1] = Utils.convertBytesToShort(grpprl, offset - 2);
break;
case 0x25:
newPAP._brcLeft[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4);
newPAP._brcLeft[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2);
newPAP._brcLeft[0] = Utils.convertBytesToShort(grpprl, offset - 4);
newPAP._brcLeft[1] = Utils.convertBytesToShort(grpprl, offset - 2);
break;
case 0x26:
newPAP._brcBottom[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4);
newPAP._brcBottom[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2);
newPAP._brcBottom[0] = Utils.convertBytesToShort(grpprl, offset - 4);
newPAP._brcBottom[1] = Utils.convertBytesToShort(grpprl, offset - 2);
break;
case 0x27:
newPAP._brcRight[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4);
newPAP._brcRight[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2);
newPAP._brcRight[0] = Utils.convertBytesToShort(grpprl, offset - 4);
newPAP._brcRight[1] = Utils.convertBytesToShort(grpprl, offset - 2);
break;
case 0x28:
newPAP._brcBetween[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4);
newPAP._brcBetween[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2);
newPAP._brcBetween[0] = Utils.convertBytesToShort(grpprl, offset - 4);
newPAP._brcBetween[1] = Utils.convertBytesToShort(grpprl, offset - 2);
break;
case 0x29:
newPAP._brcBar[0] = (short)Utils.convertBytesToShort(grpprl, offset - 4);
newPAP._brcBar[1] = (short)Utils.convertBytesToShort(grpprl, offset - 2);
newPAP._brcBar[0] = Utils.convertBytesToShort(grpprl, offset - 4);
newPAP._brcBar[1] = Utils.convertBytesToShort(grpprl, offset - 2);
break;
case 0x2a:
newPAP._fNoAutoHyph = (byte)param;

View File

@ -35,9 +35,9 @@ import org.apache.poi.util.LittleEndian;
*
* @author Ryan Ackley
*/
public final class WordDocument
{
public final class WordDocument {
// TODO - name this constant properly
private static final float K_1440_0F = 1440.0f;
/** byte buffer containing the main Document stream*/
byte[] _header;
/** contains all style information for this document see Word 97 Doc spec*/
@ -1160,19 +1160,19 @@ public final class WordDocument
}
if(pap._dxaLeft > 0)
{
buf.append("start-indent=\"" + ((float)pap._dxaLeft)/1440.0f + "in\"\r\n");
buf.append("start-indent=\"" + pap._dxaLeft/K_1440_0F + "in\"\r\n");
}
if(pap._dxaRight > 0)
{
buf.append("end-indent=\"" + ((float)pap._dxaRight)/1440.0f + "in\"\r\n");
buf.append("end-indent=\"" + pap._dxaRight/K_1440_0F + "in\"\r\n");
}
if(pap._dxaLeft1 != 0)
{
buf.append("text-indent=\"" + ((float)pap._dxaLeft1)/1440.0f + "in\"\r\n");
buf.append("text-indent=\"" + pap._dxaLeft1/K_1440_0F + "in\"\r\n");
}
if(pap._lspd[1] == 0)
{
//buf.append("line-height=\"" + ((float)pap._lspd[0])/1440.0f + "in\"\r\n");
//buf.append("line-height=\"" + pap._lspd[0]/K_1440_0F + "in\"\r\n");
}
addBorder(buf, pap._brcTop, "top");
addBorder(buf, pap._brcBottom, "bottom");
@ -1190,7 +1190,7 @@ public final class WordDocument
buf.append("font-size=\"" + (chp._hps / 2) + "pt\" ");
buf.append("color=\"" + getColor(chp._ico) + "\" ");
//not supported by fop
//buf.append("letter-spacing=\"" + ((double)chp._dxaSpace)/1440.0f + "in\" ");
//buf.append("letter-spacing=\"" + ((double)chp._dxaSpace)/K_1440_0F + "in\" ");
addBorder(buf, chp._brc, "top");
addBorder(buf, chp._brc, "bottom");
@ -1236,11 +1236,11 @@ public final class WordDocument
}
if(chp._paddingStart != 0)
{
buf.append("padding-start=\"" + (float)chp._paddingStart/1440.0f + "in\" ");
buf.append("padding-start=\"" + chp._paddingStart/K_1440_0F + "in\" ");
}
if(chp._paddingEnd != 0)
{
buf.append("padding-end=\"" + (float)chp._paddingEnd/1440.0f + "in\" ");
buf.append("padding-end=\"" + chp._paddingEnd/K_1440_0F + "in\" ");
}
buf.append(">");
}
@ -1416,12 +1416,12 @@ public final class WordDocument
private String createPageMaster(SEP sep, String type, int section,
String regionBefore, String regionAfter)
{
float height = ((float)sep._yaPage)/1440.0f;
float width = ((float)sep._xaPage)/1440.0f;
float leftMargin = ((float)sep._dxaLeft)/1440.0f;
float rightMargin = ((float)sep._dxaRight)/1440.0f;
float topMargin = ((float)sep._dyaTop)/1440.0f;
float bottomMargin = ((float)sep._dyaBottom)/1440.0f;
float height = sep._yaPage/K_1440_0F;
float width = sep._xaPage/K_1440_0F;
float leftMargin = sep._dxaLeft/K_1440_0F;
float rightMargin = sep._dxaRight/K_1440_0F;
float topMargin = sep._dyaTop/K_1440_0F;
float bottomMargin = sep._dyaBottom/K_1440_0F;
//add these to the header
String thisPage = type + "-page" + section;
@ -1452,7 +1452,7 @@ public final class WordDocument
_headerBuffer.append("column-count=\"" + (sep._ccolM1 + 1) + "\" ");
if(sep._fEvenlySpaced)
{
_headerBuffer.append("column-gap=\"" + ((float)(sep._dxaColumns))/1440.0f + "in\"");
_headerBuffer.append("column-gap=\"" + sep._dxaColumns/K_1440_0F + "in\"");
}
else
{
@ -1478,7 +1478,7 @@ public final class WordDocument
if((brc[0] & 0xff00) != 0 && brc[0] != -1)
{
int type = (brc[0] & 0xff00) >> 8;
float width = ((float)(brc[0] & 0x00ff))/8.0f;
float width = (brc[0] & 0x00ff)/8.0f;
String style = getBorderStyle(brc[0]);
String color = getColor(brc[1] & 0x00ff);
String thickness = getBorderThickness(brc[0]);
@ -1764,7 +1764,7 @@ public final class WordDocument
rowBuffer.append("<fo:table-row ");
if(tap._dyaRowHeight > 0)
{
rowBuffer.append("height=\"" + ((float)tap._dyaRowHeight)/1440.0f + "in\" ");
rowBuffer.append("height=\"" + tap._dyaRowHeight/K_1440_0F + "in\" ");
}
if(tap._fCantSplit)
{
@ -1777,9 +1777,9 @@ public final class WordDocument
TC tc = tap._rgtc[y];
overrideCellBorder(x, y, size, tap._itcMac, tc, tap);
rowBuffer.append("<fo:table-cell ");
rowBuffer.append("width=\"" + ((float)(tap._rgdxaCenter[y+1] - tap._rgdxaCenter[y]))/1440.0f + "in\" ");
rowBuffer.append("padding-start=\"" + ((float)tap._dxaGapHalf)/1440.0f + "in\" ");
rowBuffer.append("padding-end=\"" + ((float)tap._dxaGapHalf)/1440.0f + "in\" ");
rowBuffer.append("width=\"" + (tap._rgdxaCenter[y+1] - tap._rgdxaCenter[y])/K_1440_0F + "in\" ");
rowBuffer.append("padding-start=\"" + tap._dxaGapHalf/K_1440_0F + "in\" ");
rowBuffer.append("padding-end=\"" + tap._dxaGapHalf/K_1440_0F + "in\" ");
addBorder(rowBuffer, tc._brcTop, "top");
addBorder(rowBuffer, tc._brcLeft, "left");
addBorder(rowBuffer, tc._brcBottom, "bottom");

View File

@ -224,8 +224,8 @@ public final class StyleSheet implements HDFType {
break;
case 0x9:
newCHP.setFSpec(true);
newCHP.setFtcSym((short)LittleEndian.getShort(varParam, 0));
newCHP.setXchSym((short)LittleEndian.getShort(varParam, 2));
newCHP.setFtcSym(LittleEndian.getShort(varParam, 0));
newCHP.setXchSym(LittleEndian.getShort(varParam, 2));
break;
case 0xa:
newCHP.setFOle2(getFlag(param));
@ -517,8 +517,8 @@ public final class StyleSheet implements HDFType {
doCHPOperation(oldCHP, newCHP, 0x47, param, varParam, grpprl, offset, styleSheet);
break;
case 0x4d:
float percentage = (float)param/100.0f;
int add = (int)((float)percentage * (float)newCHP.getHps());
float percentage = param/100.0f;
int add = (int)(percentage * newCHP.getHps());
newCHP.setHps(newCHP.getHps() + add);
break;
case 0x4e:
@ -549,7 +549,7 @@ public final class StyleSheet implements HDFType {
break;
case 0x57:
newCHP.setFPropMark(varParam[0]);
newCHP.setIbstPropRMark((short)LittleEndian.getShort(varParam, 1));
newCHP.setIbstPropRMark(LittleEndian.getShort(varParam, 1));
newCHP.setDttmPropRMark(LittleEndian.getInt(varParam, 3));
break;
case 0x58:
@ -577,7 +577,7 @@ public final class StyleSheet implements HDFType {
case 0x62:
byte[] xstDispFldRMark = new byte[32];
newCHP.setFDispFldRMark(varParam[0]);
newCHP.setIbstDispFldRMark((short)LittleEndian.getShort(varParam, 1));
newCHP.setIbstDispFldRMark(LittleEndian.getShort(varParam, 1));
newCHP.setDttmDispFldRMark(LittleEndian.getInt(varParam, 3));
System.arraycopy(varParam, 7, xstDispFldRMark, 0, 32);
newCHP.setXstDispFldRMark(xstDispFldRMark);
@ -593,8 +593,8 @@ public final class StyleSheet implements HDFType {
break;
case 0x65:
short[] brc = new short[2];
brc[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
brc[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
brc[0] = LittleEndian.getShort(grpprl, offset - 4);
brc[1] = LittleEndian.getShort(grpprl, offset - 2);
newCHP.setBrc(brc);
break;
case 0x66:
@ -947,33 +947,33 @@ public final class StyleSheet implements HDFType {
break;
case 0x24:
short[] brcTop = newPAP.getBrcTop();
brcTop[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
brcTop[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
brcTop[0] = LittleEndian.getShort(grpprl, offset - 4);
brcTop[1] = LittleEndian.getShort(grpprl, offset - 2);
break;
case 0x25:
short[] brcLeft = newPAP.getBrcLeft();
brcLeft[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
brcLeft[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
brcLeft[0] = LittleEndian.getShort(grpprl, offset - 4);
brcLeft[1] = LittleEndian.getShort(grpprl, offset - 2);
break;
case 0x26:
short[] brcBottom = newPAP.getBrcBottom();
brcBottom[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
brcBottom[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
brcBottom[0] = LittleEndian.getShort(grpprl, offset - 4);
brcBottom[1] = LittleEndian.getShort(grpprl, offset - 2);
break;
case 0x27:
short[] brcRight = newPAP.getBrcRight();
brcRight[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
brcRight[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
brcRight[0] = LittleEndian.getShort(grpprl, offset - 4);
brcRight[1] = LittleEndian.getShort(grpprl, offset - 2);
break;
case 0x28:
short[] brcBetween = newPAP.getBrcBetween();
brcBetween[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
brcBetween[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
brcBetween[0] = LittleEndian.getShort(grpprl, offset - 4);
brcBetween[1] = LittleEndian.getShort(grpprl, offset - 2);
break;
case 0x29:
short[] brcBar = newPAP.getBrcBar();
brcBar[0] = (short)LittleEndian.getShort(grpprl, offset - 4);
brcBar[1] = (short)LittleEndian.getShort(grpprl, offset - 2);
brcBar[0] = LittleEndian.getShort(grpprl, offset - 4);
brcBar[1] = LittleEndian.getShort(grpprl, offset - 2);
break;
case 0x2a:
newPAP.setFNoAutoHyph((byte)param);

View File

@ -814,9 +814,7 @@ public abstract class CHPAbstractType
*/
public void setFBold(boolean value)
{
field_2_format_flags = (int)fBold.setBoolean(field_2_format_flags, value);
field_2_format_flags = fBold.setBoolean(field_2_format_flags, value);
}
/**
@ -826,7 +824,6 @@ public abstract class CHPAbstractType
public boolean isFBold()
{
return fBold.isSet(field_2_format_flags);
}
/**
@ -835,9 +832,7 @@ public abstract class CHPAbstractType
*/
public void setFItalic(boolean value)
{
field_2_format_flags = (int)fItalic.setBoolean(field_2_format_flags, value);
field_2_format_flags = fItalic.setBoolean(field_2_format_flags, value);
}
/**
@ -847,7 +842,6 @@ public abstract class CHPAbstractType
public boolean isFItalic()
{
return fItalic.isSet(field_2_format_flags);
}
/**
@ -856,9 +850,7 @@ public abstract class CHPAbstractType
*/
public void setFRMarkDel(boolean value)
{
field_2_format_flags = (int)fRMarkDel.setBoolean(field_2_format_flags, value);
field_2_format_flags = fRMarkDel.setBoolean(field_2_format_flags, value);
}
/**
@ -868,7 +860,6 @@ public abstract class CHPAbstractType
public boolean isFRMarkDel()
{
return fRMarkDel.isSet(field_2_format_flags);
}
/**
@ -877,9 +868,7 @@ public abstract class CHPAbstractType
*/
public void setFOutline(boolean value)
{
field_2_format_flags = (int)fOutline.setBoolean(field_2_format_flags, value);
field_2_format_flags = fOutline.setBoolean(field_2_format_flags, value);
}
/**
@ -889,7 +878,6 @@ public abstract class CHPAbstractType
public boolean isFOutline()
{
return fOutline.isSet(field_2_format_flags);
}
/**
@ -898,9 +886,7 @@ public abstract class CHPAbstractType
*/
public void setFFldVanish(boolean value)
{
field_2_format_flags = (int)fFldVanish.setBoolean(field_2_format_flags, value);
field_2_format_flags = fFldVanish.setBoolean(field_2_format_flags, value);
}
/**
@ -910,7 +896,6 @@ public abstract class CHPAbstractType
public boolean isFFldVanish()
{
return fFldVanish.isSet(field_2_format_flags);
}
/**
@ -919,9 +904,7 @@ public abstract class CHPAbstractType
*/
public void setFSmallCaps(boolean value)
{
field_2_format_flags = (int)fSmallCaps.setBoolean(field_2_format_flags, value);
field_2_format_flags = fSmallCaps.setBoolean(field_2_format_flags, value);
}
/**
@ -931,7 +914,6 @@ public abstract class CHPAbstractType
public boolean isFSmallCaps()
{
return fSmallCaps.isSet(field_2_format_flags);
}
/**
@ -940,9 +922,7 @@ public abstract class CHPAbstractType
*/
public void setFCaps(boolean value)
{
field_2_format_flags = (int)fCaps.setBoolean(field_2_format_flags, value);
field_2_format_flags = fCaps.setBoolean(field_2_format_flags, value);
}
/**
@ -952,7 +932,6 @@ public abstract class CHPAbstractType
public boolean isFCaps()
{
return fCaps.isSet(field_2_format_flags);
}
/**
@ -961,9 +940,7 @@ public abstract class CHPAbstractType
*/
public void setFVanish(boolean value)
{
field_2_format_flags = (int)fVanish.setBoolean(field_2_format_flags, value);
field_2_format_flags = fVanish.setBoolean(field_2_format_flags, value);
}
/**
@ -973,7 +950,6 @@ public abstract class CHPAbstractType
public boolean isFVanish()
{
return fVanish.isSet(field_2_format_flags);
}
/**
@ -982,9 +958,7 @@ public abstract class CHPAbstractType
*/
public void setFRMark(boolean value)
{
field_2_format_flags = (int)fRMark.setBoolean(field_2_format_flags, value);
field_2_format_flags = fRMark.setBoolean(field_2_format_flags, value);
}
/**
@ -994,7 +968,6 @@ public abstract class CHPAbstractType
public boolean isFRMark()
{
return fRMark.isSet(field_2_format_flags);
}
/**
@ -1003,9 +976,7 @@ public abstract class CHPAbstractType
*/
public void setFSpec(boolean value)
{
field_2_format_flags = (int)fSpec.setBoolean(field_2_format_flags, value);
field_2_format_flags = fSpec.setBoolean(field_2_format_flags, value);
}
/**
@ -1015,7 +986,6 @@ public abstract class CHPAbstractType
public boolean isFSpec()
{
return fSpec.isSet(field_2_format_flags);
}
/**
@ -1024,9 +994,7 @@ public abstract class CHPAbstractType
*/
public void setFStrike(boolean value)
{
field_2_format_flags = (int)fStrike.setBoolean(field_2_format_flags, value);
field_2_format_flags = fStrike.setBoolean(field_2_format_flags, value);
}
/**
@ -1036,7 +1004,6 @@ public abstract class CHPAbstractType
public boolean isFStrike()
{
return fStrike.isSet(field_2_format_flags);
}
/**
@ -1045,9 +1012,7 @@ public abstract class CHPAbstractType
*/
public void setFObj(boolean value)
{
field_2_format_flags = (int)fObj.setBoolean(field_2_format_flags, value);
field_2_format_flags = fObj.setBoolean(field_2_format_flags, value);
}
/**
@ -1057,7 +1022,6 @@ public abstract class CHPAbstractType
public boolean isFObj()
{
return fObj.isSet(field_2_format_flags);
}
/**
@ -1066,9 +1030,7 @@ public abstract class CHPAbstractType
*/
public void setFShadow(boolean value)
{
field_2_format_flags = (int)fShadow.setBoolean(field_2_format_flags, value);
field_2_format_flags = fShadow.setBoolean(field_2_format_flags, value);
}
/**
@ -1078,7 +1040,6 @@ public abstract class CHPAbstractType
public boolean isFShadow()
{
return fShadow.isSet(field_2_format_flags);
}
/**
@ -1087,9 +1048,7 @@ public abstract class CHPAbstractType
*/
public void setFLowerCase(boolean value)
{
field_2_format_flags = (int)fLowerCase.setBoolean(field_2_format_flags, value);
field_2_format_flags = fLowerCase.setBoolean(field_2_format_flags, value);
}
/**
@ -1099,7 +1058,6 @@ public abstract class CHPAbstractType
public boolean isFLowerCase()
{
return fLowerCase.isSet(field_2_format_flags);
}
/**
@ -1108,9 +1066,7 @@ public abstract class CHPAbstractType
*/
public void setFData(boolean value)
{
field_2_format_flags = (int)fData.setBoolean(field_2_format_flags, value);
field_2_format_flags = fData.setBoolean(field_2_format_flags, value);
}
/**
@ -1120,7 +1076,6 @@ public abstract class CHPAbstractType
public boolean isFData()
{
return fData.isSet(field_2_format_flags);
}
/**
@ -1129,9 +1084,7 @@ public abstract class CHPAbstractType
*/
public void setFOle2(boolean value)
{
field_2_format_flags = (int)fOle2.setBoolean(field_2_format_flags, value);
field_2_format_flags = fOle2.setBoolean(field_2_format_flags, value);
}
/**
@ -1141,7 +1094,6 @@ public abstract class CHPAbstractType
public boolean isFOle2()
{
return fOle2.isSet(field_2_format_flags);
}
/**
@ -1150,9 +1102,7 @@ public abstract class CHPAbstractType
*/
public void setFEmboss(boolean value)
{
field_3_format_flags1 = (int)fEmboss.setBoolean(field_3_format_flags1, value);
field_3_format_flags1 = fEmboss.setBoolean(field_3_format_flags1, value);
}
/**
@ -1162,7 +1112,6 @@ public abstract class CHPAbstractType
public boolean isFEmboss()
{
return fEmboss.isSet(field_3_format_flags1);
}
/**
@ -1171,9 +1120,7 @@ public abstract class CHPAbstractType
*/
public void setFImprint(boolean value)
{
field_3_format_flags1 = (int)fImprint.setBoolean(field_3_format_flags1, value);
field_3_format_flags1 = fImprint.setBoolean(field_3_format_flags1, value);
}
/**
@ -1183,7 +1130,6 @@ public abstract class CHPAbstractType
public boolean isFImprint()
{
return fImprint.isSet(field_3_format_flags1);
}
/**
@ -1192,9 +1138,7 @@ public abstract class CHPAbstractType
*/
public void setFDStrike(boolean value)
{
field_3_format_flags1 = (int)fDStrike.setBoolean(field_3_format_flags1, value);
field_3_format_flags1 = fDStrike.setBoolean(field_3_format_flags1, value);
}
/**
@ -1204,7 +1148,6 @@ public abstract class CHPAbstractType
public boolean isFDStrike()
{
return fDStrike.isSet(field_3_format_flags1);
}
/**
@ -1213,9 +1156,7 @@ public abstract class CHPAbstractType
*/
public void setFUsePgsuSettings(boolean value)
{
field_3_format_flags1 = (int)fUsePgsuSettings.setBoolean(field_3_format_flags1, value);
field_3_format_flags1 = fUsePgsuSettings.setBoolean(field_3_format_flags1, value);
}
/**
@ -1225,7 +1166,6 @@ public abstract class CHPAbstractType
public boolean isFUsePgsuSettings()
{
return fUsePgsuSettings.isSet(field_3_format_flags1);
}
/**
@ -1235,8 +1175,6 @@ public abstract class CHPAbstractType
public void setIcoHighlight(byte value)
{
field_33_Highlight = (short)icoHighlight.setValue(field_33_Highlight, value);
}
/**
@ -1246,7 +1184,6 @@ public abstract class CHPAbstractType
public byte getIcoHighlight()
{
return ( byte )icoHighlight.getValue(field_33_Highlight);
}
/**
@ -1256,8 +1193,6 @@ public abstract class CHPAbstractType
public void setFHighlight(boolean value)
{
field_33_Highlight = (short)fHighlight.setBoolean(field_33_Highlight, value);
}
/**
@ -1267,7 +1202,6 @@ public abstract class CHPAbstractType
public boolean isFHighlight()
{
return fHighlight.isSet(field_33_Highlight);
}
/**
@ -1277,8 +1211,6 @@ public abstract class CHPAbstractType
public void setKcd(byte value)
{
field_33_Highlight = (short)kcd.setValue(field_33_Highlight, value);
}
/**
@ -1288,7 +1220,6 @@ public abstract class CHPAbstractType
public byte getKcd()
{
return ( byte )kcd.getValue(field_33_Highlight);
}
/**
@ -1298,8 +1229,6 @@ public abstract class CHPAbstractType
public void setFNavHighlight(boolean value)
{
field_33_Highlight = (short)fNavHighlight.setBoolean(field_33_Highlight, value);
}
/**
@ -1309,7 +1238,6 @@ public abstract class CHPAbstractType
public boolean isFNavHighlight()
{
return fNavHighlight.isSet(field_33_Highlight);
}
/**
@ -1319,8 +1247,6 @@ public abstract class CHPAbstractType
public void setFChsDiff(boolean value)
{
field_33_Highlight = (short)fChsDiff.setBoolean(field_33_Highlight, value);
}
/**
@ -1330,7 +1256,6 @@ public abstract class CHPAbstractType
public boolean isFChsDiff()
{
return fChsDiff.isSet(field_33_Highlight);
}
/**
@ -1340,8 +1265,6 @@ public abstract class CHPAbstractType
public void setFMacChs(boolean value)
{
field_33_Highlight = (short)fMacChs.setBoolean(field_33_Highlight, value);
}
/**
@ -1351,7 +1274,6 @@ public abstract class CHPAbstractType
public boolean isFMacChs()
{
return fMacChs.isSet(field_33_Highlight);
}
/**
@ -1361,8 +1283,6 @@ public abstract class CHPAbstractType
public void setFFtcAsciSym(boolean value)
{
field_33_Highlight = (short)fFtcAsciSym.setBoolean(field_33_Highlight, value);
}
/**
@ -1372,12 +1292,5 @@ public abstract class CHPAbstractType
public boolean isFFtcAsciSym()
{
return fFtcAsciSym.isSet(field_33_Highlight);
}
} // END OF CLASS
}

View File

@ -50,8 +50,10 @@ public static byte fromInt(int b) {
* This is a convenience method
*/
public static int fromByte(byte b) {
if(b >= 0) return (int)b;
return (int)(b + 256);
if(b >= 0) {
return b;
}
return b + 256;
}
/**
@ -183,7 +185,7 @@ public void compress(InputStream src, OutputStream res) throws IOException {
* Need our own class to handle keeping track of the
* code buffer, pending bytes to write out etc.
*/
private class Compressor {
private static final class Compressor {
// We use 12 bit codes:
// * 0-255 are real bytes
// * 256-4095 are the substring codes
@ -213,6 +215,9 @@ private class Compressor {
// And how many bits we've already set
int maskBitsSet = 0;
public Compressor() {
//
}
/**
* Returns the last place that the bytes from rawCode are found
* at in the buffer, or -1 if they can't be found

View File

@ -51,11 +51,11 @@ public abstract class ChunkHeader {
} else if(documentVersion == 5 || documentVersion == 4) {
ChunkHeaderV4V5 ch = new ChunkHeaderV4V5();
ch.type = (int)LittleEndian.getShort(data, offset + 0);
ch.id = (int)LittleEndian.getShort(data, offset + 2);
ch.type = LittleEndian.getShort(data, offset + 0);
ch.id = LittleEndian.getShort(data, offset + 2);
ch.unknown2 = (short)LittleEndian.getUnsignedByte(data, offset + 4);
ch.unknown3 = (short)LittleEndian.getUnsignedByte(data, offset + 5);
ch.unknown1 = (short)LittleEndian.getShort(data, offset + 6);
ch.unknown1 = LittleEndian.getShort(data, offset + 6);
ch.length = (int)LittleEndian.getUInt(data, offset + 8);
return ch;

View File

@ -257,7 +257,7 @@ public final class HSLFSlideShow extends POIDocument {
Record[] rec = new Record[lst.size()];
for (int i = 0; i < a.length; i++) {
Integer offset = (Integer)a[i];
rec[i] = (Record)Record.buildRecordAtOffset(docstream, offset.intValue());
rec[i] = Record.buildRecordAtOffset(docstream, offset.intValue());
if(rec[i] instanceof PersistRecord) {
PersistRecord psr = (PersistRecord)rec[i];
Integer id = (Integer)offset2id.get(offset);

View File

@ -41,9 +41,7 @@ import org.apache.poi.util.LittleEndian;
*
* @author Nick Burch
*/
public final class SlideShowDumper
{
public final class SlideShowDumper {
private InputStream istream;
private POIFSFileSystem filesystem;
@ -196,7 +194,7 @@ public final class SlideShowDumper
}
public String makeHex(short s) {
String hex = Integer.toHexString((int)s).toUpperCase();
String hex = Integer.toHexString(s).toUpperCase();
if(hex.length() == 1) { return "0" + hex; }
return hex;
}
@ -232,7 +230,7 @@ public void walkTree(int depth, int startPos, int maxLen) {
System.out.println(ind + "That's a " + recordName);
// Now check if it's a container or not
int container = (int)opt & 0x0f;
int container = opt & 0x0f;
// BinaryTagData seems to contain records, but it
// isn't tagged as doing so. Try stepping in anyway

View File

@ -53,9 +53,7 @@ import org.apache.poi.hslf.model.TextRun;
*
* @author Nick Burch
*/
public final class QuickButCruddyTextExtractor
{
public final class QuickButCruddyTextExtractor {
private POIFSFileSystem fs;
private InputStream is;
private byte[] pptContents;
@ -169,7 +167,7 @@ public final class QuickButCruddyTextExtractor
// If it's a container, step into it and return
// (If it's a container, option byte 1 BINARY_AND 0x0f will be 0x0f)
int container = (int)opt & 0x0f;
int container = opt & 0x0f;
if(container == 0x0f) {
return (startPos+8);
}

View File

@ -17,13 +17,22 @@
package org.apache.poi.hslf.model;
import org.apache.poi.ddf.*;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
import java.awt.geom.*;
import java.awt.geom.AffineTransform;
import java.awt.geom.GeneralPath;
import java.awt.geom.PathIterator;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.poi.ddf.EscherArrayProperty;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherOptRecord;
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.ddf.EscherSimpleProperty;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogger;
/**
* A "Freeform" shape.
@ -85,8 +94,8 @@ public final class Freeform extends AutoShape {
Rectangle2D bounds = path.getBounds2D();
PathIterator it = path.getPathIterator(new AffineTransform());
ArrayList segInfo = new ArrayList();
ArrayList pntInfo = new ArrayList();
List<byte[]> segInfo = new ArrayList<byte[]>();
List<Point2D.Double> pntInfo = new ArrayList<Point2D.Double>();
boolean isClosed = false;
while (!it.isDone()) {
double[] vals = new double[6];
@ -135,7 +144,7 @@ public final class Freeform extends AutoShape {
verticesProp.setNumberOfElementsInMemory(pntInfo.size());
verticesProp.setSizeOfElements(0xFFF0);
for (int i = 0; i < pntInfo.size(); i++) {
Point2D.Double pnt = (Point2D.Double)pntInfo.get(i);
Point2D.Double pnt = pntInfo.get(i);
byte[] data = new byte[4];
LittleEndian.putShort(data, 0, (short)((pnt.getX() - bounds.getX())*MASTER_DPI/POINT_DPI));
LittleEndian.putShort(data, 2, (short)((pnt.getY() - bounds.getY())*MASTER_DPI/POINT_DPI));
@ -148,7 +157,7 @@ public final class Freeform extends AutoShape {
segmentsProp.setNumberOfElementsInMemory(segInfo.size());
segmentsProp.setSizeOfElements(0x2);
for (int i = 0; i < segInfo.size(); i++) {
byte[] seg = (byte[])segInfo.get(i);
byte[] seg = segInfo.get(i);
segmentsProp.setElement(i, seg);
}
opt.addEscherProperty(segmentsProp);
@ -171,10 +180,10 @@ public final class Freeform extends AutoShape {
opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4));
EscherArrayProperty verticesProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES + 0x4000));
if(verticesProp == null) verticesProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES));
if(verticesProp == null) verticesProp = (EscherArrayProperty)getEscherProperty(opt, EscherProperties.GEOMETRY__VERTICES);
EscherArrayProperty segmentsProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__SEGMENTINFO + 0x4000));
if(segmentsProp == null) segmentsProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__SEGMENTINFO));
if(segmentsProp == null) segmentsProp = (EscherArrayProperty)getEscherProperty(opt, EscherProperties.GEOMETRY__SEGMENTINFO);
//sanity check
if(verticesProp == null) {

View File

@ -58,7 +58,7 @@ public final class CString extends RecordAtom {
* The meaning of the count is specific to the type of the parent record
*/
public int getOptions() {
return (int)LittleEndian.getShort(_header);
return LittleEndian.getShort(_header);
}
/**

View File

@ -30,9 +30,7 @@ import java.io.ByteArrayOutputStream;
*
* @author Nick Burch
*/
public final class ColorSchemeAtom extends RecordAtom
{
public final class ColorSchemeAtom extends RecordAtom {
private byte[] _header;
private static long _type = 2032l;
@ -108,14 +106,14 @@ public final class ColorSchemeAtom extends RecordAtom
System.arraycopy(source,start,_header,0,8);
// Grab the rgb values
backgroundColourRGB = (int)LittleEndian.getInt(source,start+8+0);
textAndLinesColourRGB = (int)LittleEndian.getInt(source,start+8+4);
shadowsColourRGB = (int)LittleEndian.getInt(source,start+8+8);
titleTextColourRGB = (int)LittleEndian.getInt(source,start+8+12);
fillsColourRGB = (int)LittleEndian.getInt(source,start+8+16);
accentColourRGB = (int)LittleEndian.getInt(source,start+8+20);
accentAndHyperlinkColourRGB = (int)LittleEndian.getInt(source,start+8+24);
accentAndFollowingHyperlinkColourRGB = (int)LittleEndian.getInt(source,start+8+28);
backgroundColourRGB = LittleEndian.getInt(source,start+8+0);
textAndLinesColourRGB = LittleEndian.getInt(source,start+8+4);
shadowsColourRGB = LittleEndian.getInt(source,start+8+8);
titleTextColourRGB = LittleEndian.getInt(source,start+8+12);
fillsColourRGB = LittleEndian.getInt(source,start+8+16);
accentColourRGB = LittleEndian.getInt(source,start+8+20);
accentAndHyperlinkColourRGB = LittleEndian.getInt(source,start+8+24);
accentAndFollowingHyperlinkColourRGB = LittleEndian.getInt(source,start+8+28);
}
/**
@ -181,7 +179,7 @@ public final class ColorSchemeAtom extends RecordAtom
byte[] with_zero = new byte[4];
System.arraycopy(rgb,0,with_zero,0,3);
with_zero[3] = 0;
int ret = (int)LittleEndian.getInt(with_zero,0);
int ret = LittleEndian.getInt(with_zero,0);
return ret;
}
@ -216,5 +214,4 @@ public final class ColorSchemeAtom extends RecordAtom
fillsColourRGB, accentColourRGB, accentAndHyperlinkColourRGB, accentAndFollowingHyperlinkColourRGB};
return clr[idx];
}
}

View File

@ -80,16 +80,23 @@ public final class DocumentAtom extends RecordAtom
/** Was the document saved with True Type fonts embeded? */
public boolean getSaveWithFonts() {
if(saveWithFonts == 0) { return false; } else { return true; } }
return saveWithFonts != 0;
}
/** Have the placeholders on the title slide been omitted? */
public boolean getOmitTitlePlace() {
if(omitTitlePlace == 0) { return false; } else { return true; } }
return omitTitlePlace != 0;
}
/** Is this a Bi-Directional PPT Doc? */
public boolean getRightToLeft() {
if(rightToLeft == 0) { return false; } else { return true; } }
return rightToLeft != 0;
}
/** Are comment shapes visible? */
public boolean getShowComments() {
if(showComments == 0) { return false; } else { return true; } }
return showComments != 0;
}
/* *************** record code follows ********************** */
@ -118,10 +125,10 @@ public final class DocumentAtom extends RecordAtom
handoutMasterPersist = LittleEndian.getInt(source,start+28+8);
// Get the ID of the first slide
firstSlideNum = (int)LittleEndian.getShort(source,start+32+8);
firstSlideNum = LittleEndian.getShort(source,start+32+8);
// Get the slide size type
slideSizeType = (int)LittleEndian.getShort(source,start+34+8);
slideSizeType = LittleEndian.getShort(source,start+34+8);
// Get the booleans as bytes
saveWithFonts = source[start+36+8];

View File

@ -32,9 +32,7 @@ import java.io.ByteArrayOutputStream;
*
* @author Nick Burch
*/
public final class EscherTextboxWrapper extends RecordContainer
{
public final class EscherTextboxWrapper extends RecordContainer {
private EscherTextboxRecord _escherRecord;
private long _type;
private int shapeId;
@ -49,7 +47,7 @@ public final class EscherTextboxWrapper extends RecordContainer
*/
public EscherTextboxWrapper(EscherTextboxRecord textbox) {
_escherRecord = textbox;
_type = (long)_escherRecord.getRecordId();
_type = _escherRecord.getRecordId();
// Find the child records in the escher data
byte[] data = _escherRecord.getData();

View File

@ -65,7 +65,7 @@ public final class NotesAtom extends RecordAtom
System.arraycopy(source,start,_header,0,8);
// Get the slide ID
slideID = (int)LittleEndian.getInt(source,start+8);
slideID = LittleEndian.getInt(source,start+8);
// Grok the flags, stored as bits
int flags = LittleEndian.getUShort(source,start+12);

View File

@ -86,8 +86,8 @@ public final class SlideAtom extends RecordAtom
layoutAtom = new SSlideLayoutAtom(SSlideLayoutAtomData);
// Get the IDs of the master and notes
masterID = (int)LittleEndian.getInt(source,start+12+8);
notesID = (int)LittleEndian.getInt(source,start+16+8);
masterID = LittleEndian.getInt(source,start+12+8);
notesID = LittleEndian.getInt(source,start+16+8);
// Grok the flags, stored as bits
int flags = LittleEndian.getUShort(source,start+20+8);
@ -214,7 +214,7 @@ public final class SlideAtom extends RecordAtom
}
// Grab out our data
geometry = (int)LittleEndian.getInt(data,0);
geometry = LittleEndian.getInt(data,0);
placeholderIDs = new byte[8];
System.arraycopy(data,4,placeholderIDs,0,8);
}

View File

@ -27,9 +27,7 @@ import java.io.OutputStream;
*
* @author Nick Burch
*/
public final class SlidePersistAtom extends RecordAtom
{
public final class SlidePersistAtom extends RecordAtom {
private byte[] _header;
private static long _type = 1011l;
@ -76,10 +74,10 @@ public final class SlidePersistAtom extends RecordAtom
System.arraycopy(source,start,_header,0,8);
// Grab the reference ID
refID = (int)LittleEndian.getInt(source,start+8);
refID = LittleEndian.getInt(source,start+8);
// Next up is a set of flags, but only bit 3 is used!
int flags = (int)LittleEndian.getInt(source,start+12);
int flags = LittleEndian.getInt(source,start+12);
if(flags == 4) {
hasShapesOtherThanPlaceholders = true;
} else {
@ -87,10 +85,10 @@ public final class SlidePersistAtom extends RecordAtom
}
// Now the number of Placeholder Texts
numPlaceholderTexts = (int)LittleEndian.getInt(source,start+16);
numPlaceholderTexts = LittleEndian.getInt(source,start+16);
// Last useful one is the unique slide identifier
slideIdentifier = (int)LittleEndian.getInt(source,start+20);
slideIdentifier = LittleEndian.getInt(source,start+20);
// Finally you have typically 4 or 8 bytes of reserved fields,
// all zero running from 24 bytes in to the end

View File

@ -72,7 +72,7 @@ public final class TextHeaderAtom extends RecordAtom implements ParentAwareRecor
System.arraycopy(source,start,_header,0,8);
// Grab the type
textType = (int)LittleEndian.getInt(source,start+8);
textType = LittleEndian.getInt(source,start+8);
}
/**

View File

@ -82,30 +82,30 @@ public final class UserEditAtom extends PositionDependentRecordAtom
System.arraycopy(source,start,_header,0,8);
// Get the last viewed slide ID
lastViewedSlideID = (int)LittleEndian.getInt(source,start+0+8);
lastViewedSlideID = LittleEndian.getInt(source,start+0+8);
// Get the PPT version
pptVersion = (int)LittleEndian.getInt(source,start+4+8);
pptVersion = LittleEndian.getInt(source,start+4+8);
// Get the offset to the previous incremental save's UserEditAtom
// This will be the byte offset on disk where the previous one
// starts, or 0 if this is the first one
lastUserEditAtomOffset = (int)LittleEndian.getInt(source,start+8+8);
lastUserEditAtomOffset = LittleEndian.getInt(source,start+8+8);
// Get the offset to the persist pointers
// This will be the byte offset on disk where the preceding
// PersistPtrFullBlock or PersistPtrIncrementalBlock starts
persistPointersOffset = (int)LittleEndian.getInt(source,start+12+8);
persistPointersOffset = LittleEndian.getInt(source,start+12+8);
// Get the persist reference for the document persist object
// Normally seems to be 1
docPersistRef = (int)LittleEndian.getInt(source,start+16+8);
docPersistRef = LittleEndian.getInt(source,start+16+8);
// Maximum number of persist objects written
maxPersistWritten = (int)LittleEndian.getInt(source,start+20+8);
maxPersistWritten = LittleEndian.getInt(source,start+20+8);
// Last view type
lastViewType = (short)LittleEndian.getShort(source,start+24+8);
lastViewType = LittleEndian.getShort(source,start+24+8);
// There might be a few more bytes, which are a reserved field
reserved = new byte[len-26-8];

View File

@ -47,12 +47,8 @@ import org.apache.poi.poifs.storage.BlockWritable;
*
* @author Travis Ferguson
*/
public class POIFSChunkParser {
/**
* Constructor
* @param fs
* @throws IOException
*/
public final class POIFSChunkParser {
public POIFSChunkParser(POIFSFileSystem fs) throws IOException {
this.setFileSystem(fs);
}
@ -61,7 +57,6 @@ public class POIFSChunkParser {
/**
* Set the POIFileSystem object that this object is using.
* @param fs
* @throws IOException
*/
public void setFileSystem(POIFSFileSystem fs) throws IOException {
this.fs = fs;
@ -77,7 +72,6 @@ public class POIFSChunkParser {
/**
* Reparse the FileSystem object, resetting all the chunks stored in this object
* @throws IOException
*
*/
public void reparseFileSystem() throws IOException {
@ -138,10 +132,10 @@ public class POIFSChunkParser {
* @param entryName
*/
public Object getChunk(HashMap dirMap, String entryName) {
if(dirMap == null) return null;
else {
return dirMap.get(entryName);
if(dirMap == null) {
return null;
}
return dirMap.get(entryName);
}
/**
@ -199,7 +193,7 @@ public class POIFSChunkParser {
String attachmentIdString = entry.replace(AttachmentChunks.namePrefix, "");
try {
int attachmentId = Integer.parseInt(attachmentIdString);
attachmentList.add((HashMap)directoryMap.get(entry));
attachmentList.add(directoryMap.get(entry));
} catch (NumberFormatException nfe) {
System.err.println("Invalid attachment id");
}
@ -263,11 +257,11 @@ public class POIFSChunkParser {
* @throws java.io.IOException
*/
private void processDocumentNode(DocumentNode obj, HashMap currentObj) throws IOException {
String blockName = ((DocumentNode)obj).getName();
String blockName = obj.getName();
Iterator viewIt = null;
if( ((DocumentNode)obj).preferArray()) {
Object[] arr = ((DocumentNode)obj).getViewableArray();
if( obj.preferArray()) {
Object[] arr = obj.getViewableArray();
ArrayList viewList = new ArrayList(arr.length);
for(int i = 0; i < arr.length; i++) {
@ -275,7 +269,7 @@ public class POIFSChunkParser {
}
viewIt = viewList.iterator();
} else {
viewIt = ((DocumentNode)obj).getViewableIterator();
viewIt = obj.getViewableIterator();
}
while(viewIt.hasNext()) {

View File

@ -133,7 +133,7 @@ public final class ListData
int resetListID()
{
_lsid = (int)(Math.random() * (double)System.currentTimeMillis());
_lsid = (int)(Math.random() * System.currentTimeMillis());
return _lsid;
}

View File

@ -225,21 +225,19 @@ public final class StyleSheet implements HDFType {
{
parentPAP = _styleDescriptions[baseIndex].getPAP();
if(parentPAP == null)
{
if(parentPAP == null) {
if(baseIndex == istd) {
// Oh dear, style claims that it is its own parent
throw new IllegalStateException("Pap style " + istd + " claimed to have itself as its parent, which isn't allowed");
} else {
}
// Create the parent style
createPap(baseIndex);
parentPAP = _styleDescriptions[baseIndex].getPAP();
}
}
}
pap = (ParagraphProperties)ParagraphSprmUncompressor.uncompressPAP(parentPAP, papx, 2);
pap = ParagraphSprmUncompressor.uncompressPAP(parentPAP, papx, 2);
sd.setPAP(pap);
}
}
@ -274,7 +272,7 @@ public final class StyleSheet implements HDFType {
}
chp = (CharacterProperties)CharacterSprmUncompressor.uncompressCHP(parentCHP, chpx, 0);
chp = CharacterSprmUncompressor.uncompressCHP(parentCHP, chpx, 0);
sd.setCHP(chp);
}
}

View File

@ -818,9 +818,7 @@ public abstract class CHPAbstractType
*/
public void setFBold(boolean value)
{
field_2_format_flags = (int)fBold.setBoolean(field_2_format_flags, value);
field_2_format_flags = fBold.setBoolean(field_2_format_flags, value);
}
/**
@ -830,7 +828,6 @@ public abstract class CHPAbstractType
public boolean isFBold()
{
return fBold.isSet(field_2_format_flags);
}
/**
@ -839,9 +836,7 @@ public abstract class CHPAbstractType
*/
public void setFItalic(boolean value)
{
field_2_format_flags = (int)fItalic.setBoolean(field_2_format_flags, value);
field_2_format_flags = fItalic.setBoolean(field_2_format_flags, value);
}
/**
@ -851,7 +846,6 @@ public abstract class CHPAbstractType
public boolean isFItalic()
{
return fItalic.isSet(field_2_format_flags);
}
/**
@ -860,9 +854,7 @@ public abstract class CHPAbstractType
*/
public void setFRMarkDel(boolean value)
{
field_2_format_flags = (int)fRMarkDel.setBoolean(field_2_format_flags, value);
field_2_format_flags = fRMarkDel.setBoolean(field_2_format_flags, value);
}
/**
@ -872,7 +864,6 @@ public abstract class CHPAbstractType
public boolean isFRMarkDel()
{
return fRMarkDel.isSet(field_2_format_flags);
}
/**
@ -881,9 +872,7 @@ public abstract class CHPAbstractType
*/
public void setFOutline(boolean value)
{
field_2_format_flags = (int)fOutline.setBoolean(field_2_format_flags, value);
field_2_format_flags = fOutline.setBoolean(field_2_format_flags, value);
}
/**
@ -893,7 +882,6 @@ public abstract class CHPAbstractType
public boolean isFOutline()
{
return fOutline.isSet(field_2_format_flags);
}
/**
@ -902,9 +890,7 @@ public abstract class CHPAbstractType
*/
public void setFFldVanish(boolean value)
{
field_2_format_flags = (int)fFldVanish.setBoolean(field_2_format_flags, value);
field_2_format_flags = fFldVanish.setBoolean(field_2_format_flags, value);
}
/**
@ -914,7 +900,6 @@ public abstract class CHPAbstractType
public boolean isFFldVanish()
{
return fFldVanish.isSet(field_2_format_flags);
}
/**
@ -923,9 +908,7 @@ public abstract class CHPAbstractType
*/
public void setFSmallCaps(boolean value)
{
field_2_format_flags = (int)fSmallCaps.setBoolean(field_2_format_flags, value);
field_2_format_flags = fSmallCaps.setBoolean(field_2_format_flags, value);
}
/**
@ -935,7 +918,6 @@ public abstract class CHPAbstractType
public boolean isFSmallCaps()
{
return fSmallCaps.isSet(field_2_format_flags);
}
/**
@ -944,9 +926,7 @@ public abstract class CHPAbstractType
*/
public void setFCaps(boolean value)
{
field_2_format_flags = (int)fCaps.setBoolean(field_2_format_flags, value);
field_2_format_flags = fCaps.setBoolean(field_2_format_flags, value);
}
/**
@ -956,7 +936,6 @@ public abstract class CHPAbstractType
public boolean isFCaps()
{
return fCaps.isSet(field_2_format_flags);
}
/**
@ -965,9 +944,7 @@ public abstract class CHPAbstractType
*/
public void setFVanish(boolean value)
{
field_2_format_flags = (int)fVanish.setBoolean(field_2_format_flags, value);
field_2_format_flags = fVanish.setBoolean(field_2_format_flags, value);
}
/**
@ -977,7 +954,6 @@ public abstract class CHPAbstractType
public boolean isFVanish()
{
return fVanish.isSet(field_2_format_flags);
}
/**
@ -986,9 +962,7 @@ public abstract class CHPAbstractType
*/
public void setFRMark(boolean value)
{
field_2_format_flags = (int)fRMark.setBoolean(field_2_format_flags, value);
field_2_format_flags = fRMark.setBoolean(field_2_format_flags, value);
}
/**
@ -998,7 +972,6 @@ public abstract class CHPAbstractType
public boolean isFRMark()
{
return fRMark.isSet(field_2_format_flags);
}
/**
@ -1007,9 +980,7 @@ public abstract class CHPAbstractType
*/
public void setFSpec(boolean value)
{
field_2_format_flags = (int)fSpec.setBoolean(field_2_format_flags, value);
field_2_format_flags = fSpec.setBoolean(field_2_format_flags, value);
}
/**
@ -1019,7 +990,6 @@ public abstract class CHPAbstractType
public boolean isFSpec()
{
return fSpec.isSet(field_2_format_flags);
}
/**
@ -1028,9 +998,7 @@ public abstract class CHPAbstractType
*/
public void setFStrike(boolean value)
{
field_2_format_flags = (int)fStrike.setBoolean(field_2_format_flags, value);
field_2_format_flags = fStrike.setBoolean(field_2_format_flags, value);
}
/**
@ -1040,7 +1008,6 @@ public abstract class CHPAbstractType
public boolean isFStrike()
{
return fStrike.isSet(field_2_format_flags);
}
/**
@ -1049,9 +1016,7 @@ public abstract class CHPAbstractType
*/
public void setFObj(boolean value)
{
field_2_format_flags = (int)fObj.setBoolean(field_2_format_flags, value);
field_2_format_flags = fObj.setBoolean(field_2_format_flags, value);
}
/**
@ -1061,7 +1026,6 @@ public abstract class CHPAbstractType
public boolean isFObj()
{
return fObj.isSet(field_2_format_flags);
}
/**
@ -1070,9 +1034,7 @@ public abstract class CHPAbstractType
*/
public void setFShadow(boolean value)
{
field_2_format_flags = (int)fShadow.setBoolean(field_2_format_flags, value);
field_2_format_flags = fShadow.setBoolean(field_2_format_flags, value);
}
/**
@ -1082,7 +1044,6 @@ public abstract class CHPAbstractType
public boolean isFShadow()
{
return fShadow.isSet(field_2_format_flags);
}
/**
@ -1091,9 +1052,7 @@ public abstract class CHPAbstractType
*/
public void setFLowerCase(boolean value)
{
field_2_format_flags = (int)fLowerCase.setBoolean(field_2_format_flags, value);
field_2_format_flags = fLowerCase.setBoolean(field_2_format_flags, value);
}
/**
@ -1103,7 +1062,6 @@ public abstract class CHPAbstractType
public boolean isFLowerCase()
{
return fLowerCase.isSet(field_2_format_flags);
}
/**
@ -1112,9 +1070,7 @@ public abstract class CHPAbstractType
*/
public void setFData(boolean value)
{
field_2_format_flags = (int)fData.setBoolean(field_2_format_flags, value);
field_2_format_flags = fData.setBoolean(field_2_format_flags, value);
}
/**
@ -1124,7 +1080,6 @@ public abstract class CHPAbstractType
public boolean isFData()
{
return fData.isSet(field_2_format_flags);
}
/**
@ -1133,9 +1088,7 @@ public abstract class CHPAbstractType
*/
public void setFOle2(boolean value)
{
field_2_format_flags = (int)fOle2.setBoolean(field_2_format_flags, value);
field_2_format_flags = fOle2.setBoolean(field_2_format_flags, value);
}
/**
@ -1145,7 +1098,6 @@ public abstract class CHPAbstractType
public boolean isFOle2()
{
return fOle2.isSet(field_2_format_flags);
}
/**
@ -1154,9 +1106,7 @@ public abstract class CHPAbstractType
*/
public void setFEmboss(boolean value)
{
field_3_format_flags1 = (int)fEmboss.setBoolean(field_3_format_flags1, value);
field_3_format_flags1 = fEmboss.setBoolean(field_3_format_flags1, value);
}
/**
@ -1166,7 +1116,6 @@ public abstract class CHPAbstractType
public boolean isFEmboss()
{
return fEmboss.isSet(field_3_format_flags1);
}
/**
@ -1175,9 +1124,7 @@ public abstract class CHPAbstractType
*/
public void setFImprint(boolean value)
{
field_3_format_flags1 = (int)fImprint.setBoolean(field_3_format_flags1, value);
field_3_format_flags1 = fImprint.setBoolean(field_3_format_flags1, value);
}
/**
@ -1187,7 +1134,6 @@ public abstract class CHPAbstractType
public boolean isFImprint()
{
return fImprint.isSet(field_3_format_flags1);
}
/**
@ -1196,9 +1142,7 @@ public abstract class CHPAbstractType
*/
public void setFDStrike(boolean value)
{
field_3_format_flags1 = (int)fDStrike.setBoolean(field_3_format_flags1, value);
field_3_format_flags1 = fDStrike.setBoolean(field_3_format_flags1, value);
}
/**
@ -1208,7 +1152,6 @@ public abstract class CHPAbstractType
public boolean isFDStrike()
{
return fDStrike.isSet(field_3_format_flags1);
}
/**
@ -1217,9 +1160,7 @@ public abstract class CHPAbstractType
*/
public void setFUsePgsuSettings(boolean value)
{
field_3_format_flags1 = (int)fUsePgsuSettings.setBoolean(field_3_format_flags1, value);
field_3_format_flags1 = fUsePgsuSettings.setBoolean(field_3_format_flags1, value);
}
/**
@ -1229,7 +1170,6 @@ public abstract class CHPAbstractType
public boolean isFUsePgsuSettings()
{
return fUsePgsuSettings.isSet(field_3_format_flags1);
}
/**
@ -1239,8 +1179,6 @@ public abstract class CHPAbstractType
public void setIcoHighlight(byte value)
{
field_33_Highlight = (short)icoHighlight.setValue(field_33_Highlight, value);
}
/**
@ -1250,7 +1188,6 @@ public abstract class CHPAbstractType
public byte getIcoHighlight()
{
return ( byte )icoHighlight.getValue(field_33_Highlight);
}
/**
@ -1260,8 +1197,6 @@ public abstract class CHPAbstractType
public void setFHighlight(boolean value)
{
field_33_Highlight = (short)fHighlight.setBoolean(field_33_Highlight, value);
}
/**
@ -1271,7 +1206,6 @@ public abstract class CHPAbstractType
public boolean isFHighlight()
{
return fHighlight.isSet(field_33_Highlight);
}
/**
@ -1281,8 +1215,6 @@ public abstract class CHPAbstractType
public void setKcd(byte value)
{
field_33_Highlight = (short)kcd.setValue(field_33_Highlight, value);
}
/**
@ -1292,7 +1224,6 @@ public abstract class CHPAbstractType
public byte getKcd()
{
return ( byte )kcd.getValue(field_33_Highlight);
}
/**
@ -1302,8 +1233,6 @@ public abstract class CHPAbstractType
public void setFNavHighlight(boolean value)
{
field_33_Highlight = (short)fNavHighlight.setBoolean(field_33_Highlight, value);
}
/**
@ -1313,7 +1242,6 @@ public abstract class CHPAbstractType
public boolean isFNavHighlight()
{
return fNavHighlight.isSet(field_33_Highlight);
}
/**
@ -1323,8 +1251,6 @@ public abstract class CHPAbstractType
public void setFChsDiff(boolean value)
{
field_33_Highlight = (short)fChsDiff.setBoolean(field_33_Highlight, value);
}
/**
@ -1334,7 +1260,6 @@ public abstract class CHPAbstractType
public boolean isFChsDiff()
{
return fChsDiff.isSet(field_33_Highlight);
}
/**
@ -1344,8 +1269,6 @@ public abstract class CHPAbstractType
public void setFMacChs(boolean value)
{
field_33_Highlight = (short)fMacChs.setBoolean(field_33_Highlight, value);
}
/**
@ -1355,7 +1278,6 @@ public abstract class CHPAbstractType
public boolean isFMacChs()
{
return fMacChs.isSet(field_33_Highlight);
}
/**
@ -1365,8 +1287,6 @@ public abstract class CHPAbstractType
public void setFFtcAsciSym(boolean value)
{
field_33_Highlight = (short)fFtcAsciSym.setBoolean(field_33_Highlight, value);
}
/**
@ -1376,12 +1296,5 @@ public abstract class CHPAbstractType
public boolean isFFtcAsciSym()
{
return fFtcAsciSym.isSet(field_33_Highlight);
}
} // END OF CLASS
}

View File

@ -88,26 +88,24 @@ public abstract class FIBAbstractType implements HDFType {
field_12_chsTables = LittleEndian.getShort(data, 0x16 + offset);
field_13_fcMin = LittleEndian.getInt(data, 0x18 + offset);
field_14_fcMac = LittleEndian.getInt(data, 0x1c + offset);
}
public void serialize(byte[] data, int offset)
{
LittleEndian.putShort(data, 0x0 + offset, (short)field_1_wIdent);;
LittleEndian.putShort(data, 0x2 + offset, (short)field_2_nFib);;
LittleEndian.putShort(data, 0x4 + offset, (short)field_3_nProduct);;
LittleEndian.putShort(data, 0x6 + offset, (short)field_4_lid);;
LittleEndian.putShort(data, 0x8 + offset, (short)field_5_pnNext);;
LittleEndian.putShort(data, 0xa + offset, (short)field_6_options);;
LittleEndian.putShort(data, 0xc + offset, (short)field_7_nFibBack);;
LittleEndian.putShort(data, 0xe + offset, (short)field_8_lKey);;
LittleEndian.putShort(data, 0x10 + offset, (short)field_9_envr);;
LittleEndian.putShort(data, 0x12 + offset, (short)field_10_history);;
LittleEndian.putShort(data, 0x14 + offset, (short)field_11_chs);;
LittleEndian.putShort(data, 0x16 + offset, (short)field_12_chsTables);;
LittleEndian.putInt(data, 0x18 + offset, field_13_fcMin);;
LittleEndian.putInt(data, 0x1c + offset, field_14_fcMac);;
LittleEndian.putShort(data, 0x0 + offset, (short)field_1_wIdent);
LittleEndian.putShort(data, 0x2 + offset, (short)field_2_nFib);
LittleEndian.putShort(data, 0x4 + offset, (short)field_3_nProduct);
LittleEndian.putShort(data, 0x6 + offset, (short)field_4_lid);
LittleEndian.putShort(data, 0x8 + offset, (short)field_5_pnNext);
LittleEndian.putShort(data, 0xa + offset, field_6_options);
LittleEndian.putShort(data, 0xc + offset, (short)field_7_nFibBack);
LittleEndian.putShort(data, 0xe + offset, (short)field_8_lKey);
LittleEndian.putShort(data, 0x10 + offset, (short)field_9_envr);
LittleEndian.putShort(data, 0x12 + offset, field_10_history);
LittleEndian.putShort(data, 0x14 + offset, (short)field_11_chs);
LittleEndian.putShort(data, 0x16 + offset, (short)field_12_chsTables);
LittleEndian.putInt(data, 0x18 + offset, field_13_fcMin);
LittleEndian.putInt(data, 0x1c + offset, field_14_fcMac);
}
public String toString()
@ -422,8 +420,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFDot(boolean value)
{
field_6_options = (short)fDot.setBoolean(field_6_options, value);
}
/**
@ -433,7 +429,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFDot()
{
return fDot.isSet(field_6_options);
}
/**
@ -443,8 +438,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFGlsy(boolean value)
{
field_6_options = (short)fGlsy.setBoolean(field_6_options, value);
}
/**
@ -454,7 +447,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFGlsy()
{
return fGlsy.isSet(field_6_options);
}
/**
@ -464,8 +456,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFComplex(boolean value)
{
field_6_options = (short)fComplex.setBoolean(field_6_options, value);
}
/**
@ -475,7 +465,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFComplex()
{
return fComplex.isSet(field_6_options);
}
/**
@ -485,8 +474,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFHasPic(boolean value)
{
field_6_options = (short)fHasPic.setBoolean(field_6_options, value);
}
/**
@ -496,7 +483,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFHasPic()
{
return fHasPic.isSet(field_6_options);
}
/**
@ -506,8 +492,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setCQuickSaves(byte value)
{
field_6_options = (short)cQuickSaves.setValue(field_6_options, value);
}
/**
@ -517,7 +501,6 @@ public abstract class FIBAbstractType implements HDFType {
public byte getCQuickSaves()
{
return ( byte )cQuickSaves.getValue(field_6_options);
}
/**
@ -527,8 +510,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFEncrypted(boolean value)
{
field_6_options = (short)fEncrypted.setBoolean(field_6_options, value);
}
/**
@ -538,7 +519,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFEncrypted()
{
return fEncrypted.isSet(field_6_options);
}
/**
@ -548,8 +528,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFWhichTblStm(boolean value)
{
field_6_options = (short)fWhichTblStm.setBoolean(field_6_options, value);
}
/**
@ -559,7 +537,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFWhichTblStm()
{
return fWhichTblStm.isSet(field_6_options);
}
/**
@ -569,8 +546,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFReadOnlyRecommended(boolean value)
{
field_6_options = (short)fReadOnlyRecommended.setBoolean(field_6_options, value);
}
/**
@ -580,7 +555,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFReadOnlyRecommended()
{
return fReadOnlyRecommended.isSet(field_6_options);
}
/**
@ -590,8 +564,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFWriteReservation(boolean value)
{
field_6_options = (short)fWriteReservation.setBoolean(field_6_options, value);
}
/**
@ -601,7 +573,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFWriteReservation()
{
return fWriteReservation.isSet(field_6_options);
}
/**
@ -611,8 +582,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFExtChar(boolean value)
{
field_6_options = (short)fExtChar.setBoolean(field_6_options, value);
}
/**
@ -622,7 +591,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFExtChar()
{
return fExtChar.isSet(field_6_options);
}
/**
@ -632,8 +600,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFLoadOverride(boolean value)
{
field_6_options = (short)fLoadOverride.setBoolean(field_6_options, value);
}
/**
@ -643,7 +609,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFLoadOverride()
{
return fLoadOverride.isSet(field_6_options);
}
/**
@ -653,8 +618,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFFarEast(boolean value)
{
field_6_options = (short)fFarEast.setBoolean(field_6_options, value);
}
/**
@ -664,7 +627,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFFarEast()
{
return fFarEast.isSet(field_6_options);
}
/**
@ -674,8 +636,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFCrypto(boolean value)
{
field_6_options = (short)fCrypto.setBoolean(field_6_options, value);
}
/**
@ -685,7 +645,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFCrypto()
{
return fCrypto.isSet(field_6_options);
}
/**
@ -695,8 +654,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFMac(boolean value)
{
field_10_history = (short)fMac.setBoolean(field_10_history, value);
}
/**
@ -706,7 +663,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFMac()
{
return fMac.isSet(field_10_history);
}
/**
@ -716,8 +672,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFEmptySpecial(boolean value)
{
field_10_history = (short)fEmptySpecial.setBoolean(field_10_history, value);
}
/**
@ -727,7 +681,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFEmptySpecial()
{
return fEmptySpecial.isSet(field_10_history);
}
/**
@ -737,8 +690,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFLoadOverridePage(boolean value)
{
field_10_history = (short)fLoadOverridePage.setBoolean(field_10_history, value);
}
/**
@ -748,7 +699,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFLoadOverridePage()
{
return fLoadOverridePage.isSet(field_10_history);
}
/**
@ -758,8 +708,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFFutureSavedUndo(boolean value)
{
field_10_history = (short)fFutureSavedUndo.setBoolean(field_10_history, value);
}
/**
@ -769,7 +717,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFFutureSavedUndo()
{
return fFutureSavedUndo.isSet(field_10_history);
}
/**
@ -779,8 +726,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFWord97Saved(boolean value)
{
field_10_history = (short)fWord97Saved.setBoolean(field_10_history, value);
}
/**
@ -790,7 +735,6 @@ public abstract class FIBAbstractType implements HDFType {
public boolean isFWord97Saved()
{
return fWord97Saved.isSet(field_10_history);
}
/**
@ -800,8 +744,6 @@ public abstract class FIBAbstractType implements HDFType {
public void setFSpare0(byte value)
{
field_10_history = (short)fSpare0.setValue(field_10_history, value);
}
/**
@ -811,12 +753,5 @@ public abstract class FIBAbstractType implements HDFType {
public byte getFSpare0()
{
return ( byte )fSpare0.getValue(field_10_history);
}
} // END OF CLASS
}

View File

@ -67,13 +67,12 @@ public abstract class TCAbstractType implements HDFType {
public void serialize(byte[] data, int offset)
{
LittleEndian.putShort(data, 0x0 + offset, (short)field_1_rgf);;
LittleEndian.putShort(data, 0x2 + offset, (short)field_2_unused);;
field_3_brcTop.serialize(data, 0x4 + offset);;
field_4_brcLeft.serialize(data, 0x8 + offset);;
field_5_brcBottom.serialize(data, 0xc + offset);;
field_6_brcRight.serialize(data, 0x10 + offset);;
LittleEndian.putShort(data, 0x0 + offset, field_1_rgf);
LittleEndian.putShort(data, 0x2 + offset, field_2_unused);
field_3_brcTop.serialize(data, 0x4 + offset);
field_4_brcLeft.serialize(data, 0x8 + offset);
field_5_brcBottom.serialize(data, 0xc + offset);
field_6_brcRight.serialize(data, 0x10 + offset);
}
public String toString()
@ -225,8 +224,6 @@ public abstract class TCAbstractType implements HDFType {
public void setFFirstMerged(boolean value)
{
field_1_rgf = (short)fFirstMerged.setBoolean(field_1_rgf, value);
}
/**
@ -236,7 +233,6 @@ public abstract class TCAbstractType implements HDFType {
public boolean isFFirstMerged()
{
return fFirstMerged.isSet(field_1_rgf);
}
/**
@ -246,8 +242,6 @@ public abstract class TCAbstractType implements HDFType {
public void setFMerged(boolean value)
{
field_1_rgf = (short)fMerged.setBoolean(field_1_rgf, value);
}
/**
@ -257,7 +251,6 @@ public abstract class TCAbstractType implements HDFType {
public boolean isFMerged()
{
return fMerged.isSet(field_1_rgf);
}
/**
@ -267,8 +260,6 @@ public abstract class TCAbstractType implements HDFType {
public void setFVertical(boolean value)
{
field_1_rgf = (short)fVertical.setBoolean(field_1_rgf, value);
}
/**
@ -278,7 +269,6 @@ public abstract class TCAbstractType implements HDFType {
public boolean isFVertical()
{
return fVertical.isSet(field_1_rgf);
}
/**
@ -288,8 +278,6 @@ public abstract class TCAbstractType implements HDFType {
public void setFBackward(boolean value)
{
field_1_rgf = (short)fBackward.setBoolean(field_1_rgf, value);
}
/**
@ -299,7 +287,6 @@ public abstract class TCAbstractType implements HDFType {
public boolean isFBackward()
{
return fBackward.isSet(field_1_rgf);
}
/**
@ -309,8 +296,6 @@ public abstract class TCAbstractType implements HDFType {
public void setFRotateFont(boolean value)
{
field_1_rgf = (short)fRotateFont.setBoolean(field_1_rgf, value);
}
/**
@ -320,7 +305,6 @@ public abstract class TCAbstractType implements HDFType {
public boolean isFRotateFont()
{
return fRotateFont.isSet(field_1_rgf);
}
/**
@ -330,8 +314,6 @@ public abstract class TCAbstractType implements HDFType {
public void setFVertMerge(boolean value)
{
field_1_rgf = (short)fVertMerge.setBoolean(field_1_rgf, value);
}
/**
@ -341,7 +323,6 @@ public abstract class TCAbstractType implements HDFType {
public boolean isFVertMerge()
{
return fVertMerge.isSet(field_1_rgf);
}
/**
@ -351,8 +332,6 @@ public abstract class TCAbstractType implements HDFType {
public void setFVertRestart(boolean value)
{
field_1_rgf = (short)fVertRestart.setBoolean(field_1_rgf, value);
}
/**
@ -362,7 +341,6 @@ public abstract class TCAbstractType implements HDFType {
public boolean isFVertRestart()
{
return fVertRestart.isSet(field_1_rgf);
}
/**
@ -372,8 +350,6 @@ public abstract class TCAbstractType implements HDFType {
public void setVertAlign(byte value)
{
field_1_rgf = (short)vertAlign.setValue(field_1_rgf, value);
}
/**
@ -383,12 +359,5 @@ public abstract class TCAbstractType implements HDFType {
public byte getVertAlign()
{
return ( byte )vertAlign.getValue(field_1_rgf);
}
} // END OF CLASS
}

View File

@ -46,7 +46,7 @@ public final class CharacterSprmUncompressor
while (sprmIt.hasNext())
{
SprmOperation sprm = (SprmOperation)sprmIt.next();
SprmOperation sprm = sprmIt.next();
unCompressCHPOperation(parent, newProperties, sprm);
}
@ -108,8 +108,8 @@ public final class CharacterSprmUncompressor
break;
case 0x9:
newCHP.setFSpec (true);
newCHP.setFtcSym ((short) LittleEndian.getShort (sprm.getGrpprl(), sprm.getGrpprlOffset()));
newCHP.setXchSym ((short) LittleEndian.getShort (sprm.getGrpprl(), sprm.getGrpprlOffset() + 2));
newCHP.setFtcSym (LittleEndian.getShort (sprm.getGrpprl(), sprm.getGrpprlOffset()));
newCHP.setXchSym (LittleEndian.getShort (sprm.getGrpprl(), sprm.getGrpprlOffset() + 2));
break;
case 0xa:
newCHP.setFOle2 (getFlag (sprm.getOperand()));
@ -426,8 +426,8 @@ public final class CharacterSprmUncompressor
// styleSheet, opSize);
break;
case 0x4d:
float percentage = (float) sprm.getOperand() / 100.0f;
int add = (int) ((float) percentage * (float) newCHP.getHps ());
float percentage = sprm.getOperand() / 100.0f;
int add = (int) (percentage * newCHP.getHps ());
newCHP.setHps (newCHP.getHps () + add);
break;
case 0x4e:
@ -462,7 +462,7 @@ public final class CharacterSprmUncompressor
byte[] buf = sprm.getGrpprl();
int offset = sprm.getGrpprlOffset();
newCHP.setFPropMark (buf[offset]);
newCHP.setIbstPropRMark ((short) LittleEndian.getShort (buf, offset + 1));
newCHP.setIbstPropRMark (LittleEndian.getShort (buf, offset + 1));
newCHP.setDttmPropRMark (new DateAndTime(buf, offset +3));
break;
case 0x58:
@ -494,7 +494,7 @@ public final class CharacterSprmUncompressor
buf = sprm.getGrpprl();
offset = sprm.getGrpprlOffset();
newCHP.setFDispFldRMark (buf[offset]);
newCHP.setIbstDispFldRMark ((short) LittleEndian.getShort (buf, offset + 1));
newCHP.setIbstDispFldRMark (LittleEndian.getShort (buf, offset + 1));
newCHP.setDttmDispFldRMark (new DateAndTime(buf, offset + 3));
System.arraycopy (buf, offset + 7, xstDispFldRMark, 0, 32);
newCHP.setXstDispFldRMark (xstDispFldRMark);
@ -553,14 +553,7 @@ public final class CharacterSprmUncompressor
*/
public static boolean getFlag (int x)
{
if (x != 0)
{
return true;
}
else
{
return false;
}
return x != 0;
}
private static boolean getCHPFlag (byte x, boolean oldVal)

View File

@ -54,7 +54,7 @@ public final class ParagraphSprmUncompressor
while (sprmIt.hasNext())
{
SprmOperation sprm = (SprmOperation)sprmIt.next();
SprmOperation sprm = sprmIt.next();
// PAPXs can contain table sprms if the paragraph marks the end of a
// table row
@ -326,8 +326,8 @@ public final class ParagraphSprmUncompressor
{
byte[] varParam = sprm.getGrpprl();
int offset = sprm.getGrpprlOffset();
newPAP.setFPropRMark ((int) varParam[offset]);
newPAP.setIbstPropRMark ((int) LittleEndian.getShort (varParam, offset + 1));
newPAP.setFPropRMark (varParam[offset]);
newPAP.setIbstPropRMark (LittleEndian.getShort (varParam, offset + 1));
newPAP.setDttmPropRMark (new DateAndTime(varParam, offset + 3));
}
catch (Exception e)

View File

@ -33,7 +33,7 @@ public final class SectionSprmUncompressor extends SprmUncompressor
while (sprmIt.hasNext())
{
SprmOperation sprm = (SprmOperation)sprmIt.next();
SprmOperation sprm = sprmIt.next();
unCompressSEPOperation(newProperties, sprm);
}

View File

@ -39,7 +39,7 @@ public final class TableSprmUncompressor
while (sprmIt.hasNext())
{
SprmOperation sprm = (SprmOperation)sprmIt.next();
SprmOperation sprm = sprmIt.next();
//TAPXs are actually PAPXs so we have to make sure we are only trying to
//uncompress the right type of sprm.

View File

@ -380,13 +380,11 @@ public final class CharacterProperties
cp.field_23_dttmRMarkDel = (DateAndTime)field_23_dttmRMarkDel.clone();
cp.field_36_dttmPropRMark = (DateAndTime)field_36_dttmPropRMark.clone();
cp.field_40_dttmDispFldRMark = (DateAndTime)field_40_dttmDispFldRMark.clone();
cp.field_41_xstDispFldRMark = (byte[])field_41_xstDispFldRMark.clone();
cp.field_41_xstDispFldRMark = field_41_xstDispFldRMark.clone();
cp.field_42_shd = (ShadingDescriptor)field_42_shd.clone();
cp._ico24 = _ico24;
return cp;
}
}

View File

@ -546,7 +546,7 @@ public final class CharacterRun
cp._props.setDttmPropRMark((DateAndTime)_props.getDttmPropRMark().clone());
cp._props.setDttmDispFldRMark((DateAndTime)_props.getDttmDispFldRMark().
clone());
cp._props.setXstDispFldRMark((byte[])_props.getXstDispFldRMark().clone());
cp._props.setXstDispFldRMark(_props.getXstDispFldRMark().clone());
cp._props.setShd((ShadingDescriptor)_props.getShd().clone());
return cp;

View File

@ -55,7 +55,7 @@ public final class HWPFList {
*/
public HWPFList(boolean numbered, StyleSheet styleSheet)
{
_listData = new ListData((int)(Math.random() * (double)System.currentTimeMillis()), numbered);
_listData = new ListData((int)(Math.random() * System.currentTimeMillis()), numbered);
_override = new ListFormatOverride(_listData.getLsid());
_styleSheet = styleSheet;
}

View File

@ -17,7 +17,6 @@
package org.apache.poi.hwpf.usermodel;
import org.apache.poi.util.LittleEndian;
import org.apache.poi.hwpf.HWPFDocument;
@ -46,8 +45,8 @@ import java.util.NoSuchElementException;
import java.lang.ref.WeakReference;
/**
* This class is the central class of the HWPF object model. All properties
* that apply to a range of characters in a Word document extend this class.
* This class is the central class of the HWPF object model. All properties that
* apply to a range of characters in a Word document extend this class.
*
* It is possible to insert text and/or properties at the beginning or end of a
* range.
@ -135,15 +134,17 @@ public class Range { // TODO -instantiable superclass
/**
* Used to construct a Range from a document. This is generally used to
* create a Range that spans the whole document, or at least one
* whole part of the document (eg main text, header, comment)
* create a Range that spans the whole document, or at least one whole part
* of the document (eg main text, header, comment)
*
* @param start Starting character offset of the range.
* @param end Ending character offset of the range.
* @param doc The HWPFDocument the range is based on.
* @param start
* Starting character offset of the range.
* @param end
* Ending character offset of the range.
* @param doc
* The HWPFDocument the range is based on.
*/
public Range(int start, int end, HWPFDocument doc)
{
public Range(int start, int end, HWPFDocument doc) {
_start = start;
_end = end;
_doc = doc;
@ -156,16 +157,17 @@ public class Range { // TODO -instantiable superclass
sanityCheckStartEnd();
}
/**
* Used to create Ranges that are children of other Ranges.
*
* @param start Starting character offset of the range.
* @param end Ending character offset of the range.
* @param parent The parent this range belongs to.
* @param start
* Starting character offset of the range.
* @param end
* Ending character offset of the range.
* @param parent
* The parent this range belongs to.
*/
protected Range(int start, int end, Range parent)
{
protected Range(int start, int end, Range parent) {
_start = start;
_end = end;
_doc = parent._doc;
@ -182,13 +184,16 @@ public class Range { // TODO -instantiable superclass
* Constructor used to build a Range from indexes in one of its internal
* lists.
*
* @param startIdx The starting index in the list.
* @param endIdx The ending index in the list.
* @param idxType The list type.
* @param parent The parent Range this range belongs to.
* @param startIdx
* The starting index in the list.
* @param endIdx
* The ending index in the list.
* @param idxType
* The list type.
* @param parent
* The parent Range this range belongs to.
*/
protected Range(int startIdx, int endIdx, int idxType, Range parent)
{
protected Range(int startIdx, int endIdx, int idxType, Range parent) {
_doc = parent._doc;
_sections = parent._sections;
_paragraphs = parent._paragraphs;
@ -196,8 +201,7 @@ public class Range { // TODO -instantiable superclass
_text = parent._text;
_parent = new WeakReference(parent);
switch (idxType)
{
switch (idxType) {
case TYPE_PARAGRAPH:
_parStart = parent._parStart + startIdx;
_parEnd = parent._parStart + endIdx;
@ -232,16 +236,16 @@ public class Range { // TODO -instantiable superclass
}
/**
* Ensures that the start and end were were given
* are actually valid, to avoid issues later on
* if they're not
* Ensures that the start and end were were given are actually valid, to
* avoid issues later on if they're not
*/
private void sanityCheckStartEnd() {
if (_start < 0) {
throw new IllegalArgumentException("Range start must not be negative. Given " + _start);
}
if (_end < _start) {
throw new IllegalArgumentException("The end (" + _end + ") must not be before the start ("+_start+")");
throw new IllegalArgumentException("The end (" + _end
+ ") must not be before the start (" + _start + ")");
}
}
@ -254,8 +258,7 @@ public class Range { // TODO -instantiable superclass
initText();
for (int i = _textStart; i < _textEnd; i++)
{
for (int i = _textStart; i < _textEnd; i++) {
TextPiece piece = (TextPiece) _text.get(i);
if (piece.isUnicode())
return true;
@ -269,14 +272,12 @@ public class Range { // TODO -instantiable superclass
*
* @return The text for this range.
*/
public String text()
{
public String text() {
initText();
StringBuffer sb = new StringBuffer();
for (int x = _textStart; x < _textEnd; x++)
{
for (int x = _textStart; x < _textEnd; x++) {
TextPiece piece = (TextPiece) _text.get(x);
// Figure out where in this piece the text
@ -298,11 +299,9 @@ public class Range { // TODO -instantiable superclass
}
/**
* Removes any fields (eg macros, page markers etc)
* from the string.
* Normally used to make some text suitable for showing
* to humans, and the resultant text should not normally
* be saved back into the document!
* Removes any fields (eg macros, page markers etc) from the string.
* Normally used to make some text suitable for showing to humans, and the
* resultant text should not normally be saved back into the document!
*/
public static String stripFields(String text) {
// First up, fields can be nested...
@ -310,12 +309,12 @@ public class Range { // TODO -instantiable superclass
// Or it can be 0x13 [contents] 0x14 [real text] 0x15
// If there are no fields, all easy
if(text.indexOf('\u0013') == -1) return text;
if (text.indexOf('\u0013') == -1)
return text;
// Loop over until they're all gone
// That's when we're out of both 0x13s and 0x15s
while( text.indexOf('\u0013') > -1 &&
text.indexOf('\u0015') > -1) {
while (text.indexOf('\u0013') > -1 && text.indexOf('\u0015') > -1) {
int first13 = text.indexOf('\u0013');
int next13 = text.indexOf('\u0013', first13 + 1);
int first14 = text.indexOf('\u0014', first13 + 1);
@ -328,8 +327,7 @@ public class Range { // TODO -instantiable superclass
// If no more 13s and 14s, just zap
if (next13 == -1 && first14 == -1) {
text = text.substring(0, first13) +
text.substring(last15+1);
text = text.substring(0, first13) + text.substring(last15 + 1);
break;
}
@ -337,17 +335,15 @@ public class Range { // TODO -instantiable superclass
// zap from the 13 to the 14, and remove
// the 15
if (first14 != -1 && (first14 < next13 || next13 == -1)) {
text = text.substring(0, first13) +
text.substring(first14+1, last15) +
text.substring(last15+1);
text = text.substring(0, first13) + text.substring(first14 + 1, last15)
+ text.substring(last15 + 1);
continue;
}
// Another 13 comes before the next 14.
// This means there's nested stuff, so we
// can just zap the lot
text = text.substring(0, first13) +
text.substring(last15+1);
text = text.substring(0, first13) + text.substring(last15 + 1);
continue;
}
@ -360,8 +356,7 @@ public class Range { // TODO -instantiable superclass
*
* @return The number of sections in this range.
*/
public int numSections()
{
public int numSections() {
initSections();
return _sectionEnd - _sectionStart;
}
@ -373,8 +368,7 @@ public class Range { // TODO -instantiable superclass
* @return The number of paragraphs in this range.
*/
public int numParagraphs()
{
public int numParagraphs() {
initParagraphs();
return _parEnd - _parStart;
}
@ -384,8 +378,7 @@ public class Range { // TODO -instantiable superclass
* @return The number of characterRuns in this range.
*/
public int numCharacterRuns()
{
public int numCharacterRuns() {
initCharacterRuns();
return _charEnd - _charStart;
}
@ -393,7 +386,8 @@ public class Range { // TODO -instantiable superclass
/**
* Inserts text into the front of this range.
*
* @param text The text to insert
* @param text
* The text to insert
* @return The character run that text was inserted into.
*/
public CharacterRun insertBefore(String text)
@ -402,7 +396,7 @@ public class Range { // TODO -instantiable superclass
initAll();
TextPiece tp = (TextPiece) _text.get(_textStart);
StringBuffer sb = (StringBuffer)tp.getStringBuffer();
StringBuffer sb = tp.getStringBuffer();
// Since this is the first item in our list, it is safe to assume that
// _start >= tp.getStart()
@ -424,21 +418,20 @@ public class Range { // TODO -instantiable superclass
/**
* Inserts text onto the end of this range
*
* @param text The text to insert
* @param text
* The text to insert
* @return The character run the text was inserted into.
*/
public CharacterRun insertAfter(String text)
{
public CharacterRun insertAfter(String text) {
initAll();
int listIndex = _textEnd - 1;
TextPiece tp = (TextPiece) _text.get(listIndex);
StringBuffer sb = (StringBuffer)tp.getStringBuffer();
StringBuffer sb = tp.getStringBuffer();
int insertIndex = _end - tp.getStart();
if (tp.getStringBuffer().charAt(_end - 1) == '\r' && text.charAt(0) != '\u0007')
{
if (tp.getStringBuffer().charAt(_end - 1) == '\r' && text.charAt(0) != '\u0007') {
insertIndex--;
}
sb.insert(insertIndex, text);
@ -456,10 +449,12 @@ public class Range { // TODO -instantiable superclass
* Inserts text into the front of this range and it gives that text the
* CharacterProperties specified in props.
*
* @param text The text to insert.
* @param props The CharacterProperties to give the text.
* @return A new CharacterRun that has the given text and properties and is n
* ow a part of the document.
* @param text
* The text to insert.
* @param props
* The CharacterProperties to give the text.
* @return A new CharacterRun that has the given text and properties and is
* n ow a part of the document.
*/
public CharacterRun insertBefore(String text, CharacterProperties props)
// throws UnsupportedEncodingException
@ -481,10 +476,12 @@ public class Range { // TODO -instantiable superclass
* Inserts text onto the end of this range and gives that text the
* CharacterProperties specified in props.
*
* @param text The text to insert.
* @param props The CharacterProperties to give the text.
* @return A new CharacterRun that has the given text and properties and is n
* ow a part of the document.
* @param text
* The text to insert.
* @param props
* The CharacterProperties to give the text.
* @return A new CharacterRun that has the given text and properties and is
* n ow a part of the document.
*/
public CharacterRun insertAfter(String text, CharacterProperties props)
// throws UnsupportedEncodingException
@ -505,8 +502,10 @@ public class Range { // TODO -instantiable superclass
/**
* Inserts and empty paragraph into the front of this range.
*
* @param props The properties that the new paragraph will have.
* @param styleIndex The index into the stylesheet for the new paragraph.
* @param props
* The properties that the new paragraph will have.
* @param styleIndex
* The index into the stylesheet for the new paragraph.
* @return The newly inserted paragraph.
*/
public Paragraph insertBefore(ParagraphProperties props, int styleIndex)
@ -522,9 +521,12 @@ public class Range { // TODO -instantiable superclass
*
* It is necessary for the text to end with the character '\r'
*
* @param props The paragraph's properties.
* @param styleIndex The index of the paragraph's style in the style sheet.
* @param text The text to insert.
* @param props
* The paragraph's properties.
* @param styleIndex
* The index of the paragraph's style in the style sheet.
* @param text
* The text to insert.
* @return A newly inserted paragraph.
*/
protected Paragraph insertBefore(ParagraphProperties props, int styleIndex, String text)
@ -549,8 +551,10 @@ public class Range { // TODO -instantiable superclass
/**
* Inserts and empty paragraph into the end of this range.
*
* @param props The properties that the new paragraph will have.
* @param styleIndex The index into the stylesheet for the new paragraph.
* @param props
* The properties that the new paragraph will have.
* @param styleIndex
* The index into the stylesheet for the new paragraph.
* @return The newly inserted paragraph.
*/
@ -567,9 +571,12 @@ public class Range { // TODO -instantiable superclass
*
* It is necessary for the text to end with the character '\r'
*
* @param props The paragraph's properties.
* @param styleIndex The index of the paragraph's style in the style sheet.
* @param text The text to insert.
* @param props
* The paragraph's properties.
* @param styleIndex
* The index of the paragraph's style in the style sheet.
* @param text
* The text to insert.
* @return A newly inserted paragraph.
*/
protected Paragraph insertAfter(ParagraphProperties props, int styleIndex, String text)
@ -592,8 +599,7 @@ public class Range { // TODO -instantiable superclass
return getParagraph(numParagraphs() - 1);
}
public void delete()
{
public void delete() {
initAll();
@ -602,30 +608,30 @@ public class Range { // TODO -instantiable superclass
int numParagraphs = _paragraphs.size();
int numTextPieces = _text.size();
for (int x = _charStart; x < numRuns; x++)
{
for (int x = _charStart; x < numRuns; x++) {
CHPX chpx = (CHPX) _characters.get(x);
chpx.adjustForDelete(_start, _end - _start);
}
for (int x = _parStart; x < numParagraphs; x++)
{
for (int x = _parStart; x < numParagraphs; x++) {
PAPX papx = (PAPX) _paragraphs.get(x);
//System.err.println("Paragraph " + x + " was " + papx.getStart() + " -> " + papx.getEnd());
// System.err.println("Paragraph " + x + " was " + papx.getStart() +
// " -> " + papx.getEnd());
papx.adjustForDelete(_start, _end - _start);
//System.err.println("Paragraph " + x + " is now " + papx.getStart() + " -> " + papx.getEnd());
// System.err.println("Paragraph " + x + " is now " +
// papx.getStart() + " -> " + papx.getEnd());
}
for (int x = _sectionStart; x < numSections; x++)
{
for (int x = _sectionStart; x < numSections; x++) {
SEPX sepx = (SEPX) _sections.get(x);
//System.err.println("Section " + x + " was " + sepx.getStart() + " -> " + sepx.getEnd());
// System.err.println("Section " + x + " was " + sepx.getStart() +
// " -> " + sepx.getEnd());
sepx.adjustForDelete(_start, _end - _start);
//System.err.println("Section " + x + " is now " + sepx.getStart() + " -> " + sepx.getEnd());
// System.err.println("Section " + x + " is now " + sepx.getStart()
// + " -> " + sepx.getEnd());
}
for (int x = _textStart; x < numTextPieces; x++)
{
for (int x = _textStart; x < numTextPieces; x++) {
TextPiece piece = (TextPiece) _text.get(x);
piece.adjustForDelete(_start, _end - _start);
}
@ -638,23 +644,22 @@ public class Range { // TODO -instantiable superclass
* Inserts a simple table into the beginning of this range. The number of
* columns is determined by the TableProperties passed into this function.
*
* @param props The table properties for the table.
* @param rows The number of rows.
* @param props
* The table properties for the table.
* @param rows
* The number of rows.
* @return The empty Table that is now part of the document.
*/
public Table insertBefore(TableProperties props, int rows)
{
public Table insertBefore(TableProperties props, int rows) {
ParagraphProperties parProps = new ParagraphProperties();
parProps.setFInTable((byte) 1);
parProps.setTableLevel((byte) 1);
int columns = props.getItcMac();
for (int x = 0; x < rows; x++)
{
for (int x = 0; x < rows; x++) {
Paragraph cell = this.insertBefore(parProps, StyleSheet.NIL_STYLE);
cell.insertAfter(String.valueOf('\u0007'));
for(int y = 1; y < columns; y++)
{
for (int y = 1; y < columns; y++) {
cell = cell.insertAfter(parProps, StyleSheet.NIL_STYLE);
cell.insertAfter(String.valueOf('\u0007'));
}
@ -667,18 +672,20 @@ public class Range { // TODO -instantiable superclass
/**
* Inserts a list into the beginning of this range.
*
* @param props The properties of the list entry. All list entries are
* @param props
* The properties of the list entry. All list entries are
* paragraphs.
* @param listID The id of the list that contains the properties.
* @param level The indentation level of the list.
* @param styleIndex The base style's index in the stylesheet.
* @param listID
* The id of the list that contains the properties.
* @param level
* The indentation level of the list.
* @param styleIndex
* The base style's index in the stylesheet.
* @return The empty ListEntry that is now part of the document.
*/
public ListEntry insertBefore(ParagraphProperties props, int listID, int level, int styleIndex)
{
public ListEntry insertBefore(ParagraphProperties props, int listID, int level, int styleIndex) {
ListTables lt = _doc.getListTables();
if (lt.getLevel(listID, level) == null)
{
if (lt.getLevel(listID, level) == null) {
throw new NoSuchElementException("The specified list and level do not exist");
}
@ -692,18 +699,20 @@ public class Range { // TODO -instantiable superclass
/**
* Inserts a list into the beginning of this range.
*
* @param props The properties of the list entry. All list entries are
* @param props
* The properties of the list entry. All list entries are
* paragraphs.
* @param listID The id of the list that contains the properties.
* @param level The indentation level of the list.
* @param styleIndex The base style's index in the stylesheet.
* @param listID
* The id of the list that contains the properties.
* @param level
* The indentation level of the list.
* @param styleIndex
* The base style's index in the stylesheet.
* @return The empty ListEntry that is now part of the document.
*/
public ListEntry insertAfter(ParagraphProperties props, int listID, int level, int styleIndex)
{
public ListEntry insertAfter(ParagraphProperties props, int listID, int level, int styleIndex) {
ListTables lt = _doc.getListTables();
if (lt.getLevel(listID, level) == null)
{
if (lt.getLevel(listID, level) == null) {
throw new NoSuchElementException("The specified list and level do not exist");
}
int ilfo = lt.getOverrideIndexFromListID(listID);
@ -716,20 +725,21 @@ public class Range { // TODO -instantiable superclass
/**
* Replace (one instance of) a piece of text with another...
*
* @param pPlaceHolder The text to be replaced (e.g., "${organization}")
* @param pValue The replacement text (e.g., "Apache Software Foundation")
* @param pOffset The offset or index where the text to be replaced begins
* @param pPlaceHolder
* The text to be replaced (e.g., "${organization}")
* @param pValue
* The replacement text (e.g., "Apache Software Foundation")
* @param pOffset
* The offset or index where the text to be replaced begins
* (relative to/within this <code>Range</code>)
*/
public void replaceText(String pPlaceHolder, String pValue, int pOffset)
{
public void replaceText(String pPlaceHolder, String pValue, int pOffset) {
int absPlaceHolderIndex = getStartOffset() + pOffset;
Range subRange = new Range(
absPlaceHolderIndex,
(absPlaceHolderIndex + pPlaceHolder.length()), getDocument()
);
Range subRange = new Range(absPlaceHolderIndex, (absPlaceHolderIndex + pPlaceHolder
.length()), getDocument());
// this Range isn't a proper parent of the subRange() so we'll have to keep
// this Range isn't a proper parent of the subRange() so we'll have to
// keep
// track of an updated endOffset on our own
int previousEndOffset = subRange.getEndOffset();
@ -739,11 +749,8 @@ public class Range { // TODO -instantiable superclass
_end += (subRange.getEndOffset() - previousEndOffset);
// re-create the sub-range so we can delete it
subRange = new Range(
(absPlaceHolderIndex + pValue.length()),
(absPlaceHolderIndex + pPlaceHolder.length() + pValue.length()),
getDocument()
);
subRange = new Range((absPlaceHolderIndex + pValue.length()), (absPlaceHolderIndex
+ pPlaceHolder.length() + pValue.length()), getDocument());
// deletes are automagically propagated
subRange.delete();
@ -752,11 +759,12 @@ public class Range { // TODO -instantiable superclass
/**
* Replace (all instances of) a piece of text with another...
*
* @param pPlaceHolder The text to be replaced (e.g., "${organization}")
* @param pValue The replacement text (e.g., "Apache Software Foundation")
* @param pPlaceHolder
* The text to be replaced (e.g., "${organization}")
* @param pValue
* The replacement text (e.g., "Apache Software Foundation")
*/
public void replaceText(String pPlaceHolder, String pValue)
{
public void replaceText(String pPlaceHolder, String pValue) {
boolean keepLooking = true;
while (keepLooking) {
@ -772,16 +780,16 @@ public class Range { // TODO -instantiable superclass
/**
* Gets the character run at index. The index is relative to this range.
*
* @param index The index of the character run to get.
* @param index
* The index of the character run to get.
* @return The character run at the specified index in this range.
*/
public CharacterRun getCharacterRun(int index)
{
public CharacterRun getCharacterRun(int index) {
initCharacterRuns();
CHPX chpx = (CHPX) _characters.get(index + _charStart);
int[] point = findRange(_paragraphs, _parStart, Math.max(chpx.getStart(), _start),
chpx.getEnd());
int[] point = findRange(_paragraphs, _parStart, Math.max(chpx.getStart(), _start), chpx
.getEnd());
PAPX papx = (PAPX) _paragraphs.get(point[0]);
short istd = papx.getIstd();
@ -793,11 +801,11 @@ public class Range { // TODO -instantiable superclass
/**
* Gets the section at index. The index is relative to this range.
*
* @param index The index of the section to get.
* @param index
* The index of the section to get.
* @return The section at the specified index in this range.
*/
public Section getSection(int index)
{
public Section getSection(int index) {
initSections();
SEPX sepx = (SEPX) _sections.get(index + _sectionStart);
Section sep = new Section(sepx, this);
@ -807,23 +815,20 @@ public class Range { // TODO -instantiable superclass
/**
* Gets the paragraph at index. The index is relative to this range.
*
* @param index The index of the paragraph to get.
* @param index
* The index of the paragraph to get.
* @return The paragraph at the specified index in this range.
*/
public Paragraph getParagraph(int index)
{
public Paragraph getParagraph(int index) {
initParagraphs();
PAPX papx = (PAPX) _paragraphs.get(index + _parStart);
ParagraphProperties props = papx.getParagraphProperties(_doc.getStyleSheet());
Paragraph pap = null;
if (props.getIlfo() > 0)
{
if (props.getIlfo() > 0) {
pap = new ListEntry(papx, this, _doc.getListTables());
}
else
{
} else {
pap = new Paragraph(papx, this);
}
@ -836,28 +841,25 @@ public class Range { // TODO -instantiable superclass
*
* @return A TYPE constant.
*/
public int type()
{
public int type() {
return TYPE_UNDEFINED;
}
/**
* Gets the table that starts with paragraph. In a Word file, a table consists
* of a group of paragraphs with certain flags set.
* Gets the table that starts with paragraph. In a Word file, a table
* consists of a group of paragraphs with certain flags set.
*
* @param paragraph The paragraph that is the first paragraph in the table.
* @param paragraph
* The paragraph that is the first paragraph in the table.
* @return The table that starts with paragraph
*/
public Table getTable(Paragraph paragraph)
{
if (!paragraph.isInTable())
{
public Table getTable(Paragraph paragraph) {
if (!paragraph.isInTable()) {
throw new IllegalArgumentException("This paragraph doesn't belong to a table");
}
Range r = (Range)paragraph;
if (r._parent.get() != this)
{
Range r = paragraph;
if (r._parent.get() != this) {
throw new IllegalArgumentException("This paragraph is not a child of this range");
}
@ -865,28 +867,25 @@ public class Range { // TODO -instantiable superclass
int tableEnd = r._parEnd;
if (r._parStart != 0 && getParagraph(r._parStart - 1).isInTable()
&& getParagraph(r._parStart - 1)._sectionEnd >= r._sectionStart)
{
&& getParagraph(r._parStart - 1)._sectionEnd >= r._sectionStart) {
throw new IllegalArgumentException("This paragraph is not the first one in the table");
}
int limit = _paragraphs.size();
for (; tableEnd < limit; tableEnd++)
{
if (!getParagraph(tableEnd).isInTable())
{
for (; tableEnd < limit; tableEnd++) {
if (!getParagraph(tableEnd).isInTable()) {
break;
}
}
initAll();
if (tableEnd > _parEnd)
{
throw new ArrayIndexOutOfBoundsException("The table's bounds fall outside of this Range");
if (tableEnd > _parEnd) {
throw new ArrayIndexOutOfBoundsException(
"The table's bounds fall outside of this Range");
}
if (tableEnd < 0)
{
throw new ArrayIndexOutOfBoundsException("The table's end is negative, which isn't allowed!");
if (tableEnd < 0) {
throw new ArrayIndexOutOfBoundsException(
"The table's end is negative, which isn't allowed!");
}
return new Table(r._parStart, tableEnd, r._doc.getRange(), paragraph.getTableLevel());
}
@ -894,8 +893,7 @@ public class Range { // TODO -instantiable superclass
/**
* loads all of the list indexes.
*/
protected void initAll()
{
protected void initAll() {
initText();
initCharacterRuns();
initParagraphs();
@ -905,10 +903,8 @@ public class Range { // TODO -instantiable superclass
/**
* inits the paragraph list indexes.
*/
private void initParagraphs()
{
if (!_parRangeFound)
{
private void initParagraphs() {
if (!_parRangeFound) {
int[] point = findRange(_paragraphs, _parStart, _start, _end);
_parStart = point[0];
_parEnd = point[1];
@ -919,10 +915,8 @@ public class Range { // TODO -instantiable superclass
/**
* inits the character run list indexes.
*/
private void initCharacterRuns()
{
if (!_charRangeFound)
{
private void initCharacterRuns() {
if (!_charRangeFound) {
int[] point = findRange(_characters, _charStart, _start, _end);
_charStart = point[0];
_charEnd = point[1];
@ -933,10 +927,8 @@ public class Range { // TODO -instantiable superclass
/**
* inits the text piece list indexes.
*/
private void initText()
{
if (!_textRangeFound)
{
private void initText() {
if (!_textRangeFound) {
int[] point = findRange(_text, _textStart, _start, _end);
_textStart = point[0];
_textEnd = point[1];
@ -947,10 +939,8 @@ public class Range { // TODO -instantiable superclass
/**
* inits the section list indexes.
*/
private void initSections()
{
if (!_sectionRangeFound)
{
private void initSections() {
if (!_sectionRangeFound) {
int[] point = findRange(_sections, _sectionStart, _start, _end);
_sectionStart = point[0];
_sectionEnd = point[1];
@ -961,19 +951,21 @@ public class Range { // TODO -instantiable superclass
/**
* Used to find the list indexes of a particular property.
*
* @param rpl A list of property nodes.
* @param min A hint on where to start looking.
* @param start The starting character offset.
* @param end The ending character offset.
* @return An int array of length 2. The first int is the start index and the
* second int is the end index.
* @param rpl
* A list of property nodes.
* @param min
* A hint on where to start looking.
* @param start
* The starting character offset.
* @param end
* The ending character offset.
* @return An int array of length 2. The first int is the start index and
* the second int is the end index.
*/
private int[] findRange(List rpl, int min, int start, int end)
{
private int[] findRange(List rpl, int min, int start, int end) {
int x = min;
PropertyNode node = (PropertyNode) rpl.get(x);
while(node.getEnd() <= start && x < rpl.size()-1)
{
while (node.getEnd() <= start && x < rpl.size() - 1) {
x++;
node = (PropertyNode) rpl.get(x);
}
@ -984,8 +976,7 @@ public class Range { // TODO -instantiable superclass
int y = x;
node = (PropertyNode) rpl.get(y);
while(node.getEnd() < end && y < rpl.size()-1)
{
while (node.getEnd() < end && y < rpl.size() - 1) {
y++;
node = (PropertyNode) rpl.get(y);
}
@ -995,8 +986,7 @@ public class Range { // TODO -instantiable superclass
/**
* resets the list indexes.
*/
private void reset()
{
private void reset() {
_textRangeFound = false;
_charRangeFound = false;
_parRangeFound = false;
@ -1004,17 +994,21 @@ public class Range { // TODO -instantiable superclass
}
/**
* Adjust the value of the various FIB character count fields,
* eg <code>FIB.CCPText</code> after an insert or a delete...
* Adjust the value of the various FIB character count fields, eg
* <code>FIB.CCPText</code> after an insert or a delete...
*
* Works on all CCP fields from this range onwards
*
* @param adjustment The (signed) value that should be added to the FIB CCP fields
* @param adjustment
* The (signed) value that should be added to the FIB CCP fields
*/
protected void adjustFIB(int adjustment) {
// update the FIB.CCPText field (this should happen once per adjustment, so we don't want it in
// adjustForInsert() or it would get updated multiple times if the range has a parent)
// without this, OpenOffice.org (v. 2.2.x) does not see all the text in the document
// update the FIB.CCPText field (this should happen once per adjustment,
// so we don't want it in
// adjustForInsert() or it would get updated multiple times if the range
// has a parent)
// without this, OpenOffice.org (v. 2.2.x) does not see all the text in
// the document
CPSplitCalculator cpS = _doc.getCPSplitCalculator();
FileInformationBlock fib = _doc.getFileInformationBlock();
@ -1046,21 +1040,21 @@ public class Range { // TODO -instantiable superclass
/**
* adjust this range after an insert happens.
* @param length the length to adjust for (expected to be a count of code-points, not necessarily chars)
*
* @param length
* the length to adjust for (expected to be a count of
* code-points, not necessarily chars)
*/
private void adjustForInsert(int length)
{
private void adjustForInsert(int length) {
_end += length;
reset();
Range parent = (Range) _parent.get();
if (parent != null)
{
if (parent != null) {
parent.adjustForInsert(length);
}
}
public int getStartOffset() {
return _start;

View File

@ -65,7 +65,7 @@ public final class TableProperties
tap.field_14_brcRight = (BorderCode)field_14_brcRight.clone();
tap.field_15_brcVertical = (BorderCode)field_15_brcVertical.clone();
tap.field_16_brcHorizontal = (BorderCode)field_16_brcHorizontal.clone();
tap.field_8_rgdxaCenter = (short[])field_8_rgdxaCenter.clone();
tap.field_8_rgdxaCenter = field_8_rgdxaCenter.clone();
tap.field_9_rgtc = new TableCellDescriptor[field_9_rgtc.length];
for (int x = 0; x < field_9_rgtc.length; x++)
{

View File

@ -50,11 +50,10 @@ public class TestModelFactory extends TestCase {
{
ModelFactory mf = new ModelFactory();
assertTrue("listeners member cannot be null", mf.listeners != null);
assertTrue("listeners member must be a List", mf.listeners instanceof List);
models = new ArrayList(3);
factory = new ModelFactory();
book = new HSSFWorkbook();
ByteArrayOutputStream stream = (ByteArrayOutputStream)setupRunFile(book);
ByteArrayOutputStream stream = setupRunFile(book);
POIFSFileSystem fs = new POIFSFileSystem(
new ByteArrayInputStream(stream.toByteArray())
);

View File

@ -115,7 +115,6 @@ public final class TestRecordFactory extends TestCase {
* constructs the expected array of records.<P>
* SUCCESS: Record factory creates the expected records.<P>
* FAILURE: The wrong records are created or contain the wrong values <P>
*
*/
public void testContinuedUnknownRecord() {
byte[] data = {
@ -125,8 +124,7 @@ public final class TestRecordFactory extends TestCase {
};
ByteArrayInputStream bois = new ByteArrayInputStream(data);
Record[] records = (Record[])
RecordFactory.createRecords(bois).toArray(new Record[0]);
Record[] records = RecordFactory.createRecords(bois).toArray(new Record[0]);
assertEquals("Created record count", 3, records.length);
assertEquals("1st record's type",
UnknownRecord.class.getName(),