Examples: RichTextNavigator class
This agent displays the number of elements of each type in the Body item of the current or first selected document.
import lotus.domino.*;
public class JavaAgent extends AgentBase {
RichTextNavigator rtnav = null;
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
DocumentCollection dc = agentContext.getUnprocessedDocuments();
Document doc = dc.getFirstDocument();
RichTextItem rti = (RichTextItem)doc.getFirstItem("Body");
rtnav = rti.createNavigator();
System.out.println("Number of doc links = " +
getCount(RichTextItem.RTELEM_TYPE_DOCLINK));
System.out.println("Number of file attachments = " +
getCount(RichTextItem.RTELEM_TYPE_FILEATTACHMENT));
System.out.println("Number of OLE objects = " +
getCount(RichTextItem.RTELEM_TYPE_OLE));
System.out.println("Number of sections = " +
getCount(RichTextItem.RTELEM_TYPE_SECTION));
System.out.println("Number of tables = " +
getCount(RichTextItem.RTELEM_TYPE_TABLE));
System.out.println("Number of table cells = " +
getCount(RichTextItem.RTELEM_TYPE_TABLECELL));
System.out.println("Number of text paragraphs = " +
getCount(RichTextItem.RTELEM_TYPE_TEXTPARAGRAPH));
System.out.println("Number of text runs = " +
getCount(RichTextItem.RTELEM_TYPE_TEXTRUN));
} catch(Exception e) {
e.printStackTrace();
}
}
int getCount(int elementType) {
int count = 0;
try {
if (rtnav.findFirstElement(elementType)) {
do {
count++;
} while (rtnav.findNextElement());
}
} catch(Exception e) {
e.printStackTrace();
}
return count;
}
}