* Generic Generator Implementation */
| 78 | * Generic Generator Implementation |
| 79 | */ |
| 80 | Okular::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 | |
| 120 | void TextDocumentGeneratorPrivate::addAction(Action *action, int cursorBegin, int cursorEnd) |
| 121 | { |
no test coverage detected