net.sf.mpxj.mpp
Class RTFEmbeddedObject

java.lang.Object
  extended by net.sf.mpxj.mpp.RTFEmbeddedObject

public final class RTFEmbeddedObject
extends Object

This class represents embedded object data contained within an RTF document. According to the RTF specification, this data has been written using the OLESaveToStream, although I have been unable to locate any existing Java implementations of the equivalent OLELoadFromStream in order to read this data, hence the current implementation. To use this class with note fields in MPXJ, call MPPFile.setPreserveNoteFormatting(true) to allow retrieval of the raw RTF document text from the note fields. You can use the RTFUtility.strip() method to extract plain text from the document for display. If you want to extract any embedded objects from the document, call the RTFEmbeddedObject.getEmbeddedObjects() method, passing in the raw RTF document. The structure of data embedded in a notes field is beyond the scope of the MPXJ documentation. However, generally speaking, you will find that each item of embedded data will be made up of two RTFEmbeddedObject instances, the first is a header usually containing string data, the second is the actual payload data, which will typically be binary. You can retrieve the String data using the RTFEmbeddedObject.getStringData() method, and the binary data using the RTFEmbeddedObject.getData() method. For each embedded item in the document you will typically find two groups of these objects. The first group of two RTFEmbeddedObject instances (one header object and one data object) represent either the location of a linked document, or the binary data for the document itself. The second group of two RTFEmbeddedObject instances contain a METAFILEPICT, which either contains the icon image used as a placeholder for the embedded document, or it contains an image of the document contents, again used as a placeholder. Warning: this functionality is experimental, please submit bugs for any example files containing embedded objects which fail to parse when using this class.


Method Summary
 byte[] getData()
          Retrieve the data associated with this block as a byte array.
 String getDataString()
          Retrieve the data associated with this block as a string.
static List<List<RTFEmbeddedObject>> getEmbeddedObjects(String text)
          This method generates a list of lists.
 int getTypeFlag1()
          Retrieve type flag 1.
 int getTypeFlag2()
          Retrieve type flag 2.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getTypeFlag1

public int getTypeFlag1()
Retrieve type flag 1.

Returns:
type flag 1

getTypeFlag2

public int getTypeFlag2()
Retrieve type flag 2.

Returns:
type flag 2

getData

public byte[] getData()
Retrieve the data associated with this block as a byte array.

Returns:
byte array of data

getDataString

public String getDataString()
Retrieve the data associated with this block as a string.

Returns:
string data

getEmbeddedObjects

public static List<List<RTFEmbeddedObject>> getEmbeddedObjects(String text)
This method generates a list of lists. Each list represents the data for an embedded object, and contains set set of RTFEmbeddedObject instances that make up the embedded object. This method will return null if there are no embedded objects in the RTF document.

Parameters:
text - RTF document
Returns:
list of lists of RTFEmbeddedObject instances

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.