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 
28 namespace com::sun::star {
29  namespace io { class XSeekable; }
30 }
31 
32 namespace oox {
33 
34 typedef css::uno::Sequence< sal_Int8 > StreamDataSequence;
35 
36 
40 {
41 public:
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 
105 protected:
106  explicit BinaryStreamBase( bool bSeekable ) : mbEof( false ), mbSeekable( bSeekable ) {}
107 
108 private:
109  BinaryStreamBase( const BinaryStreamBase& ) = delete;
110  BinaryStreamBase& operator=( const BinaryStreamBase& ) = delete;
111 
112 protected:
113  bool mbEof;
114 
115 private:
116  const bool mbSeekable;
117 };
118 
119 
124 {
125 public:
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 
137 protected:
138  explicit BinaryXSeekableStream(
139  const css::uno::Reference< css::io::XSeekable >& rxSeekable );
140 
141 private:
142  css::uno::Reference< css::io::XSeekable >
144 };
145 
146 
155 {
156 public:
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 
166 protected:
167  explicit SequenceSeekableStream( const StreamDataSequence& rData );
168 
169 protected:
170  const StreamDataSequence* mpData;
171  sal_Int32 mnPos;
172 };
173 
174 
175 } // namespace oox
176 
177 #endif
178 
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void close() override
Releases the reference to the UNO XSeekable interface.
Base class for binary stream classes.
Base class for binary input and output streams wrapping a UNO stream, seekable via the com...
exports com.sun.star. io
virtual sal_Int64 tell() const override
Returns the current stream position, if wrapped stream is seekable, otherwise -1. ...
const bool mbSeekable
True = implementation supports seeking.
const ContentProperties & rData
BinaryStreamBase(bool bSeekable)
virtual void seek(sal_Int64 nPos) override
Seeks the stream to the passed position, if wrapped stream is seekable.
void seekToStart()
Seeks the stream to the beginning, if stream is seekable.
Base class for binary input and output streams wrapping a StreamDataSequence, which is always seekabl...
css::uno::Sequence< sal_Int8 > StreamDataSequence
virtual ~BinaryXSeekableStream() override
css::uno::Reference< css::io::XSeekable > mxSeekable
Stream seeking interface.
size
bool mbEof
End of stream flag.
bool close
virtual sal_Int64 size() const override
Returns the size of the stream, if wrapped stream is seekable, otherwise -1.
bool isSeekable() const
Returns true, if the implementation supports the seek() operation.
sal_Int32 mnPos
Current position in the sequence.
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
bool isEof() const
Returns true, if the stream position is invalid (EOF).
BinaryXSeekableStream(const css::uno::Reference< css::io::XSeekable > &rxSeekable)
sal_uInt16 nPos
const StreamDataSequence * mpData
Wrapped data sequence.