diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-05-10 15:41:17 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-05-10 17:00:27 +0100 |
commit | aef4d0ea8ba7f5e169dc04812490a103cd858f0c (patch) | |
tree | b200b35862f20c996040d69fb8f30dfdea670c34 | |
parent | dfcc1669f68783e8f648cef57d3e36277ae27cec (diff) |
Resolves: fdo#47644 compound storage backend is poor at knowing stream size
Signed-off-by: Michael Meeks <michael.meeks@suse.com>
-rw-r--r-- | sot/inc/sot/stg.hxx | 3 | ||||
-rw-r--r-- | sot/inc/sot/storage.hxx | 1 | ||||
-rw-r--r-- | sot/source/sdstor/stg.cxx | 7 | ||||
-rw-r--r-- | sot/source/sdstor/storage.cxx | 7 | ||||
-rw-r--r-- | sot/source/sdstor/ucbstorage.cxx | 5 | ||||
-rw-r--r-- | tools/inc/tools/stream.hxx | 3 | ||||
-rw-r--r-- | tools/source/stream/stream.cxx | 6 |
7 files changed, 28 insertions, 4 deletions
diff --git a/sot/inc/sot/stg.hxx b/sot/inc/sot/stg.hxx index c8d18da67a8a..307101703b85 100644 --- a/sot/inc/sot/stg.hxx +++ b/sot/inc/sot/stg.hxx @@ -90,6 +90,7 @@ public: virtual sal_uLong Tell() = 0; virtual void Flush() = 0; virtual sal_Bool SetSize( sal_uLong nNewSize ) = 0; + virtual sal_uLong GetSize() const = 0; virtual sal_Bool CopyTo( BaseStorageStream * pDestStm ) = 0; virtual sal_Bool Commit() = 0; virtual sal_Bool Revert() = 0; @@ -171,6 +172,7 @@ public: virtual sal_uLong Tell() { return nPos; } virtual void Flush(); virtual sal_Bool SetSize( sal_uLong nNewSize ); + virtual sal_uLong GetSize() const; virtual sal_Bool CopyTo( BaseStorageStream * pDestStm ); virtual sal_Bool Commit(); virtual sal_Bool Revert(); @@ -266,6 +268,7 @@ public: virtual sal_uLong Tell(); virtual void Flush(); virtual sal_Bool SetSize( sal_uLong nNewSize ); + virtual sal_uLong GetSize() const; virtual sal_Bool CopyTo( BaseStorageStream * pDestStm ); virtual sal_Bool Commit(); virtual sal_Bool Revert(); diff --git a/sot/inc/sot/storage.hxx b/sot/inc/sot/storage.hxx index 26258bc4b51e..4f602e9917f9 100644 --- a/sot/inc/sot/storage.hxx +++ b/sot/inc/sot/storage.hxx @@ -96,6 +96,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 diff --git a/sot/source/sdstor/stg.cxx b/sot/source/sdstor/stg.cxx index 4c4be65d2986..18e95f680763 100644 --- a/sot/source/sdstor/stg.cxx +++ b/sot/source/sdstor/stg.cxx @@ -252,6 +252,13 @@ sal_Bool StorageStream::SetSize( sal_uLong nNewSize ) return sal_False; } +sal_uLong StorageStream::GetSize() const +{ + if( Validate() ) + return pEntry->GetSize(); + return 0; +} + sal_Bool StorageStream::Commit() { if( !Validate() ) diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx index 897f9fe7a61b..4d24f1fea0f3 100644 --- a/sot/source/sdstor/storage.cxx +++ b/sot/source/sdstor/storage.cxx @@ -298,6 +298,13 @@ sal_uInt32 SotStorageStream::GetSize() const return nSize; } +sal_Size SotStorageStream::remainingSize() +{ + if (pOwnStm) + return pOwnStm->GetSize() - Tell(); + return SvStream::remainingSize(); +} + /************************************************************************* |* SotStorageStream::CopyTo() |* diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx index b6fb581057fc..020fb9ac8960 100644 --- a/sot/source/sdstor/ucbstorage.cxx +++ b/sot/source/sdstor/ucbstorage.cxx @@ -1566,6 +1566,11 @@ sal_Bool UCBStorageStream::GetProperty( const String& rName, ::com::sun::star::u return sal_False; } +sal_uLong UCBStorageStream::GetSize() const +{ + return pImp->GetSize(); +} + UCBStorage::UCBStorage( SvStream& rStrm, sal_Bool bDirect ) { String aURL = GetLinkedFile( rStrm ); diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx index 0ad95857ad7a..e577ca892b08 100644 --- a/tools/inc/tools/stream.hxx +++ b/tools/inc/tools/stream.hxx @@ -379,7 +379,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 @@ -678,6 +678,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(); } }; // -------------------- diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index 3e870b45ac56..84d652c3eb3d 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1820,9 +1820,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(); |