01: /* ====================================================================
02: Licensed to the Apache Software Foundation (ASF) under one or more
03: contributor license agreements. See the NOTICE file distributed with
04: this work for additional information regarding copyright ownership.
05: The ASF licenses this file to You under the Apache License, Version 2.0
06: (the "License"); you may not use this file except in compliance with
07: the License. You may obtain a copy of the License at
08:
09: 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.hssf.record;
19:
20: /**
21: * Subrecords are part of the OBJ class.
22: */
23: abstract public class SubRecord extends Record {
24: public SubRecord() {
25: }
26:
27: public SubRecord(RecordInputStream in) {
28: super (in);
29: }
30:
31: public static Record createSubRecord(RecordInputStream in) {
32: Record r = null;
33:
34: /* This must surely be an earlier hack?? Delete when confident
35: short adjustedSize = size;
36: if ( size < 0 )
37: {
38: adjustedSize = 0;
39: }
40: else if ( offset + size > data.length )
41: {
42: adjustedSize = (short) ( data.length - offset );
43: if ( adjustedSize > 4 )
44: {
45: adjustedSize -= 4;
46: }
47: }
48: */
49: switch (in.getSid()) {
50: case CommonObjectDataSubRecord.sid:
51: r = new CommonObjectDataSubRecord(in);
52: break;
53: case EmbeddedObjectRefSubRecord.sid:
54: r = new EmbeddedObjectRefSubRecord(in);
55: break;
56: case GroupMarkerSubRecord.sid:
57: r = new GroupMarkerSubRecord(in);
58: break;
59: case EndSubRecord.sid:
60: r = new EndSubRecord(in);
61: break;
62: case NoteStructureSubRecord.sid:
63: r = new NoteStructureSubRecord(in);
64: break;
65: default:
66: r = new UnknownRecord(in);
67: }
68: return r;
69: }
70: }
|