Coverage Report

Created: 2026-02-10 07:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/poppler/qt6/src/poppler-base-converter.cc
Line
Count
Source
1
/* poppler-base-converter.cc: qt interface to poppler
2
 * Copyright (C) 2007, 2009, 2025, Albert Astals Cid <aacid@kde.org>
3
 * Copyright (C) 2008, Pino Toscano <pino@kde.org>
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2, or (at your option)
8
 * any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
18
 */
19
20
#include "poppler-converter-private.h"
21
22
#include <QtCore/QFile>
23
24
namespace Poppler {
25
26
7.32k
BaseConverterPrivate::BaseConverterPrivate() = default;
27
28
7.32k
BaseConverterPrivate::~BaseConverterPrivate() = default;
29
30
QIODevice *BaseConverterPrivate::openDevice()
31
7.32k
{
32
7.32k
    if (!iodev) {
33
0
        Q_ASSERT(!outputFileName.isEmpty());
34
0
        auto *f = new QFile(outputFileName);
35
0
        iodev = f;
36
0
        ownIodev = true;
37
0
    }
38
7.32k
    Q_ASSERT(iodev);
39
7.32k
    if (!iodev->isOpen()) {
40
0
        if (!iodev->open(QIODevice::WriteOnly)) {
41
0
            if (ownIodev) {
42
0
                delete iodev;
43
0
                iodev = nullptr;
44
0
            } else {
45
0
                return nullptr;
46
0
            }
47
0
        }
48
0
    }
49
7.32k
    return iodev;
50
7.32k
}
51
52
void BaseConverterPrivate::closeDevice()
53
7.32k
{
54
7.32k
    if (ownIodev) {
55
0
        iodev->close();
56
0
        delete iodev;
57
0
        iodev = nullptr;
58
0
    }
59
7.32k
}
60
61
7.32k
BaseConverter::BaseConverter(BaseConverterPrivate &dd) : d_ptr(&dd) { }
62
63
BaseConverter::~BaseConverter()
64
7.32k
{
65
7.32k
    delete d_ptr;
66
7.32k
}
67
68
void BaseConverter::setOutputFileName(const QString &outputFileName)
69
0
{
70
0
    Q_D(BaseConverter);
71
0
    d->outputFileName = outputFileName;
72
0
}
73
74
void BaseConverter::setOutputDevice(QIODevice *device)
75
7.32k
{
76
7.32k
    Q_D(BaseConverter);
77
7.32k
    d->iodev = device;
78
7.32k
    d->ownIodev = false;
79
7.32k
}
80
81
BaseConverter::Error BaseConverter::lastError() const
82
0
{
83
    Q_D(const BaseConverter);
84
0
    return d->lastError;
85
0
}
86
87
}