summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-05-03 00:05:37 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-05-03 00:06:33 +0100
commitd726281e9020ebaddfdf6659ecfe7a0454014dff (patch)
tree439e6e848904ec034c8630444d5dbe3e6443ab06
parent80fdb3498c68f9e7f9bdd98674e762cb084fce57 (diff)
Related: fdo#47644 compound storage backend is poor at knowing stream size
Change-Id: Ie4aa6939f9f37e04fda5425a6e28c5d846a9cb62
-rw-r--r--sot/inc/sot/stg.hxx3
-rw-r--r--sot/inc/sot/storage.hxx1
-rw-r--r--sot/source/sdstor/stg.cxx7
-rw-r--r--sot/source/sdstor/storage.cxx7
-rw-r--r--sot/source/sdstor/ucbstorage.cxx5
-rw-r--r--tools/inc/tools/stream.hxx3
-rw-r--r--tools/source/stream/stream.cxx6
7 files changed, 28 insertions, 4 deletions
diff --git a/sot/inc/sot/stg.hxx b/sot/inc/sot/stg.hxx
index 225c89eee23a..ab567f3c5b64 100644
--- a/sot/inc/sot/stg.hxx
+++ b/sot/inc/sot/stg.hxx
@@ -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 );
diff --git a/sot/inc/sot/storage.hxx b/sot/inc/sot/storage.hxx
index b77d6dd13a31..925ae42f89c1 100644
--- a/sot/inc/sot/storage.hxx
+++ b/sot/inc/sot/storage.hxx
@@ -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
diff --git a/sot/source/sdstor/stg.cxx b/sot/source/sdstor/stg.cxx
index 27c95c82162d..4f4e991ae6ec 100644
--- a/sot/source/sdstor/stg.cxx
+++ b/sot/source/sdstor/stg.cxx
@@ -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
diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx
index 1006b7c1e5b1..67b270f33863 100644
--- a/sot/source/sdstor/storage.cxx
+++ b/sot/source/sdstor/storage.cxx
@@ -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()
|*
diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx
index 0254ef2f446d..2a1a00047221 100644
--- a/sot/source/sdstor/ucbstorage.cxx
+++ b/sot/source/sdstor/ucbstorage.cxx
@@ -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 );
diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx
index dc4505a06a35..d60f9e6ed904 100644
--- a/tools/inc/tools/stream.hxx
+++ b/tools/inc/tools/stream.hxx
@@ -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(); }
};
// --------------------
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 96cabc266c34..c1f06a78d97f 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -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();