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/TextInputStream | |
parent | a242da96dcd112e05ce9fa7f309d6618c61994f9 (diff) |
#67468# Added unloading and context support
Diffstat (limited to 'io/source/TextInputStream')
-rw-r--r-- | io/source/TextInputStream/TextInputStream.cxx | 109 | ||||
-rw-r--r-- | io/source/TextInputStream/makefile.mk | 6 | ||||
-rw-r--r-- | io/source/TextInputStream/tinstrm.map | 10 |
3 files changed, 75 insertions, 50 deletions
diff --git a/io/source/TextInputStream/TextInputStream.cxx b/io/source/TextInputStream/TextInputStream.cxx index 6d381413528e..88b986245d70 100644 --- a/io/source/TextInputStream/TextInputStream.cxx +++ b/io/source/TextInputStream/TextInputStream.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TextInputStream.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: ab $ $Date: 2001-04-27 15:10:58 $ + * last change: $Author: jbu $ $Date: 2001-06-22 16:32:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,16 +64,20 @@ #include <osl/mutex.hxx> #include <osl/diagnose.h> +#include <rtl/unload.h> + #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 <com/sun/star/io/XTextInputStream.hpp> #include <com/sun/star/io/XActiveDataSink.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #define IMPLEMENTATION_NAME "com.sun.star.comp.io.TextInputStream" @@ -88,13 +92,14 @@ using namespace ::com::sun::star::io; using namespace ::com::sun::star::registry; -namespace io_TextStream +namespace io_TextInputStream { + rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT; //=========================================================================== // Implementation XTextInputStream -typedef WeakImplHelper2< XTextInputStream, XActiveDataSink > TextInputStreamHelper; +typedef WeakImplHelper3< XTextInputStream, XActiveDataSink, XServiceInfo > TextInputStreamHelper; class OCommandEnvironment; #define INITIAL_UNICODE_BUFFER_CAPACITY 0x100 @@ -153,12 +158,18 @@ public: throw(RuntimeException); virtual Reference< XInputStream > SAL_CALL getInputStream() 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( () ); }; OTextInputStream::OTextInputStream() : mSeqSource( READ_BYTE_COUNT ), mpBuffer( NULL ), mnBufferSize( 0 ) , mnCharsInBuffer( 0 ), mbReachedEOF( sal_False ) { + g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); mbEncodingInitialized = false; } @@ -169,6 +180,7 @@ OTextInputStream::~OTextInputStream() rtl_destroyUnicodeToTextContext( mConvText2Unicode, mContextText2Unicode ); rtl_destroyUnicodeToTextConverter( mConvText2Unicode ); } + g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); } void OTextInputStream::implResizeBuffer( void ) @@ -462,11 +474,15 @@ Reference< XInputStream > OTextInputStream::getInputStream() } -Reference< XInterface > SAL_CALL TextInputStream_CreateInstance( const Reference< XMultiServiceFactory > &) +Reference< XInterface > SAL_CALL TextInputStream_CreateInstance( const Reference< XComponentContext > &) { return Reference < XInterface >( ( OWeakObject * ) new OTextInputStream() ); } +OUString TextInputStream_getImplementationName() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); +} Sequence< OUString > TextInputStream_getSupportedServiceNames() { @@ -477,22 +493,56 @@ Sequence< OUString > TextInputStream_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 OTextInputStream::getImplementationName() SAL_THROW( () ) +{ + return TextInputStream_getImplementationName(); +} + +sal_Bool OTextInputStream::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 > OTextInputStream::getSupportedServiceNames(void) SAL_THROW( () ) +{ + return TextInputStream_getSupportedServiceNames(); +} } +using namespace io_TextInputStream; -//================================================================================================== -// Component exports +static struct ImplementationEntry g_entries[] = +{ + { + TextInputStream_CreateInstance, TextInputStream_getImplementationName , + TextInputStream_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 ) @@ -503,50 +553,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::TextInputStream_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::TextInputStream_CreateInstance, - io_TextStream::TextInputStream_getSupportedServiceNames() ) ); - - if (xFactory.is()) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; + return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries ); } } diff --git a/io/source/TextInputStream/makefile.mk b/io/source/TextInputStream/makefile.mk index 544a9c9c78f5..a4656e27d80a 100644 --- a/io/source/TextInputStream/makefile.mk +++ b/io/source/TextInputStream/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.8 $ +# $Revision: 1.9 $ # -# last change: $Author: kz $ $Date: 2001-05-15 08:37:58 $ +# last change: $Author: jbu $ $Date: 2001-06-22 16:32:49 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -84,6 +84,7 @@ UNOTYPES= com.sun.star.io.XTextInputStream \ com.sun.star.lang.XSingleServiceFactory \ com.sun.star.lang.XMultiServiceFactory \ com.sun.star.lang.XTypeProvider \ + com.sun.star.lang.XServiceInfo \ com.sun.star.registry.XRegistryKey \ com.sun.star.uno.XAggregation \ com.sun.star.uno.XWeak \ @@ -93,6 +94,7 @@ SLOFILES= \ $(SLO)$/TextInputStream.obj SHL1TARGET= $(TARGET) +SHL1VERSIONMAP= $(TARGET).map SHL1STDLIBS= \ $(SALLIB) \ diff --git a/io/source/TextInputStream/tinstrm.map b/io/source/TextInputStream/tinstrm.map new file mode 100644 index 000000000000..f76809fbd37b --- /dev/null +++ b/io/source/TextInputStream/tinstrm.map @@ -0,0 +1,10 @@ +UDK_3_0_0 { + global: + component_getImplementationEnvironment; + component_writeInfo; + component_getFactory; + component_canUnload; + component_getDescriptionFunc; + local: + *; +}; |