Qt 4.8
Classes | Public Types | Public Functions | Static Public Functions | Protected Functions | Protected Variables | List of all members
QTextHtmlParser Class Reference

#include <qtexthtmlparser_p.h>

Inheritance diagram for QTextHtmlParser:
QTextHtmlImporter

Classes

struct  ExternalStyleSheet
 

Public Types

enum  Margin { MarginTop, MarginRight, MarginBottom, MarginLeft }
 

Public Functions

const QTextHtmlParserNodeat (int i) const
 
int bottomMargin (int i) const
 
int bottomPadding (int i) const
 
int count () const
 
int depth (int i) const
 
void dumpHtml ()
 
int last () const
 
int leftMargin (int i) const
 
int leftPadding (int i) const
 
QTextHtmlParserNodeoperator[] (int i)
 
void parse (const QString &text, const QTextDocument *resourceProvider)
 
int rightMargin (int i) const
 
int rightPadding (int i) const
 
int topMargin (int i) const
 
int topPadding (int i) const
 

Static Public Functions

static int lookupElement (const QString &element)
 

Protected Functions

void applyAttributes (const QStringList &attributes)
 
QVector< QCss::DeclarationdeclarationsForNode (int node) const
 
void eatSpace ()
 
bool hasPrefix (QChar c, int lookahead=0) const
 
void importStyleSheet (const QString &href)
 
int margin (int i, int mar) const
 
QTextHtmlParserNodenewNode (int parent)
 
bool nodeIsChildOf (int i, QTextHTMLElements id) const
 
void parse ()
 
QStringList parseAttributes ()
 
void parseCloseTag ()
 
QString parseEntity ()
 
void parseExclamationTag ()
 
void parseTag ()
 
QString parseWord ()
 
void resolveNode ()
 
QTextHtmlParserNoderesolveParent ()
 
void resolveStyleSheetImports (const QCss::StyleSheet &sheet)
 

Protected Variables

QVector< ExternalStyleSheetexternalStyleSheets
 
QVector< QCss::StyleSheetinlineStyleSheets
 
int len
 
QVector< QTextHtmlParserNodenodes
 
int pos
 
const QTextDocumentresourceProvider
 
bool textEditMode
 
QString txt
 

Detailed Description

Definition at line 264 of file qtexthtmlparser_p.h.

Enumerations

◆ Margin

Enumerator
MarginTop 
MarginRight 
MarginBottom 
MarginLeft 

Definition at line 267 of file qtexthtmlparser_p.h.

Functions

◆ applyAttributes()

void QTextHtmlParser::applyAttributes ( const QStringList attributes)
protected

Definition at line 1516 of file qtexthtmlparser.cpp.

1517 {
1518  // local state variable for qt3 textedit mode
1519  bool seenQt3Richtext = false;
1520  QString linkHref;
1521  QString linkType;
1522 
1523  if (attributes.count() % 2 == 1)
1524  return;
1525 
1526  QTextHtmlParserNode *node = &nodes.last();
1527 
1528  for (int i = 0; i < attributes.count(); i += 2) {
1529  QString key = attributes.at(i);
1530  QString value = attributes.at(i + 1);
1531 
1532  switch (node->id) {
1533  case Html_font:
1534  // the infamous font tag
1535  if (key == QLatin1String("size") && value.size()) {
1536  int n = value.toInt();
1537  if (value.at(0) != QLatin1Char('+') && value.at(0) != QLatin1Char('-'))
1538  n -= 3;
1540  } else if (key == QLatin1String("face")) {
1541  node->charFormat.setFontFamily(value);
1542  } else if (key == QLatin1String("color")) {
1543  QColor c; c.setNamedColor(value);
1544  if (!c.isValid())
1545  qWarning("QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1546  node->charFormat.setForeground(c);
1547  }
1548  break;
1549  case Html_ol:
1550  case Html_ul:
1551  if (key == QLatin1String("type")) {
1552  node->hasOwnListStyle = true;
1553  if (value == QLatin1String("1")) {
1555  } else if (value == QLatin1String("a")) {
1557  } else if (value == QLatin1String("A")) {
1559  } else if (value == QLatin1String("i")) {
1561  } else if (value == QLatin1String("I")) {
1563  } else {
1564  value = value.toLower();
1565  if (value == QLatin1String("square"))
1567  else if (value == QLatin1String("disc"))
1569  else if (value == QLatin1String("circle"))
1571  }
1572  }
1573  break;
1574  case Html_a:
1575  if (key == QLatin1String("href"))
1576  node->charFormat.setAnchorHref(value);
1577  else if (key == QLatin1String("name"))
1578  node->charFormat.setAnchorName(value);
1579  break;
1580  case Html_img:
1581  if (key == QLatin1String("src") || key == QLatin1String("source")) {
1582  node->imageName = value;
1583  } else if (key == QLatin1String("width")) {
1584  node->imageWidth = -2; // register that there is a value for it.
1585  setFloatAttribute(&node->imageWidth, value);
1586  } else if (key == QLatin1String("height")) {
1587  node->imageHeight = -2; // register that there is a value for it.
1588  setFloatAttribute(&node->imageHeight, value);
1589  }
1590  break;
1591  case Html_tr:
1592  case Html_body:
1593  if (key == QLatin1String("bgcolor")) {
1594  QColor c; c.setNamedColor(value);
1595  if (!c.isValid())
1596  qWarning("QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1597  node->charFormat.setBackground(c);
1598  } else if (key == QLatin1String("background")) {
1599  node->applyBackgroundImage(value, resourceProvider);
1600  }
1601  break;
1602  case Html_th:
1603  case Html_td:
1604  if (key == QLatin1String("width")) {
1605  setWidthAttribute(&node->width, value);
1606  } else if (key == QLatin1String("bgcolor")) {
1607  QColor c; c.setNamedColor(value);
1608  if (!c.isValid())
1609  qWarning("QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1610  node->charFormat.setBackground(c);
1611  } else if (key == QLatin1String("background")) {
1612  node->applyBackgroundImage(value, resourceProvider);
1613  } else if (key == QLatin1String("rowspan")) {
1614  if (setIntAttribute(&node->tableCellRowSpan, value))
1615  node->tableCellRowSpan = qMax(1, node->tableCellRowSpan);
1616  } else if (key == QLatin1String("colspan")) {
1617  if (setIntAttribute(&node->tableCellColSpan, value))
1618  node->tableCellColSpan = qMax(1, node->tableCellColSpan);
1619  }
1620  break;
1621  case Html_table:
1622  if (key == QLatin1String("border")) {
1623  setFloatAttribute(&node->tableBorder, value);
1624  } else if (key == QLatin1String("bgcolor")) {
1625  QColor c; c.setNamedColor(value);
1626  if (!c.isValid())
1627  qWarning("QTextHtmlParser::applyAttributes: Unknown color name '%s'",value.toLatin1().constData());
1628  node->charFormat.setBackground(c);
1629  } else if (key == QLatin1String("background")) {
1630  node->applyBackgroundImage(value, resourceProvider);
1631  } else if (key == QLatin1String("cellspacing")) {
1632  setFloatAttribute(&node->tableCellSpacing, value);
1633  } else if (key == QLatin1String("cellpadding")) {
1634  setFloatAttribute(&node->tableCellPadding, value);
1635  } else if (key == QLatin1String("width")) {
1636  setWidthAttribute(&node->width, value);
1637  } else if (key == QLatin1String("height")) {
1638  setWidthAttribute(&node->height, value);
1639  }
1640  break;
1641  case Html_meta:
1642  if (key == QLatin1String("name")
1643  && value == QLatin1String("qrichtext")) {
1644  seenQt3Richtext = true;
1645  }
1646 
1647  if (key == QLatin1String("content")
1648  && value == QLatin1String("1")
1649  && seenQt3Richtext) {
1650 
1651  textEditMode = true;
1652  }
1653  break;
1654  case Html_hr:
1655  if (key == QLatin1String("width"))
1656  setWidthAttribute(&node->width, value);
1657  break;
1658  case Html_link:
1659  if (key == QLatin1String("href"))
1660  linkHref = value;
1661  else if (key == QLatin1String("type"))
1662  linkType = value;
1663  break;
1664  default:
1665  break;
1666  }
1667 
1668  if (key == QLatin1String("style")) {
1669 #ifndef QT_NO_CSSPARSER
1670  node->parseStyleAttribute(value, resourceProvider);
1671 #endif
1672  } else if (key == QLatin1String("align")) {
1673  value = value.toLower();
1674  bool alignmentSet = true;
1675 
1676  if (value == QLatin1String("left"))
1678  else if (value == QLatin1String("right"))
1680  else if (value == QLatin1String("center"))
1682  else if (value == QLatin1String("justify"))
1684  else
1685  alignmentSet = false;
1686 
1687  if (node->id == Html_img) {
1688  // HTML4 compat
1689  if (alignmentSet) {
1690  if (node->blockFormat.alignment() & Qt::AlignLeft)
1692  else if (node->blockFormat.alignment() & Qt::AlignRight)
1694  } else if (value == QLatin1String("middle")) {
1696  } else if (value == QLatin1String("top")) {
1698  }
1699  }
1700  } else if (key == QLatin1String("valign")) {
1701  value = value.toLower();
1702  if (value == QLatin1String("top"))
1704  else if (value == QLatin1String("middle"))
1706  else if (value == QLatin1String("bottom"))
1708  } else if (key == QLatin1String("dir")) {
1709  value = value.toLower();
1710  if (value == QLatin1String("ltr"))
1712  else if (value == QLatin1String("rtl"))
1714  } else if (key == QLatin1String("title")) {
1715  node->charFormat.setToolTip(value);
1716  } else if (key == QLatin1String("id")) {
1717  node->charFormat.setAnchor(true);
1718  node->charFormat.setAnchorName(value);
1719  }
1720  }
1721 
1722 #ifndef QT_NO_CSSPARSER
1723  if (resourceProvider && !linkHref.isEmpty() && linkType == QLatin1String("text/css"))
1724  importStyleSheet(linkHref);
1725 #endif
1726 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
void setNamedColor(const QString &name)
Sets the RGB value of this QColor to name, which may be in one of these formats:
Definition: qcolor.cpp:560
unsigned char c[8]
Definition: qnumeric_p.h:62
const QTextDocument * resourceProvider
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
void setToolTip(const QString &tip)
Sets the tool tip for a fragment of text to the given text.
Definition: qtextformat.h:494
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition: qstring.cpp:6090
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
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
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
Qt::Alignment alignment() const
Returns the paragraph&#39;s alignment.
Definition: qtextformat.h:561
void parseStyleAttribute(const QString &value, const QTextDocument *resourceProvider)
QTextListFormat::Style listStyle
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void setAnchorName(const QString &name)
This function is deprecated.
Definition: qtextformat.h:509
QTextCharFormat charFormat
static bool setIntAttribute(int *destination, const QString &value)
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
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
void importStyleSheet(const QString &href)
QTextBlockFormat blockFormat
Q_CORE_EXPORT void qWarning(const char *,...)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
QTextHTMLElements id
QVector< QTextHtmlParserNode > nodes
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
void setAlignment(Qt::Alignment alignment)
Sets the paragraph&#39;s alignment.
Definition: qtextformat.h:619
void setAnchorHref(const QString &value)
Sets the hypertext link for the text format to the given value.
Definition: qtextformat.h:504
void applyBackgroundImage(const QString &url, const QTextDocument *resourceProvider)
int key
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
T & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262
void setFontFamily(const QString &family)
Sets the text format&#39;s font family.
Definition: qtextformat.h:401
if(void) toggleToolbarShown
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
static bool setFloatAttribute(qreal *destination, const QString &value)
bool isValid() const
Returns true if the color is valid; otherwise returns false.
Definition: qcolor.h:295
void setLayoutDirection(Qt::LayoutDirection direction)
Sets the document&#39;s layout direction to the specified direction.
Definition: qtextformat.h:338
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
static void setWidthAttribute(QTextLength *width, QString value)

◆ at()

const QTextHtmlParserNode& QTextHtmlParser::at ( int  i) const
inline

Definition at line 274 of file qtexthtmlparser_p.h.

Referenced by QTextHtmlImporter::closeTag(), QTextHtmlImporter::import(), QTextHtmlParserNode::isNestedList(), QTextHtmlImporter::processBlockNode(), QTextHtmlImporter::processSpecialNodes(), and QTextHtmlImporter::scanTable().

274 { return nodes.at(i); }
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QTextHtmlParserNode > nodes

◆ bottomMargin()

int QTextHtmlParser::bottomMargin ( int  i) const

Definition at line 610 of file qtexthtmlparser.cpp.

Referenced by QTextHtmlImporter::processBlockNode(), QTextHtmlImporter::processSpecialNodes(), and QTextHtmlImporter::scanTable().

611 {
612  if (!i)
613  return 0;
614  return at(i).margin[MarginBottom];
615 }
const QTextHtmlParserNode & at(int i) const

◆ bottomPadding()

int QTextHtmlParser::bottomPadding ( int  i) const
inline

Definition at line 285 of file qtexthtmlparser_p.h.

Referenced by QTextHtmlImporter::processBlockNode().

285 { return at(i).padding[MarginBottom]; }
const QTextHtmlParserNode & at(int i) const

◆ count()

int QTextHtmlParser::count ( ) const
inline

Definition at line 276 of file qtexthtmlparser_p.h.

Referenced by QTextHtmlImporter::import().

276 { return nodes.count(); }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QVector< QTextHtmlParserNode > nodes

◆ declarationsForNode()

QVector< QCss::Declaration > QTextHtmlParser::declarationsForNode ( int  node) const
protected

Definition at line 1856 of file qtexthtmlparser.cpp.

1857 {
1859 
1860  QTextHtmlStyleSelector selector(this);
1861 
1862  int idx = 0;
1863  selector.styleSheets.resize((resourceProvider ? 1 : 0)
1864  + externalStyleSheets.count()
1865  + inlineStyleSheets.count());
1866  if (resourceProvider)
1867  selector.styleSheets[idx++] = resourceProvider->docHandle()->parsedDefaultStyleSheet;
1868 
1869  for (int i = 0; i < externalStyleSheets.count(); ++i, ++idx)
1870  selector.styleSheets[idx] = externalStyleSheets.at(i).sheet;
1871 
1872  for (int i = 0; i < inlineStyleSheets.count(); ++i, ++idx)
1873  selector.styleSheets[idx] = inlineStyleSheets.at(i);
1874 
1875  selector.medium = QLatin1String("screen");
1876 
1878  n.id = node;
1879 
1880  const char *extraPseudo = 0;
1881  if (nodes.at(node).id == Html_a && nodes.at(node).hasHref)
1882  extraPseudo = "link";
1883  decls = selector.declarationsForNode(n, extraPseudo);
1884 
1885  return decls;
1886 }
const QTextDocument * resourceProvider
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QTextDocumentPrivate * docHandle() const
So that not all classes have to be friends of each other.
QCss::StyleSheet parsedDefaultStyleSheet
QTextHTMLElements id
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QTextHtmlParserNode > nodes
QVector< QCss::StyleSheet > inlineStyleSheets
QVector< ExternalStyleSheet > externalStyleSheets

◆ depth()

int QTextHtmlParser::depth ( int  i) const

Definition at line 575 of file qtexthtmlparser.cpp.

Referenced by QTextHtmlImporter::closeTag().

576 {
577  int depth = 0;
578  while (i) {
579  i = at(i).parent;
580  ++depth;
581  }
582  return depth;
583 }
const QTextHtmlParserNode & at(int i) const
int depth(int i) const

◆ dumpHtml()

void QTextHtmlParser::dumpHtml ( )

Definition at line 497 of file qtexthtmlparser.cpp.

498 {
499  for (int i = 0; i < count(); ++i) {
500  qDebug().nospace() << qPrintable(QString(depth(i)*4, QLatin1Char(' ')))
501  << qPrintable(at(i).tag) << ':'
502  << quoteNewline(at(i).text);
503  ;
504  }
505 }
static QString quoteNewline(const QString &s)
const QTextHtmlParserNode & at(int i) const
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_CORE_EXPORT void qDebug(const char *,...)
int depth(int i) const
#define qPrintable(string)
Definition: qglobal.h:1750
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
#define text
Definition: qobjectdefs.h:80

◆ eatSpace()

void QTextHtmlParser::eatSpace ( )
protected

Definition at line 617 of file qtexthtmlparser.cpp.

618 {
619  while (pos < len && txt.at(pos).isSpace() && txt.at(pos) != QChar::ParagraphSeparator)
620  pos++;
621 }
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

◆ hasPrefix()

bool QTextHtmlParser::hasPrefix ( QChar  c,
int  lookahead = 0 
) const
inlineprotected

Definition at line 313 of file qtexthtmlparser_p.h.

314  {return pos + lookahead < len && txt.at(pos) == c; }
unsigned char c[8]
Definition: qnumeric_p.h:62
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698

◆ importStyleSheet()

void QTextHtmlParser::importStyleSheet ( const QString href)
protected

Definition at line 1831 of file qtexthtmlparser.cpp.

1832 {
1833  if (!resourceProvider)
1834  return;
1835  for (int i = 0; i < externalStyleSheets.count(); ++i)
1836  if (externalStyleSheets.at(i).url == href)
1837  return;
1838 
1840  QString css;
1841  if (res.type() == QVariant::String) {
1842  css = res.toString();
1843  } else if (res.type() == QVariant::ByteArray) {
1844  // #### detect @charset
1845  css = QString::fromUtf8(res.toByteArray());
1846  }
1847  if (!css.isEmpty()) {
1848  QCss::Parser parser(css);
1849  QCss::StyleSheet sheet;
1850  parser.parse(&sheet, Qt::CaseInsensitive);
1851  externalStyleSheets.append(ExternalStyleSheet(href, sheet));
1852  resolveStyleSheetImports(sheet);
1853  }
1854 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
const QTextDocument * resourceProvider
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
Definition: qvariant.cpp:2270
The QString class provides a Unicode character string.
Definition: qstring.h:83
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
Definition: qvariant.cpp:2383
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
Type type() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1901
void resolveStyleSheetImports(const QCss::StyleSheet &sheet)
QVariant resource(int type, const QUrl &name) const
Returns data of the specified type from the resource with the given name.
QVector< ExternalStyleSheet > externalStyleSheets

◆ last()

int QTextHtmlParser::last ( ) const
inline

Definition at line 277 of file qtexthtmlparser_p.h.

277 { return nodes.count()-1; }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QVector< QTextHtmlParserNode > nodes

◆ leftMargin()

int QTextHtmlParser::leftMargin ( int  i) const
inline

◆ leftPadding()

int QTextHtmlParser::leftPadding ( int  i) const
inline

Definition at line 286 of file qtexthtmlparser_p.h.

Referenced by QTextHtmlImporter::processBlockNode().

286 { return at(i).padding[MarginLeft]; }
const QTextHtmlParserNode & at(int i) const

◆ lookupElement()

int QTextHtmlParser::lookupElement ( const QString element)
static

Definition at line 465 of file qtexthtmlparser.cpp.

Referenced by Qt::mightBeRichText().

466 {
467  const QTextHtmlElement *e = lookupElementHelper(element);
468  if (!e)
469  return -1;
470  return e->id;
471 }
QTextHTMLElements id
static const QTextHtmlElement * lookupElementHelper(const QString &element)

◆ margin()

int QTextHtmlParser::margin ( int  i,
int  mar 
) const
protected

Definition at line 585 of file qtexthtmlparser.cpp.

585  {
586  int m = 0;
587  const QTextHtmlParserNode *node;
588  if (mar == MarginLeft
589  || mar == MarginRight) {
590  while (i) {
591  node = &at(i);
592  if (!node->isBlock() && node->id != Html_table)
593  break;
594  if (node->isTableCell())
595  break;
596  m += node->margin[mar];
597  i = node->parent;
598  }
599  }
600  return m;
601 }
const QTextHtmlParserNode & at(int i) const
QTextHTMLElements id

◆ newNode()

QTextHtmlParserNode * QTextHtmlParser::newNode ( int  parent)
protected

Definition at line 507 of file qtexthtmlparser.cpp.

508 {
509  QTextHtmlParserNode *lastNode = &nodes.last();
511 
512  bool reuseLastNode = true;
513 
514  if (nodes.count() == 1) {
515  reuseLastNode = false;
516  } else if (lastNode->tag.isEmpty()) {
517 
518  if (lastNode->text.isEmpty()) {
519  reuseLastNode = true;
520  } else { // last node is a text node (empty tag) with some text
521 
522  if (lastNode->text.length() == 1 && lastNode->text.at(0).isSpace()) {
523 
524  int lastSibling = count() - 2;
525  while (lastSibling
526  && at(lastSibling).parent != lastNode->parent
527  && at(lastSibling).displayMode == QTextHtmlElement::DisplayInline) {
528  lastSibling = at(lastSibling).parent;
529  }
530 
531  if (at(lastSibling).displayMode == QTextHtmlElement::DisplayInline) {
532  reuseLastNode = false;
533  } else {
534  reuseLastNode = true;
535  }
536  } else {
537  // text node with real (non-whitespace) text -> nothing to re-use
538  reuseLastNode = false;
539  }
540 
541  }
542 
543  } else {
544  // last node had a proper tag -> nothing to re-use
545  reuseLastNode = false;
546  }
547 
548  if (reuseLastNode) {
549  newNode = lastNode;
550  newNode->tag.clear();
551  newNode->text.clear();
552  newNode->id = Html_unknown;
553  } else {
554  nodes.resize(nodes.size() + 1);
555  newNode = &nodes.last();
556  }
557 
558  newNode->parent = parent;
559  return newNode;
560 }
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QTextHtmlParserNode * newNode(int parent)
const QTextHtmlParserNode & at(int i) const
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
Definition: qchar.cpp:609
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QTextHTMLElements id
QVector< QTextHtmlParserNode > nodes
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
T & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ nodeIsChildOf()

bool QTextHtmlParser::nodeIsChildOf ( int  i,
QTextHTMLElements  id 
) const
protected

Definition at line 1888 of file qtexthtmlparser.cpp.

1889 {
1890  while (i) {
1891  if (at(i).id == id)
1892  return true;
1893  i = at(i).parent;
1894  }
1895  return false;
1896 }
const QTextHtmlParserNode & at(int i) const

◆ operator[]()

QTextHtmlParserNode& QTextHtmlParser::operator[] ( int  i)
inline

Definition at line 275 of file qtexthtmlparser_p.h.

275 { return nodes[i]; }
QVector< QTextHtmlParserNode > nodes

◆ parse() [1/2]

void QTextHtmlParser::parse ( const QString text,
const QTextDocument resourceProvider 
)

Definition at line 562 of file qtexthtmlparser.cpp.

563 {
564  nodes.clear();
565  nodes.resize(1);
566  txt = text;
567  pos = 0;
568  len = txt.length();
569  textEditMode = false;
570  resourceProvider = _resourceProvider;
571  parse();
572  //dumpHtml();
573 }
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
Definition: qvector.h:347
QVector< QTextHtmlParserNode > nodes
#define text
Definition: qobjectdefs.h:80

◆ parse() [2/2]

void QTextHtmlParser::parse ( )
protected

Definition at line 623 of file qtexthtmlparser.cpp.

Referenced by QTextHtmlImporter::QTextHtmlImporter().

624 {
625  while (pos < len) {
626  QChar c = txt.at(pos++);
627  if (c == QLatin1Char('<')) {
628  parseTag();
629  } else if (c == QLatin1Char('&')) {
630  nodes.last().text += parseEntity();
631  } else {
632  nodes.last().text += c;
633  }
634  }
635 }
unsigned char c[8]
Definition: qnumeric_p.h:62
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QVector< QTextHtmlParserNode > nodes
T & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseAttributes()

QStringList QTextHtmlParser::parseAttributes ( )
protected

Definition at line 1490 of file qtexthtmlparser.cpp.

1491 {
1492  QStringList attrs;
1493 
1494  while (pos < len) {
1495  eatSpace();
1496  if (hasPrefix(QLatin1Char('>')) || hasPrefix(QLatin1Char('/')))
1497  break;
1498  QString key = parseWord().toLower();
1499  QString value = QLatin1String("1");
1500  if (key.size() == 0)
1501  break;
1502  eatSpace();
1503  if (hasPrefix(QLatin1Char('='))){
1504  pos++;
1505  eatSpace();
1506  value = parseWord();
1507  }
1508  if (value.size() == 0)
1509  continue;
1510  attrs << key << value;
1511  }
1512 
1513  return attrs;
1514 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
int key
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
bool hasPrefix(QChar c, int lookahead=0) const
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseCloseTag()

void QTextHtmlParser::parseCloseTag ( )
protected

Definition at line 728 of file qtexthtmlparser.cpp.

729 {
730  ++pos;
731  QString tag = parseWord().toLower().trimmed();
732  while (pos < len) {
733  QChar c = txt.at(pos++);
734  if (c == QLatin1Char('>'))
735  break;
736  }
737 
738  // find corresponding open node
739  int p = last();
740  if (p > 0
741  && at(p - 1).tag == tag
742  && at(p - 1).mayNotHaveChildren())
743  p--;
744 
745  while (p && at(p).tag != tag)
746  p = at(p).parent;
747 
748  // simply ignore the tag if we can't find
749  // a corresponding open node, for broken
750  // html such as <font>blah</font></font>
751  if (!p)
752  return;
753 
754  // in a white-space preserving environment strip off a trailing newline
755  // since the closing of the opening block element will automatically result
756  // in a new block for elements following the <pre>
757  // ...foo\n</pre><p>blah -> foo</pre><p>blah
760  && at(p).isBlock()) {
761  if (at(last()).text.endsWith(QLatin1Char('\n')))
762  nodes[last()].text.chop(1);
763  }
764 
765  newNode(at(p).parent);
766  resolveNode();
767 }
unsigned char c[8]
Definition: qnumeric_p.h:62
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
QTextHtmlParserNode * newNode(int parent)
const QTextHtmlParserNode & at(int i) const
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
QVector< QTextHtmlParserNode > nodes
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
#define text
Definition: qobjectdefs.h:80

◆ parseEntity()

QString QTextHtmlParser::parseEntity ( )
protected

Definition at line 789 of file qtexthtmlparser.cpp.

790 {
791  int recover = pos;
792  QString entity;
793  while (pos < len) {
794  QChar c = txt.at(pos++);
795  if (c.isSpace() || pos - recover > 9) {
796  goto error;
797  }
798  if (c == QLatin1Char(';'))
799  break;
800  entity += c;
801  }
802  {
803  QChar resolved = resolveEntity(entity);
804  if (!resolved.isNull())
805  return QString(resolved);
806  }
807  if (entity.length() > 1 && entity.at(0) == QLatin1Char('#')) {
808  entity.remove(0, 1); // removing leading #
809 
810  int base = 10;
811  bool ok = false;
812 
813  if (entity.at(0).toLower() == QLatin1Char('x')) { // hex entity?
814  entity.remove(0, 1);
815  base = 16;
816  }
817 
818  uint uc = entity.toUInt(&ok, base);
819  if (ok) {
820  if (uc >= 0x80 && uc < 0x80 + (sizeof(windowsLatin1ExtendedCharacters)/sizeof(windowsLatin1ExtendedCharacters[0])))
821  uc = windowsLatin1ExtendedCharacters[uc - 0x80];
822  QString str;
823  if (QChar::requiresSurrogates(uc)) {
824  str += QChar(QChar::highSurrogate(uc));
825  str += QChar(QChar::lowSurrogate(uc));
826  } else {
827  str = QChar(uc);
828  }
829  return str;
830  }
831  }
832 error:
833  pos = recover;
834  return QLatin1String("&");
835 }
static const ushort windowsLatin1ExtendedCharacters[0xA0 - 0x80]
unsigned char c[8]
Definition: qnumeric_p.h:62
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
bool isNull() const
Returns true if the character is the Unicode character 0x0000 (&#39;\0&#39;); otherwise returns false...
Definition: qchar.h:262
#define error(msg)
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const uint base
Definition: qurl.cpp:268
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
Definition: qchar.cpp:609
static ushort highSurrogate(uint ucs4)
Returns the high surrogate value of a ucs4 code point.
Definition: qchar.h:303
static ushort lowSurrogate(uint ucs4)
Returns the low surrogate value of a ucs4 code point.
Definition: qchar.h:306
static bool requiresSurrogates(uint ucs4)
Returns true if the UCS-4-encoded character specified by ucs4 can be split into the high and low part...
Definition: qchar.h:294
unsigned int uint
Definition: qglobal.h:996
static QChar resolveEntity(const QString &entity)
uint toUInt(bool *ok=0, int base=10) const
Returns the string converted to an unsigned int using base base, which is 10 by default and must be b...
Definition: qstring.cpp:6120
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
QChar toLower() const
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
Definition: qchar.cpp:1239
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseExclamationTag()

void QTextHtmlParser::parseExclamationTag ( )
protected

Definition at line 770 of file qtexthtmlparser.cpp.

771 {
772  ++pos;
773  if (hasPrefix(QLatin1Char('-'),1) && hasPrefix(QLatin1Char('-'),2)) {
774  pos += 3;
775  // eat comments
776  int end = txt.indexOf(QLatin1String("-->"), pos);
777  pos = (end >= 0 ? end + 3 : len);
778  } else {
779  // eat internal tags
780  while (pos < len) {
781  QChar c = txt.at(pos++);
782  if (c == QLatin1Char('>'))
783  break;
784  }
785  }
786 }
unsigned char c[8]
Definition: qnumeric_p.h:62
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
bool hasPrefix(QChar c, int lookahead=0) const
static const KeyPair *const end
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseTag()

void QTextHtmlParser::parseTag ( )
protected

Definition at line 638 of file qtexthtmlparser.cpp.

639 {
640  eatSpace();
641 
642  // handle comments and other exclamation mark declarations
643  if (hasPrefix(QLatin1Char('!'))) {
647  && !textEditMode)
648  eatSpace();
649  return;
650  }
651 
652  // if close tag just close
653  if (hasPrefix(QLatin1Char('/'))) {
654  if (nodes.last().id == Html_style) {
655 #ifndef QT_NO_CSSPARSER
656  QCss::Parser parser(nodes.last().text);
657  QCss::StyleSheet sheet;
659  parser.parse(&sheet, Qt::CaseInsensitive);
660  inlineStyleSheets.append(sheet);
662 #endif
663  }
664  parseCloseTag();
665  return;
666  }
667 
668  int p = last();
669  while (p && at(p).tag.size() == 0)
670  p = at(p).parent;
671 
672  QTextHtmlParserNode *node = newNode(p);
673 
674  // parse tag name
675  node->tag = parseWord().toLower();
676 
677  const QTextHtmlElement *elem = lookupElementHelper(node->tag);
678  if (elem) {
679  node->id = elem->id;
680  node->displayMode = elem->displayMode;
681  } else {
682  node->id = Html_unknown;
683  }
684 
685  node->attributes.clear();
686  // _need_ at least one space after the tag name, otherwise there can't be attributes
687  if (pos < len && txt.at(pos).isSpace())
688  node->attributes = parseAttributes();
689 
690  // resolveParent() may have to change the order in the tree and
691  // insert intermediate nodes for buggy HTML, so re-initialize the 'node'
692  // pointer through the return value
693  node = resolveParent();
694  resolveNode();
695 
696  const int nodeIndex = nodes.count() - 1; // this new node is always the last
697 #ifndef QT_NO_CSSPARSER
699 #endif
701 
702  // finish tag
703  bool tagClosed = false;
704  while (pos < len && txt.at(pos) != QLatin1Char('>')) {
705  if (txt.at(pos) == QLatin1Char('/'))
706  tagClosed = true;
707 
708  pos++;
709  }
710  pos++;
711 
712  // in a white-space preserving environment strip off a initial newline
713  // since the element itself already generates a newline
716  && node->isBlock()) {
717  if (pos < len - 1 && txt.at(pos) == QLatin1Char('\n'))
718  ++pos;
719  }
720 
721  if (node->mayNotHaveChildren() || tagClosed) {
722  newNode(node->parent);
723  resolveNode();
724  }
725 }
bool mayNotHaveChildren() const
const QTextDocument * resourceProvider
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QTextHtmlParserNode * newNode(int parent)
const QTextHtmlParserNode & at(int i) const
QTextHTMLElements id
StyleSheetOrigin origin
Definition: qcssparser_p.h:643
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
Definition: qchar.cpp:609
QVector< QCss::Declaration > declarationsForNode(int node) const
QStringList parseAttributes()
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
void applyCssDeclarations(const QVector< QCss::Declaration > &declarations, const QTextDocument *resourceProvider)
void clear()
Removes all items from the list.
Definition: qlist.h:764
QTextHTMLElements id
QVector< QTextHtmlParserNode > nodes
QTextHtmlParserNode * resolveParent()
QVector< QCss::StyleSheet > inlineStyleSheets
QString toLower() const Q_REQUIRED_RESULT
Returns a lowercase copy of the string.
Definition: qstring.cpp:5389
T & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262
static const QTextHtmlElement * lookupElementHelper(const QString &element)
enum QTextHtmlElement::DisplayMode displayMode
void resolveStyleSheetImports(const QCss::StyleSheet &sheet)
bool hasPrefix(QChar c, int lookahead=0) const
void applyAttributes(const QStringList &attributes)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ parseWord()

QString QTextHtmlParser::parseWord ( )
protected

Definition at line 838 of file qtexthtmlparser.cpp.

839 {
840  QString word;
841  if (hasPrefix(QLatin1Char('\"'))) { // double quotes
842  ++pos;
843  while (pos < len) {
844  QChar c = txt.at(pos++);
845  if (c == QLatin1Char('\"'))
846  break;
847  else if (c == QLatin1Char('&'))
848  word += parseEntity();
849  else
850  word += c;
851  }
852  } else if (hasPrefix(QLatin1Char('\''))) { // single quotes
853  ++pos;
854  while (pos < len) {
855  QChar c = txt.at(pos++);
856  if (c == QLatin1Char('\''))
857  break;
858  else
859  word += c;
860  }
861  } else { // normal text
862  while (pos < len) {
863  QChar c = txt.at(pos++);
864  if (c == QLatin1Char('>')
865  || (c == QLatin1Char('/') && hasPrefix(QLatin1Char('>'), 1))
866  || c == QLatin1Char('<')
867  || c == QLatin1Char('=')
868  || c.isSpace()) {
869  --pos;
870  break;
871  }
872  if (c == QLatin1Char('&'))
873  word += parseEntity();
874  else
875  word += c;
876  }
877  }
878  return word;
879 }
unsigned char c[8]
Definition: qnumeric_p.h:62
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
bool isSpace() const
Returns true if the character is a separator character (Separator_* categories); otherwise returns fa...
Definition: qchar.cpp:609
bool hasPrefix(QChar c, int lookahead=0) const
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ resolveNode()

void QTextHtmlParser::resolveNode ( )
protected

Definition at line 980 of file qtexthtmlparser.cpp.

981 {
982  QTextHtmlParserNode *node = &nodes.last();
983  const QTextHtmlParserNode *parent = &nodes.at(node->parent);
984  node->initializeProperties(parent, this);
985 }
void initializeProperties(const QTextHtmlParserNode *parent, const QTextHtmlParser *parser)
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QTextHtmlParserNode > nodes
T & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262

◆ resolveParent()

QTextHtmlParserNode * QTextHtmlParser::resolveParent ( )
protected

Definition at line 882 of file qtexthtmlparser.cpp.

883 {
884  QTextHtmlParserNode *node = &nodes.last();
885 
886  int p = node->parent;
887 
888  // Excel gives us buggy HTML with just tr without surrounding table tags
889  // or with just td tags
890 
891  if (node->id == Html_td) {
892  int n = p;
893  while (n && at(n).id != Html_tr)
894  n = at(n).parent;
895 
896  if (!n) {
899 
900  QTextHtmlParserNode *table = &nodes[nodes.count() - 3];
901  table->parent = p;
902  table->id = Html_table;
903  table->tag = QLatin1String("table");
904  table->children.append(nodes.count() - 2); // add row as child
905 
906  QTextHtmlParserNode *row = &nodes[nodes.count() - 2];
907  row->parent = nodes.count() - 3; // table as parent
908  row->id = Html_tr;
909  row->tag = QLatin1String("tr");
910 
911  p = nodes.count() - 2;
912  node = &nodes.last(); // re-initialize pointer
913  }
914  }
915 
916  if (node->id == Html_tr) {
917  int n = p;
918  while (n && at(n).id != Html_table)
919  n = at(n).parent;
920 
921  if (!n) {
923  QTextHtmlParserNode *table = &nodes[nodes.count() - 2];
924  table->parent = p;
925  table->id = Html_table;
926  table->tag = QLatin1String("table");
927  p = nodes.count() - 2;
928  node = &nodes.last(); // re-initialize pointer
929  }
930  }
931 
932  // permit invalid html by letting block elements be children
933  // of inline elements with the exception of paragraphs:
934  //
935  // a new paragraph closes parent inline elements (while loop),
936  // unless they themselves are children of a non-paragraph block
937  // element (if statement)
938  //
939  // For example:
940  //
941  // <body><p><b>Foo<p>Bar <-- second <p> implicitly closes <b> that
942  // belongs to the first <p>. The self-nesting
943  // check further down prevents the second <p>
944  // from nesting into the first one then.
945  // so Bar is not bold.
946  //
947  // <body><b><p>Foo <-- Foo should be bold.
948  //
949  // <body><b><p>Foo<p>Bar <-- Foo and Bar should be bold.
950  //
951  if (node->id == Html_p) {
952  while (p && !at(p).isBlock())
953  p = at(p).parent;
954 
955  if (!p || at(p).id != Html_p)
956  p = node->parent;
957  }
958 
959  // some elements are not self nesting
960  if (node->id == at(p).id
961  && node->isNotSelfNesting())
962  p = at(p).parent;
963 
964  // some elements are not allowed in certain contexts
965  while ((p && !node->allowedInContext(at(p).id))
966  // ### make new styles aware of empty tags
967  || at(p).mayNotHaveChildren()
968  ) {
969  p = at(p).parent;
970  }
971 
972  node->parent = p;
973 
974  // makes it easier to traverse the tree, later
975  nodes[p].children.append(nodes.count() - 1);
976  return node;
977 }
bool mayNotHaveChildren() const
QVector< int > children
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
const QTextHtmlParserNode & at(int i) const
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
QTextHTMLElements id
QVector< QTextHtmlParserNode > nodes
void insert(int i, const T &t)
Inserts value at index position i in the vector.
Definition: qvector.h:362
T & last()
Returns a reference to the last item in the vector.
Definition: qvector.h:262
bool allowedInContext(int parentId) const
bool isNotSelfNesting() const

◆ resolveStyleSheetImports()

void QTextHtmlParser::resolveStyleSheetImports ( const QCss::StyleSheet sheet)
protected

Definition at line 1821 of file qtexthtmlparser.cpp.

1822 {
1823  for (int i = 0; i < sheet.importRules.count(); ++i) {
1824  const QCss::ImportRule &rule = sheet.importRules.at(i);
1825  if (rule.media.isEmpty()
1826  || rule.media.contains(QLatin1String("screen"), Qt::CaseInsensitive))
1827  importStyleSheet(rule.href);
1828  }
1829 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void importStyleSheet(const QString &href)
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
QVector< ImportRule > importRules
Definition: qcssparser_p.h:642
QStringList media
Definition: qcssparser_p.h:625

◆ rightMargin()

int QTextHtmlParser::rightMargin ( int  i) const
inline

◆ rightPadding()

int QTextHtmlParser::rightPadding ( int  i) const
inline

Definition at line 287 of file qtexthtmlparser_p.h.

Referenced by QTextHtmlImporter::processBlockNode().

287 { return at(i).padding[MarginRight]; }
const QTextHtmlParserNode & at(int i) const

◆ topMargin()

int QTextHtmlParser::topMargin ( int  i) const

Definition at line 603 of file qtexthtmlparser.cpp.

Referenced by QTextHtmlImporter::processBlockNode(), QTextHtmlImporter::processSpecialNodes(), and QTextHtmlImporter::scanTable().

604 {
605  if (!i)
606  return 0;
607  return at(i).margin[MarginTop];
608 }
const QTextHtmlParserNode & at(int i) const

◆ topPadding()

int QTextHtmlParser::topPadding ( int  i) const
inline

Definition at line 284 of file qtexthtmlparser_p.h.

Referenced by QTextHtmlImporter::processBlockNode().

284 { return at(i).padding[MarginTop]; }
const QTextHtmlParserNode & at(int i) const

Properties

◆ externalStyleSheets

QVector<ExternalStyleSheet> QTextHtmlParser::externalStyleSheets
protected

Definition at line 333 of file qtexthtmlparser_p.h.

◆ inlineStyleSheets

QVector<QCss::StyleSheet> QTextHtmlParser::inlineStyleSheets
protected

Definition at line 334 of file qtexthtmlparser_p.h.

◆ len

int QTextHtmlParser::len
protected

Definition at line 298 of file qtexthtmlparser_p.h.

◆ nodes

QVector<QTextHtmlParserNode> QTextHtmlParser::nodes
protected

Definition at line 296 of file qtexthtmlparser_p.h.

◆ pos

int QTextHtmlParser::pos
protected

Definition at line 298 of file qtexthtmlparser_p.h.

◆ resourceProvider

const QTextDocument* QTextHtmlParser::resourceProvider
protected

Definition at line 337 of file qtexthtmlparser_p.h.

◆ textEditMode

bool QTextHtmlParser::textEditMode
protected

◆ txt

QString QTextHtmlParser::txt
protected

Definition at line 297 of file qtexthtmlparser_p.h.


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