diff options
author | Jürgen Schmidt <jsc@apache.org> | 2013-10-21 15:55:06 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-10-22 13:17:11 +0100 |
commit | ed445d95eda257aef5efeb4ed55ceb43a00b8343 (patch) | |
tree | 25bbba6d665e2c46baa915867c4b83503a4998d9 | |
parent | a888280ccbbfab1fbff3ff8e99c1cc500b9ff3db (diff) |
Resolves: #i75731# check output stream and...
throw IOExceptioin if it is not intialized
(cherry picked from commit cf17f922f01bd75643749a7fd01a03f8167bccee)
Change-Id: I07f6def513ef54b736689bf22565645f0c313982
-rw-r--r-- | io/source/TextOutputStream/TextOutputStream.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/io/source/TextOutputStream/TextOutputStream.cxx b/io/source/TextOutputStream/TextOutputStream.cxx index f7d309c1d162..84f9f488c247 100644 --- a/io/source/TextOutputStream/TextOutputStream.cxx +++ b/io/source/TextOutputStream/TextOutputStream.cxx @@ -63,6 +63,7 @@ class OTextOutputStream : public TextOutputStreamHelper rtl_UnicodeToTextContext mContextUnicode2Text; Sequence<sal_Int8> implConvert( const OUString& rSource ); + void checkOutputStream() throw(IOException); public: OTextOutputStream(); @@ -163,6 +164,7 @@ Sequence<sal_Int8> OTextOutputStream::implConvert( const OUString& rSource ) void OTextOutputStream::writeString( const OUString& aString ) throw(IOException, RuntimeException) { + checkOutputStream(); if( !mbEncodingInitialized ) { OUString aUtf8Str("utf8"); @@ -194,22 +196,35 @@ void OTextOutputStream::setEncoding( const OUString& Encoding ) void OTextOutputStream::writeBytes( const Sequence< sal_Int8 >& aData ) throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException) { + checkOutputStream(); mxStream->writeBytes( aData ); } void OTextOutputStream::flush( ) throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException) { + checkOutputStream(); mxStream->flush(); } void OTextOutputStream::closeOutput( ) throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException) { + checkOutputStream(); mxStream->closeOutput(); } +void OTextOutputStream::checkOutputStream() + throw(IOException) +{ + if (! mxStream.is() ) + throw IOException( + OUString("output stream is not initialized, you have to use setOutputStream first"), + Reference<XInterface>()); +} + + //=========================================================================== // XActiveDataSource |