Package org.apache.poi.poifs.filesystem
Class Ole10Native
java.lang.Object
org.apache.poi.poifs.filesystem.Ole10Native
Represents an Ole10Native record which is wrapped around certain binary
files being embedded in OLE2 documents.
Ole10Native objects come in different shapes:
- unparsed: we can't identify it's structure
- compact: same as unparsed but with a leading flag
- parsed - Ole-Class "Package": data + ASCII label,command,filename
- parsed - Ole-Class "Package2": as above plus UTF16 label,command,filename
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionOle10Native(byte[] data, int offset) Creates an instance and fills the fields based on the data in the given buffer.Ole10Native(String label, String filename, String command, byte[] data) Creates an instance and fills the fields based on ... -
Method Summary
Modifier and TypeMethodDescriptionstatic Ole10NativecreateFromEmbeddedOleObject(DirectoryNode directory) Creates an instance of this class from an embedded OLE Object.static Ole10NativeCreates an instance of this class from an embedded OLE Object.static voidcreateOleMarkerEntry(DirectoryEntry parent) Add the \1OLE marker entry, which is not the Ole10Native entry.static voidAdd the \1OLE marker entry, which is not the Ole10Native entry.Returns the command field - usually the name of the file being embedded including the full path, may be a command specified during embedding the file.Get Command string of UTF16 extended OLE packages ornullif not set or not UTF16 extendedbyte[]Returns the buffer containing the embedded file's data, ornullif no data was embedded.intReturns the size of the embedded file.Returns the fileName field - usually the name of the file being embedded including the full path.Get filename string for UTF16 extended OLE packages ornullif not set or not UTF16 extendedshortReturns flags1 - currently unknown - usually 0x0002.shortReturns flags2 - currently unknown - mostly 0x0000.getLabel()Returns the label field - usually the name of the file (without directory) but probably may be any name specified during packaging/embedding the data.Get Label string for UTF16 extended OLE packages ornullif not set or not UTF16 extendedstatic intstatic intintReturns the value of the totalSize field - the total length of the structure is totalSize + 4 (value of this field + size of this field).shortReturns unknown1 field - currently unknown.voidsetCommand(String command) voidsetCommand2(String command2) Set Command string for UTF16 extended OLE packages ornullif not set or not UTF16 extendedvoidsetDataBuffer(byte[] dataBuffer) voidsetFileName(String fileName) voidsetFileName2(String fileName2) Set filename string for UTF16 extended OLE packages ornullif not set or not UTF16 extendedvoidsetFlags1(short flags1) voidsetFlags2(short flags2) voidvoidSet Label string for UTF16 extended OLE packages ornullif not set or not UTF16 extendedstatic voidsetMaxRecordLength(int length) static voidsetMaxStringLength(int length) voidsetUnknown1(short unknown1) voidwriteOut(OutputStream out) 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)
-
Field Details
-
OLE10_NATIVE
- See Also:
-
-
Constructor Details
-
Ole10Native
Creates an instance and fills the fields based on ... the fields -
Ole10Native
Creates an instance and fills the fields based on the data in the given buffer.- Parameters:
data- The buffer containing the Ole10Native recordoffset- The start offset of the record in the buffer- Throws:
Ole10NativeException- on invalid or unexcepted data format
-
-
Method Details
-
createFromEmbeddedOleObject
public static Ole10Native createFromEmbeddedOleObject(POIFSFileSystem poifs) throws IOException, Ole10NativeException 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 data relevant for this class.- Parameters:
poifs- POI Filesystem object- Returns:
- Returns an instance of this class
- Throws:
IOException- on IO errorOle10NativeException- on invalid or unexcepted data format
-
createFromEmbeddedOleObject
public static Ole10Native createFromEmbeddedOleObject(DirectoryNode directory) throws IOException, Ole10NativeException 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 data relevant for this class.- Parameters:
directory- POI Filesystem object- Returns:
- Returns an instance of this class
- Throws:
IOException- on IO errorOle10NativeException- on invalid or unexcepted data format
-
setMaxRecordLength
public static void setMaxRecordLength(int length) - Parameters:
length- the max record length allowed for Ole10Native
-
getMaxRecordLength
public static int getMaxRecordLength()- Returns:
- the max record length allowed for Ole10Native
-
setMaxStringLength
public static void setMaxStringLength(int length) - Parameters:
length- the max string length allowed for Ole10Native
-
getMaxStringLength
public static int getMaxStringLength()- Returns:
- the max string length allowed for Ole10Native
-
createOleMarkerEntry
Add the \1OLE marker entry, which is not the Ole10Native entry. Beside this "Ole" record there were several other records, e.g. CompObj, OlePresXXX, but it seems, that they aren't necessary- Throws:
IOException
-
createOleMarkerEntry
Add the \1OLE marker entry, which is not the Ole10Native entry. Beside this "Ole" record there were several other records, e.g. CompObj, OlePresXXX, but it seems, that they aren't necessary- Throws:
IOException
-
getTotalSize
public int getTotalSize()Returns the value of the totalSize field - the total length of the structure is totalSize + 4 (value of this field + size of this field).- Returns:
- the totalSize
-
getFlags1
public short getFlags1()Returns flags1 - currently unknown - usually 0x0002.- Returns:
- the flags1
-
getLabel
Returns the label field - usually the name of the file (without directory) but probably may be any name specified during packaging/embedding the data.- Returns:
- the label
-
getFileName
Returns the fileName field - usually the name of the file being embedded including the full path.- Returns:
- the fileName
-
getFlags2
public short getFlags2()Returns flags2 - currently unknown - mostly 0x0000.- Returns:
- the flags2
-
getUnknown1
public short getUnknown1()Returns unknown1 field - currently unknown.- Returns:
- the unknown1
-
getCommand
Returns the command field - usually the name of the file being embedded including the full path, may be a command specified during embedding the file.- Returns:
- the command
-
getDataSize
public int getDataSize()Returns the size of the embedded file. If the size is 0 (zero), no data has been embedded. To be sure, that no data has been embedded, check whethergetDataBuffer()returnsnull.- Returns:
- the dataSize
-
getDataBuffer
public byte[] getDataBuffer()Returns the buffer containing the embedded file's data, ornullif no data was embedded. Note that an embedding may provide information about the data, but the actual data is not included. (So label, filename etc. are available, but this method returnsnull.)- Returns:
- the dataBuffer
-
writeOut
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)- Throws:
IOException
-
setFlags1
public void setFlags1(short flags1) -
setFlags2
public void setFlags2(short flags2) -
setLabel
-
setFileName
-
setCommand
-
setUnknown1
public void setUnknown1(short unknown1) -
setDataBuffer
public void setDataBuffer(byte[] dataBuffer) -
getCommand2
Get Command string of UTF16 extended OLE packages ornullif not set or not UTF16 extended -
setCommand2
Set Command string for UTF16 extended OLE packages ornullif not set or not UTF16 extended -
getLabel2
Get Label string for UTF16 extended OLE packages ornullif not set or not UTF16 extended -
setLabel2
Set Label string for UTF16 extended OLE packages ornullif not set or not UTF16 extended -
getFileName2
Get filename string for UTF16 extended OLE packages ornullif not set or not UTF16 extended -
setFileName2
Set filename string for UTF16 extended OLE packages ornullif not set or not UTF16 extended
-