Hi Mikhail,
Thanks to your instructions in our last IRC meeting, I have adjusted the
declaration of the interface and worked out most of the implementations.
All the related files are attached to this mail, please give a
inspection to them and some advice to me. :-)
Just as usual, I have some questions today.
1. Is the XTempFile::GetProps() method to be disposed in the new
implementation as well?
2. As I can recall, you have mentioned the compatibility thing before,
do we need to do additional implementations or the PropertySetMixin
class takes care of it itself?
3. Could you give me some further explanation why
IllegalArgumentException is thrown in the old, but not thrown in the new
implementation?
4. I see lots of the methods use mutex. However they don't use the same
one. While most of them use maMutex, the getTypes() method which
inherits from XTypeProvider, as you taught me in a previous mail, uses
m_pData->m_rSharedMutexRef->GetMutex(). To make it more confusing, the
GetProps() method in the old implementation uses
::osl::Mutex::getGlobalMutex(). Could you give me some hints here?
Thanks and Best Regards,
Felix
#include "precompiled_unotools.hxx"
#ifndef _OTempFileSERVICE_HXX_
#include <OTempFileService.hxx>
#endif
#ifndef _CPPUHELPER_FACTORY_HXX_
#include <cppuhelper/factory.hxx>
#endif
#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
#include <cppuhelper/typeprovider.hxx>
#endif
#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP
#include <com/sun/star/registry/XRegistryKey.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP
#include <com/sun/star/beans/PropertyAttribute.hpp>
#endif
#ifndef _UNOTOOLS_TempFile_HXX
#include <unotools/TempFile.hxx>
#endif
#ifndef _osl_FILE_HXX_
#include <osl/file.hxx>
#endif
#ifndef _::utl_CONFIGMGR_HXX_
#include <unotools/configmgr.hxx>
#endif
#ifndef _URLOBJ_HXX
#include <tools/urlobj.hxx>
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
namespace css = com::sun::star;
// copy define from desktop\source\app\appinit.cxx
#define DESKTOP_TEMPNAMEBASE_DIR "/temp/soffice.tmp"
OTempFileService::OTempFileService()
: mpStream( NULL )
, mbRemoveFile( sal_True )
, mbInClosed( sal_False )
, mbOutClosed( sal_False )
, mnCachedPos( 0 )
, mbHasCachedPos( sal_False )
{
mpTempFile = new ::utl::TempFile;
mpTempFile->EnableKillingFile ( sal_True );
}
OTempFileService::~OTempFileService ()
{
if ( mpTempFile )
delete mpTempFile;
}
/*
::css::uno::Sequence< ::css::beans::Property > ::css::io::XTempFile::GetProps(
)
{
static ::css::uno::Sequence< ::css::beans::Property >* pProps = NULL;
if ( pProps == NULL )
{
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ) ;
if ( pProps == NULL )
{
static ::css::uno::Sequence< ::css::beans::Property >
aProps( 3 );
aProps[0].Name = ::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( "RemoveFile" ) );
aProps[0].Type = getCppuType( static_cast< sal_Bool* >(
NULL ) );
aProps[0].Attributes =
::css::beans::PropertyAttribute::TRANSIENT;
aProps[1].Name = ::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( "ResourceName" ) );
aProps[1].Type = getCppuType( static_cast<
::rtl::OUString* >( NULL ) );
aProps[1].Attributes =
::css::beans::PropertyAttribute::TRANSIENT |
::css::beans::PropertyAttribute::READONLY;
aProps[2].Name = ::rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM( "Uri" ) );
aProps[2].Type = getCppuType( static_cast<
::rtl::OUString* >( NULL ) );
aProps[2].Attributes =
::css::beans::PropertyAttribute::TRANSIENT |
::css;:beans::PropertyAttribute::READONLY;
pProps = &aProps;
}
}
return *pProps;
}
*/
// XInterface
::css::uno::Any SAL_CALL ::css::io::XTempFile::queryInterface( ::css::uno::Type
const & aType )
throw ( ::css::uno::RuntimeException )
{
::css::uno::Any aResult( OTempFileBase::queryInterface( atype ) );
if (!aResult.hasValue())
aResult = cppu::PropertySetMixin< ::css::io::XTempFile
>::queryInterface( aType ) ;
return aResult;
};
void SAL_CALL ::css::io::XTempFile::acquire( )
throw ()
{
OTempFileBase::acquire();
}
void SAL_CALL ::css::io::XTempFile::release( )
throw ()
{
OTempFileBase::release();
}
// XTypeProvider
::css::uno::Sequence< ::css::uno::Type > SAL_CALL
::css::io::XTempFile::getTypes( )
throw ( ::css::uno::RuntimeException )
{
static ::cppu::OTypeCollection* pTypeCollection = NULL;
if ( pTypeCollection == NULL )
{
::osl::MutexGuard aGuard(
m_pData->m_rSharedMutexRef->GetMutex() );
if ( pTypeCollection == NULL )
{
static ::cppu::OTypeCollection aTypeCollection(
OTempFileBase::getTypes(),
::getCppuType( ( const ::css::uno::Reference<
::css::beans::XPropertySet >*)NULL ) );
pTypeCollection = &aTypeCollection;
}
}
return pTypeCollection->getTypes();
};
::css::uno::Sequence< sal_Int8 > SAL_CALL
::css::io::XTempFile::getImplementationId( )
throw ( ::css::uno::RuntimeException )
{
return OTempFileBase::getImplementationId()
};
// XTempFile
sal_Bool SAL_CALL ::css::io::XTempFile::getRemoveFile()
throw ( ::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
if ( !mpTempFile )
{
// the stream is already disconnected
throw RuntimeException();
}
return mbRemoveFile;
};
void SAL_CALL ::css::io::XTempFile::setRemoveFile( sal_Bool _removefile )
throw ( ::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
if ( !mpTempFile )
{
// the stream is already disconnected
throw RuntimeException();
}
mbRemoveFile = _removefile;
mpTempFile->EnableKillingFile( mbRemoveFile );
};
::rtl::OUString SAL_CALL ::css::io::XTempFile::getUri()
throw ( ::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
if ( !mpTempFile )
{
throw RuntimeException();
}
return ::rtl::OUString( mpTempFile->GetFileName() );
};
::rtl::OUString SAL_CALL ::css::io::XTempFile::getResourceName()
throw ( ::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
if ( !mpTempFile )
{
throw RuntimeException();
}
return ::rtl::OUStirng( mpTempFile->GetURL() );
};
// XInputStream
sal_Int32 SAL_CALL ::css::io::XTempFile::readBytes( ::css::uno::Sequence<
sal_Int8 >& aData, sal_Int32 nBytesToRead )
throw (::css::io::NotConnectedException,
::css::io::BufferSizeExceededException, ::css::io::IOException,
::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
if ( mbInClosed )
throw ::css::io::NotConnectedException ( ::rtl::OUString(),
const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * >
(this ) ) );
checkConnected();
if (nBytesToRead < 0)
throw ::css::io::BufferSizeExceededException(
::rtl::OUString(), static_cast< ::css::uno::XWeak * >(this));
aData.realloc(nBytesToRead);
sal_uInt32 nRead = mpStream->Read(static_cast < void* > (
aData.getArray() ), nBytesToRead);
checkError();
if (nRead < static_cast < sal_uInt32 > ( nBytesToRead ) )
aData.realloc( nRead );
if ( sal::static_int_cast<sal_uInt32>(nBytesToRead) > nRead )
{
// usually that means that the stream was read till the end
// TODO/LATER: it is better to get rid of this optimization by
avoiding using of multiple temporary files ( there should be only one temporary
file? )
mnCachedPos = mpStream->Tell();
mbHasCachedPos = sal_True;
mpStream = NULL;
if ( mpTempFile )
mpTempFile->CloseStream();
}
return nRead;
}
sal_Int32 SAL_CALL ::css::io::XTempFile::readSomeBytes( ::css::uno::Sequence<
sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
throw ( ::css::io::NotConnectedException,
::css::io::BufferSizeExceededException, ::css::io::IOException,
::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
if ( mbInClosed )
throw ::css::io::NotConnectedException ( ::rtl::OUString(),
const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * >
(this ) ) );
checkConnected();
checkError();
if (nMaxBytesToRead < 0)
throw ::css::io::BufferSizeExceededException(
::rtl::OUString(), static_cast < ::css::uno::XWeak * >( this ) );
if (mpStream->IsEof())
{
aData.realloc(0);
return 0;
}
else
return readBytes(aData, nMaxBytesToRead);
}
void SAL_CALL ::css::io::XTempFile::skipBytes( sal_Int32 nBytesToSkip )
throw ( ::css::io::NotConnectedException,
::css::io::BufferSizeExceededException, ::css::io::IOException,
::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
if ( mbInClosed )
throw ::css::io::NotConnectedException ( ::rtl::OUString(),
const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * >
(this ) ) );
checkConnected();
checkError();
mpStream->SeekRel(nBytesToSkip);
checkError();
}
sal_Int32 SAL_CALL ::css::io::XTempFile::available( )
throw ( ::css::io::NotConnectedException, ::css::io::IOException,
::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
if ( mbInClosed )
throw ::css::io::NotConnectedException ( ::rtl::OUString(),
const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * >
(this ) ) );
checkConnected();
sal_uInt32 nPos = mpStream->Tell();
checkError();
mpStream->Seek(STREAM_SEEK_TO_END);
checkError();
sal_Int32 nAvailable = (sal_Int32)mpStream->Tell() - nPos;
mpStream->Seek(nPos);
checkError();
return nAvailable;
}
void SAL_CALL ::css::io::XTempFile::closeInput( )
throw ( ::css::io::NotConnectedException, ::css::io::IOException,
::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
if ( mbInClosed )
throw ::css::io::NotConnectedException ( ::rtl::OUString(),
const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * >
(this ) ) );
mbInClosed = sal_True;
if ( mbOutClosed )
{
// stream will be deleted by TempFile implementation
mpStream = NULL;
if ( mpTempFile )
{
delete mpTempFile;
mpTempFile = NULL;
}
}
}
// XOutputStream
void SAL_CALL ::css::io::XTempFile::writeBytes( const ::css::uno::Sequence<
sal_Int8 >& aData )
throw ( ::css::io::NotConnectedException,
::css::io::BufferSizeExceededException, ::css::io::IOException,
::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
if ( mbOutClosed )
throw ::css::io::NotConnectedException ( ::rtl::OUString(),
const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * >
(this ) ) );
checkConnected();
sal_uInt32 nWritten =
mpStream->Write(aData.getConstArray(),aData.getLength());
checkError();
if ( nWritten != (sal_uInt32)aData.getLength())
throw ::css::io::BufferSizeExceededException(
::rtl::OUString(),static_cast < ::css::uno::XWeak * > ( this ) );
}
void SAL_CALL ::css::io::XTempFile::flush( )
throw ( ::css::io::NotConnectedException,
::css::io::BufferSizeExceededException, ::css::io::IOException,
::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
if ( mbOutClosed )
throw ::css::io::NotConnectedException ( ::rtl::OUString(),
const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * >
(this ) ) );
checkConnected();
mpStream->Flush();
checkError();
}
void SAL_CALL ::css::io::XTempFile::closeOutput( )
throw ( ::css::io::NotConnectedException,
::css::io::BufferSizeExceededException, ::css::io::IOException,
::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
if ( mbOutClosed )
throw ::css::io::NotConnectedException ( ::rtl::OUString(),
const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * >
(this ) ) );
mbOutClosed = sal_True;
// TODO/LATER: it is better to get rid of this optimization by avoiding
using of multiple temporary files ( there should be only one temporary file? )
if ( mpStream )
{
mnCachedPos = mpStream->Tell();
mbHasCachedPos = sal_True;
mpStream = NULL;
if ( mpTempFile )
mpTempFile->CloseStream();
}
if ( mbInClosed )
{
// stream will be deleted by TempFile implementation
mpStream = NULL;
if ( mpTempFile )
{
delete mpTempFile;
mpTempFile = NULL;
}
}
}
void ::css::io::XTempFile::checkError () const
{
if (!mpStream || mpStream->SvStream::GetError () != ERRCODE_NONE )
throw ::css::io::NotConnectedException ( ::rtl::OUString(),
const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * >
(this ) ) );
}
void ::css::io::XTempFile::checkConnected ()
{
if (!mpStream && mpTempFile)
{
mpStream = mpTempFile->GetStream( STREAM_STD_READWRITE );
if ( mpStream && mbHasCachedPos )
{
mpStream->Seek(
sal::static_int_cast<sal_Size>(mnCachedPos) );
if ( mpStream->SvStream::GetError () == ERRCODE_NONE )
{
mbHasCachedPos = sal_False;
mnCachedPos = 0;
}
else
{
mpStream = NULL;
mpTempFile->CloseStream();
}
}
}
if (!mpStream)
throw ::css::io::NotConnectedException ( ::rtl::OUString(),
const_cast < ::css::uno::XWeak * > ( static_cast < const ::css::uno::XWeak * >
(this ) ) );
}
// XSeekable
void SAL_CALL ::css::io::XTempFile::seek( sal_Int64 nLocation )
throw ( ::css::lang::IllegalArgumentException, ::css::io::IOException,
::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
checkConnected();
if ( nLocation < 0 || nLocation > getLength() )
throw ::css::lang::IllegalArgumentException();
mpStream->Seek((sal_uInt32) nLocation );
checkError();
}
sal_Int64 SAL_CALL ::css::io::XTempFile::getPosition( )
throw ( ::css::io::IOException, ::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
checkConnected();
sal_uInt32 nPos = mpStream->Tell();
checkError();
return (sal_Int64)nPos;
}
sal_Int64 SAL_CALL ::css::io::XTempFile::getLength( )
throw ( ::css::io::IOException, ::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
checkConnected();
sal_uInt32 nCurrentPos = mpStream->Tell();
checkError();
mpStream->Seek(STREAM_SEEK_TO_END);
sal_uInt32 nEndPos = mpStream->Tell();
mpStream->Seek(nCurrentPos);
checkError();
return (sal_Int64)nEndPos;
}
// XStream
::css::uno::Reference< ::css::io::XInputStream > SAL_CALL
::css::io::XTempFile::getInputStream()
throw ( ::css::uno::RuntimeException )
{
return ::css::uno::Reference< ::css::io::XInputStream >( *this,
::css::uno::UNO_QUERY );
}
::css::uno::Reference< ::css::io::XOutputStream > SAL_CALL
::css::io::XTempFile::getOutputStream()
throw ( ::css::uno::RuntimeException )
{
return ::css::uno::Reference< ::css::io::XOutputStream >( *this,
::css::uno::UNO_QUERY );
}
// XTruncate
void SAL_CALL ::css::io::XTempFile::truncate()
throw ( ::css::io::IOException, ::css::uno::RuntimeException )
{
::osl::MutexGuard aGuard( maMutex );
checkConnected();
// SetStreamSize() call does not change the position
mpStream->Seek( 0 );
mpStream->SetStreamSize( 0 );
checkError();
}
// XServiceInfo
::rtl::OUString SAL_CALL ::css::io::XTempFile::getImplementationName()
throw ( ::css::uno::RuntimeException )
{
return getImplementationName_Static();
}
sal_Bool SAL_CALL ::css::io::XTempFile::supportsService( ::rtl::OUString const
& rServiceName )
throw ( ::css::uno::RuntimeException )
{
::css::uno::Sequence< ::rtl::OUString >
aServices(getSupportedServiceNames_Static());
return rServiceName == aServices[0];
}
::css::uno::Sequence < ::rtl::OUString > SAL_CALL
::css::io::XTempFile::getSupportedServiceNames()
throw ( ::css::uno::RuntimeException )
{
return getSupportedServiceNames_Static();
}
::rtl::OUString ::css::io::XTempFile::getImplementationName_Static ()
{
return ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM (
"com.sun.star.io.comp.TempFile" ) );
}
::css::uno::Sequence < ::rtl::OUString >
::css::io::XTempFile::getSupportedServiceNames_Static()
{
::css::uno::Sequence < ::rtl::OUString > aNames ( 1 );
aNames[0] = ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM (
"com.sun.star.io.TempFile" ) );
return aNames;
}
::css::uno::Reference < ::css::uno::XInterface >SAL_CALL
XTempFile_createInstance(
const ::css::uno::Reference< ::css::lang::XMultiServiceFactory > &
/*xMgr*/ )
{
return ::css::uno::Reference< ::css::uno::XInterface >( *new
::css::io::XTempFile );
}
::css::uno::Reference < ::css::lang::XSingleServiceFactory >
::css::io::XTempFile::createServiceFactory_Static( ::css::uno::Reference <
::css::lang::XMultiServiceFactory > const & rServiceFactory )
{
return cppu::createSingleFactory ( rServiceFactory,
getImplementationName_Static(),
XTempFile_createInstance,
getSupportedServiceNames_Static());
}
static sal_Bool writeInfo( void * pRegistryKey,
const ::rtl::OUString &
rImplementationName,
::css::uno::Sequence<
::rtl::OUString > const & rServiceNames )
{
::rtl::OUString aKeyName( RTL_CONSTASCII_USTRINGPARAM ( "/" ) );
aKeyName += rImplementationName;
aKeyName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM (
"/UNO/SERVICES" ) );
::css::uno::Reference< ::css::registry::XRegistryKey > xKey;
try
{
xKey = static_cast< ::css::registry::XRegistryKey * >(
pRegistryKey )->createKey( aKeyName );
}
catch ( ::css::registry::InvalidRegistryException const & )
{
}
if ( !xKey.is() )
return sal_False;
sal_Bool bSuccess = sal_True;
for ( sal_Int32 n = 0; n < rServiceNames.getLength(); ++n )
{
try
{
xKey->createKey( rServiceNames[ n ] );
}
catch ( ::css::registry::InvalidRegistryException const & )
{
bSuccess = sal_False;
break;
}
}
return bSuccess;
}
// C functions to implement this as a component
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
component_getImplementationEnvironment(
const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
/**
* This function creates an implementation section in the registry and another
subkey
* for each supported service.
* @param pServiceManager generic uno interface providing a service manager
* @param pRegistryKey generic uno interface providing registry key to write
*/
extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( void*
/*pServiceManager*/, void* pRegistryKey )
{
return pRegistryKey &&
writeInfo (pRegistryKey,
::css::io::XTempFile::getImplementationName_Static(),
::css::io::XTempFile::getSupportedServiceNames_Static() );
}
/**
* This function is called to get service factories for an implementation.
* @param pImplName name of implementation
* @param pServiceManager generic uno interface providing a service manager to
instantiate components
* @param pRegistryKey registry data key to read and write component persistent
data
* @return a component factory (generic uno interface)
*/
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
const sal_Char * pImplName, void * pServiceManager, void *
/*pRegistryKey*/ )
{
void * pRet = 0;
::css::uno::Reference< ::css::lang::XMultiServiceFactory > xSMgr(
reinterpret_cast< ::css::lang::XMultiServiceFactory * >(
pServiceManager ) );
::css::uno::Reference< ::css::lang::XSingleServiceFactory > xFactory;
if
(::css::io::XTempFile::getImplementationName_Static().compareToAscii( pImplName
) == 0)
xFactory = ::css::io::XTempFile::createServiceFactory_Static (
xSMgr );
if ( xFactory.is() )
{
xFactory->acquire();
pRet = xFactory.get();
}
return pRet;
}
#ifndef _XTEMPFILE_HXX
#define _XTEMPFILE_HXX
#ifndef _COM_SUN_STAR_IO_XINPUTSTREAM_HPP_
#include <com/sun/star/io/XInputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XOUTPUTSTREAM_HPP_
#include <com/sun/star/io/XOutputStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
#include <com/sun/star/io/XSeekable.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XSTREAM_HPP_
#include <com/sun/star/io/XStream.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XTEMPFILE_HPP_
#include <com/sun/star/io/XTempFile.hpp>
#endif
#ifndef _COM_SUN_STAR_IO_XTRUNCATE_HPP_
#include <com/sun/star/io/XTruncate.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HPP_
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _CPPUHELPER_IMPLBASE5_HXX_
#include <cppuhelper/implbase5.hxx>
#endif
#ifndef _CPPUHELPER_PROPERTYSETMIXIN_HXX_
#include <cppuhelper/propertysetmixin.hxx>
#endif
#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
#endif
class SvStream;
namespace utl { class TempFile; }
typedef ::cppu::WeakImplHelper5< com::sun::star::io::XTempFile
,
::com::sun::star::io::XInputStream
,
::com::sun::star::io::XOutputStream
,
::com::sun::star::io::XTruncate
,
::com::sun::star::lang::XServiceInfo
>
OTempFileBase;
class OTempFileService :
public ::cppu::WeakImplHelper5< com::sun::star::io::XTempFile
,
::com::sun::star::io::XInputStream
,
::com::sun::star::io::XOutputStream
,
::com::sun::star::io::XTruncate
,
::com::sun::star::lang::XServiceInfo
>,
public ::cppu::PropertySetMixin< com::sun::star::io::XTempFile>
{
protected:
::utl::TempFile* mpTempFile;
::osl::Mutex maMutex;
SvStream* mpStream;
sal_Bool mbRemoveFile;
sal_Bool mbInClosed;
sal_Bool mbOutClosed;
sal_Int64 mnCachedPos;
sal_Bool mbHasCachedPos;
void checkError () const;
void checkConnected ();
//::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
GetProps();
public:
OTempFileService ();
virtual ~OTempFileService ();
//Methods
// XInterface
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const
::com::sun::star::uno::Type& aType )
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL acquire( )
throw ();
virtual void SAL_CALL release( )
throw ();
// XTypeProvider
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >
SAL_CALL getTypes( )
throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL
getImplementationId( )
throw (::com::sun::star::uno::RuntimeException);
// XTempFile
virtual ::sal_Bool SAL_CALL getRemoveFile()
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL setRemoveFile( ::sal_Bool _removefile )
throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getUri()
throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getResourceName()
throw (::com::sun::star::uno::RuntimeException);
// XInputStream
virtual ::sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence<
::sal_Int8 >& aData, ::sal_Int32 nBytesToRead )
throw (::com::sun::star::io::NotConnectedException,
::com::sun::star::io::BufferSizeExceededException,
::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL readSomeBytes(
::com::sun::star::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32
nMaxBytesToRead )
throw (::com::sun::star::io::NotConnectedException,
::com::sun::star::io::BufferSizeExceededException,
::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL skipBytes( ::sal_Int32 nBytesToSkip )
throw (::com::sun::star::io::NotConnectedException,
::com::sun::star::io::BufferSizeExceededException,
::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL available( )
throw (::com::sun::star::io::NotConnectedException,
::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL closeInput( )
throw (::com::sun::star::io::NotConnectedException,
::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
// XOutputStream
virtual void SAL_CALL writeBytes( const
::com::sun::star::uno::Sequence< ::sal_Int8 >& aData )
throw (::com::sun::star::io::NotConnectedException,
::com::sun::star::io::BufferSizeExceededException,
::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL flush( )
throw (::com::sun::star::io::NotConnectedException,
::com::sun::star::io::BufferSizeExceededException,
::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL closeOutput( )
throw (::com::sun::star::io::NotConnectedException,
::com::sun::star::io::BufferSizeExceededException,
::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
// XSeekable
virtual void SAL_CALL seek( sal_Int64 location )
throw (::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
virtual sal_Int64 SAL_CALL getPosition( )
throw (::com::sun::star::io::IOException,
::com::sun::star::uno::RuntimeException);
virtual sal_Int64 SAL_CALL getLength( )
throw (::com::sun::star::io::IOException,
::com::sun::star::uno::RuntimeException);
// XStream
virtual ::com::sun::star::uno::Reference<
::com::sun::star::io::XInputStream > SAL_CALL getInputStream( )
throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference<
::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( )
throw (::com::sun::star::uno::RuntimeException);
// XTruncate
virtual void SAL_CALL truncate( )
throw (::com::sun::star::io::IOException,
::com::sun::star::uno::RuntimeException);
// XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName( )
throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString&
ServiceName )
throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
getSupportedServiceNames( )
throw (::com::sun::star::uno::RuntimeException);
};
#endif
#ifndef _COM_SUN_STAR_IO_XTEMPFILE_HDL_
#define _COM_SUN_STAR_IO_XTEMPFILE_HDL_
#ifndef _SAL_CONFIG_H_
#include "sal/config.h"
#endif
#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HDL_
#include "com/sun/star/uno/RuntimeException.hdl"
#endif
#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HDL_
#include "com/sun/star/io/XSeekable.hdl"
#endif
#ifndef _COM_SUN_STAR_IO_XSTREAM_HDL_
#include "com/sun/star/io/XStream.hdl"
#endif
#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
#include "com/sun/star/uno/Reference.h"
#endif
#ifndef _CPPU_MACROS_HXX_
#include "cppu/macros.hxx"
#endif
#ifndef _RTL_USTRING_HXX_
#include "rtl/ustring.hxx"
#endif
#ifndef _SAL_TYPES_H_
#include "sal/types.h"
#endif
namespace com { namespace sun { namespace star { namespace uno {
class Type;
} } } }
namespace com { namespace sun { namespace star { namespace io {
class SAL_NO_VTABLE XTempFile : public ::com::sun::star::io::XStream, public
::com::sun::star::io::XSeekable
{
public:
// Attributes
virtual ::sal_Bool SAL_CALL getRemoveFile() throw
(::com::sun::star::uno::RuntimeException) = 0;
virtual void SAL_CALL setRemoveFile( ::sal_Bool _removefile ) throw
(::com::sun::star::uno::RuntimeException) = 0;
virtual ::rtl::OUString SAL_CALL getUri() throw
(::com::sun::star::uno::RuntimeException) = 0;
virtual ::rtl::OUString SAL_CALL getResourceName() throw
(::com::sun::star::uno::RuntimeException) = 0;
static inline ::com::sun::star::uno::Type const & SAL_CALL static_type(void
* = 0);
};
} } } }
inline const ::com::sun::star::uno::Type& SAL_CALL getCppuType( const
::com::sun::star::uno::Reference< ::com::sun::star::io::XTempFile >* )
SAL_THROW( () );
#endif // _COM_SUN_STAR_IO_XTEMPFILE_HDL_
#ifndef _COM_SUN_STAR_IO_XTEMPFILE_HPP_
#define _COM_SUN_STAR_IO_XTEMPFILE_HPP_
#ifndef _SAL_CONFIG_H_
#include "sal/config.h"
#endif
#ifndef _COM_SUN_STAR_IO_XTEMPFILE_HDL_
#include "com/sun/star/io/XTempFile.hdl"
#endif
#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_
#include "com/sun/star/uno/RuntimeException.hpp"
#endif
#ifndef _COM_SUN_STAR_IO_XSEEKABLE_HPP_
#include "com/sun/star/io/XSeekable.hpp"
#endif
#ifndef _COM_SUN_STAR_IO_XSTREAM_HPP_
#include "com/sun/star/io/XStream.hpp"
#endif
#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
#include "com/sun/star/uno/Reference.hxx"
#endif
#ifndef _COM_SUN_STAR_UNO_TYPE_HXX_
#include "com/sun/star/uno/Type.hxx"
#endif
#ifndef INCLUDED_CPPU_UNOTYPE_HXX
#include "cppu/unotype.hxx"
#endif
#ifndef _OSL_MUTEX_HXX_
#include "osl/mutex.hxx"
#endif
#ifndef _RTL_USTRING_HXX_
#include "rtl/ustring.hxx"
#endif
#ifndef _SAL_TYPES_H_
#include "sal/types.h"
#endif
namespace com { namespace sun { namespace star { namespace io {
inline ::com::sun::star::uno::Type const &
cppu_detail_getUnoType(::com::sun::star::io::XTempFile const *) {
static typelib_TypeDescriptionReference * the_type = 0;
if ( !the_type )
{
typelib_static_type_init( &the_type, typelib_TypeClass_INTERFACE,
"com.sun.star.io.XTempFile" );
}
return * reinterpret_cast< ::com::sun::star::uno::Type * >( &the_type );
}
} } } }
inline ::com::sun::star::uno::Type const & SAL_CALL
getCppuType(::com::sun::star::uno::Reference< ::com::sun::star::io::XTempFile >
const *) SAL_THROW(()) {
return ::cppu::UnoType< ::com::sun::star::uno::Reference<
::com::sun::star::io::XTempFile > >::get();
}
::com::sun::star::uno::Type const &
::com::sun::star::io::XTempFile::static_type(void *) {
return ::getCppuType(static_cast< ::com::sun::star::uno::Reference<
::com::sun::star::io::XTempFile > * >(0));
}
#endif // _COM_SUN_STAR_IO_XTEMPFILE_HPP_
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: ,v $
*
* $Revision: $
*
* last change: $Author: $ $Date: $
*
* 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
*
************************************************************************/
#ifndef __com_sun_star_io_XTempFile_idl__
#define __com_sun_star_io_XTempFile_idl__
#ifndef __com_sun_star_uno_XInterface_idl__
#include <com/sun/star/uno/Xinterface.idl>
#endif
#ifndef __com_sun_star_io_XStream_idl__
#include <com/sun/star/io/XStream.idl>
#endif
#ifndef __com_sun_star_io_XSeekable_idl__
#include <com/sun/star/io/XSeekable.idl>
#endif
//============================================================================
module com { module sun { module star { module io {
//=============================================================================
interface XTempFile
{
interface XStream;
interface XSeekable;
[attribute] boolean RemoveFile;
[readonly,attribute] string Uri;
[readonly,attribute] string ResourceName;
};
//============================================================================
}; }; }; };
#endif
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: ,v $
*
* $Revision: $
*
* last change: $Author: $ $Date: $
*
* 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
*
************************************************************************/
#ifndef __com_sun_star_io_TempFile_idl__
#define __com_sun_star_io_TempFile_idl__
#ifndef __com_sun_star_io_XTempFile_idl__
#include <com/sun/star/io/XTempFile.idl>
#endif
//============================================================================
module com { module sun { module star { module io {
//============================================================================
service TempFile : XTempFile;
//============================================================================
}; }; }; };
#endif
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]