|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.ooffice.AbstractOfficeDocument
com.antelmann.ooffice.OOWriter
public class OOWriter
simplifies the handling of OpenOffice Writer documents This class implements ThirdParty for its use of OpenOffice libraries; see www.openoffice.org
OOTableWriter| Field Summary | |
|---|---|
static String |
HTML_FILTER
|
static String |
MSWORD_FILTER
|
static String |
MSWORD_XML_FILTER
|
static char |
NON_BREAKING_HYPHEN
|
static char |
NON_BREAKING_SPACE
|
static char |
OPTIONAL_HYPHEN
|
static String |
PARAGRAPH_STYLE_KEY
allows to set a cursor to 'Heading 1' or the alike via AbstractOfficeDocument.setPropertyValue(Object, String, Object) |
static String |
TEXT_FILTER
|
static String |
USER_FIELD_PREFIX
|
| Constructor Summary | |
|---|---|
OOWriter()
creates a blank new document |
|
OOWriter(boolean hidden)
|
|
OOWriter(boolean previewMode,
File file)
|
|
OOWriter(boolean previewMode,
URL url)
|
|
OOWriter(File template)
creates a new document based on the given template file |
|
OOWriter(File template,
boolean hidden)
|
|
OOWriter(File file,
Map<?,?> props)
loads a document (the given file) into a blank frame along with the given properties |
|
OOWriter(InputStream in,
boolean hidden)
|
|
OOWriter(InputStream in,
Map<?,?> props)
|
|
OOWriter(URL url,
boolean hidden)
|
|
OOWriter(URL url,
Map<?,?> props)
loads a document from the given url into a blank frame along with the given properties. |
|
OOWriter(com.sun.star.lang.XComponent comp)
|
|
OOWriter(com.sun.star.text.XTextDocument document)
|
|
| Method Summary | ||
|---|---|---|
void |
alignParagraph(ParagraphAlignment alignment)
uses the view cursor |
|
void |
alignParagraph(com.sun.star.text.XTextRange cursor,
ParagraphAlignment alignment)
|
|
OOWriter |
append(char c)
|
|
OOWriter |
append(CharSequence csq)
|
|
OOWriter |
append(CharSequence csq,
int start,
int end)
|
|
static File |
convertToPDF(File writerFile,
File pdfFile)
converts the file w/o showing the GUI (the returned file ensures a .pdf ending) |
|
void |
deleteImage(String imageName)
|
|
Object |
findFirst(String searchText,
boolean caseSensitive)
finds and returns an object that represents the search result based on the given text. |
|
Object |
findNext(Object previousSearchResult,
String searchText,
boolean caseSensitive)
sets the view cursor to the next occurrence found for further handling (as a side-effect) |
|
void |
formatText(CharacterFormat format)
uses the view cursor |
|
void |
formatText(Color color)
uses the view cursor |
|
void |
formatText(Font font)
|
|
void |
formatText(Underline ul)
uses the view cursor |
|
void |
formatText(com.sun.star.text.XTextRange cursor,
CharacterFormat format)
|
|
void |
formatText(com.sun.star.text.XTextRange cursor,
Color color)
|
|
void |
formatText(com.sun.star.text.XTextRange cursor,
Font font)
|
|
void |
formatText(com.sun.star.text.XTextRange cursor,
Underline ul)
|
|
void |
formatTextBackground(Color color)
uses the view cursor |
|
void |
formatTextBackground(com.sun.star.text.XTextRange cursor,
Color color)
|
|
static OOWriter |
getActiveDocument()
seeks the currently active document on the desktop (if any) and returns it |
|
com.sun.star.text.XTextCursor |
getBookmarkCursor(String bookmark)
throws IllegalArgumentException if the bookmark is not found |
|
com.sun.star.text.XTextRange |
getBookmarkRange(String bookmark)
may return null if the bookmark is not found |
|
String[] |
getBookmarks()
|
|
String |
getBookmarkText(String bookmark)
|
|
int |
getCharacterCount()
|
|
String |
getClipboardAsString()
retrieves the UTF text content from the office clipboard |
|
com.sun.star.text.XTextCursor |
getCursorForText(String txt,
boolean caseSensitive)
|
|
com.sun.star.text.XTextDocument |
getDocument()
|
|
OODocType |
getDocumentType()
|
|
String[] |
getFieldNames()
|
|
String |
getFieldText(String fieldName)
the fully quantified field name is to be supplied |
|
Font |
getFont()
|
|
Font |
getFont(com.sun.star.text.XTextRange cursor)
|
|
BufferedImage |
getImage(String imageName)
|
|
String[] |
getImageNames()
|
|
Object |
getImageObject(String imageName)
|
|
int |
getNumberOfPages()
attention: this method call moves the visible cursor position to the last page |
|
int |
getPageNumber(com.sun.star.text.XTextViewCursor cursor)
if the document was altered, this method is only reliable if the document is not hidden |
|
int |
getParagraphCount()
|
|
List<com.sun.star.text.XTextFrame> |
getTextFrames()
provides convenience for sticker label printing |
|
Map<String,String> |
getUserFieldContent()
|
|
String[] |
getUserFieldNames()
|
|
String |
getUserFieldText(String userFieldName)
|
|
com.sun.star.text.XTextViewCursor |
getViewCursor()
returns the XTextCursor that is currently visible in the document |
|
int |
getWordCount()
|
|
com.sun.star.lang.XComponent |
getXComponent()
|
|
com.sun.star.text.XTextViewCursor |
gotoBegin()
moves the view cursor to the begin of the document |
|
com.sun.star.text.XTextViewCursor |
gotoBookmark(String bookmark)
sets the view cursor to the given bookmark |
|
com.sun.star.text.XTextViewCursor |
gotoEnd()
moves the view cursor to the end of its current range |
|
boolean |
gotoFirst(String searchText,
boolean caseSensitive)
sets the view cursor to the first occurrence of the given String (as a side-effect), so that the view cursor can be used to further handle the occurrence. |
|
boolean |
hasBookmark(String bookmark)
|
|
void |
insertBookmark(String bookmarkName,
com.sun.star.text.XTextRange range)
|
|
void |
insertContent(InputStream in,
com.sun.star.text.XTextRange cursor)
inserts some content into the given location; for example, the content could represent HTML |
|
void |
insertContent(Object content,
com.sun.star.text.XTextRange cursor)
|
|
void |
insertContent(String content,
com.sun.star.text.XTextRange cursor)
inserts the given content via ByteArrayInputStream |
|
void |
insertFileAt(File file,
com.sun.star.text.XTextRange cursor)
inserts one document into another |
|
Object |
insertImage(File file,
com.sun.star.text.XTextRange cursor,
AnchorType at)
|
|
Object |
insertImage(File file,
com.sun.star.text.XTextRange cursor,
AnchorType at,
boolean embed)
|
|
Object |
insertImage(File file,
com.sun.star.text.XTextRange cursor,
AnchorType at,
boolean embed,
Map<?,?> props)
|
|
Object |
insertImage(File file,
com.sun.star.text.XTextRange cursor,
AnchorType at,
Map<?,?> props)
|
|
Object |
insertImage(Image image,
com.sun.star.text.XTextRange cursor,
AnchorType at)
|
|
Object |
insertImage(Image image,
com.sun.star.text.XTextRange cursor,
AnchorType at,
Map<?,?> props)
automatically sets the Width and Height properties unless an explicit value was given |
|
Object |
insertImage(URL url,
com.sun.star.text.XTextRange cursor,
AnchorType at,
boolean embed,
Map<?,?> props)
allows to insert an image into the document. |
|
Object |
insertImage(URL url,
com.sun.star.text.XTextRange cursor,
AnchorType at,
boolean embed,
Map<?,?> props,
String name)
allows to insert an image into the document. |
|
Object |
insertImage(URL url,
com.sun.star.text.XTextRange cursor,
AnchorType at,
Map<?,?> props)
|
|
void |
insertPageBreakAfter(com.sun.star.text.XTextRange cursor)
inserts a page break after the current paragraph of the given cursor |
|
void |
insertPageBreakBefore(com.sun.star.text.XTextRange cursor)
inserts a page break before the current paragraph of the given cursor |
|
void |
insertUrlAt(URL url,
com.sun.star.text.XTextRange cursor)
inserts one document into another |
|
boolean |
isEmbeddedImage(String imageName)
|
|
Iterator<com.sun.star.text.XTextCursor> |
iterate(String searchText,
boolean caseSensitive)
iterates over all occurrences of the given text and provides the corresponding cursors. |
|
static OOWriter |
open(File file)
opens a document for editing |
|
static OOWriter |
open(File file,
boolean hidden)
opens a document for editing |
|
static OOWriter |
open(File file,
boolean readOnly,
boolean previewMode)
opens a document with the specified options |
|
static OOWriter |
openReadOnly(File file)
opens a document in read-only mode |
|
void |
refreshFields()
|
|
void |
replaceAll(String search,
String replace)
performs a simple search/replace on the entire document |
|
void |
setBackgroundColor(Color c)
sets the background color for the standard page |
|
void |
setBookmarkText(String bookmark,
String text)
sets the text of for a defined bookmark within the given document |
|
void |
setBorder(Object obj,
CellBorder border)
|
|
void |
setFieldText(String fieldName,
String text)
the fully quantified field name is to be supplied |
|
void |
setUserFieldContent(Map<?,?> fields)
sets the field content of the field variables contained in the map. |
|
void |
setUserFieldText(String userFieldName,
String text)
|
|
void |
setViewCursor(com.sun.star.text.XTextRange cursor)
|
|
void |
setWatermark(File imageFile)
sets the watermark in the middle of the page for the 'Standard' page style |
|
void |
setWatermark(File imageFile,
String pageStyle)
|
|
void |
setWatermark(Image image)
|
|
void |
setWatermark(Image image,
String pageStyle)
|
|
void |
setWatermark(URL url,
String pageStyle)
|
|
com.sun.star.text.XTextViewCursor |
writeText(String text)
uses the view cursor |
|
|
writeText(String text,
T cursor)
overwrites the text at the given cursor position. |
|
| Methods inherited from class com.antelmann.ooffice.AbstractOfficeDocument |
|---|
addCloseListener, close, dispatchCommand, dispatchCommand, dispatchCommand, dispatchCommand, dispose, exportAsHTMLString, exportAsString, exportFormat, exportHTML, exportPDF, exportToHTML, exportToPDF, formatText, formatText, formatText, formatText, getController, getDocumentProperties, getFile, getFont, getHtmlFormat, getPdfFormat, getXFrame, print, print, print, print, print, query, save, setComponentVisible, setEnableComponent, setEnableFrame, setFrameVisible, setPageOrientation, setPropertyValue, storeTo, storeTo, storeTo, storeTo, storeTo, undo, updateAll |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String MSWORD_FILTER
public static final String MSWORD_XML_FILTER
public static final String TEXT_FILTER
public static final String HTML_FILTER
public static final String PARAGRAPH_STYLE_KEY
AbstractOfficeDocument.setPropertyValue(Object, String, Object)
public static final String USER_FIELD_PREFIX
public static final char OPTIONAL_HYPHEN
public static final char NON_BREAKING_HYPHEN
public static final char NON_BREAKING_SPACE
| Constructor Detail |
|---|
public OOWriter()
throws OfficeException
OfficeException
public OOWriter(boolean hidden)
throws OfficeException
OfficeException
public OOWriter(File template)
throws OfficeException,
IOException
OfficeException
IOException
public OOWriter(File template,
boolean hidden)
throws OfficeException,
IOException
OfficeException
IOException
public OOWriter(File file,
Map<?,?> props)
throws OfficeException,
IOException
OfficeException
IOException
public OOWriter(URL url,
boolean hidden)
throws OfficeException,
IOException
OfficeException
IOException
public OOWriter(InputStream in,
boolean hidden)
throws OfficeException,
IOException
OfficeException
IOException
public OOWriter(InputStream in,
Map<?,?> props)
throws OfficeException,
IOException
OfficeException
IOException
public OOWriter(boolean previewMode,
File file)
throws OfficeException,
IOException
OfficeException
IOException
public OOWriter(boolean previewMode,
URL url)
throws OfficeException,
IOException
OfficeException
IOExceptionpublic OOWriter(com.sun.star.text.XTextDocument document)
public OOWriter(URL url,
Map<?,?> props)
throws OfficeException,
IOException
OfficeException
IOException
public OOWriter(com.sun.star.lang.XComponent comp)
throws OfficeException
OfficeException| Method Detail |
|---|
public static OOWriter getActiveDocument()
throws OfficeException
OfficeException
public static OOWriter open(File file)
throws OfficeException,
IOException
OfficeException
IOException
public static OOWriter open(File file,
boolean hidden)
throws OfficeException,
IOException
OfficeException
IOException
public static OOWriter openReadOnly(File file)
throws OfficeException,
IOException
OfficeException
IOException
public static OOWriter open(File file,
boolean readOnly,
boolean previewMode)
throws OfficeException,
IOException
OfficeException
IOException
public static File convertToPDF(File writerFile,
File pdfFile)
throws OfficeException,
IOException
OfficeException
IOExceptionpublic com.sun.star.text.XTextDocument getDocument()
public com.sun.star.lang.XComponent getXComponent()
getXComponent in interface OfficeDocumentpublic OODocType getDocumentType()
getDocumentType in interface OfficeDocument
public int getWordCount()
throws OfficeException
OfficeException
public int getCharacterCount()
throws OfficeException
OfficeException
public int getParagraphCount()
throws OfficeException
OfficeExceptionpublic int getNumberOfPages()
public int getPageNumber(com.sun.star.text.XTextViewCursor cursor)
public com.sun.star.text.XTextViewCursor getViewCursor()
public void setViewCursor(com.sun.star.text.XTextRange cursor)
public void insertPageBreakBefore(com.sun.star.text.XTextRange cursor)
throws OfficeException
OfficeException
public void insertPageBreakAfter(com.sun.star.text.XTextRange cursor)
throws OfficeException
OfficeException
public Iterator<com.sun.star.text.XTextCursor> iterate(String searchText,
boolean caseSensitive)
throws OfficeException
searchText - the text to be searched forcaseSensitive - determine whether the search is case-sensitive
OfficeExceptionfindFirst(String, boolean),
findNext(Object, String, boolean)
public com.sun.star.text.XTextCursor getCursorForText(String txt,
boolean caseSensitive)
throws OfficeException
OfficeException
public boolean gotoFirst(String searchText,
boolean caseSensitive)
throws OfficeException,
IllegalArgumentException
OfficeException
IllegalArgumentExceptionfindFirst(String, boolean)
public Object findFirst(String searchText,
boolean caseSensitive)
throws OfficeException,
IllegalArgumentException
findNext(Object, String, boolean)
and can be queried for XTextRange to obtain a cursor for further handling
IllegalArgumentException - if the given searchText was not found
OfficeExceptionfindNext(Object, String, boolean),
iterate(String, boolean)
public Object findNext(Object previousSearchResult,
String searchText,
boolean caseSensitive)
throws OfficeException,
IllegalArgumentException
previousSearchResult - obtained from the return value of either this method or gotoFirst(String, boolean)searchText - caseSensitive -
OfficeException
IllegalArgumentException - if the search text was not found anymoregotoFirst(String, boolean)
public com.sun.star.text.XTextViewCursor gotoBookmark(String bookmark)
throws OfficeException,
IllegalArgumentException
IllegalArgumentException - if the given bookmark is not found
OfficeExceptionpublic com.sun.star.text.XTextViewCursor gotoBegin()
public com.sun.star.text.XTextViewCursor gotoEnd()
public void alignParagraph(ParagraphAlignment alignment)
throws OfficeException
OfficeException
public void alignParagraph(com.sun.star.text.XTextRange cursor,
ParagraphAlignment alignment)
throws OfficeException
OfficeException
public void setBorder(Object obj,
CellBorder border)
throws OfficeException
OfficeException
public Font getFont()
throws OfficeException
OfficeException
public Font getFont(com.sun.star.text.XTextRange cursor)
throws OfficeException
OfficeException
public void formatText(CharacterFormat format)
throws OfficeException
OfficeException
public void formatText(com.sun.star.text.XTextRange cursor,
CharacterFormat format)
throws OfficeException
OfficeException
public void formatText(Color color)
throws OfficeException
OfficeException
public void formatText(com.sun.star.text.XTextRange cursor,
Color color)
throws OfficeException
OfficeException
public void formatTextBackground(Color color)
throws OfficeException
OfficeException
public void formatTextBackground(com.sun.star.text.XTextRange cursor,
Color color)
throws OfficeException
OfficeException
public void formatText(Underline ul)
throws OfficeException
OfficeException
public void formatText(com.sun.star.text.XTextRange cursor,
Underline ul)
throws OfficeException
OfficeException
public void formatText(Font font)
throws OfficeException
OfficeException
public void formatText(com.sun.star.text.XTextRange cursor,
Font font)
throws OfficeException
OfficeExceptionpublic com.sun.star.text.XTextViewCursor writeText(String text)
public <T extends com.sun.star.text.XTextRange> T writeText(String text,
T cursor)
XTextRange.getEnd() on the returned cursor.
To move to the beginning of the written selection, use XTextRange.getStart().
public void replaceAll(String search,
String replace)
public void insertBookmark(String bookmarkName,
com.sun.star.text.XTextRange range)
throws OfficeException,
IllegalArgumentException
OfficeException
IllegalArgumentException
public com.sun.star.text.XTextRange getBookmarkRange(String bookmark)
throws OfficeException
OfficeException
public com.sun.star.text.XTextCursor getBookmarkCursor(String bookmark)
throws OfficeException,
IllegalArgumentException
OfficeException
IllegalArgumentExceptionpublic boolean hasBookmark(String bookmark)
public String[] getBookmarks()
public String getBookmarkText(String bookmark)
throws OfficeException,
IllegalArgumentException
OfficeException
IllegalArgumentException
public void setBookmarkText(String bookmark,
String text)
throws OfficeException,
IllegalArgumentException
IllegalArgumentException - if the bookmark is unknown in this document
OfficeException
public void insertFileAt(File file,
com.sun.star.text.XTextRange cursor)
throws OfficeException,
IllegalArgumentException
OfficeException
IllegalArgumentException
public void insertUrlAt(URL url,
com.sun.star.text.XTextRange cursor)
throws OfficeException,
IllegalArgumentException
OfficeException
IllegalArgumentException
public void insertContent(Object content,
com.sun.star.text.XTextRange cursor)
throws OfficeException,
IOException
OfficeException
IOException
public void insertContent(String content,
com.sun.star.text.XTextRange cursor)
throws OfficeException,
IllegalArgumentException,
IOException
OfficeException
IllegalArgumentException
IOExceptioninsertContent(InputStream, XTextRange)
public void insertContent(InputStream in,
com.sun.star.text.XTextRange cursor)
throws OfficeException,
IllegalArgumentException,
IOException
OfficeException
IllegalArgumentException
IOExceptionpublic String[] getFieldNames()
public Object insertImage(File file,
com.sun.star.text.XTextRange cursor,
AnchorType at)
throws OfficeException
OfficeException
public Object insertImage(File file,
com.sun.star.text.XTextRange cursor,
AnchorType at,
Map<?,?> props)
throws OfficeException
OfficeException
public Object insertImage(URL url,
com.sun.star.text.XTextRange cursor,
AnchorType at,
Map<?,?> props)
throws OfficeException,
IllegalArgumentException
OfficeException
IllegalArgumentException
public Object insertImage(File file,
com.sun.star.text.XTextRange cursor,
AnchorType at,
boolean embed)
throws OfficeException,
MalformedURLException
OfficeException
MalformedURLException
public Object insertImage(File file,
com.sun.star.text.XTextRange cursor,
AnchorType at,
boolean embed,
Map<?,?> props)
throws OfficeException,
MalformedURLException
OfficeException
MalformedURLException
public Object insertImage(Image image,
com.sun.star.text.XTextRange cursor,
AnchorType at)
throws OfficeException,
IOException
OfficeException
IOException
public Object insertImage(Image image,
com.sun.star.text.XTextRange cursor,
AnchorType at,
Map<?,?> props)
throws OfficeException,
IOException
OfficeException
IOExceptionOfficeUtils.translateToMM(int)
public Object insertImage(URL url,
com.sun.star.text.XTextRange cursor,
AnchorType at,
boolean embed,
Map<?,?> props)
throws OfficeException
embed - if true, the image will be embedded into the document;
if false, the image will be linked to the documentprops - allows to specify additional properties; may be null
OfficeException
public Object insertImage(URL url,
com.sun.star.text.XTextRange cursor,
AnchorType at,
boolean embed,
Map<?,?> props,
String name)
throws OfficeException
embed - if true, the image will be embedded into the document;
if false, the image will be linked to the documentprops - allows to specify additional properties; may be nullname - explicitly sets the name of the given image (given a non-null value);
if null is given, a unique name will be assigned by the writer
OfficeException
public boolean isEmbeddedImage(String imageName)
throws OfficeException
OfficeException
public void deleteImage(String imageName)
throws IllegalArgumentException,
OfficeException
IllegalArgumentException
OfficeException
public Object getImageObject(String imageName)
throws OfficeException,
IllegalArgumentException
OfficeException
IllegalArgumentException
public BufferedImage getImage(String imageName)
throws OfficeException,
IOException,
IllegalArgumentException
OfficeException
IOException
IllegalArgumentExceptionpublic String[] getImageNames()
public String[] getUserFieldNames()
public Map<String,String> getUserFieldContent()
throws OfficeException
OfficeExceptionsetUserFieldContent(Map)
public String getFieldText(String fieldName)
throws OfficeException,
IllegalArgumentException
OfficeException
IllegalArgumentException
public String getUserFieldText(String userFieldName)
throws OfficeException,
IllegalArgumentException
OfficeException
IllegalArgumentException
public void setUserFieldText(String userFieldName,
String text)
throws OfficeException,
IllegalArgumentException
OfficeException
IllegalArgumentException
public void setFieldText(String fieldName,
String text)
throws OfficeException,
IllegalArgumentException
OfficeException
IllegalArgumentException
public void setUserFieldContent(Map<?,?> fields)
throws OfficeException
fields - maps field names to the content that is to be used for the key field name
OfficeExceptiongetUserFieldContent()public void refreshFields()
public List<com.sun.star.text.XTextFrame> getTextFrames()
throws OfficeException
OfficeException
public void setBackgroundColor(Color c)
throws OfficeException
OfficeException
public void setWatermark(File imageFile)
throws OfficeException,
MalformedURLException
MalformedURLException
OfficeException
public void setWatermark(File imageFile,
String pageStyle)
throws OfficeException,
MalformedURLException
OfficeException
MalformedURLException
public void setWatermark(URL url,
String pageStyle)
throws OfficeException
OfficeException
public void setWatermark(Image image)
throws OfficeException,
IOException
OfficeException
IOException
public void setWatermark(Image image,
String pageStyle)
throws OfficeException,
IOException
OfficeException
IOException
public String getClipboardAsString()
throws OfficeException
OfficeExceptionpublic OOWriter append(CharSequence csq)
append in interface Appendable
public OOWriter append(CharSequence csq,
int start,
int end)
throws IOException
append in interface AppendableIOException
public OOWriter append(char c)
throws IOException
append in interface AppendableIOException
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||