aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFComment.java3
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java11
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java1
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java17
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java4
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java39
6 files changed, 53 insertions, 22 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java b/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java
index 8bafa3b507..4922529e6d 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFComment.java
@@ -210,8 +210,7 @@ public class HSSFComment extends HSSFTextbox implements Comment {
}
public void afterRemove(HSSFPatriarch patriarch){
- patriarch._getBoundAggregate().removeShapeToObjRecord(getEscherContainer().getChildById(EscherClientDataRecord.RECORD_ID));
- patriarch._getBoundAggregate().removeShapeToObjRecord(getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID));
+ super.afterRemove(patriarch);
patriarch._getBoundAggregate().removeTailRecord(getNoteRecord());
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java
index 96d12adaa7..8f40651205 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPatriarch.java
@@ -88,10 +88,13 @@ public final class HSSFPatriarch implements HSSFShapeContainer, Drawing {
*
* @param shape to be removed
*/
- public void removeShape(HSSFShape shape) {
- _mainSpgrContainer.removeChildRecord(shape.getEscherContainer());
- shape.afterRemove(this);
- _shapes.remove(shape);
+ public boolean removeShape(HSSFShape shape) {
+ boolean isRemoved = _mainSpgrContainer.removeChildRecord(shape.getEscherContainer());
+ if (isRemoved){
+ shape.afterRemove(this);
+ _shapes.remove(shape);
+ }
+ return isRemoved;
}
void afterCreate() {
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java b/src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java
index e145b9fe50..0d15030c96 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFPolygon.java
@@ -114,6 +114,7 @@ public class HSSFPolygon extends HSSFSimpleShape {
@Override
protected void afterRemove(HSSFPatriarch patriarch) {
+ patriarch._getBoundAggregate().removeShapeToObjRecord(getEscherContainer().getChildById(EscherClientDataRecord.RECORD_ID));
}
public int[] getXPoints() {
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java b/src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java
index 548b45b75d..7cf6803fd0 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFShapeGroup.java
@@ -124,6 +124,14 @@ public class HSSFShapeGroup extends HSSFShape implements HSSFShapeContainer {
@Override
protected void afterRemove(HSSFPatriarch patriarch) {
+ patriarch._getBoundAggregate().removeShapeToObjRecord(getEscherContainer().getChildContainers().get(0)
+ .getChildById(EscherClientDataRecord.RECORD_ID));
+ for ( int i=0; i<shapes.size(); i++ ) {
+ HSSFShape shape = shapes.get(i);
+ removeShape(shape);
+ shape.afterRemove(_patriarch);
+ }
+ shapes.clear();
}
private void onCreate(HSSFShape shape){
@@ -360,4 +368,13 @@ public class HSSFShapeGroup extends HSSFShape implements HSSFShapeContainer {
}
return group;
}
+
+ public boolean removeShape(HSSFShape shape) {
+ boolean isRemoved = getEscherContainer().removeChildRecord(shape.getEscherContainer());
+ if (isRemoved){
+ shape.afterRemove(this._patriarch);
+ shapes.remove(shape);
+ }
+ return isRemoved;
+ }
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java
index eb2e865e76..258ee011a6 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSimpleShape.java
@@ -152,6 +152,10 @@ public class HSSFSimpleShape extends HSSFShape
@Override
protected void afterRemove(HSSFPatriarch patriarch) {
+ patriarch._getBoundAggregate().removeShapeToObjRecord(getEscherContainer().getChildById(EscherClientDataRecord.RECORD_ID));
+ if (null != getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID)){
+ patriarch._getBoundAggregate().removeShapeToObjRecord(getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID));
+ }
}
/**
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java b/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java
index cfbbd9797c..872a195228 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFTextbox.java
@@ -71,14 +71,15 @@ public class HSSFTextbox extends HSSFSimpleShape {
ObjRecord obj = new ObjRecord();
CommonObjectDataSubRecord c = new CommonObjectDataSubRecord();
c.setObjectType(HSSFTextbox.OBJECT_TYPE_TEXT);
- c.setLocked( true );
- c.setPrintable( true );
- c.setAutofill( true );
- c.setAutoline( true );
+ c.setLocked(true);
+ c.setPrintable(true);
+ c.setAutofill(true);
+ c.setAutoline(true);
EndSubRecord e = new EndSubRecord();
- obj.addSubRecord( c );
- obj.addSubRecord( e );
- return obj; }
+ obj.addSubRecord(c);
+ obj.addSubRecord(e);
+ return obj;
+ }
@Override
protected EscherContainerRecord createSpContainer() {
@@ -106,12 +107,12 @@ public class HSSFTextbox extends HSSFSimpleShape {
opt.addEscherProperty(new EscherSimpleProperty(EscherProperties.TEXT__TEXTBOTTOM, 0));
opt.setEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEDASHING, LINESTYLE_SOLID));
- opt.setEscherProperty( new EscherBoolProperty( EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
+ opt.setEscherProperty(new EscherBoolProperty(EscherProperties.LINESTYLE__NOLINEDRAWDASH, 0x00080008));
opt.setEscherProperty(new EscherSimpleProperty(EscherProperties.LINESTYLE__LINEWIDTH, LINEWIDTH_DEFAULT));
opt.setEscherProperty(new EscherRGBProperty(EscherProperties.FILL__FILLCOLOR, FILL__FILLCOLOR_DEFAULT));
opt.setEscherProperty(new EscherRGBProperty(EscherProperties.LINESTYLE__COLOR, LINESTYLE__COLOR_DEFAULT));
opt.setEscherProperty(new EscherBoolProperty(EscherProperties.FILL__NOFILLHITTEST, NO_FILLHITTEST_FALSE));
- opt.setEscherProperty(new EscherBoolProperty( EscherProperties.GROUPSHAPE__PRINT, 0x080000));
+ opt.setEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x080000));
EscherRecord anchor = getAnchor().getEscherAnchor();
clientData.setRecordId(EscherClientDataRecord.RECORD_ID);
@@ -137,7 +138,7 @@ public class HSSFTextbox extends HSSFSimpleShape {
}
@Override
- void afterInsert(HSSFPatriarch patriarch){
+ void afterInsert(HSSFPatriarch patriarch) {
EscherAggregate agg = patriarch._getBoundAggregate();
agg.associateShapeToObjRecord(getEscherContainer().getChildById(EscherClientDataRecord.RECORD_ID), getObjRecord());
agg.associateShapeToObjRecord(getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID), getTextObjectRecord());
@@ -148,7 +149,7 @@ public class HSSFTextbox extends HSSFSimpleShape {
*/
public int getMarginLeft() {
EscherSimpleProperty property = getOptRecord().lookup(EscherProperties.TEXT__TEXTLEFT);
- return property == null ? 0: property.getPropertyValue();
+ return property == null ? 0 : property.getPropertyValue();
}
/**
@@ -163,7 +164,7 @@ public class HSSFTextbox extends HSSFSimpleShape {
*/
public int getMarginRight() {
EscherSimpleProperty property = getOptRecord().lookup(EscherProperties.TEXT__TEXTRIGHT);
- return property == null ? 0: property.getPropertyValue();
+ return property == null ? 0 : property.getPropertyValue();
}
/**
@@ -178,7 +179,7 @@ public class HSSFTextbox extends HSSFSimpleShape {
*/
public int getMarginTop() {
EscherSimpleProperty property = getOptRecord().lookup(EscherProperties.TEXT__TEXTTOP);
- return property == null ? 0: property.getPropertyValue();
+ return property == null ? 0 : property.getPropertyValue();
}
/**
@@ -193,7 +194,7 @@ public class HSSFTextbox extends HSSFSimpleShape {
*/
public int getMarginBottom() {
EscherSimpleProperty property = getOptRecord().lookup(EscherProperties.TEXT__TEXTBOTTOM);
- return property == null ? 0: property.getPropertyValue();
+ return property == null ? 0 : property.getPropertyValue();
}
/**
@@ -233,16 +234,22 @@ public class HSSFTextbox extends HSSFSimpleShape {
@Override
public void setShapeType(int shapeType) {
- throw new IllegalStateException("Shape type can not be changed in "+this.getClass().getSimpleName());
+ throw new IllegalStateException("Shape type can not be changed in " + this.getClass().getSimpleName());
}
@Override
public HSSFShape cloneShape() {
TextObjectRecord txo = (TextObjectRecord) getTextObjectRecord().cloneViaReserialise();
EscherContainerRecord spContainer = new EscherContainerRecord();
- byte [] inSp = getEscherContainer().serialize();
+ byte[] inSp = getEscherContainer().serialize();
spContainer.fillFields(inSp, 0, new DefaultEscherRecordFactory());
ObjRecord obj = (ObjRecord) getObjRecord().cloneViaReserialise();
return new HSSFTextbox(spContainer, obj, txo);
}
+
+ @Override
+ protected void afterRemove(HSSFPatriarch patriarch) {
+ patriarch._getBoundAggregate().removeShapeToObjRecord(getEscherContainer().getChildById(EscherClientDataRecord.RECORD_ID));
+ patriarch._getBoundAggregate().removeShapeToObjRecord(getEscherContainer().getChildById(EscherTextboxRecord.RECORD_ID));
+ }
}