My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DocHtmlTable Class Reference

#include <docparser.h>

Inheritance diagram for DocHtmlTable:
CompAccept< DocHtmlTable > DocNode

Public Member Functions

 DocHtmlTable (DocNode *parent, const HtmlAttribList &attribs)
 
 ~DocHtmlTable ()
 
Kind kind () const
 
uint numRows () const
 
bool hasCaption ()
 
const HtmlAttribListattribs () const
 
int parse ()
 
int parseXml ()
 
uint numColumns () const
 
void accept (DocVisitor *v)
 
DocHtmlCaptioncaption () const
 
DocHtmlRowfirstRow () const
 
- Public Member Functions inherited from CompAccept< DocHtmlTable >
 CompAccept ()
 
virtual ~CompAccept ()
 
void accept (DocHtmlTable *obj, DocVisitor *v)
 
const QList< DocNode > & children () const
 
QList< DocNode > & children ()
 
- Public Member Functions inherited from DocNode
 DocNode ()
 
virtual ~DocNode ()
 
DocNodeparent () const
 
void setParent (DocNode *parent)
 
bool isPreformatted () const
 

Private Member Functions

void computeTableGrid ()
 

Private Attributes

DocHtmlCaptionm_caption
 
HtmlAttribList m_attribs
 
int m_numCols
 

Additional Inherited Members

- Public Types inherited from DocNode
enum  Kind {
  Kind_Root = 0, Kind_Word = 1, Kind_WhiteSpace = 2, Kind_Para = 3,
  Kind_AutoList = 4, Kind_AutoListItem = 5, Kind_Symbol = 6, Kind_URL = 7,
  Kind_StyleChange = 8, Kind_SimpleSect = 9, Kind_Title = 10, Kind_SimpleList = 11,
  Kind_SimpleListItem = 12, Kind_Section = 13, Kind_Verbatim = 14, Kind_XRefItem = 15,
  Kind_HtmlList = 16, Kind_HtmlListItem = 17, Kind_HtmlDescList = 18, Kind_HtmlDescData = 19,
  Kind_HtmlDescTitle = 20, Kind_HtmlTable = 21, Kind_HtmlRow = 22, Kind_HtmlCell = 23,
  Kind_HtmlCaption = 24, Kind_LineBreak = 25, Kind_HorRuler = 26, Kind_Anchor = 27,
  Kind_IndexEntry = 28, Kind_Internal = 29, Kind_HRef = 30, Kind_Include = 31,
  Kind_IncOperator = 32, Kind_HtmlHeader = 33, Kind_Image = 34, Kind_DotFile = 35,
  Kind_Link = 36, Kind_Ref = 37, Kind_Formula = 38, Kind_SecRefItem = 39,
  Kind_SecRefList = 40, Kind_SimpleSectSep = 41, Kind_LinkedWord = 42, Kind_ParamSect = 43,
  Kind_ParamList = 44, Kind_InternalRef = 45, Kind_Copy = 46, Kind_Text = 47,
  Kind_MscFile = 48, Kind_HtmlBlockQuote = 49, Kind_VhdlFlow = 50, Kind_ParBlock = 51,
  Kind_DiaFile = 52
}
 
- Protected Member Functions inherited from DocNode
void setInsidePreformatted (bool p)
 
- Protected Attributes inherited from CompAccept< DocHtmlTable >
QList< DocNodem_children
 
- Protected Attributes inherited from DocNode
DocNodem_parent
 

Detailed Description

Node representing a HTML table

Definition at line 1345 of file docparser.h.

Constructor & Destructor Documentation

DocHtmlTable::DocHtmlTable ( DocNode parent,
const HtmlAttribList attribs 
)
inline

Definition at line 1348 of file docparser.h.

References m_caption, DocNode::m_parent, and DocNode::parent().

: m_attribs(attribs) { m_caption=0; m_parent = parent; }
DocHtmlTable::~DocHtmlTable ( )
inline

Definition at line 1350 of file docparser.h.

References m_caption.

{ delete m_caption; }

Member Function Documentation

void DocHtmlTable::accept ( DocVisitor v)
virtual

Acceptor function for node visitors. Part of the visitor pattern.

Parameters
vAbstract visitor.

Implements DocNode.

Definition at line 3818 of file docparser.cpp.

References DocNode::accept(), DocHtmlCaption::accept(), m_caption, CompAccept< DocHtmlTable >::m_children, DocVisitor::visitPost(), and DocVisitor::visitPre().

{
v->visitPre(this);
// for HTML output we put the caption first
//if (m_caption && v->id()==DocVisitor_Html) m_caption->accept(v);
// doxygen 1.8.11: always put the caption first
QListIterator<DocNode> cli(m_children);
DocNode *n;
for (cli.toFirst();(n=cli.current());++cli) n->accept(v);
// for other output formats we put the caption last
//if (m_caption && v->id()!=DocVisitor_Html) m_caption->accept(v);
v->visitPost(this);
}
const HtmlAttribList& DocHtmlTable::attribs ( ) const
inline

Definition at line 1354 of file docparser.h.

References m_attribs.

Referenced by HtmlDocVisitor::visitPre().

{ return m_attribs; }
DocHtmlCaption* DocHtmlTable::caption ( ) const
inline

Definition at line 1359 of file docparser.h.

References m_caption.

Referenced by HtmlDocVisitor::visitPre(), and LatexDocVisitor::visitPre().

{ return m_caption; }
void DocHtmlTable::computeTableGrid ( )
private

determines the location of all cells in a grid, resolving row and column spans. For each the total number of visible cells is computed, and the total number of visible columns over all rows is stored.

Definition at line 3761 of file docparser.cpp.

References CompAccept< DocHtmlTable >::children(), CompAccept< T >::children(), DocHtmlCell::colSpan(), DocNode::kind(), DocNode::Kind_HtmlCell, DocNode::Kind_HtmlRow, m_numCols, DocHtmlCell::rowSpan(), DocHtmlCell::setColumnIndex(), DocHtmlCell::setRowIndex(), DocHtmlRow::setRowIndex(), and DocHtmlRow::setVisibleCells().

Referenced by parse(), and parseXml().

{
//printf("computeTableGrid()\n");
RowSpanList rowSpans;
rowSpans.setAutoDelete(TRUE);
int maxCols=0;
int rowIdx=1;
QListIterator<DocNode> li(children());
DocNode *rowNode;
for (li.toFirst();(rowNode=li.current());++li)
{
int colIdx=1;
int cells=0;
if (rowNode->kind()==DocNode::Kind_HtmlRow)
{
uint i;
DocHtmlRow *row = (DocHtmlRow*)rowNode;
QListIterator<DocNode> rli(row->children());
DocNode *cellNode;
for (rli.toFirst();(cellNode=rli.current());++rli)
{
if (cellNode->kind()==DocNode::Kind_HtmlCell)
{
DocHtmlCell *cell = (DocHtmlCell*)cellNode;
int rs = cell->rowSpan();
int cs = cell->colSpan();
for (i=0;i<rowSpans.count();i++)
{
if (rowSpans.at(i)->rowsLeft>0 &&
rowSpans.at(i)->column==colIdx)
{
colIdx=rowSpans.at(i)->column+1;
cells++;
}
}
if (rs>0) rowSpans.append(new ActiveRowSpan(rs,colIdx));
//printf("found cell at (%d,%d)\n",rowIdx,colIdx);
cell->setRowIndex(rowIdx);
cell->setColumnIndex(colIdx);
colIdx+=cs;
cells++;
}
}
for (i=0;i<rowSpans.count();i++)
{
if (rowSpans.at(i)->rowsLeft>0) rowSpans.at(i)->rowsLeft--;
}
row->setVisibleCells(cells);
row->setRowIndex(rowIdx);
rowIdx++;
}
if (colIdx-1>maxCols) maxCols=colIdx-1;
}
m_numCols = maxCols;
}
DocHtmlRow* DocHtmlTable::firstRow ( ) const
inline

Definition at line 1360 of file docparser.h.

References DocNode::kind(), DocNode::Kind_HtmlRow, and CompAccept< DocHtmlTable >::m_children.

Referenced by LatexDocVisitor::visitPre().

{
DocNode *n = m_children.getFirst();
if (n && n->kind()==Kind_HtmlRow) return (DocHtmlRow*)n;
return 0;
}
bool DocHtmlTable::hasCaption ( )
inline

Definition at line 1353 of file docparser.h.

References m_caption.

Referenced by HtmlDocVisitor::visitPre(), and LatexDocVisitor::visitPre().

{ return m_caption!=0; }
Kind DocHtmlTable::kind ( ) const
inlinevirtual

Returns the kind of node. Provides runtime type information

Implements DocNode.

Definition at line 1351 of file docparser.h.

References DocNode::Kind_HtmlTable.

{ return Kind_HtmlTable; }
uint DocHtmlTable::numColumns ( ) const
inline
uint DocHtmlTable::numRows ( ) const
inline

Definition at line 1352 of file docparser.h.

References CompAccept< DocHtmlTable >::m_children.

Referenced by XmlDocVisitor::visitPre(), and PrintDocVisitor::visitPre().

{ return m_children.count(); }
int DocHtmlTable::parse ( )

Definition at line 3631 of file docparser.cpp.

References TokenInfo::attribs, computeTableGrid(), DBG, doctokenizerYYlex(), doctokenizerYYlineno, TokenInfo::endTag, g_fileName, g_nodeStack, g_token, HTML_CAPTION, HTML_TR, Mappers::htmlTagMapper, m_caption, CompAccept< DocHtmlTable >::m_children, Mapper::map(), TokenInfo::name, DocHtmlCaption::parse(), DocHtmlRow::parse(), RetVal_EndTable, RetVal_OK, RetVal_TableRow, TK_HTMLTAG, TK_NEWPARA, TK_WHITESPACE, tokToString(), and warn_doc_error().

Referenced by DocPara::handleHtmlStartTag().

{
int retval=RetVal_OK;
g_nodeStack.push(this);
DBG(("DocHtmlTable::parse() start\n"));
getrow:
// get next token
int tok=doctokenizerYYlex();
// skip whitespace
while (tok==TK_WHITESPACE || tok==TK_NEWPARA) tok=doctokenizerYYlex();
// should find a html tag now
if (tok==TK_HTMLTAG)
{
if (tagId==HTML_TR && !g_token->endTag) // found <tr> tag
{
// no caption, just rows
}
else if (tagId==HTML_CAPTION && !g_token->endTag) // found <caption> tag
{
if (m_caption)
{
warn_doc_error(g_fileName,doctokenizerYYlineno,"table already has a caption, found another one");
}
else
{
retval=m_caption->parse();
if (retval==RetVal_OK) // caption was parsed ok
{
goto getrow;
}
}
}
else // found wrong token
{
warn_doc_error(g_fileName,doctokenizerYYlineno,"expected <tr> or <caption> tag but "
"found <%s%s> instead!", g_token->endTag ? "/" : "", qPrint(g_token->name));
}
}
else if (tok==0) // premature end of comment
{
warn_doc_error(g_fileName,doctokenizerYYlineno,"unexpected end of comment while looking"
" for a <tr> or <caption> tag");
}
else // token other than html token
{
warn_doc_error(g_fileName,doctokenizerYYlineno,"expected <tr> tag but found %s token instead!",
tokToString(tok));
}
// parse one or more rows
while (retval==RetVal_TableRow)
{
m_children.append(tr);
retval=tr->parse();
}
DBG(("DocHtmlTable::parse() end\n"));
DocNode *n=g_nodeStack.pop();
ASSERT(n==this);
return retval==RetVal_EndTable ? RetVal_OK : retval;
}
int DocHtmlTable::parseXml ( )

Definition at line 3701 of file docparser.cpp.

References TokenInfo::attribs, computeTableGrid(), DBG, doctokenizerYYlex(), TokenInfo::endTag, g_nodeStack, g_token, Mappers::htmlTagMapper, CompAccept< DocHtmlTable >::m_children, Mapper::map(), TokenInfo::name, DocHtmlRow::parseXml(), RetVal_OK, RetVal_TableRow, TK_HTMLTAG, TK_NEWPARA, TK_WHITESPACE, XML_ITEM, XML_LIST, and XML_LISTHEADER.

Referenced by DocPara::handleHtmlStartTag().

{
int retval=RetVal_OK;
g_nodeStack.push(this);
DBG(("DocHtmlTable::parseXml() start\n"));
// get next token
int tok=doctokenizerYYlex();
// skip whitespace
while (tok==TK_WHITESPACE || tok==TK_NEWPARA) tok=doctokenizerYYlex();
// should find a html tag now
int tagId=0;
bool isHeader=FALSE;
if (tok==TK_HTMLTAG)
{
if (tagId==XML_ITEM && !g_token->endTag) // found <item> tag
{
}
if (tagId==XML_LISTHEADER && !g_token->endTag) // found <listheader> tag
{
isHeader=TRUE;
}
}
// parse one or more rows
while (retval==RetVal_TableRow)
{
m_children.append(tr);
retval=tr->parseXml(isHeader);
isHeader=FALSE;
}
DBG(("DocHtmlTable::parseXml() end\n"));
DocNode *n=g_nodeStack.pop();
ASSERT(n==this);
return tagId==XML_LIST && g_token->endTag ? RetVal_OK : retval;
}

Member Data Documentation

HtmlAttribList DocHtmlTable::m_attribs
private

Definition at line 1369 of file docparser.h.

Referenced by attribs().

DocHtmlCaption* DocHtmlTable::m_caption
private

Definition at line 1368 of file docparser.h.

Referenced by accept(), caption(), DocHtmlTable(), hasCaption(), parse(), and ~DocHtmlTable().

int DocHtmlTable::m_numCols
private

Definition at line 1370 of file docparser.h.

Referenced by computeTableGrid(), and numColumns().


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