📄 rowrecord.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: RowRecord.java
package jxl.write.biff;
import common.Logger;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import jxl.CellType;
import jxl.biff.*;
import jxl.write.Number;
// Referenced classes of package jxl.write.biff:
// CellValue, StringRecord, MulRKRecord, File
class RowRecord extends WritableRecordData
{
private static final Logger logger;
private byte data[];
private CellValue cells[];
private int rowHeight;
private boolean collapsed;
private int rowNumber;
private int numColumns;
private int xfIndex;
private XFRecord style;
private boolean defaultFormat;
private boolean matchesDefFontHeight;
private static final int growSize = 10;
private static final int maxRKValue = 0x1fffffff;
private static final int minRKValue = 0xe0000000;
private static int defaultHeightIndicator = 255;
private static int maxColumns = 256;
static Class class$jxl$write$biff$RowRecord; /* synthetic field */
public RowRecord(int rn)
{
super(Type.ROW);
rowNumber = rn;
cells = new CellValue[0];
numColumns = 0;
rowHeight = defaultHeightIndicator;
collapsed = false;
matchesDefFontHeight = true;
}
public void setRowHeight(int h)
{
if(h == 0)
{
setCollapsed(true);
matchesDefFontHeight = false;
} else
{
rowHeight = h;
matchesDefFontHeight = false;
}
}
void setRowDetails(int height, boolean mdfh, boolean col, XFRecord xfr)
{
rowHeight = height;
collapsed = col;
matchesDefFontHeight = mdfh;
if(xfr != null)
{
defaultFormat = true;
style = xfr;
xfIndex = style.getXFIndex();
}
}
public void setCollapsed(boolean c)
{
collapsed = c;
}
public int getRowNumber()
{
return rowNumber;
}
public void addCell(CellValue cv)
{
int col = cv.getColumn();
if(col >= maxColumns)
{
logger.warn("Could not add cell at " + CellReferenceHelper.getCellReference(cv.getRow(), cv.getColumn()) + " because it exceeds the maximum column limit");
return;
}
if(col >= cells.length)
{
CellValue oldCells[] = cells;
cells = new CellValue[Math.max(oldCells.length + 10, col + 1)];
System.arraycopy(oldCells, 0, cells, 0, oldCells.length);
oldCells = null;
}
cells[col] = cv;
numColumns = Math.max(col + 1, numColumns);
}
public void removeCell(int col)
{
if(col >= numColumns)
{
return;
} else
{
cells[col] = null;
return;
}
}
public void write(File outputFile)
throws IOException
{
outputFile.write(this);
}
public void writeCells(File outputFile)
throws IOException
{
ArrayList integerValues = new ArrayList();
boolean integerValue = false;
for(int i = 0; i < numColumns; i++)
{
integerValue = false;
if(cells[i] != null)
{
if(cells[i].getType() == CellType.NUMBER)
{
Number nc = (Number)cells[i];
if(nc.getValue() == (double)(int)nc.getValue() && nc.getValue() < 536870911D && nc.getValue() > -536870912D && nc.getCellFeatures() == null)
integerValue = true;
}
if(integerValue)
{
integerValues.add(cells[i]);
continue;
}
writeIntegerValues(integerValues, outputFile);
outputFile.write(cells[i]);
if(cells[i].getType() == CellType.STRING_FORMULA)
{
StringRecord sr = new StringRecord(cells[i].getContents());
outputFile.write(sr);
}
} else
{
writeIntegerValues(integerValues, outputFile);
}
}
writeIntegerValues(integerValues, outputFile);
}
private void writeIntegerValues(ArrayList integerValues, File outputFile)
throws IOException
{
if(integerValues.size() == 0)
return;
if(integerValues.size() >= 3)
{
MulRKRecord mulrk = new MulRKRecord(integerValues);
outputFile.write(mulrk);
} else
{
for(Iterator i = integerValues.iterator(); i.hasNext(); outputFile.write((CellValue)i.next()));
}
integerValues.clear();
}
public byte[] getData()
{
byte data[] = new byte[16];
IntegerHelper.getTwoBytes(rowNumber, data, 0);
IntegerHelper.getTwoBytes(numColumns, data, 4);
IntegerHelper.getTwoBytes(rowHeight, data, 6);
int options = 256;
if(collapsed)
options |= 0x20;
if(!matchesDefFontHeight)
options |= 0x40;
if(defaultFormat)
{
options |= 0x80;
options |= xfIndex << 16;
}
IntegerHelper.getFourBytes(options, data, 12);
return data;
}
public int getMaxColumn()
{
return numColumns;
}
public CellValue getCell(int col)
{
return col < 0 || col >= numColumns ? null : cells[col];
}
void incrementRow()
{
rowNumber++;
for(int i = 0; i < cells.length; i++)
if(cells[i] != null)
cells[i].incrementRow();
}
void decrementRow()
{
rowNumber--;
for(int i = 0; i < cells.length; i++)
if(cells[i] != null)
cells[i].decrementRow();
}
void insertColumn(int col)
{
if(col >= numColumns)
return;
if(numColumns >= maxColumns)
{
logger.warn("Could not insert column because maximum column limit has been reached");
return;
}
CellValue oldCells[] = cells;
if(numColumns >= cells.length - 1)
cells = new CellValue[oldCells.length + 10];
else
cells = new CellValue[oldCells.length];
System.arraycopy(oldCells, 0, cells, 0, col);
System.arraycopy(oldCells, col, cells, col + 1, numColumns - col);
for(int i = col + 1; i <= numColumns; i++)
if(cells[i] != null)
cells[i].incrementColumn();
numColumns++;
}
void removeColumn(int col)
{
if(col >= numColumns)
return;
CellValue oldCells[] = cells;
cells = new CellValue[oldCells.length];
System.arraycopy(oldCells, 0, cells, 0, col);
System.arraycopy(oldCells, col + 1, cells, col, numColumns - (col + 1));
for(int i = col; i < numColumns; i++)
if(cells[i] != null)
cells[i].decrementColumn();
numColumns--;
}
public boolean isDefaultHeight()
{
return rowHeight == defaultHeightIndicator;
}
public int getRowHeight()
{
return rowHeight;
}
public boolean isCollapsed()
{
return collapsed;
}
void rationalize(IndexMapping xfmapping)
{
if(defaultFormat)
xfIndex = xfmapping.getNewIndex(xfIndex);
}
XFRecord getStyle()
{
return style;
}
boolean hasDefaultFormat()
{
return defaultFormat;
}
boolean matchesDefaultFontHeight()
{
return matchesDefFontHeight;
}
static Class class$(String x0)
{
return Class.forName(x0);
ClassNotFoundException x1;
x1;
throw new NoClassDefFoundError(x1.getMessage());
}
static
{
logger = Logger.getLogger(class$jxl$write$biff$RowRecord != null ? class$jxl$write$biff$RowRecord : (class$jxl$write$biff$RowRecord = class$("jxl.write.biff.RowRecord")));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -