qtextlist.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/text/qtextlist.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4class QTextListPrivate : public QTextBlockGroupPrivate-
5{-
6public:-
7 QTextListPrivate(QTextDocument *doc)-
8 : QTextBlockGroupPrivate(doc)-
9 {-
10 }
never executed: end of block
0
11};-
12QTextList::QTextList(QTextDocument *doc)-
13 : QTextBlockGroup(*new QTextListPrivate(doc), doc)-
14{-
15}
never executed: end of block
0
16-
17-
18-
19-
20QTextList::~QTextList()-
21{-
22}-
23-
24-
25-
26-
27int QTextList::count() const-
28{-
29 const QTextListPrivate * const d = d_func();-
30 return
never executed: return d->blocks.count();
d->blocks.count();
never executed: return d->blocks.count();
0
31}-
32-
33-
34-
35-
36-
37-
38QTextBlock QTextList::item(int i) const-
39{-
40 const QTextListPrivate * const d = d_func();-
41 if (i < 0
i < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| i >= d->blocks.size()
i >= d->blocks.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
42 return
never executed: return QTextBlock();
QTextBlock();
never executed: return QTextBlock();
0
43 return
never executed: return d->blocks.at(i);
d->blocks.at(i);
never executed: return d->blocks.at(i);
0
44}-
45int QTextList::itemNumber(const QTextBlock &blockIt) const-
46{-
47 const QTextListPrivate * const d = d_func();-
48 return
never executed: return d->blocks.indexOf(blockIt);
d->blocks.indexOf(blockIt);
never executed: return d->blocks.indexOf(blockIt);
0
49}-
50-
51-
52-
53-
54-
55-
56QString QTextList::itemText(const QTextBlock &blockIt) const-
57{-
58 const QTextListPrivate * const d = d_func();-
59 int item = d->blocks.indexOf(blockIt) + 1;-
60 if (item <= 0
item <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
61 return
never executed: return QString();
QString();
never executed: return QString();
0
62-
63 QTextBlock block = d->blocks.at(item-1);-
64 QTextBlockFormat blockFormat = block.blockFormat();-
65-
66 QString result;-
67-
68 const int style = format().style();-
69 QString numberPrefix;-
70 QString numberSuffix = QLatin1String(".");-
71-
72 if (format().hasProperty(QTextFormat::ListNumberPrefix)
format().hasPr...tNumberPrefix)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
73 numberPrefix = format().numberPrefix();
never executed: numberPrefix = format().numberPrefix();
0
74 if (format().hasProperty(QTextFormat::ListNumberSuffix)
format().hasPr...tNumberSuffix)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
75 numberSuffix = format().numberSuffix();
never executed: numberSuffix = format().numberSuffix();
0
76-
77 switch (style) {-
78 case
never executed: case QTextListFormat::ListDecimal:
QTextListFormat::ListDecimal:
never executed: case QTextListFormat::ListDecimal:
0
79 result = QString::number(item);-
80 break;
never executed: break;
0
81-
82 case
never executed: case QTextListFormat::ListLowerAlpha:
QTextListFormat::ListLowerAlpha:
never executed: case QTextListFormat::ListLowerAlpha:
0
83 case
never executed: case QTextListFormat::ListUpperAlpha:
QTextListFormat::ListUpperAlpha:
never executed: case QTextListFormat::ListUpperAlpha:
0
84 {-
85 const char baseChar = style == QTextListFormat::ListUpperAlpha
style == QText...ListUpperAlphaDescription
TRUEnever evaluated
FALSEnever evaluated
? 'A' : 'a';
0
86-
87 int c = item;-
88 while (c > 0
c > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
89 c--;-
90 result.prepend(QChar(baseChar + (c % 26)));-
91 c /= 26;-
92 }
never executed: end of block
0
93 }-
94 break;
never executed: break;
0
95 case
never executed: case QTextListFormat::ListLowerRoman:
QTextListFormat::ListLowerRoman:
never executed: case QTextListFormat::ListLowerRoman:
0
96 case
never executed: case QTextListFormat::ListUpperRoman:
QTextListFormat::ListUpperRoman:
never executed: case QTextListFormat::ListUpperRoman:
0
97 {-
98 if (item < 5000
item < 5000Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
99 QByteArray romanNumeral;-
100-
101-
102 static const char romanSymbolsLower[] = "iiivixxxlxcccdcmmmm";-
103 static const char romanSymbolsUpper[] = "IIIVIXXXLXCCCDCMMMM";-
104 QByteArray romanSymbols;-
105 if (style == QTextListFormat::ListLowerRoman
style == QText...ListLowerRomanDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
106 romanSymbols = QByteArray::fromRawData(romanSymbolsLower, sizeof(romanSymbolsLower));
never executed: romanSymbols = QByteArray::fromRawData(romanSymbolsLower, sizeof(romanSymbolsLower));
0
107 else-
108 romanSymbols = QByteArray::fromRawData(romanSymbolsUpper, sizeof(romanSymbolsUpper));
never executed: romanSymbols = QByteArray::fromRawData(romanSymbolsUpper, sizeof(romanSymbolsUpper));
0
109-
110 int c[] = { 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000 };-
111 int n = item;-
112 for (int i = 12; i >= 0
i >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; n %= c[i], i--) {
0
113 int q = n / c[i];-
114 if (q > 0
q > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
115 int startDigit = i + (i+3)/4;-
116 int numDigits;-
117 if (i % 4
i % 4Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
118-
119 if ((
(i-2) % 4Description
TRUEnever evaluated
FALSEnever evaluated
i-2) % 4
(i-2) % 4Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
120-
121 numDigits = 2;-
122 }
never executed: end of block
0
123 else {-
124-
125 numDigits = 1;-
126 }
never executed: end of block
0
127 }-
128 else {-
129-
130 numDigits = q;-
131 }
never executed: end of block
0
132-
133 romanNumeral.append(romanSymbols.mid(startDigit, numDigits));-
134 }
never executed: end of block
0
135 }
never executed: end of block
0
136 result = QString::fromLatin1(romanNumeral);-
137 }
never executed: end of block
0
138 else {-
139 result = QLatin1String("?");-
140 }
never executed: end of block
0
141-
142 }-
143 break;
never executed: break;
0
144 default
never executed: default:
:
never executed: default:
0
145 ((!(false)) ? qt_assert("false",__FILE__,269) : qt_noop());-
146 }
never executed: end of block
0
147 if (blockIt.textDirection() == Qt::RightToLeft
blockIt.textDi...t::RightToLeftDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
148 return
never executed: return numberSuffix + result + numberPrefix;
numberSuffix + result + numberPrefix;
never executed: return numberSuffix + result + numberPrefix;
0
149 else-
150 return
never executed: return numberPrefix + result + numberSuffix;
numberPrefix + result + numberSuffix;
never executed: return numberPrefix + result + numberSuffix;
0
151}-
152void QTextList::removeItem(int i)-
153{-
154 QTextListPrivate * const d = d_func();-
155 if (i < 0
i < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| i >= d->blocks.size()
i >= d->blocks.size()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
156 return;
never executed: return;
0
157-
158 QTextBlock block = d->blocks.at(i);-
159 remove(block);-
160}
never executed: end of block
0
161-
162-
163-
164-
165-
166-
167-
168void QTextList::remove(const QTextBlock &block)-
169{-
170 QTextBlockFormat fmt = block.blockFormat();-
171 fmt.setIndent(fmt.indent() + format().indent());-
172 fmt.setObjectIndex(-1);-
173 block.docHandle()->setBlockFormat(block, block, fmt, QTextDocumentPrivate::SetFormat);-
174}
never executed: end of block
0
175-
176-
177-
178-
179-
180-
181void QTextList::add(const QTextBlock &block)-
182{-
183 QTextBlockFormat fmt = block.blockFormat();-
184 fmt.setObjectIndex(objectIndex());-
185 block.docHandle()->setBlockFormat(block, block, fmt, QTextDocumentPrivate::SetFormat);-
186}
never executed: end of block
0
187-
188-
Switch to Source codePreprocessed file

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