📄 button.java
字号:
/**
* Sets the new reference count on the drawing
*
* @param r the new reference count
*/
public void setReferenceCount(int r)
{
referenceCount = r;
}
/**
* Accessor for the column of this drawing
*
* @return the column
*/
public double getX()
{
if (!initialized)
{
initialize();
}
return column;
}
/**
* Sets the column position of this drawing. Used when inserting/removing
* columns from the spreadsheet
*
* @param x the column
*/
public void setX(double x)
{
if (origin == Origin.READ)
{
if (!initialized)
{
initialize();
}
origin = Origin.READ_WRITE;
}
column = (int) x;
}
/**
* Accessor for the row of this drawing
*
* @return the row
*/
public double getY()
{
if (!initialized)
{
initialize();
}
return row;
}
/**
* Accessor for the row of the drawing
*
* @param y the row
*/
public void setY(double y)
{
if (origin == Origin.READ)
{
if (!initialized)
{
initialize();
}
origin = Origin.READ_WRITE;
}
row = (int) y;
}
/**
* Accessor for the width of this drawing
*
* @return the number of columns spanned by this image
*/
public double getWidth()
{
if (!initialized)
{
initialize();
}
return width;
}
/**
* Accessor for the width
*
* @param w the number of columns to span
*/
public void setWidth(double w)
{
if (origin == Origin.READ)
{
if (!initialized)
{
initialize();
}
origin = Origin.READ_WRITE;
}
width = w;
}
/**
* Accessor for the height of this drawing
*
* @return the number of rows spanned by this image
*/
public double getHeight()
{
if (!initialized)
{
initialize();
}
return height;
}
/**
* Accessor for the height of this drawing
*
* @param h the number of rows spanned by this image
*/
public void setHeight(double h)
{
if (origin == Origin.READ)
{
if (!initialized)
{
initialize();
}
origin = Origin.READ_WRITE;
}
height = h;
}
/**
* Gets the SpContainer that was read in
*
* @return the read sp container
*/
private EscherContainer getReadSpContainer()
{
if (!initialized)
{
initialize();
}
return readSpContainer;
}
/**
* Accessor for the image data
*
* @return the image data
*/
public byte[] getImageData()
{
Assert.verify(origin == Origin.READ || origin == Origin.READ_WRITE);
if (!initialized)
{
initialize();
}
return drawingGroup.getImageData(blipId);
}
/**
* Accessor for the type
*
* @return the type
*/
public ShapeType getType()
{
return type;
}
/**
* Sets the text object
*
* @param t the text object record
*/
public void setTextObject(TextObjectRecord t)
{
txo = t;
}
/**
* Sets the text data
*
* @param t continuation record
*/
public void setText(ContinueRecord t)
{
text = t;
}
/**
* Sets the formatting
*
* @param t continue record
*/
public void setFormatting(ContinueRecord t)
{
formatting = t;
}
/**
* Accessor for the image data
*
* @return the image data
*/
public byte[] getImageBytes()
{
Assert.verify(false);
return null;
}
/**
* Accessor for the image file path. Normally this is the absolute path
* of a file on the directory system, but if this drawing was constructed
* using an byte[] then the blip id is returned
*
* @return the image file path, or the blip id
*/
public String getImageFilePath()
{
Assert.verify(false);
return null;
}
/**
* The drawing record
*
* @param d the drawing record
*/
public void addMso(MsoDrawingRecord d)
{
mso = d;
drawingData.addRawData(mso.getData());
}
/**
* Writes out any additional records
*
* @param outputFile the output file
* @exception IOException
*/
public void writeAdditionalRecords(File outputFile) throws IOException
{
if (origin == Origin.READ)
{
outputFile.write(objRecord);
if (mso != null)
{
outputFile.write(mso);
}
outputFile.write(txo);
outputFile.write(text);
if (formatting != null)
{
outputFile.write(formatting);
}
return;
}
Assert.verify(false);
// Create the obj record
ObjRecord objrec = new ObjRecord(objectId,
ObjRecord.EXCELNOTE);
outputFile.write(objrec);
// Create the mso data record. Write the text box record again,
// although it is already included in the SpContainer
ClientTextBox textBox = new ClientTextBox();
MsoDrawingRecord msod = new MsoDrawingRecord(textBox.getData());
outputFile.write(msod);
TextObjectRecord tor = new TextObjectRecord(getText());
outputFile.write(tor);
// Data for the first continue record
byte[] textData = new byte[commentText.length() * 2 + 1];
textData[0] = 0x1; // unicode indicator
StringHelper.getUnicodeBytes(commentText, textData, 1);
//StringHelper.getBytes(commentText, textData, 1);
ContinueRecord textContinue = new ContinueRecord(textData);
outputFile.write(textContinue);
// Data for the formatting runs
byte[] frData = new byte[16];
// First txo run (the user)
IntegerHelper.getTwoBytes(0, frData, 0); // index to the first character
IntegerHelper.getTwoBytes(0, frData, 2); // index to the font(default)
// Mandatory last txo run
IntegerHelper.getTwoBytes(commentText.length(), frData, 8);
IntegerHelper.getTwoBytes(0, frData, 10); // index to the font(default)
ContinueRecord frContinue = new ContinueRecord(frData);
outputFile.write(frContinue);
}
/**
* Writes any records that need to be written after all the drawing group
* objects have been written
* Writes out all the note records
*
* @param outputFile the output file
*/
public void writeTailRecords(File outputFile)
{
}
/**
* Accessor for the row. As buttons are not associated with a cell,
* does nothing here
*
* @return the row number
*/
public int getRow()
{
return 0;
}
/**
* Accessor for the column. As buttons are not associated with a cell,
* does nothing here
*
* @return the column number
*/
public int getColumn()
{
return 0;
}
/**
* Accessor for the text on the button
*
* @return the button text
*/
public String getText()
{
if (commentText == null)
{
Assert.verify(text != null);
byte[] td = text.getData();
if (td[0] == 0)
{
commentText = StringHelper.getString
(td, td.length - 1, 1, workbookSettings);
}
else
{
commentText = StringHelper.getUnicodeString
(td, (td.length - 1) / 2, 1);
}
}
return commentText;
}
/**
* Hashing algorithm
*
* @return the hash code
*/
public int hashCode()
{
return commentText.hashCode();
}
/**
* Called when the comment text is changed during the sheet copy process
*
* @param t the new text
*/
public void setButtonText(String t)
{
commentText = t;
if (origin == Origin.READ)
{
origin = Origin.READ_WRITE;
}
}
/**
* Accessor for the first drawing on the sheet. This is used when
* copying unmodified sheets to indicate that this drawing contains
* the first time Escher gubbins
*
* @return TRUE if this MSORecord is the first drawing on the sheet
*/
public boolean isFirst()
{
return mso.isFirst();
}
/**
* Queries whether this object is a form object. Form objects have their
* drawings records spread over TXO and CONTINUE records and
* require special handling
*
* @return TRUE if this is a form object, FALSE otherwise
*/
public boolean isFormObject()
{
return true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -