📄 hyperlinkrecord.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: HyperlinkRecord.java
package jxl.write.biff;
import common.Assert;
import common.Logger;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import jxl.CellType;
import jxl.Hyperlink;
import jxl.Range;
import jxl.biff.CellReferenceHelper;
import jxl.biff.IntegerHelper;
import jxl.biff.SheetRangeImpl;
import jxl.biff.StringHelper;
import jxl.biff.Type;
import jxl.biff.WritableRecordData;
import jxl.read.biff.Record;
import jxl.write.Label;
import jxl.write.WritableCell;
import jxl.write.WritableSheet;
public class HyperlinkRecord extends WritableRecordData
{
private static class LinkType
{
private LinkType()
{
}
LinkType(_cls1 x0)
{
this();
}
}
private static Logger logger;
private int firstRow;
private int lastRow;
private int firstColumn;
private int lastColumn;
private URL url;
private File file;
private String location;
private String contents;
private LinkType linkType;
private byte data[];
private Range range;
private WritableSheet sheet;
private boolean modified;
private static final LinkType urlLink = new LinkType(null);
private static final LinkType fileLink = new LinkType(null);
private static final LinkType uncLink = new LinkType(null);
private static final LinkType workbookLink = new LinkType(null);
private static final LinkType unknown = new LinkType(null);
static Class class$jxl$write$biff$HyperlinkRecord; /* synthetic field */
protected HyperlinkRecord(Hyperlink h, WritableSheet s)
{
super(Type.HLINK);
Assert.verify(h instanceof jxl.read.biff.HyperlinkRecord);
jxl.read.biff.HyperlinkRecord hl = (jxl.read.biff.HyperlinkRecord)h;
data = hl.getRecord().getData();
sheet = s;
firstRow = hl.getRow();
firstColumn = hl.getColumn();
lastRow = hl.getLastRow();
lastColumn = hl.getLastColumn();
range = new SheetRangeImpl(s, firstColumn, firstRow, lastColumn, lastRow);
linkType = unknown;
if(hl.isFile())
{
linkType = fileLink;
file = hl.getFile();
} else
if(hl.isURL())
{
linkType = urlLink;
url = hl.getURL();
} else
if(hl.isLocation())
{
linkType = workbookLink;
location = hl.getLocation();
}
modified = false;
}
protected HyperlinkRecord(int col, int row, int lastcol, int lastrow, URL url, String desc)
{
super(Type.HLINK);
firstColumn = col;
firstRow = row;
lastColumn = Math.max(firstColumn, lastcol);
lastRow = Math.max(firstRow, lastrow);
this.url = url;
contents = desc;
linkType = urlLink;
modified = true;
}
protected HyperlinkRecord(int col, int row, int lastcol, int lastrow, File file, String desc)
{
super(Type.HLINK);
firstColumn = col;
firstRow = row;
lastColumn = Math.max(firstColumn, lastcol);
lastRow = Math.max(firstRow, lastrow);
contents = desc;
this.file = file;
if(file.getPath().startsWith("\\\\"))
linkType = uncLink;
else
linkType = fileLink;
modified = true;
}
protected HyperlinkRecord(int col, int row, int lastcol, int lastrow, String desc, WritableSheet s, int destcol,
int destrow, int lastdestcol, int lastdestrow)
{
super(Type.HLINK);
firstColumn = col;
firstRow = row;
lastColumn = Math.max(firstColumn, lastcol);
lastRow = Math.max(firstRow, lastrow);
setLocation(s, destcol, destrow, lastdestcol, lastdestrow);
contents = desc;
linkType = workbookLink;
modified = true;
}
public boolean isFile()
{
return linkType == fileLink;
}
public boolean isUNC()
{
return linkType == uncLink;
}
public boolean isURL()
{
return linkType == urlLink;
}
public boolean isLocation()
{
return linkType == workbookLink;
}
public int getRow()
{
return firstRow;
}
public int getColumn()
{
return firstColumn;
}
public int getLastRow()
{
return lastRow;
}
public int getLastColumn()
{
return lastColumn;
}
public URL getURL()
{
return url;
}
public File getFile()
{
return file;
}
public byte[] getData()
{
if(!modified)
return data;
byte commonData[] = new byte[32];
IntegerHelper.getTwoBytes(firstRow, commonData, 0);
IntegerHelper.getTwoBytes(lastRow, commonData, 2);
IntegerHelper.getTwoBytes(firstColumn, commonData, 4);
IntegerHelper.getTwoBytes(lastColumn, commonData, 6);
commonData[8] = -48;
commonData[9] = -55;
commonData[10] = -22;
commonData[11] = 121;
commonData[12] = -7;
commonData[13] = -70;
commonData[14] = -50;
commonData[15] = 17;
commonData[16] = -116;
commonData[17] = -126;
commonData[18] = 0;
commonData[19] = -86;
commonData[20] = 0;
commonData[21] = 75;
commonData[22] = -87;
commonData[23] = 11;
commonData[24] = 2;
commonData[25] = 0;
commonData[26] = 0;
commonData[27] = 0;
int optionFlags = 0;
if(isURL())
{
optionFlags = 3;
if(contents != null)
optionFlags |= 0x14;
} else
if(isFile())
{
optionFlags = 3;
if(contents == null)
optionFlags |= 0x14;
} else
if(isLocation())
optionFlags = 8;
else
if(isUNC())
optionFlags = 259;
IntegerHelper.getFourBytes(optionFlags, commonData, 28);
if(isURL())
data = getURLData(commonData);
else
if(isFile())
data = getFileData(commonData);
else
if(isLocation())
data = getLocationData(commonData);
else
if(isUNC())
data = getUNCData(commonData);
return data;
}
public String toString()
{
if(isFile())
return file.toString();
if(isURL())
return url.toString();
if(isUNC())
return file.toString();
else
return "";
}
public Range getRange()
{
return range;
}
public void setURL(URL url)
{
linkType = urlLink;
file = null;
location = null;
contents = null;
this.url = url;
modified = true;
if(sheet == null)
{
return;
} else
{
WritableCell wc = sheet.getWritableCell(firstColumn, firstRow);
Assert.verify(wc.getType() == CellType.LABEL);
Label l = (Label)wc;
l.setString(url.toString());
return;
}
}
public void setFile(File file)
{
linkType = fileLink;
url = null;
location = null;
contents = null;
this.file = file;
modified = true;
if(sheet == null)
{
return;
} else
{
WritableCell wc = sheet.getWritableCell(firstColumn, firstRow);
Assert.verify(wc.getType() == CellType.LABEL);
Label l = (Label)wc;
l.setString(file.toString());
return;
}
}
protected void setLocation(String desc, WritableSheet sheet, int destcol, int destrow, int lastdestcol, int lastdestrow)
{
linkType = workbookLink;
url = null;
file = null;
modified = true;
contents = desc;
setLocation(sheet, destcol, destrow, lastdestcol, lastdestrow);
if(sheet == null)
{
return;
} else
{
WritableCell wc = sheet.getWritableCell(firstColumn, firstRow);
Assert.verify(wc.getType() == CellType.LABEL);
Label l = (Label)wc;
l.setString(desc);
return;
}
}
private void setLocation(WritableSheet sheet, int destcol, int destrow, int lastdestcol, int lastdestrow)
{
StringBuffer sb = new StringBuffer();
sb.append('\'');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -