Other new classes represent element types and objects: NotesRichTextTable, NotesRichTextDoclink, and NotesRichTextSection. Download the examples We’ve created a handful of code examples to show how these new capabilities are used. You can download a Notes database that includes them all from the Sandbox. When you work with these example agents, keep in mind that Notes/Domino 6 does not refresh rich text items on the fly. So while you can write agents that reshape the content of rich text fields, if you start with an open document, you must close and reopen it to see the changes. These example agents were written to run in a Notes client, but you could easily adapt them to run on a Domino server and to launch from a WebQuerySave event or any of the many other mechanisms for running agents. Example 1: Using LotusScript to build a rich text table The first code example uses several of the new classes to build and manipulate a table in a rich text field. You can see the code of this agent, which is named 1. Order an Item in the examples database. You may want to keep it open. The guided tour of the code that follows covers only the highlights and omits some of the lines of code. To see the agent run, in the examples database open the document named Office Supplies Order and create a new table in the blank document by choosing Actions - 1. Order an Item, then close and reopen the document. Order an Item is a simple order-entry application that lets a user select an item from a picklist and enter a quantity. It performs a lookup to get the item price, then creates a new row in a table to hold the quantity ordered, item description, unit price, and a subtotal of quantity times unit price. With a cell to hold a row number, the table is five columns across by unlimited rows deep. In a conventional Domino application, a 20-item order would create a table with 100 separate fields. In the following example, there are three fields—a user-editable rich text field to hold identifying information and comments, a computed rich text field to hold the table, and a computed field to hold the total of the order. The UI for this example is minimal: The Order an Item agent includes Dim statements that create three new types of objects: Dim rtnavBody As NotesRichTextNavigator
Domino automatically translates between these color spaces and the set of 241 NotesColors. When you use the SetRGB or SetHSL methods, Domino returns the NotesColor value. No matter how you set the color—whether by constant name, NotesColor, RGB, or HSL. The NotesColor, RGB, and HSL values are available as properties of the NotesColorObject. Because Domino returns the NotesColor value automatically when you use SetRGB or SetHSL, you can capture it to a variable and use it to set the color of elements. To set the bar color of a section to a custom RGB color in the previous example, for instance, you would first set the RGB values and create a variable (MyColor in the following code) to hold the integer that is the NotesColor. Where the example formerly assigned Black as the default color, it now assigns the custom color MyColor: MyColor = colorObject.SetRGB(204, 102, 51) If col$ = "Red" Then