MCPcopy Create free account
hub / github.com/KDE/okular / createTextPage

Method createTextPage

core/textdocumentgenerator.cpp:80–118  ·  view source on GitHub ↗

* Generic Generator Implementation */

Source from the content-addressed store, hash-verified

78 * Generic Generator Implementation
79 */
80Okular::TextPage *TextDocumentGeneratorPrivate::createTextPage(int pageNumber) const
81{
82#ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
83 Q_Q(const TextDocumentGenerator);
84#endif
85
86 Okular::TextPage *textPage = new Okular::TextPage;
87
88 int start, end;
89
90#ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
91 q->userMutex()->lock();
92#endif
93 TextDocumentUtils::calculatePositions(mDocument, pageNumber, start, end);
94
95 {
96 QTextCursor cursor(mDocument);
97 for (int i = start; i < end - 1; ++i) {
98 cursor.setPosition(i);
99 cursor.setPosition(i + 1, QTextCursor::KeepAnchor);
100
101 QString text = cursor.selectedText();
102 if (text.length() == 1) {
103 QRectF rect;
104 TextDocumentUtils::calculateBoundingRect(mDocument, i, i + 1, rect, pageNumber);
105 if (pageNumber == -1) {
106 text = QStringLiteral("\n");
107 }
108
109 textPage->append(text, Okular::NormalizedRect(rect.left(), rect.top(), rect.right(), rect.bottom()));
110 }
111 }
112 }
113#ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING
114 q->userMutex()->unlock();
115#endif
116
117 return textPage;
118}
119
120void TextDocumentGeneratorPrivate::addAction(Action *action, int cursorBegin, int cursorEnd)
121{

Callers 1

textPageMethod · 0.80

Calls 6

calculatePositionsFunction · 0.85
calculateBoundingRectFunction · 0.85
userMutexMethod · 0.80
selectedTextMethod · 0.80
appendMethod · 0.80
NormalizedRectClass · 0.70

Tested by

no test coverage detected