Examples: RichTextTab class
This agent sets tabs in a first rich text paragraph style, then copies the tabs from the first style to a second rich text paragraph style and clears the last tab. The agent then applies each style to a paragraph of text.
import lotus.domino.*;
import java.util.Vector;
import java.util.Enumeration;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
Document doc = db.createDocument();
Item subject = doc.replaceItemValue("Subject",
"Rich text tab");
RichTextItem body = doc.createRichTextItem("Body");
RichTextParagraphStyle b1 =
session.createRichTextParagraphStyle();
RichTextParagraphStyle b2 =
session.createRichTextParagraphStyle();
// Define para style b1
b1.clearAllTabs();
b1.setTabs(3, RichTextParagraphStyle.RULER_ONE_INCH * 3,
RichTextParagraphStyle.RULER_ONE_INCH * 2,
RichTextParagraphStyle.TAB_LEFT);
// Set b2 tabs same as b1
b2.clearAllTabs();
Enumeration b1tabs = b1.getTabs().elements();
while (b1tabs.hasMoreElements()) {
RichTextTab b1tab = (RichTextTab)b1tabs.nextElement();
b2.setTab(b1tab.getPosition(), b1tab.getType());
}
// Clear last tab
RichTextTab b2tab =
(RichTextTab)b2.getTabs().lastElement();
b2tab.clear();
// Append para style b1 and write para
body.appendParagraphStyle(b1);
body.appendText("Column 1");
body.addTab();
body.appendText("Column 2");
body.addTab();
body.appendText("Column 3");
body.addTab();
body.appendText("Column 4");
// Append para style b2 and write para
body.appendParagraphStyle(b2);
body.appendText("Column 1");
body.addTab();
body.appendText("Column 2");
body.addTab();
body.appendText("Column 3");
// Save the document
doc.save(true, true);
} catch(Exception e) {
e.printStackTrace();
}
}
}