public class OWriterDoc extends ORootDoc
| Modifier and Type | Class and Description |
|---|---|
class |
OWriterDoc.Field
A text field.
|
class |
OWriterDoc.ParaCursor
A paragraph cursor.
|
static interface |
OWriterDoc.TextCursor
Defines the behavior of all text cursors.
|
static class |
OWriterDoc.TextFieldType
Enumerates text document field types.
|
class |
OWriterDoc.TextSearch
A text search.
|
class |
OWriterDoc.WordCursor
A word cursor.
|
ORootDoc.Info| Constructor and Description |
|---|
OWriterDoc(java.lang.String url)
Constructs and opens a Writer document.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addText(java.lang.String text)
Adds text at the cursor position and advances the cursor.
|
void |
applyParaStyle(OStyle.Para style)
Applies a paragraph style at the cursor position.
|
void |
endPara()
Ends the current paragraph by inserting a paragraph break.
|
void |
insertBitmap(OStyle.Frame style,
com.sun.star.awt.Size size,
java.lang.String bitmapURL,
com.sun.star.text.TextContentAnchorType anchor)
Inserts a bitmap at the cursor position.
|
OWriterDoc.Field |
insertField(OWriterDoc.TextFieldType type)
Inserts a text field at the cursor position.
|
OTable |
insertTable(int numRows,
int numCols,
com.sun.star.text.TextContentAnchorType anchor)
Inserts a text table at the cursor position.
|
int |
insertTextFile(java.io.File path,
boolean trim)
Inserts the contents of a text file at the cursor position.
|
void |
insertTextFrame(OStyle.Frame style,
com.sun.star.awt.Size size,
java.lang.String text,
com.sun.star.text.TextContentAnchorType anchor)
Inserts a text frame at the cursor position.
|
int |
numChars()
Returns the number of characters in the document.
|
int |
numParas()
Returns the number of paragraphs in the document.
|
int |
numWords()
Returns the number of words in the document.
|
java.util.Collection<java.lang.String> |
paraTexts()
Returns a collection of paragraph texts, excluding empty paragraphs.
|
int |
replace(java.lang.String from,
java.lang.String to)
Replaces all occurences of a string with another string, case sensitive.
|
int |
setWordStyle(java.lang.String word,
OStyle.Char style)
Sets the character style for every instance in the document of a specified word.
|
void |
startPage(OStyle.Page style)
Starts a new page with a specified style.
|
void |
startPara(OStyle.Para style)
Starts a new paragraph with a specified style.
|
java.lang.String |
writeOdt(java.lang.String url)
Writes the document using OFileFilter.ODT.
|
com.sun.star.text.XTextDocument |
xGetXDoc()
Gets the XTextDocument object for the document.
|
com.sun.star.text.XTextCursor |
xGetXTextCursor()
Gets the XTextCursor object for the document.
|
close, deleteStyle, info, logFields, logServices, logShapes, logStyles, logSummary, numPages, numShapes, numStyles, read, setupStyles, shapes, shapesByType, style, styleFamilies, styles, styles, toString, url, write, writeProtected, xGetMSFactory, xGetXComplogProps, xGetPropSetpublic OWriterDoc(java.lang.String url)
throws com.sun.star.uno.Exception
url - the URLcom.sun.star.uno.Exceptionpublic int numChars()
throws com.sun.star.uno.Exception
com.sun.star.uno.Exceptionpublic int numWords()
throws com.sun.star.uno.Exception
com.sun.star.uno.Exceptionpublic int numParas()
throws com.sun.star.uno.Exception
com.sun.star.uno.Exceptionpublic java.util.Collection<java.lang.String> paraTexts()
throws com.sun.star.uno.Exception
com.sun.star.uno.Exceptionpublic int replace(java.lang.String from,
java.lang.String to)
throws com.sun.star.uno.Exception
from - the string to replaceto - the replacment stringcom.sun.star.uno.Exceptionpublic void startPara(OStyle.Para style) throws com.sun.star.uno.Exception
style - the paragraph style to setcom.sun.star.uno.Exceptionpublic void endPara()
public void startPage(OStyle.Page style) throws com.sun.star.uno.Exception
style - the page stylecom.sun.star.uno.Exceptionpublic void addText(java.lang.String text)
text - the textpublic void applyParaStyle(OStyle.Para style) throws com.sun.star.uno.Exception
style - the paragraph stylecom.sun.star.uno.Exceptionpublic void insertTextFrame(OStyle.Frame style, com.sun.star.awt.Size size, java.lang.String text, com.sun.star.text.TextContentAnchorType anchor) throws com.sun.star.uno.Exception
style - the frame stylesize - the frame sizetext - the frame textanchor - the anchor typecom.sun.star.uno.Exceptionpublic void insertBitmap(OStyle.Frame style, com.sun.star.awt.Size size, java.lang.String bitmapURL, com.sun.star.text.TextContentAnchorType anchor) throws com.sun.star.uno.Exception
style - the frame stylesize - the bitmap sizebitmapURL - the bitmap URLanchor - the anchor typecom.sun.star.uno.Exceptionpublic OTable insertTable(int numRows, int numCols, com.sun.star.text.TextContentAnchorType anchor) throws com.sun.star.uno.Exception
numRows - the number of rowsnumCols - the number of columnsanchor - the anchor typecom.sun.star.uno.Exceptionpublic OWriterDoc.Field insertField(OWriterDoc.TextFieldType type) throws com.sun.star.uno.Exception
type - the field typecom.sun.star.uno.Exceptionpublic int insertTextFile(java.io.File path,
boolean trim)
throws java.lang.Exception
path - the text file pathtrim - whether to trim whitespace from the start and end of every linejava.lang.Exceptionpublic int setWordStyle(java.lang.String word,
OStyle.Char style)
throws com.sun.star.uno.Exception
word - the wordstyle - the character stylecom.sun.star.uno.Exceptionpublic java.lang.String writeOdt(java.lang.String url)
throws com.sun.star.uno.Exception,
com.sun.star.uno.Exception
url - the URLcom.sun.star.uno.Exceptionpublic com.sun.star.text.XTextDocument xGetXDoc()
public com.sun.star.text.XTextCursor xGetXTextCursor()