Lines 46-51
Link Here
|
46 |
private final byte[] dataBuffer; // varying size, the actual native data |
46 |
private final byte[] dataBuffer; // varying size, the actual native data |
47 |
private short flags3; // some final flags? or zero terminators?, sometimes not there |
47 |
private short flags3; // some final flags? or zero terminators?, sometimes not there |
48 |
public static final String OLE10_NATIVE = "\u0001Ole10Native"; |
48 |
public static final String OLE10_NATIVE = "\u0001Ole10Native"; |
|
|
49 |
public static final String OLE10_ITEM_NAME = "\u0001Ole10ItemName"; |
50 |
public static final String OBJ_INFO = "\u0003ObjInfo"; |
49 |
|
51 |
|
50 |
/** |
52 |
/** |
51 |
* Creates an instance of this class from an embedded OLE Object. The OLE Object is expected |
53 |
* Creates an instance of this class from an embedded OLE Object. The OLE Object is expected |
Lines 72-84
Link Here
|
72 |
* @throws Ole10NativeException on invalid or unexcepted data format |
74 |
* @throws Ole10NativeException on invalid or unexcepted data format |
73 |
*/ |
75 |
*/ |
74 |
public static Ole10Native createFromEmbeddedOleObject(DirectoryNode directory) throws IOException, Ole10NativeException { |
76 |
public static Ole10Native createFromEmbeddedOleObject(DirectoryNode directory) throws IOException, Ole10NativeException { |
75 |
boolean plain = false; |
|
|
76 |
|
77 |
|
77 |
try { |
78 |
boolean plain = directory.hasEntry(OLE10_ITEM_NAME); |
78 |
directory.getEntry("\u0001Ole10ItemName"); |
79 |
|
79 |
plain = true; |
80 |
if (directory.hasEntry(OBJ_INFO)) { |
80 |
} catch (FileNotFoundException ex) { |
81 |
plain |= parseObjInfo(directory, (DocumentEntry) directory.getEntry(OBJ_INFO)); |
81 |
plain = false; |
|
|
82 |
} |
82 |
} |
83 |
|
83 |
|
84 |
DocumentEntry nativeEntry = |
84 |
DocumentEntry nativeEntry = |
Lines 90-95
Link Here
|
90 |
} |
90 |
} |
91 |
|
91 |
|
92 |
/** |
92 |
/** |
|
|
93 |
* @return true when the corresponding Ole10Native stream is thought to be in plain format |
94 |
*/ |
95 |
private static boolean parseObjInfo(DirectoryNode directory, DocumentEntry objInfoEntry) throws IOException { |
96 |
byte[] data = new byte[objInfoEntry.getSize()]; |
97 |
directory.createDocumentInputStream(objInfoEntry).read(data); |
98 |
|
99 |
if (data.length < 6) |
100 |
return true; |
101 |
|
102 |
boolean fStoredAsEMF = (data[4] & 0x4) != 0; |
103 |
|
104 |
// This is based on empirical evidence only at the moment |
105 |
return ! fStoredAsEMF; |
106 |
} |
107 |
|
108 |
/** |
93 |
* Creates an instance and fills the fields based on the data in the given buffer. |
109 |
* Creates an instance and fills the fields based on the data in the given buffer. |
94 |
* |
110 |
* |
95 |
* @param data The buffer containing the Ole10Native record |
111 |
* @param data The buffer containing the Ole10Native record |
Lines 118-126
Link Here
|
118 |
ofs += LittleEndianConsts.INT_SIZE; |
134 |
ofs += LittleEndianConsts.INT_SIZE; |
119 |
|
135 |
|
120 |
if (plain) { |
136 |
if (plain) { |
121 |
dataBuffer = new byte[totalSize-4]; |
137 |
dataBuffer = new byte[totalSize]; |
122 |
System.arraycopy(data, 4, dataBuffer, 0, dataBuffer.length); |
138 |
System.arraycopy(data, 4, dataBuffer, 0, dataBuffer.length); |
123 |
dataSize = totalSize - 4; |
139 |
dataSize = dataBuffer.length; |
124 |
|
140 |
|
125 |
byte[] oleLabel = new byte[8]; |
141 |
byte[] oleLabel = new byte[8]; |
126 |
System.arraycopy(dataBuffer, 0, oleLabel, 0, Math.min(dataBuffer.length, 8)); |
142 |
System.arraycopy(dataBuffer, 0, oleLabel, 0, Math.min(dataBuffer.length, 8)); |