summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMikhail Voitenko <mav@openoffice.org>2002-08-05 08:51:22 +0000
committerMikhail Voitenko <mav@openoffice.org>2002-08-05 08:51:22 +0000
commit0678f6604d48a7bdc78b335d777328d4856ece78 (patch)
tree9e8d938ea28d87a5d43d40fc029c261ac63e74d6 /sfx2
parent8bdb4dd984085897c954669261b2b1ca33f0927d (diff)
#102023# temporary file for readonly mode should be in temporary location
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/docfile.cxx60
1 files changed, 57 insertions, 3 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 96eddcbb1b9a..73be6d506b1e 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: docfile.cxx,v $
*
- * $Revision: 1.109 $
+ * $Revision: 1.110 $
*
- * last change: $Author: mav $ $Date: 2002-07-30 14:42:52 $
+ * last change: $Author: mav $ $Date: 2002-08-05 09:51:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -960,7 +960,9 @@ SvStorage* SfxMedium::GetStorage_Impl( BOOL bUCBStorage )
{
// open storage with the URL of the tempfile
if ( !::utl::LocalFileHelper::ConvertPhysicalNameToURL( aName, aStorageName ) )
+ {
DBG_ERROR("Physical name not convertable!");
+ }
CloseOutStream();
aStorage = new SvStorage( bUCBStorage, aStorageName, nStorOpenMode, bDirect ? 0 : STORAGE_TRANSACTED );
}
@@ -969,7 +971,9 @@ SvStorage* SfxMedium::GetStorage_Impl( BOOL bUCBStorage )
if ( aName.Len() )
{
if ( !::utl::LocalFileHelper::ConvertPhysicalNameToURL( aName, aStorageName ) )
+ {
DBG_ERROR("Physical name not convertable!");
+ }
}
else
aStorageName = GetURLObject().GetMainURL( INetURLObject::NO_DECODE );
@@ -996,7 +1000,7 @@ SvStorage* SfxMedium::GetStorage_Impl( BOOL bUCBStorage )
if ( IsReadOnly() && ::utl::LocalFileHelper::IsLocalFile( aLogicName ) )
{
- CreateTempFile();
+ CreateLocalTempFile();
aStorage = new SvStorage( aName, nStorOpenMode, bDirect ? 0 : STORAGE_TRANSACTED );
}
else
@@ -2530,6 +2534,56 @@ sal_Bool SfxMedium::IsReadOnly()
}
//----------------------------------------------------------------
+void SfxMedium::CreateLocalTempFile()
+{
+ if ( pImp->pTempFile )
+ DELETEZ( pImp->pTempFile );
+
+ StreamMode nOpenMode = nStorOpenMode;
+ GetInStream();
+ BOOL bCopy = ( nStorOpenMode == nOpenMode && ! ( nOpenMode & STREAM_TRUNC ) );
+ nStorOpenMode = nOpenMode;
+ ResetError();
+
+ pImp->pTempFile = new ::utl::TempFile();
+ pImp->pTempFile->EnableKillingFile( sal_True );
+ aName = pImp->pTempFile->GetFileName();
+ if ( !aName.Len() )
+ {
+ SetError( ERRCODE_IO_CANTWRITE );
+ return;
+ }
+
+ if ( bCopy )
+ {
+ GetOutStream();
+ if ( pInStream && pOutStream )
+ {
+ char *pBuf = new char [8192];
+ sal_uInt32 nErr = ERRCODE_NONE;
+
+ pInStream->Seek(0);
+ pOutStream->Seek(0);
+
+ while( !pInStream->IsEof() && nErr == ERRCODE_NONE )
+ {
+ sal_uInt32 nRead = pInStream->Read( pBuf, 8192 );
+ nErr = pInStream->GetError();
+ pOutStream->Write( pBuf, nRead );
+ }
+
+ delete pBuf;
+ CloseInStream();
+ }
+ CloseOutStream_Impl();
+ }
+ else
+ CloseInStream();
+
+ CloseStorage();
+}
+
+//----------------------------------------------------------------
void SfxMedium::CreateTempFile()
{
if ( pImp->pTempFile )