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

(-)src/scratchpad/src/org/apache/poi/hslf/usermodel/ObjectData.java (+51 lines)
Line 0 Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
package org.apache.poi.hslf.usermodel;
18
19
import java.io.InputStream;
20
21
import org.apache.poi.hslf.record.ExOleObjStg;
22
23
/**
24
 * A class that represents object data embedded in a slide show.
25
 *
26
 * @author Daniel Noll
27
 */
28
public class ObjectData {
29
    /**
30
     * The record that contains the object data.
31
     */
32
    private ExOleObjStg storage;
33
34
    /**
35
     * Creates the object data wrapping the record that contains the object data.
36
     *
37
     * @param storage the record that contains the object data.
38
     */
39
    public ObjectData(ExOleObjStg storage) {
40
        this.storage = storage;
41
    }
42
43
    /**
44
     * Gets an input stream which returns the binary of the embedded data.
45
     *
46
     * @return the input stream which will contain the binary of the embedded data.
47
     */
48
    public InputStream getData() {
49
        return storage.getData();
50
    }
51
}
(-)src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java (-4 / +4 lines)
Lines 98-108 Link Here
98
    public static final Type FontEmbeddedData = new Type(4024,null);
98
    public static final Type FontEmbeddedData = new Type(4024,null);
99
    public static final Type CString = new Type(4026,CString.class);
99
    public static final Type CString = new Type(4026,CString.class);
100
    public static final Type MetaFile = new Type(4033,null);
100
    public static final Type MetaFile = new Type(4033,null);
101
    public static final Type ExOleObjAtom = new Type(4035,null);
101
    public static final Type ExOleObjAtom = new Type(4035,ExOleObjAtom.class);
102
    public static final Type SrKinsoku = new Type(4040,null);
102
    public static final Type SrKinsoku = new Type(4040,null);
103
    public static final Type HandOut = new Type(4041,null);
103
    public static final Type HandOut = new Type(4041,null);
104
    public static final Type ExEmbed = new Type(4044,null);
104
    public static final Type ExEmbed = new Type(4044,ExEmbed.class);
105
    public static final Type ExEmbedAtom = new Type(4045,null);
105
    public static final Type ExEmbedAtom = new Type(4045,ExEmbedAtom.class);
106
    public static final Type ExLink = new Type(4046,null);
106
    public static final Type ExLink = new Type(4046,null);
107
    public static final Type BookmarkEntityAtom = new Type(4048,null);
107
    public static final Type BookmarkEntityAtom = new Type(4048,null);
108
    public static final Type ExLinkAtom = new Type(4049,null);
108
    public static final Type ExLinkAtom = new Type(4049,null);
Lines 136-142 Link Here
136
    public static final Type ExCDAudio = new Type(4110,null);
136
    public static final Type ExCDAudio = new Type(4110,null);
137
    public static final Type ExWAVAudioEmbedded = new Type(4111,null);
137
    public static final Type ExWAVAudioEmbedded = new Type(4111,null);
138
    public static final Type ExWAVAudioLink = new Type(4112,null);
138
    public static final Type ExWAVAudioLink = new Type(4112,null);
139
    public static final Type ExOleObjStg = new Type(4113,null);
139
    public static final Type ExOleObjStg = new Type(4113,ExOleObjStg.class);
140
    public static final Type ExCDAudioAtom = new Type(4114,null);
140
    public static final Type ExCDAudioAtom = new Type(4114,null);
141
    public static final Type ExWAVAudioEmbeddedAtom = new Type(4115,null);
141
    public static final Type ExWAVAudioEmbeddedAtom = new Type(4115,null);
142
    public static final Type AnimationInfoAtom = new Type(4116,null);
142
    public static final Type AnimationInfoAtom = new Type(4116,null);
(-)src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java (+112 lines)
Line 0 Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
18
package org.apache.poi.hslf.record;
19
20
import java.io.ByteArrayInputStream;
21
import java.io.IOException;
22
import java.io.InputStream;
23
import java.io.OutputStream;
24
import java.util.zip.InflaterInputStream;
25
26
import org.apache.poi.util.LittleEndian;
27
28
/**
29
 * Storage for embedded OLE objects.
30
 *
31
 * @author Daniel Noll
32
 */
33
public class ExOleObjStg extends RecordAtom {
34
    /**
35
     * Record header.
36
     */
37
    private byte[] _header;
38
39
    /**
40
     * Record data.
41
     */
42
    private byte[] _data;
43
44
    /**
45
     * Constructs a new empty storage container.
46
     */
47
    protected ExOleObjStg() {
48
        _header = new byte[8];
49
        _data = new byte[0];
50
51
        LittleEndian.putShort(_header, 2, (short)getRecordType());
52
        LittleEndian.putInt(_header, 4, _data.length);
53
    }
54
55
    /**
56
     * Constructs the link related atom record from its
57
     *  source data.
58
     *
59
     * @param source the source data as a byte array.
60
     * @param start the start offset into the byte array.
61
     * @param len the length of the slice in the byte array.
62
     */
63
    protected ExOleObjStg(byte[] source, int start, int len) {
64
        // Get the header.
65
        _header = new byte[8];
66
        System.arraycopy(source,start,_header,0,8);
67
68
        // Get the record data.
69
        _data = new byte[len-8];
70
        System.arraycopy(source,start+8,_data,0,len-8);
71
    }
72
73
    /**
74
     * Gets the uncompressed length of the data.
75
     *
76
     * @return the uncompressed length of the data.
77
     */
78
    public int getDataLength() {
79
        return LittleEndian.getInt(_data, 0);
80
    }
81
82
    /**
83
     * Opens an input stream which will decompress the data on the fly.
84
     *
85
     * @return the data input stream.
86
     */
87
    public InputStream getData() {
88
        InputStream compressedStream = new ByteArrayInputStream(_data, 4, _data.length);
89
        return new InflaterInputStream(compressedStream);
90
    }
91
92
    /**
93
     * Gets the record type.
94
     *
95
     * @return the record type.
96
     */
97
    public long getRecordType() {
98
        return RecordTypes.ExOleObjStg.typeID;
99
    }
100
101
    /**
102
     * Write the contents of the record back, so it can be written
103
     * to disk.
104
     *
105
     * @param out the output stream to write to.
106
     * @throws IOException if an error occurs.
107
     */
108
    public void writeOut(OutputStream out) throws IOException {
109
        out.write(_header);
110
        out.write(_data);
111
    }
112
}
(-)src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjAtom.java (+213 lines)
Line 0 Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
18
package org.apache.poi.hslf.record;
19
20
import java.io.IOException;
21
import java.io.OutputStream;
22
23
import org.apache.poi.util.LittleEndian;
24
25
/**
26
 * Atom storing information for an OLE object.
27
 *
28
 * <!--
29
 * offset   type    name         description
30
 *
31
 * 0        uint4   drawAspect   Stores whether the object can be completely seen
32
 *                               (value of 1), or if only the icon is visible (value of 4).
33
 *
34
 * 4        sint4    type        Specifies whether the object is embedded or linked.
35
 *                               0 - embedded
36
 *                               1 - linked
37
 *
38
 * 8        sint4    objID       Unique identifier for the OLE object
39
 *
40
 * 2        sint4    subType     This specifies the type of ole object.
41
 *                               0 - Default object
42
 *                               1 - Microsoft Clipart Gallery
43
 *                               2 - Microsoft Word table
44
 *                               3 - Microsoft Excel
45
 *                               4 - Microsoft Graph
46
 *                               5 - Microsoft Organization Chart
47
 *                               6 - Microsoft Equation Editor
48
 *                               7 - Microsoft Wordart object
49
 *                               8 - Sound
50
 *                               9 - Image
51
 *                               10 - PowerPoint presentation
52
 *                               11 - PowerPoint slide
53
 *                               12 - Microsoft Project
54
 *                               13 - Microsoft Note-It Ole
55
 *                               14 - Microsoft Excel chart
56
 *                               15 - Media Player object
57
 *
58
 * 16       sint4    objStgDataRef    Reference to persist object
59
 *
60
 * 20       bool1    isBlank          Set if the object's image is blank
61
 *           (note: KOffice has this as an int.)
62
 * -->
63
 *
64
 * @author Daniel Noll
65
 */
66
public class ExOleObjAtom extends RecordAtom {
67
68
    public static final int DRAW_ASPECT_VISIBLE = 1;
69
    public static final int DRAW_ASPECT_ICON = 4;
70
71
    public static final int TYPE_EMBEDDED = 0;
72
    public static final int TYPE_LINKED = 1;
73
74
    public static final int SUBTYPE_DEFAULT = 0;
75
    public static final int SUBTYPE_CLIPART_GALLERY = 1;
76
    public static final int SUBTYPE_WORD_TABLE = 2;
77
    public static final int SUBTYPE_EXCEL = 3;
78
    public static final int SUBTYPE_GRAPH = 4;
79
    public static final int SUBTYPE_ORGANIZATION_CHART = 5;
80
    public static final int SUBTYPE_EQUATION = 6;
81
    public static final int SUBTYPE_WORDART = 7;
82
    public static final int SUBTYPE_SOUND = 8;
83
    public static final int SUBTYPE_IMAGE = 9;
84
    public static final int SUBTYPE_POWERPOINT_PRESENTATION = 10;
85
    public static final int SUBTYPE_POWERPOINT_SLIDE = 11;
86
    public static final int SUBTYPE_PROJECT = 12;
87
    public static final int SUBTYPE_NOTEIT = 13;
88
    public static final int SUBTYPE_EXCEL_CHART = 14;
89
    public static final int SUBTYPE_MEDIA_PLAYER = 15;
90
91
    /**
92
     * Record header.
93
     */
94
    private byte[] _header;
95
96
    /**
97
     * Record data.
98
     */
99
    private byte[] _data;
100
101
    /**
102
     * Constructs a brand new link related atom record.
103
     */
104
    protected ExOleObjAtom() {
105
        _header = new byte[8];
106
        _data = new byte[18];
107
108
        LittleEndian.putShort(_header, 2, (short)getRecordType());
109
        LittleEndian.putInt(_header, 4, _data.length);
110
111
        // I hope it is fine for the other values to be zero.
112
    }
113
114
    /**
115
     * Constructs the link related atom record from its
116
     *  source data.
117
     *
118
     * @param source the source data as a byte array.
119
     * @param start the start offset into the byte array.
120
     * @param len the length of the slice in the byte array.
121
     */
122
    protected ExOleObjAtom(byte[] source, int start, int len) {
123
        // Get the header.
124
        _header = new byte[8];
125
        System.arraycopy(source,start,_header,0,8);
126
127
        // Get the record data.
128
        _data = new byte[len-8];
129
        System.arraycopy(source,start+8,_data,0,len-8);
130
131
        // Must be at least 24 bytes long
132
        if(_data.length < 24) {
133
        	throw new IllegalArgumentException("The length of the data for a ExOleObjAtom must be at least 24 bytes, but was only " + _data.length);
134
        }
135
    }
136
137
    /**
138
     * Gets whether the object can be completely seen, or if only the
139
     * icon is visible.
140
     *
141
     * @return the draw aspect, one of the {@code DRAW_ASPECT_*} constants.
142
     */
143
    public int getDrawAspect() {
144
        return LittleEndian.getInt(_data, 0);
145
    }
146
147
    /**
148
     * Gets whether the object is embedded or linked.
149
     *
150
     * @return the type, one of the {@code TYPE_EMBEDDED_*} constants.
151
     */
152
    public int getType() {
153
        return LittleEndian.getInt(_data, 4);
154
    }
155
156
    /**
157
     * Gets the unique identifier for the OLE object.
158
     *
159
     * @return the object ID.
160
     */
161
    public int getObjID() {
162
        return LittleEndian.getInt(_data, 8);
163
    }
164
165
    /**
166
     * Gets the type of OLE object.
167
     * 
168
     * @return the sub-type, one of the {@code SUBTYPE_*} constants.
169
     */
170
    public int getSubType() {
171
        return LittleEndian.getInt(_data, 12);
172
    }
173
174
    /**
175
     * Gets the reference to the persistent object
176
     *
177
     * @return the reference to the persistent object, corresponds with an
178
     *         {@code ExOleObjStg} storage container.
179
     */
180
    public int getObjStgDataRef() {
181
        return LittleEndian.getInt(_data, 16);
182
    }
183
184
    /**
185
     * Gets whether the object's image is blank.
186
     *
187
     * @return {@code true} if the object's image is blank.
188
     */
189
    public boolean getIsBlank() {
190
        // Even though this is a mere boolean, KOffice's code says it's an int.
191
        return LittleEndian.getInt(_data, 20) != 0;
192
    }
193
    
194
    /**
195
     * Returns the type (held as a little endian in bytes 3 and 4)
196
     * that this class handles.
197
     */
198
    public long getRecordType() {
199
        return RecordTypes.ExOleObjAtom.typeID;
200
    }
201
202
    /**
203
     * Have the contents printer out into an OutputStream, used when
204
     * writing a file back out to disk
205
     * (Normally, atom classes will keep their bytes around, but
206
     * non atom classes will just request the bytes from their
207
     * children, then chuck on their header and return)
208
     */
209
    public void writeOut(OutputStream out) throws IOException {
210
        out.write(_header);
211
        out.write(_data);
212
    }
213
}
(-)src/scratchpad/src/org/apache/poi/hslf/record/ExEmbedAtom.java (+161 lines)
Line 0 Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
18
package org.apache.poi.hslf.record;
19
20
import java.io.IOException;
21
import java.io.OutputStream;
22
23
import org.apache.poi.util.LittleEndian;
24
25
/**
26
 * The atom that holds metadata on a specific embedded object in the document.
27
 *
28
 * <!--
29
 * 0    sint4    followColorScheme  This field indicates how the object follows the color scheme. Valid values are:
30
 *                                  0 - doesn't follow the color scheme
31
 *                                  1 - follows the entire color scheme
32
 *                                  2 - follows the text and background scheme
33
 *
34
 * 4    bool1    cantLockServerB    Set if the embedded server can not be locked
35
 * 5    bool1    noSizeToServerB    Set if don't need to send the dimension to the embedded object
36
 * 6    Bool1    isTable            Set if the object is a Word table
37
 * -->
38
 *
39
 * @author Daniel Noll
40
 */
41
public class ExEmbedAtom extends RecordAtom {
42
43
    /**
44
     * Embedded document does not follow the color scheme.
45
     */
46
    public static final int DOES_NOT_FOLLOW_COLOR_SCHEME = 0;
47
48
    /**
49
     * Embedded document follows the entire color scheme.
50
     */
51
    public static final int FOLLOWS_ENTIRE_COLOR_SCHEME = 1;
52
53
    /**
54
     * Embedded document follows the text and background scheme.
55
     */
56
    public static final int FOLLOWS_TEXT_AND_BACKGROUND_SCHEME = 2;
57
58
    /**
59
     * Record header.
60
     */
61
    private byte[] _header;
62
63
    /**
64
     * Record data.
65
     */
66
    private byte[] _data;
67
68
    /**
69
     * Constructs a brand new embedded object atom record.
70
     */
71
    protected ExEmbedAtom() {
72
        _header = new byte[8];
73
        _data = new byte[7];
74
75
        LittleEndian.putShort(_header, 2, (short)getRecordType());
76
        LittleEndian.putInt(_header, 4, _data.length);
77
78
        // It is fine for the other values to be zero
79
    }
80
81
    /**
82
     * Constructs the embedded object atom record from its source data.
83
     *
84
     * @param source the source data as a byte array.
85
     * @param start the start offset into the byte array.
86
     * @param len the length of the slice in the byte array.
87
     */
88
    protected ExEmbedAtom(byte[] source, int start, int len) {
89
        // Get the header.
90
        _header = new byte[8];
91
        System.arraycopy(source,start,_header,0,8);
92
93
        // Get the record data.
94
        _data = new byte[len-8];
95
        System.arraycopy(source,start+8,_data,0,len-8);
96
97
        // Must be at least 4 bytes long
98
        if(_data.length < 7) {
99
        	throw new IllegalArgumentException("The length of the data for a ExEmbedAtom must be at least 4 bytes, but was only " + _data.length);
100
        }
101
    }
102
103
    /**
104
     * Gets whether the object follows the color scheme.
105
     *
106
     * @return one of {@link #DOES_NOT_FOLLOW_COLOR_SCHEME},
107
     *                {@link #FOLLOWS_ENTIRE_COLOR_SCHEME}, or
108
     *                {@link #FOLLOWS_TEXT_AND_BACKGROUND_SCHEME}.
109
     */
110
    public int getFollowColorScheme() {
111
        return LittleEndian.getInt(_data, 0);
112
    }
113
114
    /**
115
     * Gets whether the embedded server cannot be locked.
116
     *
117
     * @return {@code true} if the embedded server cannot be locked.
118
     */
119
    public boolean getCantLockServerB() {
120
        return _data[4] != 0;
121
    }
122
123
    /**
124
     * Gets whether it is not required to send the dimensions to the embedded object.
125
     *
126
     * @return {@code true} if the embedded server does not require the object dimensions.
127
     */
128
    public boolean getNoSizeToServerB() {
129
        return _data[5] != 0;
130
    }
131
132
    /**
133
     * Getswhether the object is a Word table.
134
     *
135
     * @return {@code true} if the object is a Word table.
136
     */
137
    public boolean getIsTable() {
138
        return _data[6] != 0;
139
    }
140
141
    /**
142
     * Gets the record type.
143
     * @return the record type.
144
     */
145
    public long getRecordType() {
146
        return RecordTypes.ExEmbedAtom.typeID;
147
    }
148
149
    /**
150
     * Write the contents of the record back, so it can be written
151
     * to disk
152
     *
153
     * @param out the output stream to write to.
154
     * @throws IOException if an error occurs.
155
     */
156
    public void writeOut(OutputStream out) throws IOException {
157
        out.write(_header);
158
        out.write(_data);
159
    }
160
161
}
(-)src/scratchpad/src/org/apache/poi/hslf/record/CString.java (+8 lines)
Lines 111-114 Link Here
111
		// Write out our text
111
		// Write out our text
112
		out.write(_text);
112
		out.write(_text);
113
	}
113
	}
114
115
    /**
116
     * Gets a string representation of this object, primarily for debugging.
117
     * @return a string representation of this object.
118
     */
119
    public String toString() {
120
        return getText();
121
    }
114
}
122
}
(-)src/scratchpad/src/org/apache/poi/hslf/record/ExEmbed.java (+188 lines)
Line 0 Link Here
1
/* ====================================================================
2
   Licensed to the Apache Software Foundation (ASF) under one or more
3
   contributor license agreements.  See the NOTICE file distributed with
4
   this work for additional information regarding copyright ownership.
5
   The ASF licenses this file to You under the Apache License, Version 2.0
6
   (the "License"); you may not use this file except in compliance with
7
   the License.  You may obtain a copy of the License at
8
9
       http://www.apache.org/licenses/LICENSE-2.0
10
11
   Unless required by applicable law or agreed to in writing, software
12
   distributed under the License is distributed on an "AS IS" BASIS,
13
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
   See the License for the specific language governing permissions and
15
   limitations under the License.
16
==================================================================== */
17
18
package org.apache.poi.hslf.record;
19
20
import java.io.OutputStream;
21
import java.io.IOException;
22
23
import org.apache.poi.util.LittleEndian;
24
import org.apache.poi.util.POILogger;
25
26
/**
27
 * This data represents an embedded object in the document.
28
 *
29
 * @author Daniel Noll
30
 */
31
public class ExEmbed extends RecordContainer {
32
33
    /**
34
     * Record header data.
35
     */
36
    private byte[] _header;
37
38
    // Links to our more interesting children
39
    private ExEmbedAtom embedAtom;
40
    private ExOleObjAtom oleObjAtom;
41
    private CString menuName;
42
    private CString progId;
43
    private CString clipboardName;
44
45
    /**
46
     * Set things up, and find our more interesting children
47
     *
48
     * @param source the source data as a byte array.
49
     * @param start the start offset into the byte array.
50
     * @param len the length of the slice in the byte array.
51
     */
52
    protected ExEmbed(byte[] source, int start, int len) {
53
        // Grab the header
54
        _header = new byte[8];
55
        System.arraycopy(source,start,_header,0,8);
56
57
        // Find our children
58
        _children = Record.findChildRecords(source,start+8,len-8);
59
        findInterestingChildren();
60
    }
61
62
    /**
63
     * Create a new ExEmbed, with blank fields
64
     */
65
    public ExEmbed() {
66
        _header = new byte[8];
67
        _children = new Record[5];
68
69
        // Setup our header block
70
        _header[0] = 0x0f; // We are a container record
71
        LittleEndian.putShort(_header, 2, (short)getRecordType());
72
73
        // Setup our child records
74
        CString cs1 = new CString();
75
        CString cs2 = new CString();
76
        CString cs3 = new CString();
77
//        cs1.setCount(0x00);
78
//        cs2.setCount(0x10);
79
        _children[0] = new ExEmbedAtom();
80
        _children[1] = new ExOleObjAtom();
81
        _children[2] = cs1;
82
        _children[3] = cs2;
83
        _children[4] = cs3;
84
        findInterestingChildren();
85
    }
86
87
    /**
88
     * Go through our child records, picking out the ones that are
89
     * interesting, and saving those for use by the easy helper methods.
90
     */
91
    private void findInterestingChildren() {
92
93
        // First child should be the ExHyperlinkAtom
94
        if(_children[0] instanceof ExEmbedAtom) {
95
            embedAtom = (ExEmbedAtom)_children[0];
96
        } else {
97
            logger.log(POILogger.ERROR, "First child record wasn't a ExEmbedAtom, was of type " + _children[0].getRecordType());
98
        }
99
100
        // Second child should be the ExOleObjAtom
101
        if (_children[1] instanceof ExOleObjAtom) {
102
            oleObjAtom = (ExOleObjAtom)_children[1];
103
        } else {
104
            logger.log(POILogger.ERROR, "Second child record wasn't a ExOleObjAtom, was of type " + _children[1].getRecordType());
105
        }
106
107
        for (int i = 2; i < _children.length; i++) {
108
            if (_children[i] instanceof CString){
109
                if (menuName == null) menuName = (CString)_children[i];
110
                else if (progId == null) progId = (CString)_children[i];
111
                else if (clipboardName == null) clipboardName = (CString)_children[i];
112
            } else {
113
                logger.log(POILogger.ERROR, "Record after atoms wasn't a CString, was of type " + _children[i].getRecordType());
114
            }
115
        }
116
    }
117
118
    /**
119
     * Gets the {@code ExEmbedAtom}.
120
     *
121
     * @return the {@code ExEmbedAtom}.
122
     */
123
    public ExEmbedAtom getExEmbedAtom()
124
    {
125
        return embedAtom;
126
    }
127
128
    /**
129
     * Gets the {@code ExOleObjAtom}.
130
     *
131
     * @return the {@code ExOleObjAtom}.
132
     */
133
    public ExOleObjAtom getExOleObjAtom()
134
    {
135
        return oleObjAtom;
136
    }
137
138
    /**
139
     * Gets the name used for menus and the Links dialog box.
140
     *
141
     * @return the name used for menus and the Links dialog box.
142
     */
143
    public String getMenuName()
144
    {
145
        return menuName == null ? null : menuName.getText();
146
    }
147
148
    /**
149
     * Gets the OLE Programmatic Identifier.
150
     * 
151
     * @return the OLE Programmatic Identifier.
152
     */
153
    public String getProgId()
154
    {
155
        return progId == null ? null : progId.getText();
156
    }
157
158
    /**
159
     * Gets the name that appears in the paste special dialog.
160
     *
161
     * @return the name that appears in the paste special dialog.
162
     */
163
    public String getClipboardName()
164
    {
165
        return clipboardName == null ? null : clipboardName.getText();
166
    }
167
168
    /**
169
     * Returns the type (held as a little endian in bytes 3 and 4)
170
     * that this class handles.
171
     *
172
     * @return the record type.
173
     */
174
    public long getRecordType() {
175
        return RecordTypes.ExEmbed.typeID;
176
    }
177
178
    /**
179
     * Have the contents printer out into an OutputStream, used when
180
     * writing a file back out to disk.
181
     *
182
     * @param out the output stream.
183
     * @throws IOException if there was an error writing to the stream.
184
     */
185
    public void writeOut(OutputStream out) throws IOException {
186
        writeOut(_header[0],_header[1],getRecordType(),_children,out);
187
    }
188
}
(-)src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java (-18 / +48 lines)
Lines 20-47 Link Here
20
20
21
package org.apache.poi.hslf;
21
package org.apache.poi.hslf;
22
22
23
import java.util.*;
23
import java.io.ByteArrayInputStream;
24
import java.io.*;
24
import java.io.ByteArrayOutputStream;
25
import java.io.FileInputStream;
26
import java.io.FileNotFoundException;
27
import java.io.IOException;
28
import java.io.InputStream;
29
import java.io.OutputStream;
30
import java.util.ArrayList;
31
import java.util.Arrays;
32
import java.util.Hashtable;
33
import java.util.Iterator;
34
import java.util.List;
25
35
26
import org.apache.poi.POIDocument;
36
import org.apache.poi.POIDocument;
27
import org.apache.poi.util.LittleEndian;
28
import org.apache.poi.util.POILogger;
29
import org.apache.poi.util.POILogFactory;
30
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
31
import org.apache.poi.poifs.filesystem.DocumentEntry;
32
import org.apache.poi.poifs.filesystem.DocumentInputStream;
33
34
import org.apache.poi.hpsf.PropertySet;
35
import org.apache.poi.hpsf.PropertySetFactory;
36
import org.apache.poi.hpsf.MutablePropertySet;
37
import org.apache.poi.hpsf.SummaryInformation;
38
import org.apache.poi.hpsf.DocumentSummaryInformation;
39
40
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
37
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
41
import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
38
import org.apache.poi.hslf.exceptions.EncryptedPowerPointFileException;
42
import org.apache.poi.hslf.exceptions.HSLFException;
39
import org.apache.poi.hslf.exceptions.HSLFException;
43
import org.apache.poi.hslf.record.*;
40
import org.apache.poi.hslf.record.CurrentUserAtom;
41
import org.apache.poi.hslf.record.ExOleObjStg;
42
import org.apache.poi.hslf.record.PersistPtrHolder;
43
import org.apache.poi.hslf.record.PositionDependentRecord;
44
import org.apache.poi.hslf.record.Record;
45
import org.apache.poi.hslf.record.UserEditAtom;
46
import org.apache.poi.hslf.usermodel.ObjectData;
44
import org.apache.poi.hslf.usermodel.PictureData;
47
import org.apache.poi.hslf.usermodel.PictureData;
48
import org.apache.poi.poifs.filesystem.DocumentEntry;
49
import org.apache.poi.poifs.filesystem.DocumentInputStream;
50
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
51
import org.apache.poi.util.LittleEndian;
52
import org.apache.poi.util.POILogFactory;
53
import org.apache.poi.util.POILogger;
45
54
46
/**
55
/**
47
 * This class contains the main functionality for the Powerpoint file 
56
 * This class contains the main functionality for the Powerpoint file 
Lines 68-75 Link Here
68
77
69
	// Raw Pictures contained in the pictures stream
78
	// Raw Pictures contained in the pictures stream
70
	private PictureData[] _pictures;
79
	private PictureData[] _pictures;
71
	
80
72
	/**
81
    // Embedded objects stored in storage records in the document stream, lazily populated.
82
    private ObjectData[] _objects;
83
84
    /**
73
	 * Returns the underlying POIFSFileSystem for the document
85
	 * Returns the underlying POIFSFileSystem for the document
74
	 *  that is open.
86
	 *  that is open.
75
	 */
87
	 */
Lines 507-510 Link Here
507
	public PictureData[] getPictures() {
519
	public PictureData[] getPictures() {
508
		return _pictures;
520
		return _pictures;
509
	}
521
	}
522
523
    /**
524
     * Gets embedded object data from the slide show.
525
     *
526
     * @return the embedded objects.
527
     */
528
    public ObjectData[] getEmbeddedObjects() {
529
        if (_objects == null) {
530
            List objects = new ArrayList();
531
            for (int i = 0; i < _records.length; i++) {
532
                if (_records[i] instanceof ExOleObjStg) {
533
                    objects.add(new ObjectData((ExOleObjStg) _records[i]));
534
                }
535
            }
536
            _objects = (ObjectData[]) objects.toArray(new ObjectData[objects.size()]);
537
        }
538
        return _objects;
539
    }
510
}
540
}

Return to bug 43247