org.geotools.openoffice
Class Formulas

Object
  extended by WeakBase
      extended by Formulas
All Implemented Interfaces:
XLocalizable, XServiceInfo, XServiceName, XTypeProvider, XAddIn, XInterface, XWeak
Direct Known Subclasses:
Nature, Referencing

public abstract class Formulas
extends WeakBase
implements XAddIn, XServiceName, XServiceInfo

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

Since:
2.2
Author:
Martin Desruisseaux (IRD)
Module:

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

Specified by:
setLocale in interface XLocalizable

getLocale

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

Specified by:
getLocale in interface XLocalizable

getJavaLocale

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


getServiceName

public abstract 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 XServiceName

getImplementationName

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

Specified by:
getImplementationName in interface XServiceInfo
Returns:
Unique name of the implementation.

getProgrammaticCategoryName

public String getProgrammaticCategoryName(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 com.sun.star.sheet.XAddIn interface.

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

getDisplayCategoryName

public String getDisplayCategoryName(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 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 String getProgrammaticFuntionName(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 XAddIn
Parameters:
display - The user-visible name of a function.
Returns:
The exact name of the method within its interface.

getDisplayFunctionName

public String getDisplayFunctionName(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 XAddIn
Parameters:
function - The exact name of a method within its interface.
Returns:
The user-visible name of the specified function.

getFunctionDescription

public String getFunctionDescription(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 XAddIn
Parameters:
function - The exact name of a method within its interface.
Returns:
The description of the specified function.

getDisplayArgumentName

public String getDisplayArgumentName(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 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 String getArgumentDescription(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 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(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 Date getEpoch(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 Date toDate(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(XPropertySet xOptions,
                          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 String getLocalizedMessage(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.


getFailure

protected static double[][] getFailure(int rows,
                                       int cols)
Returns a table filled with NaN values. This method is invoked when an operation failed for a whole table.

Since:
2.3

reportException

protected void reportException(String method,
                               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 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 © 1996-2009 Geotools. All Rights Reserved.