qabstracttextdocumentlayout.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qabstracttextdocumentlayout.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5QAbstractTextDocumentLayoutPrivate::~QAbstractTextDocumentLayoutPrivate()-
6{-
7}-
8-
9QTextObjectInterface::~QTextObjectInterface()-
10{-
11-
12}-
13QAbstractTextDocumentLayout::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-
23QAbstractTextDocumentLayout::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-
33QAbstractTextDocumentLayout::~QAbstractTextDocumentLayout()-
34{-
35}-
36void QAbstractTextDocumentLayout::registerHandler(int objectType, QObject *component)-
37{-
38 QAbstractTextDocumentLayoutPrivate * const d = d_func();-
39-
40 QTextObjectInterface *iface = qobject_cast<QTextObjectInterface *>(component);-
41 if (!iface
!ifaceDescription
TRUEnever evaluated
FALSEnever evaluated
)
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-
58void 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()
it != d->handlers.cend()Description
TRUEnever evaluated
FALSEnever evaluated
&& (!component
!componentDescription
TRUEnever evaluated
FALSEnever evaluated
|| component == it->component
component == it->componentDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
64 if (component
componentDescription
TRUEnever evaluated
FALSEnever evaluated
)
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-
73QTextObjectInterface *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
!handler.componentDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
79 return
never executed: return 0;
0;
never executed: return 0;
0
80-
81 return
never executed: return handler.iface;
handler.iface;
never executed: return handler.iface;
0
82}-
83void 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
!handler.componentDescription
TRUEnever evaluated
FALSEnever evaluated
)
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
98void 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
104void 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
!handler.componentDescription
TRUEnever evaluated
FALSEnever evaluated
)
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-
119void QAbstractTextDocumentLayoutPrivate::_q_handlerDestroyed(QObject *obj)-
120{-
121 HandlerHash::Iterator it = handlers.begin();-
122 while (it != handlers.end()
it != handlers.end()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
123 if ((*
(*it).component == objDescription
TRUEnever evaluated
FALSEnever evaluated
it).component == obj
(*it).component == objDescription
TRUEnever evaluated
FALSEnever evaluated
)
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-
134int QAbstractTextDocumentLayout::formatIndex(int pos)-
135{-
136 QTextDocumentPrivate *pieceTable = qobject_cast<QTextDocument *>(parent())->docHandle();-
137 return
never executed: return pieceTable->find(pos).value()->format;
pieceTable->find(pos).value()->format;
never executed: return pieceTable->find(pos).value()->format;
0
138}-
139-
140-
141-
142-
143-
144-
145QTextCharFormat 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: return pieceTable->formatCollection()->charFormat(idx);
pieceTable->formatCollection()->charFormat(idx);
never executed: return pieceTable->formatCollection()->charFormat(idx);
0
150}-
151-
152-
153-
154-
155-
156-
157QTextDocument *QAbstractTextDocumentLayout::document() const-
158{-
159 const QAbstractTextDocumentLayoutPrivate * const d = d_func();-
160 return
never executed: return d->document;
d->document;
never executed: return d->document;
0
161}-
162-
163-
164-
165-
166-
167-
168-
169QString QAbstractTextDocumentLayout::anchorAt(const QPointF& pos) const-
170{-
171 int cursorPos = hitTest(pos, Qt::ExactHit);-
172 if (cursorPos == -1
cursorPos == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
173 return
never executed: return QString();
QString();
never executed: return QString();
0
174-
175-
176 QTextBlock block = document()->firstBlock();-
177 while (block.isValid()
block.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
178 QRectF blockBr = blockBoundingRect(block);-
179 if (blockBr.contains(pos)
blockBr.contains(pos)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
180 QTextLayout *layout = block.layout();-
181 int relativeCursorPos = cursorPos - block.position();-
182 const int preeditLength = layout
layoutDescription
TRUEnever evaluated
FALSEnever evaluated
? layout->preeditAreaText().length() : 0;
0
183 if (preeditLength > 0
preeditLength > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& relativeCursorPos > layout->preeditAreaPosition()
relativeCursor...AreaPosition()Description
TRUEnever evaluated
FALSEnever evaluated
)
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: return fmt.anchorHref();
fmt.anchorHref();
never executed: return fmt.anchorHref();
0
194}-
195void 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-
206QPaintDevice *QAbstractTextDocumentLayout::paintDevice() const-
207{-
208 const QAbstractTextDocumentLayoutPrivate * const d = d_func();-
209 return
never executed: return d->paintDevice;
d->paintDevice;
never executed: return d->paintDevice;
0
210}-
211-
212-
213-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9