📄 drawing.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: Drawing.java
package jxl.biff.drawing;
import common.Assert;
import common.LengthConverter;
import common.LengthUnit;
import common.Logger;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import jxl.CellView;
import jxl.Image;
import jxl.Sheet;
import jxl.format.CellFormat;
import jxl.format.Font;
// Referenced classes of package jxl.biff.drawing:
// Sp, Opt, ClientAnchor, SpContainer,
// ClientData, ObjRecord, PNGReader, DrawingGroupObject,
// Origin, MsoDrawingRecord, DrawingData, DrawingGroup,
// ShapeType, EscherContainer, EscherRecord, EscherRecordType
public class Drawing
implements DrawingGroupObject, Image
{
private static Logger logger;
private EscherContainer readSpContainer;
private MsoDrawingRecord msoDrawingRecord;
private ObjRecord objRecord;
private boolean initialized;
private File imageFile;
private byte imageData[];
private int objectId;
private int blipId;
private double x;
private double y;
private double width;
private double height;
private int referenceCount;
private EscherContainer escherData;
private Origin origin;
private DrawingGroup drawingGroup;
private DrawingData drawingData;
private ShapeType type;
private int shapeId;
private int drawingNumber;
private Sheet sheet;
private PNGReader pngReader;
private static final double DEFAULT_FONT_SIZE = 10D;
static Class class$jxl$biff$drawing$Drawing; /* synthetic field */
public Drawing(MsoDrawingRecord mso, ObjRecord obj, DrawingData dd, DrawingGroup dg, Sheet s)
{
initialized = false;
drawingGroup = dg;
msoDrawingRecord = mso;
drawingData = dd;
objRecord = obj;
sheet = s;
initialized = false;
origin = Origin.READ;
drawingData.addData(msoDrawingRecord.getData());
drawingNumber = drawingData.getNumDrawings() - 1;
drawingGroup.addDrawing(this);
Assert.verify(mso != null && obj != null);
initialize();
}
protected Drawing(DrawingGroupObject dgo, DrawingGroup dg)
{
initialized = false;
Drawing d = (Drawing)dgo;
Assert.verify(d.origin == Origin.READ);
msoDrawingRecord = d.msoDrawingRecord;
objRecord = d.objRecord;
initialized = false;
origin = Origin.READ;
drawingData = d.drawingData;
drawingGroup = dg;
drawingNumber = d.drawingNumber;
drawingGroup.addDrawing(this);
}
public Drawing(double x, double y, double w, double h, File image)
{
initialized = false;
imageFile = image;
initialized = true;
origin = Origin.WRITE;
this.x = x;
this.y = y;
width = w;
height = h;
referenceCount = 1;
type = ShapeType.PICTURE_FRAME;
}
public Drawing(double x, double y, double w, double h, byte image[])
{
initialized = false;
imageData = image;
initialized = true;
origin = Origin.WRITE;
this.x = x;
this.y = y;
width = w;
height = h;
referenceCount = 1;
type = ShapeType.PICTURE_FRAME;
}
private void initialize()
{
readSpContainer = drawingData.getSpContainer(drawingNumber);
Assert.verify(readSpContainer != null);
EscherRecord children[] = readSpContainer.getChildren();
Sp sp = (Sp)readSpContainer.getChildren()[0];
shapeId = sp.getShapeId();
objectId = objRecord.getObjectId();
type = ShapeType.getType(sp.getShapeType());
if(type == ShapeType.UNKNOWN)
logger.warn("Unknown shape type");
Opt opt = (Opt)readSpContainer.getChildren()[1];
if(opt.getProperty(260) != null)
blipId = opt.getProperty(260).value;
if(opt.getProperty(261) != null)
imageFile = new File(opt.getProperty(261).stringValue);
else
if(type == ShapeType.PICTURE_FRAME)
{
logger.warn("no filename property for drawing");
imageFile = new File(Integer.toString(blipId));
}
ClientAnchor clientAnchor = null;
for(int i = 0; i < children.length && clientAnchor == null; i++)
if(children[i].getType() == EscherRecordType.CLIENT_ANCHOR)
clientAnchor = (ClientAnchor)children[i];
if(clientAnchor == null)
{
logger.warn("client anchor not found");
} else
{
x = clientAnchor.getX1();
y = clientAnchor.getY1();
width = clientAnchor.getX2() - x;
height = clientAnchor.getY2() - y;
}
if(blipId == 0)
logger.warn("linked drawings are not supported");
initialized = true;
}
public File getImageFile()
{
return imageFile;
}
public String getImageFilePath()
{
if(imageFile == null)
return blipId == 0 ? "__new__image__" : Integer.toString(blipId);
else
return imageFile.getPath();
}
public final void setObjectId(int objid, int bip, int sid)
{
objectId = objid;
blipId = bip;
shapeId = sid;
if(origin == Origin.READ)
origin = Origin.READ_WRITE;
}
public final int getObjectId()
{
if(!initialized)
initialize();
return objectId;
}
public int getShapeId()
{
if(!initialized)
initialize();
return shapeId;
}
public final int getBlipId()
{
if(!initialized)
initialize();
return blipId;
}
public MsoDrawingRecord getMsoDrawingRecord()
{
return msoDrawingRecord;
}
public EscherContainer getSpContainer()
{
if(!initialized)
initialize();
if(origin == Origin.READ)
return getReadSpContainer();
SpContainer spContainer = new SpContainer();
Sp sp = new Sp(type, shapeId, 2560);
spContainer.add(sp);
Opt opt = new Opt();
opt.addProperty(260, true, false, blipId);
if(type == ShapeType.PICTURE_FRAME)
{
String filePath = imageFile == null ? "" : imageFile.getPath();
opt.addProperty(261, true, true, filePath.length() * 2, filePath);
opt.addProperty(447, false, false, 0x10000);
opt.addProperty(959, false, false, 0x80000);
spContainer.add(opt);
}
ClientAnchor clientAnchor = new ClientAnchor(x, y, x + width, y + height);
spContainer.add(clientAnchor);
ClientData clientData = new ClientData();
spContainer.add(clientData);
return spContainer;
}
public void setDrawingGroup(DrawingGroup dg)
{
drawingGroup = dg;
}
public DrawingGroup getDrawingGroup()
{
return drawingGroup;
}
public Origin getOrigin()
{
return origin;
}
public int getReferenceCount()
{
return referenceCount;
}
public void setReferenceCount(int r)
{
referenceCount = r;
}
public double getX()
{
if(!initialized)
initialize();
return x;
}
public void setX(double x)
{
if(origin == Origin.READ)
{
if(!initialized)
initialize();
origin = Origin.READ_WRITE;
}
this.x = x;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -