Related: fdo#47644 compound storage backend is poor at knowing stream size

Change-Id: Ie4aa6939f9f37e04fda5425a6e28c5d846a9cb62
This commit is contained in:
Caolán McNamara 2012-05-03 00:05:37 +01:00
parent 80fdb3498c
commit d726281e90
7 changed files with 28 additions and 4 deletions

View File

@ -94,6 +94,7 @@ public:
virtual sal_Bool Commit() = 0;
virtual sal_Bool Revert() = 0;
virtual sal_Bool Equals( const BaseStorageStream& rStream ) const = 0;
virtual sal_Size remainingSize() = 0;
};
class BaseStorage : public StorageBase
@ -178,6 +179,7 @@ public:
virtual sal_Bool ValidateMode( StreamMode ) const;
const SvStream* GetSvStream() const;
virtual sal_Bool Equals( const BaseStorageStream& rStream ) const;
virtual sal_Size remainingSize();
};
class UCBStorageStream;
@ -270,6 +272,7 @@ public:
virtual sal_Bool Revert();
virtual sal_Bool Validate( sal_Bool=sal_False ) const;
virtual sal_Bool ValidateMode( StreamMode ) const;
virtual sal_Size remainingSize();
const SvStream* GetSvStream() const;
virtual sal_Bool Equals( const BaseStorageStream& rStream ) const;
sal_Bool SetProperty( const String& rName, const ::com::sun::star::uno::Any& rValue );

View File

@ -95,6 +95,7 @@ public:
sal_Bool GetProperty( const String& rName, ::com::sun::star::uno::Any& rValue );
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >
GetXInputStream() const;
virtual sal_Size remainingSize();
};
#ifndef SOT_DECL_SOTSTORAGESTREAM_DEFINED

View File

@ -234,6 +234,13 @@ sal_uLong StorageStream::Seek( sal_uLong n )
return n;
}
sal_Size StorageStream::remainingSize()
{
if( Validate() )
return pEntry->GetSize() - Tell();
return 0;
}
void StorageStream::Flush()
{
// Flushing means committing, since streams are never transacted

View File

@ -286,6 +286,13 @@ sal_uInt32 SotStorageStream::GetSize() const
return nSize;
}
sal_Size SotStorageStream::remainingSize()
{
if (pOwnStm)
return pOwnStm->remainingSize();
return SvStream::remainingSize();
}
/*************************************************************************
|* SotStorageStream::CopyTo()
|*

View File

@ -1554,6 +1554,11 @@ sal_Bool UCBStorageStream::GetProperty( const String& rName, ::com::sun::star::u
return sal_False;
}
sal_Size UCBStorageStream::remainingSize()
{
return pImp->GetSize() - Tell();
}
UCBStorage::UCBStorage( SvStream& rStrm, sal_Bool bDirect )
{
String aURL = GetLinkedFile( rStrm );

View File

@ -374,7 +374,7 @@ public:
sal_Size SeekRel( sal_sSize nPos );
sal_Size Tell() const { return nBufFilePos+nBufActualPos; }
//length between current (Tell()) pos and end of stream
sal_Size remainingSize();
virtual sal_Size remainingSize();
void Flush();
sal_Bool IsEof() const { return bIsEof; }
// next Tell() <= nSize
@ -789,6 +789,7 @@ public:
sal_Bool IsObjectMemoryOwner() { return bOwnsData; }
void SetResizeOffset( sal_Size nNewResize ) { nResize = nNewResize; }
sal_Size GetResizeOffset() const { return nResize; }
virtual sal_Size remainingSize() { return GetSize() - Tell(); }
};
// --------------------

View File

@ -1703,9 +1703,9 @@ sal_Size SvStream::Seek( sal_Size nFilePos )
return nBufFilePos + nBufActualPos;
}
//probably not as inefficient as it looks seeing as STREAM_SEEK_TO_END in the
//Seek backends is nomally special cased feel free to make this virtual and add
//good implementations for SvFileStream etc
//STREAM_SEEK_TO_END in the some of the Seek backends is special cased to be
//efficient, in others e.g. SotStorageStream it's really horribly slow, and in
//those this should be overridden
sal_Size SvStream::remainingSize()
{
sal_Size nCurr = Tell();