String name = ctrl.getProgId() + "-" + getControlIndex();
byte[] data = (name + '\u0000').getBytes("UTF-16LE");
EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.GROUPSHAPE__SHAPENAME, false, data);
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
opt.addEscherProperty(prop);
} catch (UnsupportedEncodingException e){
throw new HSLFException(e);
if(!isClosed) segInfo.add(SEGMENTINFO_LINETO);
segInfo.add(new byte[]{0x00, (byte)0x80});
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4));
EscherArrayProperty verticesProp = new EscherArrayProperty((short)(EscherProperties.GEOMETRY__VERTICES + 0x4000), false, null);
* @return the freeform path
*/
public GeneralPath getPath(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__SHAPEPATH, 0x4));
EscherArrayProperty verticesProp = (EscherArrayProperty)getEscherProperty(opt, (short)(EscherProperties.GEOMETRY__VERTICES + 0x4000));
spRecord.setOptions(type);
//set default properties for a line
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
//default line properties
setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, 4);
* @return the index to this picture (1 based).
*/
public int getPictureIndex(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.BLIP__BLIPTODISPLAY);
return prop == null ? 0 : prop.getPropertyValue();
}
spRecord.setOptions((short)((ShapeTypes.PictureFrame << 4) | 0x2));
//set default properties for a picture
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
setEscherProperty(opt, EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x800080);
//another weird feature of powerpoint: for picture id we must add 0x4000.
* @return name of this picture
*/
public String getPictureName(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherComplexProperty prop = (EscherComplexProperty)getEscherProperty(opt, EscherProperties.BLIP__BLIPFILENAME);
String name = null;
if(prop != null){
* @param name of this picture
*/
public void setPictureName(String name){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
try {
byte[] data = (name + '\u0000').getBytes("UTF-16LE");
EscherComplexProperty prop = new EscherComplexProperty(EscherProperties.BLIP__BLIPFILENAME, false, data);
EscherClientDataRecord cldata = new EscherClientDataRecord();
cldata.setOptions((short)15);
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
//Placeholders can't be grouped
setEscherProperty(opt, EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 262144);
float left = findSmallest(xPoints);
float top = findSmallest(yPoints);
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__RIGHT, (int)((right - left)*POINT_DPI/MASTER_DPI)));
opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.GEOMETRY__BOTTOM, (int)((bottom - top)*POINT_DPI/MASTER_DPI)));
* @param value value of the property. If value = -1 then the property is removed.
*/
public void setEscherProperty(short propId, int value){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
setEscherProperty(opt, propId, value);
}
* @param propId The id of the property. One of the constants defined in EscherOptRecord.
*/
public int getEscherProperty(short propId){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, propId);
return prop == null ? 0 : prop.getPropertyValue();
}
* @param propId The id of the property. One of the constants defined in EscherOptRecord.
*/
public int getEscherProperty(short propId, int defaultValue){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, propId);
return prop == null ? defaultValue : prop.getPropertyValue();
}
}
Color getColor(short colorProperty, short opacityProperty, int defaultColor){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty p = (EscherSimpleProperty)getEscherProperty(opt, colorProperty);
if(p == null && defaultColor == -1) return null;
public java.awt.Shape getOutline(){
return getLogicalAnchor2D();
}
+
+ protected EscherOptRecord getEscherOptRecord() {
+ return (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ }
}
* Returns width of the line in in points
*/
public double getLineWidth(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
double width = prop == null ? DEFAULT_LINE_WIDTH : (double)prop.getPropertyValue()/EMU_PER_POINT;
return width;
* @param width the width of line in in points
*/
public void setLineWidth(double width){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
setEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH, (int)(width*EMU_PER_POINT));
}
* @param color new color of the line
*/
public void setLineColor(Color color){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
if (color == null) {
setEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x80000);
} else {
* @return color of the line. If color is not set returns <code>java.awt.Color.black</code>
*/
public Color getLineColor(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty p = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH);
if(p != null && (p.getPropertyValue() & 0x8) == 0) return null;
* @return dashing of the line.
*/
public int getLineDashing(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING);
return prop == null ? Line.PEN_SOLID : prop.getPropertyValue();
* @param pen new style of the line.
*/
public void setLineDashing(int pen){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
setEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING, pen == Line.PEN_SOLID ? -1 : pen);
}
* @param style new style of the line.
*/
public void setLineStyle(int style){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
setEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE, style == Line.LINE_SIMPLE ? -1 : style);
}
* @return style of the line.
*/
public int getLineStyle(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE);
return prop == null ? Line.LINE_SIMPLE : prop.getPropertyValue();
}
public Line createBorder(){
Line line = new Line(this);
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(line.getSpContainer(), EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
setEscherProperty(opt, EscherProperties.GEOMETRY__SHAPEPATH, -1);
setEscherProperty(opt, EscherProperties.GEOMETRY__FILLOK, -1);
setEscherProperty(opt, EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x20000);
protected EscherContainerRecord createSpContainer(boolean isChild){
_escherContainer = super.createSpContainer(isChild);
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
setEscherProperty(opt, EscherProperties.TEXT__TEXTID, 0);
setEscherProperty(opt, EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x20000);
setEscherProperty(opt, EscherProperties.FILL__NOFILLHITTEST, 0x150001);
* @return the type of alignment
*/
public int getVerticalAlignment(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__ANCHORTEXT);
int valign = TextShape.AnchorTop;
if (prop == null){
* @return the botom margin
*/
public float getMarginBottom(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__TEXTBOTTOM);
int val = prop == null ? EMU_PER_INCH/20 : prop.getPropertyValue();
return (float)val/EMU_PER_POINT;
* @return the left margin
*/
public float getMarginLeft(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__TEXTLEFT);
int val = prop == null ? EMU_PER_INCH/10 : prop.getPropertyValue();
return (float)val/EMU_PER_POINT;
* @return the right margin
*/
public float getMarginRight(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__TEXTRIGHT);
int val = prop == null ? EMU_PER_INCH/10 : prop.getPropertyValue();
return (float)val/EMU_PER_POINT;
* @return the top margin
*/
public float getMarginTop(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__TEXTTOP);
int val = prop == null ? EMU_PER_INCH/20 : prop.getPropertyValue();
return (float)val/EMU_PER_POINT;
* Must be one of the <code>Wrap*</code> constants defined in this class.
*/
public int getWordWrap(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__WRAPTEXT);
return prop == null ? WrapSquare : prop.getPropertyValue();
}
* @return id for the text.
*/
public int getTextId(){
- EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
+ EscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.TEXT__TEXTID);
return prop == null ? 0 : prop.getPropertyValue();
}