Holger's
Java API

com.antelmann.ooffice
Class AbstractOfficeDocument

java.lang.Object
  extended by com.antelmann.ooffice.AbstractOfficeDocument
All Implemented Interfaces:
OfficeDocument, QueryMechanism, Closeable
Direct Known Subclasses:
OOCalc, OODraw, OOWriter

@ThirdParty(value="uses OpenOffice.org libraries")
public abstract class AbstractOfficeDocument
extends Object
implements OfficeDocument

the base class for all OpenOffice document frames

Since:
26.06.2008, 16:10:11
Author:
Holger Antelmann

Constructor Summary
AbstractOfficeDocument()
           
 
Method Summary
 void addCloseListener(Runnable task)
          allows to easily register a task that is to be executed when this frame is disposed
 void close()
          closes and disposes the document
 Object dispatchCommand(String command)
           
 Object dispatchCommand(String command, Map<?,?> props)
           
 Object dispatchCommand(String command, OfficeUtils.TargetFrame targetFrame, Map<?,?> props)
           
 Object dispatchCommand(String command, String targetFrame, Map<?,?> props)
          allows to dispatch a UNO command on the document.
 void dispose()
          disposes the document (cutting the connection to it rather than closing the window)
 String exportAsHTMLString()
           
 String exportAsString()
           
 byte[] exportFormat(String format)
           
 byte[] exportHTML()
           
 byte[] exportPDF()
           
 void exportToHTML(File file)
          deletes the target file (the name extension will be pdf) if it exists
 File exportToPDF(File file)
          deletes the target file (the name extension will be pdf) if it exists
 void formatText(Object obj, Color color)
           
 void formatText(Object obj, float size)
           
 void formatText(Object obj, Font font)
           
 void formatText(Object obj, Underline ul)
           
 com.sun.star.frame.XController getController()
           
 Properties getDocumentProperties()
           
 File getFile()
          if this frame is associated with a store location, this method returns it as a file or null if no location is present (e.g. if the document has not been saved yet)
 Font getFont(Object obj)
           
protected  String getHtmlFormat()
           
 String getPdfFormat()
           
 com.sun.star.frame.XFrame getXFrame()
           
 void print()
           
 void print(Map<?,?> printerProperties, Map<?,?> jobProperties)
           
 void print(String printerName)
           
 void print(String printerName, int count)
           
 void print(String printerName, String trayName, int count)
           
<T> T
query(Class<T> requiredReturnType, Object context)
          delegates to OfficeUtils.query(Class, Object)
 void save()
           
 void setComponentVisible(boolean flag)
          sets the component within the frame visible/invisible
 void setEnableComponent(boolean flag)
          enables/disables the component (the top frame remains untouched)
 void setEnableFrame(boolean flag)
          enables/disables the frame
 void setFrameVisible(boolean flag)
          sets the entire window visible/invisible
 void setPageOrientation(PageOrientation po)
           
static void setPropertyValue(Object obj, String key, Object value)
           
 File storeTo(File file, boolean representNewLocation)
          saves the embedded document to the given file - using the default extension, if not already given (and overwriting the file, if it exists)
 void storeTo(File file, String filterName, boolean representNewLocation)
          saves the given document to the given file (overwriting it, if it exists) in the given format
 void storeTo(OutputStream out, Map<?,?> props)
           
 void storeTo(URL url, boolean representNewLocation)
          saves the given document to the given url (overwriting the url if it exists)
 void storeTo(URL url, String filterName, boolean representNewLocation)
          allows to specify a filterName that defines the output format (null is allowed).
 void undo()
           
 void updateAll()
          updates all embedded objects within the document
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.antelmann.ooffice.OfficeDocument
getDocumentType, getXComponent
 

Constructor Detail

AbstractOfficeDocument

public AbstractOfficeDocument()
Method Detail

close

public void close()
           throws IOException
closes and disposes the document

Specified by:
close in interface Closeable
Throws:
IOException

query

public <T> T query(Class<T> requiredReturnType,
                   Object context)
delegates to OfficeUtils.query(Class, Object)

Specified by:
query in interface QueryMechanism
Type Parameters:
T - the required return type
Parameters:
requiredReturnType - specifies the return type that is needed for this operation; if Object.class is given, any returned object is admissible
context - provides a context parameter for which the desired instance is to be returned. Often (if no other meaningful context is required or applicable), it makes sense to pass a reference to the calling object source; null may also be allowed
Returns:
an instance of the required return type that matches the given context; null may be returned if no instance is available for the given context

addCloseListener

public void addCloseListener(Runnable task)
Description copied from interface: OfficeDocument
allows to easily register a task that is to be executed when this frame is disposed

Specified by:
addCloseListener in interface OfficeDocument

setComponentVisible

public void setComponentVisible(boolean flag)
sets the component within the frame visible/invisible


setFrameVisible

public void setFrameVisible(boolean flag)
sets the entire window visible/invisible


setEnableComponent

public void setEnableComponent(boolean flag)
enables/disables the component (the top frame remains untouched)


setEnableFrame

public void setEnableFrame(boolean flag)
enables/disables the frame


storeTo

public File storeTo(File file,
                    boolean representNewLocation)
             throws IOException,
                    OfficeException
saves the embedded document to the given file - using the default extension, if not already given (and overwriting the file, if it exists)

Throws:
IOException
OfficeException

storeTo

public void storeTo(OutputStream out,
                    Map<?,?> props)
             throws IOException,
                    OfficeException
Specified by:
storeTo in interface OfficeDocument
Throws:
IOException
OfficeException

storeTo

public void storeTo(File file,
                    String filterName,
                    boolean representNewLocation)
             throws IOException,
                    OfficeException
saves the given document to the given file (overwriting it, if it exists) in the given format

Throws:
IOException
OfficeException

storeTo

public void storeTo(URL url,
                    boolean representNewLocation)
             throws IOException,
                    OfficeException
saves the given document to the given url (overwriting the url if it exists)

Throws:
IOException
OfficeException

getFile

public File getFile()
if this frame is associated with a store location, this method returns it as a file or null if no location is present (e.g. if the document has not been saved yet)

Specified by:
getFile in interface OfficeDocument

print

public void print()
           throws OfficeException
Throws:
OfficeException

print

public void print(String printerName)
           throws IllegalArgumentException
Specified by:
print in interface OfficeDocument
Throws:
IllegalArgumentException

print

public void print(String printerName,
                  int count)
           throws IllegalArgumentException
Specified by:
print in interface OfficeDocument
Throws:
IllegalArgumentException

print

public void print(String printerName,
                  String trayName,
                  int count)
           throws IllegalArgumentException
Throws:
IllegalArgumentException

print

public void print(Map<?,?> printerProperties,
                  Map<?,?> jobProperties)
           throws IllegalArgumentException
Specified by:
print in interface OfficeDocument
Throws:
IllegalArgumentException

getDocumentProperties

public Properties getDocumentProperties()
                                 throws OfficeException
Throws:
OfficeException

dispose

public void dispose()
Description copied from interface: OfficeDocument
disposes the document (cutting the connection to it rather than closing the window)

Specified by:
dispose in interface OfficeDocument

exportToPDF

public File exportToPDF(File file)
                 throws OfficeException,
                        IOException
deletes the target file (the name extension will be pdf) if it exists

Specified by:
exportToPDF in interface OfficeDocument
Throws:
OfficeException
IOException

getPdfFormat

public String getPdfFormat()

exportPDF

public byte[] exportPDF()
                 throws OfficeException,
                        IOException
Throws:
OfficeException
IOException

exportFormat

public byte[] exportFormat(String format)
                    throws OfficeException,
                           IOException
Throws:
OfficeException
IOException

getHtmlFormat

protected String getHtmlFormat()

exportHTML

public byte[] exportHTML()
                  throws OfficeException,
                         IOException
Throws:
OfficeException
IOException

exportToHTML

public void exportToHTML(File file)
                  throws OfficeException,
                         IOException
deletes the target file (the name extension will be pdf) if it exists

Throws:
OfficeException
IOException

exportAsHTMLString

public String exportAsHTMLString()
                          throws IOException,
                                 OfficeException
Throws:
IOException
OfficeException

exportAsString

public String exportAsString()
                      throws IOException,
                             OfficeException
Throws:
IOException
OfficeException

storeTo

public void storeTo(URL url,
                    String filterName,
                    boolean representNewLocation)
             throws IOException,
                    OfficeException
allows to specify a filterName that defines the output format (null is allowed). Known filterNames for writer documents (for representNewLocation = true) include: if representNewLocation is false (i.e. we are talking about an export w/o editing the document hereafter), the following entries are valid for writer documents, too: Known filterNames for calc include: Note that some filters may not work for representNewLocation = true.

Specified by:
storeTo in interface OfficeDocument
Throws:
IOException
OfficeException

setPageOrientation

public void setPageOrientation(PageOrientation po)

dispatchCommand

public Object dispatchCommand(String command)
                       throws OfficeException
Throws:
OfficeException

dispatchCommand

public Object dispatchCommand(String command,
                              Map<?,?> props)
                       throws OfficeException
Throws:
OfficeException

dispatchCommand

public Object dispatchCommand(String command,
                              OfficeUtils.TargetFrame targetFrame,
                              Map<?,?> props)
                       throws OfficeException
Throws:
OfficeException

getFont

public Font getFont(Object obj)
             throws OfficeException
Throws:
OfficeException

formatText

public void formatText(Object obj,
                       Color color)
                throws OfficeException
Throws:
OfficeException

formatText

public void formatText(Object obj,
                       Underline ul)
                throws OfficeException
Throws:
OfficeException

formatText

public void formatText(Object obj,
                       Font font)
                throws OfficeException
Throws:
OfficeException

formatText

public void formatText(Object obj,
                       float size)
                throws OfficeException
Throws:
OfficeException

setPropertyValue

public static void setPropertyValue(Object obj,
                                    String key,
                                    Object value)
                             throws IllegalArgumentException,
                                    OfficeException
Throws:
IllegalArgumentException
OfficeException

getController

public com.sun.star.frame.XController getController()

getXFrame

public com.sun.star.frame.XFrame getXFrame()

dispatchCommand

public Object dispatchCommand(String command,
                              String targetFrame,
                              Map<?,?> props)
                       throws OfficeException
allows to dispatch a UNO command on the document. See OpenOffice.org 3.x Commands on Apache Wiki; there's also a spreadsheet at http://arielch.fedorapeople.org/devel/ooo/UICommands.ods

Specified by:
dispatchCommand in interface OfficeDocument
Parameters:
command - the command to be dispatched
targetFrame - the frame to which the command is to be applied
props - allows to specify additional properties to the command
Returns:
the object returned by the office helper which actually dispatches the command
Throws:
OfficeException

updateAll

public void updateAll()
               throws OfficeException
updates all embedded objects within the document

Throws:
OfficeException

undo

public void undo()
          throws OfficeException
Throws:
OfficeException

save

public void save()
          throws OfficeException
Throws:
OfficeException


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