diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2016-12-10 00:40:37 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2016-12-10 00:40:37 +0000 |
commit | ba95cb6fdb3705944cbe6acfb4cbf319f7f8f0ec (patch) | |
tree | 6bbbbd00f380b0e06ea70d8e3e00658ceeef12c5 /src | |
parent | 5e7d960a359a0145c2a6b8971fbd8c5bd43e2fe8 (diff) | |
download | poi-ba95cb6fdb3705944cbe6acfb4cbf319f7f8f0ec.tar.gz poi-ba95cb6fdb3705944cbe6acfb4cbf319f7f8f0ec.zip |
SonarCube fix - make members private
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1773495 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
17 files changed, 145 insertions, 83 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java index 3ba8f6f2d6..d82555a809 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/ActiveXShape.java @@ -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()); diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java index 5650b2b2d8..4452e758c9 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/MovieShape.java @@ -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; } /** diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java b/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java index 13de06d41c..4a473ae737 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/OLEShape.java @@ -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; } diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java b/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java index 9c2cb24ed8..5a0b4bff11 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/Polygon.java @@ -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); } /** diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFAutoShape.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFAutoShape.java index 329f78f423..910c8a0adc 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFAutoShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFAutoShape.java @@ -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); diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFConnectorShape.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFConnectorShape.java index 3c26c5a22d..b36d3fcf14 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFConnectorShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFConnectorShape.java @@ -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);
}
/**
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java index 0e8437ae1a..ee8c50a716 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFFreeformShape.java @@ -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; } diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java index bae325a0f9..bd90edfec4 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java @@ -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()); } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFLine.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFLine.java index 21706db40d..668b3e88ec 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFLine.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFLine.java @@ -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; } // /** diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureShape.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureShape.java index 6f8802d313..deee5e61fa 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPictureShape.java @@ -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); diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPlaceholder.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPlaceholder.java index 22b1d90abb..4b13300590 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPlaceholder.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPlaceholder.java @@ -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; } } diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java index 51fc33b70f..49b7ca5671 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java @@ -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; diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java index 8ca4678a29..d8352e5bf0 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java @@ -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(); } diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java index f007dd9877..62f3b877f3 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java @@ -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) { diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTableCell.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTableCell.java index a8e3294d1d..8477cadde0 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTableCell.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTableCell.java @@ -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; } diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextBox.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextBox.java index 3872ecf5b8..a76f98b3c3 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextBox.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextBox.java @@ -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); diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java index b26b3dfa24..2af4c07887 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java @@ -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 |