first commit
This commit is contained in:
commit
4d332ef662
27586 changed files with 3281783 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.common.Logger;
|
||||
|
||||
class BStoreContainer extends EscherContainer {
|
||||
private static Logger logger = Logger.getLogger(BStoreContainer.class);
|
||||
|
||||
private int numBlips;
|
||||
|
||||
public BStoreContainer(EscherRecordData erd) {
|
||||
super(erd);
|
||||
this.numBlips = getInstance();
|
||||
}
|
||||
|
||||
public BStoreContainer() {
|
||||
super(EscherRecordType.BSTORE_CONTAINER);
|
||||
}
|
||||
|
||||
void setNumBlips(int count) {
|
||||
this.numBlips = count;
|
||||
setInstance(this.numBlips);
|
||||
}
|
||||
|
||||
public int getNumBlips() {
|
||||
return this.numBlips;
|
||||
}
|
||||
|
||||
public BlipStoreEntry getDrawing(int i) {
|
||||
EscherRecord[] children = getChildren();
|
||||
BlipStoreEntry bse = (BlipStoreEntry)children[i];
|
||||
return bse;
|
||||
}
|
||||
}
|
||||
84
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/BlipStoreEntry.java
Normal file
84
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/BlipStoreEntry.java
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.io.IOException;
|
||||
import jxl.biff.IntegerHelper;
|
||||
import jxl.common.Assert;
|
||||
import jxl.common.Logger;
|
||||
|
||||
class BlipStoreEntry extends EscherAtom {
|
||||
private static Logger logger = Logger.getLogger(BlipStoreEntry.class);
|
||||
|
||||
private BlipType type;
|
||||
|
||||
private byte[] data;
|
||||
|
||||
private int imageDataLength;
|
||||
|
||||
private int referenceCount;
|
||||
|
||||
private boolean write;
|
||||
|
||||
private static final int IMAGE_DATA_OFFSET = 61;
|
||||
|
||||
public BlipStoreEntry(EscherRecordData erd) {
|
||||
super(erd);
|
||||
this.type = BlipType.getType(getInstance());
|
||||
this.write = false;
|
||||
byte[] bytes = getBytes();
|
||||
this.referenceCount = IntegerHelper.getInt(bytes[24], bytes[25], bytes[26], bytes[27]);
|
||||
}
|
||||
|
||||
public BlipStoreEntry(Drawing d) throws IOException {
|
||||
super(EscherRecordType.BSE);
|
||||
this.type = BlipType.PNG;
|
||||
setVersion(2);
|
||||
setInstance(this.type.getValue());
|
||||
byte[] imageData = d.getImageBytes();
|
||||
this.imageDataLength = imageData.length;
|
||||
this.data = new byte[this.imageDataLength + 61];
|
||||
System.arraycopy(imageData, 0, this.data, 61, this.imageDataLength);
|
||||
this.referenceCount = d.getReferenceCount();
|
||||
this.write = true;
|
||||
}
|
||||
|
||||
public BlipType getBlipType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
if (this.write) {
|
||||
this.data[0] = (byte)this.type.getValue();
|
||||
this.data[1] = (byte)this.type.getValue();
|
||||
IntegerHelper.getFourBytes(this.imageDataLength + 8 + 17, this.data, 20);
|
||||
IntegerHelper.getFourBytes(this.referenceCount, this.data, 24);
|
||||
IntegerHelper.getFourBytes(0, this.data, 28);
|
||||
this.data[32] = 0;
|
||||
this.data[33] = 0;
|
||||
this.data[34] = 126;
|
||||
this.data[35] = 1;
|
||||
this.data[36] = 0;
|
||||
this.data[37] = 110;
|
||||
IntegerHelper.getTwoBytes(61470, this.data, 38);
|
||||
IntegerHelper.getFourBytes(this.imageDataLength + 17, this.data, 40);
|
||||
} else {
|
||||
this.data = getBytes();
|
||||
}
|
||||
return setHeaderData(this.data);
|
||||
}
|
||||
|
||||
void dereference() {
|
||||
this.referenceCount--;
|
||||
Assert.verify((this.referenceCount >= 0));
|
||||
}
|
||||
|
||||
int getReferenceCount() {
|
||||
return this.referenceCount;
|
||||
}
|
||||
|
||||
byte[] getImageData() {
|
||||
byte[] allData = getBytes();
|
||||
byte[] imageData = new byte[allData.length - 61];
|
||||
System.arraycopy(allData, 61, imageData, 0, imageData.length);
|
||||
return imageData;
|
||||
}
|
||||
}
|
||||
57
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/BlipType.java
Normal file
57
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/BlipType.java
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
final class BlipType {
|
||||
private int value;
|
||||
|
||||
private String desc;
|
||||
|
||||
private static BlipType[] types = new BlipType[0];
|
||||
|
||||
private BlipType(int val, String d) {
|
||||
this.value = val;
|
||||
this.desc = d;
|
||||
BlipType[] newtypes = new BlipType[types.length + 1];
|
||||
System.arraycopy(types, 0, newtypes, 0, types.length);
|
||||
newtypes[types.length] = this;
|
||||
types = newtypes;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static BlipType getType(int val) {
|
||||
BlipType type = UNKNOWN;
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if ((types[i]).value == val) {
|
||||
type = types[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public static final BlipType ERROR = new BlipType(0, "Error");
|
||||
|
||||
public static final BlipType UNKNOWN = new BlipType(1, "Unknown");
|
||||
|
||||
public static final BlipType EMF = new BlipType(2, "EMF");
|
||||
|
||||
public static final BlipType WMF = new BlipType(3, "WMF");
|
||||
|
||||
public static final BlipType PICT = new BlipType(4, "PICT");
|
||||
|
||||
public static final BlipType JPEG = new BlipType(5, "JPEG");
|
||||
|
||||
public static final BlipType PNG = new BlipType(6, "PNG");
|
||||
|
||||
public static final BlipType DIB = new BlipType(7, "DIB");
|
||||
|
||||
public static final BlipType FIRST_CLIENT = new BlipType(32, "FIRST");
|
||||
|
||||
public static final BlipType LAST_CLIENT = new BlipType(255, "LAST");
|
||||
}
|
||||
358
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Button.java
Normal file
358
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Button.java
Normal file
|
|
@ -0,0 +1,358 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.io.IOException;
|
||||
import jxl.WorkbookSettings;
|
||||
import jxl.biff.ContinueRecord;
|
||||
import jxl.biff.IntegerHelper;
|
||||
import jxl.biff.StringHelper;
|
||||
import jxl.common.Assert;
|
||||
import jxl.common.Logger;
|
||||
import jxl.write.biff.File;
|
||||
|
||||
public class Button implements DrawingGroupObject {
|
||||
private static Logger logger = Logger.getLogger(Button.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 ContinueRecord text;
|
||||
|
||||
private ContinueRecord formatting;
|
||||
|
||||
private String commentText;
|
||||
|
||||
private WorkbookSettings workbookSettings;
|
||||
|
||||
public Button(MsoDrawingRecord msodr, ObjRecord obj, DrawingData dd, DrawingGroup dg, WorkbookSettings ws) {
|
||||
this.drawingGroup = dg;
|
||||
this.msoDrawingRecord = msodr;
|
||||
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));
|
||||
initialize();
|
||||
}
|
||||
|
||||
public Button(DrawingGroupObject dgo, DrawingGroup dg, WorkbookSettings ws) {
|
||||
Button d = (Button)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.workbookSettings = ws;
|
||||
}
|
||||
|
||||
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.initialized = true;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public final int getObjectId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.objectId;
|
||||
}
|
||||
|
||||
public final int getShapeId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.shapeId;
|
||||
}
|
||||
|
||||
public final int getBlipId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.blipId;
|
||||
}
|
||||
|
||||
public MsoDrawingRecord getMsoDrawingRecord() {
|
||||
return this.msoDrawingRecord;
|
||||
}
|
||||
|
||||
public EscherContainer getSpContainer() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
if (this.origin == Origin.READ)
|
||||
return getReadSpContainer();
|
||||
Assert.verify(false);
|
||||
return this.spContainer;
|
||||
}
|
||||
|
||||
public void setDrawingGroup(DrawingGroup dg) {
|
||||
this.drawingGroup = dg;
|
||||
}
|
||||
|
||||
public DrawingGroup getDrawingGroup() {
|
||||
return this.drawingGroup;
|
||||
}
|
||||
|
||||
public Origin getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
public int getReferenceCount() {
|
||||
return this.referenceCount;
|
||||
}
|
||||
|
||||
public void setReferenceCount(int r) {
|
||||
this.referenceCount = r;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return (double)this.column;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.column = (int)x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return (double)this.row;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.row = (int)y;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public void setWidth(double w) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.width = w;
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public byte[] getImageData() {
|
||||
Assert.verify((this.origin == Origin.READ || this.origin == Origin.READ_WRITE));
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.drawingGroup.getImageData(this.blipId);
|
||||
}
|
||||
|
||||
public ShapeType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setTextObject(TextObjectRecord t) {
|
||||
this.txo = t;
|
||||
}
|
||||
|
||||
public void setText(ContinueRecord t) {
|
||||
this.text = t;
|
||||
}
|
||||
|
||||
public void setFormatting(ContinueRecord t) {
|
||||
this.formatting = t;
|
||||
}
|
||||
|
||||
public byte[] getImageBytes() {
|
||||
Assert.verify(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getImageFilePath() {
|
||||
Assert.verify(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addMso(MsoDrawingRecord d) {
|
||||
this.mso = d;
|
||||
this.drawingData.addRawData(this.mso.getData());
|
||||
}
|
||||
|
||||
public void writeAdditionalRecords(File outputFile) throws IOException {
|
||||
if (this.origin == Origin.READ) {
|
||||
outputFile.write(this.objRecord);
|
||||
if (this.mso != null)
|
||||
outputFile.write(this.mso);
|
||||
outputFile.write(this.txo);
|
||||
outputFile.write(this.text);
|
||||
if (this.formatting != null)
|
||||
outputFile.write(this.formatting);
|
||||
return;
|
||||
}
|
||||
Assert.verify(false);
|
||||
ObjRecord objrec = new ObjRecord(this.objectId, ObjRecord.EXCELNOTE);
|
||||
outputFile.write(objrec);
|
||||
ClientTextBox textBox = new ClientTextBox();
|
||||
MsoDrawingRecord msod = new MsoDrawingRecord(textBox.getData());
|
||||
outputFile.write(msod);
|
||||
TextObjectRecord tor = new TextObjectRecord(getText());
|
||||
outputFile.write(tor);
|
||||
byte[] textData = new byte[this.commentText.length() * 2 + 1];
|
||||
textData[0] = 1;
|
||||
StringHelper.getUnicodeBytes(this.commentText, textData, 1);
|
||||
ContinueRecord textContinue = new ContinueRecord(textData);
|
||||
outputFile.write(textContinue);
|
||||
byte[] frData = new byte[16];
|
||||
IntegerHelper.getTwoBytes(0, frData, 0);
|
||||
IntegerHelper.getTwoBytes(0, frData, 2);
|
||||
IntegerHelper.getTwoBytes(this.commentText.length(), frData, 8);
|
||||
IntegerHelper.getTwoBytes(0, frData, 10);
|
||||
ContinueRecord frContinue = new ContinueRecord(frData);
|
||||
outputFile.write(frContinue);
|
||||
}
|
||||
|
||||
public void writeTailRecords(File outputFile) {}
|
||||
|
||||
public int getRow() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getColumn() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
if (this.commentText == null) {
|
||||
Assert.verify((this.text != null));
|
||||
byte[] td = this.text.getData();
|
||||
if (td[0] == 0) {
|
||||
this.commentText = StringHelper.getString(td, td.length - 1, 1, this.workbookSettings);
|
||||
} else {
|
||||
this.commentText = StringHelper.getUnicodeString(td, (td.length - 1) / 2, 1);
|
||||
}
|
||||
}
|
||||
return this.commentText;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.commentText.hashCode();
|
||||
}
|
||||
|
||||
public void setButtonText(String t) {
|
||||
this.commentText = t;
|
||||
if (this.origin == Origin.READ)
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
|
||||
public boolean isFirst() {
|
||||
return this.mso.isFirst();
|
||||
}
|
||||
|
||||
public boolean isFormObject() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
111
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Chart.java
Normal file
111
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Chart.java
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.WorkbookSettings;
|
||||
import jxl.biff.ByteData;
|
||||
import jxl.biff.IndexMapping;
|
||||
import jxl.biff.IntegerHelper;
|
||||
import jxl.biff.Type;
|
||||
import jxl.common.Assert;
|
||||
import jxl.common.Logger;
|
||||
import jxl.read.biff.File;
|
||||
|
||||
public class Chart implements ByteData, EscherStream {
|
||||
private static final Logger logger = Logger.getLogger(Chart.class);
|
||||
|
||||
private MsoDrawingRecord msoDrawingRecord;
|
||||
|
||||
private ObjRecord objRecord;
|
||||
|
||||
private int startpos;
|
||||
|
||||
private int endpos;
|
||||
|
||||
private File file;
|
||||
|
||||
private DrawingData drawingData;
|
||||
|
||||
private int drawingNumber;
|
||||
|
||||
private byte[] data;
|
||||
|
||||
private boolean initialized;
|
||||
|
||||
private WorkbookSettings workbookSettings;
|
||||
|
||||
public Chart(MsoDrawingRecord mso, ObjRecord obj, DrawingData dd, int sp, int ep, File f, WorkbookSettings ws) {
|
||||
this.msoDrawingRecord = mso;
|
||||
this.objRecord = obj;
|
||||
this.startpos = sp;
|
||||
this.endpos = ep;
|
||||
this.file = f;
|
||||
this.workbookSettings = ws;
|
||||
if (this.msoDrawingRecord != null) {
|
||||
this.drawingData = dd;
|
||||
this.drawingData.addData(this.msoDrawingRecord.getRecord().getData());
|
||||
this.drawingNumber = this.drawingData.getNumDrawings() - 1;
|
||||
}
|
||||
this.initialized = false;
|
||||
Assert.verify(((mso != null && obj != null) || (mso == null && obj == null)));
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return this.msoDrawingRecord.getRecord().getData();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
this.data = this.file.read(this.startpos, this.endpos - this.startpos);
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
public void rationalize(IndexMapping xfMapping, IndexMapping fontMapping, IndexMapping formatMapping) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
int pos = 0;
|
||||
int code = 0;
|
||||
int length = 0;
|
||||
Type type = null;
|
||||
while (pos < this.data.length) {
|
||||
code = IntegerHelper.getInt(this.data[pos], this.data[pos + 1]);
|
||||
length = IntegerHelper.getInt(this.data[pos + 2], this.data[pos + 3]);
|
||||
type = Type.getType(code);
|
||||
if (type == Type.FONTX) {
|
||||
int fontind = IntegerHelper.getInt(this.data[pos + 4], this.data[pos + 5]);
|
||||
IntegerHelper.getTwoBytes(fontMapping.getNewIndex(fontind), this.data, pos + 4);
|
||||
} else if (type == Type.FBI) {
|
||||
int fontind = IntegerHelper.getInt(this.data[pos + 12], this.data[pos + 13]);
|
||||
IntegerHelper.getTwoBytes(fontMapping.getNewIndex(fontind), this.data, pos + 12);
|
||||
} else if (type == Type.IFMT) {
|
||||
int formind = IntegerHelper.getInt(this.data[pos + 4], this.data[pos + 5]);
|
||||
IntegerHelper.getTwoBytes(formatMapping.getNewIndex(formind), this.data, pos + 4);
|
||||
} else if (type == Type.ALRUNS) {
|
||||
int numRuns = IntegerHelper.getInt(this.data[pos + 4], this.data[pos + 5]);
|
||||
int fontPos = pos + 6;
|
||||
for (int i = 0; i < numRuns; i++) {
|
||||
int fontind = IntegerHelper.getInt(this.data[fontPos + 2], this.data[fontPos + 3]);
|
||||
IntegerHelper.getTwoBytes(fontMapping.getNewIndex(fontind), this.data, fontPos + 2);
|
||||
fontPos += 4;
|
||||
}
|
||||
}
|
||||
pos += length + 4;
|
||||
}
|
||||
}
|
||||
|
||||
EscherContainer getSpContainer() {
|
||||
EscherContainer spContainer = this.drawingData.getSpContainer(this.drawingNumber);
|
||||
return spContainer;
|
||||
}
|
||||
|
||||
MsoDrawingRecord getMsoDrawingRecord() {
|
||||
return this.msoDrawingRecord;
|
||||
}
|
||||
|
||||
ObjRecord getObjRecord() {
|
||||
return this.objRecord;
|
||||
}
|
||||
}
|
||||
337
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/CheckBox.java
Normal file
337
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/CheckBox.java
Normal file
|
|
@ -0,0 +1,337 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.io.IOException;
|
||||
import jxl.WorkbookSettings;
|
||||
import jxl.biff.ContinueRecord;
|
||||
import jxl.common.Assert;
|
||||
import jxl.common.Logger;
|
||||
import jxl.write.biff.File;
|
||||
|
||||
public class CheckBox implements DrawingGroupObject {
|
||||
private static Logger logger = Logger.getLogger(CheckBox.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 ContinueRecord text;
|
||||
|
||||
private ContinueRecord formatting;
|
||||
|
||||
private WorkbookSettings workbookSettings;
|
||||
|
||||
public CheckBox(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();
|
||||
}
|
||||
|
||||
public CheckBox(DrawingGroupObject dgo, DrawingGroup dg, WorkbookSettings ws) {
|
||||
CheckBox d = (CheckBox)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.workbookSettings = ws;
|
||||
}
|
||||
|
||||
public CheckBox() {
|
||||
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;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public final int getObjectId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.objectId;
|
||||
}
|
||||
|
||||
public final int getShapeId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.shapeId;
|
||||
}
|
||||
|
||||
public final int getBlipId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.blipId;
|
||||
}
|
||||
|
||||
public MsoDrawingRecord getMsoDrawingRecord() {
|
||||
return this.msoDrawingRecord;
|
||||
}
|
||||
|
||||
public 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((double)this.column, (double)this.row, (double)(this.column + 1), (double)(this.row + 1), 1);
|
||||
spc.add(clientAnchor);
|
||||
ClientData clientData = new ClientData();
|
||||
spc.add(clientData);
|
||||
return spc;
|
||||
}
|
||||
|
||||
public void setDrawingGroup(DrawingGroup dg) {
|
||||
this.drawingGroup = dg;
|
||||
}
|
||||
|
||||
public DrawingGroup getDrawingGroup() {
|
||||
return this.drawingGroup;
|
||||
}
|
||||
|
||||
public Origin getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
public int getReferenceCount() {
|
||||
return this.referenceCount;
|
||||
}
|
||||
|
||||
public void setReferenceCount(int r) {
|
||||
this.referenceCount = r;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return (double)this.column;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.column = (int)x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return (double)this.row;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.row = (int)y;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public void setWidth(double w) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.width = w;
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public byte[] getImageData() {
|
||||
Assert.verify((this.origin == Origin.READ || this.origin == Origin.READ_WRITE));
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.drawingGroup.getImageData(this.blipId);
|
||||
}
|
||||
|
||||
public ShapeType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public byte[] getImageBytes() {
|
||||
Assert.verify(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getImageFilePath() {
|
||||
Assert.verify(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void writeAdditionalRecords(File outputFile) throws IOException {
|
||||
if (this.origin == Origin.READ) {
|
||||
outputFile.write(this.objRecord);
|
||||
if (this.mso != null)
|
||||
outputFile.write(this.mso);
|
||||
outputFile.write(this.txo);
|
||||
outputFile.write(this.text);
|
||||
if (this.formatting != null)
|
||||
outputFile.write(this.formatting);
|
||||
return;
|
||||
}
|
||||
ObjRecord objrec = new ObjRecord(this.objectId, ObjRecord.CHECKBOX);
|
||||
outputFile.write(objrec);
|
||||
logger.warn("Writing of additional records for checkboxes not implemented");
|
||||
}
|
||||
|
||||
public void writeTailRecords(File outputFile) {}
|
||||
|
||||
public int getRow() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getColumn() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return getClass().getName().hashCode();
|
||||
}
|
||||
|
||||
public boolean isFirst() {
|
||||
return this.msoDrawingRecord.isFirst();
|
||||
}
|
||||
|
||||
public boolean isFormObject() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setTextObject(TextObjectRecord t) {
|
||||
this.txo = t;
|
||||
}
|
||||
|
||||
public void setText(ContinueRecord t) {
|
||||
this.text = t;
|
||||
}
|
||||
|
||||
public void setFormatting(ContinueRecord t) {
|
||||
this.formatting = t;
|
||||
}
|
||||
|
||||
public void addMso(MsoDrawingRecord d) {
|
||||
this.mso = d;
|
||||
this.drawingData.addRawData(this.mso.getData());
|
||||
}
|
||||
}
|
||||
23
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Chunk.java
Normal file
23
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Chunk.java
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
class Chunk {
|
||||
private int pos;
|
||||
|
||||
private int length;
|
||||
|
||||
private ChunkType type;
|
||||
|
||||
private byte[] data;
|
||||
|
||||
public Chunk(int p, int l, ChunkType ct, byte[] d) {
|
||||
this.pos = p;
|
||||
this.length = l;
|
||||
this.type = ct;
|
||||
this.data = new byte[this.length];
|
||||
System.arraycopy(d, this.pos, this.data, 0, this.length);
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
45
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ChunkType.java
Normal file
45
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ChunkType.java
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
class ChunkType {
|
||||
private byte[] id;
|
||||
|
||||
private String name;
|
||||
|
||||
private static ChunkType[] chunkTypes = new ChunkType[0];
|
||||
|
||||
private ChunkType(int d1, int d2, int d3, int d4, String n) {
|
||||
this.id = new byte[] { (byte)d1, (byte)d2, (byte)d3, (byte)d4 };
|
||||
this.name = n;
|
||||
ChunkType[] ct = new ChunkType[chunkTypes.length + 1];
|
||||
System.arraycopy(chunkTypes, 0, ct, 0, chunkTypes.length);
|
||||
ct[chunkTypes.length] = this;
|
||||
chunkTypes = ct;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public static ChunkType getChunkType(byte d1, byte d2, byte d3, byte d4) {
|
||||
byte[] cmp = { d1, d2, d3, d4 };
|
||||
boolean found = false;
|
||||
ChunkType chunk = UNKNOWN;
|
||||
for (int i = 0; i < chunkTypes.length && !found; i++) {
|
||||
if (Arrays.equals((chunkTypes[i]).id, cmp)) {
|
||||
chunk = chunkTypes[i];
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
public static ChunkType IHDR = new ChunkType(73, 72, 68, 82, "IHDR");
|
||||
|
||||
public static ChunkType IEND = new ChunkType(73, 69, 78, 68, "IEND");
|
||||
|
||||
public static ChunkType PHYS = new ChunkType(112, 72, 89, 115, "pHYs");
|
||||
|
||||
public static ChunkType UNKNOWN = new ChunkType(255, 255, 255, 255, "UNKNOWN");
|
||||
}
|
||||
85
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ClientAnchor.java
Normal file
85
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ClientAnchor.java
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.biff.IntegerHelper;
|
||||
import jxl.common.Logger;
|
||||
|
||||
class ClientAnchor extends EscherAtom {
|
||||
private static final Logger logger = Logger.getLogger(ClientAnchor.class);
|
||||
|
||||
private byte[] data;
|
||||
|
||||
private int properties;
|
||||
|
||||
private double x1;
|
||||
|
||||
private double y1;
|
||||
|
||||
private double x2;
|
||||
|
||||
private double y2;
|
||||
|
||||
public ClientAnchor(EscherRecordData erd) {
|
||||
super(erd);
|
||||
byte[] bytes = getBytes();
|
||||
this.properties = IntegerHelper.getInt(bytes[0], bytes[1]);
|
||||
int x1Cell = IntegerHelper.getInt(bytes[2], bytes[3]);
|
||||
int x1Fraction = IntegerHelper.getInt(bytes[4], bytes[5]);
|
||||
this.x1 = (double)x1Cell + (double)x1Fraction / 1024.0D;
|
||||
int y1Cell = IntegerHelper.getInt(bytes[6], bytes[7]);
|
||||
int y1Fraction = IntegerHelper.getInt(bytes[8], bytes[9]);
|
||||
this.y1 = (double)y1Cell + (double)y1Fraction / 256.0D;
|
||||
int x2Cell = IntegerHelper.getInt(bytes[10], bytes[11]);
|
||||
int x2Fraction = IntegerHelper.getInt(bytes[12], bytes[13]);
|
||||
this.x2 = (double)x2Cell + (double)x2Fraction / 1024.0D;
|
||||
int y2Cell = IntegerHelper.getInt(bytes[14], bytes[15]);
|
||||
int y2Fraction = IntegerHelper.getInt(bytes[16], bytes[17]);
|
||||
this.y2 = (double)y2Cell + (double)y2Fraction / 256.0D;
|
||||
}
|
||||
|
||||
public ClientAnchor(double x1, double y1, double x2, double y2, int props) {
|
||||
super(EscherRecordType.CLIENT_ANCHOR);
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
this.properties = props;
|
||||
}
|
||||
|
||||
byte[] getData() {
|
||||
this.data = new byte[18];
|
||||
IntegerHelper.getTwoBytes(this.properties, this.data, 0);
|
||||
IntegerHelper.getTwoBytes((int)this.x1, this.data, 2);
|
||||
int x1fraction = (int)((this.x1 - (double)(int)this.x1) * 1024.0D);
|
||||
IntegerHelper.getTwoBytes(x1fraction, this.data, 4);
|
||||
IntegerHelper.getTwoBytes((int)this.y1, this.data, 6);
|
||||
int y1fraction = (int)((this.y1 - (double)(int)this.y1) * 256.0D);
|
||||
IntegerHelper.getTwoBytes(y1fraction, this.data, 8);
|
||||
IntegerHelper.getTwoBytes((int)this.x2, this.data, 10);
|
||||
int x2fraction = (int)((this.x2 - (double)(int)this.x2) * 1024.0D);
|
||||
IntegerHelper.getTwoBytes(x2fraction, this.data, 12);
|
||||
IntegerHelper.getTwoBytes((int)this.y2, this.data, 14);
|
||||
int y2fraction = (int)((this.y2 - (double)(int)this.y2) * 256.0D);
|
||||
IntegerHelper.getTwoBytes(y2fraction, this.data, 16);
|
||||
return setHeaderData(this.data);
|
||||
}
|
||||
|
||||
double getX1() {
|
||||
return this.x1;
|
||||
}
|
||||
|
||||
double getY1() {
|
||||
return this.y1;
|
||||
}
|
||||
|
||||
double getX2() {
|
||||
return this.x2;
|
||||
}
|
||||
|
||||
double getY2() {
|
||||
return this.y2;
|
||||
}
|
||||
|
||||
int getProperties() {
|
||||
return this.properties;
|
||||
}
|
||||
}
|
||||
22
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ClientData.java
Normal file
22
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ClientData.java
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.common.Logger;
|
||||
|
||||
class ClientData extends EscherAtom {
|
||||
private static Logger logger = Logger.getLogger(ClientData.class);
|
||||
|
||||
private byte[] data;
|
||||
|
||||
public ClientData(EscherRecordData erd) {
|
||||
super(erd);
|
||||
}
|
||||
|
||||
public ClientData() {
|
||||
super(EscherRecordType.CLIENT_DATA);
|
||||
}
|
||||
|
||||
byte[] getData() {
|
||||
this.data = new byte[0];
|
||||
return setHeaderData(this.data);
|
||||
}
|
||||
}
|
||||
22
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ClientTextBox.java
Normal file
22
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ClientTextBox.java
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.common.Logger;
|
||||
|
||||
class ClientTextBox extends EscherAtom {
|
||||
private static Logger logger = Logger.getLogger(ClientTextBox.class);
|
||||
|
||||
private byte[] data;
|
||||
|
||||
public ClientTextBox(EscherRecordData erd) {
|
||||
super(erd);
|
||||
}
|
||||
|
||||
public ClientTextBox() {
|
||||
super(EscherRecordType.CLIENT_TEXT_BOX);
|
||||
}
|
||||
|
||||
byte[] getData() {
|
||||
this.data = new byte[0];
|
||||
return setHeaderData(this.data);
|
||||
}
|
||||
}
|
||||
300
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ComboBox.java
Normal file
300
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ComboBox.java
Normal file
|
|
@ -0,0 +1,300 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.io.IOException;
|
||||
import jxl.WorkbookSettings;
|
||||
import jxl.common.Assert;
|
||||
import jxl.common.Logger;
|
||||
import jxl.write.biff.File;
|
||||
|
||||
public 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;
|
||||
|
||||
public 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();
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public final int getObjectId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.objectId;
|
||||
}
|
||||
|
||||
public final int getShapeId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.shapeId;
|
||||
}
|
||||
|
||||
public final int getBlipId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.blipId;
|
||||
}
|
||||
|
||||
public MsoDrawingRecord getMsoDrawingRecord() {
|
||||
return this.msoDrawingRecord;
|
||||
}
|
||||
|
||||
public 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((double)this.column, (double)this.row, (double)(this.column + 1), (double)(this.row + 1), 1);
|
||||
spc.add(clientAnchor);
|
||||
ClientData clientData = new ClientData();
|
||||
spc.add(clientData);
|
||||
return spc;
|
||||
}
|
||||
|
||||
public void setDrawingGroup(DrawingGroup dg) {
|
||||
this.drawingGroup = dg;
|
||||
}
|
||||
|
||||
public DrawingGroup getDrawingGroup() {
|
||||
return this.drawingGroup;
|
||||
}
|
||||
|
||||
public Origin getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
public int getReferenceCount() {
|
||||
return this.referenceCount;
|
||||
}
|
||||
|
||||
public void setReferenceCount(int r) {
|
||||
this.referenceCount = r;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return (double)this.column;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.column = (int)x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return (double)this.row;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.row = (int)y;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public void setWidth(double w) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.width = w;
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public byte[] getImageData() {
|
||||
Assert.verify((this.origin == Origin.READ || this.origin == Origin.READ_WRITE));
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.drawingGroup.getImageData(this.blipId);
|
||||
}
|
||||
|
||||
public ShapeType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public byte[] getImageBytes() {
|
||||
Assert.verify(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getImageFilePath() {
|
||||
Assert.verify(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
public 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);
|
||||
}
|
||||
|
||||
public void writeTailRecords(File outputFile) {}
|
||||
|
||||
public int getRow() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getColumn() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return getClass().getName().hashCode();
|
||||
}
|
||||
|
||||
public boolean isFirst() {
|
||||
return this.msoDrawingRecord.isFirst();
|
||||
}
|
||||
|
||||
public boolean isFormObject() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
404
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Comment.java
Normal file
404
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Comment.java
Normal file
|
|
@ -0,0 +1,404 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.io.IOException;
|
||||
import jxl.WorkbookSettings;
|
||||
import jxl.biff.ContinueRecord;
|
||||
import jxl.biff.IntegerHelper;
|
||||
import jxl.biff.StringHelper;
|
||||
import jxl.common.Assert;
|
||||
import jxl.common.Logger;
|
||||
import jxl.write.biff.File;
|
||||
|
||||
public 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;
|
||||
|
||||
public 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();
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public 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;
|
||||
this.commentText = 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;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public final int getObjectId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.objectId;
|
||||
}
|
||||
|
||||
public final int getShapeId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.shapeId;
|
||||
}
|
||||
|
||||
public final int getBlipId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.blipId;
|
||||
}
|
||||
|
||||
public MsoDrawingRecord getMsoDrawingRecord() {
|
||||
return this.msoDrawingRecord;
|
||||
}
|
||||
|
||||
public 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((double)this.column + 1.3D, Math.max(0.0D, (double)this.row - 0.6D), (double)this.column + 1.3D + this.width, (double)this.row + this.height, 1);
|
||||
this.spContainer.add(clientAnchor);
|
||||
ClientData clientData = new ClientData();
|
||||
this.spContainer.add(clientData);
|
||||
ClientTextBox clientTextBox = new ClientTextBox();
|
||||
this.spContainer.add(clientTextBox);
|
||||
}
|
||||
return this.spContainer;
|
||||
}
|
||||
|
||||
public void setDrawingGroup(DrawingGroup dg) {
|
||||
this.drawingGroup = dg;
|
||||
}
|
||||
|
||||
public DrawingGroup getDrawingGroup() {
|
||||
return this.drawingGroup;
|
||||
}
|
||||
|
||||
public Origin getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
public int getReferenceCount() {
|
||||
return this.referenceCount;
|
||||
}
|
||||
|
||||
public void setReferenceCount(int r) {
|
||||
this.referenceCount = r;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return (double)this.column;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.column = (int)x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return (double)this.row;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.row = (int)y;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public void setWidth(double w) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.width = w;
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public byte[] getImageData() {
|
||||
Assert.verify((this.origin == Origin.READ || this.origin == Origin.READ_WRITE));
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.drawingGroup.getImageData(this.blipId);
|
||||
}
|
||||
|
||||
public ShapeType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void setTextObject(TextObjectRecord t) {
|
||||
this.txo = t;
|
||||
}
|
||||
|
||||
public void setNote(NoteRecord t) {
|
||||
this.note = t;
|
||||
}
|
||||
|
||||
public void setText(ContinueRecord t) {
|
||||
this.text = t;
|
||||
}
|
||||
|
||||
public void setFormatting(ContinueRecord t) {
|
||||
this.formatting = t;
|
||||
}
|
||||
|
||||
public byte[] getImageBytes() {
|
||||
Assert.verify(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getImageFilePath() {
|
||||
Assert.verify(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addMso(MsoDrawingRecord d) {
|
||||
this.mso = d;
|
||||
this.drawingData.addRawData(this.mso.getData());
|
||||
}
|
||||
|
||||
public void writeAdditionalRecords(File outputFile) throws IOException {
|
||||
if (this.origin == Origin.READ) {
|
||||
outputFile.write(this.objRecord);
|
||||
if (this.mso != null)
|
||||
outputFile.write(this.mso);
|
||||
outputFile.write(this.txo);
|
||||
outputFile.write(this.text);
|
||||
if (this.formatting != null)
|
||||
outputFile.write(this.formatting);
|
||||
return;
|
||||
}
|
||||
ObjRecord objrec = new ObjRecord(this.objectId, ObjRecord.EXCELNOTE);
|
||||
outputFile.write(objrec);
|
||||
ClientTextBox textBox = new ClientTextBox();
|
||||
MsoDrawingRecord msod = new MsoDrawingRecord(textBox.getData());
|
||||
outputFile.write(msod);
|
||||
TextObjectRecord txorec = new TextObjectRecord(getText());
|
||||
outputFile.write(txorec);
|
||||
byte[] textData = new byte[this.commentText.length() * 2 + 1];
|
||||
textData[0] = 1;
|
||||
StringHelper.getUnicodeBytes(this.commentText, textData, 1);
|
||||
ContinueRecord textContinue = new ContinueRecord(textData);
|
||||
outputFile.write(textContinue);
|
||||
byte[] frData = new byte[16];
|
||||
IntegerHelper.getTwoBytes(0, frData, 0);
|
||||
IntegerHelper.getTwoBytes(0, frData, 2);
|
||||
IntegerHelper.getTwoBytes(this.commentText.length(), frData, 8);
|
||||
IntegerHelper.getTwoBytes(0, frData, 10);
|
||||
ContinueRecord frContinue = new ContinueRecord(frData);
|
||||
outputFile.write(frContinue);
|
||||
}
|
||||
|
||||
public void writeTailRecords(File outputFile) throws IOException {
|
||||
if (this.origin == Origin.READ) {
|
||||
outputFile.write(this.note);
|
||||
return;
|
||||
}
|
||||
NoteRecord noteRecord = new NoteRecord(this.column, this.row, this.objectId);
|
||||
outputFile.write(noteRecord);
|
||||
}
|
||||
|
||||
public int getRow() {
|
||||
return this.note.getRow();
|
||||
}
|
||||
|
||||
public int getColumn() {
|
||||
return this.note.getColumn();
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
if (this.commentText == null) {
|
||||
Assert.verify((this.text != null));
|
||||
byte[] td = this.text.getData();
|
||||
if (td[0] == 0) {
|
||||
this.commentText = StringHelper.getString(td, td.length - 1, 1, this.workbookSettings);
|
||||
} else {
|
||||
this.commentText = StringHelper.getUnicodeString(td, (td.length - 1) / 2, 1);
|
||||
}
|
||||
}
|
||||
return this.commentText;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.commentText.hashCode();
|
||||
}
|
||||
|
||||
public void setCommentText(String t) {
|
||||
this.commentText = t;
|
||||
if (this.origin == Origin.READ)
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
|
||||
public boolean isFirst() {
|
||||
return this.msoDrawingRecord.isFirst();
|
||||
}
|
||||
|
||||
public boolean isFormObject() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
44
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Dg.java
Normal file
44
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Dg.java
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.biff.IntegerHelper;
|
||||
|
||||
class Dg extends EscherAtom {
|
||||
private byte[] data;
|
||||
|
||||
private int drawingId;
|
||||
|
||||
private int shapeCount;
|
||||
|
||||
private int seed;
|
||||
|
||||
public Dg(EscherRecordData erd) {
|
||||
super(erd);
|
||||
this.drawingId = getInstance();
|
||||
byte[] bytes = getBytes();
|
||||
this.shapeCount = IntegerHelper.getInt(bytes[0], bytes[1], bytes[2], bytes[3]);
|
||||
this.seed = IntegerHelper.getInt(bytes[4], bytes[5], bytes[6], bytes[7]);
|
||||
}
|
||||
|
||||
public Dg(int numDrawings) {
|
||||
super(EscherRecordType.DG);
|
||||
this.drawingId = 1;
|
||||
this.shapeCount = numDrawings + 1;
|
||||
this.seed = 1024 + this.shapeCount + 1;
|
||||
setInstance(this.drawingId);
|
||||
}
|
||||
|
||||
public int getDrawingId() {
|
||||
return this.drawingId;
|
||||
}
|
||||
|
||||
int getShapeCount() {
|
||||
return this.shapeCount;
|
||||
}
|
||||
|
||||
byte[] getData() {
|
||||
this.data = new byte[8];
|
||||
IntegerHelper.getFourBytes(this.shapeCount, this.data, 0);
|
||||
IntegerHelper.getFourBytes(this.seed, this.data, 4);
|
||||
return setHeaderData(this.data);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
class DgContainer extends EscherContainer {
|
||||
public DgContainer() {
|
||||
super(EscherRecordType.DG_CONTAINER);
|
||||
}
|
||||
}
|
||||
91
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Dgg.java
Normal file
91
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Dgg.java
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import jxl.biff.IntegerHelper;
|
||||
import jxl.common.Logger;
|
||||
|
||||
class Dgg extends EscherAtom {
|
||||
private static Logger logger = Logger.getLogger(Dgg.class);
|
||||
|
||||
private byte[] data;
|
||||
|
||||
private int numClusters;
|
||||
|
||||
private int maxShapeId;
|
||||
|
||||
private int shapesSaved;
|
||||
|
||||
private int drawingsSaved;
|
||||
|
||||
private ArrayList clusters;
|
||||
|
||||
static final class Cluster {
|
||||
int drawingGroupId;
|
||||
|
||||
int shapeIdsUsed;
|
||||
|
||||
Cluster(int dgId, int sids) {
|
||||
this.drawingGroupId = dgId;
|
||||
this.shapeIdsUsed = sids;
|
||||
}
|
||||
}
|
||||
|
||||
public Dgg(EscherRecordData erd) {
|
||||
super(erd);
|
||||
this.clusters = new ArrayList();
|
||||
byte[] bytes = getBytes();
|
||||
this.maxShapeId = IntegerHelper.getInt(bytes[0], bytes[1], bytes[2], bytes[3]);
|
||||
this.numClusters = IntegerHelper.getInt(bytes[4], bytes[5], bytes[6], bytes[7]);
|
||||
this.shapesSaved = IntegerHelper.getInt(bytes[8], bytes[9], bytes[10], bytes[11]);
|
||||
this.drawingsSaved = IntegerHelper.getInt(bytes[12], bytes[13], bytes[14], bytes[15]);
|
||||
int pos = 16;
|
||||
for (int i = 0; i < this.numClusters; i++) {
|
||||
int dgId = IntegerHelper.getInt(bytes[pos], bytes[pos + 1]);
|
||||
int sids = IntegerHelper.getInt(bytes[pos + 2], bytes[pos + 3]);
|
||||
Cluster c = new Cluster(dgId, sids);
|
||||
this.clusters.add(c);
|
||||
pos += 4;
|
||||
}
|
||||
}
|
||||
|
||||
public Dgg(int numShapes, int numDrawings) {
|
||||
super(EscherRecordType.DGG);
|
||||
this.shapesSaved = numShapes;
|
||||
this.drawingsSaved = numDrawings;
|
||||
this.clusters = new ArrayList();
|
||||
}
|
||||
|
||||
void addCluster(int dgid, int sids) {
|
||||
Cluster c = new Cluster(dgid, sids);
|
||||
this.clusters.add(c);
|
||||
}
|
||||
|
||||
byte[] getData() {
|
||||
this.numClusters = this.clusters.size();
|
||||
this.data = new byte[16 + this.numClusters * 4];
|
||||
IntegerHelper.getFourBytes(1024 + this.shapesSaved, this.data, 0);
|
||||
IntegerHelper.getFourBytes(this.numClusters, this.data, 4);
|
||||
IntegerHelper.getFourBytes(this.shapesSaved, this.data, 8);
|
||||
IntegerHelper.getFourBytes(1, this.data, 12);
|
||||
int pos = 16;
|
||||
for (int i = 0; i < this.numClusters; i++) {
|
||||
Cluster c = this.clusters.get(i);
|
||||
IntegerHelper.getTwoBytes(c.drawingGroupId, this.data, pos);
|
||||
IntegerHelper.getTwoBytes(c.shapeIdsUsed, this.data, pos + 2);
|
||||
pos += 4;
|
||||
}
|
||||
return setHeaderData(this.data);
|
||||
}
|
||||
|
||||
int getShapesSaved() {
|
||||
return this.shapesSaved;
|
||||
}
|
||||
|
||||
int getDrawingsSaved() {
|
||||
return this.drawingsSaved;
|
||||
}
|
||||
|
||||
Cluster getCluster(int i) {
|
||||
return this.clusters.get(i);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
class DggContainer extends EscherContainer {
|
||||
public DggContainer() {
|
||||
super(EscherRecordType.DGG_CONTAINER);
|
||||
}
|
||||
}
|
||||
515
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Drawing.java
Normal file
515
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Drawing.java
Normal file
|
|
@ -0,0 +1,515 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import jxl.CellView;
|
||||
import jxl.Image;
|
||||
import jxl.Sheet;
|
||||
import jxl.common.Assert;
|
||||
import jxl.common.LengthConverter;
|
||||
import jxl.common.LengthUnit;
|
||||
import jxl.common.Logger;
|
||||
|
||||
public class Drawing implements DrawingGroupObject, Image {
|
||||
private static Logger logger = Logger.getLogger(Drawing.class);
|
||||
|
||||
private EscherContainer readSpContainer;
|
||||
|
||||
private MsoDrawingRecord msoDrawingRecord;
|
||||
|
||||
private ObjRecord objRecord;
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
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 ImageAnchorProperties imageAnchorProperties;
|
||||
|
||||
protected static class ImageAnchorProperties {
|
||||
private int value;
|
||||
|
||||
private static ImageAnchorProperties[] o = new ImageAnchorProperties[0];
|
||||
|
||||
ImageAnchorProperties(int v) {
|
||||
this.value = v;
|
||||
ImageAnchorProperties[] oldArray = o;
|
||||
o = new ImageAnchorProperties[oldArray.length + 1];
|
||||
System.arraycopy(oldArray, 0, o, 0, oldArray.length);
|
||||
o[oldArray.length] = this;
|
||||
}
|
||||
|
||||
int getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
static ImageAnchorProperties getImageAnchorProperties(int val) {
|
||||
ImageAnchorProperties iap = Drawing.MOVE_AND_SIZE_WITH_CELLS;
|
||||
int pos = 0;
|
||||
while (pos < o.length) {
|
||||
if (o[pos].getValue() == val) {
|
||||
iap = o[pos];
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
return iap;
|
||||
}
|
||||
}
|
||||
|
||||
public static ImageAnchorProperties MOVE_AND_SIZE_WITH_CELLS = new ImageAnchorProperties(1);
|
||||
|
||||
public static ImageAnchorProperties MOVE_WITH_CELLS = new ImageAnchorProperties(2);
|
||||
|
||||
public static ImageAnchorProperties NO_MOVE_OR_SIZE_WITH_CELLS = new ImageAnchorProperties(3);
|
||||
|
||||
private static final double DEFAULT_FONT_SIZE = 10.0D;
|
||||
|
||||
public Drawing(MsoDrawingRecord mso, ObjRecord obj, DrawingData dd, DrawingGroup dg, Sheet s) {
|
||||
this.drawingGroup = dg;
|
||||
this.msoDrawingRecord = mso;
|
||||
this.drawingData = dd;
|
||||
this.objRecord = obj;
|
||||
this.sheet = s;
|
||||
this.initialized = false;
|
||||
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();
|
||||
}
|
||||
|
||||
protected Drawing(DrawingGroupObject dgo, DrawingGroup dg) {
|
||||
Drawing d = (Drawing)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);
|
||||
}
|
||||
|
||||
public Drawing(double x, double y, double w, double h, File image) {
|
||||
this.imageFile = image;
|
||||
this.initialized = true;
|
||||
this.origin = Origin.WRITE;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.referenceCount = 1;
|
||||
this.imageAnchorProperties = MOVE_WITH_CELLS;
|
||||
this.type = ShapeType.PICTURE_FRAME;
|
||||
}
|
||||
|
||||
public Drawing(double x, double y, double w, double h, byte[] image) {
|
||||
this.imageData = image;
|
||||
this.initialized = true;
|
||||
this.origin = Origin.WRITE;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.referenceCount = 1;
|
||||
this.imageAnchorProperties = MOVE_WITH_CELLS;
|
||||
this.type = ShapeType.PICTURE_FRAME;
|
||||
}
|
||||
|
||||
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.shapeId = sp.getShapeId();
|
||||
this.objectId = this.objRecord.getObjectId();
|
||||
this.type = ShapeType.getType(sp.getShapeType());
|
||||
if (this.type == ShapeType.UNKNOWN)
|
||||
logger.warn("Unknown shape type");
|
||||
Opt opt = (Opt)this.readSpContainer.getChildren()[1];
|
||||
if (opt.getProperty(260) != null)
|
||||
this.blipId = (opt.getProperty(260)).value;
|
||||
if (opt.getProperty(261) != null) {
|
||||
this.imageFile = new File((opt.getProperty(261)).stringValue);
|
||||
} else if (this.type == ShapeType.PICTURE_FRAME) {
|
||||
logger.warn("no filename property for drawing");
|
||||
this.imageFile = new File(Integer.toString(this.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 {
|
||||
this.x = clientAnchor.getX1();
|
||||
this.y = clientAnchor.getY1();
|
||||
this.width = clientAnchor.getX2() - this.x;
|
||||
this.height = clientAnchor.getY2() - this.y;
|
||||
this.imageAnchorProperties = ImageAnchorProperties.getImageAnchorProperties(clientAnchor.getProperties());
|
||||
}
|
||||
if (this.blipId == 0)
|
||||
logger.warn("linked drawings are not supported");
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
public File getImageFile() {
|
||||
return this.imageFile;
|
||||
}
|
||||
|
||||
public String getImageFilePath() {
|
||||
if (this.imageFile == null)
|
||||
return (this.blipId != 0) ? Integer.toString(this.blipId) : "__new__image__";
|
||||
return this.imageFile.getPath();
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public final int getObjectId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.objectId;
|
||||
}
|
||||
|
||||
public int getShapeId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.shapeId;
|
||||
}
|
||||
|
||||
public final int getBlipId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.blipId;
|
||||
}
|
||||
|
||||
public MsoDrawingRecord getMsoDrawingRecord() {
|
||||
return this.msoDrawingRecord;
|
||||
}
|
||||
|
||||
public EscherContainer getSpContainer() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
if (this.origin == Origin.READ)
|
||||
return getReadSpContainer();
|
||||
SpContainer spContainer = new SpContainer();
|
||||
Sp sp = new Sp(this.type, this.shapeId, 2560);
|
||||
spContainer.add(sp);
|
||||
Opt opt = new Opt();
|
||||
opt.addProperty(260, true, false, this.blipId);
|
||||
if (this.type == ShapeType.PICTURE_FRAME) {
|
||||
String filePath = (this.imageFile != null) ? this.imageFile.getPath() : "";
|
||||
opt.addProperty(261, true, true, filePath.length() * 2, filePath);
|
||||
opt.addProperty(447, false, false, 65536);
|
||||
opt.addProperty(959, false, false, 524288);
|
||||
spContainer.add(opt);
|
||||
}
|
||||
ClientAnchor clientAnchor = new ClientAnchor(this.x, this.y, this.x + this.width, this.y + this.height, this.imageAnchorProperties.getValue());
|
||||
spContainer.add(clientAnchor);
|
||||
ClientData clientData = new ClientData();
|
||||
spContainer.add(clientData);
|
||||
return spContainer;
|
||||
}
|
||||
|
||||
public void setDrawingGroup(DrawingGroup dg) {
|
||||
this.drawingGroup = dg;
|
||||
}
|
||||
|
||||
public DrawingGroup getDrawingGroup() {
|
||||
return this.drawingGroup;
|
||||
}
|
||||
|
||||
public Origin getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
public int getReferenceCount() {
|
||||
return this.referenceCount;
|
||||
}
|
||||
|
||||
public void setReferenceCount(int r) {
|
||||
this.referenceCount = r;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public void setWidth(double w) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.width = w;
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public byte[] getImageData() {
|
||||
Assert.verify((this.origin == Origin.READ || this.origin == Origin.READ_WRITE));
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.drawingGroup.getImageData(this.blipId);
|
||||
}
|
||||
|
||||
public byte[] getImageBytes() throws IOException {
|
||||
if (this.origin == Origin.READ || this.origin == Origin.READ_WRITE)
|
||||
return getImageData();
|
||||
Assert.verify((this.origin == Origin.WRITE));
|
||||
if (this.imageFile == null) {
|
||||
Assert.verify((this.imageData != null));
|
||||
return this.imageData;
|
||||
}
|
||||
byte[] data = new byte[(int)this.imageFile.length()];
|
||||
FileInputStream fis = new FileInputStream(this.imageFile);
|
||||
fis.read(data, 0, data.length);
|
||||
fis.close();
|
||||
return data;
|
||||
}
|
||||
|
||||
public ShapeType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void writeAdditionalRecords(jxl.write.biff.File outputFile) throws IOException {
|
||||
if (this.origin == Origin.READ) {
|
||||
outputFile.write(this.objRecord);
|
||||
return;
|
||||
}
|
||||
ObjRecord objrec = new ObjRecord(this.objectId, ObjRecord.PICTURE);
|
||||
outputFile.write(objrec);
|
||||
}
|
||||
|
||||
public void writeTailRecords(jxl.write.biff.File outputFile) throws IOException {}
|
||||
|
||||
public double getColumn() {
|
||||
return getX();
|
||||
}
|
||||
|
||||
public double getRow() {
|
||||
return getY();
|
||||
}
|
||||
|
||||
public boolean isFirst() {
|
||||
return this.msoDrawingRecord.isFirst();
|
||||
}
|
||||
|
||||
public boolean isFormObject() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeRow(int r) {
|
||||
if (this.y > (double)r)
|
||||
setY((double)r);
|
||||
}
|
||||
|
||||
private double getWidthInPoints() {
|
||||
if (this.sheet == null) {
|
||||
logger.warn("calculating image width: sheet is null");
|
||||
return 0.0D;
|
||||
}
|
||||
int firstCol = (int)this.x;
|
||||
int lastCol = (int)Math.ceil(this.x + this.width) - 1;
|
||||
CellView cellView = this.sheet.getColumnView(firstCol);
|
||||
int firstColWidth = cellView.getSize();
|
||||
double firstColImageWidth = (1.0D - (this.x - (double)firstCol)) * (double)firstColWidth;
|
||||
double pointSize = (cellView.getFormat() != null) ? (double)cellView.getFormat().getFont().getPointSize() : 10.0D;
|
||||
double firstColWidthInPoints = firstColImageWidth * 0.59D * pointSize / 256.0D;
|
||||
int lastColWidth = 0;
|
||||
double lastColImageWidth = 0.0D;
|
||||
double lastColWidthInPoints = 0.0D;
|
||||
if (lastCol != firstCol) {
|
||||
cellView = this.sheet.getColumnView(lastCol);
|
||||
lastColWidth = cellView.getSize();
|
||||
lastColImageWidth = (this.x + this.width - (double)lastCol) * (double)lastColWidth;
|
||||
pointSize = (cellView.getFormat() != null) ? (double)cellView.getFormat().getFont().getPointSize() : 10.0D;
|
||||
lastColWidthInPoints = lastColImageWidth * 0.59D * pointSize / 256.0D;
|
||||
}
|
||||
double width = 0.0D;
|
||||
for (int i = 0; i < lastCol - firstCol - 1; i++) {
|
||||
cellView = this.sheet.getColumnView(firstCol + 1 + i);
|
||||
pointSize = (cellView.getFormat() != null) ? (double)cellView.getFormat().getFont().getPointSize() : 10.0D;
|
||||
width += (double)cellView.getSize() * 0.59D * pointSize / 256.0D;
|
||||
}
|
||||
double widthInPoints = width + firstColWidthInPoints + lastColWidthInPoints;
|
||||
return widthInPoints;
|
||||
}
|
||||
|
||||
private double getHeightInPoints() {
|
||||
if (this.sheet == null) {
|
||||
logger.warn("calculating image height: sheet is null");
|
||||
return 0.0D;
|
||||
}
|
||||
int firstRow = (int)this.y;
|
||||
int lastRow = (int)Math.ceil(this.y + this.height) - 1;
|
||||
int firstRowHeight = this.sheet.getRowView(firstRow).getSize();
|
||||
double firstRowImageHeight = (1.0D - (this.y - (double)firstRow)) * (double)firstRowHeight;
|
||||
int lastRowHeight = 0;
|
||||
double lastRowImageHeight = 0.0D;
|
||||
if (lastRow != firstRow) {
|
||||
lastRowHeight = this.sheet.getRowView(lastRow).getSize();
|
||||
lastRowImageHeight = (this.y + this.height - (double)lastRow) * (double)lastRowHeight;
|
||||
}
|
||||
double height = 0.0D;
|
||||
for (int i = 0; i < lastRow - firstRow - 1; i++)
|
||||
height += (double)this.sheet.getRowView(firstRow + 1 + i).getSize();
|
||||
double heightInTwips = height + (double)firstRowHeight + (double)lastRowHeight;
|
||||
double heightInPoints = heightInTwips / 20.0D;
|
||||
return heightInPoints;
|
||||
}
|
||||
|
||||
public double getWidth(LengthUnit unit) {
|
||||
double widthInPoints = getWidthInPoints();
|
||||
return widthInPoints * LengthConverter.getConversionFactor(LengthUnit.POINTS, unit);
|
||||
}
|
||||
|
||||
public double getHeight(LengthUnit unit) {
|
||||
double heightInPoints = getHeightInPoints();
|
||||
return heightInPoints * LengthConverter.getConversionFactor(LengthUnit.POINTS, unit);
|
||||
}
|
||||
|
||||
public int getImageWidth() {
|
||||
return getPngReader().getWidth();
|
||||
}
|
||||
|
||||
public int getImageHeight() {
|
||||
return getPngReader().getHeight();
|
||||
}
|
||||
|
||||
public double getHorizontalResolution(LengthUnit unit) {
|
||||
int res = getPngReader().getHorizontalResolution();
|
||||
return (double)res / LengthConverter.getConversionFactor(LengthUnit.METRES, unit);
|
||||
}
|
||||
|
||||
public double getVerticalResolution(LengthUnit unit) {
|
||||
int res = getPngReader().getVerticalResolution();
|
||||
return (double)res / LengthConverter.getConversionFactor(LengthUnit.METRES, unit);
|
||||
}
|
||||
|
||||
private PNGReader getPngReader() {
|
||||
if (this.pngReader != null)
|
||||
return this.pngReader;
|
||||
byte[] imdata = null;
|
||||
if (this.origin == Origin.READ || this.origin == Origin.READ_WRITE) {
|
||||
imdata = getImageData();
|
||||
} else {
|
||||
try {
|
||||
imdata = getImageBytes();
|
||||
} catch (IOException e) {
|
||||
logger.warn("Could not read image file");
|
||||
imdata = new byte[0];
|
||||
}
|
||||
}
|
||||
this.pngReader = new PNGReader(imdata);
|
||||
this.pngReader.read();
|
||||
return this.pngReader;
|
||||
}
|
||||
|
||||
protected void setImageAnchor(ImageAnchorProperties iap) {
|
||||
this.imageAnchorProperties = iap;
|
||||
if (this.origin == Origin.READ)
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
|
||||
protected ImageAnchorProperties getImageAnchor() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.imageAnchorProperties;
|
||||
}
|
||||
}
|
||||
282
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Drawing2.java
Normal file
282
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Drawing2.java
Normal file
|
|
@ -0,0 +1,282 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import jxl.common.Assert;
|
||||
import jxl.common.Logger;
|
||||
|
||||
public class Drawing2 implements DrawingGroupObject {
|
||||
private static Logger logger = Logger.getLogger(Drawing.class);
|
||||
|
||||
private EscherContainer readSpContainer;
|
||||
|
||||
private MsoDrawingRecord msoDrawingRecord;
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
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;
|
||||
|
||||
public Drawing2(MsoDrawingRecord mso, DrawingData dd, DrawingGroup dg) {
|
||||
this.drawingGroup = dg;
|
||||
this.msoDrawingRecord = mso;
|
||||
this.drawingData = dd;
|
||||
this.initialized = false;
|
||||
this.origin = Origin.READ;
|
||||
this.drawingData.addRawData(this.msoDrawingRecord.getData());
|
||||
this.drawingGroup.addDrawing(this);
|
||||
Assert.verify((mso != null));
|
||||
initialize();
|
||||
}
|
||||
|
||||
protected Drawing2(DrawingGroupObject dgo, DrawingGroup dg) {
|
||||
Drawing2 d = (Drawing2)dgo;
|
||||
Assert.verify((d.origin == Origin.READ));
|
||||
this.msoDrawingRecord = d.msoDrawingRecord;
|
||||
this.initialized = false;
|
||||
this.origin = Origin.READ;
|
||||
this.drawingData = d.drawingData;
|
||||
this.drawingGroup = dg;
|
||||
this.drawingNumber = d.drawingNumber;
|
||||
this.drawingGroup.addDrawing(this);
|
||||
}
|
||||
|
||||
public Drawing2(double x, double y, double w, double h, File image) {
|
||||
this.imageFile = image;
|
||||
this.initialized = true;
|
||||
this.origin = Origin.WRITE;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.referenceCount = 1;
|
||||
this.type = ShapeType.PICTURE_FRAME;
|
||||
}
|
||||
|
||||
public Drawing2(double x, double y, double w, double h, byte[] image) {
|
||||
this.imageData = image;
|
||||
this.initialized = true;
|
||||
this.origin = Origin.WRITE;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.referenceCount = 1;
|
||||
this.type = ShapeType.PICTURE_FRAME;
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public final int getObjectId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.objectId;
|
||||
}
|
||||
|
||||
public int getShapeId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.shapeId;
|
||||
}
|
||||
|
||||
public final int getBlipId() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.blipId;
|
||||
}
|
||||
|
||||
public MsoDrawingRecord getMsoDrawingRecord() {
|
||||
return this.msoDrawingRecord;
|
||||
}
|
||||
|
||||
public EscherContainer getSpContainer() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
Assert.verify((this.origin == Origin.READ));
|
||||
return getReadSpContainer();
|
||||
}
|
||||
|
||||
public void setDrawingGroup(DrawingGroup dg) {
|
||||
this.drawingGroup = dg;
|
||||
}
|
||||
|
||||
public DrawingGroup getDrawingGroup() {
|
||||
return this.drawingGroup;
|
||||
}
|
||||
|
||||
public Origin getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
public int getReferenceCount() {
|
||||
return this.referenceCount;
|
||||
}
|
||||
|
||||
public void setReferenceCount(int r) {
|
||||
this.referenceCount = r;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getWidth() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public void setWidth(double w) {
|
||||
if (this.origin == Origin.READ) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
this.origin = Origin.READ_WRITE;
|
||||
}
|
||||
this.width = w;
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public byte[] getImageData() {
|
||||
Assert.verify(false);
|
||||
Assert.verify((this.origin == Origin.READ || this.origin == Origin.READ_WRITE));
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
return this.drawingGroup.getImageData(this.blipId);
|
||||
}
|
||||
|
||||
public byte[] getImageBytes() throws IOException {
|
||||
Assert.verify(false);
|
||||
if (this.origin == Origin.READ || this.origin == Origin.READ_WRITE)
|
||||
return getImageData();
|
||||
Assert.verify((this.origin == Origin.WRITE));
|
||||
if (this.imageFile == null) {
|
||||
Assert.verify((this.imageData != null));
|
||||
return this.imageData;
|
||||
}
|
||||
byte[] data = new byte[(int)this.imageFile.length()];
|
||||
FileInputStream fis = new FileInputStream(this.imageFile);
|
||||
fis.read(data, 0, data.length);
|
||||
fis.close();
|
||||
return data;
|
||||
}
|
||||
|
||||
public ShapeType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public void writeAdditionalRecords(jxl.write.biff.File outputFile) throws IOException {}
|
||||
|
||||
public void writeTailRecords(jxl.write.biff.File outputFile) throws IOException {}
|
||||
|
||||
public double getColumn() {
|
||||
return getX();
|
||||
}
|
||||
|
||||
public double getRow() {
|
||||
return getY();
|
||||
}
|
||||
|
||||
public boolean isFirst() {
|
||||
return this.msoDrawingRecord.isFirst();
|
||||
}
|
||||
|
||||
public boolean isFormObject() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeRow(int r) {
|
||||
if (this.y > (double)r)
|
||||
setY((double)r);
|
||||
}
|
||||
|
||||
public String getImageFilePath() {
|
||||
Assert.verify(false);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
95
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/DrawingData.java
Normal file
95
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/DrawingData.java
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import jxl.common.Assert;
|
||||
import jxl.common.Logger;
|
||||
|
||||
public class DrawingData implements EscherStream {
|
||||
private static Logger logger = Logger.getLogger(DrawingData.class);
|
||||
|
||||
private int numDrawings = 0;
|
||||
|
||||
private byte[] drawingData = null;
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
private EscherRecord[] spContainers;
|
||||
|
||||
private void initialize() {
|
||||
EscherRecordData er = new EscherRecordData(this, 0);
|
||||
Assert.verify(er.isContainer());
|
||||
EscherContainer dgContainer = new EscherContainer(er);
|
||||
EscherRecord[] children = dgContainer.getChildren();
|
||||
children = dgContainer.getChildren();
|
||||
EscherContainer spgrContainer = null;
|
||||
for (int i = 0; i < children.length && spgrContainer == null; i++) {
|
||||
EscherRecord child = children[i];
|
||||
if (child.getType() == EscherRecordType.SPGR_CONTAINER)
|
||||
spgrContainer = (EscherContainer)child;
|
||||
}
|
||||
Assert.verify((spgrContainer != null));
|
||||
EscherRecord[] spgrChildren = spgrContainer.getChildren();
|
||||
boolean nestedContainers = false;
|
||||
for (int j = 0; j < spgrChildren.length && !nestedContainers; j++) {
|
||||
if (spgrChildren[j].getType() == EscherRecordType.SPGR_CONTAINER)
|
||||
nestedContainers = true;
|
||||
}
|
||||
if (!nestedContainers) {
|
||||
this.spContainers = spgrChildren;
|
||||
} else {
|
||||
ArrayList sps = new ArrayList();
|
||||
getSpContainers(spgrContainer, sps);
|
||||
this.spContainers = new EscherRecord[sps.size()];
|
||||
this.spContainers = (EscherRecord[])sps.toArray(this.spContainers);
|
||||
}
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
private void getSpContainers(EscherContainer spgrContainer, ArrayList sps) {
|
||||
EscherRecord[] spgrChildren = spgrContainer.getChildren();
|
||||
for (int i = 0; i < spgrChildren.length; i++) {
|
||||
if (spgrChildren[i].getType() == EscherRecordType.SP_CONTAINER) {
|
||||
sps.add(spgrChildren[i]);
|
||||
} else if (spgrChildren[i].getType() == EscherRecordType.SPGR_CONTAINER) {
|
||||
getSpContainers((EscherContainer)spgrChildren[i], sps);
|
||||
} else {
|
||||
logger.warn("Spgr Containers contains a record other than Sp/Spgr containers");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addData(byte[] data) {
|
||||
addRawData(data);
|
||||
this.numDrawings++;
|
||||
}
|
||||
|
||||
public void addRawData(byte[] data) {
|
||||
if (this.drawingData == null) {
|
||||
this.drawingData = data;
|
||||
return;
|
||||
}
|
||||
byte[] newArray = new byte[this.drawingData.length + data.length];
|
||||
System.arraycopy(this.drawingData, 0, newArray, 0, this.drawingData.length);
|
||||
System.arraycopy(data, 0, newArray, this.drawingData.length, data.length);
|
||||
this.drawingData = newArray;
|
||||
this.initialized = false;
|
||||
}
|
||||
|
||||
final int getNumDrawings() {
|
||||
return this.numDrawings;
|
||||
}
|
||||
|
||||
EscherContainer getSpContainer(int drawingNum) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
if (drawingNum + 1 >= this.spContainers.length)
|
||||
throw new DrawingDataException();
|
||||
EscherContainer spContainer = (EscherContainer)this.spContainers[drawingNum + 1];
|
||||
Assert.verify((spContainer != null));
|
||||
return spContainer;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return this.drawingData;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
public class DrawingDataException extends RuntimeException {
|
||||
private static String message = "Drawing number exceeds available SpContainers";
|
||||
|
||||
DrawingDataException() {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
274
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/DrawingGroup.java
Normal file
274
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/DrawingGroup.java
Normal file
|
|
@ -0,0 +1,274 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import jxl.common.Assert;
|
||||
import jxl.common.Logger;
|
||||
import jxl.read.biff.Record;
|
||||
import jxl.write.biff.File;
|
||||
|
||||
public class DrawingGroup implements EscherStream {
|
||||
private static Logger logger = Logger.getLogger(DrawingGroup.class);
|
||||
|
||||
private byte[] drawingData;
|
||||
|
||||
private EscherContainer escherData;
|
||||
|
||||
private BStoreContainer bstoreContainer;
|
||||
|
||||
private boolean initialized;
|
||||
|
||||
private ArrayList drawings;
|
||||
|
||||
private int numBlips;
|
||||
|
||||
private int numCharts;
|
||||
|
||||
private int drawingGroupId;
|
||||
|
||||
private boolean drawingsOmitted;
|
||||
|
||||
private Origin origin;
|
||||
|
||||
private HashMap imageFiles;
|
||||
|
||||
private int maxObjectId;
|
||||
|
||||
private int maxShapeId;
|
||||
|
||||
public DrawingGroup(Origin o) {
|
||||
this.origin = o;
|
||||
this.initialized = (o == Origin.WRITE);
|
||||
this.drawings = new ArrayList();
|
||||
this.imageFiles = new HashMap();
|
||||
this.drawingsOmitted = false;
|
||||
this.maxObjectId = 1;
|
||||
this.maxShapeId = 1024;
|
||||
}
|
||||
|
||||
public DrawingGroup(DrawingGroup dg) {
|
||||
this.drawingData = dg.drawingData;
|
||||
this.escherData = dg.escherData;
|
||||
this.bstoreContainer = dg.bstoreContainer;
|
||||
this.initialized = dg.initialized;
|
||||
this.drawingData = dg.drawingData;
|
||||
this.escherData = dg.escherData;
|
||||
this.bstoreContainer = dg.bstoreContainer;
|
||||
this.numBlips = dg.numBlips;
|
||||
this.numCharts = dg.numCharts;
|
||||
this.drawingGroupId = dg.drawingGroupId;
|
||||
this.drawingsOmitted = dg.drawingsOmitted;
|
||||
this.origin = dg.origin;
|
||||
this.imageFiles = (HashMap)dg.imageFiles.clone();
|
||||
this.maxObjectId = dg.maxObjectId;
|
||||
this.maxShapeId = dg.maxShapeId;
|
||||
this.drawings = new ArrayList();
|
||||
}
|
||||
|
||||
public void add(MsoDrawingGroupRecord mso) {
|
||||
addData(mso.getData());
|
||||
}
|
||||
|
||||
public void add(Record cont) {
|
||||
addData(cont.getData());
|
||||
}
|
||||
|
||||
private void addData(byte[] msodata) {
|
||||
if (this.drawingData == null) {
|
||||
this.drawingData = new byte[msodata.length];
|
||||
System.arraycopy(msodata, 0, this.drawingData, 0, msodata.length);
|
||||
return;
|
||||
}
|
||||
byte[] newdata = new byte[this.drawingData.length + msodata.length];
|
||||
System.arraycopy(this.drawingData, 0, newdata, 0, this.drawingData.length);
|
||||
System.arraycopy(msodata, 0, newdata, this.drawingData.length, msodata.length);
|
||||
this.drawingData = newdata;
|
||||
}
|
||||
|
||||
final void addDrawing(DrawingGroupObject d) {
|
||||
this.drawings.add(d);
|
||||
this.maxObjectId = Math.max(this.maxObjectId, d.getObjectId());
|
||||
this.maxShapeId = Math.max(this.maxShapeId, d.getShapeId());
|
||||
}
|
||||
|
||||
public void add(Chart c) {
|
||||
this.numCharts++;
|
||||
}
|
||||
|
||||
public void add(DrawingGroupObject d) {
|
||||
if (this.origin == Origin.READ) {
|
||||
this.origin = Origin.READ_WRITE;
|
||||
BStoreContainer bsc = getBStoreContainer();
|
||||
Dgg dgg = (Dgg)this.escherData.getChildren()[0];
|
||||
this.drawingGroupId = (dgg.getCluster(1)).drawingGroupId - this.numBlips - 1;
|
||||
this.numBlips = (bsc != null) ? bsc.getNumBlips() : 0;
|
||||
if (bsc != null)
|
||||
Assert.verify((this.numBlips == bsc.getNumBlips()));
|
||||
}
|
||||
if (!(d instanceof Drawing)) {
|
||||
this.maxObjectId++;
|
||||
this.maxShapeId++;
|
||||
d.setDrawingGroup(this);
|
||||
d.setObjectId(this.maxObjectId, this.numBlips + 1, this.maxShapeId);
|
||||
if (this.drawings.size() > this.maxObjectId)
|
||||
logger.warn("drawings length " + this.drawings.size() + " exceeds the max object id " + this.maxObjectId);
|
||||
return;
|
||||
}
|
||||
Drawing drawing = (Drawing)d;
|
||||
Drawing refImage = (Drawing)this.imageFiles.get(d.getImageFilePath());
|
||||
if (refImage == null) {
|
||||
this.maxObjectId++;
|
||||
this.maxShapeId++;
|
||||
this.drawings.add(drawing);
|
||||
drawing.setDrawingGroup(this);
|
||||
drawing.setObjectId(this.maxObjectId, this.numBlips + 1, this.maxShapeId);
|
||||
this.numBlips++;
|
||||
this.imageFiles.put(drawing.getImageFilePath(), drawing);
|
||||
} else {
|
||||
refImage.setReferenceCount(refImage.getReferenceCount() + 1);
|
||||
drawing.setDrawingGroup(this);
|
||||
drawing.setObjectId(refImage.getObjectId(), refImage.getBlipId(), refImage.getShapeId());
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(DrawingGroupObject d) {
|
||||
if (getBStoreContainer() == null)
|
||||
return;
|
||||
if (this.origin == Origin.READ) {
|
||||
this.origin = Origin.READ_WRITE;
|
||||
this.numBlips = getBStoreContainer().getNumBlips();
|
||||
Dgg dgg = (Dgg)this.escherData.getChildren()[0];
|
||||
this.drawingGroupId = (dgg.getCluster(1)).drawingGroupId - this.numBlips - 1;
|
||||
}
|
||||
EscherRecord[] children = getBStoreContainer().getChildren();
|
||||
BlipStoreEntry bse = (BlipStoreEntry)children[d.getBlipId() - 1];
|
||||
bse.dereference();
|
||||
if (bse.getReferenceCount() == 0) {
|
||||
getBStoreContainer().remove(bse);
|
||||
for (DrawingGroupObject drawing : (Iterable<DrawingGroupObject>)this.drawings) {
|
||||
if (drawing.getBlipId() > d.getBlipId())
|
||||
drawing.setObjectId(drawing.getObjectId(), drawing.getBlipId() - 1, drawing.getShapeId());
|
||||
}
|
||||
this.numBlips--;
|
||||
}
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
EscherRecordData er = new EscherRecordData(this, 0);
|
||||
Assert.verify(er.isContainer());
|
||||
this.escherData = new EscherContainer(er);
|
||||
Assert.verify((this.escherData.getLength() == this.drawingData.length));
|
||||
Assert.verify((this.escherData.getType() == EscherRecordType.DGG_CONTAINER));
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
private BStoreContainer getBStoreContainer() {
|
||||
if (this.bstoreContainer == null) {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
EscherRecord[] children = this.escherData.getChildren();
|
||||
if (children.length > 1 && children[1].getType() == EscherRecordType.BSTORE_CONTAINER)
|
||||
this.bstoreContainer = (BStoreContainer)children[1];
|
||||
}
|
||||
return this.bstoreContainer;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return this.drawingData;
|
||||
}
|
||||
|
||||
public void write(File outputFile) throws IOException {
|
||||
if (this.origin == Origin.WRITE) {
|
||||
DggContainer dggContainer = new DggContainer();
|
||||
Dgg dgg = new Dgg(this.numBlips + this.numCharts + 1, this.numBlips);
|
||||
dgg.addCluster(1, 0);
|
||||
dgg.addCluster(this.numBlips + 1, 0);
|
||||
dggContainer.add(dgg);
|
||||
int drawingsAdded = 0;
|
||||
BStoreContainer bstoreCont = new BStoreContainer();
|
||||
for (Object o : (Iterable<Object>)this.drawings) {
|
||||
if (o instanceof Drawing) {
|
||||
Drawing d = (Drawing)o;
|
||||
BlipStoreEntry bse = new BlipStoreEntry(d);
|
||||
bstoreCont.add(bse);
|
||||
drawingsAdded++;
|
||||
}
|
||||
}
|
||||
if (drawingsAdded > 0) {
|
||||
bstoreCont.setNumBlips(drawingsAdded);
|
||||
dggContainer.add(bstoreCont);
|
||||
}
|
||||
Opt opt = new Opt();
|
||||
dggContainer.add(opt);
|
||||
SplitMenuColors splitMenuColors = new SplitMenuColors();
|
||||
dggContainer.add(splitMenuColors);
|
||||
this.drawingData = dggContainer.getData();
|
||||
} else if (this.origin == Origin.READ_WRITE) {
|
||||
DggContainer dggContainer = new DggContainer();
|
||||
Dgg dgg = new Dgg(this.numBlips + this.numCharts + 1, this.numBlips);
|
||||
dgg.addCluster(1, 0);
|
||||
dgg.addCluster(this.drawingGroupId + this.numBlips + 1, 0);
|
||||
dggContainer.add(dgg);
|
||||
BStoreContainer bstoreCont = new BStoreContainer();
|
||||
bstoreCont.setNumBlips(this.numBlips);
|
||||
BStoreContainer readBStoreContainer = getBStoreContainer();
|
||||
if (readBStoreContainer != null) {
|
||||
EscherRecord[] children = readBStoreContainer.getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
BlipStoreEntry bse = (BlipStoreEntry)children[i];
|
||||
bstoreCont.add(bse);
|
||||
}
|
||||
}
|
||||
for (DrawingGroupObject dgo : (Iterable<DrawingGroupObject>)this.drawings) {
|
||||
if (dgo instanceof Drawing) {
|
||||
Drawing d = (Drawing)dgo;
|
||||
if (d.getOrigin() == Origin.WRITE) {
|
||||
BlipStoreEntry bse = new BlipStoreEntry(d);
|
||||
bstoreCont.add(bse);
|
||||
}
|
||||
}
|
||||
}
|
||||
dggContainer.add(bstoreCont);
|
||||
Opt opt = new Opt();
|
||||
opt.addProperty(191, false, false, 524296);
|
||||
opt.addProperty(385, false, false, 134217737);
|
||||
opt.addProperty(448, false, false, 134217792);
|
||||
dggContainer.add(opt);
|
||||
SplitMenuColors splitMenuColors = new SplitMenuColors();
|
||||
dggContainer.add(splitMenuColors);
|
||||
this.drawingData = dggContainer.getData();
|
||||
}
|
||||
MsoDrawingGroupRecord msodg = new MsoDrawingGroupRecord(this.drawingData);
|
||||
outputFile.write(msodg);
|
||||
}
|
||||
|
||||
final int getNumberOfBlips() {
|
||||
return this.numBlips;
|
||||
}
|
||||
|
||||
byte[] getImageData(int blipId) {
|
||||
this.numBlips = getBStoreContainer().getNumBlips();
|
||||
Assert.verify((blipId <= this.numBlips));
|
||||
Assert.verify((this.origin == Origin.READ || this.origin == Origin.READ_WRITE));
|
||||
EscherRecord[] children = getBStoreContainer().getChildren();
|
||||
BlipStoreEntry bse = (BlipStoreEntry)children[blipId - 1];
|
||||
return bse.getImageData();
|
||||
}
|
||||
|
||||
public void setDrawingsOmitted(MsoDrawingRecord mso, ObjRecord obj) {
|
||||
this.drawingsOmitted = true;
|
||||
if (obj != null)
|
||||
this.maxObjectId = Math.max(this.maxObjectId, obj.getObjectId());
|
||||
}
|
||||
|
||||
public boolean hasDrawingsOmitted() {
|
||||
return this.drawingsOmitted;
|
||||
}
|
||||
|
||||
public void updateData(DrawingGroup dg) {
|
||||
this.drawingsOmitted = dg.drawingsOmitted;
|
||||
this.maxObjectId = dg.maxObjectId;
|
||||
this.maxShapeId = dg.maxShapeId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.io.IOException;
|
||||
import jxl.write.biff.File;
|
||||
|
||||
public interface DrawingGroupObject {
|
||||
void setObjectId(int paramInt1, int paramInt2, int paramInt3);
|
||||
|
||||
int getObjectId();
|
||||
|
||||
int getBlipId();
|
||||
|
||||
int getShapeId();
|
||||
|
||||
MsoDrawingRecord getMsoDrawingRecord();
|
||||
|
||||
EscherContainer getSpContainer();
|
||||
|
||||
void setDrawingGroup(DrawingGroup paramDrawingGroup);
|
||||
|
||||
DrawingGroup getDrawingGroup();
|
||||
|
||||
Origin getOrigin();
|
||||
|
||||
int getReferenceCount();
|
||||
|
||||
void setReferenceCount(int paramInt);
|
||||
|
||||
double getX();
|
||||
|
||||
void setX(double paramDouble);
|
||||
|
||||
double getY();
|
||||
|
||||
void setY(double paramDouble);
|
||||
|
||||
double getWidth();
|
||||
|
||||
void setWidth(double paramDouble);
|
||||
|
||||
double getHeight();
|
||||
|
||||
void setHeight(double paramDouble);
|
||||
|
||||
ShapeType getType();
|
||||
|
||||
byte[] getImageData();
|
||||
|
||||
byte[] getImageBytes() throws IOException;
|
||||
|
||||
String getImageFilePath();
|
||||
|
||||
void writeAdditionalRecords(File paramFile) throws IOException;
|
||||
|
||||
void writeTailRecords(File paramFile) throws IOException;
|
||||
|
||||
boolean isFirst();
|
||||
|
||||
boolean isFormObject();
|
||||
}
|
||||
20
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/EscherAtom.java
Normal file
20
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/EscherAtom.java
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.common.Logger;
|
||||
|
||||
class EscherAtom extends EscherRecord {
|
||||
private static Logger logger = Logger.getLogger(EscherAtom.class);
|
||||
|
||||
public EscherAtom(EscherRecordData erd) {
|
||||
super(erd);
|
||||
}
|
||||
|
||||
protected EscherAtom(EscherRecordType type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
byte[] getData() {
|
||||
logger.warn("escher atom getData called on object of type " + getClass().getName() + " code " + Integer.toString(getType().getValue(), 16));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import jxl.common.Logger;
|
||||
|
||||
class EscherContainer extends EscherRecord {
|
||||
private static Logger logger = Logger.getLogger(EscherContainer.class);
|
||||
|
||||
private boolean initialized;
|
||||
|
||||
private ArrayList children;
|
||||
|
||||
public EscherContainer(EscherRecordData erd) {
|
||||
super(erd);
|
||||
this.initialized = false;
|
||||
this.children = new ArrayList();
|
||||
}
|
||||
|
||||
protected EscherContainer(EscherRecordType type) {
|
||||
super(type);
|
||||
setContainer(true);
|
||||
this.children = new ArrayList();
|
||||
}
|
||||
|
||||
public EscherRecord[] getChildren() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
Object[] ca = this.children.toArray(new EscherRecord[this.children.size()]);
|
||||
return (EscherRecord[])ca;
|
||||
}
|
||||
|
||||
public void add(EscherRecord child) {
|
||||
this.children.add(child);
|
||||
}
|
||||
|
||||
public void remove(EscherRecord child) {
|
||||
boolean result = this.children.remove(child);
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
int curpos = getPos() + 8;
|
||||
int endpos = Math.min(getPos() + getLength(), getStreamLength());
|
||||
EscherRecord newRecord = null;
|
||||
while (curpos < endpos) {
|
||||
EscherRecordData erd = new EscherRecordData(getEscherStream(), curpos);
|
||||
EscherRecordType type = erd.getType();
|
||||
if (type == EscherRecordType.DGG) {
|
||||
newRecord = new Dgg(erd);
|
||||
} else if (type == EscherRecordType.DG) {
|
||||
newRecord = new Dg(erd);
|
||||
} else if (type == EscherRecordType.BSTORE_CONTAINER) {
|
||||
newRecord = new BStoreContainer(erd);
|
||||
} else if (type == EscherRecordType.SPGR_CONTAINER) {
|
||||
newRecord = new SpgrContainer(erd);
|
||||
} else if (type == EscherRecordType.SP_CONTAINER) {
|
||||
newRecord = new SpContainer(erd);
|
||||
} else if (type == EscherRecordType.SPGR) {
|
||||
newRecord = new Spgr(erd);
|
||||
} else if (type == EscherRecordType.SP) {
|
||||
newRecord = new Sp(erd);
|
||||
} else if (type == EscherRecordType.CLIENT_ANCHOR) {
|
||||
newRecord = new ClientAnchor(erd);
|
||||
} else if (type == EscherRecordType.CLIENT_DATA) {
|
||||
newRecord = new ClientData(erd);
|
||||
} else if (type == EscherRecordType.BSE) {
|
||||
newRecord = new BlipStoreEntry(erd);
|
||||
} else if (type == EscherRecordType.OPT) {
|
||||
newRecord = new Opt(erd);
|
||||
} else if (type == EscherRecordType.SPLIT_MENU_COLORS) {
|
||||
newRecord = new SplitMenuColors(erd);
|
||||
} else if (type == EscherRecordType.CLIENT_TEXT_BOX) {
|
||||
newRecord = new ClientTextBox(erd);
|
||||
} else {
|
||||
newRecord = new EscherAtom(erd);
|
||||
}
|
||||
this.children.add(newRecord);
|
||||
curpos += newRecord.getLength();
|
||||
}
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
byte[] getData() {
|
||||
if (!this.initialized)
|
||||
initialize();
|
||||
byte[] data = new byte[0];
|
||||
for (EscherRecord er : (Iterable<EscherRecord>)this.children) {
|
||||
byte[] childData = er.getData();
|
||||
if (childData != null) {
|
||||
byte[] newData = new byte[data.length + childData.length];
|
||||
System.arraycopy(data, 0, newData, 0, data.length);
|
||||
System.arraycopy(childData, 0, newData, data.length, childData.length);
|
||||
data = newData;
|
||||
}
|
||||
}
|
||||
return setHeaderData(data);
|
||||
}
|
||||
}
|
||||
105
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/EscherDisplay.java
Normal file
105
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/EscherDisplay.java
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class EscherDisplay {
|
||||
private EscherStream stream;
|
||||
|
||||
private BufferedWriter writer;
|
||||
|
||||
public EscherDisplay(EscherStream s, BufferedWriter bw) {
|
||||
this.stream = s;
|
||||
this.writer = bw;
|
||||
}
|
||||
|
||||
public void display() throws IOException {
|
||||
EscherRecordData er = new EscherRecordData(this.stream, 0);
|
||||
EscherContainer ec = new EscherContainer(er);
|
||||
displayContainer(ec, 0);
|
||||
}
|
||||
|
||||
private void displayContainer(EscherContainer ec, int level) throws IOException {
|
||||
displayRecord(ec, level);
|
||||
level++;
|
||||
EscherRecord[] children = ec.getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
EscherRecord er = children[i];
|
||||
if (er.getEscherData().isContainer()) {
|
||||
displayContainer((EscherContainer)er, level);
|
||||
} else {
|
||||
displayRecord(er, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void displayRecord(EscherRecord er, int level) throws IOException {
|
||||
indent(level);
|
||||
EscherRecordType type = er.getType();
|
||||
this.writer.write(Integer.toString(type.getValue(), 16));
|
||||
this.writer.write(" - ");
|
||||
if (type == EscherRecordType.DGG_CONTAINER) {
|
||||
this.writer.write("Dgg Container");
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.BSTORE_CONTAINER) {
|
||||
this.writer.write("BStore Container");
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.DG_CONTAINER) {
|
||||
this.writer.write("Dg Container");
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.SPGR_CONTAINER) {
|
||||
this.writer.write("Spgr Container");
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.SP_CONTAINER) {
|
||||
this.writer.write("Sp Container");
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.DGG) {
|
||||
this.writer.write("Dgg");
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.BSE) {
|
||||
this.writer.write("Bse");
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.DG) {
|
||||
Dg dg = new Dg(er.getEscherData());
|
||||
this.writer.write("Dg: drawing id " + dg.getDrawingId() + " shape count " + dg.getShapeCount());
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.SPGR) {
|
||||
this.writer.write("Spgr");
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.SP) {
|
||||
Sp sp = new Sp(er.getEscherData());
|
||||
this.writer.write("Sp: shape id " + sp.getShapeId() + " shape type " + sp.getShapeType());
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.OPT) {
|
||||
Opt opt = new Opt(er.getEscherData());
|
||||
Opt.Property p260 = opt.getProperty(260);
|
||||
Opt.Property p261 = opt.getProperty(261);
|
||||
this.writer.write("Opt (value, stringValue): ");
|
||||
if (p260 != null)
|
||||
this.writer.write("260: " + p260.value + ", " + p260.stringValue + ";");
|
||||
if (p261 != null)
|
||||
this.writer.write("261: " + p261.value + ", " + p261.stringValue + ";");
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.CLIENT_ANCHOR) {
|
||||
this.writer.write("Client Anchor");
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.CLIENT_DATA) {
|
||||
this.writer.write("Client Data");
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.CLIENT_TEXT_BOX) {
|
||||
this.writer.write("Client Text Box");
|
||||
this.writer.newLine();
|
||||
} else if (type == EscherRecordType.SPLIT_MENU_COLORS) {
|
||||
this.writer.write("Split Menu Colors");
|
||||
this.writer.newLine();
|
||||
} else {
|
||||
this.writer.write("???");
|
||||
this.writer.newLine();
|
||||
}
|
||||
}
|
||||
|
||||
private void indent(int level) throws IOException {
|
||||
for (int i = 0; i < level * 2; i++)
|
||||
this.writer.write(32);
|
||||
}
|
||||
}
|
||||
69
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/EscherRecord.java
Normal file
69
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/EscherRecord.java
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.common.Logger;
|
||||
|
||||
abstract class EscherRecord {
|
||||
private static Logger logger = Logger.getLogger(EscherRecord.class);
|
||||
|
||||
private EscherRecordData data;
|
||||
|
||||
protected static final int HEADER_LENGTH = 8;
|
||||
|
||||
protected EscherRecord(EscherRecordData erd) {
|
||||
this.data = erd;
|
||||
}
|
||||
|
||||
protected EscherRecord(EscherRecordType type) {
|
||||
this.data = new EscherRecordData(type);
|
||||
}
|
||||
|
||||
protected void setContainer(boolean cont) {
|
||||
this.data.setContainer(cont);
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return this.data.getLength() + 8;
|
||||
}
|
||||
|
||||
protected final EscherStream getEscherStream() {
|
||||
return this.data.getEscherStream();
|
||||
}
|
||||
|
||||
protected final int getPos() {
|
||||
return this.data.getPos();
|
||||
}
|
||||
|
||||
protected final int getInstance() {
|
||||
return this.data.getInstance();
|
||||
}
|
||||
|
||||
protected final void setInstance(int i) {
|
||||
this.data.setInstance(i);
|
||||
}
|
||||
|
||||
protected final void setVersion(int v) {
|
||||
this.data.setVersion(v);
|
||||
}
|
||||
|
||||
public EscherRecordType getType() {
|
||||
return this.data.getType();
|
||||
}
|
||||
|
||||
abstract byte[] getData();
|
||||
|
||||
final byte[] setHeaderData(byte[] d) {
|
||||
return this.data.setHeaderData(d);
|
||||
}
|
||||
|
||||
byte[] getBytes() {
|
||||
return this.data.getBytes();
|
||||
}
|
||||
|
||||
protected int getStreamLength() {
|
||||
return this.data.getStreamLength();
|
||||
}
|
||||
|
||||
protected EscherRecordData getEscherData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
121
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/EscherRecordData.java
Normal file
121
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/EscherRecordData.java
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.biff.IntegerHelper;
|
||||
import jxl.common.Logger;
|
||||
|
||||
final class EscherRecordData {
|
||||
private static Logger logger = Logger.getLogger(EscherRecordData.class);
|
||||
|
||||
private int pos;
|
||||
|
||||
private int instance;
|
||||
|
||||
private int version;
|
||||
|
||||
private int recordId;
|
||||
|
||||
private int length;
|
||||
|
||||
private int streamLength;
|
||||
|
||||
private boolean container;
|
||||
|
||||
private EscherRecordType type;
|
||||
|
||||
private EscherStream escherStream;
|
||||
|
||||
public EscherRecordData(EscherStream dg, int p) {
|
||||
this.escherStream = dg;
|
||||
this.pos = p;
|
||||
byte[] data = this.escherStream.getData();
|
||||
this.streamLength = data.length;
|
||||
int value = IntegerHelper.getInt(data[this.pos], data[this.pos + 1]);
|
||||
this.instance = (value & 0xFFF0) >> 4;
|
||||
this.version = value & 0xF;
|
||||
this.recordId = IntegerHelper.getInt(data[this.pos + 2], data[this.pos + 3]);
|
||||
this.length = IntegerHelper.getInt(data[this.pos + 4], data[this.pos + 5], data[this.pos + 6], data[this.pos + 7]);
|
||||
if (this.version == 15) {
|
||||
this.container = true;
|
||||
} else {
|
||||
this.container = false;
|
||||
}
|
||||
}
|
||||
|
||||
public EscherRecordData(EscherRecordType t) {
|
||||
this.type = t;
|
||||
this.recordId = this.type.getValue();
|
||||
}
|
||||
|
||||
public boolean isContainer() {
|
||||
return this.container;
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public int getRecordId() {
|
||||
return this.recordId;
|
||||
}
|
||||
|
||||
EscherStream getDrawingGroup() {
|
||||
return this.escherStream;
|
||||
}
|
||||
|
||||
int getPos() {
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
EscherRecordType getType() {
|
||||
if (this.type == null)
|
||||
this.type = EscherRecordType.getType(this.recordId);
|
||||
return this.type;
|
||||
}
|
||||
|
||||
int getInstance() {
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
void setContainer(boolean c) {
|
||||
this.container = c;
|
||||
}
|
||||
|
||||
void setInstance(int inst) {
|
||||
this.instance = inst;
|
||||
}
|
||||
|
||||
void setLength(int l) {
|
||||
this.length = l;
|
||||
}
|
||||
|
||||
void setVersion(int v) {
|
||||
this.version = v;
|
||||
}
|
||||
|
||||
byte[] setHeaderData(byte[] d) {
|
||||
byte[] data = new byte[d.length + 8];
|
||||
System.arraycopy(d, 0, data, 8, d.length);
|
||||
if (this.container)
|
||||
this.version = 15;
|
||||
int value = this.instance << 4;
|
||||
value |= this.version;
|
||||
IntegerHelper.getTwoBytes(value, data, 0);
|
||||
IntegerHelper.getTwoBytes(this.recordId, data, 2);
|
||||
IntegerHelper.getFourBytes(d.length, data, 4);
|
||||
return data;
|
||||
}
|
||||
|
||||
EscherStream getEscherStream() {
|
||||
return this.escherStream;
|
||||
}
|
||||
|
||||
byte[] getBytes() {
|
||||
byte[] d = new byte[this.length];
|
||||
System.arraycopy(this.escherStream.getData(), this.pos + 8, d, 0, this.length);
|
||||
return d;
|
||||
}
|
||||
|
||||
int getStreamLength() {
|
||||
return this.streamLength;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
final class EscherRecordType {
|
||||
private int value;
|
||||
|
||||
private static EscherRecordType[] types = new EscherRecordType[0];
|
||||
|
||||
private EscherRecordType(int val) {
|
||||
this.value = val;
|
||||
EscherRecordType[] newtypes = new EscherRecordType[types.length + 1];
|
||||
System.arraycopy(types, 0, newtypes, 0, types.length);
|
||||
newtypes[types.length] = this;
|
||||
types = newtypes;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static EscherRecordType getType(int val) {
|
||||
EscherRecordType type = UNKNOWN;
|
||||
for (int i = 0; i < types.length; i++) {
|
||||
if (val == (types[i]).value) {
|
||||
type = types[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
public static final EscherRecordType UNKNOWN = new EscherRecordType(0);
|
||||
|
||||
public static final EscherRecordType DGG_CONTAINER = new EscherRecordType(61440);
|
||||
|
||||
public static final EscherRecordType BSTORE_CONTAINER = new EscherRecordType(61441);
|
||||
|
||||
public static final EscherRecordType DG_CONTAINER = new EscherRecordType(61442);
|
||||
|
||||
public static final EscherRecordType SPGR_CONTAINER = new EscherRecordType(61443);
|
||||
|
||||
public static final EscherRecordType SP_CONTAINER = new EscherRecordType(61444);
|
||||
|
||||
public static final EscherRecordType DGG = new EscherRecordType(61446);
|
||||
|
||||
public static final EscherRecordType BSE = new EscherRecordType(61447);
|
||||
|
||||
public static final EscherRecordType DG = new EscherRecordType(61448);
|
||||
|
||||
public static final EscherRecordType SPGR = new EscherRecordType(61449);
|
||||
|
||||
public static final EscherRecordType SP = new EscherRecordType(61450);
|
||||
|
||||
public static final EscherRecordType OPT = new EscherRecordType(61451);
|
||||
|
||||
public static final EscherRecordType CLIENT_ANCHOR = new EscherRecordType(61456);
|
||||
|
||||
public static final EscherRecordType CLIENT_DATA = new EscherRecordType(61457);
|
||||
|
||||
public static final EscherRecordType CLIENT_TEXT_BOX = new EscherRecordType(61453);
|
||||
|
||||
public static final EscherRecordType SPLIT_MENU_COLORS = new EscherRecordType(61726);
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
interface EscherStream {
|
||||
byte[] getData();
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.biff.Type;
|
||||
import jxl.biff.WritableRecordData;
|
||||
import jxl.read.biff.Record;
|
||||
|
||||
public class MsoDrawingGroupRecord extends WritableRecordData {
|
||||
private byte[] data;
|
||||
|
||||
public MsoDrawingGroupRecord(Record t) {
|
||||
super(t);
|
||||
this.data = t.getData();
|
||||
}
|
||||
|
||||
MsoDrawingGroupRecord(byte[] d) {
|
||||
super(Type.MSODRAWINGGROUP);
|
||||
this.data = d;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.biff.Type;
|
||||
import jxl.biff.WritableRecordData;
|
||||
import jxl.common.Logger;
|
||||
import jxl.read.biff.Record;
|
||||
|
||||
public class MsoDrawingRecord extends WritableRecordData {
|
||||
private static Logger logger = Logger.getLogger(MsoDrawingRecord.class);
|
||||
|
||||
private boolean first;
|
||||
|
||||
private byte[] data;
|
||||
|
||||
public MsoDrawingRecord(Record t) {
|
||||
super(t);
|
||||
this.data = getRecord().getData();
|
||||
this.first = false;
|
||||
}
|
||||
|
||||
public MsoDrawingRecord(byte[] d) {
|
||||
super(Type.MSODRAWING);
|
||||
this.data = d;
|
||||
this.first = false;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public Record getRecord() {
|
||||
return super.getRecord();
|
||||
}
|
||||
|
||||
public void setFirst() {
|
||||
this.first = true;
|
||||
}
|
||||
|
||||
public boolean isFirst() {
|
||||
return this.first;
|
||||
}
|
||||
}
|
||||
63
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/NoteRecord.java
Normal file
63
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/NoteRecord.java
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.biff.IntegerHelper;
|
||||
import jxl.biff.Type;
|
||||
import jxl.biff.WritableRecordData;
|
||||
import jxl.common.Logger;
|
||||
import jxl.read.biff.Record;
|
||||
|
||||
public class NoteRecord extends WritableRecordData {
|
||||
private static Logger logger = Logger.getLogger(NoteRecord.class);
|
||||
|
||||
private byte[] data;
|
||||
|
||||
private int row;
|
||||
|
||||
private int column;
|
||||
|
||||
private int objectId;
|
||||
|
||||
public NoteRecord(Record t) {
|
||||
super(t);
|
||||
this.data = getRecord().getData();
|
||||
this.row = IntegerHelper.getInt(this.data[0], this.data[1]);
|
||||
this.column = IntegerHelper.getInt(this.data[2], this.data[3]);
|
||||
this.objectId = IntegerHelper.getInt(this.data[6], this.data[7]);
|
||||
}
|
||||
|
||||
public NoteRecord(byte[] d) {
|
||||
super(Type.NOTE);
|
||||
this.data = d;
|
||||
}
|
||||
|
||||
public NoteRecord(int c, int r, int id) {
|
||||
super(Type.NOTE);
|
||||
this.row = r;
|
||||
this.column = c;
|
||||
this.objectId = id;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
if (this.data != null)
|
||||
return this.data;
|
||||
String author = "";
|
||||
this.data = new byte[8 + author.length() + 4];
|
||||
IntegerHelper.getTwoBytes(this.row, this.data, 0);
|
||||
IntegerHelper.getTwoBytes(this.column, this.data, 2);
|
||||
IntegerHelper.getTwoBytes(this.objectId, this.data, 6);
|
||||
IntegerHelper.getTwoBytes(author.length(), this.data, 8);
|
||||
return this.data;
|
||||
}
|
||||
|
||||
int getRow() {
|
||||
return this.row;
|
||||
}
|
||||
|
||||
int getColumn() {
|
||||
return this.column;
|
||||
}
|
||||
|
||||
public int getObjectId() {
|
||||
return this.objectId;
|
||||
}
|
||||
}
|
||||
224
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ObjRecord.java
Normal file
224
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ObjRecord.java
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.biff.IntegerHelper;
|
||||
import jxl.biff.Type;
|
||||
import jxl.biff.WritableRecordData;
|
||||
import jxl.common.Assert;
|
||||
import jxl.common.Logger;
|
||||
import jxl.read.biff.Record;
|
||||
|
||||
public class ObjRecord extends WritableRecordData {
|
||||
private static final Logger logger = Logger.getLogger(ObjRecord.class);
|
||||
|
||||
private ObjType type;
|
||||
|
||||
private boolean read;
|
||||
|
||||
private int objectId;
|
||||
|
||||
private static final class ObjType {
|
||||
public int value;
|
||||
|
||||
public String desc;
|
||||
|
||||
private static ObjType[] types = new ObjType[0];
|
||||
|
||||
ObjType(int v, String d) {
|
||||
this.value = v;
|
||||
this.desc = d;
|
||||
ObjType[] oldtypes = types;
|
||||
types = new ObjType[types.length + 1];
|
||||
System.arraycopy(oldtypes, 0, types, 0, oldtypes.length);
|
||||
types[oldtypes.length] = this;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
public static ObjType getType(int val) {
|
||||
ObjType retval = ObjRecord.UNKNOWN;
|
||||
for (int i = 0; i < types.length && retval == ObjRecord.UNKNOWN; i++) {
|
||||
if ((types[i]).value == val)
|
||||
retval = types[i];
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
public static final ObjType GROUP = new ObjType(0, "Group");
|
||||
|
||||
public static final ObjType LINE = new ObjType(1, "Line");
|
||||
|
||||
public static final ObjType RECTANGLE = new ObjType(2, "Rectangle");
|
||||
|
||||
public static final ObjType OVAL = new ObjType(3, "Oval");
|
||||
|
||||
public static final ObjType ARC = new ObjType(4, "Arc");
|
||||
|
||||
public static final ObjType CHART = new ObjType(5, "Chart");
|
||||
|
||||
public static final ObjType TEXT = new ObjType(6, "Text");
|
||||
|
||||
public static final ObjType BUTTON = new ObjType(7, "Button");
|
||||
|
||||
public static final ObjType PICTURE = new ObjType(8, "Picture");
|
||||
|
||||
public static final ObjType POLYGON = new ObjType(9, "Polygon");
|
||||
|
||||
public static final ObjType CHECKBOX = new ObjType(11, "Checkbox");
|
||||
|
||||
public static final ObjType OPTION = new ObjType(12, "Option");
|
||||
|
||||
public static final ObjType EDITBOX = new ObjType(13, "Edit Box");
|
||||
|
||||
public static final ObjType LABEL = new ObjType(14, "Label");
|
||||
|
||||
public static final ObjType DIALOGUEBOX = new ObjType(15, "Dialogue Box");
|
||||
|
||||
public static final ObjType SPINBOX = new ObjType(16, "Spin Box");
|
||||
|
||||
public static final ObjType SCROLLBAR = new ObjType(17, "Scrollbar");
|
||||
|
||||
public static final ObjType LISTBOX = new ObjType(18, "List Box");
|
||||
|
||||
public static final ObjType GROUPBOX = new ObjType(19, "Group Box");
|
||||
|
||||
public static final ObjType COMBOBOX = new ObjType(20, "Combo Box");
|
||||
|
||||
public static final ObjType MSOFFICEDRAWING = new ObjType(30, "MS Office Drawing");
|
||||
|
||||
public static final ObjType FORMCONTROL = new ObjType(20, "Form Combo Box");
|
||||
|
||||
public static final ObjType EXCELNOTE = new ObjType(25, "Excel Note");
|
||||
|
||||
public static final ObjType UNKNOWN = new ObjType(255, "Unknown");
|
||||
|
||||
private static final int COMMON_DATA_LENGTH = 22;
|
||||
|
||||
private static final int CLIPBOARD_FORMAT_LENGTH = 6;
|
||||
|
||||
private static final int PICTURE_OPTION_LENGTH = 6;
|
||||
|
||||
private static final int NOTE_STRUCTURE_LENGTH = 26;
|
||||
|
||||
private static final int COMBOBOX_STRUCTURE_LENGTH = 44;
|
||||
|
||||
private static final int END_LENGTH = 4;
|
||||
|
||||
public ObjRecord(Record t) {
|
||||
super(t);
|
||||
byte[] data = t.getData();
|
||||
int objtype = IntegerHelper.getInt(data[4], data[5]);
|
||||
this.read = true;
|
||||
this.type = ObjType.getType(objtype);
|
||||
if (this.type == UNKNOWN)
|
||||
logger.warn("unknown object type code " + objtype);
|
||||
this.objectId = IntegerHelper.getInt(data[6], data[7]);
|
||||
}
|
||||
|
||||
ObjRecord(int objId, ObjType t) {
|
||||
super(Type.OBJ);
|
||||
this.objectId = objId;
|
||||
this.type = t;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
if (this.read)
|
||||
return getRecord().getData();
|
||||
if (this.type == PICTURE || this.type == CHART)
|
||||
return getPictureData();
|
||||
if (this.type == EXCELNOTE)
|
||||
return getNoteData();
|
||||
if (this.type == COMBOBOX)
|
||||
return getComboBoxData();
|
||||
Assert.verify(false);
|
||||
return null;
|
||||
}
|
||||
|
||||
private byte[] getPictureData() {
|
||||
int dataLength = 38;
|
||||
int pos = 0;
|
||||
byte[] data = new byte[dataLength];
|
||||
IntegerHelper.getTwoBytes(21, data, pos);
|
||||
IntegerHelper.getTwoBytes(18, data, pos + 2);
|
||||
IntegerHelper.getTwoBytes(this.type.value, data, pos + 4);
|
||||
IntegerHelper.getTwoBytes(this.objectId, data, pos + 6);
|
||||
IntegerHelper.getTwoBytes(24593, data, pos + 8);
|
||||
pos += 22;
|
||||
IntegerHelper.getTwoBytes(7, data, pos);
|
||||
IntegerHelper.getTwoBytes(2, data, pos + 2);
|
||||
IntegerHelper.getTwoBytes(65535, data, pos + 4);
|
||||
pos += 6;
|
||||
IntegerHelper.getTwoBytes(8, data, pos);
|
||||
IntegerHelper.getTwoBytes(2, data, pos + 2);
|
||||
IntegerHelper.getTwoBytes(1, data, pos + 4);
|
||||
pos += 6;
|
||||
IntegerHelper.getTwoBytes(0, data, pos);
|
||||
IntegerHelper.getTwoBytes(0, data, pos + 2);
|
||||
pos += 4;
|
||||
return data;
|
||||
}
|
||||
|
||||
private byte[] getNoteData() {
|
||||
int dataLength = 52;
|
||||
int pos = 0;
|
||||
byte[] data = new byte[dataLength];
|
||||
IntegerHelper.getTwoBytes(21, data, pos);
|
||||
IntegerHelper.getTwoBytes(18, data, pos + 2);
|
||||
IntegerHelper.getTwoBytes(this.type.value, data, pos + 4);
|
||||
IntegerHelper.getTwoBytes(this.objectId, data, pos + 6);
|
||||
IntegerHelper.getTwoBytes(16401, data, pos + 8);
|
||||
pos += 22;
|
||||
IntegerHelper.getTwoBytes(13, data, pos);
|
||||
IntegerHelper.getTwoBytes(22, data, pos + 2);
|
||||
pos += 26;
|
||||
IntegerHelper.getTwoBytes(0, data, pos);
|
||||
IntegerHelper.getTwoBytes(0, data, pos + 2);
|
||||
pos += 4;
|
||||
return data;
|
||||
}
|
||||
|
||||
private byte[] getComboBoxData() {
|
||||
int dataLength = 70;
|
||||
int pos = 0;
|
||||
byte[] data = new byte[dataLength];
|
||||
IntegerHelper.getTwoBytes(21, data, pos);
|
||||
IntegerHelper.getTwoBytes(18, data, pos + 2);
|
||||
IntegerHelper.getTwoBytes(this.type.value, data, pos + 4);
|
||||
IntegerHelper.getTwoBytes(this.objectId, data, pos + 6);
|
||||
IntegerHelper.getTwoBytes(0, data, pos + 8);
|
||||
pos += 22;
|
||||
IntegerHelper.getTwoBytes(12, data, pos);
|
||||
IntegerHelper.getTwoBytes(20, data, pos + 2);
|
||||
data[pos + 14] = 1;
|
||||
data[pos + 16] = 4;
|
||||
data[pos + 20] = 16;
|
||||
data[pos + 24] = 19;
|
||||
data[pos + 26] = -18;
|
||||
data[pos + 27] = 31;
|
||||
data[pos + 30] = 4;
|
||||
data[pos + 34] = 1;
|
||||
data[pos + 35] = 6;
|
||||
data[pos + 38] = 2;
|
||||
data[pos + 40] = 8;
|
||||
data[pos + 42] = 64;
|
||||
pos += 44;
|
||||
IntegerHelper.getTwoBytes(0, data, pos);
|
||||
IntegerHelper.getTwoBytes(0, data, pos + 2);
|
||||
pos += 4;
|
||||
return data;
|
||||
}
|
||||
|
||||
public Record getRecord() {
|
||||
return super.getRecord();
|
||||
}
|
||||
|
||||
public ObjType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public int getObjectId() {
|
||||
return this.objectId;
|
||||
}
|
||||
}
|
||||
123
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Opt.java
Normal file
123
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Opt.java
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import jxl.biff.IntegerHelper;
|
||||
import jxl.biff.StringHelper;
|
||||
import jxl.common.Logger;
|
||||
|
||||
class Opt extends EscherAtom {
|
||||
private static Logger logger = Logger.getLogger(Opt.class);
|
||||
|
||||
private byte[] data;
|
||||
|
||||
private int numProperties;
|
||||
|
||||
private ArrayList properties;
|
||||
|
||||
static final class Property {
|
||||
int id;
|
||||
|
||||
boolean blipId;
|
||||
|
||||
boolean complex;
|
||||
|
||||
int value;
|
||||
|
||||
String stringValue;
|
||||
|
||||
public Property(int i, boolean bl, boolean co, int v) {
|
||||
this.id = i;
|
||||
this.blipId = bl;
|
||||
this.complex = co;
|
||||
this.value = v;
|
||||
}
|
||||
|
||||
public Property(int i, boolean bl, boolean co, int v, String s) {
|
||||
this.id = i;
|
||||
this.blipId = bl;
|
||||
this.complex = co;
|
||||
this.value = v;
|
||||
this.stringValue = s;
|
||||
}
|
||||
}
|
||||
|
||||
public Opt(EscherRecordData erd) {
|
||||
super(erd);
|
||||
this.numProperties = getInstance();
|
||||
readProperties();
|
||||
}
|
||||
|
||||
private void readProperties() {
|
||||
this.properties = new ArrayList();
|
||||
int pos = 0;
|
||||
byte[] bytes = getBytes();
|
||||
for (int i = 0; i < this.numProperties; i++) {
|
||||
int val = IntegerHelper.getInt(bytes[pos], bytes[pos + 1]);
|
||||
int id = val & 0x3FFF;
|
||||
int value = IntegerHelper.getInt(bytes[pos + 2], bytes[pos + 3], bytes[pos + 4], bytes[pos + 5]);
|
||||
Property p = new Property(id, ((val & 0x4000) != 0), ((val & 0x8000) != 0), value);
|
||||
pos += 6;
|
||||
this.properties.add(p);
|
||||
}
|
||||
for (Property p : (Iterable<Property>)this.properties) {
|
||||
if (p.complex) {
|
||||
p.stringValue = StringHelper.getUnicodeString(bytes, p.value / 2, pos);
|
||||
pos += p.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Opt() {
|
||||
super(EscherRecordType.OPT);
|
||||
this.properties = new ArrayList();
|
||||
setVersion(3);
|
||||
}
|
||||
|
||||
byte[] getData() {
|
||||
this.numProperties = this.properties.size();
|
||||
setInstance(this.numProperties);
|
||||
this.data = new byte[this.numProperties * 6];
|
||||
int pos = 0;
|
||||
for (Property p : (Iterable<Property>)this.properties) {
|
||||
int val = p.id & 0x3FFF;
|
||||
if (p.blipId)
|
||||
val |= 0x4000;
|
||||
if (p.complex)
|
||||
val |= 0x8000;
|
||||
IntegerHelper.getTwoBytes(val, this.data, pos);
|
||||
IntegerHelper.getFourBytes(p.value, this.data, pos + 2);
|
||||
pos += 6;
|
||||
}
|
||||
for (Property p : (Iterable<Property>)this.properties) {
|
||||
if (p.complex && p.stringValue != null) {
|
||||
byte[] newData = new byte[this.data.length + p.stringValue.length() * 2];
|
||||
System.arraycopy(this.data, 0, newData, 0, this.data.length);
|
||||
StringHelper.getUnicodeBytes(p.stringValue, newData, this.data.length);
|
||||
this.data = newData;
|
||||
}
|
||||
}
|
||||
return setHeaderData(this.data);
|
||||
}
|
||||
|
||||
void addProperty(int id, boolean blip, boolean complex, int val) {
|
||||
Property p = new Property(id, blip, complex, val);
|
||||
this.properties.add(p);
|
||||
}
|
||||
|
||||
void addProperty(int id, boolean blip, boolean complex, int val, String s) {
|
||||
Property p = new Property(id, blip, complex, val, s);
|
||||
this.properties.add(p);
|
||||
}
|
||||
|
||||
Property getProperty(int id) {
|
||||
boolean found = false;
|
||||
Property p = null;
|
||||
for (Iterator<Property> i = this.properties.iterator(); i.hasNext() && !found; ) {
|
||||
p = i.next();
|
||||
if (p.id == id)
|
||||
found = true;
|
||||
}
|
||||
return found ? p : null;
|
||||
}
|
||||
}
|
||||
9
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Origin.java
Normal file
9
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Origin.java
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
public final class Origin {
|
||||
public static final Origin READ = new Origin();
|
||||
|
||||
public static final Origin WRITE = new Origin();
|
||||
|
||||
public static final Origin READ_WRITE = new Origin();
|
||||
}
|
||||
97
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/PNGReader.java
Normal file
97
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/PNGReader.java
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class PNGReader {
|
||||
private byte[] pngData;
|
||||
|
||||
private Chunk ihdr;
|
||||
|
||||
private Chunk phys;
|
||||
|
||||
private int pixelWidth;
|
||||
|
||||
private int pixelHeight;
|
||||
|
||||
private int verticalResolution;
|
||||
|
||||
private int horizontalResolution;
|
||||
|
||||
private int resolutionUnit;
|
||||
|
||||
private static byte[] PNG_MAGIC_NUMBER = new byte[] { -119, 80, 78, 71, 13, 10, 26, 10 };
|
||||
|
||||
public PNGReader(byte[] data) {
|
||||
this.pngData = data;
|
||||
}
|
||||
|
||||
void read() {
|
||||
byte[] header = new byte[PNG_MAGIC_NUMBER.length];
|
||||
System.arraycopy(this.pngData, 0, header, 0, header.length);
|
||||
boolean pngFile = Arrays.equals(PNG_MAGIC_NUMBER, header);
|
||||
if (!pngFile)
|
||||
return;
|
||||
int pos = 8;
|
||||
while (pos < this.pngData.length) {
|
||||
int length = getInt(this.pngData[pos], this.pngData[pos + 1], this.pngData[pos + 2], this.pngData[pos + 3]);
|
||||
ChunkType chunkType = ChunkType.getChunkType(this.pngData[pos + 4], this.pngData[pos + 5], this.pngData[pos + 6], this.pngData[pos + 7]);
|
||||
if (chunkType == ChunkType.IHDR) {
|
||||
this.ihdr = new Chunk(pos + 8, length, chunkType, this.pngData);
|
||||
} else if (chunkType == ChunkType.PHYS) {
|
||||
this.phys = new Chunk(pos + 8, length, chunkType, this.pngData);
|
||||
}
|
||||
pos += length + 12;
|
||||
}
|
||||
byte[] ihdrData = this.ihdr.getData();
|
||||
this.pixelWidth = getInt(ihdrData[0], ihdrData[1], ihdrData[2], ihdrData[3]);
|
||||
this.pixelHeight = getInt(ihdrData[4], ihdrData[5], ihdrData[6], ihdrData[7]);
|
||||
if (this.phys != null) {
|
||||
byte[] physData = this.phys.getData();
|
||||
this.resolutionUnit = physData[8];
|
||||
this.horizontalResolution = getInt(physData[0], physData[1], physData[2], physData[3]);
|
||||
this.verticalResolution = getInt(physData[4], physData[5], physData[6], physData[7]);
|
||||
}
|
||||
}
|
||||
|
||||
private int getInt(byte d1, byte d2, byte d3, byte d4) {
|
||||
int i1 = d1 & 0xFF;
|
||||
int i2 = d2 & 0xFF;
|
||||
int i3 = d3 & 0xFF;
|
||||
int i4 = d4 & 0xFF;
|
||||
int val = i1 << 24 | i2 << 16 | i3 << 8 | i4;
|
||||
return val;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.pixelHeight;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.pixelWidth;
|
||||
}
|
||||
|
||||
public int getHorizontalResolution() {
|
||||
return (this.resolutionUnit == 1) ? this.horizontalResolution : 0;
|
||||
}
|
||||
|
||||
public int getVerticalResolution() {
|
||||
return (this.resolutionUnit == 1) ? this.verticalResolution : 0;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
File f = new File(args[0]);
|
||||
int size = (int)f.length();
|
||||
byte[] data = new byte[size];
|
||||
FileInputStream fis = new FileInputStream(f);
|
||||
fis.read(data);
|
||||
fis.close();
|
||||
PNGReader reader = new PNGReader(data);
|
||||
reader.read();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
41
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ShapeType.java
Normal file
41
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/ShapeType.java
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
final class ShapeType {
|
||||
private int value;
|
||||
|
||||
private static ShapeType[] types = new ShapeType[0];
|
||||
|
||||
ShapeType(int v) {
|
||||
this.value = v;
|
||||
ShapeType[] old = types;
|
||||
types = new ShapeType[types.length + 1];
|
||||
System.arraycopy(old, 0, types, 0, old.length);
|
||||
types[old.length] = this;
|
||||
}
|
||||
|
||||
static ShapeType getType(int v) {
|
||||
ShapeType st = UNKNOWN;
|
||||
boolean found = false;
|
||||
for (int i = 0; i < types.length && !found; i++) {
|
||||
if ((types[i]).value == v) {
|
||||
found = true;
|
||||
st = types[i];
|
||||
}
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static final ShapeType MIN = new ShapeType(0);
|
||||
|
||||
public static final ShapeType PICTURE_FRAME = new ShapeType(75);
|
||||
|
||||
public static final ShapeType HOST_CONTROL = new ShapeType(201);
|
||||
|
||||
public static final ShapeType TEXT_BOX = new ShapeType(202);
|
||||
|
||||
public static final ShapeType UNKNOWN = new ShapeType(-1);
|
||||
}
|
||||
230
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/SheetDrawingWriter.java
Normal file
230
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/SheetDrawingWriter.java
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import jxl.WorkbookSettings;
|
||||
import jxl.biff.IntegerHelper;
|
||||
import jxl.common.Logger;
|
||||
import jxl.write.biff.File;
|
||||
|
||||
public class SheetDrawingWriter {
|
||||
private static Logger logger = Logger.getLogger(SheetDrawingWriter.class);
|
||||
|
||||
private ArrayList drawings;
|
||||
|
||||
private boolean drawingsModified;
|
||||
|
||||
private Chart[] charts = new Chart[0];
|
||||
|
||||
private WorkbookSettings workbookSettings;
|
||||
|
||||
public SheetDrawingWriter(WorkbookSettings ws) {}
|
||||
|
||||
public void setDrawings(ArrayList dr, boolean mod) {
|
||||
this.drawings = dr;
|
||||
this.drawingsModified = mod;
|
||||
}
|
||||
|
||||
public void write(File outputFile) throws IOException {
|
||||
if (this.drawings.size() == 0 && this.charts.length == 0)
|
||||
return;
|
||||
boolean modified = this.drawingsModified;
|
||||
int numImages = this.drawings.size();
|
||||
for (Iterator<DrawingGroupObject> i = this.drawings.iterator(); i.hasNext() && !modified; ) {
|
||||
DrawingGroupObject d = i.next();
|
||||
if (d.getOrigin() != Origin.READ)
|
||||
modified = true;
|
||||
}
|
||||
if (numImages > 0 && !modified) {
|
||||
DrawingGroupObject d2 = this.drawings.get(0);
|
||||
if (!d2.isFirst())
|
||||
modified = true;
|
||||
}
|
||||
if (numImages == 0 && this.charts.length == 1 && this.charts[0].getMsoDrawingRecord() == null)
|
||||
modified = false;
|
||||
if (!modified) {
|
||||
writeUnmodified(outputFile);
|
||||
return;
|
||||
}
|
||||
Object[] spContainerData = new Object[numImages + this.charts.length];
|
||||
int length = 0;
|
||||
EscherContainer firstSpContainer = null;
|
||||
for (int k = 0; k < numImages; k++) {
|
||||
DrawingGroupObject drawing = this.drawings.get(k);
|
||||
EscherContainer spc = drawing.getSpContainer();
|
||||
if (spc != null) {
|
||||
byte[] data = spc.getData();
|
||||
spContainerData[k] = data;
|
||||
if (k == 0) {
|
||||
firstSpContainer = spc;
|
||||
} else {
|
||||
length += data.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < this.charts.length; j++) {
|
||||
EscherContainer escherContainer = this.charts[j].getSpContainer();
|
||||
byte[] data = escherContainer.getBytes();
|
||||
data = escherContainer.setHeaderData(data);
|
||||
spContainerData[j + numImages] = data;
|
||||
if (j == 0 && numImages == 0) {
|
||||
firstSpContainer = escherContainer;
|
||||
} else {
|
||||
length += data.length;
|
||||
}
|
||||
}
|
||||
DgContainer dgContainer = new DgContainer();
|
||||
Dg dg = new Dg(numImages + this.charts.length);
|
||||
dgContainer.add(dg);
|
||||
SpgrContainer spgrContainer = new SpgrContainer();
|
||||
SpContainer spContainer = new SpContainer();
|
||||
Spgr spgr = new Spgr();
|
||||
spContainer.add(spgr);
|
||||
Sp sp = new Sp(ShapeType.MIN, 1024, 5);
|
||||
spContainer.add(sp);
|
||||
spgrContainer.add(spContainer);
|
||||
spgrContainer.add(firstSpContainer);
|
||||
dgContainer.add(spgrContainer);
|
||||
byte[] firstMsoData = dgContainer.getData();
|
||||
int len = IntegerHelper.getInt(firstMsoData[4], firstMsoData[5], firstMsoData[6], firstMsoData[7]);
|
||||
IntegerHelper.getFourBytes(len + length, firstMsoData, 4);
|
||||
len = IntegerHelper.getInt(firstMsoData[28], firstMsoData[29], firstMsoData[30], firstMsoData[31]);
|
||||
IntegerHelper.getFourBytes(len + length, firstMsoData, 28);
|
||||
if (numImages > 0 && this.drawings.get(0).isFormObject()) {
|
||||
byte[] msodata2 = new byte[firstMsoData.length - 8];
|
||||
System.arraycopy(firstMsoData, 0, msodata2, 0, msodata2.length);
|
||||
firstMsoData = msodata2;
|
||||
}
|
||||
MsoDrawingRecord msoDrawingRecord = new MsoDrawingRecord(firstMsoData);
|
||||
outputFile.write(msoDrawingRecord);
|
||||
if (numImages > 0) {
|
||||
DrawingGroupObject firstDrawing = this.drawings.get(0);
|
||||
firstDrawing.writeAdditionalRecords(outputFile);
|
||||
} else {
|
||||
Chart chart = this.charts[0];
|
||||
ObjRecord objRecord = chart.getObjRecord();
|
||||
outputFile.write(objRecord);
|
||||
outputFile.write(chart);
|
||||
}
|
||||
for (int m = 1; m < spContainerData.length; m++) {
|
||||
byte[] bytes = (byte[])spContainerData[m];
|
||||
if (m < numImages && this.drawings.get(m).isFormObject()) {
|
||||
byte[] bytes2 = new byte[bytes.length - 8];
|
||||
System.arraycopy(bytes, 0, bytes2, 0, bytes2.length);
|
||||
bytes = bytes2;
|
||||
}
|
||||
msoDrawingRecord = new MsoDrawingRecord(bytes);
|
||||
outputFile.write(msoDrawingRecord);
|
||||
if (m < numImages) {
|
||||
DrawingGroupObject d = this.drawings.get(m);
|
||||
d.writeAdditionalRecords(outputFile);
|
||||
} else {
|
||||
Chart chart = this.charts[m - numImages];
|
||||
ObjRecord objRecord = chart.getObjRecord();
|
||||
outputFile.write(objRecord);
|
||||
outputFile.write(chart);
|
||||
}
|
||||
}
|
||||
for (DrawingGroupObject dgo2 : (Iterable<DrawingGroupObject>)this.drawings)
|
||||
dgo2.writeTailRecords(outputFile);
|
||||
}
|
||||
|
||||
private void writeUnmodified(File outputFile) throws IOException {
|
||||
if (this.charts.length == 0 && this.drawings.size() == 0)
|
||||
return;
|
||||
if (this.charts.length == 0 && this.drawings.size() != 0) {
|
||||
for (DrawingGroupObject d : (Iterable<DrawingGroupObject>)this.drawings) {
|
||||
outputFile.write(d.getMsoDrawingRecord());
|
||||
d.writeAdditionalRecords(outputFile);
|
||||
}
|
||||
for (DrawingGroupObject d : (Iterable<DrawingGroupObject>)this.drawings)
|
||||
d.writeTailRecords(outputFile);
|
||||
return;
|
||||
}
|
||||
if (this.drawings.size() == 0 && this.charts.length != 0) {
|
||||
Chart curChart = null;
|
||||
for (int m = 0; m < this.charts.length; m++) {
|
||||
curChart = this.charts[m];
|
||||
if (curChart.getMsoDrawingRecord() != null)
|
||||
outputFile.write(curChart.getMsoDrawingRecord());
|
||||
if (curChart.getObjRecord() != null)
|
||||
outputFile.write(curChart.getObjRecord());
|
||||
outputFile.write(curChart);
|
||||
}
|
||||
return;
|
||||
}
|
||||
int numDrawings = this.drawings.size();
|
||||
int length = 0;
|
||||
EscherContainer[] spContainers = new EscherContainer[numDrawings + this.charts.length];
|
||||
boolean[] isFormObject = new boolean[numDrawings + this.charts.length];
|
||||
for (int j = 0; j < numDrawings; j++) {
|
||||
DrawingGroupObject d = this.drawings.get(j);
|
||||
spContainers[j] = d.getSpContainer();
|
||||
if (j > 0)
|
||||
length += spContainers[j].getLength();
|
||||
if (d.isFormObject())
|
||||
isFormObject[j] = true;
|
||||
}
|
||||
for (int i = 0; i < this.charts.length; i++) {
|
||||
spContainers[i + numDrawings] = this.charts[i].getSpContainer();
|
||||
length += spContainers[i + numDrawings].getLength();
|
||||
}
|
||||
DgContainer dgContainer = new DgContainer();
|
||||
Dg dg = new Dg(numDrawings + this.charts.length);
|
||||
dgContainer.add(dg);
|
||||
SpgrContainer spgrContainer = new SpgrContainer();
|
||||
SpContainer spContainer = new SpContainer();
|
||||
Spgr spgr = new Spgr();
|
||||
spContainer.add(spgr);
|
||||
Sp sp = new Sp(ShapeType.MIN, 1024, 5);
|
||||
spContainer.add(sp);
|
||||
spgrContainer.add(spContainer);
|
||||
spgrContainer.add(spContainers[0]);
|
||||
dgContainer.add(spgrContainer);
|
||||
byte[] firstMsoData = dgContainer.getData();
|
||||
int len = IntegerHelper.getInt(firstMsoData[4], firstMsoData[5], firstMsoData[6], firstMsoData[7]);
|
||||
IntegerHelper.getFourBytes(len + length, firstMsoData, 4);
|
||||
len = IntegerHelper.getInt(firstMsoData[28], firstMsoData[29], firstMsoData[30], firstMsoData[31]);
|
||||
IntegerHelper.getFourBytes(len + length, firstMsoData, 28);
|
||||
if (isFormObject[0] == true) {
|
||||
byte[] cbytes = new byte[firstMsoData.length - 8];
|
||||
System.arraycopy(firstMsoData, 0, cbytes, 0, cbytes.length);
|
||||
firstMsoData = cbytes;
|
||||
}
|
||||
MsoDrawingRecord msoDrawingRecord = new MsoDrawingRecord(firstMsoData);
|
||||
outputFile.write(msoDrawingRecord);
|
||||
DrawingGroupObject dgo = this.drawings.get(0);
|
||||
dgo.writeAdditionalRecords(outputFile);
|
||||
for (int k = 1; k < spContainers.length; k++) {
|
||||
byte[] bytes = spContainers[k].getBytes();
|
||||
byte[] bytes2 = spContainers[k].setHeaderData(bytes);
|
||||
if (isFormObject[k] == true) {
|
||||
byte[] cbytes = new byte[bytes2.length - 8];
|
||||
System.arraycopy(bytes2, 0, cbytes, 0, cbytes.length);
|
||||
bytes2 = cbytes;
|
||||
}
|
||||
msoDrawingRecord = new MsoDrawingRecord(bytes2);
|
||||
outputFile.write(msoDrawingRecord);
|
||||
if (k < numDrawings) {
|
||||
dgo = this.drawings.get(k);
|
||||
dgo.writeAdditionalRecords(outputFile);
|
||||
} else {
|
||||
Chart chart = this.charts[k - numDrawings];
|
||||
ObjRecord objRecord = chart.getObjRecord();
|
||||
outputFile.write(objRecord);
|
||||
outputFile.write(chart);
|
||||
}
|
||||
}
|
||||
for (DrawingGroupObject dgo2 : (Iterable<DrawingGroupObject>)this.drawings)
|
||||
dgo2.writeTailRecords(outputFile);
|
||||
}
|
||||
|
||||
public void setCharts(Chart[] ch) {
|
||||
this.charts = ch;
|
||||
}
|
||||
|
||||
public Chart[] getCharts() {
|
||||
return this.charts;
|
||||
}
|
||||
}
|
||||
48
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Sp.java
Normal file
48
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Sp.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.biff.IntegerHelper;
|
||||
import jxl.common.Logger;
|
||||
|
||||
class Sp extends EscherAtom {
|
||||
private static Logger logger = Logger.getLogger(Sp.class);
|
||||
|
||||
private byte[] data;
|
||||
|
||||
private int shapeType;
|
||||
|
||||
private int shapeId;
|
||||
|
||||
private int persistenceFlags;
|
||||
|
||||
public Sp(EscherRecordData erd) {
|
||||
super(erd);
|
||||
this.shapeType = getInstance();
|
||||
byte[] bytes = getBytes();
|
||||
this.shapeId = IntegerHelper.getInt(bytes[0], bytes[1], bytes[2], bytes[3]);
|
||||
this.persistenceFlags = IntegerHelper.getInt(bytes[4], bytes[5], bytes[6], bytes[7]);
|
||||
}
|
||||
|
||||
public Sp(ShapeType st, int sid, int p) {
|
||||
super(EscherRecordType.SP);
|
||||
setVersion(2);
|
||||
this.shapeType = st.getValue();
|
||||
this.shapeId = sid;
|
||||
this.persistenceFlags = p;
|
||||
setInstance(this.shapeType);
|
||||
}
|
||||
|
||||
int getShapeId() {
|
||||
return this.shapeId;
|
||||
}
|
||||
|
||||
int getShapeType() {
|
||||
return this.shapeType;
|
||||
}
|
||||
|
||||
byte[] getData() {
|
||||
this.data = new byte[8];
|
||||
IntegerHelper.getFourBytes(this.shapeId, this.data, 0);
|
||||
IntegerHelper.getFourBytes(this.persistenceFlags, this.data, 4);
|
||||
return setHeaderData(this.data);
|
||||
}
|
||||
}
|
||||
11
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/SpContainer.java
Normal file
11
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/SpContainer.java
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
class SpContainer extends EscherContainer {
|
||||
public SpContainer() {
|
||||
super(EscherRecordType.SP_CONTAINER);
|
||||
}
|
||||
|
||||
public SpContainer(EscherRecordData erd) {
|
||||
super(erd);
|
||||
}
|
||||
}
|
||||
19
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Spgr.java
Normal file
19
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/Spgr.java
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
class Spgr extends EscherAtom {
|
||||
private byte[] data;
|
||||
|
||||
public Spgr(EscherRecordData erd) {
|
||||
super(erd);
|
||||
}
|
||||
|
||||
public Spgr() {
|
||||
super(EscherRecordType.SPGR);
|
||||
setVersion(1);
|
||||
this.data = new byte[16];
|
||||
}
|
||||
|
||||
byte[] getData() {
|
||||
return setHeaderData(this.data);
|
||||
}
|
||||
}
|
||||
15
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/SpgrContainer.java
Normal file
15
rus/WEB-INF/lib/jxl_src/jxl/biff/drawing/SpgrContainer.java
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.common.Logger;
|
||||
|
||||
class SpgrContainer extends EscherContainer {
|
||||
private static final Logger logger = Logger.getLogger(SpgrContainer.class);
|
||||
|
||||
public SpgrContainer() {
|
||||
super(EscherRecordType.SPGR_CONTAINER);
|
||||
}
|
||||
|
||||
public SpgrContainer(EscherRecordData erd) {
|
||||
super(erd);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
class SplitMenuColors extends EscherAtom {
|
||||
private byte[] data;
|
||||
|
||||
public SplitMenuColors(EscherRecordData erd) {
|
||||
super(erd);
|
||||
}
|
||||
|
||||
public SplitMenuColors() {
|
||||
super(EscherRecordType.SPLIT_MENU_COLORS);
|
||||
setVersion(0);
|
||||
setInstance(4);
|
||||
this.data = new byte[] {
|
||||
13, 0, 0, 8, 12, 0, 0, 8, 23, 0,
|
||||
0, 8, -9, 0, 0, 16 };
|
||||
}
|
||||
|
||||
byte[] getData() {
|
||||
return setHeaderData(this.data);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package jxl.biff.drawing;
|
||||
|
||||
import jxl.biff.IntegerHelper;
|
||||
import jxl.biff.Type;
|
||||
import jxl.biff.WritableRecordData;
|
||||
import jxl.common.Logger;
|
||||
import jxl.read.biff.Record;
|
||||
|
||||
public class TextObjectRecord extends WritableRecordData {
|
||||
private static Logger logger = Logger.getLogger(TextObjectRecord.class);
|
||||
|
||||
private byte[] data;
|
||||
|
||||
private int textLength;
|
||||
|
||||
TextObjectRecord(String t) {
|
||||
super(Type.TXO);
|
||||
this.textLength = t.length();
|
||||
}
|
||||
|
||||
public TextObjectRecord(Record t) {
|
||||
super(t);
|
||||
this.data = getRecord().getData();
|
||||
this.textLength = IntegerHelper.getInt(this.data[10], this.data[11]);
|
||||
}
|
||||
|
||||
public TextObjectRecord(byte[] d) {
|
||||
super(Type.TXO);
|
||||
this.data = d;
|
||||
}
|
||||
|
||||
public int getTextLength() {
|
||||
return this.textLength;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
if (this.data != null)
|
||||
return this.data;
|
||||
this.data = new byte[18];
|
||||
int options = 0;
|
||||
options |= 0x2;
|
||||
options |= 0x10;
|
||||
options |= 0x200;
|
||||
IntegerHelper.getTwoBytes(options, this.data, 0);
|
||||
IntegerHelper.getTwoBytes(this.textLength, this.data, 10);
|
||||
IntegerHelper.getTwoBytes(16, this.data, 12);
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue