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

(-)jakarta-poi/src/java/org/apache/poi/hssf/record/AbstractEscherHolderRecord.java (-36 / +14 lines)
Lines 1-6 Link Here
1
2
/* ====================================================================
1
/* ====================================================================
3
   Copyright 2002-2004   Apache Software Foundation
2
   Copyright 2004   Apache Software Foundation
4
3
5
   Licensed under the Apache License, Version 2.0 (the "License");
4
   Licensed under the Apache License, Version 2.0 (the "License");
6
   you may not use this file except in compliance with the License.
5
   you may not use this file except in compliance with the License.
Lines 14-26 Link Here
14
   See the License for the specific language governing permissions and
13
   See the License for the specific language governing permissions and
15
   limitations under the License.
14
   limitations under the License.
16
==================================================================== */
15
==================================================================== */
17
        
18
16
19
17
20
package org.apache.poi.hssf.record;
18
package org.apache.poi.hssf.record;
21
19
22
23
24
import org.apache.poi.ddf.DefaultEscherRecordFactory;
20
import org.apache.poi.ddf.DefaultEscherRecordFactory;
25
import org.apache.poi.ddf.EscherRecord;
21
import org.apache.poi.ddf.EscherRecord;
26
import org.apache.poi.ddf.EscherRecordFactory;
22
import org.apache.poi.ddf.EscherRecordFactory;
Lines 52-61 Link Here
52
    }
48
    }
53
49
54
    /**
50
    /**
55
     * Constructs a Bar record and sets its fields appropriately.
51
     * Constructs one of the Escher records. These are
52
     *   MSODRAWING, MSODRAWINGGROUP and MSODRAWINGSELECTION
56
     *
53
     *
57
     * @param id    id must be 0x1017 or an exception
54
     * @param id    must be one of 0xeb (MSODRAWINGGROUP),
58
     *              will be throw upon validation
55
     *               0xec (MSODRAWING), or 0xef (MSODRAWINGSELECTION)
59
     * @param size  size the size of the data area of the record
56
     * @param size  size the size of the data area of the record
60
     * @param data  data of the record (should not contain sid/len)
57
     * @param data  data of the record (should not contain sid/len)
61
     */
58
     */
Lines 63-76 Link Here
63
    public AbstractEscherHolderRecord(short id, short size, byte [] data)
60
    public AbstractEscherHolderRecord(short id, short size, byte [] data)
64
    {
61
    {
65
        super(id, size, data);
62
        super(id, size, data);
66
    
67
    }
63
    }
68
64
69
    /**
65
    /**
70
     * Constructs a Bar record and sets its fields appropriately.
66
     * Constructs one of the Escher records
71
     *
67
     *
72
     * @param id    id must be 0x1017 or an exception
68
     * @param id    must be one of 0xeb (MSODRAWINGGROUP),
73
     *              will be throw upon validation
69
     *               0xec (MSODRAWING), or 0xef (MSODRAWINGSELECTION)
74
     * @param size  size the size of the data area of the record
70
     * @param size  size the size of the data area of the record
75
     * @param data  data of the record (should not contain sid/len)
71
     * @param data  data of the record (should not contain sid/len)
76
     * @param offset of the record's data
72
     * @param offset of the record's data
Lines 91-97 Link Here
91
    {
87
    {
92
        if (id != getSid())
88
        if (id != getSid())
93
        {
89
        {
94
            throw new RecordFormatException("Not a Bar record");
90
            throw new RecordFormatException("Not a Drawing record");
95
        }
91
        }
96
    }
92
    }
97
93
Lines 137-163 Link Here
137
133
138
    public int serialize(int offset, byte[] data)
134
    public int serialize(int offset, byte[] data)
139
    {
135
    {
136
        LittleEndian.putShort(data, 0 + offset, getSid());
137
        LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
140
        if (escherRecords.size() == 0 && rawData != null)
138
        if (escherRecords.size() == 0 && rawData != null)
141
        {
139
        {
142
            System.arraycopy( rawData, 0, data, offset, rawData.length);
140
            System.arraycopy( rawData, 0, data, offset + 4, rawData.length);
143
            return rawData.length;
144
        }
141
        }
145
        else
142
        else
146
        {
143
        {
147
            collapseShapeInformation();
148
149
            LittleEndian.putShort(data, 0 + offset, getSid());
150
            LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
151
152
            int pos = offset + 4;
144
            int pos = offset + 4;
153
            for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
145
            for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
154
            {
146
            {
155
                EscherRecord r = (EscherRecord) iterator.next();
147
                EscherRecord r = (EscherRecord) iterator.next();
156
                pos += r.serialize(pos, data, new NullEscherSerializationListener() );
148
                pos += r.serialize(pos, data, new NullEscherSerializationListener() );
157
            }
149
            }
158
159
            return getRecordSize();
160
        }
150
        }
151
        return getRecordSize();
161
    }
152
    }
162
153
163
    /**
154
    /**
Lines 167-178 Link Here
167
    {
158
    {
168
        if (escherRecords.size() == 0 && rawData != null)
159
        if (escherRecords.size() == 0 && rawData != null)
169
        {
160
        {
170
            return rawData.length;
161
            return rawData.length + 4;
171
        }
162
        }
172
        else
163
        else
173
        {
164
        {
174
            collapseShapeInformation();
175
176
            int size = 4;
165
            int size = 4;
177
            for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
166
            for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
178
            {
167
            {
Lines 183-193 Link Here
183
        }
172
        }
184
    }
173
    }
185
174
186
    private void collapseShapeInformation()
187
    {
188
189
    }
190
191
    public abstract short getSid();
175
    public abstract short getSid();
192
176
193
    public Object clone()
177
    public Object clone()
Lines 215-229 Link Here
215
        escherRecords.clear();
199
        escherRecords.clear();
216
    }
200
    }
217
201
218
219
    public EscherRecord getEscherRecord(int index)
202
    public EscherRecord getEscherRecord(int index)
220
    {
203
    {
221
        return (EscherRecord) escherRecords.get(index);
204
        return (EscherRecord) escherRecords.get(index);
222
    }
205
    }
223
206
224
225
}  // END OF CLASS
207
}  // END OF CLASS
226
227
228
229

Return to bug 28203