summaryrefslogtreecommitdiff
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
commitd9dc989099c27b9c9560a6891e6c2a76eb422d90 (patch)
tree1dea17e8fc805abf19c3c957f126d6e8d4de2a8e
parent07b111e68dd8d13ece3d8c56687ff5dc65df6b51 (diff)
parent34a611badb462fd0c7894369900b29a9faee44e8 (diff)
CWS-TOOLING: integrate CWS fwk132_DEV300
-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 47ea67033e..d55be619bc 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 8f9da20970..98afd75354 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