diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2006-08-01 15:32:12 +0000 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2006-08-01 15:32:12 +0000 |
commit | 5803a0ae6913ca0603c2890244f86b89e60b9792 (patch) | |
tree | d8e5f5330bea38a95830083dc149c0086e37cc13 /odk/examples/DevelopersGuide/Components/CppComponent | |
parent | 5bfddfe6a3e8ca1a69e4bf248ff65c6427de6eef (diff) |
INTEGRATION: CWS jsc12 (1.5.28); FILE MERGED
2006/07/14 15:11:57 jsc 1.5.28.1: #i67376# adapt example code
Diffstat (limited to 'odk/examples/DevelopersGuide/Components/CppComponent')
-rw-r--r-- | odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx b/odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx index 23003f0f2ea7..e60eac75a150 100644 --- a/odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx +++ b/odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: service1_impl.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: vg $ $Date: 2006-03-15 09:25:20 $ + * last change: $Author: ihi $ $Date: 2006-08-01 16:32:12 $ * * The Contents of this file are made available subject to the terms of * the BSD license. @@ -76,11 +76,17 @@ class MyService1Impl { oslInterlockedCount m_refcount; OUString m_sData; + // it's good practise to store the context for further use when you use + // other UNO API's in your implementation + Reference< XComponentContext > m_xContext; public: - inline MyService1Impl() throw () - : m_refcount( 0 ) + inline MyService1Impl(Reference< XComponentContext > const & xContext) throw () + : m_refcount( 0 ), + m_xContext(xContext) {} + virtual ~MyService1Impl() {} + // XInterface virtual Any SAL_CALL queryInterface( Type const & type ) throw (RuntimeException); @@ -234,18 +240,18 @@ Reference< XInterface > SAL_CALL create_MyService1Impl( Reference< XComponentContext > const & xContext ) SAL_THROW( () ) { - return static_cast< lang::XTypeProvider * >( new MyService1Impl() ); + return static_cast< lang::XTypeProvider * >( new MyService1Impl( xContext) ); } // forward decl: implemented in service2_impl.cxx Reference< XInterface > SAL_CALL create_MyService2Impl( - Reference< XComponentContext > const & xContext ) SAL_THROW( () ); + Reference< XComponentContext > const & ) SAL_THROW( () ); } /* extern "C" void SAL_CALL component_getImplementationEnvironment( - sal_Char const ** ppEnvTypeName, uno_Environment ** ppEnv ) + sal_Char const ** ppEnvTypeName, uno_Environment ** ) { *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } @@ -260,13 +266,13 @@ extern "C" sal_Bool SAL_CALL component_writeInfo( // implementation of MyService1A Reference< registry::XRegistryKey > xKey( xRegistry->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( - "my_module.my_sc_impl.MyService1/UNO/SERVICES") ) ) ); + "my_module.my_sc_implementation.MyService1/UNO/SERVICES") ) ) ); // subkeys denote implemented services of implementation xKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( "my_module.MyService1") ) ); // implementation of MyService1B xKey = xRegistry->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( - "my_module.my_sc_impl.MyService2/UNO/SERVICES") ) ); + "my_module.my_sc_implementation.MyService2/UNO/SERVICES") ) ); // subkeys denote implemented services of implementation xKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( "my_module.MyService2") ) ); @@ -283,22 +289,22 @@ extern "C" void * SAL_CALL component_getFactory( sal_Char const * implName, lang::XMultiServiceFactory * xMgr, void * ) { Reference< lang::XSingleComponentFactory > xFactory; - if (0 == ::rtl_str_compare( implName, "my_module.my_sc_impl.MyService1" )) + if (0 == ::rtl_str_compare( implName, "my_module.my_sc_implementation.MyService1" )) { // create component factory for MyService1 implementation OUString serviceName( RTL_CONSTASCII_USTRINGPARAM("my_module.MyService1") ); xFactory = ::cppu::createSingleComponentFactory( ::my_sc_impl::create_MyService1Impl, - OUString( RTL_CONSTASCII_USTRINGPARAM("my_module.my_sc_impl.MyService1") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("my_module.my_sc_implementation.MyService1") ), Sequence< OUString >( &serviceName, 1 ) ); } - else if (0 == ::rtl_str_compare( implName, "my_module.my_sc_impl.MyService2" )) + else if (0 == ::rtl_str_compare( implName, "my_module.my_sc_implementation.MyService2" )) { // create component factory for MyService12 implementation OUString serviceName( RTL_CONSTASCII_USTRINGPARAM("my_module.MyService2") ); xFactory = ::cppu::createSingleComponentFactory( ::my_sc_impl::create_MyService2Impl, - OUString( RTL_CONSTASCII_USTRINGPARAM("my_module.my_sc_impl.MyService2") ), + OUString( RTL_CONSTASCII_USTRINGPARAM("my_module.my_sc_implementation.MyService2") ), Sequence< OUString >( &serviceName, 1 ) ); } if (xFactory.is()) |