| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/text/qtextformat.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | QTextLength::operator QVariant() const | - | ||||||||||||||||||
| 5 | { | - | ||||||||||||||||||
| 6 | return never executed: QVariant(QVariant::TextLength, this);return QVariant(QVariant::TextLength, this);never executed: return QVariant(QVariant::TextLength, this); | 0 | ||||||||||||||||||
| 7 | } | - | ||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | QDataStream &operator<<(QDataStream &stream, const QTextLength &length) | - | ||||||||||||||||||
| 11 | { | - | ||||||||||||||||||
| 12 | return never executed: stream << qint32(length.lengthType) << double(length.fixedValueOrPercentage);return stream << qint32(length.lengthType) << double(length.fixedValueOrPercentage);never executed: return stream << qint32(length.lengthType) << double(length.fixedValueOrPercentage); | 0 | ||||||||||||||||||
| 13 | } | - | ||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | QDataStream &operator>>(QDataStream &stream, QTextLength &length) | - | ||||||||||||||||||
| 16 | { | - | ||||||||||||||||||
| 17 | qint32 type; | - | ||||||||||||||||||
| 18 | double fixedValueOrPercentage; | - | ||||||||||||||||||
| 19 | stream >> type >> fixedValueOrPercentage; | - | ||||||||||||||||||
| 20 | length.fixedValueOrPercentage = fixedValueOrPercentage; | - | ||||||||||||||||||
| 21 | length.lengthType = QTextLength::Type(type); | - | ||||||||||||||||||
| 22 | return never executed: stream;return stream;never executed: return stream; | 0 | ||||||||||||||||||
| 23 | } | - | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | class QTextFormatPrivate : public QSharedData | - | ||||||||||||||||||
| 27 | { | - | ||||||||||||||||||
| 28 | public: | - | ||||||||||||||||||
| 29 | QTextFormatPrivate() : hashDirty(true), fontDirty(true), hashValue(0) {} never executed: end of block | 0 | ||||||||||||||||||
| 30 | - | |||||||||||||||||||
| 31 | struct Property | - | ||||||||||||||||||
| 32 | { | - | ||||||||||||||||||
| 33 | inline Property(qint32 k, const QVariant &v) : key(k), value(v) {} never executed: end of block | 0 | ||||||||||||||||||
| 34 | inline Property() {} | - | ||||||||||||||||||
| 35 | - | |||||||||||||||||||
| 36 | qint32 key; | - | ||||||||||||||||||
| 37 | QVariant value; | - | ||||||||||||||||||
| 38 | - | |||||||||||||||||||
| 39 | inline bool operator==(const Property &other) const | - | ||||||||||||||||||
| 40 | { return never executed: key == other.key && value == other.value;return key == other.key && value == other.value;never executed: }return key == other.key && value == other.value; | 0 | ||||||||||||||||||
| 41 | inline bool operator!=(const Property &other) const | - | ||||||||||||||||||
| 42 | { return never executed: key != other.key || value != other.value;return key != other.key || value != other.value;never executed: }return key != other.key || value != other.value; | 0 | ||||||||||||||||||
| 43 | }; | - | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | inline uint hash() const | - | ||||||||||||||||||
| 46 | { | - | ||||||||||||||||||
| 47 | if (!hashDirty
| 0 | ||||||||||||||||||
| 48 | return never executed: hashValue;return hashValue;never executed: return hashValue; | 0 | ||||||||||||||||||
| 49 | return never executed: recalcHash();return recalcHash();never executed: return recalcHash(); | 0 | ||||||||||||||||||
| 50 | } | - | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | inline bool operator==(const QTextFormatPrivate &rhs) const { | - | ||||||||||||||||||
| 53 | if (hash() != rhs.hash()
| 0 | ||||||||||||||||||
| 54 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | return never executed: props == rhs.props;return props == rhs.props;never executed: return props == rhs.props; | 0 | ||||||||||||||||||
| 57 | } | - | ||||||||||||||||||
| 58 | - | |||||||||||||||||||
| 59 | inline void insertProperty(qint32 key, const QVariant &value) | - | ||||||||||||||||||
| 60 | { | - | ||||||||||||||||||
| 61 | hashDirty = true; | - | ||||||||||||||||||
| 62 | if (key >= QTextFormat::FirstFontProperty
| 0 | ||||||||||||||||||
| 63 | fontDirty = true; never executed: fontDirty = true; | 0 | ||||||||||||||||||
| 64 | for (int i = 0; i < props.count()
| 0 | ||||||||||||||||||
| 65 | if (props.at(i).key == key
| 0 | ||||||||||||||||||
| 66 | props[i].value = value; | - | ||||||||||||||||||
| 67 | return; never executed: return; | 0 | ||||||||||||||||||
| 68 | } | - | ||||||||||||||||||
| 69 | props.append(Property(key, value)); | - | ||||||||||||||||||
| 70 | } never executed: end of block | 0 | ||||||||||||||||||
| 71 | - | |||||||||||||||||||
| 72 | inline void clearProperty(qint32 key) | - | ||||||||||||||||||
| 73 | { | - | ||||||||||||||||||
| 74 | for (int i = 0; i < props.count()
| 0 | ||||||||||||||||||
| 75 | if (props.at(i).key == key
| 0 | ||||||||||||||||||
| 76 | hashDirty = true; | - | ||||||||||||||||||
| 77 | if (key >= QTextFormat::FirstFontProperty
| 0 | ||||||||||||||||||
| 78 | fontDirty = true; never executed: fontDirty = true; | 0 | ||||||||||||||||||
| 79 | props.remove(i); | - | ||||||||||||||||||
| 80 | return; never executed: return; | 0 | ||||||||||||||||||
| 81 | } | - | ||||||||||||||||||
| 82 | } never executed: end of block | 0 | ||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | inline int propertyIndex(qint32 key) const | - | ||||||||||||||||||
| 85 | { | - | ||||||||||||||||||
| 86 | for (int i = 0; i < props.count()
| 0 | ||||||||||||||||||
| 87 | if (props.at(i).key == key
| 0 | ||||||||||||||||||
| 88 | return never executed: i;return i;never executed: return i; | 0 | ||||||||||||||||||
| 89 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 90 | } | - | ||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | inline QVariant property(qint32 key) const | - | ||||||||||||||||||
| 93 | { | - | ||||||||||||||||||
| 94 | const int idx = propertyIndex(key); | - | ||||||||||||||||||
| 95 | if (idx < 0
| 0 | ||||||||||||||||||
| 96 | return never executed: QVariant();return QVariant();never executed: return QVariant(); | 0 | ||||||||||||||||||
| 97 | return never executed: props.at(idx).value;return props.at(idx).value;never executed: return props.at(idx).value; | 0 | ||||||||||||||||||
| 98 | } | - | ||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | inline bool hasProperty(qint32 key) const | - | ||||||||||||||||||
| 101 | { return never executed: propertyIndex(key) != -1;return propertyIndex(key) != -1;never executed: }return propertyIndex(key) != -1; | 0 | ||||||||||||||||||
| 102 | - | |||||||||||||||||||
| 103 | void resolveFont(const QFont &defaultFont); | - | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | inline const QFont &font() const { | - | ||||||||||||||||||
| 106 | if (fontDirty
| 0 | ||||||||||||||||||
| 107 | recalcFont(); never executed: recalcFont(); | 0 | ||||||||||||||||||
| 108 | return never executed: fnt;return fnt;never executed: return fnt; | 0 | ||||||||||||||||||
| 109 | } | - | ||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | QVector<Property> props; | - | ||||||||||||||||||
| 112 | private: | - | ||||||||||||||||||
| 113 | - | |||||||||||||||||||
| 114 | uint recalcHash() const; | - | ||||||||||||||||||
| 115 | void recalcFont() const; | - | ||||||||||||||||||
| 116 | - | |||||||||||||||||||
| 117 | mutable bool hashDirty; | - | ||||||||||||||||||
| 118 | mutable bool fontDirty; | - | ||||||||||||||||||
| 119 | mutable uint hashValue; | - | ||||||||||||||||||
| 120 | mutable QFont fnt; | - | ||||||||||||||||||
| 121 | - | |||||||||||||||||||
| 122 | friend QDataStream &operator<<(QDataStream &, const QTextFormat &); | - | ||||||||||||||||||
| 123 | friend QDataStream &operator>>(QDataStream &, QTextFormat &); | - | ||||||||||||||||||
| 124 | }; | - | ||||||||||||||||||
| 125 | template<> class QTypeInfo<QTextFormatPrivate::Property > { public: enum { isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QTextFormatPrivate::Property)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QTextFormatPrivate::Property >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QTextFormatPrivate::Property) }; static inline const char *name() { return "QTextFormatPrivate::Property"; } }; | - | ||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | static inline uint hash(const QColor &color) | - | ||||||||||||||||||
| 128 | { | - | ||||||||||||||||||
| 129 | return never executed: (color.isValid()) ? color.rgba() : 0x234109;return (color.isValid()) ? color.rgba() : 0x234109;never executed: return (color.isValid()) ? color.rgba() : 0x234109; | 0 | ||||||||||||||||||
| 130 | } | - | ||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 | static inline uint hash(const QPen &pen) | - | ||||||||||||||||||
| 133 | { | - | ||||||||||||||||||
| 134 | return never executed: hash(pen.color()) + qHash(pen.widthF());return hash(pen.color()) + qHash(pen.widthF());never executed: return hash(pen.color()) + qHash(pen.widthF()); | 0 | ||||||||||||||||||
| 135 | } | - | ||||||||||||||||||
| 136 | - | |||||||||||||||||||
| 137 | static inline uint hash(const QBrush &brush) | - | ||||||||||||||||||
| 138 | { | - | ||||||||||||||||||
| 139 | return never executed: hash(brush.color()) + (brush.style() << 3);return hash(brush.color()) + (brush.style() << 3);never executed: return hash(brush.color()) + (brush.style() << 3); | 0 | ||||||||||||||||||
| 140 | } | - | ||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | static inline uint variantHash(const QVariant &variant) | - | ||||||||||||||||||
| 143 | { | - | ||||||||||||||||||
| 144 | - | |||||||||||||||||||
| 145 | switch (variant.userType()) { | - | ||||||||||||||||||
| 146 | case never executed: QVariant::String:case QVariant::String:never executed: returncase QVariant::String:never executed: qHash(variant.toString());return qHash(variant.toString());never executed: return qHash(variant.toString()); | 0 | ||||||||||||||||||
| 147 | case never executed: QVariant::Double:case QVariant::Double:never executed: returncase QVariant::Double:never executed: qHash(variant.toDouble());return qHash(variant.toDouble());never executed: return qHash(variant.toDouble()); | 0 | ||||||||||||||||||
| 148 | case never executed: QVariant::Int:case QVariant::Int:never executed: returncase QVariant::Int:never executed: 0x811890 + variant.toInt();return 0x811890 + variant.toInt();never executed: return 0x811890 + variant.toInt(); | 0 | ||||||||||||||||||
| 149 | case never executed: QVariant::Brush:case QVariant::Brush:never executed: case QVariant::Brush: | 0 | ||||||||||||||||||
| 150 | return never executed: 0x01010101 + hash(qvariant_cast<QBrush>(variant));return 0x01010101 + hash(qvariant_cast<QBrush>(variant));never executed: return 0x01010101 + hash(qvariant_cast<QBrush>(variant)); | 0 | ||||||||||||||||||
| 151 | case never executed: QVariant::Bool:case QVariant::Bool:never executed: returncase QVariant::Bool:never executed: 0x371818 + variant.toBool();return 0x371818 + variant.toBool();never executed: return 0x371818 + variant.toBool(); | 0 | ||||||||||||||||||
| 152 | case never executed: QVariant::Pen:case QVariant::Pen:never executed: returncase QVariant::Pen:never executed: 0x02020202 + hash(qvariant_cast<QPen>(variant));return 0x02020202 + hash(qvariant_cast<QPen>(variant));never executed: return 0x02020202 + hash(qvariant_cast<QPen>(variant)); | 0 | ||||||||||||||||||
| 153 | case never executed: QVariant::List:case QVariant::List:never executed: case QVariant::List: | 0 | ||||||||||||||||||
| 154 | return never executed: 0x8377 + qvariant_cast<QVariantList>(variant).count();return 0x8377 + qvariant_cast<QVariantList>(variant).count();never executed: return 0x8377 + qvariant_cast<QVariantList>(variant).count(); | 0 | ||||||||||||||||||
| 155 | case never executed: QVariant::Color:case QVariant::Color:never executed: returncase QVariant::Color:never executed: hash(qvariant_cast<QColor>(variant));return hash(qvariant_cast<QColor>(variant));never executed: return hash(qvariant_cast<QColor>(variant)); | 0 | ||||||||||||||||||
| 156 | case never executed: QVariant::TextLength:case QVariant::TextLength:never executed: case QVariant::TextLength: | 0 | ||||||||||||||||||
| 157 | return never executed: 0x377 + hash(qvariant_cast<QTextLength>(variant).rawValue());return 0x377 + hash(qvariant_cast<QTextLength>(variant).rawValue());never executed: return 0x377 + hash(qvariant_cast<QTextLength>(variant).rawValue()); | 0 | ||||||||||||||||||
| 158 | case never executed: QMetaType::Float:case QMetaType::Float:never executed: returncase QMetaType::Float:never executed: qHash(variant.toFloat());return qHash(variant.toFloat());never executed: return qHash(variant.toFloat()); | 0 | ||||||||||||||||||
| 159 | case never executed: QVariant::Invalid:case QVariant::Invalid:never executed: returncase QVariant::Invalid:never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 160 | default never executed: :default:never executed: break;default:never executed: break; | 0 | ||||||||||||||||||
| 161 | } | - | ||||||||||||||||||
| 162 | return never executed: qHash(variant.typeName());return qHash(variant.typeName());never executed: return qHash(variant.typeName()); | 0 | ||||||||||||||||||
| 163 | } | - | ||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | static inline int getHash(const QTextFormatPrivate *d, int format) | - | ||||||||||||||||||
| 166 | { | - | ||||||||||||||||||
| 167 | return never executed: (d ? d->hash() : 0) + format;return (d ? d->hash() : 0) + format;never executed: return (d ? d->hash() : 0) + format; | 0 | ||||||||||||||||||
| 168 | } | - | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | uint QTextFormatPrivate::recalcHash() const | - | ||||||||||||||||||
| 171 | { | - | ||||||||||||||||||
| 172 | hashValue = 0; | - | ||||||||||||||||||
| 173 | for (QVector<Property>::ConstIterator it = props.constBegin(); it != props.constEnd()
| 0 | ||||||||||||||||||
| 174 | hashValue += (static_cast<quint32>(it->key) << 16) + variantHash(it->value); never executed: hashValue += (static_cast<quint32>(it->key) << 16) + variantHash(it->value); | 0 | ||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | hashDirty = false; | - | ||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | return never executed: hashValue;return hashValue;never executed: return hashValue; | 0 | ||||||||||||||||||
| 179 | } | - | ||||||||||||||||||
| 180 | - | |||||||||||||||||||
| 181 | void QTextFormatPrivate::resolveFont(const QFont &defaultFont) | - | ||||||||||||||||||
| 182 | { | - | ||||||||||||||||||
| 183 | recalcFont(); | - | ||||||||||||||||||
| 184 | const uint oldMask = fnt.resolve(); | - | ||||||||||||||||||
| 185 | fnt = fnt.resolve(defaultFont); | - | ||||||||||||||||||
| 186 | - | |||||||||||||||||||
| 187 | if (hasProperty(QTextFormat::FontSizeAdjustment)
| 0 | ||||||||||||||||||
| 188 | const qreal scaleFactors[7] = {qreal(0.7), qreal(0.8), qreal(1.0), qreal(1.2), qreal(1.5), qreal(2), qreal(2.4)}; | - | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | const int htmlFontSize = qBound(0, property(QTextFormat::FontSizeAdjustment).toInt() + 3 - 1, 6); | - | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | if (defaultFont.pointSize() <= 0
| 0 | ||||||||||||||||||
| 194 | qreal pixelSize = scaleFactors[htmlFontSize] * defaultFont.pixelSize(); | - | ||||||||||||||||||
| 195 | fnt.setPixelSize(qRound(pixelSize)); | - | ||||||||||||||||||
| 196 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 197 | qreal pointSize = scaleFactors[htmlFontSize] * defaultFont.pointSizeF(); | - | ||||||||||||||||||
| 198 | fnt.setPointSizeF(pointSize); | - | ||||||||||||||||||
| 199 | } never executed: end of block | 0 | ||||||||||||||||||
| 200 | } | - | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | fnt.resolve(oldMask); | - | ||||||||||||||||||
| 203 | } never executed: end of block | 0 | ||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | void QTextFormatPrivate::recalcFont() const | - | ||||||||||||||||||
| 206 | { | - | ||||||||||||||||||
| 207 | - | |||||||||||||||||||
| 208 | QFont f; | - | ||||||||||||||||||
| 209 | - | |||||||||||||||||||
| 210 | bool hasSpacingInformation = false; | - | ||||||||||||||||||
| 211 | QFont::SpacingType spacingType = QFont::PercentageSpacing; | - | ||||||||||||||||||
| 212 | qreal letterSpacing = 0.0; | - | ||||||||||||||||||
| 213 | - | |||||||||||||||||||
| 214 | for (int i = 0; i < props.count()
| 0 | ||||||||||||||||||
| 215 | switch (props.at(i).key) { | - | ||||||||||||||||||
| 216 | case never executed: QTextFormat::FontFamily:case QTextFormat::FontFamily:never executed: case QTextFormat::FontFamily: | 0 | ||||||||||||||||||
| 217 | f.setFamily(props.at(i).value.toString()); | - | ||||||||||||||||||
| 218 | break; never executed: break; | 0 | ||||||||||||||||||
| 219 | case never executed: QTextFormat::FontPointSize:case QTextFormat::FontPointSize:never executed: case QTextFormat::FontPointSize: | 0 | ||||||||||||||||||
| 220 | f.setPointSizeF(props.at(i).value.toReal()); | - | ||||||||||||||||||
| 221 | break; never executed: break; | 0 | ||||||||||||||||||
| 222 | case never executed: QTextFormat::FontPixelSize:case QTextFormat::FontPixelSize:never executed: case QTextFormat::FontPixelSize: | 0 | ||||||||||||||||||
| 223 | f.setPixelSize(props.at(i).value.toInt()); | - | ||||||||||||||||||
| 224 | break; never executed: break; | 0 | ||||||||||||||||||
| 225 | case never executed: QTextFormat::FontWeight:case QTextFormat::FontWeight:never executed: {case QTextFormat::FontWeight: | 0 | ||||||||||||||||||
| 226 | const QVariant weightValue = props.at(i).value; | - | ||||||||||||||||||
| 227 | int weight = weightValue.toInt(); | - | ||||||||||||||||||
| 228 | if (weight >= 0
| 0 | ||||||||||||||||||
| 229 | f.setWeight(weight); never executed: f.setWeight(weight); | 0 | ||||||||||||||||||
| 230 | break; never executed: }break; | 0 | ||||||||||||||||||
| 231 | case never executed: QTextFormat::FontItalic:case QTextFormat::FontItalic:never executed: case QTextFormat::FontItalic: | 0 | ||||||||||||||||||
| 232 | f.setItalic(props.at(i).value.toBool()); | - | ||||||||||||||||||
| 233 | break; never executed: break; | 0 | ||||||||||||||||||
| 234 | case never executed: QTextFormat::FontUnderline:case QTextFormat::FontUnderline:never executed: case QTextFormat::FontUnderline: | 0 | ||||||||||||||||||
| 235 | if (! hasProperty(QTextFormat::TextUnderlineStyle)
| 0 | ||||||||||||||||||
| 236 | f.setUnderline(props.at(i).value.toBool()); never executed: f.setUnderline(props.at(i).value.toBool()); | 0 | ||||||||||||||||||
| 237 | break; never executed: break; | 0 | ||||||||||||||||||
| 238 | case never executed: QTextFormat::TextUnderlineStyle:case QTextFormat::TextUnderlineStyle:never executed: case QTextFormat::TextUnderlineStyle: | 0 | ||||||||||||||||||
| 239 | f.setUnderline(static_cast<QTextCharFormat::UnderlineStyle>(props.at(i).value.toInt()) == QTextCharFormat::SingleUnderline); | - | ||||||||||||||||||
| 240 | break; never executed: break; | 0 | ||||||||||||||||||
| 241 | case never executed: QTextFormat::FontOverline:case QTextFormat::FontOverline:never executed: case QTextFormat::FontOverline: | 0 | ||||||||||||||||||
| 242 | f.setOverline(props.at(i).value.toBool()); | - | ||||||||||||||||||
| 243 | break; never executed: break; | 0 | ||||||||||||||||||
| 244 | case never executed: QTextFormat::FontStrikeOut:case QTextFormat::FontStrikeOut:never executed: case QTextFormat::FontStrikeOut: | 0 | ||||||||||||||||||
| 245 | f.setStrikeOut(props.at(i).value.toBool()); | - | ||||||||||||||||||
| 246 | break; never executed: break; | 0 | ||||||||||||||||||
| 247 | case never executed: QTextFormat::FontLetterSpacingType:case QTextFormat::FontLetterSpacingType:never executed: case QTextFormat::FontLetterSpacingType: | 0 | ||||||||||||||||||
| 248 | spacingType = static_cast<QFont::SpacingType>(props.at(i).value.toInt()); | - | ||||||||||||||||||
| 249 | hasSpacingInformation = true; | - | ||||||||||||||||||
| 250 | break; never executed: break; | 0 | ||||||||||||||||||
| 251 | case never executed: QTextFormat::FontLetterSpacing:case QTextFormat::FontLetterSpacing:never executed: case QTextFormat::FontLetterSpacing: | 0 | ||||||||||||||||||
| 252 | letterSpacing = props.at(i).value.toReal(); | - | ||||||||||||||||||
| 253 | hasSpacingInformation = true; | - | ||||||||||||||||||
| 254 | break; never executed: break; | 0 | ||||||||||||||||||
| 255 | case never executed: QTextFormat::FontWordSpacing:case QTextFormat::FontWordSpacing:never executed: case QTextFormat::FontWordSpacing: | 0 | ||||||||||||||||||
| 256 | f.setWordSpacing(props.at(i).value.toReal()); | - | ||||||||||||||||||
| 257 | break; never executed: break; | 0 | ||||||||||||||||||
| 258 | case never executed: QTextFormat::FontCapitalization:case QTextFormat::FontCapitalization:never executed: case QTextFormat::FontCapitalization: | 0 | ||||||||||||||||||
| 259 | f.setCapitalization(static_cast<QFont::Capitalization> (props.at(i).value.toInt())); | - | ||||||||||||||||||
| 260 | break; never executed: break; | 0 | ||||||||||||||||||
| 261 | case never executed: QTextFormat::FontFixedPitch:case QTextFormat::FontFixedPitch:never executed: {case QTextFormat::FontFixedPitch: | 0 | ||||||||||||||||||
| 262 | const bool value = props.at(i).value.toBool(); | - | ||||||||||||||||||
| 263 | if (f.fixedPitch() != value
| 0 | ||||||||||||||||||
| 264 | f.setFixedPitch(value); never executed: f.setFixedPitch(value); | 0 | ||||||||||||||||||
| 265 | break; never executed: }break; | 0 | ||||||||||||||||||
| 266 | case never executed: QTextFormat::FontStretch:case QTextFormat::FontStretch:never executed: case QTextFormat::FontStretch: | 0 | ||||||||||||||||||
| 267 | f.setStretch(props.at(i).value.toInt()); | - | ||||||||||||||||||
| 268 | break; never executed: break; | 0 | ||||||||||||||||||
| 269 | case never executed: QTextFormat::FontStyleHint:case QTextFormat::FontStyleHint:never executed: case QTextFormat::FontStyleHint: | 0 | ||||||||||||||||||
| 270 | f.setStyleHint(static_cast<QFont::StyleHint>(props.at(i).value.toInt()), f.styleStrategy()); | - | ||||||||||||||||||
| 271 | break; never executed: break; | 0 | ||||||||||||||||||
| 272 | case never executed: QTextFormat::FontHintingPreference:case QTextFormat::FontHintingPreference:never executed: case QTextFormat::FontHintingPreference: | 0 | ||||||||||||||||||
| 273 | f.setHintingPreference(static_cast<QFont::HintingPreference>(props.at(i).value.toInt())); | - | ||||||||||||||||||
| 274 | break; never executed: break; | 0 | ||||||||||||||||||
| 275 | case never executed: QTextFormat::FontStyleStrategy:case QTextFormat::FontStyleStrategy:never executed: case QTextFormat::FontStyleStrategy: | 0 | ||||||||||||||||||
| 276 | f.setStyleStrategy(static_cast<QFont::StyleStrategy>(props.at(i).value.toInt())); | - | ||||||||||||||||||
| 277 | break; never executed: break; | 0 | ||||||||||||||||||
| 278 | case never executed: QTextFormat::FontKerning:case QTextFormat::FontKerning:never executed: case QTextFormat::FontKerning: | 0 | ||||||||||||||||||
| 279 | f.setKerning(props.at(i).value.toBool()); | - | ||||||||||||||||||
| 280 | break; never executed: break; | 0 | ||||||||||||||||||
| 281 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 282 | break; never executed: break; | 0 | ||||||||||||||||||
| 283 | } | - | ||||||||||||||||||
| 284 | } | - | ||||||||||||||||||
| 285 | - | |||||||||||||||||||
| 286 | if (hasSpacingInformation
| 0 | ||||||||||||||||||
| 287 | f.setLetterSpacing(spacingType, letterSpacing); never executed: f.setLetterSpacing(spacingType, letterSpacing); | 0 | ||||||||||||||||||
| 288 | - | |||||||||||||||||||
| 289 | fnt = f; | - | ||||||||||||||||||
| 290 | fontDirty = false; | - | ||||||||||||||||||
| 291 | } never executed: end of block | 0 | ||||||||||||||||||
| 292 | - | |||||||||||||||||||
| 293 | - | |||||||||||||||||||
| 294 | __attribute__((visibility("default"))) QDataStream &operator<<(QDataStream &stream, const QTextFormat &fmt) | - | ||||||||||||||||||
| 295 | { | - | ||||||||||||||||||
| 296 | stream << fmt.format_type << fmt.properties(); | - | ||||||||||||||||||
| 297 | return never executed: stream;return stream;never executed: return stream; | 0 | ||||||||||||||||||
| 298 | } | - | ||||||||||||||||||
| 299 | - | |||||||||||||||||||
| 300 | __attribute__((visibility("default"))) QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt) | - | ||||||||||||||||||
| 301 | { | - | ||||||||||||||||||
| 302 | QMap<qint32, QVariant> properties; | - | ||||||||||||||||||
| 303 | stream >> fmt.format_type >> properties; | - | ||||||||||||||||||
| 304 | - | |||||||||||||||||||
| 305 | - | |||||||||||||||||||
| 306 | - | |||||||||||||||||||
| 307 | if(!fmt.d
| 0 | ||||||||||||||||||
| 308 | fmt.d = new QTextFormatPrivate(); never executed: fmt.d = new QTextFormatPrivate(); | 0 | ||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | for (QMap<qint32, QVariant>::ConstIterator it = properties.constBegin(); | - | ||||||||||||||||||
| 311 | it != properties.constEnd()
| 0 | ||||||||||||||||||
| 312 | fmt.d->insertProperty(it.key(), it.value()); never executed: fmt.d->insertProperty(it.key(), it.value()); | 0 | ||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | return never executed: stream;return stream;never executed: return stream; | 0 | ||||||||||||||||||
| 315 | } | - | ||||||||||||||||||
| 316 | QTextFormat::QTextFormat() | - | ||||||||||||||||||
| 317 | : format_type(InvalidFormat) | - | ||||||||||||||||||
| 318 | { | - | ||||||||||||||||||
| 319 | } never executed: end of block | 0 | ||||||||||||||||||
| 320 | - | |||||||||||||||||||
| 321 | - | |||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | - | |||||||||||||||||||
| 324 | - | |||||||||||||||||||
| 325 | - | |||||||||||||||||||
| 326 | QTextFormat::QTextFormat(int type) | - | ||||||||||||||||||
| 327 | : format_type(type) | - | ||||||||||||||||||
| 328 | { | - | ||||||||||||||||||
| 329 | } never executed: end of block | 0 | ||||||||||||||||||
| 330 | QTextFormat::QTextFormat(const QTextFormat &rhs) | - | ||||||||||||||||||
| 331 | : d(rhs.d), format_type(rhs.format_type) | - | ||||||||||||||||||
| 332 | { | - | ||||||||||||||||||
| 333 | } never executed: end of block | 0 | ||||||||||||||||||
| 334 | - | |||||||||||||||||||
| 335 | - | |||||||||||||||||||
| 336 | - | |||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | - | |||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | - | |||||||||||||||||||
| 341 | QTextFormat &QTextFormat::operator=(const QTextFormat &rhs) | - | ||||||||||||||||||
| 342 | { | - | ||||||||||||||||||
| 343 | d = rhs.d; | - | ||||||||||||||||||
| 344 | format_type = rhs.format_type; | - | ||||||||||||||||||
| 345 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||||||||
| 346 | } | - | ||||||||||||||||||
| 347 | QTextFormat::~QTextFormat() | - | ||||||||||||||||||
| 348 | { | - | ||||||||||||||||||
| 349 | } | - | ||||||||||||||||||
| 350 | - | |||||||||||||||||||
| 351 | - | |||||||||||||||||||
| 352 | - | |||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | - | |||||||||||||||||||
| 355 | QTextFormat::operator QVariant() const | - | ||||||||||||||||||
| 356 | { | - | ||||||||||||||||||
| 357 | return never executed: QVariant(QVariant::TextFormat, this);return QVariant(QVariant::TextFormat, this);never executed: return QVariant(QVariant::TextFormat, this); | 0 | ||||||||||||||||||
| 358 | } | - | ||||||||||||||||||
| 359 | - | |||||||||||||||||||
| 360 | - | |||||||||||||||||||
| 361 | - | |||||||||||||||||||
| 362 | - | |||||||||||||||||||
| 363 | - | |||||||||||||||||||
| 364 | void QTextFormat::merge(const QTextFormat &other) | - | ||||||||||||||||||
| 365 | { | - | ||||||||||||||||||
| 366 | if (format_type != other.format_type
| 0 | ||||||||||||||||||
| 367 | return; never executed: return; | 0 | ||||||||||||||||||
| 368 | - | |||||||||||||||||||
| 369 | if (!d
| 0 | ||||||||||||||||||
| 370 | d = other.d; | - | ||||||||||||||||||
| 371 | return; never executed: return; | 0 | ||||||||||||||||||
| 372 | } | - | ||||||||||||||||||
| 373 | - | |||||||||||||||||||
| 374 | if (!other.d
| 0 | ||||||||||||||||||
| 375 | return; never executed: return; | 0 | ||||||||||||||||||
| 376 | - | |||||||||||||||||||
| 377 | QTextFormatPrivate *d = this->d; | - | ||||||||||||||||||
| 378 | - | |||||||||||||||||||
| 379 | const QVector<QTextFormatPrivate::Property> &otherProps = other.d->props; | - | ||||||||||||||||||
| 380 | d->props.reserve(d->props.size() + otherProps.size()); | - | ||||||||||||||||||
| 381 | for (int i = 0; i < otherProps.count()
| 0 | ||||||||||||||||||
| 382 | const QTextFormatPrivate::Property &p = otherProps.at(i); | - | ||||||||||||||||||
| 383 | d->insertProperty(p.key, p.value); | - | ||||||||||||||||||
| 384 | } never executed: end of block | 0 | ||||||||||||||||||
| 385 | } never executed: end of block | 0 | ||||||||||||||||||
| 386 | - | |||||||||||||||||||
| 387 | - | |||||||||||||||||||
| 388 | - | |||||||||||||||||||
| 389 | - | |||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | - | |||||||||||||||||||
| 392 | int QTextFormat::type() const | - | ||||||||||||||||||
| 393 | { | - | ||||||||||||||||||
| 394 | return never executed: format_type;return format_type;never executed: return format_type; | 0 | ||||||||||||||||||
| 395 | } | - | ||||||||||||||||||
| 396 | - | |||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | - | |||||||||||||||||||
| 399 | - | |||||||||||||||||||
| 400 | QTextBlockFormat QTextFormat::toBlockFormat() const | - | ||||||||||||||||||
| 401 | { | - | ||||||||||||||||||
| 402 | return never executed: QTextBlockFormat(*this);return QTextBlockFormat(*this);never executed: return QTextBlockFormat(*this); | 0 | ||||||||||||||||||
| 403 | } | - | ||||||||||||||||||
| 404 | - | |||||||||||||||||||
| 405 | - | |||||||||||||||||||
| 406 | - | |||||||||||||||||||
| 407 | - | |||||||||||||||||||
| 408 | QTextCharFormat QTextFormat::toCharFormat() const | - | ||||||||||||||||||
| 409 | { | - | ||||||||||||||||||
| 410 | return never executed: QTextCharFormat(*this);return QTextCharFormat(*this);never executed: return QTextCharFormat(*this); | 0 | ||||||||||||||||||
| 411 | } | - | ||||||||||||||||||
| 412 | - | |||||||||||||||||||
| 413 | - | |||||||||||||||||||
| 414 | - | |||||||||||||||||||
| 415 | - | |||||||||||||||||||
| 416 | QTextListFormat QTextFormat::toListFormat() const | - | ||||||||||||||||||
| 417 | { | - | ||||||||||||||||||
| 418 | return never executed: QTextListFormat(*this);return QTextListFormat(*this);never executed: return QTextListFormat(*this); | 0 | ||||||||||||||||||
| 419 | } | - | ||||||||||||||||||
| 420 | - | |||||||||||||||||||
| 421 | - | |||||||||||||||||||
| 422 | - | |||||||||||||||||||
| 423 | - | |||||||||||||||||||
| 424 | QTextTableFormat QTextFormat::toTableFormat() const | - | ||||||||||||||||||
| 425 | { | - | ||||||||||||||||||
| 426 | return never executed: QTextTableFormat(*this);return QTextTableFormat(*this);never executed: return QTextTableFormat(*this); | 0 | ||||||||||||||||||
| 427 | } | - | ||||||||||||||||||
| 428 | - | |||||||||||||||||||
| 429 | - | |||||||||||||||||||
| 430 | - | |||||||||||||||||||
| 431 | - | |||||||||||||||||||
| 432 | QTextFrameFormat QTextFormat::toFrameFormat() const | - | ||||||||||||||||||
| 433 | { | - | ||||||||||||||||||
| 434 | return never executed: QTextFrameFormat(*this);return QTextFrameFormat(*this);never executed: return QTextFrameFormat(*this); | 0 | ||||||||||||||||||
| 435 | } | - | ||||||||||||||||||
| 436 | - | |||||||||||||||||||
| 437 | - | |||||||||||||||||||
| 438 | - | |||||||||||||||||||
| 439 | - | |||||||||||||||||||
| 440 | QTextImageFormat QTextFormat::toImageFormat() const | - | ||||||||||||||||||
| 441 | { | - | ||||||||||||||||||
| 442 | return never executed: QTextImageFormat(*this);return QTextImageFormat(*this);never executed: return QTextImageFormat(*this); | 0 | ||||||||||||||||||
| 443 | } | - | ||||||||||||||||||
| 444 | - | |||||||||||||||||||
| 445 | - | |||||||||||||||||||
| 446 | - | |||||||||||||||||||
| 447 | - | |||||||||||||||||||
| 448 | - | |||||||||||||||||||
| 449 | - | |||||||||||||||||||
| 450 | QTextTableCellFormat QTextFormat::toTableCellFormat() const | - | ||||||||||||||||||
| 451 | { | - | ||||||||||||||||||
| 452 | return never executed: QTextTableCellFormat(*this);return QTextTableCellFormat(*this);never executed: return QTextTableCellFormat(*this); | 0 | ||||||||||||||||||
| 453 | } | - | ||||||||||||||||||
| 454 | bool QTextFormat::boolProperty(int propertyId) const | - | ||||||||||||||||||
| 455 | { | - | ||||||||||||||||||
| 456 | if (!d
| 0 | ||||||||||||||||||
| 457 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 458 | const QVariant prop = d->property(propertyId); | - | ||||||||||||||||||
| 459 | if (prop.userType() != QVariant::Bool
| 0 | ||||||||||||||||||
| 460 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 461 | return never executed: prop.toBool();return prop.toBool();never executed: return prop.toBool(); | 0 | ||||||||||||||||||
| 462 | } | - | ||||||||||||||||||
| 463 | int QTextFormat::intProperty(int propertyId) const | - | ||||||||||||||||||
| 464 | { | - | ||||||||||||||||||
| 465 | - | |||||||||||||||||||
| 466 | int def = (
| 0 | ||||||||||||||||||
| 467 | - | |||||||||||||||||||
| 468 | if (!d
| 0 | ||||||||||||||||||
| 469 | return never executed: def;return def;never executed: return def; | 0 | ||||||||||||||||||
| 470 | const QVariant prop = d->property(propertyId); | - | ||||||||||||||||||
| 471 | if (prop.userType() != QVariant::Int
| 0 | ||||||||||||||||||
| 472 | return never executed: def;return def;never executed: return def; | 0 | ||||||||||||||||||
| 473 | return never executed: prop.toInt();return prop.toInt();never executed: return prop.toInt(); | 0 | ||||||||||||||||||
| 474 | } | - | ||||||||||||||||||
| 475 | qreal QTextFormat::doubleProperty(int propertyId) const | - | ||||||||||||||||||
| 476 | { | - | ||||||||||||||||||
| 477 | if (!d
| 0 | ||||||||||||||||||
| 478 | return never executed: 0.;return 0.;never executed: return 0.; | 0 | ||||||||||||||||||
| 479 | const QVariant prop = d->property(propertyId); | - | ||||||||||||||||||
| 480 | if (prop.userType() != QVariant::Double
| 0 | ||||||||||||||||||
| 481 | return never executed: 0.;return 0.;never executed: return 0.; | 0 | ||||||||||||||||||
| 482 | return never executed: qvariant_cast<qreal>(prop);return qvariant_cast<qreal>(prop);never executed: return qvariant_cast<qreal>(prop); | 0 | ||||||||||||||||||
| 483 | } | - | ||||||||||||||||||
| 484 | QString QTextFormat::stringProperty(int propertyId) const | - | ||||||||||||||||||
| 485 | { | - | ||||||||||||||||||
| 486 | if (!d
| 0 | ||||||||||||||||||
| 487 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||
| 488 | const QVariant prop = d->property(propertyId); | - | ||||||||||||||||||
| 489 | if (prop.userType() != QVariant::String
| 0 | ||||||||||||||||||
| 490 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||
| 491 | return never executed: prop.toString();return prop.toString();never executed: return prop.toString(); | 0 | ||||||||||||||||||
| 492 | } | - | ||||||||||||||||||
| 493 | QColor QTextFormat::colorProperty(int propertyId) const | - | ||||||||||||||||||
| 494 | { | - | ||||||||||||||||||
| 495 | if (!d
| 0 | ||||||||||||||||||
| 496 | return never executed: QColor();return QColor();never executed: return QColor(); | 0 | ||||||||||||||||||
| 497 | const QVariant prop = d->property(propertyId); | - | ||||||||||||||||||
| 498 | if (prop.userType() != QVariant::Color
| 0 | ||||||||||||||||||
| 499 | return never executed: QColor();return QColor();never executed: return QColor(); | 0 | ||||||||||||||||||
| 500 | return never executed: qvariant_cast<QColor>(prop);return qvariant_cast<QColor>(prop);never executed: return qvariant_cast<QColor>(prop); | 0 | ||||||||||||||||||
| 501 | } | - | ||||||||||||||||||
| 502 | QPen QTextFormat::penProperty(int propertyId) const | - | ||||||||||||||||||
| 503 | { | - | ||||||||||||||||||
| 504 | if (!d
| 0 | ||||||||||||||||||
| 505 | return never executed: QPen(Qt::NoPen);return QPen(Qt::NoPen);never executed: return QPen(Qt::NoPen); | 0 | ||||||||||||||||||
| 506 | const QVariant prop = d->property(propertyId); | - | ||||||||||||||||||
| 507 | if (prop.userType() != QVariant::Pen
| 0 | ||||||||||||||||||
| 508 | return never executed: QPen(Qt::NoPen);return QPen(Qt::NoPen);never executed: return QPen(Qt::NoPen); | 0 | ||||||||||||||||||
| 509 | return never executed: qvariant_cast<QPen>(prop);return qvariant_cast<QPen>(prop);never executed: return qvariant_cast<QPen>(prop); | 0 | ||||||||||||||||||
| 510 | } | - | ||||||||||||||||||
| 511 | QBrush QTextFormat::brushProperty(int propertyId) const | - | ||||||||||||||||||
| 512 | { | - | ||||||||||||||||||
| 513 | if (!d
| 0 | ||||||||||||||||||
| 514 | return never executed: QBrush(Qt::NoBrush);return QBrush(Qt::NoBrush);never executed: return QBrush(Qt::NoBrush); | 0 | ||||||||||||||||||
| 515 | const QVariant prop = d->property(propertyId); | - | ||||||||||||||||||
| 516 | if (prop.userType() != QVariant::Brush
| 0 | ||||||||||||||||||
| 517 | return never executed: QBrush(Qt::NoBrush);return QBrush(Qt::NoBrush);never executed: return QBrush(Qt::NoBrush); | 0 | ||||||||||||||||||
| 518 | return never executed: qvariant_cast<QBrush>(prop);return qvariant_cast<QBrush>(prop);never executed: return qvariant_cast<QBrush>(prop); | 0 | ||||||||||||||||||
| 519 | } | - | ||||||||||||||||||
| 520 | - | |||||||||||||||||||
| 521 | - | |||||||||||||||||||
| 522 | - | |||||||||||||||||||
| 523 | - | |||||||||||||||||||
| 524 | - | |||||||||||||||||||
| 525 | - | |||||||||||||||||||
| 526 | - | |||||||||||||||||||
| 527 | QTextLength QTextFormat::lengthProperty(int propertyId) const | - | ||||||||||||||||||
| 528 | { | - | ||||||||||||||||||
| 529 | if (!d
| 0 | ||||||||||||||||||
| 530 | return never executed: QTextLength();return QTextLength();never executed: return QTextLength(); | 0 | ||||||||||||||||||
| 531 | return never executed: qvariant_cast<QTextLength>(d->property(propertyId));return qvariant_cast<QTextLength>(d->property(propertyId));never executed: return qvariant_cast<QTextLength>(d->property(propertyId)); | 0 | ||||||||||||||||||
| 532 | } | - | ||||||||||||||||||
| 533 | QVector<QTextLength> QTextFormat::lengthVectorProperty(int propertyId) const | - | ||||||||||||||||||
| 534 | { | - | ||||||||||||||||||
| 535 | QVector<QTextLength> vector; | - | ||||||||||||||||||
| 536 | if (!d
| 0 | ||||||||||||||||||
| 537 | return never executed: vector;return vector;never executed: return vector; | 0 | ||||||||||||||||||
| 538 | const QVariant prop = d->property(propertyId); | - | ||||||||||||||||||
| 539 | if (prop.userType() != QVariant::List
| 0 | ||||||||||||||||||
| 540 | return never executed: vector;return vector;never executed: return vector; | 0 | ||||||||||||||||||
| 541 | - | |||||||||||||||||||
| 542 | QList<QVariant> propertyList = prop.toList(); | - | ||||||||||||||||||
| 543 | for (int i=0; i<propertyList.size()
| 0 | ||||||||||||||||||
| 544 | QVariant var = propertyList.at(i); | - | ||||||||||||||||||
| 545 | if (var.userType() == QVariant::TextLength
| 0 | ||||||||||||||||||
| 546 | vector.append(qvariant_cast<QTextLength>(var)); never executed: vector.append(qvariant_cast<QTextLength>(var)); | 0 | ||||||||||||||||||
| 547 | } never executed: end of block | 0 | ||||||||||||||||||
| 548 | - | |||||||||||||||||||
| 549 | return never executed: vector;return vector;never executed: return vector; | 0 | ||||||||||||||||||
| 550 | } | - | ||||||||||||||||||
| 551 | - | |||||||||||||||||||
| 552 | - | |||||||||||||||||||
| 553 | - | |||||||||||||||||||
| 554 | - | |||||||||||||||||||
| 555 | - | |||||||||||||||||||
| 556 | - | |||||||||||||||||||
| 557 | QVariant QTextFormat::property(int propertyId) const | - | ||||||||||||||||||
| 558 | { | - | ||||||||||||||||||
| 559 | return never executed: d ? d->property(propertyId) : QVariant();return d ? d->property(propertyId) : QVariant();never executed: return d ? d->property(propertyId) : QVariant(); | 0 | ||||||||||||||||||
| 560 | } | - | ||||||||||||||||||
| 561 | - | |||||||||||||||||||
| 562 | - | |||||||||||||||||||
| 563 | - | |||||||||||||||||||
| 564 | - | |||||||||||||||||||
| 565 | - | |||||||||||||||||||
| 566 | - | |||||||||||||||||||
| 567 | void QTextFormat::setProperty(int propertyId, const QVariant &value) | - | ||||||||||||||||||
| 568 | { | - | ||||||||||||||||||
| 569 | if (!d
| 0 | ||||||||||||||||||
| 570 | d = new QTextFormatPrivate; never executed: d = new QTextFormatPrivate; | 0 | ||||||||||||||||||
| 571 | if (!value.isValid()
| 0 | ||||||||||||||||||
| 572 | clearProperty(propertyId); never executed: clearProperty(propertyId); | 0 | ||||||||||||||||||
| 573 | else | - | ||||||||||||||||||
| 574 | d->insertProperty(propertyId, value); never executed: d->insertProperty(propertyId, value); | 0 | ||||||||||||||||||
| 575 | } | - | ||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | - | |||||||||||||||||||
| 578 | - | |||||||||||||||||||
| 579 | - | |||||||||||||||||||
| 580 | - | |||||||||||||||||||
| 581 | - | |||||||||||||||||||
| 582 | void QTextFormat::setProperty(int propertyId, const QVector<QTextLength> &value) | - | ||||||||||||||||||
| 583 | { | - | ||||||||||||||||||
| 584 | if (!d
| 0 | ||||||||||||||||||
| 585 | d = new QTextFormatPrivate; never executed: d = new QTextFormatPrivate; | 0 | ||||||||||||||||||
| 586 | QVariantList list; | - | ||||||||||||||||||
| 587 | const int numValues = value.size(); | - | ||||||||||||||||||
| 588 | list.reserve(numValues); | - | ||||||||||||||||||
| 589 | for (int i = 0; i < numValues
| 0 | ||||||||||||||||||
| 590 | list << value.at(i); never executed: list << value.at(i); | 0 | ||||||||||||||||||
| 591 | d->insertProperty(propertyId, list); | - | ||||||||||||||||||
| 592 | } never executed: end of block | 0 | ||||||||||||||||||
| 593 | - | |||||||||||||||||||
| 594 | - | |||||||||||||||||||
| 595 | - | |||||||||||||||||||
| 596 | - | |||||||||||||||||||
| 597 | - | |||||||||||||||||||
| 598 | - | |||||||||||||||||||
| 599 | void QTextFormat::clearProperty(int propertyId) | - | ||||||||||||||||||
| 600 | { | - | ||||||||||||||||||
| 601 | if (!d
| 0 | ||||||||||||||||||
| 602 | return; never executed: return; | 0 | ||||||||||||||||||
| 603 | d->clearProperty(propertyId); | - | ||||||||||||||||||
| 604 | } never executed: end of block | 0 | ||||||||||||||||||
| 605 | int QTextFormat::objectIndex() const | - | ||||||||||||||||||
| 606 | { | - | ||||||||||||||||||
| 607 | if (!d
| 0 | ||||||||||||||||||
| 608 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 609 | const QVariant prop = d->property(ObjectIndex); | - | ||||||||||||||||||
| 610 | if (prop.userType() != QVariant::Int
| 0 | ||||||||||||||||||
| 611 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 612 | return never executed: prop.toInt();return prop.toInt();never executed: return prop.toInt(); | 0 | ||||||||||||||||||
| 613 | } | - | ||||||||||||||||||
| 614 | void QTextFormat::setObjectIndex(int o) | - | ||||||||||||||||||
| 615 | { | - | ||||||||||||||||||
| 616 | if (o == -1
| 0 | ||||||||||||||||||
| 617 | if (d
| 0 | ||||||||||||||||||
| 618 | d->clearProperty(ObjectIndex); never executed: d->clearProperty(ObjectIndex); | 0 | ||||||||||||||||||
| 619 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 620 | if (!d
| 0 | ||||||||||||||||||
| 621 | d = new QTextFormatPrivate; never executed: d = new QTextFormatPrivate; | 0 | ||||||||||||||||||
| 622 | - | |||||||||||||||||||
| 623 | d->insertProperty(ObjectIndex, o); | - | ||||||||||||||||||
| 624 | } never executed: end of block | 0 | ||||||||||||||||||
| 625 | } | - | ||||||||||||||||||
| 626 | - | |||||||||||||||||||
| 627 | - | |||||||||||||||||||
| 628 | - | |||||||||||||||||||
| 629 | - | |||||||||||||||||||
| 630 | - | |||||||||||||||||||
| 631 | - | |||||||||||||||||||
| 632 | - | |||||||||||||||||||
| 633 | bool QTextFormat::hasProperty(int propertyId) const | - | ||||||||||||||||||
| 634 | { | - | ||||||||||||||||||
| 635 | return never executed: d ? d->hasProperty(propertyId) : false;return d ? d->hasProperty(propertyId) : false;never executed: return d ? d->hasProperty(propertyId) : false; | 0 | ||||||||||||||||||
| 636 | } | - | ||||||||||||||||||
| 637 | QMap<int, QVariant> QTextFormat::properties() const | - | ||||||||||||||||||
| 638 | { | - | ||||||||||||||||||
| 639 | QMap<int, QVariant> map; | - | ||||||||||||||||||
| 640 | if (d
| 0 | ||||||||||||||||||
| 641 | for (int i = 0; i < d->props.count()
| 0 | ||||||||||||||||||
| 642 | map.insert(d->props.at(i).key, d->props.at(i).value); never executed: map.insert(d->props.at(i).key, d->props.at(i).value); | 0 | ||||||||||||||||||
| 643 | } never executed: end of block | 0 | ||||||||||||||||||
| 644 | return never executed: map;return map;never executed: return map; | 0 | ||||||||||||||||||
| 645 | } | - | ||||||||||||||||||
| 646 | - | |||||||||||||||||||
| 647 | - | |||||||||||||||||||
| 648 | - | |||||||||||||||||||
| 649 | - | |||||||||||||||||||
| 650 | - | |||||||||||||||||||
| 651 | int QTextFormat::propertyCount() const | - | ||||||||||||||||||
| 652 | { | - | ||||||||||||||||||
| 653 | return never executed: d ? d->props.count() : 0;return d ? d->props.count() : 0;never executed: return d ? d->props.count() : 0; | 0 | ||||||||||||||||||
| 654 | } | - | ||||||||||||||||||
| 655 | bool QTextFormat::operator==(const QTextFormat &rhs) const | - | ||||||||||||||||||
| 656 | { | - | ||||||||||||||||||
| 657 | if (format_type != rhs.format_type
| 0 | ||||||||||||||||||
| 658 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 659 | - | |||||||||||||||||||
| 660 | if (d == rhs.d
| 0 | ||||||||||||||||||
| 661 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 662 | - | |||||||||||||||||||
| 663 | if (d
| 0 | ||||||||||||||||||
| 664 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 665 | - | |||||||||||||||||||
| 666 | if (!d
| 0 | ||||||||||||||||||
| 667 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 668 | - | |||||||||||||||||||
| 669 | if (!d
| 0 | ||||||||||||||||||
| 670 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 671 | - | |||||||||||||||||||
| 672 | return never executed: *d == *rhs.d;return *d == *rhs.d;never executed: return *d == *rhs.d; | 0 | ||||||||||||||||||
| 673 | } | - | ||||||||||||||||||
| 674 | QTextCharFormat::QTextCharFormat() : QTextFormat(CharFormat) {} never executed: end of block | 0 | ||||||||||||||||||
| 675 | QTextCharFormat::QTextCharFormat(const QTextFormat &fmt) | - | ||||||||||||||||||
| 676 | : QTextFormat(fmt) | - | ||||||||||||||||||
| 677 | { | - | ||||||||||||||||||
| 678 | } never executed: end of block | 0 | ||||||||||||||||||
| 679 | bool QTextCharFormat::fontUnderline() const | - | ||||||||||||||||||
| 680 | { | - | ||||||||||||||||||
| 681 | if (hasProperty(TextUnderlineStyle)
| 0 | ||||||||||||||||||
| 682 | return never executed: underlineStyle() == SingleUnderline;return underlineStyle() == SingleUnderline;never executed: return underlineStyle() == SingleUnderline; | 0 | ||||||||||||||||||
| 683 | return never executed: boolProperty(FontUnderline);return boolProperty(FontUnderline);never executed: return boolProperty(FontUnderline); | 0 | ||||||||||||||||||
| 684 | } | - | ||||||||||||||||||
| 685 | void QTextCharFormat::setUnderlineStyle(UnderlineStyle style) | - | ||||||||||||||||||
| 686 | { | - | ||||||||||||||||||
| 687 | setProperty(TextUnderlineStyle, style); | - | ||||||||||||||||||
| 688 | - | |||||||||||||||||||
| 689 | setProperty(FontUnderline, style == SingleUnderline); | - | ||||||||||||||||||
| 690 | } never executed: end of block | 0 | ||||||||||||||||||
| 691 | QString QTextCharFormat::anchorName() const | - | ||||||||||||||||||
| 692 | { | - | ||||||||||||||||||
| 693 | QVariant prop = property(AnchorName); | - | ||||||||||||||||||
| 694 | if (prop.userType() == QVariant::StringList
| 0 | ||||||||||||||||||
| 695 | return never executed: prop.toStringList().value(0);return prop.toStringList().value(0);never executed: return prop.toStringList().value(0); | 0 | ||||||||||||||||||
| 696 | else if (prop.userType() != QVariant::String
| 0 | ||||||||||||||||||
| 697 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||
| 698 | return never executed: prop.toString();return prop.toString();never executed: return prop.toString(); | 0 | ||||||||||||||||||
| 699 | } | - | ||||||||||||||||||
| 700 | QStringList QTextCharFormat::anchorNames() const | - | ||||||||||||||||||
| 701 | { | - | ||||||||||||||||||
| 702 | QVariant prop = property(AnchorName); | - | ||||||||||||||||||
| 703 | if (prop.userType() == QVariant::StringList
| 0 | ||||||||||||||||||
| 704 | return never executed: prop.toStringList();return prop.toStringList();never executed: return prop.toStringList(); | 0 | ||||||||||||||||||
| 705 | else if (prop.userType() != QVariant::String
| 0 | ||||||||||||||||||
| 706 | return never executed: QStringList();return QStringList();never executed: return QStringList(); | 0 | ||||||||||||||||||
| 707 | return never executed: QStringList(prop.toString());return QStringList(prop.toString());never executed: return QStringList(prop.toString()); | 0 | ||||||||||||||||||
| 708 | } | - | ||||||||||||||||||
| 709 | void QTextCharFormat::setFont(const QFont &font) | - | ||||||||||||||||||
| 710 | { | - | ||||||||||||||||||
| 711 | setFont(font, FontPropertiesAll); | - | ||||||||||||||||||
| 712 | } never executed: end of block | 0 | ||||||||||||||||||
| 713 | void QTextCharFormat::setFont(const QFont &font, FontPropertiesInheritanceBehavior behavior) | - | ||||||||||||||||||
| 714 | { | - | ||||||||||||||||||
| 715 | const uint mask = behavior == FontPropertiesAll
| 0 | ||||||||||||||||||
| 716 | : font.resolve(); | - | ||||||||||||||||||
| 717 | - | |||||||||||||||||||
| 718 | if (mask & QFont::FamilyResolved
| 0 | ||||||||||||||||||
| 719 | setFontFamily(font.family()); never executed: setFontFamily(font.family()); | 0 | ||||||||||||||||||
| 720 | if (mask & QFont::SizeResolved
| 0 | ||||||||||||||||||
| 721 | const qreal pointSize = font.pointSizeF(); | - | ||||||||||||||||||
| 722 | if (pointSize > 0
| 0 | ||||||||||||||||||
| 723 | setFontPointSize(pointSize); | - | ||||||||||||||||||
| 724 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 725 | const int pixelSize = font.pixelSize(); | - | ||||||||||||||||||
| 726 | if (pixelSize > 0
| 0 | ||||||||||||||||||
| 727 | setProperty(QTextFormat::FontPixelSize, pixelSize); never executed: setProperty(QTextFormat::FontPixelSize, pixelSize); | 0 | ||||||||||||||||||
| 728 | } never executed: end of block | 0 | ||||||||||||||||||
| 729 | } | - | ||||||||||||||||||
| 730 | - | |||||||||||||||||||
| 731 | if (mask & QFont::WeightResolved
| 0 | ||||||||||||||||||
| 732 | setFontWeight(font.weight()); never executed: setFontWeight(font.weight()); | 0 | ||||||||||||||||||
| 733 | if (mask & QFont::StyleResolved
| 0 | ||||||||||||||||||
| 734 | setFontItalic(font.style() != QFont::StyleNormal); never executed: setFontItalic(font.style() != QFont::StyleNormal); | 0 | ||||||||||||||||||
| 735 | if (mask & QFont::UnderlineResolved
| 0 | ||||||||||||||||||
| 736 | setUnderlineStyle(font.underline() ? SingleUnderline : NoUnderline); never executed: setUnderlineStyle(font.underline() ? SingleUnderline : NoUnderline); | 0 | ||||||||||||||||||
| 737 | if (mask & QFont::OverlineResolved
| 0 | ||||||||||||||||||
| 738 | setFontOverline(font.overline()); never executed: setFontOverline(font.overline()); | 0 | ||||||||||||||||||
| 739 | if (mask & QFont::StrikeOutResolved
| 0 | ||||||||||||||||||
| 740 | setFontStrikeOut(font.strikeOut()); never executed: setFontStrikeOut(font.strikeOut()); | 0 | ||||||||||||||||||
| 741 | if (mask & QFont::FixedPitchResolved
| 0 | ||||||||||||||||||
| 742 | setFontFixedPitch(font.fixedPitch()); never executed: setFontFixedPitch(font.fixedPitch()); | 0 | ||||||||||||||||||
| 743 | if (mask & QFont::CapitalizationResolved
| 0 | ||||||||||||||||||
| 744 | setFontCapitalization(font.capitalization()); never executed: setFontCapitalization(font.capitalization()); | 0 | ||||||||||||||||||
| 745 | if (mask & QFont::WordSpacingResolved
| 0 | ||||||||||||||||||
| 746 | setFontWordSpacing(font.wordSpacing()); never executed: setFontWordSpacing(font.wordSpacing()); | 0 | ||||||||||||||||||
| 747 | if (mask & QFont::LetterSpacingResolved
| 0 | ||||||||||||||||||
| 748 | setFontLetterSpacingType(font.letterSpacingType()); | - | ||||||||||||||||||
| 749 | setFontLetterSpacing(font.letterSpacing()); | - | ||||||||||||||||||
| 750 | } never executed: end of block | 0 | ||||||||||||||||||
| 751 | if (mask & QFont::StretchResolved
| 0 | ||||||||||||||||||
| 752 | setFontStretch(font.stretch()); never executed: setFontStretch(font.stretch()); | 0 | ||||||||||||||||||
| 753 | if (mask & QFont::StyleHintResolved
| 0 | ||||||||||||||||||
| 754 | setFontStyleHint(font.styleHint()); never executed: setFontStyleHint(font.styleHint()); | 0 | ||||||||||||||||||
| 755 | if (mask & QFont::StyleStrategyResolved
| 0 | ||||||||||||||||||
| 756 | setFontStyleStrategy(font.styleStrategy()); never executed: setFontStyleStrategy(font.styleStrategy()); | 0 | ||||||||||||||||||
| 757 | if (mask & QFont::HintingPreferenceResolved
| 0 | ||||||||||||||||||
| 758 | setFontHintingPreference(font.hintingPreference()); never executed: setFontHintingPreference(font.hintingPreference()); | 0 | ||||||||||||||||||
| 759 | if (mask & QFont::KerningResolved
| 0 | ||||||||||||||||||
| 760 | setFontKerning(font.kerning()); never executed: setFontKerning(font.kerning()); | 0 | ||||||||||||||||||
| 761 | } never executed: end of block | 0 | ||||||||||||||||||
| 762 | - | |||||||||||||||||||
| 763 | - | |||||||||||||||||||
| 764 | - | |||||||||||||||||||
| 765 | - | |||||||||||||||||||
| 766 | QFont QTextCharFormat::font() const | - | ||||||||||||||||||
| 767 | { | - | ||||||||||||||||||
| 768 | return never executed: d ? d->font() : QFont();return d ? d->font() : QFont();never executed: return d ? d->font() : QFont(); | 0 | ||||||||||||||||||
| 769 | } | - | ||||||||||||||||||
| 770 | QTextBlockFormat::QTextBlockFormat() : QTextFormat(BlockFormat) {} never executed: end of block | 0 | ||||||||||||||||||
| 771 | QTextBlockFormat::QTextBlockFormat(const QTextFormat &fmt) | - | ||||||||||||||||||
| 772 | : QTextFormat(fmt) | - | ||||||||||||||||||
| 773 | { | - | ||||||||||||||||||
| 774 | } never executed: end of block | 0 | ||||||||||||||||||
| 775 | void QTextBlockFormat::setTabPositions(const QList<QTextOption::Tab> &tabs) | - | ||||||||||||||||||
| 776 | { | - | ||||||||||||||||||
| 777 | QList<QVariant> list; | - | ||||||||||||||||||
| 778 | list.reserve(tabs.count()); | - | ||||||||||||||||||
| 779 | QList<QTextOption::Tab>::ConstIterator iter = tabs.constBegin(); | - | ||||||||||||||||||
| 780 | while (iter != tabs.constEnd()
| 0 | ||||||||||||||||||
| 781 | QVariant v; | - | ||||||||||||||||||
| 782 | v.setValue<QTextOption::Tab>(*iter); | - | ||||||||||||||||||
| 783 | list.append(v); | - | ||||||||||||||||||
| 784 | ++iter; | - | ||||||||||||||||||
| 785 | } never executed: end of block | 0 | ||||||||||||||||||
| 786 | setProperty(TabPositions, list); | - | ||||||||||||||||||
| 787 | } never executed: end of block | 0 | ||||||||||||||||||
| 788 | - | |||||||||||||||||||
| 789 | - | |||||||||||||||||||
| 790 | - | |||||||||||||||||||
| 791 | - | |||||||||||||||||||
| 792 | - | |||||||||||||||||||
| 793 | - | |||||||||||||||||||
| 794 | - | |||||||||||||||||||
| 795 | QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const | - | ||||||||||||||||||
| 796 | { | - | ||||||||||||||||||
| 797 | QVariant variant = property(TabPositions); | - | ||||||||||||||||||
| 798 | if(variant.isNull()
| 0 | ||||||||||||||||||
| 799 | return never executed: QList<QTextOption::Tab>();return QList<QTextOption::Tab>();never executed: return QList<QTextOption::Tab>(); | 0 | ||||||||||||||||||
| 800 | QList<QTextOption::Tab> answer; | - | ||||||||||||||||||
| 801 | QList<QVariant> variantsList = qvariant_cast<QList<QVariant> >(variant); | - | ||||||||||||||||||
| 802 | QList<QVariant>::Iterator iter = variantsList.begin(); | - | ||||||||||||||||||
| 803 | answer.reserve(variantsList.count()); | - | ||||||||||||||||||
| 804 | while(iter != variantsList.end()
| 0 | ||||||||||||||||||
| 805 | answer.append( qvariant_cast<QTextOption::Tab>(*iter)); | - | ||||||||||||||||||
| 806 | ++iter; | - | ||||||||||||||||||
| 807 | } never executed: end of block | 0 | ||||||||||||||||||
| 808 | return never executed: answer;return answer;never executed: return answer; | 0 | ||||||||||||||||||
| 809 | } | - | ||||||||||||||||||
| 810 | QTextListFormat::QTextListFormat() | - | ||||||||||||||||||
| 811 | : QTextFormat(ListFormat) | - | ||||||||||||||||||
| 812 | { | - | ||||||||||||||||||
| 813 | setIndent(1); | - | ||||||||||||||||||
| 814 | } never executed: end of block | 0 | ||||||||||||||||||
| 815 | QTextListFormat::QTextListFormat(const QTextFormat &fmt) | - | ||||||||||||||||||
| 816 | : QTextFormat(fmt) | - | ||||||||||||||||||
| 817 | { | - | ||||||||||||||||||
| 818 | } never executed: end of block | 0 | ||||||||||||||||||
| 819 | QTextFrameFormat::QTextFrameFormat() : QTextFormat(FrameFormat) | - | ||||||||||||||||||
| 820 | { | - | ||||||||||||||||||
| 821 | setBorderStyle(BorderStyle_Outset); | - | ||||||||||||||||||
| 822 | setBorderBrush(Qt::darkGray); | - | ||||||||||||||||||
| 823 | } never executed: end of block | 0 | ||||||||||||||||||
| 824 | QTextFrameFormat::QTextFrameFormat(const QTextFormat &fmt) | - | ||||||||||||||||||
| 825 | : QTextFormat(fmt) | - | ||||||||||||||||||
| 826 | { | - | ||||||||||||||||||
| 827 | } never executed: end of block | 0 | ||||||||||||||||||
| 828 | void QTextFrameFormat::setMargin(qreal amargin) | - | ||||||||||||||||||
| 829 | { | - | ||||||||||||||||||
| 830 | setProperty(FrameMargin, amargin); | - | ||||||||||||||||||
| 831 | setProperty(FrameTopMargin, amargin); | - | ||||||||||||||||||
| 832 | setProperty(FrameBottomMargin, amargin); | - | ||||||||||||||||||
| 833 | setProperty(FrameLeftMargin, amargin); | - | ||||||||||||||||||
| 834 | setProperty(FrameRightMargin, amargin); | - | ||||||||||||||||||
| 835 | } never executed: end of block | 0 | ||||||||||||||||||
| 836 | qreal QTextFrameFormat::topMargin() const | - | ||||||||||||||||||
| 837 | { | - | ||||||||||||||||||
| 838 | if (!hasProperty(FrameTopMargin)
| 0 | ||||||||||||||||||
| 839 | return never executed: margin();return margin();never executed: return margin(); | 0 | ||||||||||||||||||
| 840 | return never executed: doubleProperty(FrameTopMargin);return doubleProperty(FrameTopMargin);never executed: return doubleProperty(FrameTopMargin); | 0 | ||||||||||||||||||
| 841 | } | - | ||||||||||||||||||
| 842 | qreal QTextFrameFormat::bottomMargin() const | - | ||||||||||||||||||
| 843 | { | - | ||||||||||||||||||
| 844 | if (!hasProperty(FrameBottomMargin)
| 0 | ||||||||||||||||||
| 845 | return never executed: margin();return margin();never executed: return margin(); | 0 | ||||||||||||||||||
| 846 | return never executed: doubleProperty(FrameBottomMargin);return doubleProperty(FrameBottomMargin);never executed: return doubleProperty(FrameBottomMargin); | 0 | ||||||||||||||||||
| 847 | } | - | ||||||||||||||||||
| 848 | qreal QTextFrameFormat::leftMargin() const | - | ||||||||||||||||||
| 849 | { | - | ||||||||||||||||||
| 850 | if (!hasProperty(FrameLeftMargin)
| 0 | ||||||||||||||||||
| 851 | return never executed: margin();return margin();never executed: return margin(); | 0 | ||||||||||||||||||
| 852 | return never executed: doubleProperty(FrameLeftMargin);return doubleProperty(FrameLeftMargin);never executed: return doubleProperty(FrameLeftMargin); | 0 | ||||||||||||||||||
| 853 | } | - | ||||||||||||||||||
| 854 | qreal QTextFrameFormat::rightMargin() const | - | ||||||||||||||||||
| 855 | { | - | ||||||||||||||||||
| 856 | if (!hasProperty(FrameRightMargin)
| 0 | ||||||||||||||||||
| 857 | return never executed: margin();return margin();never executed: return margin(); | 0 | ||||||||||||||||||
| 858 | return never executed: doubleProperty(FrameRightMargin);return doubleProperty(FrameRightMargin);never executed: return doubleProperty(FrameRightMargin); | 0 | ||||||||||||||||||
| 859 | } | - | ||||||||||||||||||
| 860 | QTextTableFormat::QTextTableFormat() | - | ||||||||||||||||||
| 861 | : QTextFrameFormat() | - | ||||||||||||||||||
| 862 | { | - | ||||||||||||||||||
| 863 | setObjectType(TableObject); | - | ||||||||||||||||||
| 864 | setCellSpacing(2); | - | ||||||||||||||||||
| 865 | setBorder(1); | - | ||||||||||||||||||
| 866 | } never executed: end of block | 0 | ||||||||||||||||||
| 867 | QTextTableFormat::QTextTableFormat(const QTextFormat &fmt) | - | ||||||||||||||||||
| 868 | : QTextFrameFormat(fmt) | - | ||||||||||||||||||
| 869 | { | - | ||||||||||||||||||
| 870 | } never executed: end of block | 0 | ||||||||||||||||||
| 871 | QTextImageFormat::QTextImageFormat() : QTextCharFormat() { setObjectType(ImageObject); } never executed: end of block | 0 | ||||||||||||||||||
| 872 | QTextImageFormat::QTextImageFormat(const QTextFormat &fmt) | - | ||||||||||||||||||
| 873 | : QTextCharFormat(fmt) | - | ||||||||||||||||||
| 874 | { | - | ||||||||||||||||||
| 875 | } never executed: end of block | 0 | ||||||||||||||||||
| 876 | QTextTableCellFormat::QTextTableCellFormat() | - | ||||||||||||||||||
| 877 | : QTextCharFormat() | - | ||||||||||||||||||
| 878 | { | - | ||||||||||||||||||
| 879 | setObjectType(TableCellObject); | - | ||||||||||||||||||
| 880 | } never executed: end of block | 0 | ||||||||||||||||||
| 881 | QTextTableCellFormat::QTextTableCellFormat(const QTextFormat &fmt) | - | ||||||||||||||||||
| 882 | : QTextCharFormat(fmt) | - | ||||||||||||||||||
| 883 | { | - | ||||||||||||||||||
| 884 | } never executed: end of block | 0 | ||||||||||||||||||
| 885 | QTextFormatCollection::QTextFormatCollection(const QTextFormatCollection &rhs) | - | ||||||||||||||||||
| 886 | { | - | ||||||||||||||||||
| 887 | formats = rhs.formats; | - | ||||||||||||||||||
| 888 | objFormats = rhs.objFormats; | - | ||||||||||||||||||
| 889 | } never executed: end of block | 0 | ||||||||||||||||||
| 890 | - | |||||||||||||||||||
| 891 | QTextFormatCollection &QTextFormatCollection::operator=(const QTextFormatCollection &rhs) | - | ||||||||||||||||||
| 892 | { | - | ||||||||||||||||||
| 893 | formats = rhs.formats; | - | ||||||||||||||||||
| 894 | objFormats = rhs.objFormats; | - | ||||||||||||||||||
| 895 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||||||||
| 896 | } | - | ||||||||||||||||||
| 897 | - | |||||||||||||||||||
| 898 | QTextFormatCollection::~QTextFormatCollection() | - | ||||||||||||||||||
| 899 | { | - | ||||||||||||||||||
| 900 | } | - | ||||||||||||||||||
| 901 | - | |||||||||||||||||||
| 902 | int QTextFormatCollection::indexForFormat(const QTextFormat &format) | - | ||||||||||||||||||
| 903 | { | - | ||||||||||||||||||
| 904 | uint hash = getHash(format.d, format.format_type); | - | ||||||||||||||||||
| 905 | QMultiHash<uint, int>::const_iterator i = hashes.constFind(hash); | - | ||||||||||||||||||
| 906 | while (i != hashes.constEnd()
| 0 | ||||||||||||||||||
| 907 | if (formats.value(i.value()) == format
| 0 | ||||||||||||||||||
| 908 | return never executed: i.value();return i.value();never executed: return i.value(); | 0 | ||||||||||||||||||
| 909 | } | - | ||||||||||||||||||
| 910 | ++i; | - | ||||||||||||||||||
| 911 | } never executed: end of block | 0 | ||||||||||||||||||
| 912 | - | |||||||||||||||||||
| 913 | int idx = formats.size(); | - | ||||||||||||||||||
| 914 | formats.append(format); | - | ||||||||||||||||||
| 915 | - | |||||||||||||||||||
| 916 | if (true){ | - | ||||||||||||||||||
| 917 | QTextFormat &f = formats.last(); | - | ||||||||||||||||||
| 918 | if (!f.d
| 0 | ||||||||||||||||||
| 919 | f.d = new QTextFormatPrivate; never executed: f.d = new QTextFormatPrivate; | 0 | ||||||||||||||||||
| 920 | f.d->resolveFont(defaultFnt); | - | ||||||||||||||||||
| 921 | - | |||||||||||||||||||
| 922 | if (!hashes.contains(hash, idx)
| 0 | ||||||||||||||||||
| 923 | hashes.insert(hash, idx); never executed: hashes.insert(hash, idx); | 0 | ||||||||||||||||||
| 924 | - | |||||||||||||||||||
| 925 | } never executed: else {end of blockdead code: { formats.pop_back(); qt_noop(); } | - | ||||||||||||||||||
| 926 | formats.pop_back(); dead code: { formats.pop_back(); qt_noop(); } | - | ||||||||||||||||||
| 927 | qt_noop(); dead code: { formats.pop_back(); qt_noop(); } | - | ||||||||||||||||||
| 928 | } dead code: { formats.pop_back(); qt_noop(); } | - | ||||||||||||||||||
| 929 | return never executed: idx;return idx;never executed: return idx; | 0 | ||||||||||||||||||
| 930 | } | - | ||||||||||||||||||
| 931 | - | |||||||||||||||||||
| 932 | bool QTextFormatCollection::hasFormatCached(const QTextFormat &format) const | - | ||||||||||||||||||
| 933 | { | - | ||||||||||||||||||
| 934 | uint hash = getHash(format.d, format.format_type); | - | ||||||||||||||||||
| 935 | QMultiHash<uint, int>::const_iterator i = hashes.constFind(hash); | - | ||||||||||||||||||
| 936 | while (i != hashes.constEnd()
| 0 | ||||||||||||||||||
| 937 | if (formats.value(i.value()) == format
| 0 | ||||||||||||||||||
| 938 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 939 | } | - | ||||||||||||||||||
| 940 | ++i; | - | ||||||||||||||||||
| 941 | } never executed: end of block | 0 | ||||||||||||||||||
| 942 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 943 | } | - | ||||||||||||||||||
| 944 | - | |||||||||||||||||||
| 945 | int QTextFormatCollection::objectFormatIndex(int objectIndex) const | - | ||||||||||||||||||
| 946 | { | - | ||||||||||||||||||
| 947 | if (objectIndex == -1
| 0 | ||||||||||||||||||
| 948 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 949 | return never executed: objFormats.at(objectIndex);return objFormats.at(objectIndex);never executed: return objFormats.at(objectIndex); | 0 | ||||||||||||||||||
| 950 | } | - | ||||||||||||||||||
| 951 | - | |||||||||||||||||||
| 952 | void QTextFormatCollection::setObjectFormatIndex(int objectIndex, int formatIndex) | - | ||||||||||||||||||
| 953 | { | - | ||||||||||||||||||
| 954 | objFormats[objectIndex] = formatIndex; | - | ||||||||||||||||||
| 955 | } never executed: end of block | 0 | ||||||||||||||||||
| 956 | - | |||||||||||||||||||
| 957 | int QTextFormatCollection::createObjectIndex(const QTextFormat &f) | - | ||||||||||||||||||
| 958 | { | - | ||||||||||||||||||
| 959 | const int objectIndex = objFormats.size(); | - | ||||||||||||||||||
| 960 | objFormats.append(indexForFormat(f)); | - | ||||||||||||||||||
| 961 | return never executed: objectIndex;return objectIndex;never executed: return objectIndex; | 0 | ||||||||||||||||||
| 962 | } | - | ||||||||||||||||||
| 963 | - | |||||||||||||||||||
| 964 | QTextFormat QTextFormatCollection::format(int idx) const | - | ||||||||||||||||||
| 965 | { | - | ||||||||||||||||||
| 966 | if (idx < 0
| 0 | ||||||||||||||||||
| 967 | return never executed: QTextFormat();return QTextFormat();never executed: return QTextFormat(); | 0 | ||||||||||||||||||
| 968 | - | |||||||||||||||||||
| 969 | return never executed: formats.at(idx);return formats.at(idx);never executed: return formats.at(idx); | 0 | ||||||||||||||||||
| 970 | } | - | ||||||||||||||||||
| 971 | - | |||||||||||||||||||
| 972 | void QTextFormatCollection::setDefaultFont(const QFont &f) | - | ||||||||||||||||||
| 973 | { | - | ||||||||||||||||||
| 974 | defaultFnt = f; | - | ||||||||||||||||||
| 975 | for (int i = 0; i < formats.count()
| 0 | ||||||||||||||||||
| 976 | if (formats.at(i).d
| 0 | ||||||||||||||||||
| 977 | formats[i].d->resolveFont(defaultFnt); never executed: formats[i].d->resolveFont(defaultFnt); | 0 | ||||||||||||||||||
| 978 | } never executed: end of block | 0 | ||||||||||||||||||
| 979 | - | |||||||||||||||||||
| 980 | - | |||||||||||||||||||
| 981 | QDebug operator<<(QDebug dbg, const QTextLength &l) | - | ||||||||||||||||||
| 982 | { | - | ||||||||||||||||||
| 983 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||
| 984 | dbg.nospace() << "QTextLength(QTextLength::Type(" << l.type() << "))"; | - | ||||||||||||||||||
| 985 | return never executed: dbg;return dbg;never executed: return dbg; | 0 | ||||||||||||||||||
| 986 | } | - | ||||||||||||||||||
| 987 | - | |||||||||||||||||||
| 988 | QDebug operator<<(QDebug dbg, const QTextFormat &f) | - | ||||||||||||||||||
| 989 | { | - | ||||||||||||||||||
| 990 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||
| 991 | dbg.nospace() << "QTextFormat(QTextFormat::FormatType(" << f.type() << "))"; | - | ||||||||||||||||||
| 992 | return never executed: dbg;return dbg;never executed: return dbg; | 0 | ||||||||||||||||||
| 993 | } | - | ||||||||||||||||||
| 994 | - | |||||||||||||||||||
| 995 | - | |||||||||||||||||||
| 996 | - | |||||||||||||||||||
| 997 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |