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

(-)a/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java (-12 / +68 lines)
Lines 429-435 public class XMLSlideShow extends POIXMLDocument implements SlideShow { Link Here
429
    }
429
    }
430
430
431
    /**
431
    /**
432
     * Adds a picture to the workbook.
432
     * Adds a picture to the slideshow.
433
     *
433
     *
434
     * @param pictureData       The bytes of the picture
434
     * @param pictureData       The bytes of the picture
435
     * @param format            The format of the picture.
435
     * @param format            The format of the picture.
Lines 442-469 public class XMLSlideShow extends POIXMLDocument implements SlideShow { Link Here
442
     * @see XSLFPictureData#PICTURE_TYPE_PNG
442
     * @see XSLFPictureData#PICTURE_TYPE_PNG
443
     * @see XSLFPictureData#PICTURE_TYPE_DIB
443
     * @see XSLFPictureData#PICTURE_TYPE_DIB
444
     */
444
     */
445
    public int addPicture(byte[] pictureData, int format) {
445
    @Deprecated
446
    public int addPicture(byte[] pictureData, int format)
447
    {
448
        return addPicture
449
        (
450
            pictureData,
451
            XSLFPicture.Type.findByDeprecatedPictureTypeIndex(format)
452
        ).getIndex();
453
    }
454
455
456
    /**
457
     * Adds a picture to the slideshow.
458
     *
459
     * @param pictureData       The bytes of the picture
460
     * @param type              The format of the picture
461
     *
462
     * @return the reference to this picture
463
     */
464
    public XSLFPicture.Reference addPicture
465
    (
466
        byte[] pictureData,
467
        XSLFPicture.Type format
468
    )
469
    {
446
        XSLFPictureData img = findPictureData(pictureData);
470
        XSLFPictureData img = findPictureData(pictureData);
447
        // POIXMLRelation relDesc = XSLFPictureData.RELATIONS[format];
448
471
449
        if(img == null) {
472
        int imageNumber;
450
            int imageNumber = _pictures.size();
473
        if (img == null)
451
            img = (XSLFPictureData) createRelationship(
474
        {
452
                    XSLFPictureData.RELATIONS[format], XSLFFactory.getInstance(), imageNumber + 1, true);
475
            imageNumber = _pictures.size();
476
            img = (XSLFPictureData) createRelationship
477
            (
478
                format.getDescriptor(),
479
                XSLFFactory.getInstance(),
480
                imageNumber + 1,
481
                true
482
            );
453
            _pictures.add(img);
483
            _pictures.add(img);
454
            try {
484
485
            try
486
            {
455
                OutputStream out = img.getPackagePart().getOutputStream();
487
                OutputStream out = img.getPackagePart().getOutputStream();
456
                out.write(pictureData);
488
                out.write(pictureData);
457
                out.close();
489
                out.close();
458
            } catch (IOException e) {
490
            }
491
            catch (IOException e)
492
            {
459
                throw new POIXMLException(e);
493
                throw new POIXMLException(e);
460
            }
494
            }
461
            return _pictures.size() - 1;
462
        } else {
463
            return _pictures.indexOf(img);
464
        }
495
        }
496
        else
497
        {
498
            imageNumber = _pictures.indexOf(img);
499
        }
500
501
        return new XSLFPicture.Reference(format, imageNumber);
465
    }
502
    }
466
503
504
505
    /**
506
     * Adds a picture to the slideshow.
507
     *
508
     * @param is                The stream to read image from
509
     * @param type              The format of the picture
510
     *
511
     * @return the reference to this picture
512
     */
513
    public XSLFPicture.Reference addPicture
514
    (
515
        InputStream is,
516
        XSLFPicture.Type format
517
    ) throws IOException
518
    {
519
        return addPicture(IOUtils.toByteArray(is), format);
520
    }
521
522
467
    /**
523
    /**
468
     * check if a picture with this picture data already exists in this presentation
524
     * check if a picture with this picture data already exists in this presentation
469
     */
525
     */
(-)a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFGroupShape.java (-5 / +39 lines)
Lines 239-247 public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, Gro Link Here
239
        return sh;
239
        return sh;
240
    }
240
    }
241
241
242
    public XSLFPictureShape createPicture(int pictureIndex){
242
    @Deprecated
243
243
    public XSLFPictureShape createPicture(int pictureIndex)
244
        List<PackagePart>  pics = getSheet().getPackagePart().getPackage()
244
    {
245
        List<PackagePart> pics = getSheet().getPackagePart().getPackage()
245
                .getPartsByName(Pattern.compile("/ppt/media/image" + (pictureIndex + 1) + ".*?"));
246
                .getPartsByName(Pattern.compile("/ppt/media/image" + (pictureIndex + 1) + ".*?"));
246
247
247
        if(pics.size() == 0) {
248
        if(pics.size() == 0) {
Lines 260-265 public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, Gro Link Here
260
        return sh;
261
        return sh;
261
    }
262
    }
262
263
264
265
    @Override
266
    public XSLFPictureShape createPicture(XSLFPicture.Reference picref)
267
    {
268
        int pictureIndex = picref.getIndex1();
269
        List<PackagePart> pics = getSheet().getPackagePart().getPackage()
270
            .getPartsByName(Pattern.compile("/ppt/media/image" + pictureIndex + "\\..+"));
271
272
        if (pics.isEmpty())
273
        {
274
            throw new IllegalArgumentException("Picture with index=" + pictureIndex + " was not found");
275
        }
276
277
        PackagePart pic = pics.get(0);
278
279
        PackageRelationship rel = getSheet().getPackagePart().addRelationship
280
        (
281
            pic.getPartName(), TargetMode.INTERNAL, XSLFRelation.IMAGES.getRelation()
282
        );
283
284
        XSLFPictureShape sh = getDrawing().createPicture(rel.getId());
285
        sh.resize();
286
        _shapes.add(sh);
287
        sh.setParent(this);
288
        return sh;
289
    }
290
291
263
    public XSLFTable createTable(){
292
    public XSLFTable createTable(){
264
        XSLFTable sh = getDrawing().createTable();
293
        XSLFTable sh = getDrawing().createTable();
265
        _shapes.add(sh);
294
        _shapes.add(sh);
Lines 321-328 public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, Gro Link Here
321
            } else if (shape instanceof XSLFPictureShape) {
350
            } else if (shape instanceof XSLFPictureShape) {
322
                XSLFPictureShape p = (XSLFPictureShape)shape;
351
                XSLFPictureShape p = (XSLFPictureShape)shape;
323
                XSLFPictureData pd = p.getPictureData();
352
                XSLFPictureData pd = p.getPictureData();
324
                int picId = getSheet().getSlideShow().addPicture(pd.getData(), pd.getPictureType());
353
325
                newShape = createPicture(picId);
354
                // OLD // int picId = getSheet().getSlideShow().addPicture(pd.getData(), pd.getPictureType());
355
                // OLD // newShape = createPicture(picId);
356
                newShape = createPicture
357
                (
358
                    getSheet().getSlideShow().addPicture(pd.getData(), pd.getType())
359
                );
326
            } else if (shape instanceof XSLFGroupShape) {
360
            } else if (shape instanceof XSLFGroupShape) {
327
                newShape = createGroup();
361
                newShape = createGroup();
328
            } else if (shape instanceof XSLFTable) {
362
            } else if (shape instanceof XSLFTable) {
(-)a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPicture.java (+215 lines)
Line 0 Link Here
1
/*
2
 *  ====================================================================
3
 *    Licensed to the Apache Software Foundation (ASF) under one or more
4
 *    contributor license agreements.  See the NOTICE file distributed with
5
 *    this work for additional information regarding copyright ownership.
6
 *    The ASF licenses this file to You under the Apache License, Version 2.0
7
 *    (the "License"); you may not use this file except in compliance with
8
 *    the License.  You may obtain a copy of the License at
9
 *
10
 *        http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 *    Unless required by applicable law or agreed to in writing, software
13
 *    distributed under the License is distributed on an "AS IS" BASIS,
14
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 *    See the License for the specific language governing permissions and
16
 *    limitations under the License.
17
 * ====================================================================
18
 */
19
20
package org.apache.poi.xslf.usermodel;
21
22
import org.apache.poi.POIXMLRelation;
23
import org.apache.poi.util.Beta;
24
25
/**
26
 * Manages picture types and references for adding images to a slideshow
27
 */
28
@Beta
29
public class XSLFPicture
30
{
31
    /** Utility class */
32
    private XSLFPicture() {}
33
34
35
    /**
36
     * Supported picture types for a slideshow
37
     */
38
    public enum Type
39
    {
40
        /** Extended windows meta file (.emf) */
41
        EMF("emf",      XSLFRelation.IMAGE_EMF, 2),
42
43
        /** Windows Meta File (.wmf) */
44
        WMF("wmf",      XSLFRelation.IMAGE_WMF, 3),
45
46
        /** Mac PICT format (.pict) */
47
        PICT("pict",    XSLFRelation.IMAGE_PICT, 4),
48
49
        /** JPEG format (.jpeg) */
50
        JPEG("jpeg",    XSLFRelation.IMAGE_JPEG, 5),
51
52
        /** PNG format (.png) */
53
        PNG("png",      XSLFRelation.IMAGE_PNG, 6),
54
55
        /** Device independent bitmap (.dib) */
56
        DIB("dib",      XSLFRelation.IMAGE_DIB, 7),
57
58
        /** GIF image format (.gif) */
59
        GIF("gif",      XSLFRelation.IMAGE_GIF, 8),
60
61
        /** Tag Image File (.tiff) */
62
        TIFF("tiff",    XSLFRelation.IMAGE_TIFF, 9),
63
64
        /** Encapsulated Postscript (.eps) */
65
        EPS("eps",      XSLFRelation.IMAGE_EPS, 10),
66
67
        /** Windows Bitmap (.bmp) */
68
        BMG("bmp",      XSLFRelation.IMAGE_BMP, 11),
69
70
        /** WordPerfect graphics (.wpg) */
71
        WPG("wpg",      XSLFRelation.IMAGE_WPG, 12),
72
73
        /** Microsoft Windows Media Photo image (.wdp) */
74
        WDP("wdp",      XSLFRelation.IMAGE_WDP, 13);
75
76
        private String formatName;
77
        private POIXMLRelation descriptor;
78
79
        private Type(String formatName, XSLFRelation descriptor)
80
        {
81
            this.formatName = formatName;
82
            this.descriptor = descriptor;
83
        }
84
85
        /**
86
         * For transition purposes only - do not use for new code.
87
         * This value matches the PICTURE_TYPE_* constants from XSLFPictudeData
88
         */
89
        @Deprecated private int compat;
90
91
        @Deprecated private Type(String formatName, XSLFRelation descriptor, int compatibility)
92
        {
93
            this(formatName, descriptor);
94
            compat = compatibility;
95
        }
96
97
98
        /** The informal format name */
99
        public String getFormatName()
100
        {
101
            return formatName;
102
        }
103
104
105
        /** The part descriptor (XSLFRelation) */
106
        public POIXMLRelation getDescriptor()
107
        {
108
            return descriptor;
109
        }
110
111
        /**
112
         * For transition purposes only - do not use for new code.
113
         * This value matches the PICTURE_TYPE_* constants from XSLFPictudeData
114
         */
115
        @Deprecated
116
        public int getDeprecatedPictureTypeIndex()
117
        {
118
            return compat;
119
        }
120
121
122
        /** The (mime) content-type */
123
        public String getContentType()
124
        {
125
            return descriptor.getContentType();
126
        }
127
128
129
        /** String representation = format name (for now) */
130
        @Override
131
        public String toString()
132
        {
133
            return formatName;
134
        }
135
136
137
        /**
138
         * Find the enumeration corresponding to specified content-type,
139
         * null on failure.
140
         */
141
        public static Type findByContentType(String contentType)
142
        {
143
            for (Type type : Type.values())
144
            {
145
                if (type.getContentType().equals(contentType))
146
                {
147
                    return type;
148
                }
149
            }
150
151
            return null;
152
        }
153
154
        /**
155
         * Find the enumeration corresponding to specified content-type,
156
         * null on failure.
157
         */
158
        @Deprecated
159
        /*package*/ static Type findByDeprecatedPictureTypeIndex(int typeIndex)
160
        {
161
            for (Type type : Type.values())
162
            {
163
                if (type.compat == typeIndex)
164
                {
165
                    return type;
166
                }
167
            }
168
169
            return null;
170
        }
171
    }
172
173
174
    /**
175
     * An indexed reference to an image within the slideshow
176
     */
177
    public static class Reference
178
    {
179
        /* Picture type */
180
        private Type type_;
181
182
        /** The 0-based index */
183
        private int index_;
184
185
        /* package */ Reference(Type type, int index)
186
        {
187
            type_  = type;
188
            index_ = index;
189
        }
190
191
192
        /** Return the type */
193
        public Type getType()
194
        {
195
            return type_;
196
        }
197
198
199
        /** Return the 0-based picture index */
200
        public int getIndex()
201
        {
202
            return index_;
203
        }
204
205
206
        /** Return the 1-based picture index */
207
        public int getIndex1()
208
        {
209
            return index_ + 1;
210
        }
211
    }
212
213
}
214
215
// ************************************************************************* //
(-)a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFPictureData.java (-84 / +62 lines)
Lines 24-30 import java.io.OutputStream; Link Here
24
24
25
import org.apache.poi.POIXMLDocumentPart;
25
import org.apache.poi.POIXMLDocumentPart;
26
import org.apache.poi.POIXMLException;
26
import org.apache.poi.POIXMLException;
27
import org.apache.poi.POIXMLRelation;
28
import org.apache.poi.openxml4j.opc.PackagePart;
27
import org.apache.poi.openxml4j.opc.PackagePart;
29
import org.apache.poi.openxml4j.opc.PackageRelationship;
28
import org.apache.poi.openxml4j.opc.PackageRelationship;
30
import org.apache.poi.sl.usermodel.PictureData;
29
import org.apache.poi.sl.usermodel.PictureData;
Lines 38-124 import org.apache.poi.util.IOUtils; Link Here
38
 */
37
 */
39
@Beta
38
@Beta
40
public final class XSLFPictureData extends POIXMLDocumentPart implements PictureData {
39
public final class XSLFPictureData extends POIXMLDocumentPart implements PictureData {
41
    /**
42
     * Extended windows meta file
43
     */
44
    public static final int PICTURE_TYPE_EMF = 2;
45
40
46
    /**
41
    /** Extended windows meta file */
47
     * Windows Meta File
42
    @Deprecated public static final int PICTURE_TYPE_EMF = 2;
48
     */
49
    public static final int PICTURE_TYPE_WMF = 3;
50
43
51
    /**
44
    /** Windows Meta File */
52
     * Mac PICT format
45
    @Deprecated public static final int PICTURE_TYPE_WMF = 3;
53
     */
54
    public static final int PICTURE_TYPE_PICT = 4;
55
46
56
    /**
47
    /** Mac PICT format */
57
     * JPEG format
48
    @Deprecated public static final int PICTURE_TYPE_PICT = 4;
58
     */
59
    public static final int PICTURE_TYPE_JPEG = 5;
60
49
61
    /**
50
    /** JPEG format */
62
     * PNG format
51
    @Deprecated public static final int PICTURE_TYPE_JPEG = 5;
63
     */
64
    public static final int PICTURE_TYPE_PNG = 6;
65
52
66
    /**
53
    /** PNG format */
67
     * Device independent bitmap
54
    @Deprecated public static final int PICTURE_TYPE_PNG = 6;
68
     */
69
    public static final int PICTURE_TYPE_DIB = 7;
70
55
71
    /**
56
    /** Device independent bitmap */
72
     * GIF image format
57
    @Deprecated public static final int PICTURE_TYPE_DIB = 7;
73
     */
74
    public static final int PICTURE_TYPE_GIF = 8;
75
58
76
    /**
59
    /** GIF image format */
77
     * Tag Image File (.tiff)
60
    @Deprecated public static final int PICTURE_TYPE_GIF = 8;
78
     */
79
    public static final int PICTURE_TYPE_TIFF = 9;
80
61
81
    /**
62
    /** Tag Image File (.tiff) */
82
     * Encapsulated Postscript (.eps)
63
    @Deprecated public static final int PICTURE_TYPE_TIFF = 9;
83
     */
84
    public static final int PICTURE_TYPE_EPS = 10;
85
64
65
    /** Encapsulated Postscript (.eps) */
66
    @Deprecated public static final int PICTURE_TYPE_EPS = 10;
86
67
87
    /**
68
    /** Windows Bitmap (.bmp) */
88
     * Windows Bitmap (.bmp)
69
    @Deprecated public static final int PICTURE_TYPE_BMP = 11;
89
     */
90
    public static final int PICTURE_TYPE_BMP = 11;
91
70
92
    /**
71
    /** WordPerfect graphics (.wpg) */
93
     * WordPerfect graphics (.wpg)
72
    @Deprecated public static final int PICTURE_TYPE_WPG = 12;
94
     */
95
    public static final int PICTURE_TYPE_WPG = 12;
96
73
97
    /**
74
    /** Microsoft Windows Media Photo image (.wdp) */
98
     * Microsoft Windows Media Photo image (.wdp)
75
    @Deprecated public static final int PICTURE_TYPE_WDP = 13;
99
     */
100
    public static final int PICTURE_TYPE_WDP = 13;
101
76
102
    /**
103
     * Relationships for each known picture type
104
     */
105
    protected static final POIXMLRelation[] RELATIONS;
106
107
    static {
108
        RELATIONS = new POIXMLRelation[14];
109
        RELATIONS[PICTURE_TYPE_EMF] = XSLFRelation.IMAGE_EMF;
110
        RELATIONS[PICTURE_TYPE_WMF] = XSLFRelation.IMAGE_WMF;
111
        RELATIONS[PICTURE_TYPE_PICT] = XSLFRelation.IMAGE_PICT;
112
        RELATIONS[PICTURE_TYPE_JPEG] = XSLFRelation.IMAGE_JPEG;
113
        RELATIONS[PICTURE_TYPE_PNG] = XSLFRelation.IMAGE_PNG;
114
        RELATIONS[PICTURE_TYPE_DIB] = XSLFRelation.IMAGE_DIB;
115
        RELATIONS[PICTURE_TYPE_GIF] = XSLFRelation.IMAGE_GIF;
116
        RELATIONS[PICTURE_TYPE_TIFF] = XSLFRelation.IMAGE_TIFF;
117
        RELATIONS[PICTURE_TYPE_EPS] = XSLFRelation.IMAGE_EPS;
118
        RELATIONS[PICTURE_TYPE_BMP] = XSLFRelation.IMAGE_BMP;
119
        RELATIONS[PICTURE_TYPE_WPG] = XSLFRelation.IMAGE_WPG;
120
        RELATIONS[PICTURE_TYPE_WDP] = XSLFRelation.IMAGE_WDP;
121
    }
122
77
123
    private Long checksum = null;
78
    private Long checksum = null;
124
79
Lines 187-204 public final class XSLFPictureData extends POIXMLDocumentPart implements Picture Link Here
187
     *
142
     *
188
     * @return an integer constant that specifies type of this picture
143
     * @return an integer constant that specifies type of this picture
189
     */
144
     */
145
    @Deprecated
190
    public int getPictureType() {
146
    public int getPictureType() {
191
        String contentType = getPackagePart().getContentType();
147
        // OLD // String contentType = getPackagePart().getContentType();
192
        for (int i = 0; i < RELATIONS.length; i++) {
148
        // OLD // for (int i = 0; i < RELATIONS.length; i++) {
193
            if (RELATIONS[i] == null) {
149
        // OLD //     if (RELATIONS[i] == null) {
194
                continue;
150
        // OLD //         continue;
195
            }
151
        // OLD //     }
196
152
        // OLD //
197
            if (RELATIONS[i].getContentType().equals(contentType)) {
153
        // OLD //     if (RELATIONS[i].getContentType().equals(contentType)) {
198
                return i;
154
        // OLD //         return i;
199
            }
155
        // OLD //     }
200
        }
156
        // OLD // }
201
        return 0;
157
        // OLD // return 0;
158
159
        XSLFPicture.Type type = getType();
160
        return type == null ? 0 : type.getDeprecatedPictureTypeIndex();
202
    }
161
    }
203
162
204
    long getChecksum(){
163
    long getChecksum(){
Lines 217-232 public final class XSLFPictureData extends POIXMLDocumentPart implements Picture Link Here
217
    protected void prepareForCommit() {
176
    protected void prepareForCommit() {
218
        // do not clear the part here
177
        // do not clear the part here
219
    }
178
    }
220
    
179
221
    public String getContentType() {
180
222
        POIXMLRelation rel = RELATIONS[getPictureType()];
181
    /**
223
        return (rel == null) ? null : rel.getContentType();
182
     * Return the enum corresponding to the type of this picture content,
183
     * null on failure
184
     */
185
    public XSLFPicture.Type getType()
186
    {
187
        return XSLFPicture.Type.findByContentType(getPackagePart().getContentType());
224
    }
188
    }
225
189
190
191
    public String getContentType()
192
    {
193
        // OLD // POIXMLRelation rel = RELATIONS[getPictureType()];
194
        // OLD // return (rel == null) ? null : rel.getContentType();
195
196
        XSLFPicture.Type type = getType();
197
        return (type == null) ? null : type.getContentType();
198
    }
199
200
    @Override
226
    public void setData(byte[] data) throws IOException {
201
    public void setData(byte[] data) throws IOException {
227
        OutputStream os = getPackagePart().getOutputStream();
202
        OutputStream os = getPackagePart().getOutputStream();
228
        os.write(data);
203
        os.write(data);
229
        os.close();
204
        os.close();
205
206
        // checksum is invalid
207
        checksum = null;
230
    }
208
    }
231
    
209
    
232
    
210
    
(-)a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShapeContainer.java (-3 / +4 lines)
Lines 42-48 public interface XSLFShapeContainer extends ShapeContainer<XSLFShape> { Link Here
42
    XSLFTextBox createTextBox();
42
    XSLFTextBox createTextBox();
43
43
44
    /**
44
    /**
45
     *
46
     * create a connector
45
     * create a connector
47
     */
46
     */
48
    XSLFConnectorShape createConnector();
47
    XSLFConnectorShape createConnector();
Lines 53-61 public interface XSLFShapeContainer extends ShapeContainer<XSLFShape> { Link Here
53
    XSLFGroupShape createGroup();
52
    XSLFGroupShape createGroup();
54
53
55
    /**
54
    /**
56
     * create a picture belonging to this container
55
     * create a picture belonging to this container.
56
     * The picture will have been previously added via the
57
     * XMLSlideShow.addPicture() method
57
     */
58
     */
58
    XSLFPictureShape createPicture(int pictureIndex);
59
    XSLFPictureShape createPicture(XSLFPicture.Reference picref);
59
60
60
    /**
61
    /**
61
     * Removes all of the elements from this container (optional operation).
62
     * Removes all of the elements from this container (optional operation).
(-)a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java (-3 / +37 lines)
Lines 182-187 public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC Link Here
182
        return sh;
182
        return sh;
183
    }
183
    }
184
184
185
    @Deprecated
185
    public XSLFPictureShape createPicture(int pictureIndex){
186
    public XSLFPictureShape createPicture(int pictureIndex){
186
        List<PackagePart>  pics = getPackagePart().getPackage()
187
        List<PackagePart>  pics = getPackagePart().getPackage()
187
                .getPartsByName(Pattern.compile("/ppt/media/image" + (pictureIndex + 1) + ".*?"));
188
                .getPartsByName(Pattern.compile("/ppt/media/image" + (pictureIndex + 1) + ".*?"));
Lines 204-209 public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC Link Here
204
        return sh;
205
        return sh;
205
    }
206
    }
206
207
208
209
    @Override
210
    public XSLFPictureShape createPicture(XSLFPicture.Reference picref)
211
    {
212
        int pictureIndex = picref.getIndex1();
213
        List<PackagePart> pics = getPackagePart().getPackage()
214
            .getPartsByName(Pattern.compile("/ppt/media/image" + pictureIndex + "\\..*"));
215
216
        if (pics.isEmpty())
217
        {
218
            throw new IllegalArgumentException("Picture with index=" + pictureIndex + " was not found");
219
        }
220
221
        PackagePart pic = pics.get(0);
222
        PackageRelationship rel = getPackagePart().addRelationship
223
        (
224
            pic.getPartName(), TargetMode.INTERNAL, XSLFRelation.IMAGES.getRelation()
225
        );
226
        addRelation(rel.getId(), new XSLFPictureData(pic, rel));
227
228
        XSLFPictureShape sh = getDrawing().createPicture(rel.getId());
229
        sh.resize();
230
231
        getShapeList().add(sh);
232
        sh.setParent(this);
233
        return sh;
234
    }
235
236
207
    public XSLFTable createTable(){
237
    public XSLFTable createTable(){
208
        List<XSLFShape> shapes = getShapeList();
238
        List<XSLFShape> shapes = getShapeList();
209
        XSLFTable sh = getDrawing().createTable();
239
        XSLFTable sh = getDrawing().createTable();
Lines 525-532 public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC Link Here
525
        XSLFPictureData data = new XSLFPictureData(blipPart, null);
555
        XSLFPictureData data = new XSLFPictureData(blipPart, null);
526
556
527
        XMLSlideShow ppt = getSlideShow();
557
        XMLSlideShow ppt = getSlideShow();
528
        int pictureIdx = ppt.addPicture(data.getData(), data.getPictureType());
558
        // OLD // int pictureIdx = ppt.addPicture(data.getData(), data.getPictureType());
529
        PackagePart pic = ppt.getAllPictures().get(pictureIdx).getPackagePart();
559
        // OLD // PackagePart pic = ppt.getAllPictures().get(pictureIdx).getPackagePart();
560
561
        PackagePart pic = ppt.getAllPictures().get
562
        (
563
            ppt.addPicture(data.getData(), data.getType()).getIndex()
564
        ).getPackagePart();
530
565
531
        PackageRelationship rel = getPackagePart().addRelationship(
566
        PackageRelationship rel = getPackagePart().addRelationship(
532
                pic.getPartName(), TargetMode.INTERNAL, blipRel.getRelationshipType());
567
                pic.getPartName(), TargetMode.INTERNAL, blipRel.getRelationshipType());
533
- 

Return to bug 58190