org.geotools.openoffice
Class Formulas

java.lang.Object
  extended bycom.sun.star.lib.uno.helper.WeakBase
      extended byorg.geotools.openoffice.Formulas
All Implemented Interfaces:
com.sun.star.sheet.XAddIn, com.sun.star.uno.XInterface, com.sun.star.lang.XLocalizable, com.sun.star.lang.XServiceInfo, com.sun.star.lang.XServiceName, com.sun.star.lang.XTypeProvider, com.sun.star.uno.XWeak
Direct Known Subclasses:
Nature, Referencing

public abstract class Formulas
extends com.sun.star.lib.uno.helper.WeakBase
implements com.sun.star.sheet.XAddIn, com.sun.star.lang.XServiceName, com.sun.star.lang.XServiceInfo

Base class for methods to export as formulas in the OpenOffice spread sheet.

Since:
2.2
Version:
$Id: Formulas.java 17661 2006-01-18 07:55:11Z desruisseaux $
Author:
Martin Desruisseaux

Field Summary
protected static long DAY_TO_MILLIS
          Factor for conversions of days to milliseconds.
protected  java.util.Map methods
          Informations about exported methods.
 
Fields inherited from class com.sun.star.lib.uno.helper.WeakBase
_mapImplementationIds, _mapTypes
 
Fields inherited from interface com.sun.star.sheet.XAddIn
UNOTYPEINFO
 
Fields inherited from interface com.sun.star.lang.XServiceName
UNOTYPEINFO
 
Fields inherited from interface com.sun.star.lang.XServiceInfo
UNOTYPEINFO
 
Fields inherited from interface com.sun.star.uno.XWeak
UNOTYPEINFO
 
Fields inherited from interface com.sun.star.lang.XTypeProvider
UNOTYPEINFO
 
Constructor Summary
protected Formulas()
          Default constructor.
 
Method Summary
 java.lang.String getArgumentDescription(java.lang.String function, int argument)
          Returns the description of the specified argument.
 java.lang.String getDisplayArgumentName(java.lang.String function, int argument)
          Returns the user-visible name of the specified argument.
 java.lang.String getDisplayCategoryName(java.lang.String function)
          Returns the user-visible name of the category the function belongs to.
 java.lang.String getDisplayFunctionName(java.lang.String function)
          Returns the user-visible function name for an internal name.
protected  java.util.Date getEpoch(com.sun.star.beans.XPropertySet xOptions)
          Returns the spreadsheet epoch.
 java.lang.String getFunctionDescription(java.lang.String function)
          Returns the description of a function.
 java.lang.String getImplementationName()
          Provides the implementation name of the service implementation.
protected  java.util.Locale getJavaLocale()
          Returns the locale as an object from the Java standard SDK.
 com.sun.star.lang.Locale getLocale()
          Returns the locale, which is used by this object.
protected static java.lang.String getLocalizedMessage(java.lang.Throwable exception)
          Returns the localized message from the specified exception.
protected  java.util.logging.Logger getLogger()
          Returns the logger to use for logging warnings.
 java.lang.String getProgrammaticCategoryName(java.lang.String function)
          Returns the programmatic name of the category the function belongs to.
 java.lang.String getProgrammaticFuntionName(java.lang.String display)
          Returns the internal function name for an user-visible name.
abstract  java.lang.String getServiceName()
          The service name that can be used to create such an object by a factory.
protected  void reportException(java.lang.String method, java.lang.Throwable exception)
          Reports an exception.
 void setLocale(com.sun.star.lang.Locale locale)
          Sets the locale to be used by this object.
protected  void setTimeZone(java.lang.String timezone)
          Sets the timezone for time values to be provided to toDate(com.sun.star.beans.XPropertySet, double).
protected  java.util.Date toDate(com.sun.star.beans.XPropertySet xOptions, double time)
          Converts a date from a spreadsheet value to a Java Date object.
protected  double toDouble(com.sun.star.beans.XPropertySet xOptions, java.util.Date time)
          Converts a date from a Java Date object to a spreadsheet value.
 
Methods inherited from class com.sun.star.lib.uno.helper.WeakBase
finalize, getImplementationId, getTypes, queryAdapter
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.star.lang.XServiceInfo
getSupportedServiceNames, supportsService
 

Field Detail

DAY_TO_MILLIS

protected static final long DAY_TO_MILLIS
Factor for conversions of days to milliseconds. Used for date conversions as in toDate(com.sun.star.beans.XPropertySet, double).

See Also:
Constant Field Values

methods

protected final java.util.Map methods
Informations about exported methods.

Constructor Detail

Formulas

protected Formulas()
Default constructor. Subclass constructors need to add entries in the methods map.

Method Detail

setLocale

public void setLocale(com.sun.star.lang.Locale locale)
Sets the locale to be used by this object.

Specified by:
setLocale in interface com.sun.star.lang.XLocalizable

getLocale

public com.sun.star.lang.Locale getLocale()
Returns the locale, which is used by this object.

Specified by:
getLocale in interface com.sun.star.lang.XLocalizable

getJavaLocale

protected final java.util.Locale getJavaLocale()
Returns the locale as an object from the Java standard SDK.


getServiceName

public abstract java.lang.String getServiceName()
The service name that can be used to create such an object by a factory. This is defined as a field in the subclass with exactly the following signature:
private static final String __serviceName;

Specified by:
getServiceName in interface com.sun.star.lang.XServiceName

getImplementationName

public java.lang.String getImplementationName()
Provides the implementation name of the service implementation.

Specified by:
getImplementationName in interface com.sun.star.lang.XServiceInfo
Returns:
Unique name of the implementation.

getProgrammaticCategoryName

public java.lang.String getProgrammaticCategoryName(java.lang.String function)
Returns the programmatic name of the category the function belongs to. The category name is used to group similar functions together. The programmatic category name should always be in English, it is never shown to the user. It is usually one of the names listed in interface.

Specified by:
getProgrammaticCategoryName in interface com.sun.star.sheet.XAddIn
Parameters:
function - The exact name of a method within its interface.
Returns:
The category name the specified function belongs to.

getDisplayCategoryName

public java.lang.String getDisplayCategoryName(java.lang.String function)
Returns the user-visible name of the category the function belongs to. This is used when category names are shown to the user.

Specified by:
getDisplayCategoryName in interface com.sun.star.sheet.XAddIn
Parameters:
function - The exact name of a method within its interface.
Returns:
The user-visible category name the specified function belongs to.

getProgrammaticFuntionName

public java.lang.String getProgrammaticFuntionName(java.lang.String display)
Returns the internal function name for an user-visible name. The user-visible name of a function is the name shown to the user. It may be translated to the current language, so it is never stored in files. It should be a single word and is used when entering or displaying formulas.

Attention: The method name contains a spelling error. Due to compatibility reasons the name cannot be changed.

Specified by:
getProgrammaticFuntionName in interface com.sun.star.sheet.XAddIn
Parameters:
display - The user-visible name of a function.
Returns:
The exact name of the method within its interface.

getDisplayFunctionName

public java.lang.String getDisplayFunctionName(java.lang.String function)
Returns the user-visible function name for an internal name. The user-visible name of a function is the name shown to the user. It may be translated to the current language, so it is never stored in files. It should be a single word and is used when entering or displaying formulas.

Specified by:
getDisplayFunctionName in interface com.sun.star.sheet.XAddIn
Parameters:
function - The exact name of a method within its interface.
Returns:
The user-visible name of the specified function.

getFunctionDescription

public java.lang.String getFunctionDescription(java.lang.String function)
Returns the description of a function. The description is shown to the user when selecting functions. It may be translated to the current language.

Specified by:
getFunctionDescription in interface com.sun.star.sheet.XAddIn
Parameters:
function - The exact name of a method within its interface.
Returns:
The description of the specified function.

getDisplayArgumentName

public java.lang.String getDisplayArgumentName(java.lang.String function,
                                               int argument)
Returns the user-visible name of the specified argument. The argument name is shown to the user when prompting for arguments. It should be a single word and may be translated to the current language.

Specified by:
getDisplayArgumentName in interface com.sun.star.sheet.XAddIn
Parameters:
function - The exact name of a method within its interface.
argument - The index of the argument (0-based).
Returns:
The user-visible name of the specified argument.

getArgumentDescription

public java.lang.String getArgumentDescription(java.lang.String function,
                                               int argument)
Returns the description of the specified argument. The argument description is shown to the user when prompting for arguments. It may be translated to the current language.

Specified by:
getArgumentDescription in interface com.sun.star.sheet.XAddIn
Parameters:
function - The exact name of a method within its interface.
argument - The index of the argument (0-based).
Returns:
The description of the specified argument.

setTimeZone

protected void setTimeZone(java.lang.String timezone)
Sets the timezone for time values to be provided to toDate(com.sun.star.beans.XPropertySet, double). If this method is never invoked, then the default timezone is the locale one.


getEpoch

protected java.util.Date getEpoch(com.sun.star.beans.XPropertySet xOptions)
Returns the spreadsheet epoch. The timezone is the one specified during the last invocation of setTimeZone(java.lang.String). The epoch is used for date conversions as in toDate(com.sun.star.beans.XPropertySet, double).

Parameters:
xOptions - Provided by OpenOffice.
Returns:
The spreedsheet epoch, always as a new Java Date object.

toDate

protected java.util.Date toDate(com.sun.star.beans.XPropertySet xOptions,
                                double time)
Converts a date from a spreadsheet value to a Java Date object. The timezone is the one specified during the last invocation of setTimeZone(java.lang.String).

Parameters:
xOptions - Provided by OpenOffice.
time - The spreadsheet numerical value for a date, by default in the local timezone.
Returns:
The date as a Java object.

toDouble

protected double toDouble(com.sun.star.beans.XPropertySet xOptions,
                          java.util.Date time)
Converts a date from a Java Date object to a spreadsheet value. The timezone is the one specified during the last invocation of setTimeZone(java.lang.String).


getLocalizedMessage

protected static java.lang.String getLocalizedMessage(java.lang.Throwable exception)
Returns the localized message from the specified exception. If no message is available, returns a default string. This method never returns a null value.


reportException

protected void reportException(java.lang.String method,
                               java.lang.Throwable exception)
Reports an exception. This is used if an exception occured in a method which can't returns a String object. This method log the stack trace at the FINE level. We don't use the WARNING level since this is not a program disfunction; the failure is probably caused by wrong user-specified parameters.


getLogger

protected java.util.logging.Logger getLogger()
Returns the logger to use for logging warnings. The default implementation returns the org.geotools.openoffice logger. Subclasses should override this method if they want to use a different logger.



Copyright © GeoTools. All Rights Reserved.