summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/gfxlink.cxx
diff options
context:
space:
mode:
authorKai Ahrens <ka@openoffice.org>2000-11-07 16:09:05 +0000
committerKai Ahrens <ka@openoffice.org>2000-11-07 16:09:05 +0000
commit44653449c0dfcd3e8c3869801a371cadb1792a8d (patch)
tree521a9a63e8e135260851f0c0dfa706c755dc88ef /vcl/source/gdi/gfxlink.cxx
parent7e6ded5098c6e66941f8d9d9b387b58a721fc793 (diff)
must changes (File access)
Diffstat (limited to 'vcl/source/gdi/gfxlink.cxx')
-rw-r--r--vcl/source/gdi/gfxlink.cxx119
1 files changed, 45 insertions, 74 deletions
diff --git a/vcl/source/gdi/gfxlink.cxx b/vcl/source/gdi/gfxlink.cxx
index 35a350d26dd8..26356a3c8088 100644
--- a/vcl/source/gdi/gfxlink.cxx
+++ b/vcl/source/gdi/gfxlink.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: gfxlink.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: pl $ $Date: 2000-09-21 14:59:10 $
+ * last change: $Author: ka $ $Date: 2000-11-07 17:09:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,7 +62,8 @@
#include <tools/vcompat.hxx>
#include <tools/urlobj.hxx>
#include <tools/debug.hxx>
-#include <tools/tempfile.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/tempfile.hxx>
#include <ucbhelper/content.hxx>
#include "graph.hxx"
#include "gfxlink.hxx"
@@ -94,44 +95,6 @@ GfxLink::GfxLink( const GfxLink& rGfxLink )
// ------------------------------------------------------------------------
-GfxLink::GfxLink( const String& rPath, GfxLinkType nType )
-{
- sal_Int64 nFileSize = 0;
-
- try
- {
- ::ucb::Content aCnt( INetURLObject( rPath, INET_PROT_FILE ).GetMainURL(),
- ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
-
- aCnt.getPropertyValue( ::rtl::OUString::createFromAscii( "Size" ) ) >>= nFileSize;
- }
- catch( ::com::sun::star::ucb::CommandAbortedException& rE )
- {
- DBG_ERRORFILE( "CommandAbortedException" );
- }
- catch( ... )
- {
- DBG_ERRORFILE( "Any other exception" );
- }
-
- meType = nType;
- mnBufSize = nFileSize;
- mpSwap = NULL;
- mnUserId = 0UL;
-
- if( mnBufSize )
- {
- SvFileStream aFileStream( rPath, STREAM_READ );
-
- mpBuf = new ImpBuffer( mnBufSize );
- aFileStream.Read( mpBuf->mpBuffer, mnBufSize );
- }
- else
- mpBuf = NULL;
-}
-
-// ------------------------------------------------------------------------
-
GfxLink::GfxLink( BYTE* pBuf, ULONG nSize, GfxLinkType nType, BOOL bOwns )
{
meType = nType;
@@ -354,36 +317,41 @@ ImpSwap::ImpSwap( BYTE* pData, ULONG nDataSize ) :
{
if( pData && mnDataSize )
{
- maFileName = TempFile::CreateTempName();
+ ::utl::TempFile aTempFile;
- if( maFileName.Len() )
- {
- SvFileStream aOStm( maFileName, STREAM_WRITE | STREAM_SHARE_DENYWRITE );
+ maURL = aTempFile.GetURL();
- aOStm.Write( pData, mnDataSize );
+ if( maURL.GetMainURL().Len() )
+ {
+ SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( maURL.GetMainURL(), STREAM_READWRITE | STREAM_SHARE_DENYWRITE );
- if( aOStm.GetError() )
+ if( pOStm )
{
- aOStm.Close();
-
- try
- {
- ::ucb::Content aCnt( INetURLObject( maFileName, INET_PROT_FILE ).GetMainURL(),
- ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
+ pOStm->Write( pData, mnDataSize );
+ sal_Bool bError = ( ERRCODE_NONE != pOStm->GetError() );
+ delete pOStm;
- aCnt.executeCommand( ::rtl::OUString::createFromAscii( "delete" ),
- ::com::sun::star::uno::makeAny( sal_Bool( sal_True ) ) );
- }
- catch( ::com::sun::star::ucb::CommandAbortedException& rE )
- {
- DBG_ERRORFILE( "CommandAbortedException" );
- }
- catch( ... )
+ if( bError )
{
- DBG_ERRORFILE( "Any other exception" );
+ try
+ {
+ ::ucb::Content aCnt( maURL.GetMainURL(),
+ ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
+
+ aCnt.executeCommand( ::rtl::OUString::createFromAscii( "delete" ),
+ ::com::sun::star::uno::makeAny( sal_Bool( sal_True ) ) );
+ }
+ catch( ::com::sun::star::ucb::CommandAbortedException& )
+ {
+ DBG_ERRORFILE( "CommandAbortedException" );
+ }
+ catch( ... )
+ {
+ DBG_ERRORFILE( "Any other exception" );
+ }
+
+ maURL = INetURLObject();
}
-
- maFileName.Erase();
}
}
}
@@ -397,13 +365,13 @@ ImpSwap::~ImpSwap()
{
try
{
- ::ucb::Content aCnt( INetURLObject( maFileName, INET_PROT_FILE ).GetMainURL(),
+ ::ucb::Content aCnt( maURL.GetMainURL(),
::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment >() );
aCnt.executeCommand( ::rtl::OUString::createFromAscii( "delete" ),
::com::sun::star::uno::makeAny( sal_Bool( sal_True ) ) );
}
- catch( ::com::sun::star::ucb::CommandAbortedException& rE )
+ catch( ::com::sun::star::ucb::CommandAbortedException& )
{
DBG_ERRORFILE( "CommandAbortedException" );
}
@@ -422,17 +390,20 @@ BYTE* ImpSwap::GetData() const
if( IsSwapped() )
{
- SvFileStream aIStm( maFileName, STREAM_READ );
-
- pData = new BYTE[ mnDataSize ];
- aIStm.Read( pData, mnDataSize );
+ SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( maURL.GetMainURL(), STREAM_READWRITE );
- if( aIStm.GetError() )
+ if( pIStm )
{
- aIStm.Close();
- delete[] pData;
- pData = NULL;
+ pData = new BYTE[ mnDataSize ];
+ pIStm->Read( pData, mnDataSize );
+ sal_Bool bError = ( ERRCODE_NONE != pIStm->GetError() );
+ delete pIStm;
+
+ if( bError )
+ delete[] pData, pData = NULL;
}
+ else
+ pData = NULL;
}
else
pData = NULL;