Skip to main content

The DocHtmlRow Class Reference

Node representing a HTML table row. More...

Declaration

class DocHtmlRow { ... }

Included Headers

#include <src/docnode.h>

Base class

classDocCompoundNode

Base class for nodes with children. More...

Friends Index

classDocHtmlTable

Public Constructors Index

DocHtmlRow (DocParser *parser, DocNodeVariant *parent, const HtmlAttribList &attribs)

Public Member Functions Index

size_tnumCells () const
const HtmlAttribList &attribs () const
Tokenparse ()
TokenparseXml (bool header)
boolisHeading () const
voidsetVisibleCells (uint32_t n)
uint32_tvisibleCells () const
uint32_trowIndex () const

Private Member Functions Index

voidsetRowIndex (uint32_t idx)

Private Member Attributes Index

HtmlAttribListm_attribs
uint32_tm_visibleCells = 0
uint32_tm_rowIdx = static_cast<uint32_t>(-1)

Description

Node representing a HTML table row.

Definition at line 1245 of file docnode.h.

Friends

DocHtmlTable

friend class DocHtmlTable

Definition at line 1247 of file docnode.h.

1247 friend class DocHtmlTable;

Reference DocHtmlTable.

Referenced by DocHtmlTable.

Public Constructors

DocHtmlRow()

DocHtmlRow::DocHtmlRow (DocParser * parser, DocNodeVariant * parent, const HtmlAttribList & attribs)
inline

Public Member Functions

attribs()

const HtmlAttribList & DocHtmlRow::attribs ()
inline

Definition at line 1252 of file docnode.h.

1252 const HtmlAttribList &attribs() const { return m_attribs; }

Reference m_attribs.

Referenced by DocHtmlRow, DocbookDocVisitor::operator() and HtmlDocVisitor::operator().

isHeading()

bool DocHtmlRow::isHeading ()

Declaration at line 1255 of file docnode.h, definition at line 1922 of file docnode.cpp.

1923{ // a row is a table heading if all cells are marked as such
1924 bool heading=TRUE;
1925 for (const auto &n : children())
1926 {
1927 const DocHtmlCell *cell = std::get_if<DocHtmlCell>(&n);
1928 if (cell && !cell->isHeading())
1929 {
1930 heading = FALSE;
1931 break;
1932 }
1933 }
1934 return !children().empty() && heading;
1935}

References DocCompoundNode::children, GrowVector< T >::empty, FALSE, DocHtmlCell::isHeading and TRUE.

Referenced by DocbookDocVisitor::operator(), LatexDocVisitor::operator(), RTFDocVisitor::operator(), parse and parseXml.

numCells()

size_t DocHtmlRow::numCells ()
inline

Definition at line 1251 of file docnode.h.

1251 size_t numCells() const { return children().size(); }

References DocCompoundNode::children and GrowVector< T >::size.

Referenced by RTFDocVisitor::operator().

parse()

Token DocHtmlRow::parse ()

Declaration at line 1253 of file docnode.h, definition at line 1937 of file docnode.cpp.

1938{
1939 AUTO_TRACE();
1940 Token retval = Token::make_RetVal_OK();
1941 auto ns = AutoNodeStack(parser(),thisVariant());
1942
1943 bool isHeading=FALSE;
1944 bool isFirst=TRUE;
1945 DocHtmlCell *cell=nullptr;
1946
1947 // get next token
1948 Token tok=parser()->tokenizer.lex();
1949 // skip whitespace
1950 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
1951 // should find a html tag now
1952 if (tok.is(TokenRetval::TK_HTMLTAG))
1953 {
1954 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
1955 if (tagId==HtmlTagType::HTML_TD && !parser()->context.token->endTag) // found <td> tag
1956 {
1957 }
1958 else if (tagId==HtmlTagType::HTML_TH && !parser()->context.token->endTag) // found <th> tag
1959 {
1961 }
1962 else // found some other tag
1963 {
1964 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td> or <th> tag but "
1965 "found <{}{}> instead!",parser()->context.token->endTag ? "/" : "", parser()->context.token->name);
1966 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
1967 goto endrow;
1968 }
1969 }
1970 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
1971 {
1972 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
1973 " for a html description title");
1974 goto endrow;
1975 }
1976 else // token other than html token
1977 {
1978 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td> or <th> tag but found {} token instead!",
1979 tok.to_string());
1980 goto endrow;
1981 }
1982
1983 // parse one or more cells
1984 do
1985 {
1988 isHeading);
1989 cell = children().get_last<DocHtmlCell>();
1990 cell->markFirst(isFirst);
1991 isFirst=FALSE;
1992 retval=cell->parse();
1993 isHeading = retval.is(TokenRetval::RetVal_TableHCell);
1994 //printf("DocHtmlRow:retval=%s\n",retval.to_string());
1995 if (retval.is(TokenRetval::RetVal_EndTableCell))
1996 {
1997 // get next token
1998 retval=parser()->tokenizer.lex();
1999 // skip whitespace after </td> or </th>
2000 while (retval.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) retval=parser()->tokenizer.lex();
2001 //printf("DocHtmlRow:retval= next=%s name=%s endTag=%d\n",retval.to_string(),qPrint(parser()->context.token->name),parser()->context.token->endTag);
2002 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2003 if (tok.is(TokenRetval::TK_HTMLTAG))
2004 {
2005 if ((tagId==HtmlTagType::HTML_TD || tagId==HtmlTagType::HTML_TH) &&
2006 !parser()->context.token->endTag) // found new <td> or <td> tag
2007 {
2008 retval = Token::make_RetVal_TableCell();
2010 }
2011 else if (tagId==HtmlTagType::HTML_TR)
2012 {
2013 if (parser()->context.token->endTag) // found </tr> tag
2014 {
2015 retval = Token::make_RetVal_EndTableRow();
2016 }
2017 else // found <tr> tag
2018 {
2019 retval = Token::make_RetVal_TableRow();
2020 }
2021 }
2022 else if (tagId==HtmlTagType::HTML_TABLE && parser()->context.token->endTag) // found </table>
2023 {
2024 retval = Token::make_RetVal_EndTable();
2025 }
2026 else // found some other tag
2027 {
2028 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td>, <th> or <tr> tag but "
2029 "found <{}{}> instead!",parser()->context.token->endTag ? "/" : "", parser()->context.token->name);
2030 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2031 goto endrow;
2032 }
2033 }
2034 else // token other than html token
2035 {
2036 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td>, <th> or <tr> tag but found {} token instead!",
2037 tok.to_string());
2038 goto endrow;
2039 }
2040 }
2041 }
2042 while (retval.is_any_of(TokenRetval::RetVal_TableCell,TokenRetval::RetVal_TableHCell));
2043 cell->markLast(TRUE);
2044
2045endrow:
2046 return retval;
2047}

References DocNodeList::append, TokenInfo::attribs, AUTO_TRACE, DocCompoundNode::children, DocParser::context, FALSE, DocNodeList::get_last, HTML_TABLE, HTML_TD, HTML_TH, HTML_TR, Mappers::htmlTagMapper, Token::is, Token::is_any_of, isHeading, DocTokenizer::lex, DocHtmlCell::markFirst, DocHtmlCell::markLast, DocHtmlCell::parse, DocNode::parser, DocTokenizer::pushBackHtmlTag, DocNode::thisVariant, Token::to_string, DocParserContext::token, DocParser::tokenizer, TRUE and warn_doc_error.

parseXml()

Token DocHtmlRow::parseXml (bool header)

Declaration at line 1254 of file docnode.h, definition at line 2049 of file docnode.cpp.

2050{
2051 AUTO_TRACE();
2052 Token retval = Token::make_RetVal_OK();
2053 auto ns = AutoNodeStack(parser(),thisVariant());
2054
2055 bool isFirst=TRUE;
2056 DocHtmlCell *cell=nullptr;
2057
2058 // get next token
2059 Token tok=parser()->tokenizer.lex();
2060 // skip whitespace
2061 while (tok.is_any_of(TokenRetval::TK_WHITESPACE,TokenRetval::TK_NEWPARA)) tok=parser()->tokenizer.lex();
2062 // should find a html tag now
2063 if (tok.is(TokenRetval::TK_HTMLTAG))
2064 {
2065 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
2066 if (tagId==HtmlTagType::XML_TERM && !parser()->context.token->endTag) // found <term> tag
2067 {
2068 }
2069 else if (tagId==HtmlTagType::XML_DESCRIPTION && !parser()->context.token->endTag) // found <description> tag
2070 {
2071 }
2072 else // found some other tag
2073 {
2074 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <term> or <description> tag but "
2075 "found <{}> instead!",parser()->context.token->name);
2076 parser()->tokenizer.pushBackHtmlTag(parser()->context.token->name);
2077 goto endrow;
2078 }
2079 }
2080 else if (tok.is_any_of(TokenRetval::TK_NONE,TokenRetval::TK_EOF)) // premature end of comment
2081 {
2082 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected end of comment while looking"
2083 " for a html description title");
2084 goto endrow;
2085 }
2086 else // token other than html token
2087 {
2088 warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected <td> or <th> tag but found {} token instead!",
2089 tok.to_string());
2090 goto endrow;
2091 }
2092
2093 do
2094 {
2096 cell = children().get_last<DocHtmlCell>();
2097 cell->markFirst(isFirst);
2098 isFirst=FALSE;
2099 retval=cell->parseXml();
2100 }
2101 while (retval.is_any_of(TokenRetval::RetVal_TableCell,TokenRetval::RetVal_TableHCell));
2102 cell->markLast(TRUE);
2103
2104endrow:
2105 return retval;
2106}

References DocNodeList::append, TokenInfo::attribs, AUTO_TRACE, DocCompoundNode::children, DocParser::context, FALSE, DocNodeList::get_last, Mappers::htmlTagMapper, Token::is, Token::is_any_of, isHeading, DocTokenizer::lex, DocHtmlCell::markFirst, DocHtmlCell::markLast, DocNode::parser, DocHtmlCell::parseXml, DocTokenizer::pushBackHtmlTag, DocNode::thisVariant, Token::to_string, DocParserContext::token, DocParser::tokenizer, TRUE, warn_doc_error, XML_DESCRIPTION and XML_TERM.

rowIndex()

uint32_t DocHtmlRow::rowIndex ()
inline

Definition at line 1258 of file docnode.h.

1258 uint32_t rowIndex() const { return m_rowIdx; }

Reference m_rowIdx.

Referenced by LatexDocVisitor::operator().

setVisibleCells()

void DocHtmlRow::setVisibleCells (uint32_t n)
inline

Definition at line 1256 of file docnode.h.

1256 void setVisibleCells(uint32_t n) { m_visibleCells = n; }

Reference m_visibleCells.

Referenced by DocHtmlTable::computeTableGrid.

visibleCells()

uint32_t DocHtmlRow::visibleCells ()
inline

Definition at line 1257 of file docnode.h.

1257 uint32_t visibleCells() const { return m_visibleCells; }

Reference m_visibleCells.

Private Member Functions

setRowIndex()

void DocHtmlRow::setRowIndex (uint32_t idx)
inline

Definition at line 1261 of file docnode.h.

1261 void setRowIndex(uint32_t idx) { m_rowIdx = idx; }

Reference m_rowIdx.

Referenced by DocHtmlTable::computeTableGrid.

Private Member Attributes

m_attribs

HtmlAttribList DocHtmlRow::m_attribs

Definition at line 1262 of file docnode.h.

Referenced by attribs and DocHtmlRow.

m_rowIdx

uint32_t DocHtmlRow::m_rowIdx = static_cast<uint32_t>(-1)

Definition at line 1264 of file docnode.h.

1264 uint32_t m_rowIdx = static_cast<uint32_t>(-1);

Referenced by rowIndex and setRowIndex.

m_visibleCells

uint32_t DocHtmlRow::m_visibleCells = 0

Definition at line 1263 of file docnode.h.

1263 uint32_t m_visibleCells = 0;

Referenced by setVisibleCells and visibleCells.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.