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

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 ,
  Requirement
}
Protected Member Functions inherited from DocNode
void setInsidePreformatted (bool p)

Detailed Description

Node representing a HTML table cell.

Definition at line 1197 of file docnode.h.

Member Enumeration Documentation

◆ Alignment

Enumerator
Left 
Right 
Center 

Definition at line 1201 of file docnode.h.

◆ Valignment

Enumerator
Top 
Middle 
Bottom 

Definition at line 1202 of file docnode.h.

Constructor & Destructor Documentation

◆ DocHtmlCell()

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

Definition at line 1203 of file docnode.h.

1203 :
DocCompoundNode(DocParser *parser, DocNodeVariant *parent)
Definition docnode.h:141
bool isHeading() const
Definition docnode.h:1205
const HtmlAttribList & attribs() const
Definition docnode.h:1210
HtmlAttribList m_attribs
Definition docnode.h:1226
bool m_isHeading
Definition docnode.h:1223
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 2026 of file docnode.cpp.

2027{
2028 for (const auto &attr : attribs())
2029 {
2030 DString attrName = attr.name.lower();
2031 DString attrValue = attr.value.lower();
2032 if (attrName=="align")
2033 {
2034 if (attrValue=="center")
2035 return Center;
2036 else if (attrValue=="right")
2037 return Right;
2038 else return Left;
2039 }
2040 else if (attrName=="class" && attrValue.startsWith("markdowntable"))
2041 {
2042 if (attrValue=="markdowntableheadcenter")
2043 return Center;
2044 else if (attrValue=="markdowntableheadright")
2045 return Right;
2046 else if (attrValue=="markdowntableheadleft")
2047 return Left;
2048 else if (attrValue=="markdowntableheadnone")
2049 return Center;
2050 else if (attrValue=="markdowntablebodycenter")
2051 return Center;
2052 else if (attrValue=="markdowntablebodyright")
2053 return Right;
2054 else if (attrValue=="markdowntablebodyleft")
2055 return Left;
2056 else if (attrValue=="markdowntablebodynone")
2057 return Left;
2058 else return Left;
2059 }
2060 }
2061 return Left;
2062}
bool startsWith(const char *s) const
Definition dstring.h:600

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

Referenced by LatexDocVisitor::operator()().

◆ attribs()

const HtmlAttribList & DocHtmlCell::attribs ( ) const
inline

◆ colSpan()

uint32_t DocHtmlCell::colSpan ( ) const

Definition at line 2014 of file docnode.cpp.

2015{
2016 for (const auto &attr : attribs())
2017 {
2018 if (attr.name.lower()=="colspan")
2019 {
2020 return std::max(1u,attr.value.toUInt());
2021 }
2022 }
2023 return 1;
2024}

References attribs().

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

◆ columnIndex()

uint32_t DocHtmlCell::columnIndex ( ) const
inline

Definition at line 1214 of file docnode.h.

1214{ return m_colIdx; }
uint32_t m_colIdx
Definition docnode.h:1228

References m_colIdx.

◆ isFirst()

bool DocHtmlCell::isFirst ( ) const
inline

Definition at line 1206 of file docnode.h.

1206{ return m_isFirst; }
bool m_isFirst
Definition docnode.h:1224

References m_isFirst.

Referenced by parse(), and parseXml().

◆ isHeading()

◆ isLast()

bool DocHtmlCell::isLast ( ) const
inline

Definition at line 1207 of file docnode.h.

1207{ return m_isLast; }
bool m_isLast
Definition docnode.h:1225

References m_isLast.

Referenced by LatexDocVisitor::operator()().

◆ markFirst()

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

Definition at line 1208 of file docnode.h.

1208{ m_isFirst=v; }

References m_isFirst.

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

◆ markLast()

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

Definition at line 1209 of file docnode.h.

1209{ m_isLast=v; }

References m_isLast.

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

◆ parse()

Token DocHtmlCell::parse ( )

Definition at line 1934 of file docnode.cpp.

1935{
1936 AUTO_TRACE();
1937 Token retval = Token::make_RetVal_OK();
1938 auto ns = AutoNodeStack(parser(),thisVariant());
1939
1940 // parse one or more paragraphs
1941 bool isFirst=true;
1942 DocPara *par=nullptr;
1943 do
1944 {
1945 children().append<DocPara>(parser(),thisVariant());
1946 par = children().get_last<DocPara>();
1947 if (isFirst) { par->markFirst(); isFirst=false; }
1948 retval=par->parse();
1949 if (retval.is(TokenRetval::TK_HTMLTAG))
1950 {
1951 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
1952 if (tagId==HtmlTagType::HTML_TD && parser()->context.token->endTag) // found </td> tag
1953 {
1954 retval = Token::make_TK_NEWPARA(); // ignore the tag
1955 }
1956 else if (tagId==HtmlTagType::HTML_TH && parser()->context.token->endTag) // found </th> tag
1957 {
1958 retval = Token::make_TK_NEWPARA(); // ignore the tag
1959 }
1960 }
1961 }
1962 while (retval.is_any_of(TokenRetval::TK_NEWPARA,TokenRetval::RetVal_EndParBlock));
1963 if (par) par->markLast();
1964
1965 return retval;
1966}
DocNodeList & children()
Definition docnode.h:143
bool isFirst() const
Definition docnode.h:1206
DocNodeVariant * thisVariant()
Definition docnode.h:92
void append(Args &&... args)
Append a new DocNodeVariant to the list by constructing it with type T and parameters Args.
Definition docnode.h:1404
T * get_last()
Returns a pointer to the last element in the list if that element exists and holds a T,...
Definition docnode.h:1415
void markFirst(bool v=true)
Definition docnode.h:1094
Token parse()
Definition docnode.cpp:5769
void markLast(bool v=true)
Definition docnode.h:1095
bool is(TokenRetval rv) const
bool is_any_of(ARGS... args) const
HtmlTagType
Definition cmdmapper.h:174
#define AUTO_TRACE(...)
Definition docnode.cpp:53
const Mapper< HtmlTagType > * htmlTagMapper

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

Referenced by DocHtmlRow::parse().

◆ parseXml()

Token DocHtmlCell::parseXml ( )

Definition at line 1968 of file docnode.cpp.

1969{
1970 AUTO_TRACE();
1971 Token retval = Token::make_RetVal_OK();
1972 auto ns = AutoNodeStack(parser(),thisVariant());
1973
1974 // parse one or more paragraphs
1975 bool isFirst=true;
1976 DocPara *par=nullptr;
1977 do
1978 {
1979 children().append<DocPara>(parser(),thisVariant());
1980 par = children().get_last<DocPara>();
1981 if (isFirst) { par->markFirst(); isFirst=false; }
1982 retval=par->parse();
1983 if (retval.is(TokenRetval::TK_HTMLTAG))
1984 {
1985 HtmlTagType tagId=Mappers::htmlTagMapper->map(parser()->context.token->name);
1986 if (tagId==HtmlTagType::XML_ITEM && parser()->context.token->endTag) // found </item> tag
1987 {
1988 retval = Token::make_TK_NEWPARA(); // ignore the tag
1989 }
1990 else if (tagId==HtmlTagType::XML_DESCRIPTION && parser()->context.token->endTag) // found </description> tag
1991 {
1992 retval = Token::make_TK_NEWPARA(); // ignore the tag
1993 }
1994 }
1995 }
1996 while (retval.is(TokenRetval::TK_NEWPARA));
1997 if (par) par->markLast();
1998
1999 return retval;
2000}

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

Referenced by DocHtmlRow::parseXml().

◆ rowIndex()

uint32_t DocHtmlCell::rowIndex ( ) const
inline

Definition at line 1213 of file docnode.h.

1213{ return m_rowIdx; }
uint32_t m_rowIdx
Definition docnode.h:1227

References m_rowIdx.

◆ rowSpan()

uint32_t DocHtmlCell::rowSpan ( ) const

Definition at line 2002 of file docnode.cpp.

2003{
2004 for (const auto &attr : attribs())
2005 {
2006 if (attr.name.lower()=="rowspan")
2007 {
2008 return attr.value.toUInt();
2009 }
2010 }
2011 return 0;
2012}

References attribs().

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

◆ setColumnIndex()

void DocHtmlCell::setColumnIndex ( uint32_t idx)
inlineprivate

Definition at line 1222 of file docnode.h.

1222{ m_colIdx = idx; }

References m_colIdx.

Referenced by DocHtmlTable::computeTableGrid().

◆ setRowIndex()

void DocHtmlCell::setRowIndex ( uint32_t idx)
inlineprivate

Definition at line 1221 of file docnode.h.

1221{ m_rowIdx = idx; }

References m_rowIdx.

Referenced by DocHtmlTable::computeTableGrid().

◆ valignment()

DocHtmlCell::Valignment DocHtmlCell::valignment ( ) const

Definition at line 2064 of file docnode.cpp.

2065{
2066 for (const auto &attr : attribs())
2067 {
2068 DString attrName = attr.name.lower();
2069 DString attrValue = attr.value.lower();
2070 if (attrName=="valign")
2071 {
2072 if (attrValue=="top")
2073 return Top;
2074 else if (attrValue=="bottom")
2075 return Bottom;
2076 else if (attrValue=="middle")
2077 return Middle;
2078 else return Middle;
2079 }
2080 }
2081 return Middle;
2082}

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

Referenced by LatexDocVisitor::operator()().

◆ DocHtmlTable

friend class DocHtmlTable
friend

Definition at line 1199 of file docnode.h.

References DocHtmlTable.

Referenced by DocHtmlTable.

Member Data Documentation

◆ m_attribs

HtmlAttribList DocHtmlCell::m_attribs
private

Definition at line 1226 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 1228 of file docnode.h.

Referenced by columnIndex(), and setColumnIndex().

◆ m_isFirst

bool DocHtmlCell::m_isFirst = false
private

Definition at line 1224 of file docnode.h.

Referenced by isFirst(), and markFirst().

◆ m_isHeading

bool DocHtmlCell::m_isHeading = false
private

Definition at line 1223 of file docnode.h.

Referenced by DocHtmlCell(), and isHeading().

◆ m_isLast

bool DocHtmlCell::m_isLast = false
private

Definition at line 1225 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 1227 of file docnode.h.

Referenced by rowIndex(), and setRowIndex().


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