summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürgen Schmidt <jsc@apache.org>2013-10-21 15:55:06 +0000
committerJürgen Schmidt <jsc@apache.org>2013-10-21 15:55:06 +0000
commitcf17f922f01bd75643749a7fd01a03f8167bccee (patch)
tree5b555986be900348d1da2a28ae429d9a0bdb97c2
parentdd1cb9aa9ea24b6c89de05e6c5deae7951b78feb (diff)
#75731# check output stream and throw IOExceptioin if it is not intiliazed
Notes
-rw-r--r--io/source/TextOutputStream/TextOutputStream.cxx15
1 files changed, 15 insertions, 0 deletions
diff --git a/io/source/TextOutputStream/TextOutputStream.cxx b/io/source/TextOutputStream/TextOutputStream.cxx
index 878a18553ae0..e2ac57e70255 100644
--- a/io/source/TextOutputStream/TextOutputStream.cxx
+++ b/io/source/TextOutputStream/TextOutputStream.cxx
@@ -74,6 +74,7 @@ class OTextOutputStream : public TextOutputStreamHelper
rtl_UnicodeToTextContext mContextUnicode2Text;
Sequence<sal_Int8> implConvert( const OUString& rSource );
+ void checkOutputStream() throw(IOException);
public:
OTextOutputStream();
@@ -174,6 +175,7 @@ Sequence<sal_Int8> OTextOutputStream::implConvert( const OUString& rSource )
void OTextOutputStream::writeString( const OUString& aString )
throw(IOException, RuntimeException)
{
+ checkOutputStream();
if( !mbEncodingInitialized )
{
OUString aUtf8Str( RTL_CONSTASCII_USTRINGPARAM("utf8") );
@@ -205,22 +207,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(RTL_CONSTASCII_USTRINGPARAM("output stream is not initialized, you have to use setOutputStream first")),
+ Reference<XInterface>());
+}
+
+
//===========================================================================
// XActiveDataSource