diff -urNpw @comphelper/source/compare/AnyCompareFactory.cxx comphelper/source/compare/AnyCompareFactory.cxx --- @comphelper/source/compare/AnyCompareFactory.cxx 2006-09-18 01:05:52.000000000 +0800 +++ comphelper/source/compare/AnyCompareFactory.cxx 2007-09-29 10:08:36.000000000 +0800 @@ -67,6 +67,9 @@ #ifndef _COM_SUN_STAR_LANG_ILLEGALARGUMENTEXCEPTION_HPP_ #include #endif +#ifndef _COM_SUN_STAR_LANG_XMULTICOMPONENTFACTORY_HPP_ +#include +#endif #ifndef _COMPHELPER_STLTYPES_HXX_ #include #endif @@ -88,14 +91,17 @@ class AnyCompare : public ::cppu::WeakIm Reference< XCollator > m_rCollator; public: - AnyCompare( Reference< XMultiServiceFactory > xFactory, const Locale& rLocale ) throw() + AnyCompare( Reference< XComponentContext > xContext, const Locale& rLocale ) throw() + { + Reference< XMultiComponentFactory > xFactory = xContext->getServiceManager(); + if ( xFactory.is() ) { m_rCollator = Reference< XCollator >( - xFactory->createInstance( OUString::createFromAscii( "com.sun.star.i18n.Collator" ) ), + xFactory->createInstanceWithContext( OUString::createFromAscii( "com.sun.star.i18n.Collator" ), xContext ), UNO_QUERY ); - m_rCollator->loadDefaultCollator( rLocale, 0 ); //??? + } } @@ -112,13 +118,12 @@ Reference< XInterface > SAL_CALL AnyComp class AnyCompareFactory : public cppu::WeakImplHelper3< XAnyCompareFactory, XInitialization, XServiceInfo > { Reference< XAnyCompare > m_rAnyCompare; - Reference< XMultiServiceFactory > m_rFactory; + Reference< XComponentContext > m_rContext; Locale m_Locale; public: - AnyCompareFactory( Reference< XMultiServiceFactory > xFactory ) : m_rFactory( xFactory ) - { - } + AnyCompareFactory( Reference< XComponentContext > xContext ) : m_rContext( xContext ) + {} // XAnyCompareFactory virtual Reference< XAnyCompare > SAL_CALL createAnyCompareByName ( const OUString& aPropertyName ) throw(::com::sun::star::uno::RuntimeException); @@ -172,14 +177,11 @@ void SAL_CALL AnyCompareFactory::initial { if( aArguments[0] >>= m_Locale ) { - m_rAnyCompare = new AnyCompare( m_rFactory, m_Locale ); + m_rAnyCompare = new AnyCompare( m_rContext, m_Locale ); return; } } - throw IllegalArgumentException( OUString::createFromAscii( "The Any object does not contain Locale!\n" ), - Reference< XInterface >(), - 1 ); } OUString SAL_CALL AnyCompareFactory::getImplementationName( ) throw( RuntimeException ) @@ -212,8 +214,7 @@ rtl::OUString SAL_CALL AnyCompareFactory } Reference< XInterface > SAL_CALL AnyCompareFactory_createInstance( - const Reference< XMultiServiceFactory > & rSMgr ) throw( Exception ) + const Reference< XComponentContext >& rxContext ) throw( Exception ) { - return (cppu::OWeakObject*)new AnyCompareFactory( rSMgr ); + return (cppu::OWeakObject*)new AnyCompareFactory( rxContext ); } - diff -urNpw @comphelper/source/container/IndexedPropertyValuesContainer.cxx comphelper/source/container/IndexedPropertyValuesContainer.cxx --- @comphelper/source/container/IndexedPropertyValuesContainer.cxx 2006-09-18 01:06:08.000000000 +0800 +++ comphelper/source/container/IndexedPropertyValuesContainer.cxx 2007-09-26 16:49:02.000000000 +0800 @@ -51,6 +51,10 @@ #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ #include #endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include +#endif + #ifndef __SGI_STL_VECTOR #include @@ -63,7 +67,7 @@ typedef std::vector < uno::Sequence< bea uno::Sequence< rtl::OUString > SAL_CALL IndexedPropertyValuesContainer_getSupportedServiceNames() throw(); rtl::OUString SAL_CALL IndexedPropertyValuesContainer_getImplementationName() throw(); uno::Reference< uno::XInterface > SAL_CALL IndexedPropertyValuesContainer_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ); + const uno::Reference< uno::XComponentContext > & rxContext ) throw( uno::Exception ); class IndexedPropertyValuesContainer : public cppu::WeakImplHelper2< container::XIndexContainer, lang::XServiceInfo > { @@ -272,7 +276,7 @@ rtl::OUString SAL_CALL IndexedPropertyVa } uno::Reference< uno::XInterface > SAL_CALL IndexedPropertyValuesContainer_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & ) throw( uno::Exception ) + const uno::Reference< uno::XComponentContext > &rxContext) throw( uno::Exception ) { return (cppu::OWeakObject*)new IndexedPropertyValuesContainer(); } diff -urNpw @comphelper/source/container/NamedPropertyValuesContainer.cxx comphelper/source/container/NamedPropertyValuesContainer.cxx --- @comphelper/source/container/NamedPropertyValuesContainer.cxx 2006-09-18 01:06:22.000000000 +0800 +++ comphelper/source/container/NamedPropertyValuesContainer.cxx 2007-09-26 16:44:12.000000000 +0800 @@ -46,6 +46,9 @@ #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_ #include #endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ +#include +#endif #ifndef _CPPUHELPER_IMPLBASE2_HXX_ #include #endif @@ -56,6 +59,7 @@ #include #endif + #include @@ -66,7 +70,7 @@ DECLARE_STL_USTRINGACCESS_MAP( uno::Sequ uno::Sequence< rtl::OUString > SAL_CALL NamedPropertyValuesContainer_getSupportedServiceNames() throw(); rtl::OUString SAL_CALL NamedPropertyValuesContainer_getImplementationName() throw(); uno::Reference< uno::XInterface > SAL_CALL NamedPropertyValuesContainer_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ); + const uno::Reference< uno::XComponentContext > & rxContext ) throw( uno::Exception ); class NamedPropertyValuesContainer : public cppu::WeakImplHelper2< container::XNameContainer, lang::XServiceInfo > { @@ -245,7 +249,7 @@ rtl::OUString SAL_CALL NamedPropertyValu } uno::Reference< uno::XInterface > SAL_CALL NamedPropertyValuesContainer_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & ) throw( uno::Exception ) + const uno::Reference< uno::XComponentContext > & rxContext) throw( uno::Exception ) { return (cppu::OWeakObject*)new NamedPropertyValuesContainer(); } diff -urNpw @comphelper/source/misc/facreg.cxx comphelper/source/misc/facreg.cxx --- @comphelper/source/misc/facreg.cxx 2007-06-27 00:10:54.000000000 +0800 +++ comphelper/source/misc/facreg.cxx 2007-09-28 17:04:12.000000000 +0800 @@ -63,31 +63,34 @@ using namespace com::sun::star; // IndexedPropertyValuesContainer extern uno::Sequence< OUString > SAL_CALL IndexedPropertyValuesContainer_getSupportedServiceNames() throw(); extern OUString SAL_CALL IndexedPropertyValuesContainer_getImplementationName() throw(); -extern uno::Reference< uno::XInterface > SAL_CALL IndexedPropertyValuesContainer_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception ); +extern uno::Reference< uno::XInterface > SAL_CALL IndexedPropertyValuesContainer_createInstance(const uno::Reference< uno::XComponentContext > & rxContext) throw( uno::Exception ); // NamedPropertyValuesContainer extern uno::Sequence< OUString > SAL_CALL NamedPropertyValuesContainer_getSupportedServiceNames() throw(); extern OUString SAL_CALL NamedPropertyValuesContainer_getImplementationName() throw(); -extern uno::Reference< uno::XInterface > SAL_CALL NamedPropertyValuesContainer_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception ); +extern uno::Reference< uno::XInterface > SAL_CALL NamedPropertyValuesContainer_createInstance(const uno::Reference< uno::XComponentContext > & rxContext) throw( uno::Exception ); // AnyCompareFactory extern uno::Sequence< OUString > SAL_CALL AnyCompareFactory_getSupportedServiceNames() throw(); extern OUString SAL_CALL AnyCompareFactory_getImplementationName() throw(); -extern uno::Reference< uno::XInterface > SAL_CALL AnyCompareFactory_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception ); +extern uno::Reference< uno::XInterface > SAL_CALL AnyCompareFactory_createInstance(const uno::Reference< uno::XComponentContext > & rxContext) throw( uno::Exception ); // OfficeInstallationDirectories extern uno::Sequence< OUString > SAL_CALL OfficeInstallationDirectories_getSupportedServiceNames() throw(); extern OUString SAL_CALL OfficeInstallationDirectories_getImplementationName() throw(); extern OUString SAL_CALL OfficeInstallationDirectories_getSingletonName() throw(); extern OUString SAL_CALL OfficeInstallationDirectories_getSingletonServiceName() throw(); -extern uno::Reference< uno::XInterface > SAL_CALL OfficeInstallationDirectories_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception ); +extern uno::Reference< uno::XInterface > SAL_CALL OfficeInstallationDirectories_createInstance(const uno::Reference< uno::XComponentContext > & rxContext) throw( uno::Exception ); // SequenceInputStreamService extern uno::Sequence< OUString > SAL_CALL SequenceInputStreamService_getSupportedServiceNames() throw(); extern OUString SAL_CALL SequenceInputStreamService_getImplementationName() throw(); -extern uno::Reference< uno::XInterface > SAL_CALL SequenceInputStreamService_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr) throw( uno::Exception ); - +extern uno::Reference< uno::XInterface > SAL_CALL SequenceInputStreamService_createInstance(const uno::Reference< uno::XComponentContext > & rxContext) throw( uno::Exception ); +//SequenceOutputStreamService +extern uno::Sequence< OUString > SAL_CALL SequenceOutputStreamService_getSupportedServiceNames() throw(); +extern OUString SAL_CALL SequenceOutputStreamService_getImplementationName() throw(); +extern uno::Reference< uno::XInterface > SAL_CALL SequenceOutputStreamService_createInstance(const uno::Reference< uno::XComponentContext >& rxContext) throw( uno::Exception ); // @@ -146,6 +149,8 @@ SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL c writeInfo( pKey, OInstanceLocker::impl_staticGetImplementationName(), OInstanceLocker::impl_staticGetSupportedServiceNames() ); // SequenceInputStreamService writeInfo( pKey, SequenceInputStreamService_getImplementationName(), SequenceInputStreamService_getSupportedServiceNames() ); + // SequenceOutputStreamService + writeInfo( pKey, SequenceOutputStreamService_getImplementationName(), SequenceOutputStreamService_getSupportedServiceNames() ); } catch (registry::InvalidRegistryException &) @@ -161,58 +166,63 @@ SAL_DLLPUBLIC_EXPORT void * SAL_CALL com void * pRet = 0; if( pServiceManager ) { - uno::Reference< lang::XMultiServiceFactory > xMSF( reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) ); - - uno::Reference< lang::XSingleServiceFactory > xFactory; + uno::Reference xComponentFactory; const sal_Int32 nImplNameLen = strlen( pImplName ); if( IndexedPropertyValuesContainer_getImplementationName().equalsAsciiL( pImplName, nImplNameLen ) ) { - xFactory = ::cppu::createSingleFactory( xMSF, - IndexedPropertyValuesContainer_getImplementationName(), + xComponentFactory = ::cppu::createSingleComponentFactory( IndexedPropertyValuesContainer_createInstance, + IndexedPropertyValuesContainer_getImplementationName(), IndexedPropertyValuesContainer_getSupportedServiceNames() ); } else if( NamedPropertyValuesContainer_getImplementationName().equalsAsciiL( pImplName, nImplNameLen ) ) { - xFactory = ::cppu::createSingleFactory( xMSF, - NamedPropertyValuesContainer_getImplementationName(), + xComponentFactory = ::cppu::createSingleComponentFactory( NamedPropertyValuesContainer_createInstance, + NamedPropertyValuesContainer_getImplementationName(), NamedPropertyValuesContainer_getSupportedServiceNames() ); } else if( AnyCompareFactory_getImplementationName().equalsAsciiL( pImplName, nImplNameLen ) ) { - xFactory = ::cppu::createSingleFactory( xMSF, - AnyCompareFactory_getImplementationName(), + xComponentFactory = ::cppu::createSingleComponentFactory( AnyCompareFactory_createInstance, + AnyCompareFactory_getImplementationName(), AnyCompareFactory_getSupportedServiceNames() ); } else if( OfficeInstallationDirectories_getImplementationName().equalsAsciiL( pImplName, nImplNameLen ) ) { - xFactory = ::cppu::createSingleFactory( xMSF, - OfficeInstallationDirectories_getImplementationName(), + xComponentFactory = ::cppu::createSingleComponentFactory( OfficeInstallationDirectories_createInstance, + OfficeInstallationDirectories_getImplementationName(), OfficeInstallationDirectories_getSupportedServiceNames() ); } else if( OInstanceLocker::impl_staticGetImplementationName().equalsAsciiL( pImplName, nImplNameLen ) ) { - xFactory = ::cppu::createSingleFactory( xMSF, - OInstanceLocker::impl_staticGetImplementationName(), + xComponentFactory = ::cppu::createSingleComponentFactory( OInstanceLocker::impl_staticCreateSelfInstance, + OInstanceLocker::impl_staticGetImplementationName(), OInstanceLocker::impl_staticGetSupportedServiceNames() ); } else if( SequenceInputStreamService_getImplementationName().equalsAsciiL( pImplName, nImplNameLen ) ) { - xFactory = ::cppu::createSingleFactory( xMSF, - SequenceInputStreamService_getImplementationName(), + xComponentFactory = ::cppu::createSingleComponentFactory( SequenceInputStreamService_createInstance, + SequenceInputStreamService_getImplementationName(), SequenceInputStreamService_getSupportedServiceNames() ); } + else if ( SequenceOutputStreamService_getImplementationName().equalsAsciiL( pImplName, nImplNameLen ) ) + { + xComponentFactory = ::cppu::createSingleComponentFactory( + SequenceOutputStreamService_createInstance, + SequenceOutputStreamService_getImplementationName(), + SequenceOutputStreamService_getSupportedServiceNames() ); + } - if( xFactory.is()) + if( xComponentFactory.is()) { - xFactory->acquire(); - pRet = xFactory.get(); + xComponentFactory->acquire(); + pRet = xComponentFactory.get(); } } return pRet; diff -urNpw @comphelper/source/misc/instancelocker.cxx comphelper/source/misc/instancelocker.cxx --- @comphelper/source/misc/instancelocker.cxx 2006-09-18 01:11:28.000000000 +0800 +++ comphelper/source/misc/instancelocker.cxx 2007-09-26 17:31:54.000000000 +0800 @@ -261,21 +261,9 @@ uno::Sequence< ::rtl::OUString > SAL_CAL // -------------------------------------------------------- uno::Reference< uno::XInterface > SAL_CALL OInstanceLocker::impl_staticCreateSelfInstance( - const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) + const uno::Reference< uno::XComponentContext >& rxContext ) { - uno::Reference< uno::XComponentContext > xContext; - uno::Reference< beans::XPropertySet > xPropSet( xServiceManager, uno::UNO_QUERY ); - if ( xPropSet.is() ) - xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ) >>= xContext; - - if ( !xContext.is() ) - { - throw uno::RuntimeException( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unable to obtain component context from service manager!" ) ), - uno::Reference< uno::XInterface >() ); - } - - return static_cast< cppu::OWeakObject * >( new OInstanceLocker( xContext ) ); + return static_cast< cppu::OWeakObject * >( new OInstanceLocker( rxContext ) ); } diff -urNpw @comphelper/source/misc/instancelocker.hxx comphelper/source/misc/instancelocker.hxx --- @comphelper/source/misc/instancelocker.hxx 2006-06-20 06:48:26.000000000 +0800 +++ comphelper/source/misc/instancelocker.hxx 2007-09-26 17:34:50.000000000 +0800 @@ -111,7 +111,7 @@ public: static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL impl_staticCreateSelfInstance( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext ); // XComponent virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException); diff -urNpw @comphelper/source/officeinstdir/officeinstallationdirectories.cxx comphelper/source/officeinstdir/officeinstallationdirectories.cxx --- @comphelper/source/officeinstdir/officeinstallationdirectories.cxx 2006-09-18 01:15:42.000000000 +0800 +++ comphelper/source/officeinstdir/officeinstallationdirectories.cxx 2007-09-26 16:56:32.000000000 +0800 @@ -96,30 +96,11 @@ rtl::OUString SAL_CALL OfficeInstallatio //========================================================================= uno::Reference< uno::XInterface > SAL_CALL OfficeInstallationDirectories_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & xSMgr ) + const uno::Reference< uno::XComponentContext > & rxContext ) throw( uno::Exception ) { - OSL_ENSURE( xSMgr.is(), "No service manager!" ); - - uno::Reference< uno::XComponentContext > xCtx; - uno::Reference< beans::XPropertySet > xPropSet( xSMgr, uno::UNO_QUERY ); - if ( xPropSet.is() ) - { - xPropSet->getPropertyValue( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ) - >>= xCtx; - } - - if ( !xCtx.is() ) - { - throw uno::RuntimeException( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "Unable to obtain component context from service manager!" ) ), - uno::Reference< uno::XInterface >() ); - } - return static_cast< cppu::OWeakObject * >( - new OfficeInstallationDirectories( xCtx ) ); + new OfficeInstallationDirectories( rxContext ) ); } //========================================================================= diff -urNpw @comphelper/source/streaming/makefile.mk comphelper/source/streaming/makefile.mk --- @comphelper/source/streaming/makefile.mk 2007-06-27 00:11:08.000000000 +0800 +++ comphelper/source/streaming/makefile.mk 2007-09-11 13:39:14.000000000 +0800 @@ -50,6 +50,7 @@ SLOFILES= $(SLO)$/basicio.obj \ $(SLO)$/oslfile2streamwrap.obj \ $(SLO)$/seqstream.obj \ $(SLO)$/seqinputstreamserv.obj \ + $(SLO)$/seqoutputstreamserv.obj \ $(SLO)$/streamsection.obj \ $(SLO)$/seekableinput.obj \ $(SLO)$/otransactedfilestream.obj \ diff -urNpw @comphelper/source/streaming/seqinputstreamserv.cxx comphelper/source/streaming/seqinputstreamserv.cxx --- @comphelper/source/streaming/seqinputstreamserv.cxx 2007-06-27 00:11:18.000000000 +0800 +++ comphelper/source/streaming/seqinputstreamserv.cxx 2007-09-26 16:20:32.000000000 +0800 @@ -46,13 +46,14 @@ #include #include #include +#include using namespace ::com::sun::star; ::rtl::OUString SAL_CALL SequenceInputStreamService_getImplementationName(); uno::Sequence< ::rtl::OUString > SAL_CALL SequenceInputStreamService_getSupportedServiceNames(); -uno::Reference< uno::XInterface > SAL_CALL SequenceInputStreamService_createInstance( const uno::Reference< lang::XMultiServiceFactory > & xFactory ) SAL_THROW( (uno::Exception ) ); +uno::Reference< uno::XInterface > SAL_CALL SequenceInputStreamService_createInstance( const uno::Reference< uno::XComponentContext > & rxContext ) SAL_THROW( (uno::Exception ) ); namespace { @@ -64,7 +65,7 @@ class SequenceInputStreamService: lang::XInitialization> { public: - explicit SequenceInputStreamService( uno::Reference< lang::XMultiServiceFactory > const & xFactory ); + explicit SequenceInputStreamService(); // ::com::sun::star::lang::XServiceInfo: virtual ::rtl::OUString SAL_CALL getImplementationName() throw ( uno::RuntimeException ); @@ -94,15 +95,13 @@ private: ::osl::Mutex m_aMutex; - uno::Reference< lang::XMultiServiceFactory > m_xFactory; sal_Bool m_bInitialized; uno::Reference< io::XInputStream > m_xInputStream; uno::Reference< io::XSeekable > m_xSeekable; }; -SequenceInputStreamService::SequenceInputStreamService( uno::Reference< lang::XMultiServiceFactory > const & xFactory ) -: m_xFactory( xFactory ) -, m_bInitialized( sal_False ) +SequenceInputStreamService::SequenceInputStreamService() +: m_bInitialized( sal_False ) {} // com.sun.star.uno.XServiceInfo: @@ -247,10 +246,10 @@ uno::Sequence< ::rtl::OUString > SAL_CAL } uno::Reference< uno::XInterface > SAL_CALL SequenceInputStreamService_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & xFactory ) + const uno::Reference< uno::XComponentContext > & rxContext ) SAL_THROW( (uno::Exception ) ) { - return static_cast< ::cppu::OWeakObject * >( new SequenceInputStreamService( xFactory ) ); + return static_cast< ::cppu::OWeakObject * >( new SequenceInputStreamService() ); } diff -urNpw @comphelper/source/streaming/seqoutputstreamserv.cxx comphelper/source/streaming/seqoutputstreamserv.cxx --- @comphelper/source/streaming/seqoutputstreamserv.cxx 1970-01-01 08:00:00.000000000 +0800 +++ comphelper/source/streaming/seqoutputstreamserv.cxx 2007-10-08 11:09:14.000000000 +0800 @@ -0,0 +1,175 @@ +/************************************************************************* +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile: seqinputstreamserv.cxx,v $ +* +* $Revision: 1.2 $ +* +* last change: $Author: hr $ $Date: 2007/06/26 16:11:17 $ +* +* The Contents of this file are made available subject to +* the terms of GNU Lesser General Public License Version 2.1. +* +* +* GNU Lesser General Public License Version 2.1 +* ============================================= +* Copyright 2005 by Sun Microsystems, Inc. +* 901 San Antonio Road, Palo Alto, CA 94303, USA +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License version 2.1, as published by the Free Software Foundation. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +* +************************************************************************/ + +#include "precompiled_comphelper.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace ::com::sun::star; + + +::rtl::OUString SAL_CALL SequenceOutputStreamService_getImplementationName(); +uno::Sequence< ::rtl::OUString > SAL_CALL SequenceOutputStreamService_getSupportedServiceNames(); +uno::Reference< uno::XInterface > SAL_CALL SequenceOutputStreamService_createInstance( const uno::Reference< uno::XComponentContext >& rxContext )SAL_THROW((uno::Exception)); + + +namespace { + +class SequenceOutputStreamService: +public ::cppu::WeakImplHelper2 < lang::XServiceInfo, io::XSequenceOutputStream > +{ +public: + explicit SequenceOutputStreamService(); + + // ::com::sun::star::lang::XServiceInfo: + virtual ::rtl::OUString SAL_CALL getImplementationName() throw ( uno::RuntimeException ); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString & ServiceName ) throw ( uno::RuntimeException ); + virtual uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw ( uno::RuntimeException ); + + // ::com::sun::star::io::XOutputStream: + virtual void SAL_CALL writeBytes( const uno::Sequence< ::sal_Int8 > & aData ) throw ( io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException ); + virtual void SAL_CALL flush() throw ( uno::RuntimeException, io::NotConnectedException, io::BufferSizeExceededException, io::IOException ); + virtual void SAL_CALL closeOutput() throw ( uno::RuntimeException, io::NotConnectedException, io::BufferSizeExceededException, io::IOException ); + + // ::com::sun::star::io::XSequenceOutputStream: + virtual uno::Sequence< ::sal_Int8 > SAL_CALL getWrittenBytes( ) throw ( io::NotConnectedException, io::IOException, uno::RuntimeException); + +private: + SequenceOutputStreamService( SequenceOutputStreamService & ); //not defined + void operator =( SequenceOutputStreamService & ); //not defined + + virtual ~SequenceOutputStreamService() {}; + + + ::osl::Mutex m_aMutex; + uno::Reference< io::XOutputStream > m_xOutputStream; + uno::Sequence< ::sal_Int8 > m_aSequence; +}; +SequenceOutputStreamService::SequenceOutputStreamService() +{ + m_xOutputStream.set( static_cast < ::cppu::OWeakObject* >( new ::comphelper::OSequenceOutputStream( m_aSequence ) ), uno::UNO_QUERY_THROW ); +} + +// com.sun.star.uno.XServiceInfo: +::rtl::OUString SAL_CALL SequenceOutputStreamService::getImplementationName() throw ( uno::RuntimeException ) +{ + return SequenceOutputStreamService_getImplementationName(); +} + +::sal_Bool SAL_CALL SequenceOutputStreamService::supportsService( ::rtl::OUString const & serviceName ) throw ( uno::RuntimeException ) +{ + uno::Sequence< ::rtl::OUString > serviceNames = SequenceOutputStreamService_getSupportedServiceNames(); + for ( ::sal_Int32 i = 0; i < serviceNames.getLength(); ++i ) { + if ( serviceNames[i] == serviceName ) + return sal_True; + } + return sal_False; +} + +uno::Sequence< ::rtl::OUString > SAL_CALL SequenceOutputStreamService::getSupportedServiceNames() throw ( uno::RuntimeException ) +{ + return SequenceOutputStreamService_getSupportedServiceNames(); +} + +// ::com::sun::star::io::XOutputStream: +void SAL_CALL SequenceOutputStreamService::writeBytes( const uno::Sequence< ::sal_Int8 > & aData ) throw ( uno::RuntimeException, io::NotConnectedException, io::BufferSizeExceededException, io::IOException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !m_xOutputStream.is() ) + throw io::NotConnectedException(); + + m_xOutputStream->writeBytes( aData ); + m_aSequence = aData; +} + +void SAL_CALL SequenceOutputStreamService::flush() throw ( uno::RuntimeException, io::NotConnectedException, io::BufferSizeExceededException, io::IOException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !m_xOutputStream.is() ) + throw io::NotConnectedException(); + + m_xOutputStream->flush(); +}; + +void SAL_CALL SequenceOutputStreamService::closeOutput() throw ( uno::RuntimeException, io::NotConnectedException, io::BufferSizeExceededException, io::IOException ) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !m_xOutputStream.is() ) + throw io::NotConnectedException(); + + m_xOutputStream->closeOutput(); + m_xOutputStream = uno::Reference< io::XOutputStream >(); +} + +// ::com::sun::star::io::XSequenceOutputStream: +uno::Sequence< ::sal_Int8 > SAL_CALL SequenceOutputStreamService::getWrittenBytes() throw ( io::NotConnectedException, io::IOException, uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !m_xOutputStream.is() ) + throw io::NotConnectedException(); + + m_xOutputStream->flush(); + return m_aSequence; +} + +} // anonymous namespace + +::rtl::OUString SAL_CALL SequenceOutputStreamService_getImplementationName() { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.SequenceOutputStreamService" ) ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL SequenceOutputStreamService_getSupportedServiceNames() +{ + uno::Sequence< ::rtl::OUString > s( 1 ); + s[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.io.SequenceOutputStream" ) ); + return s; +} + +uno::Reference< uno::XInterface > SAL_CALL SequenceOutputStreamService_createInstance( + const uno::Reference< uno::XComponentContext >& rxContext ) + SAL_THROW( (uno::Exception) ) +{ + return static_cast< ::cppu::OWeakObject * >( new SequenceOutputStreamService()); +} diff -urNpw @comphelper/source/streaming/seqstream.cxx comphelper/source/streaming/seqstream.cxx --- @comphelper/source/streaming/seqstream.cxx 2006-09-18 01:21:22.000000000 +0800 +++ comphelper/source/streaming/seqstream.cxx 2007-09-12 10:43:52.000000000 +0800 @@ -234,7 +234,8 @@ void SAL_CALL OSequenceOutputStream::flu if (!m_bConnected) throw NotConnectedException(); - // nothing to do here + // cut the sequence to the real size + m_rSequence.realloc(m_nSize); } //--------------------------------------------------------------------------