summaryrefslogtreecommitdiffstats
path: root/src/pdf/qpdfsearchmodel.cpp
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2025-06-04 09:23:45 +0300
committerTarja Sundqvist <tarja.sundqvist@qt.io>2025-06-04 09:23:45 +0300
commit94c09aab1dac228a9ddf03abd7d76559b5d6af16 (patch)
tree9a02c6407dded2f74b6790f8686c4ab7c8777b21 /src/pdf/qpdfsearchmodel.cpp
parentf08b503f680e8a6d4021d2fd21d2386f8e60da24 (diff)
parent0efae85f199a61fd6919703cfbb74d680d9a9443 (diff)
Merge tag 'v6.5.6-lts' into 6.5.66.5.6
Qt 6.5.6-lts release Conflicts solved: dependencies.yaml Change-Id: I31ed402989d58b5195459a8a3bf309e6354c35f6
Diffstat (limited to 'src/pdf/qpdfsearchmodel.cpp')
-rw-r--r--src/pdf/qpdfsearchmodel.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/pdf/qpdfsearchmodel.cpp b/src/pdf/qpdfsearchmodel.cpp
index 78dfe06fa..abe0122bf 100644
--- a/src/pdf/qpdfsearchmodel.cpp
+++ b/src/pdf/qpdfsearchmodel.cpp
@@ -3,12 +3,11 @@
#include "qpdfdocument_p.h"
#include "qpdflink.h"
-#include "qpdflink_p.h"
#include "qpdfsearchmodel.h"
#include "qpdfsearchmodel_p.h"
-#include "third_party/pdfium/public/fpdf_doc.h"
#include "third_party/pdfium/public/fpdf_text.h"
+#include "third_party/pdfium/public/fpdfview.h"
#include <QtCore/qelapsedtimer.h>
#include <QtCore/qloggingcategory.h>
@@ -251,7 +250,6 @@ bool QPdfSearchModelPrivate::doSearch(int page)
qWarning() << "failed to load page" << page;
return false;
}
- double pageHeight = FPDF_GetPageHeight(pdfPage);
FPDF_TEXTPAGE textPage = FPDFText_LoadPage(pdfPage);
if (!textPage) {
qWarning() << "failed to load text of page" << page;
@@ -269,9 +267,12 @@ bool QPdfSearchModelPrivate::doSearch(int page)
int startIndex = -1;
int endIndex = -1;
for (int r = 0; r < rectCount; ++r) {
+ // get bounding box of search result in page coordinates
double left, top, right, bottom;
FPDFText_GetRect(textPage, r, &left, &top, &right, &bottom);
- rects << QRectF(left, pageHeight - top, right - left, top - bottom);
+ // deal with any internal PDF transforms and
+ // convert to the 1x (pixels = points) 4th-quadrant coordinate system
+ rects << document->d->mapPageToView(pdfPage, left, top, right, bottom);
if (r == 0) {
startIndex = FPDFText_GetCharIndexAtPos(textPage, left, top,
CharacterHitTolerance, CharacterHitTolerance);
@@ -280,7 +281,8 @@ bool QPdfSearchModelPrivate::doSearch(int page)
endIndex = FPDFText_GetCharIndexAtPos(textPage, right, top,
CharacterHitTolerance, CharacterHitTolerance);
}
- qCDebug(qLcS) << rects.last() << "char idx" << startIndex << "->" << endIndex;
+ qCDebug(qLcS) << rects.last() << "char idx" << startIndex << "->" << endIndex
+ << "from page rect" << left << top << right << bottom;
}
QString contextBefore, contextAfter;
if (startIndex >= 0 || endIndex >= 0) {