private XLinguServiceManager GetLinguSvcMgr ( XComponentContext xContext ) { try { XMultiComponentFactory xMCF = UnoRuntime . queryInterface ( XMultiComponentFactory . class , xContext . getServiceManager ( ) ) ; if ( xMCF == null ) { printText ( "XMultiComponentFactory == null" ) ; return null ; } // retrieve Office's remote component context as a property XPropertySet props = UnoRuntime . queryInterface ( XPropertySet . class , xMCF ) ; if ( props == null ) { printText ( "XPropertySet == null" ) ; return null ; } // initObject); Object defaultContext = props . getPropertyValue ( "DefaultContext" ) ; // get the remote interface XComponentContext XComponentContext xComponentContext = UnoRuntime . queryInterface ( XComponentContext . class , defaultContext ) ; if ( xComponentContext == null ) { printText ( "XComponentContext == null" ) ; return null ; } Object o = xMCF . createInstanceWithContext ( "com.sun.star.linguistic2.LinguServiceManager" , xComponentContext ) ; // create service component using the specified component context XLinguServiceManager mxLinguSvcMgr = UnoRuntime . queryInterface ( XLinguServiceManager . class , o ) ; if ( mxLinguSvcMgr == null ) { printText ( "XLinguServiceManager2 == null" ) ; return null ; } return mxLinguSvcMgr ; } catch ( Throwable t ) { // If anything goes wrong, give the user a stack trace printMessage ( t ) ; } return null ; }
Get the LinguServiceManager to be used for example to access spell checker thesaurus and hyphenator