See the License for the specific language governing permissions and\r
limitations under the License.\r
==================================================================== */\r
-
-package org.apache.poi.poifs.filesystem;
-
+\r
+package org.apache.poi.poifs.filesystem;\r
+\r
import java.io.ByteArrayOutputStream;\r
import java.io.IOException;\r
import java.io.OutputStream;\r
* Represents an Ole10Native record which is wrapped around certain binary\r
* files being embedded in OLE2 documents.\r
*\r
- * @author Rainer Schwarze
- */
-public class Ole10Native {
-
- public static final String OLE10_NATIVE = "\u0001Ole10Native";
- protected static final String ISO1 = "ISO-8859-1";
-
+ * @author Rainer Schwarze\r
+ */\r
+public class Ole10Native {\r
+\r
+ public static final String OLE10_NATIVE = "\u0001Ole10Native";\r
+ protected static final String ISO1 = "ISO-8859-1";\r
+ \r
// (the fields as they appear in the raw record:)\r
- private int totalSize; // 4 bytes, total size of record not including this field
- private short flags1 = 2; // 2 bytes, unknown, mostly [02 00]
- private String label; // ASCIIZ, stored in this field without the terminating zero
- private String fileName; // ASCIIZ, stored in this field without the terminating zero
- private short flags2 = 0; // 2 bytes, unknown, mostly [00 00]
- private short unknown1 = 3; // see below
- private String command; // ASCIIZ, stored in this field without the terminating zero
- private byte[] dataBuffer; // varying size, the actual native data
- private short flags3 = 0; // some final flags? or zero terminators?, sometimes not there
-
+ private int totalSize; // 4 bytes, total size of record not including this field\r
+ private short flags1 = 2; // 2 bytes, unknown, mostly [02 00]\r
+ private String label; // ASCIIZ, stored in this field without the terminating zero\r
+ private String fileName; // ASCIIZ, stored in this field without the terminating zero\r
+ private short flags2 = 0; // 2 bytes, unknown, mostly [00 00]\r
+ private short unknown1 = 3; // see below\r
+ private String command; // ASCIIZ, stored in this field without the terminating zero\r
+ private byte[] dataBuffer; // varying size, the actual native data\r
+ private short flags3 = 0; // some final flags? or zero terminators?, sometimes not there\r
+ \r
/**\r
* the field encoding mode - merely a try-and-error guess ...\r
**/ \r
/**\r
* the data is stored raw after the length field and the flags1 field\r
*/\r
- compact;\r
+ compact\r
}\r
\r
private EncodingMode mode;\r
\r
\r
\r
- /**
- * Creates an instance of this class from an embedded OLE Object. The OLE Object is expected
- * to include a stream "{01}Ole10Native" which contains the actual
+ /**\r
+ * Creates an instance of this class from an embedded OLE Object. The OLE Object is expected\r
+ * to include a stream "{01}Ole10Native" which contains the actual\r
* data relevant for this class.\r
*\r
* @param poifs POI Filesystem object\r
assert(readBytes == data.length);\r
\r
return new Ole10Native(data, 0);\r
- }
-
- /**
- * Creates an instance and fills the fields based on ... the fields
- */
- public Ole10Native(String label, String filename, String command, byte[] data) {
- setLabel(label);
- setFileName(filename);
- setCommand(command);
+ }\r
+ \r
+ /**\r
+ * Creates an instance and fills the fields based on ... the fields\r
+ */\r
+ public Ole10Native(String label, String filename, String command, byte[] data) {\r
+ setLabel(label);\r
+ setFileName(filename);\r
+ setCommand(command);\r
setDataBuffer(data);\r
- mode = EncodingMode.parsed;
- }
+ mode = EncodingMode.parsed;\r
+ }\r
\r
/**\r
* Creates an instance and fills the fields based on the data in the given buffer.\r
public Ole10Native(byte[] data, int offset, boolean plain) throws Ole10NativeException {\r
this(data, offset);\r
}\r
-
- /**
- * Creates an instance and fills the fields based on the data in the given buffer.
- *
- * @param data The buffer containing the Ole10Native record
+ \r
+ /**\r
+ * Creates an instance and fills the fields based on the data in the given buffer.\r
+ *\r
+ * @param data The buffer containing the Ole10Native record\r
* @param offset The start offset of the record in the buffer\r
* @throws Ole10NativeException on invalid or unexcepted data format\r
*/\r
ofs += len;\r
\r
flags2 = LittleEndian.getShort(data, ofs);\r
- ofs += LittleEndianConsts.SHORT_SIZE;
-
- unknown1 = LittleEndian.getShort(data, ofs);
- ofs += LittleEndianConsts.SHORT_SIZE;
-
- len = LittleEndian.getInt(data, ofs);
+ ofs += LittleEndianConsts.SHORT_SIZE;\r
+ \r
+ unknown1 = LittleEndian.getShort(data, ofs);\r
+ ofs += LittleEndianConsts.SHORT_SIZE;\r
+ \r
+ len = LittleEndian.getInt(data, ofs);\r
ofs += LittleEndianConsts.INT_SIZE;\r
- command = StringUtil.getFromCompressedUnicode(data, ofs, len - 1);
- ofs += len;
-
- if (totalSize < ofs) {
- throw new Ole10NativeException("Invalid Ole10Native");
- }
-
- dataSize = LittleEndian.getInt(data, ofs);
- ofs += LittleEndianConsts.INT_SIZE;
-
- if (dataSize < 0 || totalSize - (ofs - LittleEndianConsts.INT_SIZE) < dataSize) {
- throw new Ole10NativeException("Invalid Ole10Native");
+ command = StringUtil.getFromCompressedUnicode(data, ofs, len - 1);\r
+ ofs += len;\r
+ \r
+ if (totalSize < ofs) {\r
+ throw new Ole10NativeException("Invalid Ole10Native");\r
+ }\r
+ \r
+ dataSize = LittleEndian.getInt(data, ofs);\r
+ ofs += LittleEndianConsts.INT_SIZE;\r
+ \r
+ if (dataSize < 0 || totalSize - (ofs - LittleEndianConsts.INT_SIZE) < dataSize) {\r
+ throw new Ole10NativeException("Invalid Ole10Native");\r
}\r
break;\r
}\r
case unparsed:\r
dataSize = totalSize;\r
break;\r
- }
-
- dataBuffer = new byte[dataSize];
- System.arraycopy(data, ofs, dataBuffer, 0, dataSize);
- ofs += dataSize;
+ }\r
+ \r
+ dataBuffer = new byte[dataSize];\r
+ System.arraycopy(data, ofs, dataBuffer, 0, dataSize);\r
+ ofs += dataSize;\r
}\r
\r
/*\r
return flags3;\r
}\r
\r
- /**
- * Have the contents printer out into an OutputStream, used when writing a
- * file back out to disk (Normally, atom classes will keep their bytes
- * around, but non atom classes will just request the bytes from their
- * children, then chuck on their header and return)
- */
+ /**\r
+ * Have the contents printer out into an OutputStream, used when writing a\r
+ * file back out to disk (Normally, atom classes will keep their bytes\r
+ * around, but non atom classes will just request the bytes from their\r
+ * children, then chuck on their header and return)\r
+ */\r
public void writeOut(OutputStream out) throws IOException {\r
// byte intbuf[] = new byte[LittleEndianConsts.INT_SIZE];\r
// byte shortbuf[] = new byte[LittleEndianConsts.SHORT_SIZE];\r
}\r
\r
}\r
-
+\r
public void setFlags1(short flags1) {\r
this.flags1 = flags1;\r
}\r
public void setDataBuffer(byte dataBuffer[]) {\r
this.dataBuffer = dataBuffer;\r
}\r
-}
+}\r