public final class LocalOfficeUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static OfficeUrl[] |
buildOfficeUrls(int[] portNumbers,
java.lang.String[] pipeNames)
Builds an array of
OfficeUrl from an array of port numbers and an array of pipe names. |
static ProcessManager |
findBestProcessManager()
Find the best process manager that will be used to retrieve a process PID and to kill a process
by PID.
|
static java.io.File |
getDefaultOfficeHome()
Gets the default office home directory, which is auto-detected.
|
static java.io.File |
getOfficeExecutable(java.io.File officeHome)
Gets the office executable within an office installation.
|
static com.sun.star.beans.PropertyValue |
property(java.lang.String name,
java.lang.Object value)
Creates a
PropertyValue with the specified name and value. |
static void |
stopQuietly(org.jodconverter.office.OfficeManager manager)
Stops an
OfficeManager unconditionally. |
static com.sun.star.beans.PropertyValue[] |
toUnoProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
Converts a regular java map to an array of
PropertyValue , usable as arguments with UNO
interface types. |
static java.lang.String |
toUrl(java.io.File file)
Constructs an URL from the specified file as expected by office.
|
static void |
validateOfficeHome(java.io.File officeHome)
Validates that the specified File instance is a valid office home directory.
|
static void |
validateOfficeTemplateProfileDirectory(java.io.File templateProfileDir)
Validates that the specified File instance is a valid office template profile directory.
|
static void |
validateOfficeWorkingDirectory(java.io.File workingDir)
Validates that the specified File instance is a valid office working directory.
|
public static ProcessManager findBestProcessManager()
public static OfficeUrl[] buildOfficeUrls(int[] portNumbers, java.lang.String[] pipeNames)
OfficeUrl
from an array of port numbers and an array of pipe names.portNumbers
- The port numbers from which office URLs will be created, may be null.pipeNames
- The pipe names from which office URLs will be created, may be null.public static java.io.File getDefaultOfficeHome()
File
instance that is the directory where lives the first detected office
installation.public static java.io.File getOfficeExecutable(java.io.File officeHome)
officeHome
- The root (home) directory of the office installation.public static com.sun.star.beans.PropertyValue property(java.lang.String name, java.lang.Object value)
PropertyValue
with the specified name and value.name
- The property name.value
- The property value.PropertyValue
.public static void stopQuietly(org.jodconverter.office.OfficeManager manager)
OfficeManager
unconditionally.
Equivalent to OfficeManager.stop()
, except any exceptions will be ignored. This is
typically used in finally blocks.
Example code:
OfficeManager manager = null; try { manager = LocalOfficeManager().make(); manager.start(); // process manager } catch (Exception e) { // error handling } finally { OfficeUtils.stopQuietly(manager); }
manager
- the manager to stop, may be null or already stopped.public static com.sun.star.beans.PropertyValue[] toUnoProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
PropertyValue
, usable as arguments with UNO
interface types.properties
- The map to convert.PropertyValue
.public static java.lang.String toUrl(java.io.File file)
file
- The file for which an URL will be constructed.public static void validateOfficeHome(java.io.File officeHome)
officeHome
- The home to validate.java.lang.IllegalStateException
- If the specified directory if not a valid office home
directory.public static void validateOfficeTemplateProfileDirectory(java.io.File templateProfileDir)
templateProfileDir
- The directory to validate.java.lang.IllegalStateException
- If the specified directory if not a valid office template
profile directory.public static void validateOfficeWorkingDirectory(java.io.File workingDir)
workingDir
- The directory to validate.java.lang.IllegalStateException
- If the specified directory if not a valid office working
directory.