/**
* Represents an ActiveX control in a PowerPoint document.
- *
- * TODO: finish
- * @author Yegor Kozlov
*/
public final class ActiveXShape extends HSLFPictureShape {
public static final int DEFAULT_ACTIVEX_THUMBNAIL = -1;
*
* @return the created <code>EscherContainerRecord</code> which holds shape data
*/
+ @Override
protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {
- _escherContainer = super.createSpContainer(idx, isChild);
+ EscherContainerRecord ecr = super.createSpContainer(idx, isChild);
- EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
+ EscherSpRecord spRecord = ecr.getChildById(EscherSpRecord.RECORD_ID);
spRecord.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE | EscherSpRecord.FLAG_OLESHAPE);
setShapeType(ShapeType.HOST_CONTROL);
HSLFEscherClientDataRecord cldata = getClientData(true);
cldata.addChild(new ExObjRefAtom());
- return _escherContainer;
+ return ecr;
}
/**
return ctrl;
}
+ @Override
protected void afterInsert(HSLFSheet sheet){
ExControl ctrl = getExControl();
ctrl.getExControlAtom().setSlideId(sheet._getSheetNumber());
*
* @return the created <code>EscherContainerRecord</code> which holds shape data
*/
+ @Override
protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {
- _escherContainer = super.createSpContainer(idx, isChild);
+ EscherContainerRecord ecr = super.createSpContainer(idx, isChild);
setEscherProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x1000100);
setEscherProperty(EscherProperties.FILL__NOFILLHITTEST, 0x10001);
cldata.addChild(an);
cldata.addChild(info);
- return _escherContainer;
+ return ecr;
}
/**
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
import org.apache.poi.sl.usermodel.ShapeContainer;
+import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
* A shape representing embedded OLE obejct.
*/
public final class OLEShape extends HSLFPictureShape {
+ private static final POILogger LOG = POILogFactory.getLogger(OLEShape.class);
+
private ExEmbed _exEmbed;
/**
}
}
if (data==null) {
- logger.log(POILogger.WARN, "OLE data not found");
+ LOG.log(POILogger.WARN, "OLE data not found");
}
return data;
ExObjList lst = ppt.getDocumentRecord().getExObjList(false);
if(lst == null){
- logger.log(POILogger.WARN, "ExObjList not found");
+ LOG.log(POILogger.WARN, "ExObjList not found");
return null;
}
*/
public Polygon(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
super((EscherContainerRecord)null, parent);
- _escherContainer = createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof HSLFGroupShape);
+ createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof HSLFGroupShape);
}
/**
public HSLFAutoShape(ShapeType type, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
super(null, parent);
- _escherContainer = createSpContainer(type, parent instanceof HSLFGroupShape);
+ createSpContainer(type, parent instanceof HSLFGroupShape);
}
public HSLFAutoShape(ShapeType type){
}
protected EscherContainerRecord createSpContainer(ShapeType shapeType, boolean isChild){
- _escherContainer = super.createSpContainer(isChild);
+ EscherContainerRecord ecr = super.createSpContainer(isChild);
setShapeType(shapeType);
setEscherProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x80008);
setEscherProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
- return _escherContainer;
+ return ecr;
}
+ @Override
protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){
setVerticalAlignment(VerticalAlignment.MIDDLE);
setHorizontalCentered(true);
*/\r
public HSLFConnectorShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){\r
super(null, parent);\r
- _escherContainer = createSpContainer(parent instanceof HSLFGroupShape);\r
+ createSpContainer(parent instanceof HSLFGroupShape);\r
}\r
\r
/**\r
import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.Units;
* </p>
*/
public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformShape<HSLFShape,HSLFTextParagraph> {
+ private static final POILogger LOG = POILogFactory.getLogger(HSLFFreeformShape.class);
public static final byte[] SEGMENTINFO_MOVETO = new byte[]{0x00, 0x40};
public static final byte[] SEGMENTINFO_LINETO = new byte[]{0x00, (byte)0xAC};
*/
public HSLFFreeformShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
super((EscherContainerRecord)null, parent);
- _escherContainer = createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof HSLFGroupShape);
+ createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof HSLFGroupShape);
}
/**
break;
case PathIterator.SEG_QUADTO:
//TODO: figure out how to convert SEG_QUADTO into SEG_CUBICTO
- logger.log(POILogger.WARN, "SEG_QUADTO is not supported");
+ LOG.log(POILogger.WARN, "SEG_QUADTO is not supported");
break;
case PathIterator.SEG_CLOSE:
pntInfo.add(pntInfo.get(0));
numPoints++;
break;
default:
- logger.log(POILogger.WARN, "Ignoring invalid segment type "+type);
+ LOG.log(POILogger.WARN, "Ignoring invalid segment type "+type);
break;
}
//sanity check
if(verticesProp == null) {
- logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__VERTICES ");
+ LOG.log(POILogger.WARN, "Freeform is missing GEOMETRY__VERTICES ");
return path;
}
if(segmentsProp == null) {
- logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__SEGMENTINFO ");
+ LOG.log(POILogger.WARN, "Freeform is missing GEOMETRY__SEGMENTINFO ");
return path;
}
int masterCnt = (xyMaster == null) ? 0 : xyMaster.length;
int pointCnt = (xyPoints == null) ? 0 : xyPoints.length;
if ((masterCnt != 4 && masterCnt != 8) || pointCnt != 2) {
- logger.log(POILogger.WARN, "Invalid number of master bytes for a single point - ignore point");
+ LOG.log(POILogger.WARN, "Invalid number of master bytes for a single point - ignore point");
return;
}
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.Units;
*/
public class HSLFGroupShape extends HSLFShape
implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
+ private static final POILogger LOG = POILogFactory.getLogger(HSLFGroupShape.class);
+
/**
* Create a new ShapeGroup. This constructor is used when a new shape is created.
*
*/
public HSLFGroupShape(){
this(null, null);
- _escherContainer = createSpContainer(false);
+ createSpContainer(false);
}
/**
*/
public HSLFGroupShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
this(null, parent);
- _escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
+ createSpContainer(parent instanceof HSLFGroupShape);
}
/**
/**
* Create a new ShapeGroup and create an instance of <code>EscherSpgrContainer</code> which represents a group of shapes
*/
+ @Override
protected EscherContainerRecord createSpContainer(boolean isChild) {
- EscherContainerRecord spgr = new EscherContainerRecord();
- spgr.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
- spgr.setOptions((short)15);
+ EscherContainerRecord ecr = super.createSpContainer(isChild);
+ ecr.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
//The group itself is a shape, and always appears as the first EscherSpContainer in the group container.
EscherContainerRecord spcont = new EscherContainerRecord();
EscherClientAnchorRecord anchor = new EscherClientAnchorRecord();
spcont.addChildRecord(anchor);
- spgr.addChildRecord(spcont);
- return spgr;
+ ecr.addChildRecord(spcont);
+ return ecr;
}
/**
*
* @param shape - the Shape to add
*/
+ @Override
public void addShape(HSLFShape shape){
- _escherContainer.addChildRecord(shape.getSpContainer());
+ getSpContainer().addChildRecord(shape.getSpContainer());
HSLFSheet sheet = getSheet();
shape.setSheet(sheet);
*
* @return the anchor of this shape group
*/
+ @Override
public Rectangle2D getAnchor(){
EscherClientAnchorRecord clientAnchor = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
int x1,y1,x2,y2;
if(clientAnchor == null){
- logger.log(POILogger.INFO, "EscherClientAnchorRecord was not found for shape group. Searching for EscherChildAnchorRecord.");
+ LOG.log(POILogger.INFO, "EscherClientAnchorRecord was not found for shape group. Searching for EscherChildAnchorRecord.");
EscherChildAnchorRecord rec = getEscherChild(EscherChildAnchorRecord.RECORD_ID);
x1 = rec.getDx1();
y1 = rec.getDy1();
*
* @return type of the shape.
*/
+ @Override
public ShapeType getShapeType(){
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
int nativeId = spRecord.getOptions() >> 4;
@Override
public <T extends EscherRecord> T getEscherChild(int recordId){
- EscherContainerRecord groupInfoContainer = (EscherContainerRecord)_escherContainer.getChild(0);
+ EscherContainerRecord groupInfoContainer = (EscherContainerRecord)getSpContainer().getChild(0);
return groupInfoContainer.getChildById((short)recordId);
}
+ @Override
public Iterator<HSLFShape> iterator() {
return getShapes().iterator();
}
+ @Override
public boolean removeShape(HSLFShape shape) {
// TODO: implement!
throw new UnsupportedOperationException();
public List<HSLFShape> getShapes() {
// Out escher container record should contain several
// SpContainers, the first of which is the group shape itself
- Iterator<EscherRecord> iter = _escherContainer.getChildIterator();
+ Iterator<EscherRecord> iter = getSpContainer().getChildIterator();
// Don't include the first SpContainer, it is always NotPrimitive
if (iter.hasNext()) {
} else {
// Should we do anything special with these non
// Container records?
- logger.log(POILogger.ERROR, "Shape contained non container escher record, was " + r.getClass().getName());
+ LOG.log(POILogger.ERROR, "Shape contained non container escher record, was " + r.getClass().getName());
}
}
public HSLFLine(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
super(null, parent);
- _escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
+ createSpContainer(parent instanceof HSLFGroupShape);
}
public HSLFLine(){
this(null);
}
+ @Override
protected EscherContainerRecord createSpContainer(boolean isChild){
- _escherContainer = super.createSpContainer(isChild);
+ EscherContainerRecord ecr = super.createSpContainer(isChild);
setShapeType(ShapeType.LINE);
- EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
+ EscherSpRecord spRecord = ecr.getChildById(EscherSpRecord.RECORD_ID);
short type = (short)((ShapeType.LINE.nativeId << 4) | 0x2);
spRecord.setOptions(type);
setEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0xA0008);
setEscherProperty(opt, EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
- return _escherContainer;
+ return ecr;
}
// /**
import org.apache.poi.sl.usermodel.PictureShape;
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
+import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.StringUtil;
import org.apache.poi.util.Units;
/**
* Represents a picture in a PowerPoint document.
- *
- * @author Yegor Kozlov
*/
public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HSLFShape,HSLFTextParagraph> {
+ private static final POILogger LOG = POILogFactory.getLogger(HSLFPictureShape.class);
/**
* Create a new <code>Picture</code>
*/
public HSLFPictureShape(HSLFPictureData data, ShapeContainer<HSLFShape,HSLFTextParagraph> parent) {
super(null, parent);
- _escherContainer = createSpContainer(data.getIndex(), parent instanceof HSLFGroupShape);
+ createSpContainer(data.getIndex(), parent instanceof HSLFGroupShape);
}
/**
* @return the create Picture object
*/
protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {
- _escherContainer = super.createSpContainer(isChild);
- _escherContainer.setOptions((short)15);
+ EscherContainerRecord ecr = super.createSpContainer(isChild);
- EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
+ EscherSpRecord spRecord = ecr.getChildById(EscherSpRecord.RECORD_ID);
spRecord.setOptions((short)((ShapeType.FRAME.nativeId << 4) | 0x2));
//set default properties for a picture
//another weird feature of powerpoint: for picture id we must add 0x4000.
setEscherProperty(opt, (short)(EscherProperties.BLIP__BLIPTODISPLAY + 0x4000), idx);
- return _escherContainer;
+ return ecr;
}
@SuppressWarnings("resource")
EscherBSERecord bse = getEscherBSERecord();
if (bse == null){
- logger.log(POILogger.ERROR, "no reference to picture data found ");
+ LOG.log(POILogger.ERROR, "no reference to picture data found ");
} else {
for (HSLFPictureData pd : pict) {
if (pd.getOffset() == bse.getOffset()){
return pd;
}
}
- logger.log(POILogger.ERROR, "no picture found for our BSE offset " + bse.getOffset());
+ LOG.log(POILogger.ERROR, "no picture found for our BSE offset " + bse.getOffset());
}
return null;
}
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
if(bstore == null) {
- logger.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
+ LOG.log(POILogger.DEBUG, "EscherContainerRecord.BSTORE_CONTAINER was not found ");
return null;
}
List<EscherRecord> lst = bstore.getChildRecords();
int idx = getPictureIndex();
if (idx == 0){
- logger.log(POILogger.DEBUG, "picture index was not found, returning ");
+ LOG.log(POILogger.DEBUG, "picture index was not found, returning ");
return null;
}
return (EscherBSERecord)lst.get(idx-1);
/**
* By default set the orininal image size
*/
+ @Override
protected void afterInsert(HSLFSheet sh){
super.afterInsert(sh);
*
* @return the created <code>EscherContainerRecord</code> which holds shape data
*/
+ @Override
protected EscherContainerRecord createSpContainer(boolean isChild){
- _escherContainer = super.createSpContainer(isChild);
+ EscherContainerRecord ecr = super.createSpContainer(isChild);
setPlaceholder(Placeholder.BODY);
- return _escherContainer;
+ return ecr;
}
}
import org.apache.poi.ddf.AbstractEscherOptRecord;
import org.apache.poi.ddf.EscherChildAnchorRecord;
import org.apache.poi.ddf.EscherClientAnchorRecord;
+import org.apache.poi.ddf.EscherClientDataRecord;
import org.apache.poi.ddf.EscherColorRef;
import org.apache.poi.ddf.EscherColorRef.SysIndexProcedure;
import org.apache.poi.ddf.EscherColorRef.SysIndexSource;
* <p>
*/
public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
-
- // For logging
- protected POILogger logger = POILogFactory.getLogger(this.getClass());
+ private static final POILogger LOG = POILogFactory.getLogger(HSLFShape.class);
/**
* Either EscherSpContainer or EscheSpgrContainer record
* which holds information about this shape.
*/
- protected EscherContainerRecord _escherContainer;
+ private EscherContainerRecord _escherContainer;
/**
* Parent of this shape.
* <code>null</code> for the topmost shapes.
*/
- protected ShapeContainer<HSLFShape,HSLFTextParagraph> _parent;
+ private ShapeContainer<HSLFShape,HSLFTextParagraph> _parent;
/**
* The <code>Sheet</code> this shape belongs to
*/
- protected HSLFSheet _sheet;
+ private HSLFSheet _sheet;
/**
* Fill
*/
- protected HSLFFill _fill;
+ private HSLFFill _fill;
/**
* Create a Shape object. This constructor is used when an existing Shape is read from from a PowerPoint document.
}
/**
- * Creates the lowerlevel escher records for this shape.
+ * Create and assign the lower level escher record to this shape
*/
- protected abstract EscherContainerRecord createSpContainer(boolean isChild);
+ protected EscherContainerRecord createSpContainer(boolean isChild) {
+ if (_escherContainer == null) {
+ _escherContainer = new EscherContainerRecord();
+ _escherContainer.setOptions((short)15);
+ }
+ return _escherContainer;
+ }
/**
* @return the parent of this shape
*/
+ @Override
public ShapeContainer<HSLFShape,HSLFTextParagraph> getParent(){
return _parent;
}
*
* @return the anchor of this shape
*/
+ @Override
public Rectangle2D getAnchor() {
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
int flags = spRecord.getFlags();
y2 = childRec.getDy2();
} else {
if (useChildRec) {
- logger.log(POILogger.WARN, "EscherSpRecord.FLAG_CHILD is set but EscherChildAnchorRecord was not found");
+ LOG.log(POILogger.WARN, "EscherSpRecord.FLAG_CHILD is set but EscherChildAnchorRecord was not found");
}
EscherClientAnchorRecord clientRec = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
x1 = clientRec.getCol1();
/**
* @return the <code>SlideShow</code> this shape belongs to
*/
+ @Override
public HSLFSheet getSheet(){
return _sheet;
}
* @return the client record or null if it was missing and create wasn't activated
*/
protected HSLFEscherClientDataRecord getClientData(boolean create) {
- HSLFEscherClientDataRecord clientData = getEscherChild(HSLFEscherClientDataRecord.RECORD_ID);
+ HSLFEscherClientDataRecord clientData = getEscherChild(EscherClientDataRecord.RECORD_ID);
if (clientData == null && create) {
clientData = new HSLFEscherClientDataRecord();
clientData.setOptions((short)15);
- clientData.setRecordId(HSLFEscherClientDataRecord.RECORD_ID);
+ clientData.setRecordId(EscherClientDataRecord.RECORD_ID);
getSpContainer().addChildBefore(clientData, EscherTextboxRecord.RECORD_ID);
}
return clientData;
import org.apache.poi.sl.usermodel.StrokeStyle.LineCompound;
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.Units;
/**
* An abstract simple (non-group) shape.
* This is the parent class for all primitive shapes like Line, Rectangle, etc.
- *
- * @author Yegor Kozlov
*/
public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<HSLFShape,HSLFTextParagraph> {
+ private static final POILogger LOG = POILogFactory.getLogger(HSLFSimpleShape.class);
public final static double DEFAULT_LINE_WIDTH = 0.75;
* @param isChild <code>true</code> if the Line is inside a group, <code>false</code> otherwise
* @return the record container which holds this shape
*/
+ @Override
protected EscherContainerRecord createSpContainer(boolean isChild) {
- _escherContainer = new EscherContainerRecord();
- _escherContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
- _escherContainer.setOptions((short)15);
+ EscherContainerRecord ecr = super.createSpContainer(isChild);
+ ecr.setRecordId( EscherContainerRecord.SP_CONTAINER );
EscherSpRecord sp = new EscherSpRecord();
int flags = EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE;
- if (isChild) flags |= EscherSpRecord.FLAG_CHILD;
+ if (isChild) {
+ flags |= EscherSpRecord.FLAG_CHILD;
+ }
sp.setFlags(flags);
- _escherContainer.addChildRecord(sp);
+ ecr.addChildRecord(sp);
AbstractEscherOptRecord opt = new EscherOptRecord();
opt.setRecordId(EscherOptRecord.RECORD_ID);
- _escherContainer.addChildRecord(opt);
+ ecr.addChildRecord(opt);
EscherRecord anchor;
if(isChild) {
LittleEndian.putInt(header, 4, 8);
anchor.fillFields(header, 0, null);
}
- _escherContainer.addChildRecord(anchor);
+ ecr.addChildRecord(anchor);
- return _escherContainer;
+ return ecr;
}
/**
*
* @return style of the line.
*/
+ @Override
public StrokeStyle getStrokeStyle(){
return new StrokeStyle() {
+ @Override
public PaintStyle getPaint() {
return DrawPaint.createSolidPaint(HSLFSimpleShape.this.getLineColor());
}
+ @Override
public LineCap getLineCap() {
return null;
}
+ @Override
public LineDash getLineDash() {
return HSLFSimpleShape.this.getLineDash();
}
+ @Override
public LineCompound getLineCompound() {
return HSLFSimpleShape.this.getLineCompound();
}
+ @Override
public double getLineWidth() {
return HSLFSimpleShape.this.getLineWidth();
}
getFill().setForegroundColor(color);
}
+ @Override
public Guide getAdjustValue(String name) {
if (name == null || !name.matches("adj([1-9]|10)?")) {
- logger.log(POILogger.INFO, "Adjust value '"+name+"' not supported. Using default value.");
+ LOG.log(POILogger.INFO, "Adjust value '"+name+"' not supported. Using default value.");
return null;
}
return (adjval == -1) ? null : new Guide(name, "val "+adjval);
}
+ @Override
public CustomGeometry getGeometry() {
PresetGeometries dict = PresetGeometries.getInstance();
ShapeType st = getShapeType();
if (name == null) {
name = (st != null) ? st.toString() : "<unknown>";
}
- logger.log(POILogger.WARN, "No preset shape definition for shapeType: "+name);
+ LOG.log(POILogger.WARN, "No preset shape definition for shapeType: "+name);
}
return geom;
return clr == null ? Color.black : clr;
}
+ @Override
public Shadow<HSLFShape,HSLFTextParagraph> getShadow() {
AbstractEscherOptRecord opt = getEscherOptRecord();
if (opt == null) return null;
if (shadowType == null) return null;
return new Shadow<HSLFShape,HSLFTextParagraph>(){
+ @Override
public SimpleShape<HSLFShape,HSLFTextParagraph> getShadowParent() {
return HSLFSimpleShape.this;
}
+ @Override
public double getDistance() {
return getShadowDistance();
}
+ @Override
public double getAngle() {
return getShadowAngle();
}
+ @Override
public double getBlur() {
// TODO Auto-generated method stub
return 0;
}
+ @Override
public SolidPaint getFillStyle() {
return DrawPaint.createSolidPaint(getShadowColor());
}
+ @Override
public LineDecoration getLineDecoration() {
return new LineDecoration() {
+ @Override
public DecorationShape getHeadShape() {
return HSLFSimpleShape.this.getLineHeadDecoration();
}
+ @Override
public DecorationSize getHeadWidth() {
return HSLFSimpleShape.this.getLineHeadWidth();
}
+ @Override
public DecorationSize getHeadLength() {
return HSLFSimpleShape.this.getLineHeadLength();
}
+ @Override
public DecorationShape getTailShape() {
return HSLFSimpleShape.this.getLineTailDecoration();
}
+ @Override
public DecorationSize getTailWidth() {
return HSLFSimpleShape.this.getLineTailWidth();
}
+ @Override
public DecorationSize getTailLength() {
return HSLFSimpleShape.this.getLineTailLength();
}
return cells.length;
}
+ @Override
protected void afterInsert(HSLFSheet sh){
super.afterInsert(sh);
*
* @param sheet owner of this shape
*/
+ @Override
public void setSheet(HSLFSheet sheet){
super.setSheet(sheet);
if (cells == null) {
//_txtrun.getRichTextRuns()[0].setFlag(false, 0, false);
}
+ @Override
protected EscherContainerRecord createSpContainer(boolean isChild){
- _escherContainer = super.createSpContainer(isChild);
+ EscherContainerRecord ecr = super.createSpContainer(isChild);
AbstractEscherOptRecord opt = getEscherOptRecord();
setEscherProperty(opt, EscherProperties.TEXT__TEXTID, 0);
setEscherProperty(opt, EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x20000);
setEscherProperty(opt, EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x20000);
setEscherProperty(opt, EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x40000);
- return _escherContainer;
+ return ecr;
}
private void anchorBorder(BorderEdge edge, final HSLFLine line) {
line.setAnchor(new Rectangle2D.Double(x,y,w,h));
}
+ @Override
public void setAnchor(Rectangle2D anchor){
super.setAnchor(anchor);
public StrokeStyle getBorderStyle(final BorderEdge edge) {
final Double width = getBorderWidth(edge);
return (width == null) ? null : new StrokeStyle() {
+ @Override
public PaintStyle getPaint() {
return DrawPaint.createSolidPaint(getBorderColor(edge));
}
+ @Override
public LineCap getLineCap() {
return null;
}
+ @Override
public LineDash getLineDash() {
return getBorderDash(edge);
}
+ @Override
public LineCompound getLineCompound() {
return getBorderCompound(edge);
}
+ @Override
public double getLineWidth() {
return width;
}
*
* @return the created <code>EscherContainerRecord</code> which holds shape data
*/
+ @Override
protected EscherContainerRecord createSpContainer(boolean isChild){
- _escherContainer = super.createSpContainer(isChild);
+ EscherContainerRecord ecr = super.createSpContainer(isChild);
setShapeType(ShapeType.TEXT_BOX);
// init paragraphs
getTextParagraphs();
- return _escherContainer;
+ return ecr;
}
+ @Override
protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){
setVerticalAlignment(VerticalAlignment.TOP);
setEscherProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x20002);
import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.TextShape;
import org.apache.poi.sl.usermodel.VerticalAlignment;
+import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
import org.apache.poi.util.Units;
*/
public abstract class HSLFTextShape extends HSLFSimpleShape
implements TextShape<HSLFShape,HSLFTextParagraph> {
+ private static final POILogger LOG = POILogFactory.getLogger(HSLFTextShape.class);
/**
* How to anchor the text
*/
public HSLFTextShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
super(null, parent);
- _escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
+ createSpContainer(parent instanceof HSLFGroupShape);
}
/**
*
* @param sh the sheet we are adding to
*/
+ @Override
protected void afterInsert(HSLFSheet sh){
super.afterInsert(sh);
EscherTextboxWrapper thisTxtbox = getEscherTextboxWrapper();
if(thisTxtbox != null){
- _escherContainer.addChildRecord(thisTxtbox.getEscherRecord());
+ getSpContainer().addChildRecord(thisTxtbox.getEscherRecord());
PPDrawing ppdrawing = sh.getPPDrawing();
ppdrawing.addTextboxWrapper(thisTxtbox);
public Rectangle2D resizeToFitText(){
Rectangle2D anchor = getAnchor();
if(anchor.getWidth() == 0.) {
- logger.log(POILogger.WARN, "Width of shape wasn't set. Defaulting to 200px");
+ LOG.log(POILogger.WARN, "Width of shape wasn't set. Defaulting to 200px");
anchor.setRect(anchor.getX(), anchor.getY(), 200., anchor.getHeight());
setAnchor(anchor);
}
}
if (_paragraphs.isEmpty()) {
- logger.log(POILogger.WARN, "TextRecord didn't contained any text lines");
+ LOG.log(POILogger.WARN, "TextRecord didn't contained any text lines");
}
}
return _paragraphs;
}
+ @Override
public void setSheet(HSLFSheet sheet) {
- _sheet = sheet;
+ super.setSheet(sheet);
// Initialize _txtrun object.
// (We can't do it in the constructor because the sheet