Class OleObjectBinaryPart

Direct Known Subclasses:
VbaProjectBinaryPart, VbaProjectSignatureBin

public class OleObjectBinaryPart extends BinaryPart
You can use oleObjectBinaryPart.setBinaryData( ByteBuffer.wrap(bytes) ); to populate this from a byte[] An OleObjectBinaryPart is a binary container for Object Linking and Embedding (OLE) data. It essentially stores a "snapshot" of a foreign application's data so that Word can hand it back to that application when you double-click it. Here are the most common things you’ll find stored in this part: 1. Embedded Excel Spreadsheets This is the most frequent resident of an OLE binary. When you go to Insert > Object > Excel Worksheet, Word doesn't just copy the text; it embeds the entire logic of an Excel file. What's inside: The cells, formulas, formatting, and even hidden sheets from that specific Excel object. 2. Legacy Equations (Microsoft Equation 3.0) While modern Word uses Office Math (MathML), older documents or those using the "Equation 3.0" editor store math formulas as OLE objects. Note: Because of security vulnerabilities, Microsoft has disabled the execution of many of these older OLE objects in recent years, but the .bin files often remain in older documents. 3. Adobe Acrobat Documents (PDFs) If you drag and drop a PDF into a Word document as an icon, Word creates an oleObject.bin. The Catch: The .bin file contains the actual PDF data. When you double-click the icon in Word, it extracts that binary data and asks your PDF reader to open it. 4. Third-Party Specialized Data Any program that supports the OLE standard can "park" its data here. Why is it a .bin part? Microsoft uses a format called Compound File Binary Format (CFBF)—informally known as "a file system within a file." Because Word doesn't know how to read a CFBF natively, it treats the data as a "black box." It stores the binary "blob" and keeps a record of which program (the Class ID or CLSID) is responsible for opening it. Security Warning Because .bin files can execute code via their host applications (like Excel macros or old Equation Editor exploits), they are a common vector for malware. If you find an oleObject1.bin in a document from an untrusted source, it is the most likely place for a "malicious payload" to be hiding. See further Microsoft specs [MS-OLEDS] and [MS-CFB]
Author:
jharrop
  • Constructor Details

  • Method Details

    • init

      public void init()
    • getFs

      public POIFSFileSystem getFs() throws IOException
      Throws:
      IOException
    • initPOIFSFileSystem

      public void initPOIFSFileSystem() throws IOException
      Throws:
      IOException
    • writePOIFSFileSystem

      public void writePOIFSFileSystem() throws IOException
      Write any changes which have been made to POIFSFileSystem, to the underlying ByteBuffer. This is necessary if the changes are to be persisted.
      Throws:
      IOException
    • viewFile

      public void viewFile(boolean verbose) throws IOException
      Throws:
      IOException
    • viewFile

      public void viewFile(OutputStream os, boolean verbose) throws IOException
      Parameters:
      os -
      verbose -
      Throws:
      IOException
      Since:
      3.0.0
    • setUSE_TIKA_IF_AVAILABLE

      public static void setUSE_TIKA_IF_AVAILABLE(boolean val)
      Primarily for test purposes, you'd use it if you had it.
    • setTRUST_CLSID

      public static void setTRUST_CLSID(boolean val)
      Primarily for test purposes, trust unless proven otherwise.
    • detectMimeType

      public String detectMimeType()
      Returns a mime type
      Returns:
      Since:
      11.5.10
    • mapSignatureToMime

      public static String mapSignatureToMime(String signature)
      Maps a known OLE stream signature to its corresponding MIME type.
      Parameters:
      signature - The name of the stream found in the OLE directory.
      Returns:
      The MIME type string, or a generic fallback if unknown.
    • detectMimeType

      public String detectMimeType(byte[] payload)
      Attempts to use Tika via reflection. Falls back to FileMagic if Tika is missing.
    • detectMimeType

      public String detectMimeType(InputStream stream)
      Attempts to use Tika via reflection. Falls back to FileMagic if Tika is missing.
    • getMimeType

      public static String getMimeType(FileMagic magic)
      Converts a FileMagic entry to its primary MIME type.