Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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#include "qtpdfexports.h"
20
21#include "third_party/pdfium/public/fpdfview.h"
22#include "third_party/pdfium/public/fpdf_dataavail.h"
23
24#include <QtCore/qbuffer.h>
25#include <QtCore/qmutex.h>
26#include <QtCore/qpointer.h>
27#include <QtNetwork/qnetworkreply.h>
28
29#include <mutex>
30
32
33class QPdfMutexLocker : public std::unique_lock<QRecursiveMutex>
34{
35public:
37};
38
39class QPdfPageModel;
40
41class Q_PDF_EXPORT QPdfDocumentPrivate: public FPDF_FILEACCESS, public FX_FILEAVAIL, public FX_DOWNLOADHINTS
42{
43public:
46
48 QPdfPageModel *pageModel = nullptr;
49
50 FPDF_AVAIL avail;
51 FPDF_DOCUMENT doc;
53
54 QPointer<QIODevice> device;
55 QScopedPointer<QIODevice> ownDevice;
57 QPointer<QIODevice> sequentialSourceDevice;
59
63
64 void clear();
65
66 void load(QIODevice *device, bool ownDevice);
68
69 void _q_tryLoadingWithSizeFromContentHeader();
70 void initiateAsyncLoadWithTotalSizeKnown(quint64 totalSize);
71 void _q_copyFromSequentialSourceDevice();
72 void tryLoadDocument();
73 void checkComplete();
74 bool checkPageComplete(int page);
75 void setStatus(QPdfDocument::Status status);
76
77 static FPDF_BOOL fpdf_IsDataAvail(struct _FX_FILEAVAIL* pThis, size_t offset, size_t size);
78 static int fpdf_GetBlock(void* param, unsigned long position, unsigned char* pBuf, unsigned long size);
79 static void fpdf_AddSegment(struct _FX_DOWNLOADHINTS* pThis, size_t offset, size_t size);
80 void updateLastError();
81 QString getText(FPDF_TEXTPAGE textPage, int startIndex, int count) const;
82 QPointF getCharPosition(FPDF_PAGE pdfPage, FPDF_TEXTPAGE textPage, int charIndex) const;
83 QRectF getCharBox(FPDF_PAGE pdfPage, FPDF_TEXTPAGE textPage, int charIndex) const;
84 QPointF mapPageToView(FPDF_PAGE pdfPage, double x, double y) const;
85 QRectF mapPageToView(FPDF_PAGE pdfPage, double left, double top, double right, double bottom) const;
86 QPointF mapViewToPage(FPDF_PAGE pdfPage, QPointF position) const;
87
88 // FPDF takes the rotation parameter as an int.
89 // This enum is mapping the int values defined in fpdfview.h:956.
90 // (not using enum class to ensure int convertability)
92 Normal = 0,
93 ClockWise90 = 1,
94 ClockWise180 = 2,
95 CounterClockWise90 = 3
96 };
97
99 {
100 switch (rotation) {
102 return QFPDFRotation::Normal;
104 return QFPDFRotation::ClockWise90;
106 return QFPDFRotation::ClockWise180;
108 return QFPDFRotation::CounterClockWise90;
109 }
110 Q_UNREACHABLE();
111 }
112
116 int charIndex = -1;
117 };
118 TextPosition hitTest(int page, QPointF position);
119};
120
122
123#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:217
\inmodule QtCore\reentrant
Definition qrect.h:484
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
b clear()
p1 load("image.bmp")
Combined button and popup list for selecting options.
GLint GLint GLint GLint GLint x
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLdouble GLdouble right
GLint left
GLint GLint bottom
GLenum const GLint * param
GLenum GLuint GLintptr offset
GLint y
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static void getText(QString &text, QTextDocumentPrivate *priv, const QString &docText, int pos, int end)
unsigned long long quint64
Definition qtypes.h:61
double qreal
Definition qtypes.h:187
QByteArray page
[45]