资源描述
package jxl.biff.drawing;
import common.Assert;
import common.Logger;
import java.io.IOException;
import jxl.WorkbookSettings;
import jxl.write.biff.File;
Store management class ComboBox
implements DrawingGroupObject
{
private static Logger logger = Logger.getLogger(ComboBox.class);
private EscherContainer readSpContainer;
private EscherContainer spContainer;
private MsoDrawingRecord msoDrawingRecord;
private ObjRecord objRecord;
private boolean initialized = false;
private int objectId;
private int blipId;
private int shapeId;
private int column;
private int row;
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 drawingNumber;
private WorkbookSettings workbookSettings;
Store management ComboBox(MsoDrawingRecord mso, ObjRecord obj, DrawingData dd, DrawingGroup dg, WorkbookSettings ws)
{
this.drawingGroup = dg;
this.msoDrawingRecord = mso;
this.drawingData = dd;
this.objRecord = obj;
this.initialized = false;
this.workbookSettings = ws;
this.origin = Origin.READ;
this.drawingData.addData(this.msoDrawingRecord.getData());
this.drawingNumber = (this.drawingData.getNumDrawings() - 1);
this.drawingGroup.addDrawing(this);
Assert.verify((mso != null) && (obj != null));
initialize();
}
Store management ComboBox(DrawingGroupObject dgo, DrawingGroup dg, WorkbookSettings ws)
{
ComboBox d = (ComboBox)dgo;
Assert.verify(d.origin == Origin.READ);
this.msoDrawingRecord = d.msoDrawingRecord;
this.objRecord = d.objRecord;
this.initialized = false;
this.origin = Origin.READ;
this.drawingData = d.drawingData;
this.drawingGroup = dg;
this.drawingNumber = d.drawingNumber;
this.drawingGroup.addDrawing(this);
this.workbookSettings = ws;
}
Store management ComboBox()
{
this.initialized = true;
this.origin = Origin.WRITE;
this.referenceCount = 1;
this.type = ShapeType.HOST_CONTROL;
}
private void initialize()
{
this.readSpContainer = this.drawingData.getSpContainer(this.drawingNumber);
Assert.verify(this.readSpContainer != null);
EscherRecord[] children = this.readSpContainer.getChildren();
Sp sp = (Sp)this.readSpContainer.getChildren()[0];
this.objectId = this.objRecord.getObjectId();
this.shapeId = sp.getShapeId();
this.type = ShapeType.getType(sp.getShapeType());
if (this.type == ShapeType.UNKNOWN)
{
logger.warn("Unknown shape type");
}
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
{
this.column = ((int)clientAnchor.getX1());
this.row = ((int)clientAnchor.getY1());
}
this.initialized = true;
}
Store management final void setObjectId(int objid, int bip, int sid)
{
this.objectId = objid;
this.blipId = bip;
this.shapeId = sid;
if (this.origin == Origin.READ)
{
this.origin = Origin.READ_WRITE;
}
}
Store management final int getObjectId()
{
if (!this.initialized)
{
initialize();
}
return this.objectId;
}
Store management final int getShapeId()
{
if (!this.initialized)
{
initialize();
}
return this.shapeId;
}
Store management final int getBlipId()
{
if (!this.initialized)
{
initialize();
}
return this.blipId;
}
Store management MsoDrawingRecord getMsoDrawingRecord()
{
return this.msoDrawingRecord;
}
Store management EscherContainer getSpContainer()
{
if (!this.initialized)
{
initialize();
}
if (this.origin == Origin.READ)
{
return getReadSpContainer();
}
SpContainer spc = new SpContainer();
Sp sp = new Sp(this.type, this.shapeId, 2560);
spc.add(sp);
Opt opt = new Opt();
opt.addProperty(127, false, false, 17039620);
opt.addProperty(191, false, false, 524296);
opt.addProperty(511, false, false, 524288);
opt.addProperty(959, false, false, 131072);
spc.add(opt);
ClientAnchor clientAnchor = new ClientAnchor(this.column, this.row, this.column + 1, this.row + 1);
spc.add(clientAnchor);
ClientData clientData = new ClientData();
spc.add(clientData);
return spc;
}
Store management void setDrawingGroup(DrawingGroup dg)
{
this.drawingGroup = dg;
}
Store management DrawingGroup getDrawingGroup()
{
return this.drawingGroup;
}
Store management Origin getOrigin()
{
return this.origin;
}
Store management int getReferenceCount()
{
return this.referenceCount;
}
Store management void setReferenceCount(int r)
{
this.referenceCount = r;
}
Store management double getX()
{
if (!this.initialized)
{
initialize();
}
return this.column;
}
Store management void setX(double x)
{
if (this.origin == Origin.READ)
{
if (!this.initialized)
{
initialize();
}
this.origin = Origin.READ_WRITE;
}
this.column = ((int)x);
}
Store management double getY()
{
if (!this.initialized)
{
initialize();
}
return this.row;
}
Store management void setY(double y)
{
if (this.origin == Origin.READ)
{
if (!this.initialized)
{
initialize();
}
this.origin = Origin.READ_WRITE;
}
this.row = ((int)y);
}
Store management double getWidth()
{
if (!this.initialized)
{
initialize();
}
return this.width;
}
Store management void setWidth(double w)
{
if (this.origin == Origin.READ)
{
if (!this.initialized)
{
initialize();
}
this.origin = Origin.READ_WRITE;
}
this.width = w;
}
Store management double getHeight()
{
if (!this.initialized)
{
initialize();
}
return this.height;
}
Store management void setHeight(double h)
{
if (this.origin == Origin.READ)
{
if (!this.initialized)
{
initialize();
}
this.origin = Origin.READ_WRITE;
}
this.height = h;
}
private EscherContainer getReadSpContainer()
{
if (!this.initialized)
{
initialize();
}
return this.readSpContainer;
}
Store management byte[] getImageData()
{
Assert.verify((this.origin == Origin.READ) || (this.origin == Origin.READ_WRITE));
if (!this.initialized)
{
initialize();
}
return this.drawingGroup.getImageData(this.blipId);
}
Store management ShapeType getType()
{
return this.type;
}
Store management byte[] getImageBytes()
{
Assert.verify(false);
return null;
}
Store management String getImageFilePath()
{
Assert.verify(false);
return null;
}
Store management void writeAdditionalRecords(File outputFile)
throws IOException
{
if (this.origin == Origin.READ)
{
outputFile.write(this.objRecord);
return;
}
ObjRecord objrec = new ObjRecord(this.objectId, ObjRecord.COMBOBOX);
outputFile.write(objrec);
}
Store management void writeTailRecords(File outputFile)
{
}
Store management int getRow()
{
return 0;
}
Store management int getColumn()
{
return 0;
}
Store management int hashCode()
{
return getClass().getName().hashCode();
}
Store management boolean isFirst()
{
return this.msoDrawingRecord.isFirst();
}
Store management boolean isFormObject()
{
return false;
}
}
package jxl.biff.drawing;
import common.Assert;
import common.Logger;
import java.io.IOException;
import jxl.WorkbookSettings;
import jxl.biff.ContinueRecord;
import jxl.biff.IntegerHelper;
import jxl.biff.StringHelper;
import jxl.write.biff.File;
Store management class Comment
implements DrawingGroupObject
{
private static Logger logger = Logger.getLogger(Comment.class);
private EscherContainer readSpContainer;
private EscherContainer spContainer;
private MsoDrawingRecord msoDrawingRecord;
private ObjRecord objRecord;
private boolean initialized = false;
private int objectId;
private int blipId;
private int shapeId;
private int column;
private int row;
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 drawingNumber;
private MsoDrawingRecord mso;
private TextObjectRecord txo;
private NoteRecord note;
private ContinueRecord text;
private ContinueRecord formatting;
private String commentText;
private WorkbookSettings workbookSettings;
Store management Comment(MsoDrawingRecord msorec, ObjRecord obj, DrawingData dd, DrawingGroup dg, WorkbookSettings ws)
{
this.drawingGroup = dg;
this.msoDrawingRecord = msorec;
this.drawingData = dd;
this.objRecord = obj;
this.initialized = false;
this.workbookSettings = ws;
this.origin = Origin.READ;
this.drawingData.addData(this.msoDrawingRecord.getData());
this.drawingNumber = (this.drawingData.getNumDrawings() - 1);
this.drawingGroup.addDrawing(this);
Assert.verify((this.msoDrawingRecord != null) && (this.objRecord != null));
if (!this.initialized)
{
initialize();
}
}
Store management Comment(DrawingGroupObject dgo, DrawingGroup dg, WorkbookSettings ws)
{
Comment d = (Comment)dgo;
Assert.verify(d.origin == Origin.READ);
this.msoDrawingRecord = d.msoDrawingRecord;
this.objRecord = d.objRecord;
this.initialized = false;
this.origin = Origin.READ;
this.drawingData = d.drawingData;
this.drawingGroup = dg;
this.drawingNumber = d.drawingNumber;
this.drawingGroup.addDrawing(this);
this.mso = d.mso;
this.txo = d.txo;
this.text = d.text;
this.formatting = d.formatting;
this.note = d.note;
this.width = d.width;
this.height = d.height;
this.workbookSettings = ws;
}
Store management Comment(String txt, int c, int r)
{
this.initialized = true;
this.origin = Origin.WRITE;
this.column = c;
this.row = r;
this.referenceCount = 1;
this.type = ShapeType.TEXT_BOX;
mentText = txt;
this.width = 3.0D;
this.height = 4.0D;
}
private void initialize()
{
this.readSpContainer = this.drawingData.getSpContainer(this.drawingNumber);
Assert.verify(this.readSpContainer != null);
EscherRecord[] children = this.readSpContainer.getChildren();
Sp sp = (Sp)this.readSpContainer.getChildren()[0];
this.objectId = this.objRecord.getObjectId();
this.shapeId = sp.getShapeId();
this.type = ShapeType.getType(sp.getShapeType());
if (this.type == ShapeType.UNKNOWN)
{
logger.warn("Unknown shape type");
}
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
{
this.column = ((int)clientAnchor.getX1() - 1);
this.row = ((int)clientAnchor.getY1() + 1);
this.width = (clientAnchor.getX2() - clientAnchor.getX1());
this.height = (clientAnchor.getY2() - clientAnchor.getY1());
}
this.initialized = true;
}
Store management final void setObjectId(int objid, int bip, int sid)
{
this.objectId = objid;
this.blipId = bip;
this.shapeId = sid;
if (this.origin == Origin.READ)
{
this.origin = Origin.READ_WRITE;
}
}
Store management final int getObjectId()
{
if (!this.initialized)
{
initialize();
}
return this.objectId;
}
Store management final int getShapeId()
{
if (!this.initialized)
{
initialize();
}
return this.shapeId;
}
Store management final int getBlipId()
{
if (!this.initialized)
{
initialize();
}
return this.blipId;
}
Store management MsoDrawingRecord getMsoDrawingRecord()
{
return this.msoDrawingRecord;
}
Store management EscherContainer getSpContainer()
{
if (!this.initialized)
{
initialize();
}
if (this.origin == Origin.READ)
{
return getReadSpContainer();
}
if (this.spContainer == null)
{
this.spContainer = new SpContainer();
Sp sp = new Sp(this.type, this.shapeId, 2560);
this.spContainer.add(sp);
Opt opt = new Opt();
opt.addProperty(344, false, false, 0);
opt.addProperty(385, false, false, 134217808);
opt.addProperty(387, false, false, 134217808);
opt.addProperty(959, false, false, 131074);
this.spContainer.add(opt);
ClientAnchor clientAnchor = new ClientAnchor(this.column + 1.3D, Math.max(0.0D, this.row - 0.6D), this.column + 1.3D + this.width, this.row + this.height);
this.spContainer.add(clientAnchor);
ClientData clientData = new ClientData();
this.spContainer.add(clientData);
ClientTextBox clientTextBox = new ClientTextBox();
this.spContainer.add(clientTextBox);
}
return this.spContainer;
}
Store management void setDrawingGroup(DrawingGroup dg)
{
this.drawingGroup = dg;
}
Store management DrawingGroup getDrawingGroup()
{
return this.drawingGroup;
}
Store management Origin getOrigin()
{
return this.origin;
}
Store management int getReferenceCount()
{
return this.referenceCount;
}
Store management void setReferenceCount(int r)
{
this.referenceCount = r;
}
Store management double getX()
{
if (!this.initialized)
{
initialize();
}
return this.column;
}
Store management void setX(double x)
{
if (this.origin =
展开阅读全文