INTEGRATION: CWS sdksample (1.3.124); FILE MERGED
2004/06/30 09:10:29 jsc 1.3.124.1: #i29308# use of new UNO features
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ExampleAddIn.java,v $
|
||||
*
|
||||
* $Revision: 1.3 $
|
||||
* $Revision: 1.4 $
|
||||
*
|
||||
* last change: $Author: hr $ $Date: 2003-06-30 15:45:13 $
|
||||
* last change: $Author: rt $ $Date: 2005-01-31 16:54:08 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* the BSD license.
|
||||
@@ -51,13 +51,14 @@ class ExampleAddInResult implements com.sun.star.sheet.XVolatileResult
|
||||
|
||||
private com.sun.star.sheet.ResultEvent getResult()
|
||||
{
|
||||
com.sun.star.sheet.ResultEvent aEvent = new com.sun.star.sheet.ResultEvent();
|
||||
com.sun.star.sheet.ResultEvent aEvent =
|
||||
new com.sun.star.sheet.ResultEvent();
|
||||
aEvent.Value = aName + " " + String.valueOf( nValue );
|
||||
aEvent.Source = this;
|
||||
return aEvent;
|
||||
}
|
||||
|
||||
public void addResultListener( com.sun.star.sheet.XResultListener aListener )
|
||||
public void addResultListener(com.sun.star.sheet.XResultListener aListener)
|
||||
{
|
||||
aListeners.addElement( aListener );
|
||||
|
||||
@@ -65,7 +66,7 @@ class ExampleAddInResult implements com.sun.star.sheet.XVolatileResult
|
||||
aListener.modified( getResult() );
|
||||
}
|
||||
|
||||
public void removeResultListener( com.sun.star.sheet.XResultListener aListener )
|
||||
public void removeResultListener(com.sun.star.sheet.XResultListener aListener)
|
||||
{
|
||||
aListeners.removeElement( aListener );
|
||||
}
|
||||
@@ -77,7 +78,8 @@ class ExampleAddInResult implements com.sun.star.sheet.XVolatileResult
|
||||
|
||||
java.util.Enumeration aEnum = aListeners.elements();
|
||||
while (aEnum.hasMoreElements())
|
||||
((com.sun.star.sheet.XResultListener)aEnum.nextElement()).modified( aEvent );
|
||||
((com.sun.star.sheet.XResultListener)aEnum.nextElement()).modified(
|
||||
aEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,13 +114,13 @@ class ExampleAddInThread extends Thread
|
||||
|
||||
public class ExampleAddIn
|
||||
{
|
||||
static public class _ExampleAddIn extends com.sun.star.lib.uno.helper.WeakBase implements
|
||||
com.sun.star.sheet.addin.XExampleAddIn,
|
||||
com.sun.star.sheet.XAddIn,
|
||||
com.sun.star.lang.XServiceName,
|
||||
com.sun.star.lang.XServiceInfo
|
||||
static public class _ExampleAddIn extends com.sun.star.lib.uno.helper.WeakBase
|
||||
implements org.openoffice.sheet.addin.XExampleAddIn,
|
||||
com.sun.star.sheet.XAddIn,
|
||||
com.sun.star.lang.XServiceName,
|
||||
com.sun.star.lang.XServiceInfo
|
||||
{
|
||||
static private final String aExampleService = "com.sun.star.sheet.addin.ExampleAddIn";
|
||||
static private final String aExampleService = "org.openoffice.sheet.addin.ExampleAddIn";
|
||||
static private final String aAddInService = "com.sun.star.sheet.AddIn";
|
||||
static private final String aImplName = "ExampleAddIn";
|
||||
|
||||
@@ -162,7 +164,7 @@ public class ExampleAddIn
|
||||
private int getFunctionID( String aProgrammaticFunctionName )
|
||||
{
|
||||
for ( int i = 0; i < aFunctionNames.length; i++ )
|
||||
if ( aProgrammaticFunctionName.equals( aFunctionNames[ i ] ) )
|
||||
if ( aProgrammaticFunctionName.equals(aFunctionNames[i]) )
|
||||
return i;
|
||||
return FUNCTION_INVALID;
|
||||
}
|
||||
@@ -174,20 +176,21 @@ public class ExampleAddIn
|
||||
return nValue + 1;
|
||||
}
|
||||
|
||||
public com.sun.star.sheet.XVolatileResult getCounter( String aName )
|
||||
public com.sun.star.sheet.XVolatileResult getCounter(String aName)
|
||||
{
|
||||
if ( aResults == null )
|
||||
{
|
||||
// create the table of results, and start a thread to increment all counters
|
||||
// create the table of results, and start a thread to increment
|
||||
// all counters
|
||||
aResults = new java.util.Hashtable();
|
||||
ExampleAddInThread aThread = new ExampleAddInThread( aResults );
|
||||
aThread.start();
|
||||
}
|
||||
|
||||
ExampleAddInResult aResult = (ExampleAddInResult) aResults.get( aName );
|
||||
ExampleAddInResult aResult = (ExampleAddInResult) aResults.get(aName);
|
||||
if ( aResult == null )
|
||||
{
|
||||
aResult = new ExampleAddInResult( aName );
|
||||
aResult = new ExampleAddInResult(aName);
|
||||
aResults.put( aName, aResult );
|
||||
}
|
||||
return aResult;
|
||||
@@ -195,46 +198,52 @@ public class ExampleAddIn
|
||||
|
||||
// XAddIn
|
||||
|
||||
public String getProgrammaticFuntionName( String aDisplayName )
|
||||
public String getProgrammaticFuntionName(String aDisplayName)
|
||||
{
|
||||
for ( int i = 0; i < aFunctionNames.length; i++ )
|
||||
if ( aDisplayName.equals( aDisplayFunctionNames[ i ] ) )
|
||||
if ( aDisplayName.equals(aDisplayFunctionNames[i]) )
|
||||
return aFunctionNames[i];
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getDisplayFunctionName( String aProgrammaticName )
|
||||
public String getDisplayFunctionName(String aProgrammaticName)
|
||||
{
|
||||
int nFunction = getFunctionID( aProgrammaticName );
|
||||
return ( nFunction == FUNCTION_INVALID ) ? "" : aDisplayFunctionNames[nFunction];
|
||||
return ( nFunction == FUNCTION_INVALID ) ? "" :
|
||||
aDisplayFunctionNames[nFunction];
|
||||
}
|
||||
|
||||
public String getFunctionDescription( String aProgrammaticName )
|
||||
public String getFunctionDescription(String aProgrammaticName)
|
||||
{
|
||||
int nFunction = getFunctionID( aProgrammaticName );
|
||||
return ( nFunction == FUNCTION_INVALID ) ? "" : aDescriptions[nFunction];
|
||||
return ( nFunction == FUNCTION_INVALID ) ? "" :
|
||||
aDescriptions[nFunction];
|
||||
}
|
||||
|
||||
public String getDisplayArgumentName( String aProgrammaticFunctionName, int nArgument )
|
||||
public String getDisplayArgumentName(String aProgrammaticFunctionName,
|
||||
int nArgument)
|
||||
{
|
||||
// both functions in this example only have a first argument
|
||||
int nFunction = getFunctionID( aProgrammaticFunctionName );
|
||||
return ( nFunction == FUNCTION_INVALID || nArgument != 0) ? "" : aFirstArgumentNames[nFunction];
|
||||
return ( nFunction == FUNCTION_INVALID || nArgument != 0) ? "" :
|
||||
aFirstArgumentNames[nFunction];
|
||||
}
|
||||
|
||||
public String getArgumentDescription( String aProgrammaticFunctionName, int nArgument )
|
||||
public String getArgumentDescription(String aProgrammaticFunctionName,
|
||||
int nArgument )
|
||||
{
|
||||
// both functions in this example only have a first argument
|
||||
int nFunction = getFunctionID( aProgrammaticFunctionName );
|
||||
return ( nFunction == FUNCTION_INVALID || nArgument != 0) ? "" : aFirstArgumentDescriptions[nFunction];
|
||||
return ( nFunction == FUNCTION_INVALID || nArgument != 0) ? "" :
|
||||
aFirstArgumentDescriptions[nFunction];
|
||||
}
|
||||
|
||||
public String getProgrammaticCategoryName( String aProgrammaticFunctionName )
|
||||
public String getProgrammaticCategoryName(String aProgrammaticFunctionName)
|
||||
{
|
||||
return( "Add-In" );
|
||||
}
|
||||
|
||||
public String getDisplayCategoryName( String aProgrammaticFunctionName )
|
||||
public String getDisplayCategoryName(String aProgrammaticFunctionName)
|
||||
{
|
||||
return( "Add-In" );
|
||||
}
|
||||
@@ -243,7 +252,8 @@ public class ExampleAddIn
|
||||
|
||||
public void setLocale( com.sun.star.lang.Locale aLocale )
|
||||
{
|
||||
// the locale is stored and used for getLocale, but otherwise ignored in this example
|
||||
// the locale is stored and used for getLocale, but otherwise
|
||||
// ignored in this example
|
||||
aFuncLocale = aLocale;
|
||||
}
|
||||
|
||||
@@ -276,30 +286,35 @@ public class ExampleAddIn
|
||||
|
||||
public boolean supportsService( String aService )
|
||||
{
|
||||
return aService.equals( aExampleService ) || aService.equals( aAddInService );
|
||||
return (aService.equals( aExampleService ) ||
|
||||
aService.equals( aAddInService ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(String implName,
|
||||
com.sun.star.lang.XMultiServiceFactory multiFactory,
|
||||
com.sun.star.registry.XRegistryKey regKey)
|
||||
public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(
|
||||
String implName,
|
||||
com.sun.star.lang.XMultiServiceFactory multiFactory,
|
||||
com.sun.star.registry.XRegistryKey regKey)
|
||||
{
|
||||
com.sun.star.lang.XSingleServiceFactory xSingleServiceFactory = null;
|
||||
if ( implName.equals(_ExampleAddIn.aImplName) )
|
||||
xSingleServiceFactory = com.sun.star.comp.loader.FactoryHelper.getServiceFactory(
|
||||
_ExampleAddIn.class, _ExampleAddIn.aExampleService, multiFactory, regKey);
|
||||
xSingleServiceFactory =
|
||||
com.sun.star.comp.loader.FactoryHelper.getServiceFactory(
|
||||
_ExampleAddIn.class, _ExampleAddIn.aExampleService,
|
||||
multiFactory, regKey);
|
||||
return xSingleServiceFactory;
|
||||
}
|
||||
|
||||
public static boolean __writeRegistryServiceInfo(com.sun.star.registry.XRegistryKey regKey)
|
||||
public static boolean __writeRegistryServiceInfo(
|
||||
com.sun.star.registry.XRegistryKey regKey)
|
||||
{
|
||||
// register for both the base AddIn and the own service
|
||||
return com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo(
|
||||
_ExampleAddIn.aImplName, _ExampleAddIn.aExampleService, regKey )
|
||||
_ExampleAddIn.aImplName, _ExampleAddIn.aExampleService, regKey)
|
||||
&& com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo(
|
||||
_ExampleAddIn.aImplName, _ExampleAddIn.aAddInService, regKey );
|
||||
_ExampleAddIn.aImplName, _ExampleAddIn.aAddInService, regKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user