summaryrefslogtreecommitdiff
path: root/writerperfect/source/stream/WPXSvStream.cxx
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2005-03-23 13:01:17 +0000
committerVladimir Glazounov <vg@openoffice.org>2005-03-23 13:01:17 +0000
commit00691716798852c60f828355ab0b8d3b266bc8dd (patch)
treeb6435547f80bdf3655984a5349f4cf36d771aac8 /writerperfect/source/stream/WPXSvStream.cxx
parent485d59eceef2933304f9fb83ad7ab27c1b57f41c (diff)
INTEGRATION: CWS fwkfinal1 (1.4.2); FILE MERGED
2005/03/07 10:29:37 as 1.4.2.1: #i43995# handle unknown formats more gracefully
Diffstat (limited to 'writerperfect/source/stream/WPXSvStream.cxx')
-rw-r--r--writerperfect/source/stream/WPXSvStream.cxx40
1 files changed, 33 insertions, 7 deletions
diff --git a/writerperfect/source/stream/WPXSvStream.cxx b/writerperfect/source/stream/WPXSvStream.cxx
index 2ce67a489189..b37f9d0e9099 100644
--- a/writerperfect/source/stream/WPXSvStream.cxx
+++ b/writerperfect/source/stream/WPXSvStream.cxx
@@ -1,5 +1,4 @@
#include "WPXSvStream.h"
-
#include <tools/stream.hxx>
#include <unotools/streamwrap.hxx>
#include <unotools/ucbstreamhelper.hxx>
@@ -18,11 +17,27 @@ WPXSvInputStream::WPXSvInputStream( Reference< XInputStream > xStream ) :
mxStream(xStream),
mnOffset(0)
{
- Reference < XSeekable> xSeekable = Reference < XSeekable > (xStream, UNO_QUERY);
- if (!xSeekable.is())
+ if (!xStream.is())
+ {
mnLength = 0;
+ }
else
- mnLength = xSeekable->getLength(); // exception
+ {
+ Reference < XSeekable> xSeekable = Reference < XSeekable > (xStream, UNO_QUERY);
+ if (!xSeekable.is())
+ mnLength = 0;
+ else
+ {
+ try
+ {
+ mnLength = xSeekable->getLength(); // exception
+ }
+ catch ( ... )
+ {
+ mnLength = 0;
+ }
+ }
+ }
}
WPXSvInputStream::~WPXSvInputStream()
@@ -42,9 +57,14 @@ int WPXSvInputStream::seek(long offset, WPX_SEEK_TYPE seekType)
{
if (seekType == WPX_SEEK_CUR && offset >= 0)
{
- mxStream->skipBytes (offset); // exception ?
- mnOffset += offset;
- return FALSE;
+ if (mnOffset + offset <= mnLength)
+ {
+ mxStream->skipBytes (offset); // exception ?
+ mnOffset += offset;
+ return FALSE;
+ }
+ else
+ return TRUE;
}
Reference < XSeekable> xSeekable = Reference < XSeekable >(mxStream, UNO_QUERY);
@@ -56,6 +76,9 @@ int WPXSvInputStream::seek(long offset, WPX_SEEK_TYPE seekType)
else
mnOffset = offset;
+ if (mnOffset > mnLength)
+ return TRUE;
+
xSeekable->seek(mnOffset); // FIXME: catch exception!
return FALSE;
@@ -94,6 +117,9 @@ WPXInputStream * WPXSvInputStream::getDocumentOLEStream()
rtl::OUString::createFromAscii( "PerfectOffice_MAIN" ),
STREAM_STD_READ );
+ if ( !mxChildStream.Is() || mxChildStream->GetError() )
+ return NULL;
+
Reference < XInputStream > xContents = new utl::OSeekableInputStreamWrapper( mxChildStream );
if (xContents.is())
return new WPXSvInputStream( xContents );