Unified access to escher opt record
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1647927 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0c580c8f45
commit
47fe5b9651
@ -159,7 +159,7 @@ public final class ActiveXShape extends Picture {
|
||||
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);
|
||||
|
@ -136,7 +136,7 @@ public final class Freeform extends AutoShape {
|
||||
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);
|
||||
@ -176,7 +176,7 @@ public final class Freeform extends AutoShape {
|
||||
* @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));
|
||||
|
@ -116,7 +116,7 @@ public final class Line extends SimpleShape {
|
||||
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);
|
||||
|
@ -111,7 +111,7 @@ public class Picture extends SimpleShape {
|
||||
* @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();
|
||||
}
|
||||
@ -130,7 +130,7 @@ public class Picture extends SimpleShape {
|
||||
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.
|
||||
@ -214,7 +214,7 @@ public class Picture extends SimpleShape {
|
||||
* @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){
|
||||
@ -235,7 +235,7 @@ public class Picture extends SimpleShape {
|
||||
* @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);
|
||||
|
@ -56,7 +56,7 @@ public final class Placeholder extends TextBox {
|
||||
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);
|
||||
|
@ -71,7 +71,7 @@ public final class Polygon extends AutoShape {
|
||||
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)));
|
||||
|
||||
|
@ -299,7 +299,7 @@ public abstract class Shape {
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ public abstract class Shape {
|
||||
* @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();
|
||||
}
|
||||
@ -320,7 +320,7 @@ public abstract class Shape {
|
||||
* @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();
|
||||
}
|
||||
@ -364,7 +364,7 @@ public abstract class Shape {
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -483,4 +483,8 @@ public abstract class Shape {
|
||||
public java.awt.Shape getOutline(){
|
||||
return getLogicalAnchor2D();
|
||||
}
|
||||
|
||||
protected EscherOptRecord getEscherOptRecord() {
|
||||
return (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public abstract class SimpleShape extends Shape {
|
||||
* 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;
|
||||
@ -113,7 +113,7 @@ public abstract class SimpleShape extends Shape {
|
||||
* @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));
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ public abstract class SimpleShape extends Shape {
|
||||
* @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 {
|
||||
@ -137,7 +137,7 @@ public abstract class SimpleShape extends Shape {
|
||||
* @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;
|
||||
@ -152,7 +152,7 @@ public abstract class SimpleShape extends Shape {
|
||||
* @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();
|
||||
@ -164,7 +164,7 @@ public abstract class SimpleShape extends Shape {
|
||||
* @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);
|
||||
}
|
||||
@ -175,7 +175,7 @@ public abstract class SimpleShape extends Shape {
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ public abstract class SimpleShape extends Shape {
|
||||
* @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();
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ public final class Table extends ShapeGroup {
|
||||
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);
|
||||
|
@ -61,7 +61,7 @@ public final class TableCell extends TextBox {
|
||||
|
||||
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);
|
||||
|
@ -280,7 +280,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* @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){
|
||||
@ -351,7 +351,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* @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;
|
||||
@ -376,7 +376,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* @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;
|
||||
@ -401,7 +401,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* @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;
|
||||
@ -425,7 +425,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* @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;
|
||||
@ -449,7 +449,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* 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();
|
||||
}
|
||||
@ -468,7 +468,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* @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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user