diff options
author | Jörg Budischewski <jbu@openoffice.org> | 2001-06-22 15:32:57 +0000 |
---|---|---|
committer | Jörg Budischewski <jbu@openoffice.org> | 2001-06-22 15:32:57 +0000 |
commit | 4409e1cfb5d33e57c1eba238bd5ab9d153cbbacd (patch) | |
tree | b5a5977d54c51cd971011c26286c922acdd272c9 /io/source/TextOutputStream | |
parent | a242da96dcd112e05ce9fa7f309d6618c61994f9 (diff) |
#67468# Added unloading and context support
Diffstat (limited to 'io/source/TextOutputStream')
-rw-r--r-- | io/source/TextOutputStream/TextOutputStream.cxx | 109 | ||||
-rw-r--r-- | io/source/TextOutputStream/makefile.mk | 7 | ||||
-rw-r--r-- | io/source/TextOutputStream/toutstrm.map | 10 |
3 files changed, 74 insertions, 52 deletions
diff --git a/io/source/TextOutputStream/TextOutputStream.cxx b/io/source/TextOutputStream/TextOutputStream.cxx index c6cb13ee7901..19407c9575c2 100644 --- a/io/source/TextOutputStream/TextOutputStream.cxx +++ b/io/source/TextOutputStream/TextOutputStream.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TextOutputStream.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: jl $ $Date: 2001-03-12 15:50:46 $ + * last change: $Author: jbu $ $Date: 2001-06-22 16:32:53 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,13 +66,16 @@ #include <uno/mapping.hxx> #include <cppuhelper/factory.hxx> -#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implementationentry.hxx> #include <rtl/textenc.h> #include <rtl/tencinfo.h> +#include <rtl/unload.h> #include <com/sun/star/io/XTextOutputStream.hpp> #include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #define IMPLEMENTATION_NAME "com.sun.star.comp.io.TextOutputStream" @@ -87,13 +90,13 @@ using namespace ::com::sun::star::io; using namespace ::com::sun::star::registry; -namespace io_TextStream +namespace io_TextOutputStream { - + rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT; //=========================================================================== // Implementation XTextOutputStream -typedef WeakImplHelper2< XTextOutputStream, XActiveDataSource > TextOutputStreamHelper; +typedef WeakImplHelper3< XTextOutputStream, XActiveDataSource, XServiceInfo > TextOutputStreamHelper; class OCommandEnvironment; class OTextOutputStream : public TextOutputStreamHelper @@ -131,6 +134,11 @@ public: throw(RuntimeException); virtual Reference< XOutputStream > SAL_CALL getOutputStream( ) throw(RuntimeException); + + // Methods XServiceInfo + virtual OUString SAL_CALL getImplementationName() SAL_THROW( () ); + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(void) SAL_THROW( () ); + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) SAL_THROW( () ); }; OTextOutputStream::OTextOutputStream() @@ -265,11 +273,16 @@ Reference< XOutputStream > OTextOutputStream::getOutputStream() } -Reference< XInterface > SAL_CALL TextOutputStream_CreateInstance( const Reference< XMultiServiceFactory > &) +Reference< XInterface > SAL_CALL TextOutputStream_CreateInstance( const Reference< XComponentContext > &) { return Reference < XInterface >( ( OWeakObject * ) new OTextOutputStream() ); } +OUString TextOutputStream_getImplementationName() SAL_THROW( () ) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); +} + Sequence< OUString > TextOutputStream_getSupportedServiceNames() { @@ -280,22 +293,57 @@ Sequence< OUString > TextOutputStream_getSupportedServiceNames() if( !pNames ) { static Sequence< OUString > seqNames(1); - seqNames.getArray()[0] = OUString::createFromAscii( SERVICE_NAME ); + seqNames.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) ); pNames = &seqNames; } } return *pNames; } +OUString OTextOutputStream::getImplementationName() SAL_THROW( () ) +{ + return TextOutputStream_getImplementationName(); +} + +sal_Bool OTextOutputStream::supportsService(const OUString& ServiceName) SAL_THROW( () ) +{ + Sequence< OUString > aSNL = getSupportedServiceNames(); + const OUString * pArray = aSNL.getConstArray(); + + for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) + if( pArray[i] == ServiceName ) + return sal_True; + return sal_False; } +Sequence< OUString > OTextOutputStream::getSupportedServiceNames(void) SAL_THROW( () ) +{ + return TextOutputStream_getSupportedServiceNames(); +} -//================================================================================================== -// Component exports + +} + +using namespace io_TextOutputStream; + +static struct ImplementationEntry g_entries[] = +{ + { + TextOutputStream_CreateInstance, TextOutputStream_getImplementationName , + TextOutputStream_getSupportedServiceNames, createSingleComponentFactory , + &g_moduleCount.modCnt , 0 + }, + { 0, 0, 0, 0, 0, 0 } +}; extern "C" { +sal_Bool SAL_CALL component_canUnload( TimeValue *pTime ) +{ + return g_moduleCount.canUnload( &g_moduleCount , pTime ); +} + //================================================================================================== void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) @@ -306,50 +354,13 @@ void SAL_CALL component_getImplementationEnvironment( sal_Bool SAL_CALL component_writeInfo( void * pServiceManager, void * pRegistryKey ) { - if (pRegistryKey) - { - try - { - Reference< XRegistryKey > xNewKey( - reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( - OUString::createFromAscii("/" IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) ); - - const Sequence< OUString > & rSNL = io_TextStream::TextOutputStream_getSupportedServiceNames(); - const OUString * pArray = rSNL.getConstArray(); - for ( sal_Int32 nPos = rSNL.getLength(); nPos--; ) - xNewKey->createKey( pArray[nPos] ); - - return sal_True; - } - catch (InvalidRegistryException &) - { - OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); - } - } - return sal_False; + return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); } //================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { - void * pRet = 0; - - if (pServiceManager && rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0) - { - Reference< XSingleServiceFactory > xFactory( createSingleFactory( - reinterpret_cast< XMultiServiceFactory * >( pServiceManager ), - OUString::createFromAscii( pImplName ), - io_TextStream::TextOutputStream_CreateInstance, - io_TextStream::TextOutputStream_getSupportedServiceNames() ) ); - - if (xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; + return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries ); } } diff --git a/io/source/TextOutputStream/makefile.mk b/io/source/TextOutputStream/makefile.mk index b1e95544e152..9ae20a2dc8d4 100644 --- a/io/source/TextOutputStream/makefile.mk +++ b/io/source/TextOutputStream/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.8 $ +# $Revision: 1.9 $ # -# last change: $Author: jbu $ $Date: 2001-05-15 08:12:05 $ +# last change: $Author: jbu $ $Date: 2001-06-22 16:32:53 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -83,6 +83,7 @@ UNOTYPES= com.sun.star.io.XTextOutputStream \ com.sun.star.lang.XMultiServiceFactory \ com.sun.star.lang.XTypeProvider \ com.sun.star.lang.XSingleComponentFactory \ + com.sun.star.lang.XServiceInfo \ com.sun.star.uno.XComponentContext \ com.sun.star.registry.XRegistryKey \ com.sun.star.uno.XAggregation \ @@ -92,6 +93,7 @@ SLOFILES= \ $(SLO)$/TextOutputStream.obj SHL1TARGET= $(TARGET) +SHL1VERSIONMAP= $(TARGET).map SHL1STDLIBS= \ $(SALLIB) \ @@ -104,7 +106,6 @@ SHL1LIBS= $(SLB)$/$(TARGET).lib SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) -DEF1EXPORTFILE= exports.dxp # --- Targets ------------------------------------------------------ diff --git a/io/source/TextOutputStream/toutstrm.map b/io/source/TextOutputStream/toutstrm.map new file mode 100644 index 000000000000..f76809fbd37b --- /dev/null +++ b/io/source/TextOutputStream/toutstrm.map @@ -0,0 +1,10 @@ +UDK_3_0_0 { + global: + component_getImplementationEnvironment; + component_writeInfo; + component_getFactory; + component_canUnload; + component_getDescriptionFunc; + local: + *; +}; |