diff options
Diffstat (limited to 'odk/examples/DevelopersGuide/OfficeDev')
4 files changed, 38 insertions, 57 deletions
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java index 2a33ecb4d6cf..63c27185c4e6 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java @@ -32,11 +32,11 @@ * *************************************************************************/ -import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.lang.XSingleComponentFactory; import com.sun.star.lang.XServiceInfo; import com.sun.star.lang.XInitialization; -import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.beans.XPropertySet; +import com.sun.star.uno.XComponentContext; import com.sun.star.uno.XInterface; import com.sun.star.uno.UnoRuntime; @@ -49,32 +49,29 @@ import java.lang.reflect.Constructor; public class OneInstanceFactory implements - XSingleServiceFactory, + XSingleComponentFactory, XServiceInfo { Class aMyClass; String aSvcImplName; String[] aSupportedSvcNames; XInterface xInstantiatedService; - XMultiServiceFactory xMultiFactory; public OneInstanceFactory( Class aMyClass, String aSvcImplName, - String[] aSupportedSvcNames, - XMultiServiceFactory xMultiFactory ) + String[] aSupportedSvcNames ) { this.aMyClass = aMyClass; this.aSvcImplName = aSvcImplName; this.aSupportedSvcNames = aSupportedSvcNames; - this.xMultiFactory = xMultiFactory; xInstantiatedService = null; } - // XSingleServiceFactory + // XSingleComponentFactory - public Object createInstance() + public Object createInstanceWithContext( XComponentContext context ) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException { @@ -91,15 +88,17 @@ public class OneInstanceFactory implements //!! workaround for services not always being created //!! via 'createInstanceWithArguments' XInitialization xIni = UnoRuntime.queryInterface( - XInitialization.class, createInstance()); + XInitialization.class, createInstanceWithContext(context)); if (xIni != null) { Object[] aArguments = new Object[]{ null, null }; - if (xMultiFactory != null) + if (context != null) { XPropertySet xPropSet = UnoRuntime.queryInterface( - XPropertySet.class , xMultiFactory.createInstance( - "com.sun.star.linguistic2.LinguProperties" ) ); + XPropertySet.class, + context.getServiceManager().createInstanceWithContext( + "com.sun.star.linguistic2.LinguProperties", + context ) ); aArguments[0] = xPropSet; } xIni.initialize( aArguments ); @@ -108,14 +107,14 @@ public class OneInstanceFactory implements return xInstantiatedService; } - public Object createInstanceWithArguments( Object[] aArguments ) + public Object createInstanceWithArgumentsAndContext( Object[] aArguments, XComponentContext context ) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException { if (xInstantiatedService == null) { XInitialization xIni = UnoRuntime.queryInterface( - XInitialization.class, createInstance()); + XInitialization.class, createInstanceWithContext( context )); if (xIni != null) xIni.initialize( aArguments ); } diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java index ffa8358227cd..f74c5a7d8884 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java @@ -37,8 +37,7 @@ import com.sun.star.lib.uno.helper.ComponentBase; import com.sun.star.uno.UnoRuntime; // factories -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.lang.XSingleComponentFactory; // supported Interfaces import com.sun.star.linguistic2.XHyphenator; @@ -493,26 +492,21 @@ public class SampleHyphenator extends ComponentBase implements * Returns a factory for creating the service. * This method is called by the <code>JavaLoader</code> * <p> - * @return returns a <code>XSingleServiceFactory</code> for creating the component + * @return returns a <code>XComponentServiceFactory</code> for creating the component * @param implName the name of the implementation for which a service is desired - * @param multiFactory the service manager to be used if needed - * @param regKey the registryKey * @see com.sun.star.comp.loader.JavaLoader */ - public static XSingleServiceFactory __getServiceFactory( - String aImplName, - XMultiServiceFactory xMultiFactory, - com.sun.star.registry.XRegistryKey xRegKey ) + public static XSingleComponentFactory __getComponentFactory( + String aImplName ) { - XSingleServiceFactory xSingleServiceFactory = null; + XSingleComponentFactory xSingleComponentFactory = null; if( aImplName.equals( _aSvcImplName ) ) { - xSingleServiceFactory = new OneInstanceFactory( + xSingleComponentFactory = new OneInstanceFactory( SampleHyphenator.class, _aSvcImplName, - getSupportedServiceNames_Static(), - xMultiFactory ); + getSupportedServiceNames_Static() ); } - return xSingleServiceFactory; + return xSingleComponentFactory; } /** diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java index 00fbab8365d9..7887fa06af30 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java @@ -37,8 +37,7 @@ import com.sun.star.lib.uno.helper.ComponentBase; import com.sun.star.uno.UnoRuntime; // factories -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.lang.XSingleComponentFactory; // supported Interfaces import com.sun.star.linguistic2.XSpellChecker; @@ -436,26 +435,21 @@ public class SampleSpellChecker extends ComponentBase implements * Returns a factory for creating the service. * This method is called by the <code>JavaLoader</code> * <p> - * @return returns a <code>XSingleServiceFactory</code> for creating the component + * @return returns a <code>XSingleComponentFactory</code> for creating the component * @param implName the name of the implementation for which a service is desired - * @param multiFactory the service manager to be used if needed - * @param regKey the registryKey * @see com.sun.star.comp.loader.JavaLoader */ - public static XSingleServiceFactory __getServiceFactory( - String aImplName, - XMultiServiceFactory xMultiFactory, - com.sun.star.registry.XRegistryKey xRegKey ) + public static XSingleComponentFactory __getComponentFactory( + String aImplName ) { - XSingleServiceFactory xSingleServiceFactory = null; + XSingleComponentFactory xSingleComponentFactory = null; if( aImplName.equals( _aSvcImplName ) ) { - xSingleServiceFactory = new OneInstanceFactory( + xSingleComponentFactory = new OneInstanceFactory( SampleSpellChecker.class, _aSvcImplName, - getSupportedServiceNames_Static(), - xMultiFactory ); + getSupportedServiceNames_Static() ); } - return xSingleServiceFactory; + return xSingleComponentFactory; } /** diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java index ee0295393da0..5feb49bd3e99 100644 --- a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java +++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java @@ -37,8 +37,7 @@ import com.sun.star.lib.uno.helper.ComponentBase; import com.sun.star.uno.UnoRuntime; // factories -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.lang.XSingleComponentFactory; // supported Interfaces import com.sun.star.linguistic2.XThesaurus; @@ -272,26 +271,21 @@ public class SampleThesaurus extends ComponentBase implements * Returns a factory for creating the service. * This method is called by the <code>JavaLoader</code> * <p> - * @return returns a <code>XSingleServiceFactory</code> for creating the component + * @return returns a <code>XSingleComponentFactory</code> for creating the component * @param implName the name of the implementation for which a service is desired - * @param multiFactory the service manager to be used if needed - * @param regKey the registryKey * @see com.sun.star.comp.loader.JavaLoader */ - public static XSingleServiceFactory __getServiceFactory( - String aImplName, - XMultiServiceFactory xMultiFactory, - com.sun.star.registry.XRegistryKey xRegKey ) + public static XSingleComponentFactory __getComponentFactory( + String aImplName ) { - XSingleServiceFactory xSingleServiceFactory = null; + XSingleComponentFactory xSingleComponentFactory = null; if( aImplName.equals( _aSvcImplName ) ) { - xSingleServiceFactory = new OneInstanceFactory( + xSingleComponentFactory = new OneInstanceFactory( SampleThesaurus.class, _aSvcImplName, - getSupportedServiceNames_Static(), - xMultiFactory ); + getSupportedServiceNames_Static() ); } - return xSingleServiceFactory; + return xSingleComponentFactory; } /** |