Qt 4.8
Public Types | Public Functions | Public Variables | Friends | List of all members
QTextHtmlParserNode Struct Reference

#include <qtexthtmlparser_p.h>

Public Types

enum  WhiteSpaceMode {
  WhiteSpaceNormal, WhiteSpacePre, WhiteSpaceNoWrap, WhiteSpacePreWrap,
  WhiteSpaceModeUndefined = -1
}
 

Public Functions

bool allowedInContext (int parentId) const
 
void applyBackgroundImage (const QString &url, const QTextDocument *resourceProvider)
 
void applyCssDeclarations (const QVector< QCss::Declaration > &declarations, const QTextDocument *resourceProvider)
 
bool hasOnlyWhitespace () const
 
void initializeProperties (const QTextHtmlParserNode *parent, const QTextHtmlParser *parser)
 
bool isBlock () const
 
bool isListStart () const
 
bool isNestedList (const QTextHtmlParser *parser) const
 
bool isNotSelfNesting () const
 
bool isTableCell () const
 
bool mayNotHaveChildren () const
 
void parseStyleAttribute (const QString &value, const QTextDocument *resourceProvider)
 
 QTextHtmlParserNode ()
 
void setListStyle (const QVector< QCss::Value > &cssValues)
 
int uncollapsedMargin (int mar) const
 

Public Variables

QStringList attributes
 
QTextBlockFormat blockFormat
 
QBrush borderBrush
 
QTextFrameFormat::BorderStyle borderStyle
 
QTextCharFormat charFormat
 
QVector< int > children
 
uint cssFloat: 2
 
int cssListIndent
 
uint displayMode: 3
 
uint hasCssListIndent: 1
 
uint hasHref: 1
 
uint hasOwnListStyle: 1
 
QTextLength height
 
QTextHTMLElements id
 
qreal imageHeight
 
QString imageName
 
qreal imageWidth
 
uint isEmptyParagraph: 1
 
uint isRootFrame: 1
 
uint isTextFrame: 1
 
QTextListFormat::Style listStyle
 
int margin [4]
 
int padding [4]
 
int parent
 
qreal tableBorder
 
int tableCellColSpan
 
qreal tableCellPadding
 
int tableCellRowSpan
 
qreal tableCellSpacing
 
QString tag
 
QString text
 
QString textListNumberPrefix
 
QString textListNumberSuffix
 
int userState
 
QTextLength width
 
WhiteSpaceMode wsm
 

Friends

class QTextHtmlParser
 

Detailed Description

Definition at line 156 of file qtexthtmlparser_p.h.

Enumerations

◆ WhiteSpaceMode

Constructors and Destructors

◆ QTextHtmlParserNode()

QTextHtmlParserNode::QTextHtmlParserNode ( )

Definition at line 481 of file qtexthtmlparser.cpp.

Referenced by QTextHtmlParser::resolveParent().

482  : parent(0), id(Html_unknown),
484  hasCssListIndent(false), isEmptyParagraph(false), isTextFrame(false), isRootFrame(false),
490 {
495 }
QTextFrameFormat::BorderStyle borderStyle
QTextListFormat::Style listStyle
QTextHTMLElements id

Functions

◆ allowedInContext()

bool QTextHtmlParserNode::allowedInContext ( int  parentId) const
inline

Definition at line 213 of file qtexthtmlparser_p.h.

Referenced by QTextHtmlParser::resolveParent().

214  {
215  switch (id) {
216  case Html_dd:
217  case Html_dt: return (parentId == Html_dl);
218  case Html_tr: return (parentId == Html_table
219  || parentId == Html_thead
220  || parentId == Html_tbody
221  || parentId == Html_tfoot
222  );
223  case Html_th:
224  case Html_td: return (parentId == Html_tr);
225  case Html_thead:
226  case Html_tbody:
227  case Html_tfoot: return (parentId == Html_table);
228  case Html_caption: return (parentId == Html_table);
229  case Html_body: return parentId != Html_head;
230  default: break;
231  }
232  return true;
233  }

◆ applyBackgroundImage()

void QTextHtmlParserNode::applyBackgroundImage ( const QString url,
const QTextDocument resourceProvider 
)

Definition at line 1400 of file qtexthtmlparser.cpp.

Referenced by QTextHtmlParser::applyAttributes(), and applyCssDeclarations().

1401 {
1402  if (!url.isEmpty() && resourceProvider) {
1403  QVariant val = resourceProvider->resource(QTextDocument::ImageResource, url);
1404 
1405  if (qApp->thread() != QThread::currentThread()) {
1406  // must use images in non-GUI threads
1407  if (val.type() == QVariant::Image) {
1408  QImage image = qvariant_cast<QImage>(val);
1409  charFormat.setBackground(image);
1410  } else if (val.type() == QVariant::ByteArray) {
1411  QImage image;
1412  if (image.loadFromData(val.toByteArray())) {
1413  charFormat.setBackground(image);
1414  }
1415  }
1416  } else {
1417  if (val.type() == QVariant::Image || val.type() == QVariant::Pixmap) {
1418  charFormat.setBackground(qvariant_cast<QPixmap>(val));
1419  } else if (val.type() == QVariant::ByteArray) {
1420  QPixmap pm;
1421  if (pm.loadFromData(val.toByteArray())) {
1423  }
1424  }
1425  }
1426  }
1427  if (!url.isEmpty())
1429 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
void setBackground(const QBrush &brush)
Sets the brush use to paint the document&#39;s background to the brush specified.
Definition: qtextformat.h:343
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
QTextCharFormat charFormat
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define qApp
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
bool loadFromData(const uchar *buf, uint len, const char *format=0, Qt::ImageConversionFlags flags=Qt::AutoColor)
Loads a pixmap from the len first bytes of the given binary data.
Definition: qpixmap.cpp:979
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QVariant resource(int type, const QUrl &name) const
Returns data of the specified type from the resource with the given name.
bool loadFromData(const uchar *buf, int len, const char *format=0)
Loads an image from the first len bytes of the given binary data.
Definition: qimage.cpp:5275

◆ applyCssDeclarations()

void QTextHtmlParserNode::applyCssDeclarations ( const QVector< QCss::Declaration > &  declarations,
const QTextDocument resourceProvider 
)

Definition at line 1215 of file qtexthtmlparser.cpp.

Referenced by parseStyleAttribute(), and QTextHtmlParser::parseTag().

1216 {
1217  QCss::ValueExtractor extractor(declarations);
1218  extractor.extractBox(margin, padding);
1219 
1220  for (int i = 0; i < declarations.count(); ++i) {
1221  const QCss::Declaration &decl = declarations.at(i);
1222  if (decl.d->values.isEmpty()) continue;
1223 
1224  QCss::KnownValue identifier = QCss::UnknownValue;
1225  if (decl.d->values.first().type == QCss::Value::KnownIdentifier)
1226  identifier = static_cast<QCss::KnownValue>(decl.d->values.first().variant.toInt());
1227 
1228  switch (decl.d->propertyId) {
1229  case QCss::BorderColor: borderBrush = QBrush(decl.colorValue()); break;
1230  case QCss::BorderStyles:
1232  borderStyle = static_cast<QTextFrameFormat::BorderStyle>(decl.styleValue() - 1);
1233  break;
1234  case QCss::BorderWidth:
1235  tableBorder = extractor.lengthValue(decl);
1236  break;
1237  case QCss::Color: charFormat.setForeground(decl.colorValue()); break;
1238  case QCss::Float:
1240  switch (identifier) {
1243  default: break;
1244  }
1245  break;
1246  case QCss::QtBlockIndent:
1247  blockFormat.setIndent(decl.d->values.first().variant.toInt());
1248  break;
1249  case QCss::LineHeight: {
1250  qreal lineHeight;
1251  if (decl.realValue(&lineHeight, "px")) {
1253  } else {
1254  bool ok;
1255  QString value = decl.d->values.first().toString();
1256  lineHeight = value.toDouble(&ok);
1257  if (ok)
1259  else
1261  }
1262  break; }
1263  case QCss::TextIndent: {
1264  qreal indent = 0;
1265  if (decl.realValue(&indent, "px"))
1266  blockFormat.setTextIndent(indent);
1267  break; }
1268  case QCss::QtListIndent:
1269  if (decl.intValue(&cssListIndent))
1270  hasCssListIndent = true;
1271  break;
1272  case QCss::QtParagraphType:
1273  if (decl.d->values.first().variant.toString().compare(QLatin1String("empty"), Qt::CaseInsensitive) == 0)
1274  isEmptyParagraph = true;
1275  break;
1276  case QCss::QtTableType:
1277  if (decl.d->values.first().variant.toString().compare(QLatin1String("frame"), Qt::CaseInsensitive) == 0)
1278  isTextFrame = true;
1279  else if (decl.d->values.first().variant.toString().compare(QLatin1String("root"), Qt::CaseInsensitive) == 0) {
1280  isTextFrame = true;
1281  isRootFrame = true;
1282  }
1283  break;
1284  case QCss::QtUserState:
1285  userState = decl.d->values.first().variant.toInt();
1286  break;
1287  case QCss::Whitespace:
1288  switch (identifier) {
1293  default: break;
1294  }
1295  break;
1297  switch (identifier) {
1304  }
1305  break;
1306  case QCss::PageBreakBefore:
1307  switch (identifier) {
1309  case QCss::Value_Auto: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() & ~QTextFormat::PageBreak_AlwaysBefore); break;
1310  default: break;
1311  }
1312  break;
1313  case QCss::PageBreakAfter:
1314  switch (identifier) {
1316  case QCss::Value_Auto: blockFormat.setPageBreakPolicy(blockFormat.pageBreakPolicy() & ~QTextFormat::PageBreak_AlwaysAfter); break;
1317  default: break;
1318  }
1319  break;
1321  switch (identifier) {
1329  default: break;
1330  }
1331  break;
1332  case QCss::ListStyleType:
1333  case QCss::ListStyle:
1334  setListStyle(decl.d->values);
1335  break;
1337  textListNumberPrefix = decl.d->values.first().variant.toString();
1338  break;
1340  textListNumberSuffix = decl.d->values.first().variant.toString();
1341  break;
1342  default: break;
1343  }
1344  }
1345 
1346  QFont f;
1347  int adjustment = -255;
1348  extractor.extractFont(&f, &adjustment);
1349  if (f.resolve() & QFont::SizeResolved) {
1350  if (f.pointSize() > 0) {
1352  } else if (f.pixelSize() > 0) {
1354  }
1355  }
1356  if (f.resolve() & QFont::StyleResolved)
1358 
1359  if (f.resolve() & QFont::WeightResolved)
1361 
1362  if (f.resolve() & QFont::FamilyResolved)
1364 
1367 
1368  if (f.resolve() & QFont::OverlineResolved)
1370 
1373 
1376 
1377  if (adjustment >= -1)
1379 
1380  {
1381  Qt::Alignment ignoredAlignment;
1382  QCss::Repeat ignoredRepeat;
1383  QString bgImage;
1384  QBrush bgBrush;
1385  QCss::Origin ignoredOrigin, ignoredClip;
1386  QCss::Attachment ignoredAttachment;
1387  extractor.extractBackground(&bgBrush, &bgImage, &ignoredRepeat, &ignoredAlignment,
1388  &ignoredOrigin, &ignoredAttachment, &ignoredClip);
1389 
1390  if (!bgImage.isEmpty() && resourceProvider) {
1391  applyBackgroundImage(bgImage, resourceProvider);
1392  } else if (bgBrush.style() != Qt::NoBrush) {
1393  charFormat.setBackground(bgBrush);
1394  }
1395  }
1396 }
QColor colorValue(const QPalette &=QPalette()) const
void setFontItalic(bool italic)
If italic is true, sets the text format&#39;s font to be italic; otherwise the font will be non-italic...
Definition: qtextformat.h:415
double qreal
Definition: qglobal.h:1193
QTextFrameFormat::BorderStyle borderStyle
void setLineHeight(qreal height, int heightType)
Sets the line height for the paragraph to the value given by height which is dependent on heightType ...
Definition: qtextformat.h:593
void setFontStrikeOut(bool strikeOut)
If strikeOut is true, sets the text format&#39;s font with strike-out enabled (with a horizontal line thr...
Definition: qtextformat.h:441
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
bool underline() const
Returns true if underline has been set; otherwise returns false.
Definition: qfont.cpp:1320
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
int pixelSize() const
Returns the pixel size of the font if it was set with setPixelSize().
Definition: qfont.cpp:1178
void setListStyle(const QVector< QCss::Value > &cssValues)
PageBreakFlags pageBreakPolicy() const
Returns the currently set page break policy for the paragraph.
Definition: qtextformat.h:608
Style style() const
Returns the style of the font.
Definition: qfont.cpp:1223
void setFontOverline(bool overline)
If overline is true, sets the text format&#39;s font to be overlined; otherwise the font is displayed non...
Definition: qtextformat.h:436
void setVerticalAlignment(VerticalAlignment alignment)
Sets the vertical alignment used for the characters with this format to the alignment specified...
Definition: qtextformat.h:484
Capitalization capitalization() const
Returns the current capitalization type of the font.
Definition: qfont.cpp:1819
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void setTextIndent(qreal aindent)
Sets the indent for the first line in the block.
Definition: qtextformat.h:584
void setBackground(const QBrush &brush)
Sets the brush use to paint the document&#39;s background to the brush specified.
Definition: qtextformat.h:343
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setFontWeight(int weight)
Sets the text format&#39;s font weight to weight.
Definition: qtextformat.h:411
QExplicitlySharedDataPointer< DeclarationData > d
Definition: qcssparser_p.h:430
QFont resolve(const QFont &) const
Returns a new QFont that has attributes copied from other that have not been previously set on this f...
Definition: qfont.cpp:1983
QTextCharFormat charFormat
bool overline() const
Returns true if overline has been set; otherwise returns false.
Definition: qfont.cpp:1344
void setFontCapitalization(QFont::Capitalization capitalization)
Sets the capitalization of the text that apppears in this font to capitalization. ...
Definition: qtextformat.h:419
The QTextFormat class provides formatting information for a QTextDocument.
Definition: qtextformat.h:129
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void setPageBreakPolicy(PageBreakFlags flags)
Sets the page break policy for the paragraph to policy.
Definition: qtextformat.h:606
QTextBlockFormat blockFormat
bool intValue(int *i, const char *unit=0) const
void setFontPointSize(qreal size)
Sets the text format&#39;s font size.
Definition: qtextformat.h:406
Qt::BrushStyle style() const
Returns the brush style.
Definition: qbrush.h:182
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QString family() const
Returns the requested font family name, i.e.
Definition: qfont.cpp:906
void applyBackgroundImage(const QString &url, const QTextDocument *resourceProvider)
double toDouble(bool *ok=0) const
Returns the string converted to a double value.
Definition: qstring.cpp:6227
void setFontFamily(const QString &family)
Sets the text format&#39;s font family.
Definition: qtextformat.h:401
int weight() const
Returns the weight of the font which is one of the enumerated values from QFont::Weight.
Definition: qfont.cpp:1248
void setIndent(int indent)
Sets the paragraph&#39;s indentation.
Definition: qtextformat.h:622
void setForeground(const QBrush &brush)
Sets the foreground brush to the specified brush.
Definition: qtextformat.h:350
bool realValue(qreal *r, const char *unit=0) const
int pointSize() const
Returns the point size of the font.
Definition: qfont.cpp:981
bool strikeOut() const
Returns true if strikeout has been set; otherwise returns false.
Definition: qfont.cpp:1367
void setUnderlineStyle(UnderlineStyle style)
Sets the style of underlining the text to style.
BorderStyle styleValue() const

◆ hasOnlyWhitespace()

bool QTextHtmlParserNode::hasOnlyWhitespace ( ) const

Definition at line 1431 of file qtexthtmlparser.cpp.

Referenced by QTextHtmlImporter::import().

1432 {
1433  for (int i = 0; i < text.count(); ++i)
1434  if (!text.at(i).isSpace() || text.at(i) == QChar::LineSeparator)
1435  return false;
1436  return true;
1437 }
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
Definition: qchar.cpp:609
int count() const
Definition: qstring.h:103

◆ initializeProperties()

void QTextHtmlParserNode::initializeProperties ( const QTextHtmlParserNode parent,
const QTextHtmlParser parser 
)

Definition at line 1001 of file qtexthtmlparser.cpp.

Referenced by QTextHtmlParser::resolveNode().

1002 {
1003  // inherit properties from parent element
1004  charFormat = parent->charFormat;
1005 
1006  if (id == Html_html)
1010 
1013 
1014  if (parent->id != Html_table || id == Html_caption) {
1017  else
1019  }
1020  // we don't paint per-row background colors, yet. so as an
1021  // exception inherit the background color here
1022  // we also inherit the background between inline elements
1023  if ((parent->id != Html_tr || !isTableCell())
1026  }
1027 
1028  listStyle = parent->listStyle;
1029  // makes no sense to inherit that property, a named anchor is a single point
1030  // in the document, which is set by the DocumentFragment
1032  wsm = parent->wsm;
1033 
1034  // initialize remaining properties
1040 
1041  for (int i = 0; i < 4; ++i)
1042  padding[i] = -1;
1043 
1044  // set element specific attributes
1045  switch (id) {
1046  case Html_a:
1047  charFormat.setAnchor(true);
1048  for (int i = 0; i < attributes.count(); i += 2) {
1049  const QString key = attributes.at(i);
1050  if (key.compare(QLatin1String("href"), Qt::CaseInsensitive) == 0
1051  && !attributes.at(i + 1).isEmpty()) {
1052  hasHref = true;
1055  }
1056  }
1057 
1058  break;
1059  case Html_em:
1060  case Html_i:
1061  case Html_cite:
1062  case Html_address:
1063  case Html_var:
1064  case Html_dfn:
1065  charFormat.setFontItalic(true);
1066  break;
1067  case Html_big:
1069  break;
1070  case Html_small:
1072  break;
1073  case Html_strong:
1074  case Html_b:
1076  break;
1077  case Html_h1:
1082  break;
1083  case Html_h2:
1088  break;
1089  case Html_h3:
1094  break;
1095  case Html_h4:
1100  break;
1101  case Html_h5:
1106  break;
1107  case Html_p:
1110  break;
1111  case Html_center:
1113  break;
1114  case Html_ul:
1116  // nested lists don't have margins, except for the toplevel one
1117  if (!isNestedList(parser)) {
1120  }
1121  // no left margin as we use indenting instead
1122  break;
1123  case Html_ol:
1125  // nested lists don't have margins, except for the toplevel one
1126  if (!isNestedList(parser)) {
1129  }
1130  // no left margin as we use indenting instead
1131  break;
1132  case Html_code:
1133  case Html_tt:
1134  case Html_kbd:
1135  case Html_samp:
1136  charFormat.setFontFamily(QString::fromLatin1("Courier New,courier"));
1137  // <tt> uses a fixed font, so set the property
1139  break;
1140  case Html_br:
1143  break;
1144  // ##### sub / sup
1145  case Html_pre:
1146  charFormat.setFontFamily(QString::fromLatin1("Courier New,courier"));
1147  wsm = WhiteSpacePre;
1150  // <pre> uses a fixed font
1152  break;
1153  case Html_blockquote:
1158  break;
1159  case Html_dl:
1162  break;
1163  case Html_dd:
1165  break;
1166  case Html_u:
1168  break;
1169  case Html_s:
1171  break;
1172  case Html_nobr:
1174  break;
1175  case Html_th:
1178  break;
1179  case Html_td:
1181  break;
1182  case Html_sub:
1184  break;
1185  case Html_sup:
1187  break;
1188  default: break;
1189  }
1190 }
void setFontItalic(bool italic)
If italic is true, sets the text format&#39;s font to be italic; otherwise the font will be non-italic...
Definition: qtextformat.h:415
void setFontStrikeOut(bool strikeOut)
If strikeOut is true, sets the text format&#39;s font with strike-out enabled (with a horizontal line thr...
Definition: qtextformat.h:441
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
void setVerticalAlignment(VerticalAlignment alignment)
Sets the vertical alignment used for the characters with this format to the alignment specified...
Definition: qtextformat.h:484
void setFontFixedPitch(bool fixedPitch)
If fixedPitch is true, sets the text format&#39;s font to be fixed pitch; otherwise a non-fixed pitch fon...
Definition: qtextformat.h:451
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static QPalette palette()
Returns the application palette.
The QString class provides a Unicode character string.
Definition: qstring.h:83
Qt::Alignment alignment() const
Returns the paragraph&#39;s alignment.
Definition: qtextformat.h:561
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QTextListFormat::Style listStyle
Qt::LayoutDirection layoutDirection() const
Returns the document&#39;s layout direction.
Definition: qtextformat.h:340
void setFontWeight(int weight)
Sets the text format&#39;s font weight to weight.
Definition: qtextformat.h:411
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false...
QTextCharFormat charFormat
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QTextBlockFormat blockFormat
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QTextHTMLElements id
void setAlignment(Qt::Alignment alignment)
Sets the paragraph&#39;s alignment.
Definition: qtextformat.h:619
int compare(const QString &s) const
Definition: qstring.cpp:5037
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
int key
void setFontFamily(const QString &family)
Sets the text format&#39;s font family.
Definition: qtextformat.h:401
void setAnchor(bool anchor)
If anchor is true, text with this format represents an anchor, and is formatted in the appropriate wa...
Definition: qtextformat.h:499
void setForeground(const QBrush &brush)
Sets the foreground brush to the specified brush.
Definition: qtextformat.h:350
void clearProperty(int propertyId)
Clears the value of the property given by propertyId.
bool isNestedList(const QTextHtmlParser *parser) const
void setLayoutDirection(Qt::LayoutDirection direction)
Sets the document&#39;s layout direction to the specified direction.
Definition: qtextformat.h:338
void setUnderlineStyle(UnderlineStyle style)
Sets the style of underlining the text to style.

◆ isBlock()

bool QTextHtmlParserNode::isBlock ( ) const
inline

◆ isListStart()

bool QTextHtmlParserNode::isListStart ( ) const
inline

Definition at line 203 of file qtexthtmlparser_p.h.

Referenced by isNestedList(), and QTextHtmlImporter::processBlockNode().

204  { return id == Html_ol || id == Html_ul; }

◆ isNestedList()

bool QTextHtmlParserNode::isNestedList ( const QTextHtmlParser parser) const

Definition at line 987 of file qtexthtmlparser.cpp.

Referenced by initializeProperties().

988 {
989  if (!isListStart())
990  return false;
991 
992  int p = parent;
993  while (p) {
994  if (parser->at(p).isListStart())
995  return true;
996  p = parser->at(p).parent;
997  }
998  return false;
999 }
const QTextHtmlParserNode & at(int i) const

◆ isNotSelfNesting()

bool QTextHtmlParserNode::isNotSelfNesting ( ) const
inline

Definition at line 210 of file qtexthtmlparser_p.h.

Referenced by QTextHtmlParser::resolveParent().

211  { return id == Html_p || id == Html_li; }

◆ isTableCell()

bool QTextHtmlParserNode::isTableCell ( ) const
inline

◆ mayNotHaveChildren()

bool QTextHtmlParserNode::mayNotHaveChildren ( ) const
inline

Definition at line 235 of file qtexthtmlparser_p.h.

Referenced by QTextHtmlParser::parseCloseTag(), and QTextHtmlParser::parseTag().

236  { return id == Html_img || id == Html_hr || id == Html_br || id == Html_meta; }

◆ parseStyleAttribute()

void QTextHtmlParserNode::parseStyleAttribute ( const QString value,
const QTextDocument resourceProvider 
)

Definition at line 1477 of file qtexthtmlparser.cpp.

Referenced by QTextHtmlParser::applyAttributes().

1478 {
1479  QString css = value;
1480  css.prepend(QLatin1String("* {"));
1481  css.append(QLatin1Char('}'));
1482  QCss::Parser parser(css);
1483  QCss::StyleSheet sheet;
1484  parser.parse(&sheet, Qt::CaseInsensitive);
1485  if (sheet.styleRules.count() != 1) return;
1486  applyCssDeclarations(sheet.styleRules.at(0).declarations, resourceProvider);
1487 }
QString & prepend(QChar c)
Definition: qstring.h:261
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QVector< StyleRule > styleRules
Definition: qcssparser_p.h:639
void applyCssDeclarations(const QVector< QCss::Declaration > &declarations, const QTextDocument *resourceProvider)
QString & append(QChar c)
Definition: qstring.cpp:1777
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ setListStyle()

void QTextHtmlParserNode::setListStyle ( const QVector< QCss::Value > &  cssValues)

Definition at line 1193 of file qtexthtmlparser.cpp.

Referenced by applyCssDeclarations().

1194 {
1195  for (int i = 0; i < cssValues.count(); ++i) {
1196  if (cssValues.at(i).type == QCss::Value::KnownIdentifier) {
1197  switch (static_cast<QCss::KnownValue>(cssValues.at(i).variant.toInt())) {
1206  default: break;
1207  }
1208  }
1209  }
1210  // allow individual list items to override the style
1211  if (id == Html_li && hasOwnListStyle)
1213 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
QTextListFormat::Style listStyle
QVariant variant
Definition: qcssparser_p.h:372
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
QTextBlockFormat blockFormat
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350

◆ uncollapsedMargin()

int QTextHtmlParserNode::uncollapsedMargin ( int  mar) const
inline

Definition at line 240 of file qtexthtmlparser_p.h.

240 { return margin[mar]; }

Friends and Related Functions

◆ QTextHtmlParser

friend class QTextHtmlParser
friend

Definition at line 259 of file qtexthtmlparser_p.h.

Properties

◆ attributes

QStringList QTextHtmlParserNode::attributes

◆ blockFormat

QTextBlockFormat QTextHtmlParserNode::blockFormat

◆ borderBrush

QBrush QTextHtmlParserNode::borderBrush

Definition at line 195 of file qtexthtmlparser_p.h.

Referenced by applyCssDeclarations(), and QTextHtmlImporter::scanTable().

◆ borderStyle

QTextFrameFormat::BorderStyle QTextHtmlParserNode::borderStyle

Definition at line 196 of file qtexthtmlparser_p.h.

Referenced by applyCssDeclarations(), and QTextHtmlImporter::scanTable().

◆ charFormat

QTextCharFormat QTextHtmlParserNode::charFormat

◆ children

QVector<int> QTextHtmlParserNode::children

◆ cssFloat

uint QTextHtmlParserNode::cssFloat

◆ cssListIndent

int QTextHtmlParserNode::cssListIndent

◆ displayMode

uint QTextHtmlParserNode::displayMode

◆ hasCssListIndent

uint QTextHtmlParserNode::hasCssListIndent

◆ hasHref

uint QTextHtmlParserNode::hasHref

Definition at line 181 of file qtexthtmlparser_p.h.

Referenced by initializeProperties().

◆ hasOwnListStyle

uint QTextHtmlParserNode::hasOwnListStyle

◆ height

QTextLength QTextHtmlParserNode::height

◆ id

QTextHTMLElements QTextHtmlParserNode::id

◆ imageHeight

qreal QTextHtmlParserNode::imageHeight

◆ imageName

QString QTextHtmlParserNode::imageName

◆ imageWidth

qreal QTextHtmlParserNode::imageWidth

◆ isEmptyParagraph

uint QTextHtmlParserNode::isEmptyParagraph

◆ isRootFrame

uint QTextHtmlParserNode::isRootFrame

Definition at line 179 of file qtexthtmlparser_p.h.

Referenced by applyCssDeclarations(), and QTextHtmlImporter::scanTable().

◆ isTextFrame

uint QTextHtmlParserNode::isTextFrame

Definition at line 178 of file qtexthtmlparser_p.h.

Referenced by applyCssDeclarations(), and QTextHtmlImporter::scanTable().

◆ listStyle

QTextListFormat::Style QTextHtmlParserNode::listStyle

◆ margin

int QTextHtmlParserNode::margin[4]

◆ padding

int QTextHtmlParserNode::padding[4]

Definition at line 257 of file qtexthtmlparser_p.h.

Referenced by applyCssDeclarations(), and initializeProperties().

◆ parent

int QTextHtmlParserNode::parent

◆ tableBorder

qreal QTextHtmlParserNode::tableBorder

◆ tableCellColSpan

int QTextHtmlParserNode::tableCellColSpan

◆ tableCellPadding

qreal QTextHtmlParserNode::tableCellPadding

◆ tableCellRowSpan

int QTextHtmlParserNode::tableCellRowSpan

◆ tableCellSpacing

qreal QTextHtmlParserNode::tableCellSpacing

◆ tag

QString QTextHtmlParserNode::tag

◆ text

QString QTextHtmlParserNode::text

◆ textListNumberPrefix

QString QTextHtmlParserNode::textListNumberPrefix

◆ textListNumberSuffix

QString QTextHtmlParserNode::textListNumberSuffix

◆ userState

int QTextHtmlParserNode::userState

◆ width

QTextLength QTextHtmlParserNode::width

◆ wsm

WhiteSpaceMode QTextHtmlParserNode::wsm

The documentation for this struct was generated from the following files: