21#include <com/sun/star/io/XMarkableStream.hpp>
22#include <com/sun/star/io/XDataInputStream.hpp>
23#include <com/sun/star/io/XDataOutputStream.hpp>
24#include <osl/diagnose.h>
30OStreamSection::OStreamSection(
const css::uno::Reference< css::io::XDataInputStream >& _rxInput)
31 :m_xMarkStream(_rxInput, css::
uno::UNO_QUERY)
32 ,m_xInStream(_rxInput)
36 OSL_ENSURE(m_xInStream.is() && m_xMarkStream.is(),
"OStreamSection::OStreamSection : invalid argument !");
37 if (m_xInStream.is() && m_xMarkStream.is())
39 m_nBlockLen = _rxInput->readLong();
40 m_nBlockStart = m_xMarkStream->createMark();
45OStreamSection::OStreamSection(
const css::uno::Reference< css::io::XDataOutputStream >& _rxOutput)
46 :m_xMarkStream(_rxOutput, css::
uno::UNO_QUERY)
47 ,m_xOutStream(_rxOutput)
51 OSL_ENSURE(m_xOutStream.is() && m_xMarkStream.is(),
"OStreamSection::OStreamSection : invalid argument !");
52 if (m_xOutStream.is() && m_xMarkStream.is())
54 m_nBlockStart = m_xMarkStream->createMark();
56 m_xOutStream->writeLong(m_nBlockLen);
61OStreamSection::~OStreamSection()
66 if (m_xInStream.is() && m_xMarkStream.is())
68 m_xMarkStream->jumpToMark(m_nBlockStart);
69 m_xInStream->skipBytes(m_nBlockLen);
70 m_xMarkStream->deleteMark(m_nBlockStart);
72 else if (m_xOutStream.is() && m_xMarkStream.is())
74 sal_Int32 nRealBlockLength = m_xMarkStream->offsetToMark(m_nBlockStart) -
sizeof(m_nBlockLen);
75 m_nBlockLen = nRealBlockLength;
76 m_xMarkStream->jumpToMark(m_nBlockStart);
77 m_xOutStream->writeLong(m_nBlockLen);
78 m_xMarkStream->jumpToFurthest();
79 m_xMarkStream->deleteMark(m_nBlockStart);
82 catch(
const css::uno::Exception&)