22#include <com/sun/star/io/BufferSizeExceededException.hpp>
23#include <com/sun/star/io/NotConnectedException.hpp>
24#include <com/sun/star/lang/IllegalArgumentException.hpp>
27#include <osl/diagnose.h>
40 const sal_Int8* pData, sal_Int32 nDataLength)
42, m_nMemoryDataLength(nDataLength)
52 throw NotConnectedException(OUString(), *
this);
62 throw BufferSizeExceededException(OUString(),*
this);
66 sal_Int32 nAvail =
avail();
68 if (nAvail < nBytesToRead)
69 nBytesToRead = nAvail;
71 aData.realloc(nBytesToRead);
81 throw BufferSizeExceededException(OUString(),*
this);
85 sal_Int32 nAvail =
avail();
87 if (nAvail < nBytesToRead)
88 nBytesToRead = nAvail;
105 if (nBytesToSkip < 0)
106 throw BufferSizeExceededException(OUString(),*
this);
108 std::scoped_lock aGuard(
m_aMutex );
110 sal_Int32 nAvail =
avail();
112 if (nAvail < nBytesToSkip)
113 nBytesToSkip = nAvail;
121 std::scoped_lock aGuard(
m_aMutex );
129 std::scoped_lock aGuard(
m_aMutex );
132 throw NotConnectedException(OUString(), *
this);
140 throw IllegalArgumentException(
"bad location",
static_cast<cppu::OWeakObject*
>(
this), 1);
141 std::scoped_lock aGuard(
m_aMutex );
142 m_nPos =
static_cast<sal_Int32
>(location);
147 std::scoped_lock aGuard(
m_aMutex );
153 std::scoped_lock aGuard(
m_aMutex );
159 css::uno::Sequence<sal_Int8>
const & rData)
166OSequenceOutputStream::OSequenceOutputStream(
Sequence< sal_Int8 >& _rSeq,
double _nResizeFactor, sal_Int32 _nMinimumResize)
168 ,m_nResizeFactor(_nResizeFactor)
169 ,m_nMinimumResize(_nMinimumResize)
173 OSL_ENSURE(m_nResizeFactor > 1,
"OSequenceOutputStream::OSequenceOutputStream : invalid resize factor !");
175 if (m_nResizeFactor <= 1)
176 m_nResizeFactor = 1.3;
184 throw NotConnectedException();
187 if (m_nSize + _rData.getLength() > m_rSequence.getLength())
189 sal_Int32 nCurrentLength = m_rSequence.getLength();
190 sal_Int32 nNewLength =
static_cast< sal_Int32
>(
191 nCurrentLength * m_nResizeFactor);
193 if (m_nMinimumResize > nNewLength - nCurrentLength)
195 nNewLength = nCurrentLength + m_nMinimumResize;
197 if (nNewLength < m_nSize + _rData.getLength())
202 sal_Int32 nNewGrowth = _rData.getLength() * 2;
203 nNewLength = nCurrentLength + nNewGrowth;
207 nNewLength = (nNewLength + 3) / 4 * 4;
209 m_rSequence.realloc(nNewLength);
212 OSL_ENSURE(m_rSequence.getLength() >= m_nSize + _rData.getLength(),
213 "ooops ... the realloc algorithm seems to be wrong :( !");
215 memcpy(m_rSequence.getArray() + m_nSize, _rData.getConstArray(), _rData.getLength());
220void SAL_CALL OSequenceOutputStream::flush( )
224 throw NotConnectedException();
227 m_rSequence.realloc(m_nSize);
230void OSequenceOutputStream::finalizeOutput()
233 m_rSequence.realloc(m_nSize);
235 m_bConnected =
false;
238void SAL_CALL OSequenceOutputStream::closeOutput()
242 throw NotConnectedException();
std::unique_ptr< sal_Int32[]> pData
constexpr OUStringLiteral aData
double getLength(const B2DPolygon &rCandidate)