summaryrefslogtreecommitdiff
path: root/unotools/source/ucbhelper/ucbstreamhelper.cxx
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2004-05-28 14:19:02 +0000
committerOliver Bolte <obo@openoffice.org>2004-05-28 14:19:02 +0000
commit208de4e92f7894d2a2e952014faaa6e440c2a054 (patch)
tree6eae1704b8c76a4dc9bc129fca4145a2fbbc04c5 /unotools/source/ucbhelper/ucbstreamhelper.cxx
parentbb3f36a8d3c5c4be999d0af7f8319d8ab6e1fe86 (diff)
INTEGRATION: CWS tdocfixes1 (1.13.8); FILE MERGED
2004/05/14 15:17:52 kso 1.13.8.1: #29204# - Added new member function to class UcbStreamHelper
Diffstat (limited to 'unotools/source/ucbhelper/ucbstreamhelper.cxx')
-rw-r--r--unotools/source/ucbhelper/ucbstreamhelper.cxx89
1 files changed, 54 insertions, 35 deletions
diff --git a/unotools/source/ucbhelper/ucbstreamhelper.cxx b/unotools/source/ucbhelper/ucbstreamhelper.cxx
index 93425bfdcf61..536fd0be6d1f 100644
--- a/unotools/source/ucbhelper/ucbstreamhelper.cxx
+++ b/unotools/source/ucbhelper/ucbstreamhelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ucbstreamhelper.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: svesik $ $Date: 2004-04-21 12:29:09 $
+ * last change: $Author: obo $ $Date: 2004-05-28 15:19:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -94,15 +94,9 @@ using namespace ::com::sun::star::beans;
namespace utl
{
-SvStream* UcbStreamHelper::CreateStream( const String& rFileName, StreamMode eOpenMode,
- UcbLockBytesHandler* pHandler, sal_Bool bForceSynchron )
-{
- return CreateStream( rFileName, eOpenMode, Reference < XInteractionHandler >(), pHandler, bForceSynchron );
-}
-
-SvStream* UcbStreamHelper::CreateStream( const String& rFileName, StreamMode eOpenMode,
+static SvStream* lcl_CreateStream( const String& rFileName, StreamMode eOpenMode,
Reference < XInteractionHandler > xInteractionHandler,
- UcbLockBytesHandler* pHandler, sal_Bool bForceSynchron )
+ UcbLockBytesHandler* pHandler, sal_Bool bForceSynchron, sal_Bool bEnsureFileExists )
{
SvStream* pStream = NULL;
::ucb::ContentBroker* pBroker = ::ucb::ContentBroker::get();
@@ -133,33 +127,36 @@ SvStream* UcbStreamHelper::CreateStream( const String& rFileName, StreamMode eOp
}
}
- try
+ if ( bEnsureFileExists )
{
- // make sure that the desired file exists before trying to open
- SvMemoryStream aStream(0,0);
- ::utl::OInputStreamWrapper* pInput = new ::utl::OInputStreamWrapper( aStream );
- Reference< XInputStream > xInput( pInput );
-
- ::ucb::Content aContent( rFileName, Reference < XCommandEnvironment >() );
- InsertCommandArgument aInsertArg;
- aInsertArg.Data = xInput;
-
- aInsertArg.ReplaceExisting = sal_False;
- Any aCmdArg;
- aCmdArg <<= aInsertArg;
- aContent.executeCommand( ::rtl::OUString::createFromAscii( "insert" ), aCmdArg );
- }
+ try
+ {
+ // make sure that the desired file exists before trying to open
+ SvMemoryStream aStream(0,0);
+ ::utl::OInputStreamWrapper* pInput = new ::utl::OInputStreamWrapper( aStream );
+ Reference< XInputStream > xInput( pInput );
+
+ ::ucb::Content aContent( rFileName, Reference < XCommandEnvironment >() );
+ InsertCommandArgument aInsertArg;
+ aInsertArg.Data = xInput;
+
+ aInsertArg.ReplaceExisting = sal_False;
+ Any aCmdArg;
+ aCmdArg <<= aInsertArg;
+ aContent.executeCommand( ::rtl::OUString::createFromAscii( "insert" ), aCmdArg );
+ }
- // it is NOT an error when the stream already exists and no truncation was desired
- catch ( CommandAbortedException& )
- {
- // currently never an error is detected !
- }
- catch ( ContentCreationException& )
- {
- }
- catch ( Exception& )
- {
+ // it is NOT an error when the stream already exists and no truncation was desired
+ catch ( CommandAbortedException& )
+ {
+ // currently never an error is detected !
+ }
+ catch ( ContentCreationException& )
+ {
+ }
+ catch ( Exception& )
+ {
+ }
}
}
@@ -193,6 +190,28 @@ SvStream* UcbStreamHelper::CreateStream( const String& rFileName, StreamMode eOp
return pStream;
}
+//============================================================================
+
+SvStream* UcbStreamHelper::CreateStream( const String& rFileName, StreamMode eOpenMode,
+ UcbLockBytesHandler* pHandler, sal_Bool bForceSynchron )
+{
+ return lcl_CreateStream( rFileName, eOpenMode, Reference < XInteractionHandler >(), pHandler, bForceSynchron, sal_True /* bEnsureFileExists */ );
+}
+
+SvStream* UcbStreamHelper::CreateStream( const String& rFileName, StreamMode eOpenMode,
+ Reference < XInteractionHandler > xInteractionHandler,
+ UcbLockBytesHandler* pHandler, sal_Bool bForceSynchron )
+{
+ return lcl_CreateStream( rFileName, eOpenMode, xInteractionHandler, pHandler, bForceSynchron, sal_True /* bEnsureFileExists */ );
+}
+
+SvStream* UcbStreamHelper::CreateStream( const String& rFileName, StreamMode eOpenMode,
+ sal_Bool bFileExists,
+ UcbLockBytesHandler* pHandler, sal_Bool bForceSynchron )
+{
+ return lcl_CreateStream( rFileName, eOpenMode, Reference < XInteractionHandler >(), pHandler, bForceSynchron, !bFileExists );
+}
+
SvStream* UcbStreamHelper::CreateStream( Reference < XInputStream > xStream )
{
SvStream* pStream = NULL;