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.

1349  : m_attribs(attribs) { m_caption=0; m_parent = parent; }
DocNode * parent() const
Definition: docparser.h:147
DocNode * m_parent
Definition: docparser.h:163
HtmlAttribList m_attribs
Definition: docparser.h:1369
DocHtmlCaption * m_caption
Definition: docparser.h:1368
DocHtmlTable::~DocHtmlTable ( )
inline

Definition at line 1350 of file docparser.h.

1350 { delete m_caption; }
DocHtmlCaption * m_caption
Definition: docparser.h:1368

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 3803 of file docparser.cpp.

3804 {
3805  v->visitPre(this);
3806  // for HTML output we put the caption first
3807  //if (m_caption && v->id()==DocVisitor_Html) m_caption->accept(v);
3808  // doxygen 1.8.11: always put the caption first
3809  if (m_caption) m_caption->accept(v);
3811  DocNode *n;
3812  for (cli.toFirst();(n=cli.current());++cli) n->accept(v);
3813  // for other output formats we put the caption last
3814  //if (m_caption && v->id()!=DocVisitor_Html) m_caption->accept(v);
3815  v->visitPost(this);
3816 }
QList< DocNode > m_children
Definition: docparser.h:189
def cli(ctx)
Definition: main.py:7
void accept(DocVisitor *v)
Definition: docparser.h:1293
std::void_t< T > n
virtual void visitPre(DocAutoList *)=0
virtual void visitPost(DocAutoList *)=0
DocHtmlCaption * m_caption
Definition: docparser.h:1368
virtual void accept(DocVisitor *v)=0
const HtmlAttribList& DocHtmlTable::attribs ( ) const
inline

Definition at line 1354 of file docparser.h.

1354 { return m_attribs; }
HtmlAttribList m_attribs
Definition: docparser.h:1369
DocHtmlCaption* DocHtmlTable::caption ( ) const
inline

Definition at line 1359 of file docparser.h.

1359 { return m_caption; }
DocHtmlCaption * m_caption
Definition: docparser.h:1368
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 3746 of file docparser.cpp.

3747 {
3748  //printf("computeTableGrid()\n");
3749  RowSpanList rowSpans;
3750  rowSpans.setAutoDelete(TRUE);
3751  int maxCols=0;
3752  int rowIdx=1;
3754  DocNode *rowNode;
3755  for (li.toFirst();(rowNode=li.current());++li)
3756  {
3757  int colIdx=1;
3758  int cells=0;
3759  if (rowNode->kind()==DocNode::Kind_HtmlRow)
3760  {
3761  uint i;
3762  DocHtmlRow *row = (DocHtmlRow*)rowNode;
3763  QListIterator<DocNode> rli(row->children());
3764  DocNode *cellNode;
3765  for (rli.toFirst();(cellNode=rli.current());++rli)
3766  {
3767  if (cellNode->kind()==DocNode::Kind_HtmlCell)
3768  {
3769  DocHtmlCell *cell = (DocHtmlCell*)cellNode;
3770  int rs = cell->rowSpan();
3771  int cs = cell->colSpan();
3772 
3773  for (i=0;i<rowSpans.count();i++)
3774  {
3775  if (rowSpans.at(i)->rowsLeft>0 &&
3776  rowSpans.at(i)->column==colIdx)
3777  {
3778  colIdx=rowSpans.at(i)->column+1;
3779  cells++;
3780  }
3781  }
3782  if (rs>0) rowSpans.append(new ActiveRowSpan(rs,colIdx));
3783  //printf("found cell at (%d,%d)\n",rowIdx,colIdx);
3784  cell->setRowIndex(rowIdx);
3785  cell->setColumnIndex(colIdx);
3786  colIdx+=cs;
3787  cells++;
3788  }
3789  }
3790  for (i=0;i<rowSpans.count();i++)
3791  {
3792  if (rowSpans.at(i)->rowsLeft>0) rowSpans.at(i)->rowsLeft--;
3793  }
3794  row->setVisibleCells(cells);
3795  row->setRowIndex(rowIdx);
3796  rowIdx++;
3797  }
3798  if (colIdx-1>maxCols) maxCols=colIdx-1;
3799  }
3800  m_numCols = maxCols;
3801 }
void setColumnIndex(int idx)
Definition: docparser.h:1278
void setRowIndex(int idx)
Definition: docparser.h:1277
void append(const type *d)
Definition: qlist.h:73
int rowSpan() const
Definition: docparser.cpp:3433
type * at(uint i) const
Definition: qlist.h:94
virtual Kind kind() const =0
uint count() const
Definition: qlist.h:66
int colSpan() const
Definition: docparser.cpp:3449
void setVisibleCells(int n)
Definition: docparser.h:1333
type * current() const
Definition: qlist.h:146
const char * cs
unsigned uint
Definition: qglobal.h:351
void setAutoDelete(bool enable)
Definition: qlist.h:99
const bool TRUE
Definition: qglobal.h:371
void setRowIndex(int idx)
Definition: docparser.h:1338
const QList< DocNode > & children() const
Definition: docparser.h:185
DocHtmlRow* DocHtmlTable::firstRow ( ) const
inline

Definition at line 1360 of file docparser.h.

1360  {
1362  if (n && n->kind()==Kind_HtmlRow) return (DocHtmlRow*)n;
1363  return 0;
1364  }
QList< DocNode > m_children
Definition: docparser.h:189
virtual Kind kind() const =0
std::void_t< T > n
type * getFirst() const
Definition: qlist.h:95
bool DocHtmlTable::hasCaption ( )
inline

Definition at line 1353 of file docparser.h.

1353 { return m_caption!=0; }
DocHtmlCaption * m_caption
Definition: docparser.h:1368
Kind DocHtmlTable::kind ( ) const
inlinevirtual

Returns the kind of node. Provides runtime type information

Implements DocNode.

Definition at line 1351 of file docparser.h.

uint DocHtmlTable::numColumns ( ) const
inline

Definition at line 1357 of file docparser.h.

1357 { return m_numCols; }
uint DocHtmlTable::numRows ( ) const
inline

Definition at line 1352 of file docparser.h.

1352 { return m_children.count(); }
QList< DocNode > m_children
Definition: docparser.h:189
uint count() const
Definition: qlist.h:66
int DocHtmlTable::parse ( )

Definition at line 3616 of file docparser.cpp.

3617 {
3618  int retval=RetVal_OK;
3619  g_nodeStack.push(this);
3620  DBG(("DocHtmlTable::parse() start\n"));
3621 
3622 getrow:
3623  // get next token
3624  int tok=doctokenizerYYlex();
3625  // skip whitespace
3626  while (tok==TK_WHITESPACE || tok==TK_NEWPARA) tok=doctokenizerYYlex();
3627  // should find a html tag now
3628  if (tok==TK_HTMLTAG)
3629  {
3630  int tagId=Mappers::htmlTagMapper->map(g_token->name);
3631  if (tagId==HTML_TR && !g_token->endTag) // found <tr> tag
3632  {
3633  // no caption, just rows
3634  retval=RetVal_TableRow;
3635  }
3636  else if (tagId==HTML_CAPTION && !g_token->endTag) // found <caption> tag
3637  {
3638  if (m_caption)
3639  {
3640  warn_doc_error(g_fileName,doctokenizerYYlineno,"table already has a caption, found another one");
3641  }
3642  else
3643  {
3644  m_caption = new DocHtmlCaption(this,g_token->attribs);
3645  retval=m_caption->parse();
3646 
3647  if (retval==RetVal_OK) // caption was parsed ok
3648  {
3649  goto getrow;
3650  }
3651  }
3652  }
3653  else // found wrong token
3654  {
3655  warn_doc_error(g_fileName,doctokenizerYYlineno,"expected <tr> or <caption> tag but "
3656  "found <%s%s> instead!", g_token->endTag ? "/" : "", qPrint(g_token->name));
3657  }
3658  }
3659  else if (tok==0) // premature end of comment
3660  {
3661  warn_doc_error(g_fileName,doctokenizerYYlineno,"unexpected end of comment while looking"
3662  " for a <tr> or <caption> tag");
3663  }
3664  else // token other than html token
3665  {
3666  warn_doc_error(g_fileName,doctokenizerYYlineno,"expected <tr> tag but found %s token instead!",
3667  tokToString(tok));
3668  }
3669 
3670  // parse one or more rows
3671  while (retval==RetVal_TableRow)
3672  {
3673  DocHtmlRow *tr=new DocHtmlRow(this,g_token->attribs);
3674  m_children.append(tr);
3675  retval=tr->parse();
3676  }
3677 
3678  computeTableGrid();
3679 
3680  DBG(("DocHtmlTable::parse() end\n"));
3681  DocNode *n=g_nodeStack.pop();
3682  ASSERT(n==this);
3683  return retval==RetVal_EndTable ? RetVal_OK : retval;
3684 }
static QCString g_fileName
Definition: docparser.cpp:95
QList< DocNode > m_children
Definition: docparser.h:189
void append(const type *d)
Definition: qlist.h:73
void computeTableGrid()
Definition: docparser.cpp:3746
#define DBG(x)
Definition: docparser.cpp:59
int doctokenizerYYlineno
void warn_doc_error(const char *file, int line, const char *fmt,...)
Definition: message.cpp:210
static Mapper * htmlTagMapper
Definition: cmdmapper.h:220
static QStack< DocNode > g_nodeStack
Definition: docparser.cpp:91
TokenInfo * g_token
int doctokenizerYYlex(void)
void push(const type *d)
Definition: qstack.h:58
std::void_t< T > n
int map(const char *n)
Definition: cmdmapper.cpp:225
type * pop()
Definition: qstack.h:59
HtmlAttribList attribs
Definition: doctokenizer.h:102
QCString name
Definition: doctokenizer.h:77
const char * tokToString(int token)
DocHtmlCaption * m_caption
Definition: docparser.h:1368
const char * qPrint(const char *s)
Definition: qcstring.h:797
#define ASSERT(x)
Definition: qglobal.h:590
int DocHtmlTable::parseXml ( )

Definition at line 3686 of file docparser.cpp.

3687 {
3688  int retval=RetVal_OK;
3689  g_nodeStack.push(this);
3690  DBG(("DocHtmlTable::parseXml() start\n"));
3691 
3692  // get next token
3693  int tok=doctokenizerYYlex();
3694  // skip whitespace
3695  while (tok==TK_WHITESPACE || tok==TK_NEWPARA) tok=doctokenizerYYlex();
3696  // should find a html tag now
3697  int tagId=0;
3698  bool isHeader=FALSE;
3699  if (tok==TK_HTMLTAG)
3700  {
3702  if (tagId==XML_ITEM && !g_token->endTag) // found <item> tag
3703  {
3704  retval=RetVal_TableRow;
3705  }
3706  if (tagId==XML_LISTHEADER && !g_token->endTag) // found <listheader> tag
3707  {
3708  retval=RetVal_TableRow;
3709  isHeader=TRUE;
3710  }
3711  }
3712 
3713  // parse one or more rows
3714  while (retval==RetVal_TableRow)
3715  {
3716  DocHtmlRow *tr=new DocHtmlRow(this,g_token->attribs);
3717  m_children.append(tr);
3718  retval=tr->parseXml(isHeader);
3719  isHeader=FALSE;
3720  }
3721 
3722  computeTableGrid();
3723 
3724  DBG(("DocHtmlTable::parseXml() end\n"));
3725  DocNode *n=g_nodeStack.pop();
3726  ASSERT(n==this);
3728  return tagId==XML_LIST && g_token->endTag ? RetVal_OK : retval;
3729 }
QList< DocNode > m_children
Definition: docparser.h:189
void append(const type *d)
Definition: qlist.h:73
void computeTableGrid()
Definition: docparser.cpp:3746
#define DBG(x)
Definition: docparser.cpp:59
const bool FALSE
Definition: qglobal.h:370
static Mapper * htmlTagMapper
Definition: cmdmapper.h:220
static QStack< DocNode > g_nodeStack
Definition: docparser.cpp:91
TokenInfo * g_token
int doctokenizerYYlex(void)
void push(const type *d)
Definition: qstack.h:58
std::void_t< T > n
int map(const char *n)
Definition: cmdmapper.cpp:225
type * pop()
Definition: qstack.h:59
HtmlAttribList attribs
Definition: doctokenizer.h:102
int parseXml(bool header)
Definition: docparser.cpp:3552
QCString name
Definition: doctokenizer.h:77
const bool TRUE
Definition: qglobal.h:371
#define ASSERT(x)
Definition: qglobal.h:590

Member Data Documentation

HtmlAttribList DocHtmlTable::m_attribs
private

Definition at line 1369 of file docparser.h.

DocHtmlCaption* DocHtmlTable::m_caption
private

Definition at line 1368 of file docparser.h.

int DocHtmlTable::m_numCols
private

Definition at line 1370 of file docparser.h.


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