Doxygen
Loading...
Searching...
No Matches
DocHtmlCell Class Reference

Node representing a HTML table cell. More...

#include <src/docnode.h>

+ Inheritance diagram for DocHtmlCell:
+ Collaboration diagram for DocHtmlCell:

Public Types

enum  Alignment { Left , Right , Center }
 
enum  Valignment { Top , Middle , Bottom }
 

Public Member Functions

 DocHtmlCell (DocParser *parser, DocNodeVariant *parent, const HtmlAttribList &attribs, bool isHeading)
 
bool isHeading () const
 
bool isFirst () const
 
bool isLast () const
 
void markFirst (bool v=TRUE)
 
void markLast (bool v=TRUE)
 
const HtmlAttribListattribs () const
 
Token parse ()
 
Token parseXml ()
 
uint32_t rowIndex () const
 
uint32_t columnIndex () const
 
uint32_t rowSpan () const
 
uint32_t colSpan () const
 
Alignment alignment () const
 
Valignment valignment () const
 
- Public Member Functions inherited from DocCompoundNode
 DocCompoundNode (DocParser *parser, DocNodeVariant *parent)
 
DocNodeListchildren ()
 
const DocNodeListchildren () const
 
- Public Member Functions inherited from DocNode
 DocNode (DocParser *parser, DocNodeVariant *parent)
 
 ~DocNode ()=default
 
DocNodeVariantparent ()
 
const DocNodeVariantparent () const
 
DocNodeVariantthisVariant ()
 
const DocNodeVariantthisVariant () const
 
void setThisVariant (DocNodeVariant *thisVariant)
 
DocParserparser ()
 
const DocParserparser () const
 
void setParent (DocNodeVariant *parent)
 
bool isPreformatted () const
 

Private Member Functions

void setRowIndex (uint32_t idx)
 
void setColumnIndex (uint32_t idx)
 

Private Attributes

bool m_isHeading = false
 
bool m_isFirst = false
 
bool m_isLast = false
 
HtmlAttribList m_attribs
 
uint32_t m_rowIdx = static_cast<uint32_t>(-1)
 
uint32_t m_colIdx = static_cast<uint32_t>(-1)
 

Friends

class DocHtmlTable
 

Additional Inherited Members

- Protected Types inherited from DocNode
enum  RefType { Unknown , Anchor , Section , Table }
 
- Protected Member Functions inherited from DocNode
void setInsidePreformatted (bool p)
 

Detailed Description

Node representing a HTML table cell.

Definition at line 1186 of file docnode.h.

Member Enumeration Documentation

◆ Alignment

Enumerator
Left 
Right 
Center 

Definition at line 1190 of file docnode.h.

◆ Valignment

Enumerator
Top 
Middle 
Bottom 

Definition at line 1191 of file docnode.h.

Constructor & Destructor Documentation

◆ DocHtmlCell()

DocHtmlCell::DocHtmlCell ( DocParser * parser,
DocNodeVariant * parent,
const HtmlAttribList & attribs,
bool isHeading )
inline

Definition at line 1192 of file docnode.h.

1192 :
DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:140
bool isHeading() const
Definition docnode.h:1194
const HtmlAttribList & attribs() const
Definition docnode.h:1199
HtmlAttribList m_attribs
Definition docnode.h:1215
bool m_isHeading
Definition docnode.h:1212
DocParser * parser()
Definition docnode.h:97
DocNodeVariant * parent()
Definition docnode.h:89

References attribs(), DocCompoundNode::DocCompoundNode(), isHeading(), m_attribs, m_isHeading, DocNode::parent(), and DocNode::parser().

Member Function Documentation

◆ alignment()

DocHtmlCell::Alignment DocHtmlCell::alignment ( ) const

Definition at line 1823 of file docnode.cpp.

1824{
1825 for (const auto &attr : attribs())
1826 {
1827 QCString attrName = attr.name.lower();
1828 QCString attrValue = attr.value.lower();
1829 if (attrName=="align")
1830 {
1831 if (attrValue=="center")
1832 return Center;
1833 else if (attrValue=="right")
1834 return Right;
1835 else return Left;
1836 }
1837 else if (attrName=="class" && attrValue.startsWith("markdowntable"))
1838 {
1839 if (attrValue=="markdowntableheadcenter")
1840 return Center;
1841 else if (attrValue=="markdowntableheadright")
1842 return Right;
1843 else if (attrValue=="markdowntableheadleft")
1844 return Left;
1845 else if (attrValue=="markdowntableheadnone")
1846 return Center;
1847 else if (attrValue=="markdowntablebodycenter")
1848 return Center;
1849 else if (attrValue=="markdowntablebodyright")
1850 return Right;
1851 else if (attrValue=="markdowntablebodyleft")
1852 return Left;
1853 else if (attrValue=="markdowntablebodynone")
1854 return Left;
1855 else return Left;
1856 }
1857 }
1858 return Left;
1859}
bool startsWith(const char *s) const
Definition qcstring.h:492

References attribs(), Center, Left, QCString::lower(), Right, and QCString::startsWith().

Referenced by LatexDocVisitor::operator()().

◆ attribs()

const HtmlAttribList & DocHtmlCell::attribs ( ) const
inline

◆ colSpan()

uint32_t DocHtmlCell::colSpan ( ) const

Definition at line 1811 of file docnode.cpp.

1812{
1813 for (const auto &attr : attribs())
1814 {
1815 if (attr.name.lower()=="colspan")
1816 {
1817 return std::max(1u,attr.value.toUInt());
1818 }
1819 }
1820 return 1;
1821}

References attribs().

Referenced by DocHtmlTable::computeTableGrid(), and LatexDocVisitor::operator()().

◆ columnIndex()

uint32_t DocHtmlCell::columnIndex ( ) const
inline

Definition at line 1203 of file docnode.h.

1203{ return m_colIdx; }
uint32_t m_colIdx
Definition docnode.h:1217

References m_colIdx.

Referenced by LatexDocVisitor::operator()().

◆ isFirst()

bool DocHtmlCell::isFirst ( ) const
inline

Definition at line 1195 of file docnode.h.

1195{ return m_isFirst; }
bool m_isFirst
Definition docnode.h:1213

References m_isFirst.

Referenced by parse(), and parseXml().

◆ isHeading()

◆ isLast()

bool DocHtmlCell::isLast ( ) const
inline

Definition at line 1196 of file docnode.h.

1196{ return m_isLast; }
bool m_isLast
Definition docnode.h:1214

References m_isLast.

Referenced by LatexDocVisitor::operator()().

◆ markFirst()

void DocHtmlCell::markFirst ( bool v = TRUE)
inline

Definition at line 1197 of file docnode.h.

1197{ m_isFirst=v; }

References m_isFirst, and TRUE.

Referenced by DocHtmlRow::parse(), and DocHtmlRow::parseXml().

◆ markLast()

void DocHtmlCell::markLast ( bool v = TRUE)
inline

Definition at line 1198 of file docnode.h.

1198{ m_isLast=v; }

References m_isLast, and TRUE.

Referenced by DocHtmlRow::parse(), and DocHtmlRow::parseXml().

◆ parse()

Token DocHtmlCell::parse ( )

Definition at line 1731 of file docnode.cpp.

1732{
1733 AUTO_TRACE();
1734 Token retval = Token::make_RetVal_OK();
1735 auto ns = AutoNodeStack(parser(),thisVariant());
1736
1737 // parse one or more paragraphs
1738 bool isFirst=TRUE;
1739 DocPara *par=nullptr;
1740 do
1741 {
1742 children().append<DocPara>(parser(),thisVariant());
1743 par = children().get_last<DocPara>();
1744 if (isFirst) { par->markFirst(); isFirst=FALSE; }
1745 retval=par->parse();
1746 if (retval.is(TokenRetval::TK_HTMLTAG))
1747 {
1748 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
1749 if (tagId==HtmlTagType::HTML_TD && parser()->context.token->endTag) // found </td> tag
1750 {
1751 retval = Token::make_TK_NEWPARA(); // ignore the tag
1752 }
1753 else if (tagId==HtmlTagType::HTML_TH && parser()->context.token->endTag) // found </th> tag
1754 {
1755 retval = Token::make_TK_NEWPARA(); // ignore the tag
1756 }
1757 }
1758 }
1759 while (retval.is_any_of(TokenRetval::TK_NEWPARA,TokenRetval::RetVal_EndParBlock));
1760 if (par) par->markLast();
1761
1762 return retval;
1763}
DocNodeList & children()
Definition docnode.h:142
bool isFirst() const
Definition docnode.h:1195
DocNodeVariant * thisVariant()
Definition docnode.h:92
void markLast(bool v=TRUE)
Definition docnode.h:1080
void markFirst(bool v=TRUE)
Definition docnode.h:1079
Token parse()
Definition docnode.cpp:5459
bool is(TokenRetval rv) const
bool is_any_of(ARGS... args) const
HtmlTagType
Definition cmdmapper.h:169
#define AUTO_TRACE(...)
Definition docnode.cpp:46
const Mapper< HtmlTagType > * htmlTagMapper
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
void append(Args &&... args)
Append a new DocNodeVariant to the list by constructing it with type T and parameters Args.
Definition docnode.h:1393
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1404

References DocNodeList::append(), AUTO_TRACE, DocCompoundNode::children(), FALSE, DocNodeList::get_last(), HTML_TD, HTML_TH, Mappers::htmlTagMapper, Token::is(), Token::is_any_of(), isFirst(), DocPara::markFirst(), DocPara::markLast(), DocPara::parse(), DocNode::parser(), DocNode::thisVariant(), and TRUE.

Referenced by DocHtmlRow::parse().

◆ parseXml()

Token DocHtmlCell::parseXml ( )

Definition at line 1765 of file docnode.cpp.

1766{
1767 AUTO_TRACE();
1768 Token retval = Token::make_RetVal_OK();
1769 auto ns = AutoNodeStack(parser(),thisVariant());
1770
1771 // parse one or more paragraphs
1772 bool isFirst=TRUE;
1773 DocPara *par=nullptr;
1774 do
1775 {
1776 children().append<DocPara>(parser(),thisVariant());
1777 par = children().get_last<DocPara>();
1778 if (isFirst) { par->markFirst(); isFirst=FALSE; }
1779 retval=par->parse();
1780 if (retval.is(TokenRetval::TK_HTMLTAG))
1781 {
1782 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
1783 if (tagId==HtmlTagType::XML_ITEM && parser()->context.token->endTag) // found </item> tag
1784 {
1785 retval = Token::make_TK_NEWPARA(); // ignore the tag
1786 }
1787 else if (tagId==HtmlTagType::XML_DESCRIPTION && parser()->context.token->endTag) // found </description> tag
1788 {
1789 retval = Token::make_TK_NEWPARA(); // ignore the tag
1790 }
1791 }
1792 }
1793 while (retval.is(TokenRetval::TK_NEWPARA));
1794 if (par) par->markLast();
1795
1796 return retval;
1797}

References DocNodeList::append(), AUTO_TRACE, DocCompoundNode::children(), FALSE, DocNodeList::get_last(), Mappers::htmlTagMapper, Token::is(), isFirst(), DocPara::markFirst(), DocPara::markLast(), DocPara::parse(), DocNode::parser(), DocNode::thisVariant(), TRUE, XML_DESCRIPTION, and XML_ITEM.

Referenced by DocHtmlRow::parseXml().

◆ rowIndex()

uint32_t DocHtmlCell::rowIndex ( ) const
inline

Definition at line 1202 of file docnode.h.

1202{ return m_rowIdx; }
uint32_t m_rowIdx
Definition docnode.h:1216

References m_rowIdx.

◆ rowSpan()

uint32_t DocHtmlCell::rowSpan ( ) const

Definition at line 1799 of file docnode.cpp.

1800{
1801 for (const auto &attr : attribs())
1802 {
1803 if (attr.name.lower()=="rowspan")
1804 {
1805 return attr.value.toUInt();
1806 }
1807 }
1808 return 0;
1809}

References attribs().

Referenced by DocHtmlTable::computeTableGrid(), and LatexDocVisitor::operator()().

◆ setColumnIndex()

void DocHtmlCell::setColumnIndex ( uint32_t idx)
inlineprivate

Definition at line 1211 of file docnode.h.

1211{ m_colIdx = idx; }

References m_colIdx.

Referenced by DocHtmlTable::computeTableGrid().

◆ setRowIndex()

void DocHtmlCell::setRowIndex ( uint32_t idx)
inlineprivate

Definition at line 1210 of file docnode.h.

1210{ m_rowIdx = idx; }

References m_rowIdx.

Referenced by DocHtmlTable::computeTableGrid().

◆ valignment()

DocHtmlCell::Valignment DocHtmlCell::valignment ( ) const

Definition at line 1861 of file docnode.cpp.

1862{
1863 for (const auto &attr : attribs())
1864 {
1865 QCString attrName = attr.name.lower();
1866 QCString attrValue = attr.value.lower();
1867 if (attrName=="valign")
1868 {
1869 if (attrValue=="top")
1870 return Top;
1871 else if (attrValue=="bottom")
1872 return Bottom;
1873 else if (attrValue=="middle")
1874 return Middle;
1875 else return Middle;
1876 }
1877 }
1878 return Middle;
1879}

References attribs(), Bottom, QCString::lower(), Middle, and Top.

Referenced by LatexDocVisitor::operator()().

Friends And Related Symbol Documentation

◆ DocHtmlTable

friend class DocHtmlTable
friend

Definition at line 1188 of file docnode.h.

References DocHtmlTable.

Referenced by DocHtmlTable.

Member Data Documentation

◆ m_attribs

HtmlAttribList DocHtmlCell::m_attribs
private

Definition at line 1215 of file docnode.h.

Referenced by attribs(), and DocHtmlCell().

◆ m_colIdx

uint32_t DocHtmlCell::m_colIdx = static_cast<uint32_t>(-1)
private

Definition at line 1217 of file docnode.h.

Referenced by columnIndex(), and setColumnIndex().

◆ m_isFirst

bool DocHtmlCell::m_isFirst = false
private

Definition at line 1213 of file docnode.h.

Referenced by isFirst(), and markFirst().

◆ m_isHeading

bool DocHtmlCell::m_isHeading = false
private

Definition at line 1212 of file docnode.h.

Referenced by DocHtmlCell(), and isHeading().

◆ m_isLast

bool DocHtmlCell::m_isLast = false
private

Definition at line 1214 of file docnode.h.

Referenced by isLast(), and markLast().

◆ m_rowIdx

uint32_t DocHtmlCell::m_rowIdx = static_cast<uint32_t>(-1)
private

Definition at line 1216 of file docnode.h.

Referenced by rowIndex(), and setRowIndex().


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