summaryrefslogtreecommitdiff
path: root/xmlscript
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2016-04-03 22:25:19 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-04-05 06:25:39 +0000
commitdb43ef00c12bc0f7fefd6d028c9a2ed8f771cd47 (patch)
tree62f08a44e99513251324f8972d257d8fd3be2b2c /xmlscript
parente72c80c01629798a93948d4419f109ac324de4ef (diff)
sequence->vector in xmlscript
Change-Id: I4f99cd9dc659f54bd4818559dd3e0dbce1e8f5d4 Reviewed-on: https://gerrit.libreoffice.org/23795 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'xmlscript')
-rw-r--r--xmlscript/source/xml_helper/xml_byteseq.cxx36
-rw-r--r--xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx6
2 files changed, 25 insertions, 17 deletions
diff --git a/xmlscript/source/xml_helper/xml_byteseq.cxx b/xmlscript/source/xml_helper/xml_byteseq.cxx
index 82ef110245b9..56cc5d29df0c 100644
--- a/xmlscript/source/xml_helper/xml_byteseq.cxx
+++ b/xmlscript/source/xml_helper/xml_byteseq.cxx
@@ -34,11 +34,11 @@ namespace xmlscript
class BSeqInputStream
: public ::cppu::WeakImplHelper< io::XInputStream >
{
- ByteSequence _seq;
+ std::vector<sal_Int8> _seq;
sal_Int32 _nPos;
public:
- explicit BSeqInputStream( ByteSequence const & rSeq )
+ explicit BSeqInputStream( std::vector<sal_Int8> const & rSeq )
: _seq( rSeq )
, _nPos( 0 )
{}
@@ -63,12 +63,13 @@ sal_Int32 BSeqInputStream::readBytes(
Sequence< sal_Int8 > & rData, sal_Int32 nBytesToRead )
throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException, std::exception)
{
- nBytesToRead = ((nBytesToRead > _seq.getLength() - _nPos)
- ? _seq.getLength() - _nPos
+ nBytesToRead = ((nBytesToRead > (sal_Int32)_seq.size() - _nPos)
+ ? _seq.size() - _nPos
: nBytesToRead);
- ByteSequence aBytes( _seq.getConstArray() + _nPos, nBytesToRead );
- rData = toUnoSequence( aBytes );
+ if (rData.getLength() != nBytesToRead)
+ rData.realloc( nBytesToRead );
+ memcpy(rData.getArray(), &_seq.data()[_nPos], nBytesToRead);
_nPos += nBytesToRead;
return nBytesToRead;
}
@@ -89,7 +90,7 @@ void BSeqInputStream::skipBytes(
sal_Int32 BSeqInputStream::available()
throw (io::NotConnectedException, io::IOException, RuntimeException, std::exception)
{
- return (_seq.getLength() - _nPos);
+ return _seq.size() - _nPos;
}
void BSeqInputStream::closeInput()
@@ -100,10 +101,10 @@ void BSeqInputStream::closeInput()
class BSeqOutputStream
: public ::cppu::WeakImplHelper< io::XOutputStream >
{
- ByteSequence * _seq;
+ std::vector<sal_Int8> * _seq;
public:
- explicit BSeqOutputStream( ByteSequence * seq )
+ explicit BSeqOutputStream( std::vector<sal_Int8> * seq )
: _seq( seq )
{}
@@ -120,9 +121,9 @@ public:
void BSeqOutputStream::writeBytes( Sequence< sal_Int8 > const & rData )
throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException, std::exception)
{
- sal_Int32 nPos = _seq->getLength();
- _seq->realloc( nPos + rData.getLength() );
- memcpy( _seq->getArray() + nPos,
+ sal_Int32 nPos = _seq->size();
+ _seq->resize( nPos + rData.getLength() );
+ memcpy( _seq->data() + nPos,
rData.getConstArray(),
rData.getLength() );
}
@@ -136,12 +137,19 @@ void BSeqOutputStream::closeOutput()
{
}
-Reference< io::XInputStream > SAL_CALL createInputStream( ByteSequence const & rInData )
+Reference< io::XInputStream > SAL_CALL createInputStream( std::vector<sal_Int8> const & rInData )
{
return new BSeqInputStream( rInData );
}
-Reference< io::XOutputStream > SAL_CALL createOutputStream( ByteSequence * pOutData )
+Reference< io::XInputStream > SAL_CALL createInputStream( const sal_Int8* pData, int len )
+{
+ std::vector<sal_Int8> rInData(len);
+ memcpy( rInData.data(), pData, len);
+ return new BSeqInputStream( rInData );
+}
+
+Reference< io::XOutputStream > SAL_CALL createOutputStream( std::vector<sal_Int8> * pOutData )
{
return new BSeqOutputStream( pOutData );
}
diff --git a/xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx b/xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx
index 101ce157d8db..beb697136e89 100644
--- a/xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx
+++ b/xmlscript/source/xmldlg_imexp/xmldlg_addfunc.cxx
@@ -38,10 +38,10 @@ namespace xmlscript
class InputStreamProvider
: public ::cppu::WeakImplHelper< io::XInputStreamProvider >
{
- ByteSequence _bytes;
+ std::vector<sal_Int8> _bytes;
public:
- explicit InputStreamProvider( ByteSequence const & rBytes )
+ explicit InputStreamProvider( std::vector<sal_Int8> const & rBytes )
: _bytes( rBytes )
{
}
@@ -63,7 +63,7 @@ Reference< io::XInputStreamProvider > SAL_CALL exportDialogModel(
{
Reference< xml::sax::XWriter > xWriter = xml::sax::Writer::create(xContext);
- ByteSequence aBytes;
+ std::vector<sal_Int8> aBytes;
xWriter->setOutputStream( createOutputStream( &aBytes ) );
Reference< xml::sax::XExtendedDocumentHandler > xHandler(xWriter, UNO_QUERY_THROW);