LibreOffice Module oox (master) 1
binarystreambase.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_OOX_HELPER_BINARYSTREAMBASE_HXX
21#define INCLUDED_OOX_HELPER_BINARYSTREAMBASE_HXX
22
23#include <com/sun/star/uno/Reference.hxx>
24#include <com/sun/star/uno/Sequence.hxx>
25#include <oox/dllapi.h>
26#include <sal/types.h>
27
28namespace com::sun::star {
29 namespace io { class XSeekable; }
30}
31
32namespace oox {
33
34typedef css::uno::Sequence< sal_Int8 > StreamDataSequence;
35
36
40{
41public:
42 virtual ~BinaryStreamBase();
43
52 virtual sal_Int64 size() const = 0;
53
62 virtual sal_Int64 tell() const = 0;
63
67 virtual void seek( sal_Int64 nPos ) = 0;
68
71 virtual void close() = 0;
72
78 bool isSeekable() const { return mbSeekable; }
79
83 bool isEof() const { return mbEof; }
84
88 sal_Int64 getRemaining() const;
89
92 void seekToStart() { seek( 0 ); }
93
103 void alignToBlock( sal_Int32 nBlockSize, sal_Int64 nAnchorPos );
104
105protected:
106 explicit BinaryStreamBase( bool bSeekable ) : mbEof( false ), mbSeekable( bSeekable ) {}
107
108private:
111
112protected:
113 bool mbEof;
114
115private:
116 const bool mbSeekable;
117};
118
119
124{
125public:
126 virtual ~BinaryXSeekableStream() override;
127
129 virtual sal_Int64 size() const override;
131 virtual sal_Int64 tell() const override;
133 virtual void seek( sal_Int64 nPos ) override;
135 virtual void close() override;
136
137protected:
138 explicit BinaryXSeekableStream(
139 const css::uno::Reference< css::io::XSeekable >& rxSeekable );
140
141private:
142 css::uno::Reference< css::io::XSeekable >
144};
145
146
155{
156public:
158 virtual sal_Int64 size() const override;
160 virtual sal_Int64 tell() const override;
162 virtual void seek( sal_Int64 nPos ) override;
164 virtual void close() override;
165
166protected:
167 explicit SequenceSeekableStream( const StreamDataSequence& rData );
168
169protected:
171 sal_Int32 mnPos;
172};
173
174
175} // namespace oox
176
177#endif
178
179/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Base class for binary stream classes.
bool isSeekable() const
Returns true, if the implementation supports the seek() operation.
BinaryStreamBase & operator=(const BinaryStreamBase &)=delete
virtual sal_Int64 size() const =0
Implementations return the size of the stream, if possible.
virtual void close()=0
Implementations close the stream.
void seekToStart()
Seeks the stream to the beginning, if stream is seekable.
const bool mbSeekable
True = implementation supports seeking.
BinaryStreamBase(const BinaryStreamBase &)=delete
bool isEof() const
Returns true, if the stream position is invalid (EOF).
virtual sal_Int64 tell() const =0
Implementations return the current stream position, if possible.
virtual void seek(sal_Int64 nPos)=0
Implementations seek the stream to the passed position, if the stream is seekable.
bool mbEof
End of stream flag.
BinaryStreamBase(bool bSeekable)
Base class for binary input and output streams wrapping a UNO stream, seekable via the com....
BinaryXSeekableStream(const css::uno::Reference< css::io::XSeekable > &rxSeekable)
virtual ~BinaryXSeekableStream() override
virtual void close() override
Releases the reference to the UNO XSeekable interface.
virtual sal_Int64 tell() const override
Returns the current stream position, if wrapped stream is seekable, otherwise -1.
css::uno::Reference< css::io::XSeekable > mxSeekable
Stream seeking interface.
virtual sal_Int64 size() const override
Returns the size of the stream, if wrapped stream is seekable, otherwise -1.
virtual void seek(sal_Int64 nPos) override
Seeks the stream to the passed position, if wrapped stream is seekable.
Base class for binary input and output streams wrapping a StreamDataSequence, which is always seekabl...
sal_Int32 mnPos
Current position in the sequence.
const StreamDataSequence * mpData
Wrapped data sequence.
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
bool close
sal_uInt16 nPos
size
css::uno::Sequence< sal_Int8 > StreamDataSequence