WordProcessor API

The WordProcessor class defines API properties and methods that operate on the document as a whole. There are a number of objects that implement the WordProcessor properties and methods. The following diagram shows the object hierarchy:

WordProcessor object model
The methods and properties are listed below in the following categories:


The following methods perform operations on text for navigating through the text and optionally selecting the text.

Insertion

The following methods insert text, images, or special characters at the insertion point.
Return Function Call Description
IWP_Bookmark insertBookmark(String name) insert a bookmark object at the current insertion point, giving it a specified name
IWP_ClickHere insertClickHere(String name, String prompt) insert a click here block object at the current insertion point, giving it a specified name. See also: ClickHere blocks.
IWP_Date insertDate(String name, String format) insert a date object at the current insertion point, giving it a specified name. Use the java SimpleDateFormat
IWP_HorizontalLine insertHorizontalLine(String name) insert a horizontal line object at the current insertion point, giving it a specified name
IWP_Image insertImage(String name, String URL) insert an image object at the current insertion point, giving it a specified name
boolean insertLineBreak() insert a line break object at the current insertion point, giving it a specified name
IWP_Link insertLink(String name, String destination) insert a link object at the current insertion point, giving it a specified name
IWP_Marker insertMarker(String name, String text) insert a marker object at the current insertion point, giving it a specified name
boolean insertPageBreak() insert a page break object at the current insertion point, giving it a specified name
IWP_PageNumber insertPageNumber(String name, String format) insert a page number object at the current insertion point, giving it a specified name and format
IWP_Table insertTable(String name, int rows, int cols) insert a table object at the current insertion point, giving it a specified name
void insertText(String s) insert the string at the current insertion point
void setDocumentVariable(String name, String value) like ClickHere blocks, DocumentVariables provide a named location and current value for use by automation. Unlike ClickHere blocks, there is not prompt text.
void splitParagraph() the same as pressing ENTER to split a paragraph.
Return to top


Enumerating

The following methods enumerating types of objects (images, tables, links, etc.) within the entire document.
Return Function Call Description
IWP_Enumerator enumerateBookmarks() returns an IWP_Enumerator with the bookmark objects names. Use findBookmark() to access the desired bookmark by name.
IWP_Enumerator enumerateClickHeres() returns an IWP_Enumerator with the click here objects names. Use findClickHere() to access the desired click here by name.
IWP_Enumerator enumerateDates() returns an IWP_Enumerator with the date objects names. Use findDate() to access the desired date by name.
IWP_Enumerator enumerateDocumentVariables() returns an IWP_Enumerator with the document variable objects names. Use getDocumentVariable() to access the desired document variable by name.
IWP_Enumerator enumerateHorizontalLines() returns an IWP_Enumerator with the horizontal line object names. Use findHorizontalLine() to access the desired horizontal line by name.
IWP_Enumerator enumerateImages() returns an IWP_Enumerator with the image object names. Use findImage() to access the desired image by name.
IWP_Enumerator enumerateLinks() returns an IWP_Enumerator with the link object names. Use findLink() to access the desired link by name.
IWP_Enumerator enumerateMarkers() returns an IWP_Enumerator with the marker object names. Use findMarker() to access the desired marker by name.
IWP_Enumerator enumeratePageLayouts() returns an IWP_Enumerator with the page layout object names. Use findPageLayout() to access the desired page layout by name.
IWP_Enumerator enumeratePageNumbers() returns an IWP_Enumerator with the page number object names. Use findPageNumbers() to access the desired page number by name.
IWP_Enumerator enumerateParagraphStyles() returns an IWP_Enumerator with the paragarph style object names. Use findParagraphStyle() to access the desired paragraph style by name.
IWP_Enumerator enumerateTables() returns an IWP_Enumerator with the table object names. Use findTable() to access the desired table by name.
Return to top


Accessing

The following methods access the names of inserted object like tables, links, etc.
Return Function Call Description
IWP_Bookmark findBookmark(String name) find a bookmark object by name
IWP_ClickHere findClickHere(String name) find a click here block object by name
IWP_Date findDate(String name) find a date object by name
IWP_HorizontalLine findHorizontalLine(String name) find a horizontal line object by name
IWP_Image findImage(String name) find an image object by name
IWP_Link findLink(String name) find a link object by name
IWP_Marker findMarker(String name) find a marker object by name
IWP_PageLayout findPageLayout(String name) find a page layout object by name
IWP_PageNumber findPageNumber(String name) find a page number object by name
IWP_ParagraphStyle findParagraphStyle(String name) find a paragraph style object by name
IWP_Table findTable(String name) find a table object by name
String getDocumentVariable(String name) get the current value for the document variable by name.
Return to top


Deletion

The following methods deleting text, images, or special characters at the insertion point.
Return Function Call Description
void backSpace() The same as pressing BACKSPACE.
boolean delete() The same as pressing DELETE.
boolean deleteBookmark(String name) delete a bookmark object by name
boolean deleteClickHere(String name) delete a click here block object by name
boolean deleteDate(String name) delete a date object by name
boolean deleteHorizontalLine(String name) delete a horizontal line object by name
boolean deleteImage(String name) delete an image object by name
boolean deleteLink(String name) delete a link object by name
boolean deleteMarker(String name) delete a marker object by name
boolean deletePageLayout(String name) delete a page layout object by name
boolean deletePageNumber(String name) delete a page number object by name
boolean deleteParagraphStyle(String name) delete a paragraph style object by name
boolean deleteTable(String name) delete a table object by name
Return to top


Text selection

Return Function Call Description
boolean left( boolean shade ) move the insertion point one character to the left, and if shading is true, shade the character
boolean right( boolean shade ) move the insertion point one character to the right, and if shading is true, shade the character
boolean up( boolean shade ) move the insertion point up one line, and if shading is true, shade the text passed over.
boolean down( boolean shade ) move the insertion point down one line, and if shading is true, shade the text passed over.
boolean home( boolean shade ) move the insertion point to the beginning of the line, and if shading is true, shade the text passed over.
boolean end( boolean shade ) move the insertion point to the end of the line, and if shading is true, shade the text passed over.
Return to top

Text manipulation

The following methods perform operations on text, such as copying and pasting.
Return Function Call Description
boolean undo() reverses the last action performed on the document.
boolean copy() copies the highlighted text to the Clipboard.
boolean cut() cuts the highlighted text and puts it on the Clipboard.
boolean paste() places the text from the clipboard at the insertion point.
boolean clear() cuts the highlighted text without putting it on the Clipboard.
Return to top


Text retrieval

The following methods move the insertion point to various locations in the document.
Return Function Call Description
String getCharacter() gets the character at the insertion point
String getWord() gets the word at the insertion point
String getParagraph() gets the paragraph at the insertion point
String getShadedText() gets the text that is shaded
Return to top


Document navigation

The following methods move the insertion point to various locations in the document.
Return Function Call Description
boolean gotoPage(int page) move the insertion point to the beginning of the specified page number. Page numbering is zero based, so the first page is page 0.
boolean gotoHeader() move the insertion point to the header
boolean gotoFooter() move the insertion point in the footer
boolean gotoBeginningOfDocument() move the insertion point to the beginning of the document
boolean gotoBeginningOfParagraph() move the insertion pointer to the beginning of the current paragraph
boolean gotoBeginningofWord() move the insertion point to the beginning of the current word
boolean gotoEndOfDocument() move the insertion point to the end of the document.
boolean gotoEndOfParagraph() move the insertion point to the end of the current paragraph
boolean gotoEndOfWord() move the insertion point to the end of the current word
boolean gotoNextCharacter() move the insertion point to the next character
boolean gotoNextParagraph() move the insertion point to the beginning of the next paragaraph
boolean gotoNextWord() move the insertion point to the beginning of the next word
boolean gotoPreviousCharacter() move the insertion point to the previous character
boolean gotoPreviousParagarph() move the insertion point to the beginning of the prevous paragraph
boolean gotoPreviousWord() move the insertion point to the beginning of the previous word
boolean gotoText(String text) move the insetion point to the next block of text that matches the specified text
Return to top


Document colors

The following methods get and set the colors of various elements of the document, for example, text and ClickHere blocks.
Return Function Call Description
Color getBackgroundColor() get the Color of the background for the document
void setBackgroundColor( Color ) set the Color of the background for the document
Color getDefaultTextColor() get the default Color of the text for the document
Color setDefaultTextColor( Color ) set the default Color of the text for the document
Color getLinkColor() get the Color used for links
void setLinkColor ( Color ) set the Color used for links
Color getBorderColor() get the Color used for the border
void setBorderColor( Color ) set the Color used for the border
Color getStrikethroughColor() get the Color used for strike through text
void setStrikethroughColor( Color ) set the Color used for strike through text
Color getClickhereColor() get the Color used for click here block prompt text
void setClickhereColor( Color ) set the Color used for click here block prompt text
Return to top


Document operations

The following methods load documents and get and set document contents
Return Function Call Description
String getFilename() gets the name of the current file
boolean newDocumentFromTemplate(String filename) create a new document from a template and give the filename
boolean openDocument(String filename) open the specified file
boolean openDocumentFromStream( DataInput streamname ) open a stream of java type DataInput
boolean saveDocument(String filename) save the document with the filename
boolean saveDocumentToStream( DataOutput streamname) save the stream to the java type DataOutput
void setInfoBusHTMLSource(String infobusItemName) Loads an HTML document from the InfoBus.
String getInfoBusHTMLSource() returns the name of an InfoBus item.
void setInfoBusAsciiSource(String infobusItemName) loads an ASCII document from the InfoBus.
String getInfoBusAsciiSource() Returns the name of an InfoBus item.
void insertDocument(String url) Insert the contents of document from a file, intranet, or internet at the insertion point.
String getDocumentContents() gets the complete document as ASCII text. Uses ASCII newlines to separate paragraphs.
void setDocumentContents(String source) sets the complete document as ASCII text. Uses ASCII newlines to separate paragraphs.
String getDocumentContentsAsHTML() gets the complete document as HTML text
void setDocumentContentsAsHTML(String source) sets the complete document as HTML text
Return to top


Paragraph attributes

The following functions paragraph alignment and styles. There is also a method that lets you create paragraph styles.
Return Function Call Description
IWP_ParagraphStyle createParagraphStyle(String newstylename, String basestylename) creates a new paragraph style, named "newstylename" based on and exactly like "basestylename". With the returned pointer make changes to the new paragraph style. See IWP_ParagraphStyle
IWP_Enumerator enumerateParagraphStyles() returns an IWP_Enumerator with the paragarph style object names. Use findParagraphStyle() to access the desired paragraph style by name.
IWP_ParagraphStyle findParagraphStyle() returns a pointer to an IWP_ParagraphStyle object. With the returned pointer make changes to the paragraph style. See IWP_ParagraphStyle
boolean deleteParagraphStyle(String name) delete the paragraph style object by name.
void setParagraphStyle(String stylename) What are the possible string values I can pass to this method?
String getParagraphStyle() get the name of the paragarph style at the insertion point
void setAlignment(String alignment) set the alignment at the insertion point to "left", "right", "center", "justify"
String getAlignment() gets the alignment for the text at the insertion point


Text attributes

The following properties set and get text and font settings, and paragraph alignment and styles. There is also a method that lets you create paragraph styles.
Return Function Call Description
void setBold(boolean on) set the bold attribute for the shaded text. See Text selection for selecting text.
boolean isBold() determine if the selected text is bold
void setItalic(boolean on) set the italic attribute for the shaded text. See Text selection for selecting text.
boolean isItalic() determine if the selected text is italic
void setUnderline(boolean on) set the underline attribute for the shaded text. See Text selection for selecting text.
boolean isUnderline() determine if the selected text is underline
void setStrikeThrough(boolean on) set the strike through attribute for the shaded text. See Text selection for selecting text.
boolean isStrikeThrough() determine if the selected text is strike through
void setProtected(boolean on) set the protected attribute for the shaded text. See Text selection for selecting text. Protected text is not editable.
boolean isProtected() determine if the selected text is protected
void setFontName(String facename) set the font face for the selected text. Standard Java fonts are: "Dialog", "Serif", "SansSerif", "MonoSpaced", "Helvetica", "TimesRoman", "Courier", "ZapfDingbats"
String getFontName() gets the font face at the insertion point
void setFontSize(int size) set the font size of the selected text in points
int setFontSize() get the font size at the insertion point
Color getFontColor() get the Color used for text
void setFontColor ( Color ) set the Color used for links
void setTextColor (Color color) set the text color of the selected text
Color getTextColor() get the text color at the insertion point
Return to top


Printing

The following methods print or preview all or part of a document.
Return Function Call Description
boolean printDocument() print the document
boolean printRange(int start, int end) pages in the document are zero-based so the first page is page 0 and the start and end values are page-1. Printing the second thru the fourth pages would be printRange(1,3)
void setPrintPreview(boolean bPreview) display a preview of the document as it will print. true starts preview and false ends preview.
boolean getPrintPreview() determine whether the wordprocessor is previewing the document. True is preview mode, and false is edit mode.
Return to top


Mail merge

The following methods perform mail merge operations. The mail merge methods uses a record manager (IRecordMan) that handles RowsetAccess data from the InfoBus. If you produce RowsetAccess data on the InfoBus, call mergeToPrinterFromInfoBus. If you produce some other kind of data on the InfoBus, and wrote a class that implements IRecordMan, first call setRecordManager passing your class name. Then call mergeToPrinterFromInfoBus, and the mail merge feature uses your record manager. If you wrote a class that imlements IRecordMan, and it can produce its own data, just call mergeToPrinter and pass it your record manager. If you are not interested in printing, you can merge one record at a time with the mergeFirstRecord and mergeNextRecord methods.

Return Function Call Description
void setRecordManager(String classname) Calling program must provide the record manager supporting the IRecordMan interface. A simple example ArrayRecordMan is included.
String getRecordManager() get the name of the record manager for merging
boolean mergeToPrinter(IRecordMan recMan) merge all records to the printer. Calling program must provide the record manager supporting the IRecordMan interface. A simple example ArrayRecordMan is included.
boolean mergeToPrinterFromInfoBus(String itemName) merge all records to the printer using data some program puts on the InfoBus.
boolean mergeFirstRecordFromInfoBus(String itemName) merge the first record into the current document from the InfoBus using the reference name itemName for the information on the InfoBus
boolean mergeFirstRecord(IRecordMan recMan) merge the first record into the current document using the specified record manager. A simple example ArrayRecordMan is included.
boolean mergeNextRecord() merge the next record into the current document. Function returns false when end-of-file is encountered.
Return to top


Utilities

The following methods perform useful operations, such as getting the word count for the document. They also specify properties of features, such as document variables and Click Here blocks.
Return Function Call Description
int currentPageNumber() returns the number of the page the insertion point is on; numbering is zero-based
void setStartingPageNumber(int num) specifies the page number for the first page
int getStartingPageNumber() returns the page number for the first page.
int getPageCount() get the number of pages in the document
Return to top


See Also
WordProcessor examples
Table examples