| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/text/qabstracttextdocumentlayout.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | QAbstractTextDocumentLayoutPrivate::~QAbstractTextDocumentLayoutPrivate() | - | ||||||||||||||||||
| 6 | { | - | ||||||||||||||||||
| 7 | } | - | ||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | QTextObjectInterface::~QTextObjectInterface() | - | ||||||||||||||||||
| 10 | { | - | ||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | } | - | ||||||||||||||||||
| 13 | QAbstractTextDocumentLayout::QAbstractTextDocumentLayout(QTextDocument *document) | - | ||||||||||||||||||
| 14 | : QObject(*new QAbstractTextDocumentLayoutPrivate, document) | - | ||||||||||||||||||
| 15 | { | - | ||||||||||||||||||
| 16 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||
| 17 | d->setDocument(document); | - | ||||||||||||||||||
| 18 | } never executed: end of block | 0 | ||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | - | |||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | QAbstractTextDocumentLayout::QAbstractTextDocumentLayout(QAbstractTextDocumentLayoutPrivate &p, QTextDocument *document) | - | ||||||||||||||||||
| 24 | :QObject(p, document) | - | ||||||||||||||||||
| 25 | { | - | ||||||||||||||||||
| 26 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||
| 27 | d->setDocument(document); | - | ||||||||||||||||||
| 28 | } never executed: end of block | 0 | ||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | - | |||||||||||||||||||
| 31 | - | |||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | QAbstractTextDocumentLayout::~QAbstractTextDocumentLayout() | - | ||||||||||||||||||
| 34 | { | - | ||||||||||||||||||
| 35 | } | - | ||||||||||||||||||
| 36 | void QAbstractTextDocumentLayout::registerHandler(int objectType, QObject *component) | - | ||||||||||||||||||
| 37 | { | - | ||||||||||||||||||
| 38 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | QTextObjectInterface *iface = qobject_cast<QTextObjectInterface *>(component); | - | ||||||||||||||||||
| 41 | if (!iface
| 0 | ||||||||||||||||||
| 42 | return; never executed: return; | 0 | ||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | connect(component, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "438"), this, qFlagLocation("1""_q_handlerDestroyed(QObject*)" "\0" __FILE__ ":" "438")); | - | ||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | QTextObjectHandler h; | - | ||||||||||||||||||
| 47 | h.iface = iface; | - | ||||||||||||||||||
| 48 | h.component = component; | - | ||||||||||||||||||
| 49 | d->handlers.insert(objectType, h); | - | ||||||||||||||||||
| 50 | } never executed: end of block | 0 | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | - | |||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | void QAbstractTextDocumentLayout::unregisterHandler(int objectType, QObject *component) | - | ||||||||||||||||||
| 59 | { | - | ||||||||||||||||||
| 60 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | const auto it = d->handlers.constFind(objectType); | - | ||||||||||||||||||
| 63 | if (it != d->handlers.cend()
| 0 | ||||||||||||||||||
| 64 | if (component
| 0 | ||||||||||||||||||
| 65 | disconnect(component, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "459"), this, qFlagLocation("1""_q_handlerDestroyed(QObject*)" "\0" __FILE__ ":" "459")); never executed: disconnect(component, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "459"), this, qFlagLocation("1""_q_handlerDestroyed(QObject*)" "\0" __FILE__ ":" "459")); | 0 | ||||||||||||||||||
| 66 | d->handlers.erase(it); | - | ||||||||||||||||||
| 67 | } never executed: end of block | 0 | ||||||||||||||||||
| 68 | } never executed: end of block | 0 | ||||||||||||||||||
| 69 | - | |||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | - | |||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | QTextObjectInterface *QAbstractTextDocumentLayout::handlerForObject(int objectType) const | - | ||||||||||||||||||
| 74 | { | - | ||||||||||||||||||
| 75 | const QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | QTextObjectHandler handler = d->handlers.value(objectType); | - | ||||||||||||||||||
| 78 | if (!handler.component
| 0 | ||||||||||||||||||
| 79 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 80 | - | |||||||||||||||||||
| 81 | return never executed: handler.iface;return handler.iface;never executed: return handler.iface; | 0 | ||||||||||||||||||
| 82 | } | - | ||||||||||||||||||
| 83 | void QAbstractTextDocumentLayout::resizeInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) | - | ||||||||||||||||||
| 84 | { | - | ||||||||||||||||||
| 85 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | QTextCharFormat f = format.toCharFormat(); | - | ||||||||||||||||||
| 88 | ((!(f.isValid())) ? qt_assert("f.isValid()",__FILE__,494) : qt_noop()); | - | ||||||||||||||||||
| 89 | QTextObjectHandler handler = d->handlers.value(f.objectType()); | - | ||||||||||||||||||
| 90 | if (!handler.component
| 0 | ||||||||||||||||||
| 91 | return; never executed: return; | 0 | ||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | QSizeF s = handler.iface->intrinsicSize(document(), posInDocument, format); | - | ||||||||||||||||||
| 94 | item.setWidth(s.width()); | - | ||||||||||||||||||
| 95 | item.setAscent(s.height()); | - | ||||||||||||||||||
| 96 | item.setDescent(0); | - | ||||||||||||||||||
| 97 | } never executed: end of block | 0 | ||||||||||||||||||
| 98 | void QAbstractTextDocumentLayout::positionInlineObject(QTextInlineObject item, int posInDocument, const QTextFormat &format) | - | ||||||||||||||||||
| 99 | { | - | ||||||||||||||||||
| 100 | (void)item;; | - | ||||||||||||||||||
| 101 | (void)posInDocument;; | - | ||||||||||||||||||
| 102 | (void)format;; | - | ||||||||||||||||||
| 103 | } never executed: end of block | 0 | ||||||||||||||||||
| 104 | void QAbstractTextDocumentLayout::drawInlineObject(QPainter *p, const QRectF &rect, QTextInlineObject item, | - | ||||||||||||||||||
| 105 | int posInDocument, const QTextFormat &format) | - | ||||||||||||||||||
| 106 | { | - | ||||||||||||||||||
| 107 | (void)item;; | - | ||||||||||||||||||
| 108 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | QTextCharFormat f = format.toCharFormat(); | - | ||||||||||||||||||
| 111 | ((!(f.isValid())) ? qt_assert("f.isValid()",__FILE__,545) : qt_noop()); | - | ||||||||||||||||||
| 112 | QTextObjectHandler handler = d->handlers.value(f.objectType()); | - | ||||||||||||||||||
| 113 | if (!handler.component
| 0 | ||||||||||||||||||
| 114 | return; never executed: return; | 0 | ||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | handler.iface->drawObject(p, rect, document(), posInDocument, format); | - | ||||||||||||||||||
| 117 | } never executed: end of block | 0 | ||||||||||||||||||
| 118 | - | |||||||||||||||||||
| 119 | void QAbstractTextDocumentLayoutPrivate::_q_handlerDestroyed(QObject *obj) | - | ||||||||||||||||||
| 120 | { | - | ||||||||||||||||||
| 121 | HandlerHash::Iterator it = handlers.begin(); | - | ||||||||||||||||||
| 122 | while (it != handlers.end()
| 0 | ||||||||||||||||||
| 123 | if ((*
| 0 | ||||||||||||||||||
| 124 | it = handlers.erase(it); never executed: it = handlers.erase(it); | 0 | ||||||||||||||||||
| 125 | else | - | ||||||||||||||||||
| 126 | ++ never executed: it;++it;never executed: ++it; | 0 | ||||||||||||||||||
| 127 | } never executed: end of block | 0 | ||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | - | |||||||||||||||||||
| 130 | - | |||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 | - | |||||||||||||||||||
| 133 | - | |||||||||||||||||||
| 134 | int QAbstractTextDocumentLayout::formatIndex(int pos) | - | ||||||||||||||||||
| 135 | { | - | ||||||||||||||||||
| 136 | QTextDocumentPrivate *pieceTable = qobject_cast<QTextDocument *>(parent())->docHandle(); | - | ||||||||||||||||||
| 137 | return never executed: pieceTable->find(pos).value()->format;return pieceTable->find(pos).value()->format;never executed: return pieceTable->find(pos).value()->format; | 0 | ||||||||||||||||||
| 138 | } | - | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | - | |||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | - | |||||||||||||||||||
| 144 | - | |||||||||||||||||||
| 145 | QTextCharFormat QAbstractTextDocumentLayout::format(int pos) | - | ||||||||||||||||||
| 146 | { | - | ||||||||||||||||||
| 147 | QTextDocumentPrivate *pieceTable = qobject_cast<QTextDocument *>(parent())->docHandle(); | - | ||||||||||||||||||
| 148 | int idx = pieceTable->find(pos).value()->format; | - | ||||||||||||||||||
| 149 | return never executed: pieceTable->formatCollection()->charFormat(idx);return pieceTable->formatCollection()->charFormat(idx);never executed: return pieceTable->formatCollection()->charFormat(idx); | 0 | ||||||||||||||||||
| 150 | } | - | ||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | - | |||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | QTextDocument *QAbstractTextDocumentLayout::document() const | - | ||||||||||||||||||
| 158 | { | - | ||||||||||||||||||
| 159 | const QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||
| 160 | return never executed: d->document;return d->document;never executed: return d->document; | 0 | ||||||||||||||||||
| 161 | } | - | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | - | |||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | QString QAbstractTextDocumentLayout::anchorAt(const QPointF& pos) const | - | ||||||||||||||||||
| 170 | { | - | ||||||||||||||||||
| 171 | int cursorPos = hitTest(pos, Qt::ExactHit); | - | ||||||||||||||||||
| 172 | if (cursorPos == -1
| 0 | ||||||||||||||||||
| 173 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | QTextBlock block = document()->firstBlock(); | - | ||||||||||||||||||
| 177 | while (block.isValid()
| 0 | ||||||||||||||||||
| 178 | QRectF blockBr = blockBoundingRect(block); | - | ||||||||||||||||||
| 179 | if (blockBr.contains(pos)
| 0 | ||||||||||||||||||
| 180 | QTextLayout *layout = block.layout(); | - | ||||||||||||||||||
| 181 | int relativeCursorPos = cursorPos - block.position(); | - | ||||||||||||||||||
| 182 | const int preeditLength = layout
| 0 | ||||||||||||||||||
| 183 | if (preeditLength > 0
| 0 | ||||||||||||||||||
| 184 | cursorPos -= qMin(cursorPos - layout->preeditAreaPosition(), preeditLength); never executed: cursorPos -= qMin(cursorPos - layout->preeditAreaPosition(), preeditLength); | 0 | ||||||||||||||||||
| 185 | break; never executed: break; | 0 | ||||||||||||||||||
| 186 | } | - | ||||||||||||||||||
| 187 | block = block.next(); | - | ||||||||||||||||||
| 188 | } never executed: end of block | 0 | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | QTextDocumentPrivate *pieceTable = qobject_cast<const QTextDocument *>(parent())->docHandle(); | - | ||||||||||||||||||
| 191 | QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos); | - | ||||||||||||||||||
| 192 | QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format); | - | ||||||||||||||||||
| 193 | return never executed: fmt.anchorHref();return fmt.anchorHref();never executed: return fmt.anchorHref(); | 0 | ||||||||||||||||||
| 194 | } | - | ||||||||||||||||||
| 195 | void QAbstractTextDocumentLayout::setPaintDevice(QPaintDevice *device) | - | ||||||||||||||||||
| 196 | { | - | ||||||||||||||||||
| 197 | QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||
| 198 | d->paintDevice = device; | - | ||||||||||||||||||
| 199 | } never executed: end of block | 0 | ||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | - | |||||||||||||||||||
| 203 | - | |||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | QPaintDevice *QAbstractTextDocumentLayout::paintDevice() const | - | ||||||||||||||||||
| 207 | { | - | ||||||||||||||||||
| 208 | const QAbstractTextDocumentLayoutPrivate * const d = d_func(); | - | ||||||||||||||||||
| 209 | return never executed: d->paintDevice;return d->paintDevice;never executed: return d->paintDevice; | 0 | ||||||||||||||||||
| 210 | } | - | ||||||||||||||||||
| 211 | - | |||||||||||||||||||
| 212 | - | |||||||||||||||||||
| 213 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |