2004-04-09 09:05:39 -04:00
|
|
|
/* ====================================================================
|
2006-12-22 14:18:16 -05:00
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
2004-04-09 09:05:39 -04:00
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
==================================================================== */
|
2004-08-23 04:52:54 -04:00
|
|
|
|
2004-04-09 07:45:38 -04:00
|
|
|
package org.apache.poi.hssf.usermodel;
|
|
|
|
|
2012-06-28 06:56:55 -04:00
|
|
|
import org.apache.poi.ddf.*;
|
2012-07-01 05:38:08 -04:00
|
|
|
import org.apache.poi.hssf.record.*;
|
2012-06-08 13:47:37 -04:00
|
|
|
|
2004-04-09 07:45:38 -04:00
|
|
|
import java.util.ArrayList;
|
2012-07-23 05:06:56 -04:00
|
|
|
import java.util.Collections;
|
2004-04-09 07:45:38 -04:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A shape group may contain other shapes. It was no actual form on the
|
|
|
|
* sheet.
|
|
|
|
*
|
|
|
|
* @author Glen Stampoultzis (glens at apache.org)
|
|
|
|
*/
|
2012-07-01 05:38:08 -04:00
|
|
|
public class HSSFShapeGroup extends HSSFShape implements HSSFShapeContainer {
|
2012-07-23 05:06:56 -04:00
|
|
|
private final List<HSSFShape> shapes = new ArrayList<HSSFShape>();
|
2012-06-18 16:59:32 -04:00
|
|
|
private EscherSpgrRecord _spgrRecord;
|
2004-04-09 07:45:38 -04:00
|
|
|
|
2012-06-08 13:47:37 -04:00
|
|
|
public HSSFShapeGroup(EscherContainerRecord spgrContainer, ObjRecord objRecord) {
|
|
|
|
super(spgrContainer, objRecord);
|
|
|
|
|
|
|
|
// read internal and external coordinates from spgrContainer
|
|
|
|
EscherContainerRecord spContainer = spgrContainer.getChildContainers().get(0);
|
2012-06-18 16:59:32 -04:00
|
|
|
_spgrRecord = (EscherSpgrRecord) spContainer.getChild(0);
|
2012-07-01 05:38:08 -04:00
|
|
|
for (EscherRecord ch : spContainer.getChildRecords()) {
|
|
|
|
switch (ch.getRecordId()) {
|
2012-06-08 13:47:37 -04:00
|
|
|
case EscherSpgrRecord.RECORD_ID:
|
|
|
|
break;
|
|
|
|
case EscherClientAnchorRecord.RECORD_ID:
|
2012-07-01 05:38:08 -04:00
|
|
|
anchor = new HSSFClientAnchor((EscherClientAnchorRecord) ch);
|
2012-06-08 13:47:37 -04:00
|
|
|
break;
|
|
|
|
case EscherChildAnchorRecord.RECORD_ID:
|
2012-07-01 05:38:08 -04:00
|
|
|
anchor = new HSSFChildAnchor((EscherChildAnchorRecord) ch);
|
2012-06-08 13:47:37 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-04-09 07:45:38 -04:00
|
|
|
|
2012-07-01 05:38:08 -04:00
|
|
|
public HSSFShapeGroup(HSSFShape parent, HSSFAnchor anchor) {
|
|
|
|
super(parent, anchor);
|
2012-07-11 08:08:38 -04:00
|
|
|
_spgrRecord = ((EscherContainerRecord)getEscherContainer().getChild(0)).getChildById(EscherSpgrRecord.RECORD_ID);
|
2004-04-09 07:45:38 -04:00
|
|
|
}
|
|
|
|
|
2012-06-26 07:21:13 -04:00
|
|
|
@Override
|
|
|
|
protected EscherContainerRecord createSpContainer() {
|
2012-07-01 05:38:08 -04:00
|
|
|
EscherContainerRecord spgrContainer = new EscherContainerRecord();
|
2012-06-28 06:56:55 -04:00
|
|
|
EscherContainerRecord spContainer = new EscherContainerRecord();
|
2012-07-01 05:38:08 -04:00
|
|
|
EscherSpgrRecord spgr = new EscherSpgrRecord();
|
|
|
|
EscherSpRecord sp = new EscherSpRecord();
|
|
|
|
EscherOptRecord opt = new EscherOptRecord();
|
|
|
|
EscherRecord anchor;
|
|
|
|
EscherClientDataRecord clientData = new EscherClientDataRecord();
|
|
|
|
|
|
|
|
spgrContainer.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
|
|
|
|
spgrContainer.setOptions((short) 0x000F);
|
|
|
|
spContainer.setRecordId(EscherContainerRecord.SP_CONTAINER);
|
|
|
|
spContainer.setOptions((short) 0x000F);
|
|
|
|
spgr.setRecordId(EscherSpgrRecord.RECORD_ID);
|
|
|
|
spgr.setOptions((short) 0x0001);
|
|
|
|
spgr.setRectX1(0);
|
|
|
|
spgr.setRectY1(0);
|
|
|
|
spgr.setRectX2(1023);
|
|
|
|
spgr.setRectY2(255);
|
|
|
|
sp.setRecordId(EscherSpRecord.RECORD_ID);
|
|
|
|
sp.setOptions((short) 0x0002);
|
|
|
|
if (getAnchor() instanceof HSSFClientAnchor) {
|
|
|
|
sp.setFlags(EscherSpRecord.FLAG_GROUP | EscherSpRecord.FLAG_HAVEANCHOR);
|
|
|
|
} else {
|
|
|
|
sp.setFlags(EscherSpRecord.FLAG_GROUP | EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_CHILD);
|
|
|
|
}
|
|
|
|
opt.setRecordId(EscherOptRecord.RECORD_ID);
|
|
|
|
opt.setOptions((short) 0x0023);
|
|
|
|
opt.addEscherProperty(new EscherBoolProperty(EscherProperties.PROTECTION__LOCKAGAINSTGROUPING, 0x00040004));
|
|
|
|
opt.addEscherProperty(new EscherBoolProperty(EscherProperties.GROUPSHAPE__PRINT, 0x00080000));
|
|
|
|
|
|
|
|
anchor = getAnchor().getEscherAnchor();
|
|
|
|
clientData.setRecordId(EscherClientDataRecord.RECORD_ID);
|
|
|
|
clientData.setOptions((short) 0x0000);
|
|
|
|
|
|
|
|
spgrContainer.addChildRecord(spContainer);
|
|
|
|
spContainer.addChildRecord(spgr);
|
|
|
|
spContainer.addChildRecord(sp);
|
|
|
|
spContainer.addChildRecord(opt);
|
|
|
|
spContainer.addChildRecord(anchor);
|
|
|
|
spContainer.addChildRecord(clientData);
|
|
|
|
return spgrContainer;
|
2012-06-26 07:21:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected ObjRecord createObjRecord() {
|
2012-07-01 05:38:08 -04:00
|
|
|
ObjRecord obj = new ObjRecord();
|
|
|
|
CommonObjectDataSubRecord cmo = new CommonObjectDataSubRecord();
|
|
|
|
cmo.setObjectType(CommonObjectDataSubRecord.OBJECT_TYPE_GROUP);
|
|
|
|
cmo.setLocked(true);
|
|
|
|
cmo.setPrintable(true);
|
|
|
|
cmo.setAutofill(true);
|
|
|
|
cmo.setAutoline(true);
|
|
|
|
GroupMarkerSubRecord gmo = new GroupMarkerSubRecord();
|
|
|
|
EndSubRecord end = new EndSubRecord();
|
|
|
|
obj.addSubRecord(cmo);
|
|
|
|
obj.addSubRecord(gmo);
|
|
|
|
obj.addSubRecord(end);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2012-07-11 08:08:38 -04:00
|
|
|
@Override
|
|
|
|
protected void afterRemove(HSSFPatriarch patriarch) {
|
2012-07-19 16:29:42 -04:00
|
|
|
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();
|
2012-07-11 08:08:38 -04:00
|
|
|
}
|
|
|
|
|
2012-07-01 05:38:08 -04:00
|
|
|
private void onCreate(HSSFShape shape){
|
2012-07-19 15:02:43 -04:00
|
|
|
if(_patriarch != null){
|
2012-07-01 05:38:08 -04:00
|
|
|
EscherContainerRecord spContainer = shape.getEscherContainer();
|
|
|
|
int shapeId = _patriarch.newShapeId();
|
|
|
|
shape.setShapeId(shapeId);
|
2012-07-11 08:08:38 -04:00
|
|
|
getEscherContainer().addChildRecord(spContainer);
|
2012-07-01 05:38:08 -04:00
|
|
|
shape.afterInsert(_patriarch);
|
2012-07-19 15:02:43 -04:00
|
|
|
EscherSpRecord sp;
|
|
|
|
if (shape instanceof HSSFShapeGroup){
|
|
|
|
sp = shape.getEscherContainer().getChildContainers().get(0).getChildById(EscherSpRecord.RECORD_ID);
|
|
|
|
} else {
|
|
|
|
sp = shape.getEscherContainer().getChildById(EscherSpRecord.RECORD_ID);
|
|
|
|
}
|
2012-07-06 13:00:20 -04:00
|
|
|
sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_CHILD);
|
2012-07-01 05:38:08 -04:00
|
|
|
}
|
2012-06-26 07:21:13 -04:00
|
|
|
}
|
|
|
|
|
2004-04-09 07:45:38 -04:00
|
|
|
/**
|
|
|
|
* Create another group under this group.
|
2012-07-01 05:38:08 -04:00
|
|
|
*
|
|
|
|
* @param anchor the position of the new group.
|
|
|
|
* @return the group
|
2004-04-09 07:45:38 -04:00
|
|
|
*/
|
2012-07-01 05:38:08 -04:00
|
|
|
public HSSFShapeGroup createGroup(HSSFChildAnchor anchor) {
|
2004-04-09 07:45:38 -04:00
|
|
|
HSSFShapeGroup group = new HSSFShapeGroup(this, anchor);
|
2012-07-01 05:38:08 -04:00
|
|
|
group.parent = this;
|
2004-04-09 07:45:38 -04:00
|
|
|
group.anchor = anchor;
|
|
|
|
shapes.add(group);
|
2012-07-01 05:38:08 -04:00
|
|
|
onCreate(group);
|
2004-04-09 07:45:38 -04:00
|
|
|
return group;
|
|
|
|
}
|
|
|
|
|
2012-07-01 05:38:08 -04:00
|
|
|
public void addShape(HSSFShape shape) {
|
2011-09-12 06:19:50 -04:00
|
|
|
shape._patriarch = this._patriarch;
|
2012-07-01 05:38:08 -04:00
|
|
|
shape.parent = this;
|
2011-09-12 06:19:50 -04:00
|
|
|
shapes.add(shape);
|
|
|
|
}
|
|
|
|
|
2004-04-09 07:45:38 -04:00
|
|
|
/**
|
|
|
|
* Create a new simple shape under this group.
|
2012-07-01 05:38:08 -04:00
|
|
|
*
|
|
|
|
* @param anchor the position of the shape.
|
|
|
|
* @return the shape
|
2004-04-09 07:45:38 -04:00
|
|
|
*/
|
2012-07-01 05:38:08 -04:00
|
|
|
public HSSFSimpleShape createShape(HSSFChildAnchor anchor) {
|
2004-04-09 07:45:38 -04:00
|
|
|
HSSFSimpleShape shape = new HSSFSimpleShape(this, anchor);
|
2012-07-01 05:38:08 -04:00
|
|
|
shape.parent = this;
|
2004-04-09 07:45:38 -04:00
|
|
|
shape.anchor = anchor;
|
|
|
|
shapes.add(shape);
|
2012-07-01 05:38:08 -04:00
|
|
|
onCreate(shape);
|
2012-07-11 08:08:38 -04:00
|
|
|
EscherSpRecord sp = shape.getEscherContainer().getChildById(EscherSpRecord.RECORD_ID);
|
|
|
|
if (shape.anchor.isHorizontallyFlipped()){
|
|
|
|
sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ);
|
|
|
|
}
|
|
|
|
if (shape.anchor.isVerticallyFlipped()){
|
|
|
|
sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPVERT);
|
|
|
|
}
|
2004-04-09 07:45:38 -04:00
|
|
|
return shape;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new textbox under this group.
|
2012-07-01 05:38:08 -04:00
|
|
|
*
|
|
|
|
* @param anchor the position of the shape.
|
|
|
|
* @return the textbox
|
2004-04-09 07:45:38 -04:00
|
|
|
*/
|
2012-07-01 05:38:08 -04:00
|
|
|
public HSSFTextbox createTextbox(HSSFChildAnchor anchor) {
|
2004-04-09 07:45:38 -04:00
|
|
|
HSSFTextbox shape = new HSSFTextbox(this, anchor);
|
2012-07-01 05:38:08 -04:00
|
|
|
shape.parent = this;
|
2004-04-09 07:45:38 -04:00
|
|
|
shape.anchor = anchor;
|
|
|
|
shapes.add(shape);
|
2012-07-01 05:38:08 -04:00
|
|
|
onCreate(shape);
|
2004-04-09 07:45:38 -04:00
|
|
|
return shape;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a polygon
|
|
|
|
*
|
2012-07-01 05:38:08 -04:00
|
|
|
* @param anchor the client anchor describes how this group is attached
|
|
|
|
* to the sheet.
|
|
|
|
* @return the newly created shape.
|
2004-04-09 07:45:38 -04:00
|
|
|
*/
|
2012-07-01 05:38:08 -04:00
|
|
|
public HSSFPolygon createPolygon(HSSFChildAnchor anchor) {
|
2004-04-09 07:45:38 -04:00
|
|
|
HSSFPolygon shape = new HSSFPolygon(this, anchor);
|
2012-07-01 05:38:08 -04:00
|
|
|
shape.parent = this;
|
2004-04-09 07:45:38 -04:00
|
|
|
shape.anchor = anchor;
|
|
|
|
shapes.add(shape);
|
2012-07-01 05:38:08 -04:00
|
|
|
onCreate(shape);
|
2004-04-09 07:45:38 -04:00
|
|
|
return shape;
|
|
|
|
}
|
|
|
|
|
2007-04-16 07:12:03 -04:00
|
|
|
/**
|
|
|
|
* Creates a picture.
|
|
|
|
*
|
2012-07-01 05:38:08 -04:00
|
|
|
* @param anchor the client anchor describes how this group is attached
|
|
|
|
* to the sheet.
|
|
|
|
* @return the newly created shape.
|
2007-04-16 07:12:03 -04:00
|
|
|
*/
|
2012-07-01 05:38:08 -04:00
|
|
|
public HSSFPicture createPicture(HSSFChildAnchor anchor, int pictureIndex) {
|
|
|
|
HSSFPicture shape = new HSSFPicture(this, anchor);
|
|
|
|
shape.parent = this;
|
|
|
|
shape.anchor = anchor;
|
|
|
|
shape.setPictureIndex(pictureIndex);
|
|
|
|
shapes.add(shape);
|
|
|
|
onCreate(shape);
|
2012-07-11 08:08:38 -04:00
|
|
|
EscherSpRecord sp = shape.getEscherContainer().getChildById(EscherSpRecord.RECORD_ID);
|
|
|
|
if (shape.anchor.isHorizontallyFlipped()){
|
|
|
|
sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ);
|
|
|
|
}
|
|
|
|
if (shape.anchor.isVerticallyFlipped()){
|
|
|
|
sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_FLIPVERT);
|
|
|
|
}
|
2012-07-01 05:38:08 -04:00
|
|
|
return shape;
|
2007-04-16 07:12:03 -04:00
|
|
|
}
|
2012-07-01 05:38:08 -04:00
|
|
|
|
2004-04-09 07:45:38 -04:00
|
|
|
/**
|
|
|
|
* Return all children contained by this shape.
|
|
|
|
*/
|
2012-07-01 05:38:08 -04:00
|
|
|
public List<HSSFShape> getChildren() {
|
2012-07-23 05:06:56 -04:00
|
|
|
return Collections.unmodifiableList(shapes);
|
2004-04-09 07:45:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-01-15 11:31:29 -05:00
|
|
|
* Sets the coordinate space of this group. All children are constrained
|
2004-04-09 07:45:38 -04:00
|
|
|
* to these coordinates.
|
|
|
|
*/
|
2012-07-01 05:38:08 -04:00
|
|
|
public void setCoordinates(int x1, int y1, int x2, int y2) {
|
2012-06-18 16:59:32 -04:00
|
|
|
_spgrRecord.setRectX1(x1);
|
|
|
|
_spgrRecord.setRectX2(x2);
|
|
|
|
_spgrRecord.setRectY1(y1);
|
|
|
|
_spgrRecord.setRectY2(y2);
|
2004-04-09 07:45:38 -04:00
|
|
|
}
|
|
|
|
|
2012-07-23 05:06:56 -04:00
|
|
|
public void clear() {
|
|
|
|
ArrayList <HSSFShape> copy = new ArrayList<HSSFShape>(shapes);
|
|
|
|
for (HSSFShape shape: copy){
|
|
|
|
removeShape(shape);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-09 07:45:38 -04:00
|
|
|
/**
|
|
|
|
* The top left x coordinate of this group.
|
|
|
|
*/
|
2012-07-01 05:38:08 -04:00
|
|
|
public int getX1() {
|
2012-06-18 16:59:32 -04:00
|
|
|
return _spgrRecord.getRectX1();
|
2004-04-09 07:45:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The top left y coordinate of this group.
|
|
|
|
*/
|
2012-07-01 05:38:08 -04:00
|
|
|
public int getY1() {
|
2012-06-18 16:59:32 -04:00
|
|
|
return _spgrRecord.getRectY1();
|
2004-04-09 07:45:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The bottom right x coordinate of this group.
|
|
|
|
*/
|
2012-07-01 05:38:08 -04:00
|
|
|
public int getX2() {
|
2012-06-18 16:59:32 -04:00
|
|
|
return _spgrRecord.getRectX2();
|
2004-04-09 07:45:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The bottom right y coordinate of this group.
|
|
|
|
*/
|
2012-07-01 05:38:08 -04:00
|
|
|
public int getY2() {
|
2012-06-18 16:59:32 -04:00
|
|
|
return _spgrRecord.getRectY2();
|
2004-04-09 07:45:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Count of all children and their childrens children.
|
|
|
|
*/
|
2012-07-01 05:38:08 -04:00
|
|
|
public int countOfAllChildren() {
|
2004-04-09 07:45:38 -04:00
|
|
|
int count = shapes.size();
|
2012-07-01 05:38:08 -04:00
|
|
|
for (Iterator iterator = shapes.iterator(); iterator.hasNext(); ) {
|
2004-04-09 07:45:38 -04:00
|
|
|
HSSFShape shape = (HSSFShape) iterator.next();
|
|
|
|
count += shape.countOfAllChildren();
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
2012-07-01 05:38:08 -04:00
|
|
|
|
|
|
|
@Override
|
|
|
|
void afterInsert(HSSFPatriarch patriarch){
|
|
|
|
EscherAggregate agg = patriarch._getBoundAggregate();
|
2012-07-11 08:08:38 -04:00
|
|
|
EscherContainerRecord containerRecord = getEscherContainer().getChildById(EscherContainerRecord.SP_CONTAINER);
|
2012-07-01 05:38:08 -04:00
|
|
|
agg.associateShapeToObjRecord(containerRecord.getChildById(EscherClientDataRecord.RECORD_ID), getObjRecord());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
void setShapeId(int shapeId){
|
2012-07-11 08:08:38 -04:00
|
|
|
EscherContainerRecord containerRecord = getEscherContainer().getChildById(EscherContainerRecord.SP_CONTAINER);
|
2012-07-01 05:38:08 -04:00
|
|
|
EscherSpRecord spRecord = containerRecord.getChildById(EscherSpRecord.RECORD_ID);
|
|
|
|
spRecord.setShapeId(shapeId);
|
2012-07-11 08:08:38 -04:00
|
|
|
CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord) getObjRecord().getSubRecords().get(0);
|
2012-07-19 15:02:43 -04:00
|
|
|
cod.setObjectId((short) (shapeId % 1024));
|
2012-07-01 05:38:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
int getShapeId(){
|
2012-07-11 08:08:38 -04:00
|
|
|
EscherContainerRecord containerRecord = getEscherContainer().getChildById(EscherContainerRecord.SP_CONTAINER);
|
2012-07-01 05:38:08 -04:00
|
|
|
return ((EscherSpRecord)containerRecord.getChildById(EscherSpRecord.RECORD_ID)).getShapeId();
|
|
|
|
}
|
2012-07-19 15:02:43 -04:00
|
|
|
|
|
|
|
@Override
|
2012-07-28 06:21:40 -04:00
|
|
|
protected HSSFShape cloneShape() {
|
2012-07-19 15:02:43 -04:00
|
|
|
throw new IllegalStateException("Use method cloneShape(HSSFPatriarch patriarch)");
|
|
|
|
}
|
|
|
|
|
2012-08-06 17:06:12 -04:00
|
|
|
protected HSSFShape cloneShape(HSSFPatriarch patriarch) {
|
2012-07-19 15:02:43 -04:00
|
|
|
EscherContainerRecord spgrContainer = new EscherContainerRecord();
|
|
|
|
spgrContainer.setRecordId(EscherContainerRecord.SPGR_CONTAINER);
|
|
|
|
spgrContainer.setOptions((short) 0x000F);
|
|
|
|
EscherContainerRecord spContainer = new EscherContainerRecord();
|
2012-08-02 15:52:47 -04:00
|
|
|
EscherContainerRecord cont = getEscherContainer().getChildById(EscherContainerRecord.SP_CONTAINER);
|
|
|
|
byte [] inSp = cont.serialize();
|
2012-07-19 15:02:43 -04:00
|
|
|
spContainer.fillFields(inSp, 0, new DefaultEscherRecordFactory());
|
|
|
|
|
|
|
|
spgrContainer.addChildRecord(spContainer);
|
|
|
|
ObjRecord obj = null;
|
|
|
|
if (null != getObjRecord()){
|
|
|
|
obj = (ObjRecord) getObjRecord().cloneViaReserialise();
|
|
|
|
}
|
|
|
|
|
|
|
|
HSSFShapeGroup group = new HSSFShapeGroup(spgrContainer, obj);
|
|
|
|
group._patriarch = patriarch;
|
|
|
|
|
|
|
|
for (HSSFShape shape: getChildren()){
|
|
|
|
HSSFShape newShape;
|
|
|
|
if (shape instanceof HSSFShapeGroup){
|
|
|
|
newShape = ((HSSFShapeGroup)shape).cloneShape(patriarch);
|
|
|
|
} else {
|
|
|
|
newShape = shape.cloneShape();
|
|
|
|
}
|
|
|
|
group.addShape(newShape);
|
|
|
|
group.onCreate(newShape);
|
|
|
|
}
|
|
|
|
return group;
|
|
|
|
}
|
2012-07-19 16:29:42 -04:00
|
|
|
|
|
|
|
public boolean removeShape(HSSFShape shape) {
|
|
|
|
boolean isRemoved = getEscherContainer().removeChildRecord(shape.getEscherContainer());
|
|
|
|
if (isRemoved){
|
|
|
|
shape.afterRemove(this._patriarch);
|
|
|
|
shapes.remove(shape);
|
|
|
|
}
|
|
|
|
return isRemoved;
|
|
|
|
}
|
2012-07-23 05:06:56 -04:00
|
|
|
|
|
|
|
public Iterator<HSSFShape> iterator() {
|
|
|
|
return shapes.iterator();
|
|
|
|
}
|
2011-09-12 06:19:50 -04:00
|
|
|
}
|