SonarCube fix - make members private

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1773495 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2016-12-10 00:40:37 +00:00
parent ac92d7bc0a
commit f27507244c
17 changed files with 145 additions and 83 deletions

View File

@ -41,9 +41,6 @@ import org.apache.poi.util.StringUtil;
/**
* 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;
@ -74,10 +71,11 @@ public final class ActiveXShape extends HSLFPictureShape {
*
* @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);
@ -90,7 +88,7 @@ public final class ActiveXShape extends HSLFPictureShape {
HSLFEscherClientDataRecord cldata = getClientData(true);
cldata.addChild(new ExObjRefAtom());
return _escherContainer;
return ecr;
}
/**
@ -148,6 +146,7 @@ public final class ActiveXShape extends HSLFPictureShape {
return ctrl;
}
@Override
protected void afterInsert(HSLFSheet sheet){
ExControl ctrl = getExControl();
ctrl.getExControlAtom().setSlideId(sheet._getSheetNumber());

View File

@ -86,8 +86,9 @@ public final class MovieShape extends HSLFPictureShape {
*
* @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);
@ -107,7 +108,7 @@ public final class MovieShape extends HSLFPictureShape {
cldata.addChild(an);
cldata.addChild(info);
return _escherContainer;
return ecr;
}
/**

View File

@ -33,6 +33,7 @@ import org.apache.poi.hslf.usermodel.HSLFShape;
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;
@ -40,6 +41,8 @@ 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;
/**
@ -133,7 +136,7 @@ public final class OLEShape extends HSLFPictureShape {
}
}
if (data==null) {
logger.log(POILogger.WARN, "OLE data not found");
LOG.log(POILogger.WARN, "OLE data not found");
}
return data;
@ -160,7 +163,7 @@ public final class OLEShape extends HSLFPictureShape {
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;
}

View File

@ -51,7 +51,7 @@ public final class Polygon extends HSLFAutoShape {
*/
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);
}
/**

View File

@ -39,7 +39,7 @@ public class HSLFAutoShape extends HSLFTextShape implements AutoShape<HSLFShape,
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){
@ -47,7 +47,7 @@ public class HSLFAutoShape extends HSLFTextShape implements AutoShape<HSLFShape,
}
protected EscherContainerRecord createSpContainer(ShapeType shapeType, boolean isChild){
_escherContainer = super.createSpContainer(isChild);
EscherContainerRecord ecr = super.createSpContainer(isChild);
setShapeType(shapeType);
@ -61,9 +61,10 @@ public class HSLFAutoShape extends HSLFTextShape implements AutoShape<HSLFShape,
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);

View File

@ -52,7 +52,7 @@ implements ConnectorShape<HSLFShape,HSLFTextParagraph> {
*/
public HSLFConnectorShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
super(null, parent);
_escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
createSpContainer(parent instanceof HSLFGroupShape);
}
/**

View File

@ -38,6 +38,7 @@ import org.apache.poi.sl.usermodel.ShapeType;
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;
@ -50,6 +51,7 @@ 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};
@ -167,7 +169,7 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
*/
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);
}
/**
@ -212,7 +214,7 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
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));
@ -224,7 +226,7 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
numPoints++;
break;
default:
logger.log(POILogger.WARN, "Ignoring invalid segment type "+type);
LOG.log(POILogger.WARN, "Ignoring invalid segment type "+type);
break;
}
@ -281,11 +283,11 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
//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;
}
@ -358,7 +360,7 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
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;
}

View File

@ -33,6 +33,7 @@ import org.apache.poi.sl.usermodel.PictureData;
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;
@ -43,13 +44,15 @@ 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);
}
/**
@ -59,7 +62,7 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
*/
public HSLFGroupShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
this(null, parent);
_escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
createSpContainer(parent instanceof HSLFGroupShape);
}
/**
@ -133,10 +136,10 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
/**
* 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();
@ -156,8 +159,8 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
EscherClientAnchorRecord anchor = new EscherClientAnchorRecord();
spcont.addChildRecord(anchor);
spgr.addChildRecord(spcont);
return spgr;
ecr.addChildRecord(spcont);
return ecr;
}
/**
@ -165,8 +168,9 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
*
* @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);
@ -200,11 +204,12 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
*
* @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();
@ -232,6 +237,7 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
*
* @return type of the shape.
*/
@Override
public ShapeType getShapeType(){
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
int nativeId = spRecord.getOptions() >> 4;
@ -249,14 +255,16 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
@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();
@ -266,7 +274,7 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
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()) {
@ -284,7 +292,7 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
} 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());
}
}

View File

@ -37,19 +37,20 @@ public final class HSLFLine extends HSLFTextShape implements Line<HSLFShape,HSLF
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);
@ -64,7 +65,7 @@ public final class HSLFLine extends HSLFTextShape implements Line<HSLFShape,HSLF
setEscherProperty(opt, EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0xA0008);
setEscherProperty(opt, EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
return _escherContainer;
return ecr;
}
// /**

View File

@ -34,6 +34,7 @@ import org.apache.poi.sl.draw.DrawPictureShape;
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;
@ -41,10 +42,9 @@ 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>
@ -63,7 +63,7 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HS
*/
public HSLFPictureShape(HSLFPictureData data, ShapeContainer<HSLFShape,HSLFTextParagraph> parent) {
super(null, parent);
_escherContainer = createSpContainer(data.getIndex(), parent instanceof HSLFGroupShape);
createSpContainer(data.getIndex(), parent instanceof HSLFGroupShape);
}
/**
@ -97,10 +97,9 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HS
* @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
@ -110,7 +109,7 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HS
//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")
@ -121,14 +120,14 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HS
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;
}
@ -140,13 +139,13 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HS
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);
@ -180,6 +179,7 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HS
/**
* By default set the orininal image size
*/
@Override
protected void afterInsert(HSLFSheet sh){
super.afterInsert(sh);

View File

@ -45,11 +45,12 @@ public final class HSLFPlaceholder extends HSLFTextBox {
*
* @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;
}
}

View File

@ -26,6 +26,7 @@ import java.util.List;
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;
@ -65,31 +66,29 @@ import org.apache.poi.util.Units;
* <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.
@ -103,13 +102,20 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
}
/**
* 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;
}
@ -138,6 +144,7 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
*
* @return the anchor of this shape
*/
@Override
public Rectangle2D getAnchor() {
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
int flags = spRecord.getFlags();
@ -151,7 +158,7 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
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();
@ -329,6 +336,7 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
/**
* @return the <code>SlideShow</code> this shape belongs to
*/
@Override
public HSLFSheet getSheet(){
return _sheet;
}
@ -639,11 +647,11 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
* @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;

View File

@ -54,16 +54,16 @@ import org.apache.poi.sl.usermodel.StrokeStyle.LineCap;
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;
@ -88,20 +88,22 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
* @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) {
@ -117,9 +119,9 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
LittleEndian.putInt(header, 4, 8);
anchor.fillFields(header, 0, null);
}
_escherContainer.addChildRecord(anchor);
ecr.addChildRecord(anchor);
return _escherContainer;
return ecr;
}
/**
@ -268,24 +270,30 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
*
* @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();
}
@ -303,9 +311,10 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
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;
}
@ -337,6 +346,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
return (adjval == -1) ? null : new Guide(name, "val "+adjval);
}
@Override
public CustomGeometry getGeometry() {
PresetGeometries dict = PresetGeometries.getInstance();
ShapeType st = getShapeType();
@ -346,7 +356,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
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;
@ -379,6 +389,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
return clr == null ? Color.black : clr;
}
@Override
public Shadow<HSLFShape,HSLFTextParagraph> getShadow() {
AbstractEscherOptRecord opt = getEscherOptRecord();
if (opt == null) return null;
@ -386,23 +397,28 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
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());
}
@ -478,29 +494,36 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
@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();
}

View File

@ -147,6 +147,7 @@ implements HSLFShapeContainer, TableShape<HSLFShape,HSLFTextParagraph> {
return cells.length;
}
@Override
protected void afterInsert(HSLFSheet sh){
super.afterInsert(sh);
@ -335,6 +336,7 @@ implements HSLFShapeContainer, TableShape<HSLFShape,HSLFTextParagraph> {
*
* @param sheet owner of this shape
*/
@Override
public void setSheet(HSLFSheet sheet){
super.setSheet(sheet);
if (cells == null) {

View File

@ -77,8 +77,9 @@ public final class HSLFTableCell extends HSLFTextBox implements TableCell<HSLFSh
//_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);
@ -86,7 +87,7 @@ public final class HSLFTableCell extends HSLFTextBox implements TableCell<HSLFSh
setEscherProperty(opt, EscherProperties.SHADOWSTYLE__SHADOWOBSURED, 0x20000);
setEscherProperty(opt, EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x40000);
return _escherContainer;
return ecr;
}
private void anchorBorder(BorderEdge edge, final HSLFLine line) {
@ -126,6 +127,7 @@ public final class HSLFTableCell extends HSLFTextBox implements TableCell<HSLFSh
line.setAnchor(new Rectangle2D.Double(x,y,w,h));
}
@Override
public void setAnchor(Rectangle2D anchor){
super.setAnchor(anchor);
@ -139,22 +141,27 @@ public final class HSLFTableCell extends HSLFTextBox implements TableCell<HSLFSh
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;
}

View File

@ -69,8 +69,9 @@ public class HSLFTextBox extends HSLFTextShape implements TextBox<HSLFShape,HSLF
*
* @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);
@ -85,9 +86,10 @@ public class HSLFTextBox extends HSLFTextShape implements TextBox<HSLFShape,HSLF
// 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);

View File

@ -46,6 +46,7 @@ import org.apache.poi.sl.usermodel.Placeholder;
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;
@ -54,6 +55,7 @@ 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
@ -161,7 +163,7 @@ implements TextShape<HSLFShape,HSLFTextParagraph> {
*/
public HSLFTextShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
super(null, parent);
_escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
createSpContainer(parent instanceof HSLFGroupShape);
}
/**
@ -189,6 +191,7 @@ implements TextShape<HSLFShape,HSLFTextParagraph> {
*
* @param sh the sheet we are adding to
*/
@Override
protected void afterInsert(HSLFSheet sh){
super.afterInsert(sh);
@ -196,7 +199,7 @@ implements TextShape<HSLFShape,HSLFTextParagraph> {
EscherTextboxWrapper thisTxtbox = getEscherTextboxWrapper();
if(thisTxtbox != null){
_escherContainer.addChildRecord(thisTxtbox.getEscherRecord());
getSpContainer().addChildRecord(thisTxtbox.getEscherRecord());
PPDrawing ppdrawing = sh.getPPDrawing();
ppdrawing.addTextboxWrapper(thisTxtbox);
@ -253,7 +256,7 @@ implements TextShape<HSLFShape,HSLFTextParagraph> {
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);
}
@ -573,7 +576,7 @@ implements TextShape<HSLFShape,HSLFTextParagraph> {
}
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");
}
}
@ -584,8 +587,9 @@ implements TextShape<HSLFShape,HSLFTextParagraph> {
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