View | Details | Raw Unified | Return to bug 58204
Collapse All | Expand All

(-)a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java (-2 / +1 lines)
Lines 144-151 public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, Gro Link Here
144
    }
144
    }
145
145
146
    /**
146
    /**
147
     *
147
     * @return child shapes contained within this group
148
     * @return child shapes contained witin this group
149
     */
148
     */
150
    @Override
149
    @Override
151
    public List<XSLFShape> getShapes(){
150
    public List<XSLFShape> getShapes(){
(-)a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java (-33 / +22 lines)
Lines 25-31 import java.util.HashMap; Link Here
25
import java.util.Iterator;
25
import java.util.Iterator;
26
import java.util.List;
26
import java.util.List;
27
import java.util.Map;
27
import java.util.Map;
28
29
import javax.xml.namespace.QName;
28
import javax.xml.namespace.QName;
30
29
31
import org.apache.poi.POIXMLDocumentPart;
30
import org.apache.poi.POIXMLDocumentPart;
Lines 132-139 public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC Link Here
132
        return _drawing;
131
        return _drawing;
133
    }
132
    }
134
133
135
    private List<XSLFShape> getShapeList(){
134
    /**
136
        if(_shapes == null){
135
     * Returns an array containing all of the shapes in this sheet
136
     *
137
     * @return an array of all shapes in this sheet
138
     */
139
    @Override
140
    public List<XSLFShape> getShapes(){
141
        if (_shapes == null) {
137
            _shapes = buildShapes(getSpTree());
142
            _shapes = buildShapes(getSpTree());
138
        }
143
        }
139
        return _shapes;
144
        return _shapes;
Lines 142-182 public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC Link Here
142
    // shape factory methods
147
    // shape factory methods
143
148
144
    public XSLFAutoShape createAutoShape(){
149
    public XSLFAutoShape createAutoShape(){
145
        List<XSLFShape> shapes = getShapeList();
146
        XSLFAutoShape sh = getDrawing().createAutoShape();
150
        XSLFAutoShape sh = getDrawing().createAutoShape();
147
        shapes.add(sh);
151
        getShapes().add(sh);
148
        sh.setParent(this);
152
        sh.setParent(this);
149
        return sh;
153
        return sh;
150
    }
154
    }
151
155
152
    public XSLFFreeformShape createFreeform(){
156
    public XSLFFreeformShape createFreeform(){
153
        List<XSLFShape> shapes = getShapeList();
154
        XSLFFreeformShape sh = getDrawing().createFreeform();
157
        XSLFFreeformShape sh = getDrawing().createFreeform();
155
        shapes.add(sh);
158
        getShapes().add(sh);
156
        sh.setParent(this);
159
        sh.setParent(this);
157
        return sh;
160
        return sh;
158
    }
161
    }
159
162
160
    public XSLFTextBox createTextBox(){
163
    public XSLFTextBox createTextBox(){
161
        List<XSLFShape> shapes = getShapeList();
162
        XSLFTextBox sh = getDrawing().createTextBox();
164
        XSLFTextBox sh = getDrawing().createTextBox();
163
        shapes.add(sh);
165
        getShapes().add(sh);
164
        sh.setParent(this);
166
        sh.setParent(this);
165
        return sh;
167
        return sh;
166
    }
168
    }
167
169
168
    public XSLFConnectorShape createConnector(){
170
    public XSLFConnectorShape createConnector(){
169
        List<XSLFShape> shapes = getShapeList();
170
        XSLFConnectorShape sh = getDrawing().createConnector();
171
        XSLFConnectorShape sh = getDrawing().createConnector();
171
        shapes.add(sh);
172
        getShapes().add(sh);
172
        sh.setParent(this);
173
        sh.setParent(this);
173
        return sh;
174
        return sh;
174
    }
175
    }
175
176
176
    public XSLFGroupShape createGroup(){
177
    public XSLFGroupShape createGroup(){
177
        List<XSLFShape> shapes = getShapeList();
178
        XSLFGroupShape sh = getDrawing().createGroup();
178
        XSLFGroupShape sh = getDrawing().createGroup();
179
        shapes.add(sh);
179
        getShapes().add(sh);
180
        sh.setParent(this);
180
        sh.setParent(this);
181
        return sh;
181
        return sh;
182
    }
182
    }
Lines 190-225 public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC Link Here
190
190
191
        XSLFPictureShape sh = getDrawing().createPicture(rel.getId());
191
        XSLFPictureShape sh = getDrawing().createPicture(rel.getId());
192
        sh.resize();
192
        sh.resize();
193
193
        getShapes().add(sh);
194
        getShapeList().add(sh);
195
        sh.setParent(this);
194
        sh.setParent(this);
196
        return sh;
195
        return sh;
197
    }
196
    }
198
197
199
    public XSLFTable createTable(){
198
    public XSLFTable createTable(){
200
        List<XSLFShape> shapes = getShapeList();
201
        XSLFTable sh = getDrawing().createTable();
199
        XSLFTable sh = getDrawing().createTable();
202
        shapes.add(sh);
200
        getShapes().add(sh);
203
        sh.setParent(this);
201
        sh.setParent(this);
204
        return sh;
202
        return sh;
205
    }
203
    }
206
204
207
    /**
205
    /**
208
     * Returns an array containing all of the shapes in this sheet
209
     *
210
     * @return an array of all shapes in this sheet
211
     */
212
    public List<XSLFShape> getShapes(){
213
        return getShapeList();
214
    }
215
216
    /**
217
     * Returns an iterator over the shapes in this sheet
206
     * Returns an iterator over the shapes in this sheet
218
     *
207
     *
219
     * @return an iterator over the shapes in this sheet
208
     * @return an iterator over the shapes in this sheet
220
     */
209
     */
221
    public Iterator<XSLFShape> iterator(){
210
    public Iterator<XSLFShape> iterator(){
222
        return getShapeList().iterator();
211
        return getShapes().iterator();
223
    }
212
    }
224
213
225
    public void addShape(XSLFShape shape) {
214
    public void addShape(XSLFShape shape) {
Lines 250-256 public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC Link Here
250
        } else {
239
        } else {
251
            throw new IllegalArgumentException("Unsupported shape: " + xShape);
240
            throw new IllegalArgumentException("Unsupported shape: " + xShape);
252
        }
241
        }
253
        return getShapeList().remove(xShape);
242
        return getShapes().remove(xShape);
254
    }
243
    }
255
244
256
    /**
245
    /**
Lines 319-326 public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC Link Here
319
        getSpTree().set(src.getSpTree());
308
        getSpTree().set(src.getSpTree());
320
309
321
        // recursively update each shape
310
        // recursively update each shape
322
        List<XSLFShape> tgtShapes = getShapeList();
311
        List<XSLFShape> tgtShapes = getShapes();
323
        List<XSLFShape> srcShapes = src.getShapeList();
312
        List<XSLFShape> srcShapes = src.getShapes();
324
        for(int i = 0; i < tgtShapes.size(); i++){
313
        for(int i = 0; i < tgtShapes.size(); i++){
325
            XSLFShape s1 = srcShapes.get(i);
314
            XSLFShape s1 = srcShapes.get(i);
326
            XSLFShape s2 = tgtShapes.get(i);
315
            XSLFShape s2 = tgtShapes.get(i);
Lines 338-344 public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC Link Here
338
     */
327
     */
339
    public XSLFSheet appendContent(XSLFSheet src){
328
    public XSLFSheet appendContent(XSLFSheet src){
340
        CTGroupShape spTree = getSpTree();
329
        CTGroupShape spTree = getSpTree();
341
        int numShapes = getShapeList().size();
330
        int numShapes = getShapes().size();
342
331
343
        CTGroupShape srcTree = src.getSpTree();
332
        CTGroupShape srcTree = src.getSpTree();
344
        for(XmlObject ch : srcTree.selectPath("*")){
333
        for(XmlObject ch : srcTree.selectPath("*")){
Lines 362-369 public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC Link Here
362
        _placeholders = null;
351
        _placeholders = null;
363
352
364
        // recursively update each shape
353
        // recursively update each shape
365
        List<XSLFShape> tgtShapes = getShapeList();
354
        List<XSLFShape> tgtShapes = getShapes();
366
        List<XSLFShape> srcShapes = src.getShapeList();
355
        List<XSLFShape> srcShapes = src.getShapes();
367
        for(int i = 0; i < srcShapes.size(); i++){
356
        for(int i = 0; i < srcShapes.size(); i++){
368
            XSLFShape s1 = srcShapes.get(i);
357
            XSLFShape s1 = srcShapes.get(i);
369
            XSLFShape s2 = tgtShapes.get(numShapes + i);
358
            XSLFShape s2 = tgtShapes.get(numShapes + i);
(-)a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java (-7 / +3 lines)
Lines 52-62 public class HSLFGroupShape extends HSLFShape implements GroupShape<HSLFShape> { Link Here
52
        super(escherRecord, parent);
52
        super(escherRecord, parent);
53
    }
53
    }
54
54
55
    @Override
56
    public List<HSLFShape> getShapes() {
57
        return getShapeList();
58
    }
59
60
    /**
55
    /**
61
     * Sets the anchor (the bounding box rectangle) of this shape.
56
     * Sets the anchor (the bounding box rectangle) of this shape.
62
     * All coordinates should be expressed in Master units (576 dpi).
57
     * All coordinates should be expressed in Master units (576 dpi).
Lines 238-244 public class HSLFGroupShape extends HSLFShape implements GroupShape<HSLFShape> { Link Here
238
    }
233
    }
239
234
240
    public Iterator<HSLFShape> iterator() {
235
    public Iterator<HSLFShape> iterator() {
241
        return getShapeList().iterator();
236
        return getShapes().iterator();
242
    }
237
    }
243
238
244
    public boolean removeShape(HSLFShape shape) {
239
    public boolean removeShape(HSLFShape shape) {
Lines 249-255 public class HSLFGroupShape extends HSLFShape implements GroupShape<HSLFShape> { Link Here
249
    /**
244
    /**
250
     * @return the shapes contained in this group container
245
     * @return the shapes contained in this group container
251
     */
246
     */
252
    protected List<HSLFShape> getShapeList() {
247
    @Override
248
    public List<HSLFShape> getShapes() {
253
        // Out escher container record should contain several
249
        // Out escher container record should contain several
254
        //  SpContainers, the first of which is the group shape itself
250
        //  SpContainers, the first of which is the group shape itself
255
        Iterator<EscherRecord> iter = _escherContainer.getChildIterator();
251
        Iterator<EscherRecord> iter = _escherContainer.getChildIterator();
(-)a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java (-2 / +1 lines)
Lines 162-168 public final class HSLFTable extends HSLFGroupShape implements TableShape { Link Here
162
    }
162
    }
163
163
164
    protected void initTable(){
164
    protected void initTable(){
165
        List<HSLFShape> shapeList = getShapeList();
165
        List<HSLFShape> shapeList = getShapes();
166
166
167
        Iterator<HSLFShape> shapeIter = shapeList.iterator();
167
        Iterator<HSLFShape> shapeIter = shapeList.iterator();
168
        while (shapeIter.hasNext()) {
168
        while (shapeIter.hasNext()) {
169
- 

Return to bug 58204