9#include "third_party/pdfium/public/fpdf_doc.h"
10#include "third_party/pdfium/public/fpdf_text.h"
12#include <QLoggingCategory>
73 return d->links.size();
82 const auto &link =
d->links.at(
index.row());
87 return link.rectangles().empty() ?
QVariant() : link.rectangles().constFirst();
93 return link.location();
100 return link.toString();
160 for (
const auto &link : std::as_const(
d->links)) {
161 for (
const auto &
rect : link.rectangles()) {
162 if (
rect.contains(point))
180 FPDF_PAGE pdfPage = FPDF_LoadPage(doc,
page);
185 double pageHeight = FPDF_GetPageHeight(pdfPage);
186 q->beginResetModel();
194 hasNext = FPDFLink_Enumerate(pdfPage, &linkStart, &linkAnnot);
198 bool ok = FPDFLink_GetAnnotRect(linkAnnot, &
rect);
200 qCWarning(qLcLink) <<
"skipping link with invalid bounding box";
212 FPDF_DEST dest = FPDFLink_GetDest(doc, linkAnnot);
213 FPDF_ACTION action = FPDFLink_GetAction(linkAnnot);
214 switch (FPDFAction_GetType(action)) {
215 case PDFACTION_UNSUPPORTED:
216 case PDFACTION_GOTO: {
217 linkData.d->
page = FPDFDest_GetDestPageIndex(doc, dest);
218 if (linkData.d->
page < 0) {
219 qCWarning(qLcLink) <<
"skipping link with invalid page number";
222 FPDF_BOOL hasX, hasY, hasZoom;
224 ok = FPDFDest_GetLocationInPage(dest, &hasX, &hasY, &hasZoom, &
x, &
y, &zoom);
226 qCWarning(qLcLink) <<
"link with invalid location and/or zoom @" << linkData.d->
rects;
232 linkData.d->
zoom = zoom;
235 case PDFACTION_URI: {
236 unsigned long len = FPDFAction_GetURIPath(doc, action,
nullptr, 0);
238 qCWarning(qLcLink) <<
"skipping link with empty URI @" << linkData.d->
rects;
242 unsigned long got = FPDFAction_GetURIPath(doc, action,
buf.data(),
len);
248 case PDFACTION_LAUNCH:
249 case PDFACTION_REMOTEGOTO: {
250 unsigned long len = FPDFAction_GetFilePath(action,
nullptr, 0);
252 qCWarning(qLcLink) <<
"skipping link with empty file path @" << linkData.d->
rects;
256 unsigned long got = FPDFAction_GetFilePath(action,
buf.data(),
len);
271 FPDF_TEXTPAGE textPage = FPDFText_LoadPage(pdfPage);
273 FPDF_PAGELINK webLinks = FPDFLink_LoadWebLinks(textPage);
275 int count = FPDFLink_CountWebLinks(webLinks);
278 int len = FPDFLink_GetURL(webLinks,
i,
nullptr, 0);
280 qCWarning(qLcLink) <<
"skipping link" <<
i <<
"with empty URL";
283 int got = FPDFLink_GetURL(webLinks,
i,
buf.data(),
len);
286 reinterpret_cast<const char16_t *
>(
buf.data()), got - 1);
288 len = FPDFLink_CountRects(webLinks,
i);
289 for (
int r = 0;
r <
len; ++
r) {
298 FPDFLink_CloseWebLinks(webLinks);
300 FPDFText_ClosePage(textPage);
304 FPDF_ClosePage(pdfPage);
306 for (
const auto &l :
links)
315 qCDebug(qLcLink) <<
"sees document statusChanged" << status;
322#include "moc_qpdflinkmodel_p.cpp"
QObject * parent() const
Returns a pointer to the parent object.
QByteArray toLower() const &
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
The QPdfDocument class loads a PDF document and renders pages from it.
Status
This enum describes the current status of the document.
void statusChanged(QPdfDocument::Status status)
The QPdfLinkModel class holds the geometry and the destination for each link that the specified \l pa...
QHash< int, QByteArray > roleNames() const override
void pageChanged(int page)
int page
The page to load links from.
QVariant data(const QModelIndex &index, int role) const override
\reimp
QPdfDocument * document
The document to load links from.
Role
\value Link A QPdfLink object.
QPdfLink linkAt(QPointF point) const
Returns a \l {QPdfLink::isValid()}{valid} link if found under the point (given in units of points,...
void setDocument(QPdfDocument *document)
int rowCount(const QModelIndex &parent) const override
\reimp
~QPdfLinkModel()
Destroys the model.
The QPdfLink class defines a link between a region on a page (such as a hyperlink or a search result)...
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString fromUtf16(const char16_t *, qsizetype size=-1)
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Combined button and popup list for selecting options.
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
GLint GLint GLint GLint GLint x
[0]
GLdouble GLdouble GLdouble GLdouble top
GLenum GLenum GLsizei count
GLenum GLuint GLenum GLsizei const GLchar * buf
GLdouble GLdouble GLdouble GLdouble q
static bool hasNext(const Symbols &symbols, int i)
obj metaObject() -> className()
myObject disconnect()
[26]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent