Holger's
Java API

com.antelmann.ooffice
Class OfficeUtils

java.lang.Object
  extended by com.antelmann.ooffice.OfficeUtils

@ThirdParty(value="uses OpenOffice.org libraries")
public class OfficeUtils
extends Object

general utilities for OpenOffice

Author:
Holger Antelmann

Nested Class Summary
static class OfficeUtils.TargetFrame
           
 
Field Summary
static int ALL
          search flag option
static int CHILDREN
          search flag option
static int CREATE
          search flag option
static int GLOBAL
          search flag option
static int PARENT
          search flag option
static int SELF
          search flag option
static int SIBLINGS
          search flag option
static int TASKS
          search flag option
 
Method Summary
static Properties asProperties(com.sun.star.beans.XPropertySet pset)
           
static void closeComponent(com.sun.star.lang.XComponent component)
          closes and disposes the document (attemting to setting it to unmodified before).
static void debugPrintSupportedTypes(Object obj)
          prints all the supported interfaces by query(Class, Object) for the given object
static void debugPrintXProperties(Object obj)
           
static LinkedList<Class<?>> findQueryPath(Object obj, Class<?> targetClass)
           
static com.sun.star.lang.XComponent getActiveComponent()
           
static int getColorNumber(Color c)
           
static com.sun.star.frame.XComponentLoader getComponentLoader()
           
static String getPrintXPropertiesAsString(Object obj)
           
static Properties getProperties(Object obj)
           
static String getStoreLocation(com.sun.star.lang.XComponent component)
           
static Class<?>[] getSupportedTypes(Object obj)
          returns all the supported interfaces by query(Class, Object) for the given object
static String[] getXPropertyKeys(Object obj)
           
static Object getXPropertyValue(Object obj, String key)
           
static boolean isEmbeddedURL(String unoURL)
           
static
<T> T
loadDocument(Class<T> type, File file, Map<?,?> props, OfficeUtils.TargetFrame target, int searchFlag)
           
static
<T> T
loadDocument(Class<T> type, InputStream in, Map<?,?> props, OfficeUtils.TargetFrame target, int searchFlag)
           
static
<T> T
loadDocument(Class<T> type, String unoUrl, Map<?,?> props, OfficeUtils.TargetFrame target, int searchFlag)
           
static
<T> T
loadDocument(Class<T> type, URL url, Map<?,?> props, OfficeUtils.TargetFrame target, int searchFlag)
           
static com.sun.star.beans.PropertyValue makePropertyValue(String key, Object value)
           
static com.sun.star.beans.PropertyValue[] makePropertyValues(Map<?,?> props)
           
static String makeURLString(File file)
          Deprecated. use translateUrlToUno(String) instead
static void printComponent(com.sun.star.lang.XComponent component, Map<?,?> printerProperties, Map<?,?> jobProperties)
           
static void printComponent(com.sun.star.lang.XComponent component, String printerName, Map<?,?> props)
           
static void printComponent(com.sun.star.lang.XComponent component, String printerName, String trayName, Map<?,?> props)
           
static
<T> T
query(Class<T> c, Object xObj)
          utility method to ease access to the query interface of OpenOffice
static void setXPropertyValue(Object obj, String key, Object value)
           
static void storeComponent(com.sun.star.lang.XComponent component)
           
static void storeComponent(com.sun.star.lang.XComponent component, OutputStream out, Map<?,?> props)
           
static void storeComponent(com.sun.star.lang.XComponent component, URL url, Map<?,?> props, boolean representNewLocation)
           
static Locale toLocale(com.sun.star.lang.Locale l)
           
static com.sun.star.lang.Locale toOfficeLocale(Locale locale)
           
static int translateToMM(int pixel)
          translates the given number of pixels into 100th mm value used by most office attribute values
static int translateToPixel(int mm)
          translates the given 100th mm value (used by most office attribute values) into the number of pixels
static String translateUnoToUrl(String unoUrl)
           
static String translateUrlToUno(String url)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARENT

public static final int PARENT
search flag option

See Also:
Constant Field Values

SELF

public static final int SELF
search flag option

See Also:
Constant Field Values

CHILDREN

public static final int CHILDREN
search flag option

See Also:
Constant Field Values

CREATE

public static final int CREATE
search flag option

See Also:
Constant Field Values

SIBLINGS

public static final int SIBLINGS
search flag option

See Also:
Constant Field Values

TASKS

public static final int TASKS
search flag option

See Also:
Constant Field Values

ALL

public static final int ALL
search flag option

See Also:
Constant Field Values

GLOBAL

public static final int GLOBAL
search flag option

See Also:
Constant Field Values
Method Detail

findQueryPath

public static LinkedList<Class<?>> findQueryPath(Object obj,
                                                 Class<?> targetClass)
                                          throws OfficeException
Throws:
OfficeException

query

public static <T> T query(Class<T> c,
                          Object xObj)
utility method to ease access to the query interface of OpenOffice


loadDocument

public static <T> T loadDocument(Class<T> type,
                                 File file,
                                 Map<?,?> props,
                                 OfficeUtils.TargetFrame target,
                                 int searchFlag)
                      throws OfficeException,
                             IOException
Throws:
OfficeException
IOException

makeURLString

@Deprecated
public static String makeURLString(File file)
Deprecated. use translateUrlToUno(String) instead


translateUrlToUno

public static String translateUrlToUno(String url)
                                throws OfficeException
Throws:
OfficeException

translateUnoToUrl

public static String translateUnoToUrl(String unoUrl)
                                throws OfficeException
Throws:
OfficeException

toOfficeLocale

public static com.sun.star.lang.Locale toOfficeLocale(Locale locale)

toLocale

public static Locale toLocale(com.sun.star.lang.Locale l)

loadDocument

public static <T> T loadDocument(Class<T> type,
                                 URL url,
                                 Map<?,?> props,
                                 OfficeUtils.TargetFrame target,
                                 int searchFlag)
                      throws OfficeException,
                             IOException,
                             IllegalArgumentException
Throws:
OfficeException
IOException
IllegalArgumentException

loadDocument

public static <T> T loadDocument(Class<T> type,
                                 InputStream in,
                                 Map<?,?> props,
                                 OfficeUtils.TargetFrame target,
                                 int searchFlag)
                      throws OfficeException,
                             IOException
Throws:
OfficeException
IOException

loadDocument

public static <T> T loadDocument(Class<T> type,
                                 String unoUrl,
                                 Map<?,?> props,
                                 OfficeUtils.TargetFrame target,
                                 int searchFlag)
                      throws OfficeException,
                             IOException,
                             IllegalArgumentException
Parameters:
unoUrl - must be given in the internal UNO form
Throws:
OfficeException
IOException
IllegalArgumentException
See Also:
translateUrlToUno(String)

getActiveComponent

public static com.sun.star.lang.XComponent getActiveComponent()
                                                       throws OfficeException
Throws:
OfficeException

getComponentLoader

public static com.sun.star.frame.XComponentLoader getComponentLoader()
                                                              throws OfficeException
Throws:
OfficeException

getStoreLocation

public static String getStoreLocation(com.sun.star.lang.XComponent component)

storeComponent

public static void storeComponent(com.sun.star.lang.XComponent component)
                           throws IOException,
                                  IllegalArgumentException
Throws:
IOException
IllegalArgumentException

storeComponent

public static void storeComponent(com.sun.star.lang.XComponent component,
                                  OutputStream out,
                                  Map<?,?> props)
                           throws IOException,
                                  OfficeException
Throws:
IOException
OfficeException

storeComponent

public static void storeComponent(com.sun.star.lang.XComponent component,
                                  URL url,
                                  Map<?,?> props,
                                  boolean representNewLocation)
                           throws IOException,
                                  OfficeException
Throws:
IOException
OfficeException

printComponent

public static void printComponent(com.sun.star.lang.XComponent component,
                                  String printerName,
                                  Map<?,?> props)
                           throws IllegalArgumentException
Throws:
IllegalArgumentException

printComponent

public static void printComponent(com.sun.star.lang.XComponent component,
                                  String printerName,
                                  String trayName,
                                  Map<?,?> props)
                           throws IllegalArgumentException
Throws:
IllegalArgumentException

printComponent

public static void printComponent(com.sun.star.lang.XComponent component,
                                  Map<?,?> printerProperties,
                                  Map<?,?> jobProperties)
                           throws IllegalArgumentException
Throws:
IllegalArgumentException

closeComponent

public static void closeComponent(com.sun.star.lang.XComponent component)
                           throws IOException
closes and disposes the document (attemting to setting it to unmodified before).

Throws:
IOException - (instead of others) so that implementing Closeable is easy for the given component

makePropertyValues

public static com.sun.star.beans.PropertyValue[] makePropertyValues(Map<?,?> props)

makePropertyValue

public static com.sun.star.beans.PropertyValue makePropertyValue(String key,
                                                                 Object value)

translateToMM

public static int translateToMM(int pixel)
translates the given number of pixels into 100th mm value used by most office attribute values


translateToPixel

public static int translateToPixel(int mm)
translates the given 100th mm value (used by most office attribute values) into the number of pixels


isEmbeddedURL

public static boolean isEmbeddedURL(String unoURL)

getColorNumber

public static int getColorNumber(Color c)

getProperties

public static Properties getProperties(Object obj)
                                throws OfficeException
Throws:
OfficeException

getXPropertyKeys

public static String[] getXPropertyKeys(Object obj)
                                 throws IllegalArgumentException
Throws:
IllegalArgumentException

setXPropertyValue

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

getXPropertyValue

public static Object getXPropertyValue(Object obj,
                                       String key)
                                throws OfficeException,
                                       IllegalArgumentException
Throws:
OfficeException
IllegalArgumentException

asProperties

@Todo(value="get rid of the com.sun.star.uno.RuntimeException since OpenOffice 3.1")
public static Properties asProperties(com.sun.star.beans.XPropertySet pset)
                               throws OfficeException
Throws:
OfficeException

getSupportedTypes

public static Class<?>[] getSupportedTypes(Object obj)
returns all the supported interfaces by query(Class, Object) for the given object


debugPrintXProperties

public static void debugPrintXProperties(Object obj)

getPrintXPropertiesAsString

public static String getPrintXPropertiesAsString(Object obj)

debugPrintSupportedTypes

public static void debugPrintSupportedTypes(Object obj)
prints all the supported interfaces by query(Class, Object) for the given object



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