| 1 |
/* poppler-qiodeviceinstream.cc: Qt5 interface to poppler |
| 2 |
* Copyright (C) 2019 Alexander Volkov <[email protected]> |
| 3 |
* Copyright (C) 2025 g10 Code GmbH, Author: Sune Stolborg Vuorela <[email protected]> |
| 4 |
* Copyright (C) 2025 Albert Astals Cid <[email protected]> |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2, or (at your option) |
| 9 |
* any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "poppler-qiodeviceinstream-private.h" |
| 22 |
|
| 23 |
#include <QtCore/QIODevice> |
| 24 |
|
| 25 |
namespace Poppler { |
| 26 |
|
| 27 |
QIODeviceInStream::QIODeviceInStream(QIODevice *device, Goffset startA, bool limitedA, Goffset lengthA, Object &&dictA) : BaseSeekInputStream(startA, limitedA, lengthA, std::move(dictA)), m_device(device) { } |
| 28 |
|
| 29 |
QIODeviceInStream::~QIODeviceInStream() |
| 30 |
{ |
| 31 |
close(); |
| 32 |
} |
| 33 |
|
| 34 |
BaseStream *QIODeviceInStream::copy() |
| 35 |
{ |
| 36 |
return new QIODeviceInStream(m_device, start, limited, length, dict.copy()); |
| 37 |
} |
| 38 |
|
| 39 |
std::unique_ptr<Stream> QIODeviceInStream::makeSubStream(Goffset startA, bool limitedA, Goffset lengthA, Object &&dictA) |
| 40 |
{ |
| 41 |
return std::make_unique<QIODeviceInStream>(m_device, startA, limitedA, lengthA, std::move(dictA)); |
| 42 |
} |
| 43 |
|
| 44 |
Goffset QIODeviceInStream::currentPos() const |
| 45 |
{ |
| 46 |
return m_device->pos(); |
| 47 |
} |
| 48 |
|
| 49 |
void QIODeviceInStream::setCurrentPos(Goffset offset) |
| 50 |
{ |
| 51 |
m_device->seek(offset); |
| 52 |
} |
| 53 |
|
| 54 |
Goffset QIODeviceInStream::read(char *buffer, Goffset count) |
| 55 |
{ |
| 56 |
return m_device->read(buffer, count); |
| 57 |
} |
| 58 |
|
| 59 |
} |