diff options
author | Mathias Bauer <mba@openoffice.org> | 2001-03-30 08:36:35 +0000 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2001-03-30 08:36:35 +0000 |
commit | 9d5843ec8ae8c23dea9f10d4f2eabfcff0bc7dd8 (patch) | |
tree | 2b1d4a53e46197675ae890a6e8851beb56d9921e /unotools | |
parent | 7770c15aba7545e3f406e668cf5ced03b22b7c27 (diff) |
#84666#: use XTruncate if present
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/ucbhelper/ucblockbytes.cxx | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx index a8cba6b0b204..23f73d604f1a 100644 --- a/unotools/source/ucbhelper/ucblockbytes.cxx +++ b/unotools/source/ucbhelper/ucblockbytes.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ucblockbytes.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: mba $ $Date: 2001-03-08 11:32:43 $ + * last change: $Author: mba $ $Date: 2001-03-30 09:36:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -113,6 +113,9 @@ #ifndef _TOOLS_INETMSG_HXX #include <tools/inetmsg.hxx> #endif +#ifndef _COM_SUN_STAR_IO_XTRUNCATE_HPP_ +#include <com/sun/star/io/XTruncate.hpp> +#endif #include <ucbhelper/contentbroker.hxx> #include <ucbhelper/content.hxx> @@ -674,6 +677,19 @@ ErrCode UcbLockBytes::SetSize (ULONG nNewSize) SvLockBytesStat aStat; Stat( &aStat, (SvLockBytesStatFlag) 0 ); ULONG nSize = aStat.nSize; + + if ( nSize > nNewSize ) + { + Reference < XTruncate > xTrunc( getSeekable_Impl(), UNO_QUERY ); + if ( xTrunc.is() ) + { + xTrunc->truncate(); + nSize = 0; + } + else + DBG_WARNING("Not truncatable!"); + } + if ( nSize < nNewSize ) { ULONG nDiff = nNewSize-nSize, nCount=0; @@ -683,10 +699,6 @@ ErrCode UcbLockBytes::SetSize (ULONG nNewSize) if ( nCount != nDiff ) return ERRCODE_IO_CANTWRITE; } - else if ( nSize > nNewSize ) - { - DBG_WARNING( "Can't shrink UCBLockBytes!" ); - } return ERRCODE_NONE; } |