Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qpdfdocument_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QPDFDOCUMENT_P_H
5#define QPDFDOCUMENT_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qpdfdocument.h"
19
20#include "third_party/pdfium/public/fpdfview.h"
21#include "third_party/pdfium/public/fpdf_dataavail.h"
22
23#include <QtCore/qbuffer.h>
24#include <QtCore/qmutex.h>
25#include <QtCore/qpointer.h>
26#include <QtNetwork/qnetworkreply.h>
27
28#include <mutex>
29
31
32class QPdfMutexLocker : public std::unique_lock<QRecursiveMutex>
33{
34public:
36};
37
38class QPdfPageModel;
39
40class Q_PDF_PRIVATE_EXPORT QPdfDocumentPrivate: public FPDF_FILEACCESS, public FX_FILEAVAIL, public FX_DOWNLOADHINTS
41{
42public:
45
47 QPdfPageModel *pageModel = nullptr;
48
49 FPDF_AVAIL avail;
50 FPDF_DOCUMENT doc;
52
58
62
63 void clear();
64
65 void load(QIODevice *device, bool ownDevice);
67
68 void _q_tryLoadingWithSizeFromContentHeader();
69 void initiateAsyncLoadWithTotalSizeKnown(quint64 totalSize);
70 void _q_copyFromSequentialSourceDevice();
71 void tryLoadDocument();
72 void checkComplete();
73 bool checkPageComplete(int page);
74 void setStatus(QPdfDocument::Status status);
75
76 static FPDF_BOOL fpdf_IsDataAvail(struct _FX_FILEAVAIL* pThis, size_t offset, size_t size);
77 static int fpdf_GetBlock(void* param, unsigned long position, unsigned char* pBuf, unsigned long size);
78 static void fpdf_AddSegment(struct _FX_DOWNLOADHINTS* pThis, size_t offset, size_t size);
79 void updateLastError();
80 QString getText(FPDF_TEXTPAGE textPage, int startIndex, int count);
81 QPointF getCharPosition(FPDF_TEXTPAGE textPage, double pageHeight, int charIndex);
82 QRectF getCharBox(FPDF_TEXTPAGE textPage, double pageHeight, int charIndex);
83
84 // FPDF takes the rotation parameter as an int.
85 // This enum is mapping the int values defined in fpdfview.h:956.
86 // (not using enum class to ensure int convertability)
88 Normal = 0,
89 ClockWise90 = 1,
90 ClockWise180 = 2,
91 CounterClockWise90 = 3
92 };
93
95 {
96 switch (rotation) {
98 return QFPDFRotation::Normal;
100 return QFPDFRotation::ClockWise90;
102 return QFPDFRotation::ClockWise180;
104 return QFPDFRotation::CounterClockWise90;
105 }
106 Q_UNREACHABLE();
107 }
108
112 int charIndex = -1;
113 };
114 TextPosition hitTest(int page, QPointF position);
115};
116
118
119#endif // QPDFDOCUMENT_P_H
IOBluetoothDevice * device
\inmodule QtCore \reentrant
Definition qbuffer.h:16
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore \reentrant
Definition qiodevice.h:34
void loadAsync(QIODevice *device)
QPointer< QIODevice > device
QPdfDocument::Status status
QScopedPointer< QIODevice > ownDevice
static constexpr QFPDFRotation toFPDFRotation(QPdfDocumentRenderOptions::Rotation rotation)
QPointer< QIODevice > sequentialSourceDevice
QPdfDocument::Error lastError
The QPdfDocument class loads a PDF document and renders pages from it.
Status
This enum describes the current status of the document.
Error
This enum describes the error while attempting the last operation on the document.
\inmodule QtCore\reentrant
Definition qpoint.h:214
\inmodule QtCore
Definition qpointer.h:18
\inmodule QtCore\reentrant
Definition qrect.h:483
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
b clear()
p1 load("image.bmp")
Combined button and popup list for selecting options.
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLenum const GLint * param
GLenum GLuint GLintptr offset
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static void getText(QString &text, QTextDocumentPrivate *priv, const QString &docText, int pos, int end)
#define Q_PDF_PRIVATE_EXPORT
Definition qtpdfglobal.h:23
unsigned long long quint64
Definition qtypes.h:56
double qreal
Definition qtypes.h:92
QByteArray page
[45]