Holger's
Java API

com.antelmann.ooffice
Class OOWriter

java.lang.Object
  extended by com.antelmann.ooffice.AbstractOfficeDocument
      extended by com.antelmann.ooffice.OOWriter
All Implemented Interfaces:
OfficeDocument, QueryMechanism, Closeable, Appendable

public class OOWriter
extends AbstractOfficeDocument
implements Appendable

simplifies the handling of OpenOffice Writer documents This class implements ThirdParty for its use of OpenOffice libraries; see www.openoffice.org

Author:
Holger Antelmann
See Also:
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
<T extends com.sun.star.text.XTextRange>
T
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

MSWORD_FILTER

public static final String MSWORD_FILTER
See Also:
Constant Field Values

MSWORD_XML_FILTER

public static final String MSWORD_XML_FILTER
See Also:
Constant Field Values

TEXT_FILTER

public static final String TEXT_FILTER
See Also:
Constant Field Values

HTML_FILTER

public static final String HTML_FILTER
See Also:
Constant Field Values

PARAGRAPH_STYLE_KEY

public static final String PARAGRAPH_STYLE_KEY
allows to set a cursor to 'Heading 1' or the alike via AbstractOfficeDocument.setPropertyValue(Object, String, Object)

See Also:
Constant Field Values

USER_FIELD_PREFIX

public static final String USER_FIELD_PREFIX
See Also:
Constant Field Values

OPTIONAL_HYPHEN

public static final char OPTIONAL_HYPHEN
See Also:
Constant Field Values

NON_BREAKING_HYPHEN

public static final char NON_BREAKING_HYPHEN
See Also:
Constant Field Values

NON_BREAKING_SPACE

public static final char NON_BREAKING_SPACE
See Also:
Constant Field Values
Constructor Detail

OOWriter

public OOWriter()
         throws OfficeException
creates a blank new document

Throws:
OfficeException

OOWriter

public OOWriter(boolean hidden)
         throws OfficeException
Throws:
OfficeException

OOWriter

public OOWriter(File template)
         throws OfficeException,
                IOException
creates a new document based on the given template file

Throws:
OfficeException
IOException

OOWriter

public OOWriter(File template,
                boolean hidden)
         throws OfficeException,
                IOException
Throws:
OfficeException
IOException

OOWriter

public OOWriter(File file,
                Map<?,?> props)
         throws OfficeException,
                IOException
loads a document (the given file) into a blank frame along with the given properties

Throws:
OfficeException
IOException

OOWriter

public OOWriter(URL url,
                boolean hidden)
         throws OfficeException,
                IOException
Throws:
OfficeException
IOException

OOWriter

public OOWriter(InputStream in,
                boolean hidden)
         throws OfficeException,
                IOException
Throws:
OfficeException
IOException

OOWriter

public OOWriter(InputStream in,
                Map<?,?> props)
         throws OfficeException,
                IOException
Throws:
OfficeException
IOException

OOWriter

public OOWriter(boolean previewMode,
                File file)
         throws OfficeException,
                IOException
Throws:
OfficeException
IOException

OOWriter

public OOWriter(boolean previewMode,
                URL url)
         throws OfficeException,
                IOException
Throws:
OfficeException
IOException

OOWriter

public OOWriter(com.sun.star.text.XTextDocument document)

OOWriter

public OOWriter(URL url,
                Map<?,?> props)
         throws OfficeException,
                IOException
loads a document from the given url into a blank frame along with the given properties. To load the document as a template, put the property AsTemplate into the properties mapped to true.

Throws:
OfficeException
IOException

OOWriter

public OOWriter(com.sun.star.lang.XComponent comp)
         throws OfficeException
Throws:
OfficeException
Method Detail

getActiveDocument

public static OOWriter getActiveDocument()
                                  throws OfficeException
seeks the currently active document on the desktop (if any) and returns it

Throws:
OfficeException

open

public static OOWriter open(File file)
                     throws OfficeException,
                            IOException
opens a document for editing

Throws:
OfficeException
IOException

open

public static OOWriter open(File file,
                            boolean hidden)
                     throws OfficeException,
                            IOException
opens a document for editing

Throws:
OfficeException
IOException

openReadOnly

public static OOWriter openReadOnly(File file)
                             throws OfficeException,
                                    IOException
opens a document in read-only mode

Throws:
OfficeException
IOException

open

public static OOWriter open(File file,
                            boolean readOnly,
                            boolean previewMode)
                     throws OfficeException,
                            IOException
opens a document with the specified options

Throws:
OfficeException
IOException

convertToPDF

public static File convertToPDF(File writerFile,
                                File pdfFile)
                         throws OfficeException,
                                IOException
converts the file w/o showing the GUI (the returned file ensures a .pdf ending)

Throws:
OfficeException
IOException

getDocument

public com.sun.star.text.XTextDocument getDocument()

getXComponent

public com.sun.star.lang.XComponent getXComponent()
Specified by:
getXComponent in interface OfficeDocument

getDocumentType

public OODocType getDocumentType()
Specified by:
getDocumentType in interface OfficeDocument

getWordCount

public int getWordCount()
                 throws OfficeException
Throws:
OfficeException

getCharacterCount

public int getCharacterCount()
                      throws OfficeException
Throws:
OfficeException

getParagraphCount

public int getParagraphCount()
                      throws OfficeException
Throws:
OfficeException

getNumberOfPages

public int getNumberOfPages()
attention: this method call moves the visible cursor position to the last page


getPageNumber

public int getPageNumber(com.sun.star.text.XTextViewCursor cursor)
if the document was altered, this method is only reliable if the document is not hidden


getViewCursor

public com.sun.star.text.XTextViewCursor getViewCursor()
returns the XTextCursor that is currently visible in the document


setViewCursor

public void setViewCursor(com.sun.star.text.XTextRange cursor)

insertPageBreakBefore

public void insertPageBreakBefore(com.sun.star.text.XTextRange cursor)
                           throws OfficeException
inserts a page break before the current paragraph of the given cursor

Throws:
OfficeException

insertPageBreakAfter

public void insertPageBreakAfter(com.sun.star.text.XTextRange cursor)
                          throws OfficeException
inserts a page break after the current paragraph of the given cursor

Throws:
OfficeException

iterate

public Iterator<com.sun.star.text.XTextCursor> iterate(String searchText,
                                                       boolean caseSensitive)
                                                throws OfficeException
iterates over all occurrences of the given text and provides the corresponding cursors.

Parameters:
searchText - the text to be searched for
caseSensitive - determine whether the search is case-sensitive
Returns:
an iterator allowing to easily access all cursors for the text occurrences
Throws:
OfficeException
See Also:
findFirst(String, boolean), findNext(Object, String, boolean)

getCursorForText

public com.sun.star.text.XTextCursor getCursorForText(String txt,
                                                      boolean caseSensitive)
                                               throws OfficeException
Throws:
OfficeException

gotoFirst

public boolean gotoFirst(String searchText,
                         boolean caseSensitive)
                  throws OfficeException,
                         IllegalArgumentException
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.

Throws:
OfficeException
IllegalArgumentException
See Also:
findFirst(String, boolean)

findFirst

public Object findFirst(String searchText,
                        boolean caseSensitive)
                 throws OfficeException,
                        IllegalArgumentException
finds and returns an object that represents the search result based on the given text.

Returns:
an object that can be used as the previous search result with findNext(Object, String, boolean) and can be queried for XTextRange to obtain a cursor for further handling
Throws:
IllegalArgumentException - if the given searchText was not found
OfficeException
See Also:
findNext(Object, String, boolean), iterate(String, boolean)

findNext

public Object findNext(Object previousSearchResult,
                       String searchText,
                       boolean caseSensitive)
                throws OfficeException,
                       IllegalArgumentException
sets the view cursor to the next occurrence found for further handling (as a side-effect)

Parameters:
previousSearchResult - obtained from the return value of either this method or gotoFirst(String, boolean)
searchText -
caseSensitive -
Returns:
the search result that can be used for the next call to this method;
Throws:
OfficeException
IllegalArgumentException - if the search text was not found anymore
See Also:
gotoFirst(String, boolean)

gotoBookmark

public com.sun.star.text.XTextViewCursor gotoBookmark(String bookmark)
                                               throws OfficeException,
                                                      IllegalArgumentException
sets the view cursor to the given bookmark

Throws:
IllegalArgumentException - if the given bookmark is not found
OfficeException

gotoBegin

public com.sun.star.text.XTextViewCursor gotoBegin()
moves the view cursor to the begin of the document


gotoEnd

public com.sun.star.text.XTextViewCursor gotoEnd()
moves the view cursor to the end of its current range


alignParagraph

public void alignParagraph(ParagraphAlignment alignment)
                    throws OfficeException
uses the view cursor

Throws:
OfficeException

alignParagraph

public void alignParagraph(com.sun.star.text.XTextRange cursor,
                           ParagraphAlignment alignment)
                    throws OfficeException
Throws:
OfficeException

setBorder

public void setBorder(Object obj,
                      CellBorder border)
               throws OfficeException
Throws:
OfficeException

getFont

public Font getFont()
             throws OfficeException
Throws:
OfficeException

getFont

public Font getFont(com.sun.star.text.XTextRange cursor)
             throws OfficeException
Throws:
OfficeException

formatText

public void formatText(CharacterFormat format)
                throws OfficeException
uses the view cursor

Throws:
OfficeException

formatText

public void formatText(com.sun.star.text.XTextRange cursor,
                       CharacterFormat format)
                throws OfficeException
Throws:
OfficeException

formatText

public void formatText(Color color)
                throws OfficeException
uses the view cursor

Throws:
OfficeException

formatText

public void formatText(com.sun.star.text.XTextRange cursor,
                       Color color)
                throws OfficeException
Throws:
OfficeException

formatTextBackground

public void formatTextBackground(Color color)
                          throws OfficeException
uses the view cursor

Throws:
OfficeException

formatTextBackground

public void formatTextBackground(com.sun.star.text.XTextRange cursor,
                                 Color color)
                          throws OfficeException
Throws:
OfficeException

formatText

public void formatText(Underline ul)
                throws OfficeException
uses the view cursor

Throws:
OfficeException

formatText

public void formatText(com.sun.star.text.XTextRange cursor,
                       Underline ul)
                throws OfficeException
Throws:
OfficeException

formatText

public void formatText(Font font)
                throws OfficeException
Throws:
OfficeException

formatText

public void formatText(com.sun.star.text.XTextRange cursor,
                       Font font)
                throws OfficeException
Throws:
OfficeException

writeText

public com.sun.star.text.XTextViewCursor writeText(String text)
uses the view cursor


writeText

public <T extends com.sun.star.text.XTextRange> T writeText(String text,
                                                            T cursor)
overwrites the text at the given cursor position. The cursor is returned for further handling (the written text is still selected). To move the cursor to the end of the selection, use XTextRange.getEnd() on the returned cursor. To move to the beginning of the written selection, use XTextRange.getStart().


replaceAll

public void replaceAll(String search,
                       String replace)
performs a simple search/replace on the entire document


insertBookmark

public void insertBookmark(String bookmarkName,
                           com.sun.star.text.XTextRange range)
                    throws OfficeException,
                           IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

getBookmarkRange

public com.sun.star.text.XTextRange getBookmarkRange(String bookmark)
                                              throws OfficeException
may return null if the bookmark is not found

Throws:
OfficeException

getBookmarkCursor

public com.sun.star.text.XTextCursor getBookmarkCursor(String bookmark)
                                                throws OfficeException,
                                                       IllegalArgumentException
throws IllegalArgumentException if the bookmark is not found

Throws:
OfficeException
IllegalArgumentException

hasBookmark

public boolean hasBookmark(String bookmark)

getBookmarks

public String[] getBookmarks()

getBookmarkText

public String getBookmarkText(String bookmark)
                       throws OfficeException,
                              IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

setBookmarkText

public void setBookmarkText(String bookmark,
                            String text)
                     throws OfficeException,
                            IllegalArgumentException
sets the text of for a defined bookmark within the given document

Throws:
IllegalArgumentException - if the bookmark is unknown in this document
OfficeException

insertFileAt

public void insertFileAt(File file,
                         com.sun.star.text.XTextRange cursor)
                  throws OfficeException,
                         IllegalArgumentException
inserts one document into another

Throws:
OfficeException
IllegalArgumentException

insertUrlAt

public void insertUrlAt(URL url,
                        com.sun.star.text.XTextRange cursor)
                 throws OfficeException,
                        IllegalArgumentException
inserts one document into another

Throws:
OfficeException
IllegalArgumentException

insertContent

public void insertContent(Object content,
                          com.sun.star.text.XTextRange cursor)
                   throws OfficeException,
                          IOException
Throws:
OfficeException
IOException

insertContent

public void insertContent(String content,
                          com.sun.star.text.XTextRange cursor)
                   throws OfficeException,
                          IllegalArgumentException,
                          IOException
inserts the given content via ByteArrayInputStream

Throws:
OfficeException
IllegalArgumentException
IOException
See Also:
insertContent(InputStream, XTextRange)

insertContent

public void insertContent(InputStream in,
                          com.sun.star.text.XTextRange cursor)
                   throws OfficeException,
                          IllegalArgumentException,
                          IOException
inserts some content into the given location; for example, the content could represent HTML

Throws:
OfficeException
IllegalArgumentException
IOException

getFieldNames

public String[] getFieldNames()

insertImage

public Object insertImage(File file,
                          com.sun.star.text.XTextRange cursor,
                          AnchorType at)
                   throws OfficeException
Throws:
OfficeException

insertImage

public Object insertImage(File file,
                          com.sun.star.text.XTextRange cursor,
                          AnchorType at,
                          Map<?,?> props)
                   throws OfficeException
Throws:
OfficeException

insertImage

public Object insertImage(URL url,
                          com.sun.star.text.XTextRange cursor,
                          AnchorType at,
                          Map<?,?> props)
                   throws OfficeException,
                          IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

insertImage

public Object insertImage(File file,
                          com.sun.star.text.XTextRange cursor,
                          AnchorType at,
                          boolean embed)
                   throws OfficeException,
                          MalformedURLException
Throws:
OfficeException
MalformedURLException

insertImage

public Object insertImage(File file,
                          com.sun.star.text.XTextRange cursor,
                          AnchorType at,
                          boolean embed,
                          Map<?,?> props)
                   throws OfficeException,
                          MalformedURLException
Throws:
OfficeException
MalformedURLException

insertImage

public Object insertImage(Image image,
                          com.sun.star.text.XTextRange cursor,
                          AnchorType at)
                   throws OfficeException,
                          IOException
Throws:
OfficeException
IOException

insertImage

public Object insertImage(Image image,
                          com.sun.star.text.XTextRange cursor,
                          AnchorType at,
                          Map<?,?> props)
                   throws OfficeException,
                          IOException
automatically sets the Width and Height properties unless an explicit value was given

Throws:
OfficeException
IOException
See Also:
OfficeUtils.translateToMM(int)

insertImage

public Object insertImage(URL url,
                          com.sun.star.text.XTextRange cursor,
                          AnchorType at,
                          boolean embed,
                          Map<?,?> props)
                   throws OfficeException
allows to insert an image into the document. Note that when embedding is used, the properties Width and Height should be set manually

Parameters:
embed - if true, the image will be embedded into the document; if false, the image will be linked to the document
props - allows to specify additional properties; may be null
Returns:
the object representing the image
Throws:
OfficeException

insertImage

public Object insertImage(URL url,
                          com.sun.star.text.XTextRange cursor,
                          AnchorType at,
                          boolean embed,
                          Map<?,?> props,
                          String name)
                   throws OfficeException
allows to insert an image into the document. Note that when embedding is used, the properties Width and Height should be set manually

Parameters:
embed - if true, the image will be embedded into the document; if false, the image will be linked to the document
props - allows to specify additional properties; may be null
name - 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
Returns:
the object representing the image
Throws:
OfficeException

isEmbeddedImage

public boolean isEmbeddedImage(String imageName)
                        throws OfficeException
Throws:
OfficeException

deleteImage

public void deleteImage(String imageName)
                 throws IllegalArgumentException,
                        OfficeException
Throws:
IllegalArgumentException
OfficeException

getImageObject

public Object getImageObject(String imageName)
                      throws OfficeException,
                             IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

getImage

public BufferedImage getImage(String imageName)
                       throws OfficeException,
                              IOException,
                              IllegalArgumentException
Throws:
OfficeException
IOException
IllegalArgumentException

getImageNames

public String[] getImageNames()

getUserFieldNames

public String[] getUserFieldNames()

getUserFieldContent

public Map<String,String> getUserFieldContent()
                                       throws OfficeException
Throws:
OfficeException
See Also:
setUserFieldContent(Map)

getFieldText

public String getFieldText(String fieldName)
                    throws OfficeException,
                           IllegalArgumentException
the fully quantified field name is to be supplied

Throws:
OfficeException
IllegalArgumentException

getUserFieldText

public String getUserFieldText(String userFieldName)
                        throws OfficeException,
                               IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

setUserFieldText

public void setUserFieldText(String userFieldName,
                             String text)
                      throws OfficeException,
                             IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

setFieldText

public void setFieldText(String fieldName,
                         String text)
                  throws OfficeException,
                         IllegalArgumentException
the fully quantified field name is to be supplied

Throws:
OfficeException
IllegalArgumentException

setUserFieldContent

public void setUserFieldContent(Map<?,?> fields)
                         throws OfficeException
sets the field content of the field variables contained in the map. Non-existing fields will be ignored and all non-String values will be converted to a String.

Parameters:
fields - maps field names to the content that is to be used for the key field name
Throws:
OfficeException
See Also:
getUserFieldContent()

refreshFields

public void refreshFields()

getTextFrames

public List<com.sun.star.text.XTextFrame> getTextFrames()
                                                 throws OfficeException
provides convenience for sticker label printing

Throws:
OfficeException

setBackgroundColor

public void setBackgroundColor(Color c)
                        throws OfficeException
sets the background color for the standard page

Throws:
OfficeException

setWatermark

public void setWatermark(File imageFile)
                  throws OfficeException,
                         MalformedURLException
sets the watermark in the middle of the page for the 'Standard' page style

Throws:
MalformedURLException
OfficeException

setWatermark

public void setWatermark(File imageFile,
                         String pageStyle)
                  throws OfficeException,
                         MalformedURLException
Throws:
OfficeException
MalformedURLException

setWatermark

public void setWatermark(URL url,
                         String pageStyle)
                  throws OfficeException
Throws:
OfficeException

setWatermark

public void setWatermark(Image image)
                  throws OfficeException,
                         IOException
Throws:
OfficeException
IOException

setWatermark

public void setWatermark(Image image,
                         String pageStyle)
                  throws OfficeException,
                         IOException
Throws:
OfficeException
IOException

getClipboardAsString

public String getClipboardAsString()
                            throws OfficeException
retrieves the UTF text content from the office clipboard

Throws:
OfficeException

append

public OOWriter append(CharSequence csq)
Specified by:
append in interface Appendable

append

public OOWriter append(CharSequence csq,
                       int start,
                       int end)
                throws IOException
Specified by:
append in interface Appendable
Throws:
IOException

append

public OOWriter append(char c)
                throws IOException
Specified by:
append in interface Appendable
Throws:
IOException


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads