summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorVladimir Glazunov <vg@openoffice.org>2009-12-15 12:36:38 +0100
committerVladimir Glazunov <vg@openoffice.org>2009-12-15 12:36:38 +0100
commit11a7d7ddcb5f6a0708b3f9b685760e97c6c43ed9 (patch)
tree33063e9626d433c02788f62f59b66492028ccaa2 /sfx2
parent07d8b0db978fa194e069fc7b89f0b5f24efa1abd (diff)
parent04a4f6cec0db528341395499ecb33cd2a292367e (diff)
CWS-TOOLING: integrate CWS fwk132_DEV300
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/docfile.cxx27
-rw-r--r--sfx2/source/doc/objstor.cxx14
2 files changed, 32 insertions, 9 deletions
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 5db5d2afcb17..fcbd353b990c 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -3436,13 +3436,14 @@ void SfxMedium::CreateTempFile( sal_Bool bReplace )
if ( !( nStorOpenMode & STREAM_TRUNC ) )
{
+ sal_Bool bTransferSuccess = sal_False;
+
if ( GetContent().is()
&& ::utl::LocalFileHelper::IsLocalFile( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) )
&& ::utl::UCBContentHelper::IsDocument( GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) ) )
{
// if there is already such a document, we should copy it
// if it is a file system use OS copy process
- sal_Bool bTransferSuccess = sal_False;
try
{
uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > xComEnv;
@@ -3463,16 +3464,14 @@ void SfxMedium::CreateTempFile( sal_Bool bReplace )
catch( uno::Exception& )
{}
- if ( !bTransferSuccess )
+ if ( bTransferSuccess )
{
- SetError( ERRCODE_IO_CANTWRITE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
- return;
+ CloseOutStream();
+ CloseInStream();
}
-
- CloseOutStream();
- CloseInStream();
}
- else if ( pInStream )
+
+ if ( !bTransferSuccess && pInStream )
{
// the case when there is no URL-access available or this is a remote protocoll
// but there is an input stream
@@ -3492,13 +3491,25 @@ void SfxMedium::CreateTempFile( sal_Bool bReplace )
pOutStream->Write( pBuf, nRead );
}
+ bTransferSuccess = sal_True;
delete[] pBuf;
CloseInStream();
}
CloseOutStream_Impl();
}
else
+ {
+ // Quite strange design, but currently it is expected that in this case no transfer happens
+ // TODO/LATER: get rid of this inconsistent part of the call design
+ bTransferSuccess = sal_True;
CloseInStream();
+ }
+
+ if ( !bTransferSuccess )
+ {
+ SetError( ERRCODE_IO_CANTWRITE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ return;
+ }
}
CloseStorage();
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 287cb5b96179..ead9a7c9fd9a 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -1871,7 +1871,19 @@ sal_Bool SfxObjectShell::DisconnectStorage_Impl( SfxMedium& rSrcMedium, SfxMediu
{
uno::Reference< embed::XOptimizedStorage > xOptStorage( xStorage, uno::UNO_QUERY_THROW );
::rtl::OUString aBackupURL = rTargetMedium.GetBackup_Impl();
- if ( aBackupURL.getLength() )
+ if ( !aBackupURL.getLength() )
+ {
+ // the backup could not be created, try to disconnect the storage and close the source SfxMedium
+ // in this case the optimization is not possible, connect storage to a temporary file
+ rTargetMedium.ResetError();
+ xOptStorage->writeAndAttachToStream( uno::Reference< io::XStream >() );
+ rSrcMedium.CanDisposeStorage_Impl( sal_False );
+ rSrcMedium.Close();
+
+ // now try to create the backup
+ rTargetMedium.GetBackup_Impl();
+ }
+ else
{
// the following call will only compare stream sizes
// TODO/LATER: this is a very risky part, since if the URL contents are different from the storage