From 9d5843ec8ae8c23dea9f10d4f2eabfcff0bc7dd8 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Fri, 30 Mar 2001 08:36:35 +0000 Subject: #84666#: use XTruncate if present --- unotools/source/ucbhelper/ucblockbytes.cxx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'unotools') 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 #endif +#ifndef _COM_SUN_STAR_IO_XTRUNCATE_HPP_ +#include +#endif #include #include @@ -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; } -- cgit