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:
parent
ac92d7bc0a
commit
f27507244c
@ -41,9 +41,6 @@ import org.apache.poi.util.StringUtil;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an ActiveX control in a PowerPoint document.
|
* Represents an ActiveX control in a PowerPoint document.
|
||||||
*
|
|
||||||
* TODO: finish
|
|
||||||
* @author Yegor Kozlov
|
|
||||||
*/
|
*/
|
||||||
public final class ActiveXShape extends HSLFPictureShape {
|
public final class ActiveXShape extends HSLFPictureShape {
|
||||||
public static final int DEFAULT_ACTIVEX_THUMBNAIL = -1;
|
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
|
* @return the created <code>EscherContainerRecord</code> which holds shape data
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {
|
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);
|
spRecord.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE | EscherSpRecord.FLAG_OLESHAPE);
|
||||||
|
|
||||||
setShapeType(ShapeType.HOST_CONTROL);
|
setShapeType(ShapeType.HOST_CONTROL);
|
||||||
@ -90,7 +88,7 @@ public final class ActiveXShape extends HSLFPictureShape {
|
|||||||
HSLFEscherClientDataRecord cldata = getClientData(true);
|
HSLFEscherClientDataRecord cldata = getClientData(true);
|
||||||
cldata.addChild(new ExObjRefAtom());
|
cldata.addChild(new ExObjRefAtom());
|
||||||
|
|
||||||
return _escherContainer;
|
return ecr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -148,6 +146,7 @@ public final class ActiveXShape extends HSLFPictureShape {
|
|||||||
return ctrl;
|
return ctrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void afterInsert(HSLFSheet sheet){
|
protected void afterInsert(HSLFSheet sheet){
|
||||||
ExControl ctrl = getExControl();
|
ExControl ctrl = getExControl();
|
||||||
ctrl.getExControlAtom().setSlideId(sheet._getSheetNumber());
|
ctrl.getExControlAtom().setSlideId(sheet._getSheetNumber());
|
||||||
|
@ -86,8 +86,9 @@ public final class MovieShape extends HSLFPictureShape {
|
|||||||
*
|
*
|
||||||
* @return the created <code>EscherContainerRecord</code> which holds shape data
|
* @return the created <code>EscherContainerRecord</code> which holds shape data
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {
|
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.PROTECTION__LOCKAGAINSTGROUPING, 0x1000100);
|
||||||
setEscherProperty(EscherProperties.FILL__NOFILLHITTEST, 0x10001);
|
setEscherProperty(EscherProperties.FILL__NOFILLHITTEST, 0x10001);
|
||||||
@ -107,7 +108,7 @@ public final class MovieShape extends HSLFPictureShape {
|
|||||||
cldata.addChild(an);
|
cldata.addChild(an);
|
||||||
cldata.addChild(info);
|
cldata.addChild(info);
|
||||||
|
|
||||||
return _escherContainer;
|
return ecr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,6 +33,7 @@ import org.apache.poi.hslf.usermodel.HSLFShape;
|
|||||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||||
import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
|
import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
|
||||||
import org.apache.poi.sl.usermodel.ShapeContainer;
|
import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||||
|
import org.apache.poi.util.POILogFactory;
|
||||||
import org.apache.poi.util.POILogger;
|
import org.apache.poi.util.POILogger;
|
||||||
|
|
||||||
|
|
||||||
@ -40,6 +41,8 @@ import org.apache.poi.util.POILogger;
|
|||||||
* A shape representing embedded OLE obejct.
|
* A shape representing embedded OLE obejct.
|
||||||
*/
|
*/
|
||||||
public final class OLEShape extends HSLFPictureShape {
|
public final class OLEShape extends HSLFPictureShape {
|
||||||
|
private static final POILogger LOG = POILogFactory.getLogger(OLEShape.class);
|
||||||
|
|
||||||
private ExEmbed _exEmbed;
|
private ExEmbed _exEmbed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,7 +136,7 @@ public final class OLEShape extends HSLFPictureShape {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data==null) {
|
if (data==null) {
|
||||||
logger.log(POILogger.WARN, "OLE data not found");
|
LOG.log(POILogger.WARN, "OLE data not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
@ -160,7 +163,7 @@ public final class OLEShape extends HSLFPictureShape {
|
|||||||
|
|
||||||
ExObjList lst = ppt.getDocumentRecord().getExObjList(false);
|
ExObjList lst = ppt.getDocumentRecord().getExObjList(false);
|
||||||
if(lst == null){
|
if(lst == null){
|
||||||
logger.log(POILogger.WARN, "ExObjList not found");
|
LOG.log(POILogger.WARN, "ExObjList not found");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public final class Polygon extends HSLFAutoShape {
|
|||||||
*/
|
*/
|
||||||
public Polygon(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
|
public Polygon(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
|
||||||
super((EscherContainerRecord)null, parent);
|
super((EscherContainerRecord)null, parent);
|
||||||
_escherContainer = createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof HSLFGroupShape);
|
createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof HSLFGroupShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,7 @@ public class HSLFAutoShape extends HSLFTextShape implements AutoShape<HSLFShape,
|
|||||||
|
|
||||||
public HSLFAutoShape(ShapeType type, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
|
public HSLFAutoShape(ShapeType type, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
|
||||||
super(null, parent);
|
super(null, parent);
|
||||||
_escherContainer = createSpContainer(type, parent instanceof HSLFGroupShape);
|
createSpContainer(type, parent instanceof HSLFGroupShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HSLFAutoShape(ShapeType type){
|
public HSLFAutoShape(ShapeType type){
|
||||||
@ -47,7 +47,7 @@ public class HSLFAutoShape extends HSLFTextShape implements AutoShape<HSLFShape,
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected EscherContainerRecord createSpContainer(ShapeType shapeType, boolean isChild){
|
protected EscherContainerRecord createSpContainer(ShapeType shapeType, boolean isChild){
|
||||||
_escherContainer = super.createSpContainer(isChild);
|
EscherContainerRecord ecr = super.createSpContainer(isChild);
|
||||||
|
|
||||||
setShapeType(shapeType);
|
setShapeType(shapeType);
|
||||||
|
|
||||||
@ -61,9 +61,10 @@ public class HSLFAutoShape extends HSLFTextShape implements AutoShape<HSLFShape,
|
|||||||
setEscherProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x80008);
|
setEscherProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x80008);
|
||||||
setEscherProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
|
setEscherProperty(EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
|
||||||
|
|
||||||
return _escherContainer;
|
return ecr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){
|
protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){
|
||||||
setVerticalAlignment(VerticalAlignment.MIDDLE);
|
setVerticalAlignment(VerticalAlignment.MIDDLE);
|
||||||
setHorizontalCentered(true);
|
setHorizontalCentered(true);
|
||||||
|
@ -52,7 +52,7 @@ implements ConnectorShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
*/
|
*/
|
||||||
public HSLFConnectorShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
|
public HSLFConnectorShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
|
||||||
super(null, parent);
|
super(null, parent);
|
||||||
_escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
|
createSpContainer(parent instanceof HSLFGroupShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,6 +38,7 @@ import org.apache.poi.sl.usermodel.ShapeType;
|
|||||||
import org.apache.poi.util.BitField;
|
import org.apache.poi.util.BitField;
|
||||||
import org.apache.poi.util.BitFieldFactory;
|
import org.apache.poi.util.BitFieldFactory;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
import org.apache.poi.util.POILogFactory;
|
||||||
import org.apache.poi.util.POILogger;
|
import org.apache.poi.util.POILogger;
|
||||||
import org.apache.poi.util.Units;
|
import org.apache.poi.util.Units;
|
||||||
|
|
||||||
@ -50,6 +51,7 @@ import org.apache.poi.util.Units;
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformShape<HSLFShape,HSLFTextParagraph> {
|
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_MOVETO = new byte[]{0x00, 0x40};
|
||||||
public static final byte[] SEGMENTINFO_LINETO = new byte[]{0x00, (byte)0xAC};
|
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){
|
public HSLFFreeformShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
|
||||||
super((EscherContainerRecord)null, 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;
|
break;
|
||||||
case PathIterator.SEG_QUADTO:
|
case PathIterator.SEG_QUADTO:
|
||||||
//TODO: figure out how to convert SEG_QUADTO into SEG_CUBICTO
|
//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;
|
break;
|
||||||
case PathIterator.SEG_CLOSE:
|
case PathIterator.SEG_CLOSE:
|
||||||
pntInfo.add(pntInfo.get(0));
|
pntInfo.add(pntInfo.get(0));
|
||||||
@ -224,7 +226,7 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
|
|||||||
numPoints++;
|
numPoints++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.log(POILogger.WARN, "Ignoring invalid segment type "+type);
|
LOG.log(POILogger.WARN, "Ignoring invalid segment type "+type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,11 +283,11 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
|
|||||||
|
|
||||||
//sanity check
|
//sanity check
|
||||||
if(verticesProp == null) {
|
if(verticesProp == null) {
|
||||||
logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__VERTICES ");
|
LOG.log(POILogger.WARN, "Freeform is missing GEOMETRY__VERTICES ");
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
if(segmentsProp == null) {
|
if(segmentsProp == null) {
|
||||||
logger.log(POILogger.WARN, "Freeform is missing GEOMETRY__SEGMENTINFO ");
|
LOG.log(POILogger.WARN, "Freeform is missing GEOMETRY__SEGMENTINFO ");
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +360,7 @@ public final class HSLFFreeformShape extends HSLFAutoShape implements FreeformSh
|
|||||||
int masterCnt = (xyMaster == null) ? 0 : xyMaster.length;
|
int masterCnt = (xyMaster == null) ? 0 : xyMaster.length;
|
||||||
int pointCnt = (xyPoints == null) ? 0 : xyPoints.length;
|
int pointCnt = (xyPoints == null) ? 0 : xyPoints.length;
|
||||||
if ((masterCnt != 4 && masterCnt != 8) || pointCnt != 2) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ import org.apache.poi.sl.usermodel.PictureData;
|
|||||||
import org.apache.poi.sl.usermodel.ShapeContainer;
|
import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||||
import org.apache.poi.sl.usermodel.ShapeType;
|
import org.apache.poi.sl.usermodel.ShapeType;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
import org.apache.poi.util.POILogFactory;
|
||||||
import org.apache.poi.util.POILogger;
|
import org.apache.poi.util.POILogger;
|
||||||
import org.apache.poi.util.Units;
|
import org.apache.poi.util.Units;
|
||||||
|
|
||||||
@ -43,13 +44,15 @@ import org.apache.poi.util.Units;
|
|||||||
*/
|
*/
|
||||||
public class HSLFGroupShape extends HSLFShape
|
public class HSLFGroupShape extends HSLFShape
|
||||||
implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
|
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.
|
* Create a new ShapeGroup. This constructor is used when a new shape is created.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public HSLFGroupShape(){
|
public HSLFGroupShape(){
|
||||||
this(null, null);
|
this(null, null);
|
||||||
_escherContainer = createSpContainer(false);
|
createSpContainer(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +62,7 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
*/
|
*/
|
||||||
public HSLFGroupShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
|
public HSLFGroupShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
|
||||||
this(null, 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
|
* Create a new ShapeGroup and create an instance of <code>EscherSpgrContainer</code> which represents a group of shapes
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected EscherContainerRecord createSpContainer(boolean isChild) {
|
protected EscherContainerRecord createSpContainer(boolean isChild) {
|
||||||
EscherContainerRecord spgr = new EscherContainerRecord();
|
EscherContainerRecord ecr = super.createSpContainer(isChild);
|
||||||
spgr.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
|
ecr.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
|
||||||
spgr.setOptions((short)15);
|
|
||||||
|
|
||||||
//The group itself is a shape, and always appears as the first EscherSpContainer in the group container.
|
//The group itself is a shape, and always appears as the first EscherSpContainer in the group container.
|
||||||
EscherContainerRecord spcont = new EscherContainerRecord();
|
EscherContainerRecord spcont = new EscherContainerRecord();
|
||||||
@ -156,8 +159,8 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
EscherClientAnchorRecord anchor = new EscherClientAnchorRecord();
|
EscherClientAnchorRecord anchor = new EscherClientAnchorRecord();
|
||||||
spcont.addChildRecord(anchor);
|
spcont.addChildRecord(anchor);
|
||||||
|
|
||||||
spgr.addChildRecord(spcont);
|
ecr.addChildRecord(spcont);
|
||||||
return spgr;
|
return ecr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -165,8 +168,9 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
*
|
*
|
||||||
* @param shape - the Shape to add
|
* @param shape - the Shape to add
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void addShape(HSLFShape shape){
|
public void addShape(HSLFShape shape){
|
||||||
_escherContainer.addChildRecord(shape.getSpContainer());
|
getSpContainer().addChildRecord(shape.getSpContainer());
|
||||||
|
|
||||||
HSLFSheet sheet = getSheet();
|
HSLFSheet sheet = getSheet();
|
||||||
shape.setSheet(sheet);
|
shape.setSheet(sheet);
|
||||||
@ -200,11 +204,12 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
*
|
*
|
||||||
* @return the anchor of this shape group
|
* @return the anchor of this shape group
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Rectangle2D getAnchor(){
|
public Rectangle2D getAnchor(){
|
||||||
EscherClientAnchorRecord clientAnchor = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
|
EscherClientAnchorRecord clientAnchor = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
|
||||||
int x1,y1,x2,y2;
|
int x1,y1,x2,y2;
|
||||||
if(clientAnchor == null){
|
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);
|
EscherChildAnchorRecord rec = getEscherChild(EscherChildAnchorRecord.RECORD_ID);
|
||||||
x1 = rec.getDx1();
|
x1 = rec.getDx1();
|
||||||
y1 = rec.getDy1();
|
y1 = rec.getDy1();
|
||||||
@ -232,6 +237,7 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
*
|
*
|
||||||
* @return type of the shape.
|
* @return type of the shape.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ShapeType getShapeType(){
|
public ShapeType getShapeType(){
|
||||||
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
|
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
|
||||||
int nativeId = spRecord.getOptions() >> 4;
|
int nativeId = spRecord.getOptions() >> 4;
|
||||||
@ -249,14 +255,16 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends EscherRecord> T getEscherChild(int recordId){
|
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);
|
return groupInfoContainer.getChildById((short)recordId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Iterator<HSLFShape> iterator() {
|
public Iterator<HSLFShape> iterator() {
|
||||||
return getShapes().iterator();
|
return getShapes().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean removeShape(HSLFShape shape) {
|
public boolean removeShape(HSLFShape shape) {
|
||||||
// TODO: implement!
|
// TODO: implement!
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
@ -266,7 +274,7 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
public List<HSLFShape> getShapes() {
|
public List<HSLFShape> getShapes() {
|
||||||
// Out escher container record should contain several
|
// Out escher container record should contain several
|
||||||
// SpContainers, the first of which is the group shape itself
|
// 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
|
// Don't include the first SpContainer, it is always NotPrimitive
|
||||||
if (iter.hasNext()) {
|
if (iter.hasNext()) {
|
||||||
@ -284,7 +292,7 @@ implements HSLFShapeContainer, GroupShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
} else {
|
} else {
|
||||||
// Should we do anything special with these non
|
// Should we do anything special with these non
|
||||||
// Container records?
|
// 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,19 +37,20 @@ public final class HSLFLine extends HSLFTextShape implements Line<HSLFShape,HSLF
|
|||||||
|
|
||||||
public HSLFLine(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
|
public HSLFLine(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
|
||||||
super(null, parent);
|
super(null, parent);
|
||||||
_escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
|
createSpContainer(parent instanceof HSLFGroupShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HSLFLine(){
|
public HSLFLine(){
|
||||||
this(null);
|
this(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected EscherContainerRecord createSpContainer(boolean isChild){
|
protected EscherContainerRecord createSpContainer(boolean isChild){
|
||||||
_escherContainer = super.createSpContainer(isChild);
|
EscherContainerRecord ecr = super.createSpContainer(isChild);
|
||||||
|
|
||||||
setShapeType(ShapeType.LINE);
|
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);
|
short type = (short)((ShapeType.LINE.nativeId << 4) | 0x2);
|
||||||
spRecord.setOptions(type);
|
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.LINESTYLE__NOLINEDRAWDASH, 0xA0008);
|
||||||
setEscherProperty(opt, EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
|
setEscherProperty(opt, EscherProperties.SHADOWSTYLE__COLOR, 0x8000002);
|
||||||
|
|
||||||
return _escherContainer;
|
return ecr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
|
@ -34,6 +34,7 @@ import org.apache.poi.sl.draw.DrawPictureShape;
|
|||||||
import org.apache.poi.sl.usermodel.PictureShape;
|
import org.apache.poi.sl.usermodel.PictureShape;
|
||||||
import org.apache.poi.sl.usermodel.ShapeContainer;
|
import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||||
import org.apache.poi.sl.usermodel.ShapeType;
|
import org.apache.poi.sl.usermodel.ShapeType;
|
||||||
|
import org.apache.poi.util.POILogFactory;
|
||||||
import org.apache.poi.util.POILogger;
|
import org.apache.poi.util.POILogger;
|
||||||
import org.apache.poi.util.StringUtil;
|
import org.apache.poi.util.StringUtil;
|
||||||
import org.apache.poi.util.Units;
|
import org.apache.poi.util.Units;
|
||||||
@ -41,10 +42,9 @@ import org.apache.poi.util.Units;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a picture in a PowerPoint document.
|
* Represents a picture in a PowerPoint document.
|
||||||
*
|
|
||||||
* @author Yegor Kozlov
|
|
||||||
*/
|
*/
|
||||||
public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HSLFShape,HSLFTextParagraph> {
|
public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HSLFShape,HSLFTextParagraph> {
|
||||||
|
private static final POILogger LOG = POILogFactory.getLogger(HSLFPictureShape.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new <code>Picture</code>
|
* 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) {
|
public HSLFPictureShape(HSLFPictureData data, ShapeContainer<HSLFShape,HSLFTextParagraph> parent) {
|
||||||
super(null, 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
|
* @return the create Picture object
|
||||||
*/
|
*/
|
||||||
protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {
|
protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {
|
||||||
_escherContainer = super.createSpContainer(isChild);
|
EscherContainerRecord ecr = super.createSpContainer(isChild);
|
||||||
_escherContainer.setOptions((short)15);
|
|
||||||
|
|
||||||
EscherSpRecord spRecord = _escherContainer.getChildById(EscherSpRecord.RECORD_ID);
|
EscherSpRecord spRecord = ecr.getChildById(EscherSpRecord.RECORD_ID);
|
||||||
spRecord.setOptions((short)((ShapeType.FRAME.nativeId << 4) | 0x2));
|
spRecord.setOptions((short)((ShapeType.FRAME.nativeId << 4) | 0x2));
|
||||||
|
|
||||||
//set default properties for a picture
|
//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.
|
//another weird feature of powerpoint: for picture id we must add 0x4000.
|
||||||
setEscherProperty(opt, (short)(EscherProperties.BLIP__BLIPTODISPLAY + 0x4000), idx);
|
setEscherProperty(opt, (short)(EscherProperties.BLIP__BLIPTODISPLAY + 0x4000), idx);
|
||||||
|
|
||||||
return _escherContainer;
|
return ecr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
@ -121,14 +120,14 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HS
|
|||||||
|
|
||||||
EscherBSERecord bse = getEscherBSERecord();
|
EscherBSERecord bse = getEscherBSERecord();
|
||||||
if (bse == null){
|
if (bse == null){
|
||||||
logger.log(POILogger.ERROR, "no reference to picture data found ");
|
LOG.log(POILogger.ERROR, "no reference to picture data found ");
|
||||||
} else {
|
} else {
|
||||||
for (HSLFPictureData pd : pict) {
|
for (HSLFPictureData pd : pict) {
|
||||||
if (pd.getOffset() == bse.getOffset()){
|
if (pd.getOffset() == bse.getOffset()){
|
||||||
return pd;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
@ -140,13 +139,13 @@ public class HSLFPictureShape extends HSLFSimpleShape implements PictureShape<HS
|
|||||||
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
|
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
|
||||||
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
|
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
|
||||||
if(bstore == null) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
List<EscherRecord> lst = bstore.getChildRecords();
|
List<EscherRecord> lst = bstore.getChildRecords();
|
||||||
int idx = getPictureIndex();
|
int idx = getPictureIndex();
|
||||||
if (idx == 0){
|
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 null;
|
||||||
}
|
}
|
||||||
return (EscherBSERecord)lst.get(idx-1);
|
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
|
* By default set the orininal image size
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void afterInsert(HSLFSheet sh){
|
protected void afterInsert(HSLFSheet sh){
|
||||||
super.afterInsert(sh);
|
super.afterInsert(sh);
|
||||||
|
|
||||||
|
@ -45,11 +45,12 @@ public final class HSLFPlaceholder extends HSLFTextBox {
|
|||||||
*
|
*
|
||||||
* @return the created <code>EscherContainerRecord</code> which holds shape data
|
* @return the created <code>EscherContainerRecord</code> which holds shape data
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected EscherContainerRecord createSpContainer(boolean isChild){
|
protected EscherContainerRecord createSpContainer(boolean isChild){
|
||||||
_escherContainer = super.createSpContainer(isChild);
|
EscherContainerRecord ecr = super.createSpContainer(isChild);
|
||||||
|
|
||||||
setPlaceholder(Placeholder.BODY);
|
setPlaceholder(Placeholder.BODY);
|
||||||
|
|
||||||
return _escherContainer;
|
return ecr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||||||
import org.apache.poi.ddf.AbstractEscherOptRecord;
|
import org.apache.poi.ddf.AbstractEscherOptRecord;
|
||||||
import org.apache.poi.ddf.EscherChildAnchorRecord;
|
import org.apache.poi.ddf.EscherChildAnchorRecord;
|
||||||
import org.apache.poi.ddf.EscherClientAnchorRecord;
|
import org.apache.poi.ddf.EscherClientAnchorRecord;
|
||||||
|
import org.apache.poi.ddf.EscherClientDataRecord;
|
||||||
import org.apache.poi.ddf.EscherColorRef;
|
import org.apache.poi.ddf.EscherColorRef;
|
||||||
import org.apache.poi.ddf.EscherColorRef.SysIndexProcedure;
|
import org.apache.poi.ddf.EscherColorRef.SysIndexProcedure;
|
||||||
import org.apache.poi.ddf.EscherColorRef.SysIndexSource;
|
import org.apache.poi.ddf.EscherColorRef.SysIndexSource;
|
||||||
@ -65,31 +66,29 @@ import org.apache.poi.util.Units;
|
|||||||
* <p>
|
* <p>
|
||||||
*/
|
*/
|
||||||
public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
|
public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
|
||||||
|
private static final POILogger LOG = POILogFactory.getLogger(HSLFShape.class);
|
||||||
// For logging
|
|
||||||
protected POILogger logger = POILogFactory.getLogger(this.getClass());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Either EscherSpContainer or EscheSpgrContainer record
|
* Either EscherSpContainer or EscheSpgrContainer record
|
||||||
* which holds information about this shape.
|
* which holds information about this shape.
|
||||||
*/
|
*/
|
||||||
protected EscherContainerRecord _escherContainer;
|
private EscherContainerRecord _escherContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent of this shape.
|
* Parent of this shape.
|
||||||
* <code>null</code> for the topmost shapes.
|
* <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
|
* The <code>Sheet</code> this shape belongs to
|
||||||
*/
|
*/
|
||||||
protected HSLFSheet _sheet;
|
private HSLFSheet _sheet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fill
|
* 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.
|
* 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
|
* @return the parent of this shape
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public ShapeContainer<HSLFShape,HSLFTextParagraph> getParent(){
|
public ShapeContainer<HSLFShape,HSLFTextParagraph> getParent(){
|
||||||
return _parent;
|
return _parent;
|
||||||
}
|
}
|
||||||
@ -138,6 +144,7 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
|
|||||||
*
|
*
|
||||||
* @return the anchor of this shape
|
* @return the anchor of this shape
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Rectangle2D getAnchor() {
|
public Rectangle2D getAnchor() {
|
||||||
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
|
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
|
||||||
int flags = spRecord.getFlags();
|
int flags = spRecord.getFlags();
|
||||||
@ -151,7 +158,7 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
|
|||||||
y2 = childRec.getDy2();
|
y2 = childRec.getDy2();
|
||||||
} else {
|
} else {
|
||||||
if (useChildRec) {
|
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);
|
EscherClientAnchorRecord clientRec = getEscherChild(EscherClientAnchorRecord.RECORD_ID);
|
||||||
x1 = clientRec.getCol1();
|
x1 = clientRec.getCol1();
|
||||||
@ -329,6 +336,7 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
|
|||||||
/**
|
/**
|
||||||
* @return the <code>SlideShow</code> this shape belongs to
|
* @return the <code>SlideShow</code> this shape belongs to
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public HSLFSheet getSheet(){
|
public HSLFSheet getSheet(){
|
||||||
return _sheet;
|
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
|
* @return the client record or null if it was missing and create wasn't activated
|
||||||
*/
|
*/
|
||||||
protected HSLFEscherClientDataRecord getClientData(boolean create) {
|
protected HSLFEscherClientDataRecord getClientData(boolean create) {
|
||||||
HSLFEscherClientDataRecord clientData = getEscherChild(HSLFEscherClientDataRecord.RECORD_ID);
|
HSLFEscherClientDataRecord clientData = getEscherChild(EscherClientDataRecord.RECORD_ID);
|
||||||
if (clientData == null && create) {
|
if (clientData == null && create) {
|
||||||
clientData = new HSLFEscherClientDataRecord();
|
clientData = new HSLFEscherClientDataRecord();
|
||||||
clientData.setOptions((short)15);
|
clientData.setOptions((short)15);
|
||||||
clientData.setRecordId(HSLFEscherClientDataRecord.RECORD_ID);
|
clientData.setRecordId(EscherClientDataRecord.RECORD_ID);
|
||||||
getSpContainer().addChildBefore(clientData, EscherTextboxRecord.RECORD_ID);
|
getSpContainer().addChildBefore(clientData, EscherTextboxRecord.RECORD_ID);
|
||||||
}
|
}
|
||||||
return clientData;
|
return clientData;
|
||||||
|
@ -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.LineCompound;
|
||||||
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
|
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
|
||||||
import org.apache.poi.util.LittleEndian;
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
import org.apache.poi.util.POILogFactory;
|
||||||
import org.apache.poi.util.POILogger;
|
import org.apache.poi.util.POILogger;
|
||||||
import org.apache.poi.util.Units;
|
import org.apache.poi.util.Units;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract simple (non-group) shape.
|
* An abstract simple (non-group) shape.
|
||||||
* This is the parent class for all primitive shapes like Line, Rectangle, etc.
|
* 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> {
|
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;
|
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
|
* @param isChild <code>true</code> if the Line is inside a group, <code>false</code> otherwise
|
||||||
* @return the record container which holds this shape
|
* @return the record container which holds this shape
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected EscherContainerRecord createSpContainer(boolean isChild) {
|
protected EscherContainerRecord createSpContainer(boolean isChild) {
|
||||||
_escherContainer = new EscherContainerRecord();
|
EscherContainerRecord ecr = super.createSpContainer(isChild);
|
||||||
_escherContainer.setRecordId( EscherContainerRecord.SP_CONTAINER );
|
ecr.setRecordId( EscherContainerRecord.SP_CONTAINER );
|
||||||
_escherContainer.setOptions((short)15);
|
|
||||||
|
|
||||||
EscherSpRecord sp = new EscherSpRecord();
|
EscherSpRecord sp = new EscherSpRecord();
|
||||||
int flags = EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE;
|
int flags = EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE;
|
||||||
if (isChild) flags |= EscherSpRecord.FLAG_CHILD;
|
if (isChild) {
|
||||||
|
flags |= EscherSpRecord.FLAG_CHILD;
|
||||||
|
}
|
||||||
sp.setFlags(flags);
|
sp.setFlags(flags);
|
||||||
_escherContainer.addChildRecord(sp);
|
ecr.addChildRecord(sp);
|
||||||
|
|
||||||
AbstractEscherOptRecord opt = new EscherOptRecord();
|
AbstractEscherOptRecord opt = new EscherOptRecord();
|
||||||
opt.setRecordId(EscherOptRecord.RECORD_ID);
|
opt.setRecordId(EscherOptRecord.RECORD_ID);
|
||||||
_escherContainer.addChildRecord(opt);
|
ecr.addChildRecord(opt);
|
||||||
|
|
||||||
EscherRecord anchor;
|
EscherRecord anchor;
|
||||||
if(isChild) {
|
if(isChild) {
|
||||||
@ -117,9 +119,9 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
|
|||||||
LittleEndian.putInt(header, 4, 8);
|
LittleEndian.putInt(header, 4, 8);
|
||||||
anchor.fillFields(header, 0, null);
|
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.
|
* @return style of the line.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public StrokeStyle getStrokeStyle(){
|
public StrokeStyle getStrokeStyle(){
|
||||||
return new StrokeStyle() {
|
return new StrokeStyle() {
|
||||||
|
@Override
|
||||||
public PaintStyle getPaint() {
|
public PaintStyle getPaint() {
|
||||||
return DrawPaint.createSolidPaint(HSLFSimpleShape.this.getLineColor());
|
return DrawPaint.createSolidPaint(HSLFSimpleShape.this.getLineColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public LineCap getLineCap() {
|
public LineCap getLineCap() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public LineDash getLineDash() {
|
public LineDash getLineDash() {
|
||||||
return HSLFSimpleShape.this.getLineDash();
|
return HSLFSimpleShape.this.getLineDash();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public LineCompound getLineCompound() {
|
public LineCompound getLineCompound() {
|
||||||
return HSLFSimpleShape.this.getLineCompound();
|
return HSLFSimpleShape.this.getLineCompound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getLineWidth() {
|
public double getLineWidth() {
|
||||||
return HSLFSimpleShape.this.getLineWidth();
|
return HSLFSimpleShape.this.getLineWidth();
|
||||||
}
|
}
|
||||||
@ -303,9 +311,10 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
|
|||||||
getFill().setForegroundColor(color);
|
getFill().setForegroundColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Guide getAdjustValue(String name) {
|
public Guide getAdjustValue(String name) {
|
||||||
if (name == null || !name.matches("adj([1-9]|10)?")) {
|
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 null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,6 +346,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
|
|||||||
return (adjval == -1) ? null : new Guide(name, "val "+adjval);
|
return (adjval == -1) ? null : new Guide(name, "val "+adjval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CustomGeometry getGeometry() {
|
public CustomGeometry getGeometry() {
|
||||||
PresetGeometries dict = PresetGeometries.getInstance();
|
PresetGeometries dict = PresetGeometries.getInstance();
|
||||||
ShapeType st = getShapeType();
|
ShapeType st = getShapeType();
|
||||||
@ -346,7 +356,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
|
|||||||
if (name == null) {
|
if (name == null) {
|
||||||
name = (st != null) ? st.toString() : "<unknown>";
|
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 geom;
|
||||||
@ -379,6 +389,7 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
|
|||||||
return clr == null ? Color.black : clr;
|
return clr == null ? Color.black : clr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Shadow<HSLFShape,HSLFTextParagraph> getShadow() {
|
public Shadow<HSLFShape,HSLFTextParagraph> getShadow() {
|
||||||
AbstractEscherOptRecord opt = getEscherOptRecord();
|
AbstractEscherOptRecord opt = getEscherOptRecord();
|
||||||
if (opt == null) return null;
|
if (opt == null) return null;
|
||||||
@ -386,23 +397,28 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
|
|||||||
if (shadowType == null) return null;
|
if (shadowType == null) return null;
|
||||||
|
|
||||||
return new Shadow<HSLFShape,HSLFTextParagraph>(){
|
return new Shadow<HSLFShape,HSLFTextParagraph>(){
|
||||||
|
@Override
|
||||||
public SimpleShape<HSLFShape,HSLFTextParagraph> getShadowParent() {
|
public SimpleShape<HSLFShape,HSLFTextParagraph> getShadowParent() {
|
||||||
return HSLFSimpleShape.this;
|
return HSLFSimpleShape.this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getDistance() {
|
public double getDistance() {
|
||||||
return getShadowDistance();
|
return getShadowDistance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getAngle() {
|
public double getAngle() {
|
||||||
return getShadowAngle();
|
return getShadowAngle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getBlur() {
|
public double getBlur() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public SolidPaint getFillStyle() {
|
public SolidPaint getFillStyle() {
|
||||||
return DrawPaint.createSolidPaint(getShadowColor());
|
return DrawPaint.createSolidPaint(getShadowColor());
|
||||||
}
|
}
|
||||||
@ -478,29 +494,36 @@ public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape<H
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public LineDecoration getLineDecoration() {
|
public LineDecoration getLineDecoration() {
|
||||||
return new LineDecoration() {
|
return new LineDecoration() {
|
||||||
|
|
||||||
|
@Override
|
||||||
public DecorationShape getHeadShape() {
|
public DecorationShape getHeadShape() {
|
||||||
return HSLFSimpleShape.this.getLineHeadDecoration();
|
return HSLFSimpleShape.this.getLineHeadDecoration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DecorationSize getHeadWidth() {
|
public DecorationSize getHeadWidth() {
|
||||||
return HSLFSimpleShape.this.getLineHeadWidth();
|
return HSLFSimpleShape.this.getLineHeadWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DecorationSize getHeadLength() {
|
public DecorationSize getHeadLength() {
|
||||||
return HSLFSimpleShape.this.getLineHeadLength();
|
return HSLFSimpleShape.this.getLineHeadLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DecorationShape getTailShape() {
|
public DecorationShape getTailShape() {
|
||||||
return HSLFSimpleShape.this.getLineTailDecoration();
|
return HSLFSimpleShape.this.getLineTailDecoration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DecorationSize getTailWidth() {
|
public DecorationSize getTailWidth() {
|
||||||
return HSLFSimpleShape.this.getLineTailWidth();
|
return HSLFSimpleShape.this.getLineTailWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public DecorationSize getTailLength() {
|
public DecorationSize getTailLength() {
|
||||||
return HSLFSimpleShape.this.getLineTailLength();
|
return HSLFSimpleShape.this.getLineTailLength();
|
||||||
}
|
}
|
||||||
|
@ -147,6 +147,7 @@ implements HSLFShapeContainer, TableShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
return cells.length;
|
return cells.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void afterInsert(HSLFSheet sh){
|
protected void afterInsert(HSLFSheet sh){
|
||||||
super.afterInsert(sh);
|
super.afterInsert(sh);
|
||||||
|
|
||||||
@ -335,6 +336,7 @@ implements HSLFShapeContainer, TableShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
*
|
*
|
||||||
* @param sheet owner of this shape
|
* @param sheet owner of this shape
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void setSheet(HSLFSheet sheet){
|
public void setSheet(HSLFSheet sheet){
|
||||||
super.setSheet(sheet);
|
super.setSheet(sheet);
|
||||||
if (cells == null) {
|
if (cells == null) {
|
||||||
|
@ -77,8 +77,9 @@ public final class HSLFTableCell extends HSLFTextBox implements TableCell<HSLFSh
|
|||||||
//_txtrun.getRichTextRuns()[0].setFlag(false, 0, false);
|
//_txtrun.getRichTextRuns()[0].setFlag(false, 0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected EscherContainerRecord createSpContainer(boolean isChild){
|
protected EscherContainerRecord createSpContainer(boolean isChild){
|
||||||
_escherContainer = super.createSpContainer(isChild);
|
EscherContainerRecord ecr = super.createSpContainer(isChild);
|
||||||
AbstractEscherOptRecord opt = getEscherOptRecord();
|
AbstractEscherOptRecord opt = getEscherOptRecord();
|
||||||
setEscherProperty(opt, EscherProperties.TEXT__TEXTID, 0);
|
setEscherProperty(opt, EscherProperties.TEXT__TEXTID, 0);
|
||||||
setEscherProperty(opt, EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x20000);
|
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.SHADOWSTYLE__SHADOWOBSURED, 0x20000);
|
||||||
setEscherProperty(opt, EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x40000);
|
setEscherProperty(opt, EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x40000);
|
||||||
|
|
||||||
return _escherContainer;
|
return ecr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void anchorBorder(BorderEdge edge, final HSLFLine line) {
|
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));
|
line.setAnchor(new Rectangle2D.Double(x,y,w,h));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setAnchor(Rectangle2D anchor){
|
public void setAnchor(Rectangle2D anchor){
|
||||||
super.setAnchor(anchor);
|
super.setAnchor(anchor);
|
||||||
|
|
||||||
@ -139,22 +141,27 @@ public final class HSLFTableCell extends HSLFTextBox implements TableCell<HSLFSh
|
|||||||
public StrokeStyle getBorderStyle(final BorderEdge edge) {
|
public StrokeStyle getBorderStyle(final BorderEdge edge) {
|
||||||
final Double width = getBorderWidth(edge);
|
final Double width = getBorderWidth(edge);
|
||||||
return (width == null) ? null : new StrokeStyle() {
|
return (width == null) ? null : new StrokeStyle() {
|
||||||
|
@Override
|
||||||
public PaintStyle getPaint() {
|
public PaintStyle getPaint() {
|
||||||
return DrawPaint.createSolidPaint(getBorderColor(edge));
|
return DrawPaint.createSolidPaint(getBorderColor(edge));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public LineCap getLineCap() {
|
public LineCap getLineCap() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public LineDash getLineDash() {
|
public LineDash getLineDash() {
|
||||||
return getBorderDash(edge);
|
return getBorderDash(edge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public LineCompound getLineCompound() {
|
public LineCompound getLineCompound() {
|
||||||
return getBorderCompound(edge);
|
return getBorderCompound(edge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public double getLineWidth() {
|
public double getLineWidth() {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,9 @@ public class HSLFTextBox extends HSLFTextShape implements TextBox<HSLFShape,HSLF
|
|||||||
*
|
*
|
||||||
* @return the created <code>EscherContainerRecord</code> which holds shape data
|
* @return the created <code>EscherContainerRecord</code> which holds shape data
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected EscherContainerRecord createSpContainer(boolean isChild){
|
protected EscherContainerRecord createSpContainer(boolean isChild){
|
||||||
_escherContainer = super.createSpContainer(isChild);
|
EscherContainerRecord ecr = super.createSpContainer(isChild);
|
||||||
|
|
||||||
setShapeType(ShapeType.TEXT_BOX);
|
setShapeType(ShapeType.TEXT_BOX);
|
||||||
|
|
||||||
@ -85,9 +86,10 @@ public class HSLFTextBox extends HSLFTextShape implements TextBox<HSLFShape,HSLF
|
|||||||
// init paragraphs
|
// init paragraphs
|
||||||
getTextParagraphs();
|
getTextParagraphs();
|
||||||
|
|
||||||
return _escherContainer;
|
return ecr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){
|
protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){
|
||||||
setVerticalAlignment(VerticalAlignment.TOP);
|
setVerticalAlignment(VerticalAlignment.TOP);
|
||||||
setEscherProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x20002);
|
setEscherProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x20002);
|
||||||
|
@ -46,6 +46,7 @@ import org.apache.poi.sl.usermodel.Placeholder;
|
|||||||
import org.apache.poi.sl.usermodel.ShapeContainer;
|
import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||||
import org.apache.poi.sl.usermodel.TextShape;
|
import org.apache.poi.sl.usermodel.TextShape;
|
||||||
import org.apache.poi.sl.usermodel.VerticalAlignment;
|
import org.apache.poi.sl.usermodel.VerticalAlignment;
|
||||||
|
import org.apache.poi.util.POILogFactory;
|
||||||
import org.apache.poi.util.POILogger;
|
import org.apache.poi.util.POILogger;
|
||||||
import org.apache.poi.util.Units;
|
import org.apache.poi.util.Units;
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ import org.apache.poi.util.Units;
|
|||||||
*/
|
*/
|
||||||
public abstract class HSLFTextShape extends HSLFSimpleShape
|
public abstract class HSLFTextShape extends HSLFSimpleShape
|
||||||
implements TextShape<HSLFShape,HSLFTextParagraph> {
|
implements TextShape<HSLFShape,HSLFTextParagraph> {
|
||||||
|
private static final POILogger LOG = POILogFactory.getLogger(HSLFTextShape.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How to anchor the text
|
* How to anchor the text
|
||||||
@ -161,7 +163,7 @@ implements TextShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
*/
|
*/
|
||||||
public HSLFTextShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
|
public HSLFTextShape(ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
|
||||||
super(null, 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
|
* @param sh the sheet we are adding to
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void afterInsert(HSLFSheet sh){
|
protected void afterInsert(HSLFSheet sh){
|
||||||
super.afterInsert(sh);
|
super.afterInsert(sh);
|
||||||
|
|
||||||
@ -196,7 +199,7 @@ implements TextShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
|
|
||||||
EscherTextboxWrapper thisTxtbox = getEscherTextboxWrapper();
|
EscherTextboxWrapper thisTxtbox = getEscherTextboxWrapper();
|
||||||
if(thisTxtbox != null){
|
if(thisTxtbox != null){
|
||||||
_escherContainer.addChildRecord(thisTxtbox.getEscherRecord());
|
getSpContainer().addChildRecord(thisTxtbox.getEscherRecord());
|
||||||
|
|
||||||
PPDrawing ppdrawing = sh.getPPDrawing();
|
PPDrawing ppdrawing = sh.getPPDrawing();
|
||||||
ppdrawing.addTextboxWrapper(thisTxtbox);
|
ppdrawing.addTextboxWrapper(thisTxtbox);
|
||||||
@ -253,7 +256,7 @@ implements TextShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
public Rectangle2D resizeToFitText(){
|
public Rectangle2D resizeToFitText(){
|
||||||
Rectangle2D anchor = getAnchor();
|
Rectangle2D anchor = getAnchor();
|
||||||
if(anchor.getWidth() == 0.) {
|
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());
|
anchor.setRect(anchor.getX(), anchor.getY(), 200., anchor.getHeight());
|
||||||
setAnchor(anchor);
|
setAnchor(anchor);
|
||||||
}
|
}
|
||||||
@ -573,7 +576,7 @@ implements TextShape<HSLFShape,HSLFTextParagraph> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_paragraphs.isEmpty()) {
|
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;
|
return _paragraphs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setSheet(HSLFSheet sheet) {
|
public void setSheet(HSLFSheet sheet) {
|
||||||
_sheet = sheet;
|
super.setSheet(sheet);
|
||||||
|
|
||||||
// Initialize _txtrun object.
|
// Initialize _txtrun object.
|
||||||
// (We can't do it in the constructor because the sheet
|
// (We can't do it in the constructor because the sheet
|
||||||
|
Loading…
Reference in New Issue
Block a user