Functions | Variables
htmldocvisitor.cpp File Reference
#include <qdir.h>
#include "htmldocvisitor.h"
#include "docparser.h"
#include "language.h"
#include "doxygen.h"
#include "outputgen.h"
#include "dot.h"
#include "message.h"
#include "config.h"
#include "htmlgen.h"
#include "parserintf.h"
#include "msc.h"
#include "dia.h"
#include "util.h"
#include "vhdldocgen.h"
#include "filedef.h"
#include "memberdef.h"
#include "htmlentity.h"
#include "plantuml.h"

Go to the source code of this file.

Functions

static QCString convertIndexWordToAnchor (const QString &word)
 
static bool mustBeOutsideParagraph (DocNode *n)
 
static QString htmlAttribsToString (const HtmlAttribList &attribs)
 
static void visitPreCaption (FTextStream &t, DocVerbatim *s)
 
static void visitPostCaption (FTextStream &t, DocVerbatim *s)
 
static void visitCaption (HtmlDocVisitor *parent, QList< DocNode > children)
 
template<class T >
bool isFirstChildNode (T *parent, DocNode *node)
 
template<class T >
bool isLastChildNode (T *parent, DocNode *node)
 
bool isSeparatedParagraph (DocSimpleSect *parent, DocPara *par)
 
static int getParagraphContext (DocPara *p, bool &isFirst, bool &isLast)
 
static bool insideStyleChangeThatIsOutsideParagraph (DocPara *para, int nodeIndex)
 

Variables

static const int NUM_HTML_LIST_TYPES = 4
 
static const char types [][NUM_HTML_LIST_TYPES] = {"1", "a", "i", "A"}
 

Function Documentation

static QCString convertIndexWordToAnchor ( const QString word)
static

Definition at line 42 of file htmldocvisitor.cpp.

43 {
44  static char hex[] = "0123456789abcdef";
45  QCString result="a";
46  const char *str = word.data();
47  unsigned char c;
48  if (str)
49  {
50  while ((c = *str++))
51  {
52  if ((c >= 'a' && c <= 'z') || // ALPHA
53  (c >= 'A' && c <= 'A') || // ALPHA
54  (c >= '0' && c <= '9') || // DIGIT
55  c == '-' ||
56  c == '.' ||
57  c == '_'
58  )
59  {
60  result += c;
61  }
62  else
63  {
64  char enc[4];
65  enc[0] = ':';
66  enc[1] = hex[(c & 0xf0) >> 4];
67  enc[2] = hex[c & 0xf];
68  enc[3] = 0;
69  result += enc;
70  }
71  }
72  }
73  return result;
74 }
static QCString result
QTextStream & hex(QTextStream &s)
const char * data() const
Definition: qstring.h:542
static QCString str
static int getParagraphContext ( DocPara p,
bool isFirst,
bool isLast 
)
static

Definition at line 830 of file htmldocvisitor.cpp.

831 {
832  int t=0;
833  isFirst=FALSE;
834  isLast=FALSE;
835  if (p && p->parent())
836  {
837  switch (p->parent()->kind())
838  {
840  { // hierarchy: node N -> para -> parblock -> para
841  // adapt return value to kind of N
843  if ( p->parent()->parent() && p->parent()->parent()->parent() )
844  {
845  kind = p->parent()->parent()->parent()->kind();
846  }
847  isFirst=isFirstChildNode((DocParBlock*)p->parent(),p);
848  isLast =isLastChildNode ((DocParBlock*)p->parent(),p);
849  t=0;
850  if (isFirst)
851  {
852  if (kind==DocNode::Kind_HtmlListItem ||
854  {
855  t=1;
856  }
857  else if (kind==DocNode::Kind_HtmlDescData ||
858  kind==DocNode::Kind_XRefItem ||
860  {
861  t=2;
862  }
863  else if (kind==DocNode::Kind_HtmlCell ||
865  {
866  t=5;
867  }
868  }
869  if (isLast)
870  {
871  if (kind==DocNode::Kind_HtmlListItem ||
873  {
874  t=3;
875  }
876  else if (kind==DocNode::Kind_HtmlDescData ||
877  kind==DocNode::Kind_XRefItem ||
879  {
880  t=4;
881  }
882  else if (kind==DocNode::Kind_HtmlCell ||
884  {
885  t=6;
886  }
887  }
888  break;
889  }
891  isFirst=isFirstChildNode((DocAutoListItem*)p->parent(),p);
892  isLast =isLastChildNode ((DocAutoListItem*)p->parent(),p);
893  t=1; // not used
894  break;
896  isFirst=TRUE;
897  isLast =TRUE;
898  t=1; // not used
899  break;
901  isFirst=TRUE;
902  isLast =TRUE;
903  t=1; // not used
904  break;
906  isFirst=isFirstChildNode((DocHtmlListItem*)p->parent(),p);
907  isLast =isLastChildNode ((DocHtmlListItem*)p->parent(),p);
908  if (isFirst) t=1;
909  if (isLast) t=3;
910  break;
912  isFirst=isFirstChildNode((DocSecRefItem*)p->parent(),p);
913  isLast =isLastChildNode ((DocSecRefItem*)p->parent(),p);
914  if (isFirst) t=1;
915  if (isLast) t=3;
916  break;
918  isFirst=isFirstChildNode((DocHtmlDescData*)p->parent(),p);
919  isLast =isLastChildNode ((DocHtmlDescData*)p->parent(),p);
920  if (isFirst) t=2;
921  if (isLast) t=4;
922  break;
924  isFirst=isFirstChildNode((DocXRefItem*)p->parent(),p);
925  isLast =isLastChildNode ((DocXRefItem*)p->parent(),p);
926  if (isFirst) t=2;
927  if (isLast) t=4;
928  break;
930  isFirst=isFirstChildNode((DocSimpleSect*)p->parent(),p);
931  isLast =isLastChildNode ((DocSimpleSect*)p->parent(),p);
932  if (isFirst) t=2;
933  if (isLast) t=4;
935  // if the paragraph is enclosed with separators it will
936  // be included in <dd>..</dd> so avoid addition paragraph
937  // markers
938  {
939  isFirst=isLast=TRUE;
940  }
941  break;
943  isFirst=isFirstChildNode((DocHtmlCell*)p->parent(),p);
944  isLast =isLastChildNode ((DocHtmlCell*)p->parent(),p);
945  if (isFirst) t=5;
946  if (isLast) t=6;
947  break;
948  default:
949  break;
950  }
951  //printf("para=%p parent()->kind=%d isFirst=%d isLast=%d t=%d\n",
952  // p,p->parent()->kind(),isFirst,isLast,t);
953  }
954  return t;
955 }
DocNode * parent() const
Definition: docparser.h:147
const bool FALSE
Definition: qglobal.h:370
virtual Kind kind() const =0
p
Definition: test.py:223
bool isLastChildNode(T *parent, DocNode *node)
bool isSeparatedParagraph(DocSimpleSect *parent, DocPara *par)
bool isFirstChildNode(T *parent, DocNode *node)
const bool TRUE
Definition: qglobal.h:371
static QString htmlAttribsToString ( const HtmlAttribList attribs)
static

Definition at line 129 of file htmldocvisitor.cpp.

130 {
131  QString result;
132  HtmlAttribListIterator li(attribs);
133  HtmlAttrib *att;
134  for (li.toFirst();(att=li.current());++li)
135  {
136  if (!att->value.isEmpty()) // ignore attribute without values as they
137  // are not XHTML compliant
138  {
139  result+=" ";
140  result+=att->name;
141  result+="=\""+convertToXML(att->value)+"\"";
142  }
143  }
144  return result;
145 }
QCString convertToXML(const char *s)
Definition: util.cpp:5717
static QCString result
bool isEmpty() const
Definition: qcstring.h:189
The QString class provides an abstraction of Unicode text and the classic C null-terminated char arra...
Definition: qstring.h:350
QCString value
Definition: htmlattrib.h:25
Html attribute list iterator.
Definition: htmlattrib.h:71
QCString name
Definition: htmlattrib.h:24
static bool insideStyleChangeThatIsOutsideParagraph ( DocPara para,
int  nodeIndex 
)
static

Returns TRUE if the child nodes in paragraph para until nodeIndex contain a style change node that is still active and that style change is one that must be located outside of a paragraph, i.e. it is a center, div, or pre tag. See also bug746162.

Definition at line 2051 of file htmldocvisitor.cpp.

2052 {
2053  //printf("insideStyleChangeThatIsOutputParagraph(index=%d)\n",nodeIndex);
2054  int styleMask=0;
2055  bool styleOutsideParagraph=FALSE;
2056  while (nodeIndex>=0 && !styleOutsideParagraph)
2057  {
2058  DocNode *n = para->children().at(nodeIndex);
2059  if (n->kind()==DocNode::Kind_StyleChange)
2060  {
2061  DocStyleChange *sc = (DocStyleChange*)n;
2062  if (!sc->enable()) // remember styles that has been closed already
2063  {
2064  styleMask|=(int)sc->style();
2065  }
2066  bool paraStyle = sc->style()==DocStyleChange::Center ||
2067  sc->style()==DocStyleChange::Div ||
2069  //printf("Found style change %s enabled=%d\n",sc->styleString(),sc->enable());
2070  if (sc->enable() && (styleMask&(int)sc->style())==0 && // style change that is still active
2071  paraStyle
2072  )
2073  {
2074  styleOutsideParagraph=TRUE;
2075  }
2076  }
2077  nodeIndex--;
2078  }
2079  return styleOutsideParagraph;
2080 }
const bool FALSE
Definition: qglobal.h:370
type * at(uint i) const
Definition: qlist.h:94
virtual Kind kind() const =0
std::void_t< T > n
Style style() const
Definition: docparser.h:329
bool enable() const
Definition: docparser.h:331
const bool TRUE
Definition: qglobal.h:371
const QList< DocNode > & children() const
Definition: docparser.h:185
template<class T >
bool isFirstChildNode ( T *  parent,
DocNode node 
)

Definition at line 788 of file htmldocvisitor.cpp.

789 {
790  return parent->children().getFirst()==node;
791 }
def parent(G, child, parent_type)
Definition: graph.py:67
template<class T >
bool isLastChildNode ( T *  parent,
DocNode node 
)

Definition at line 794 of file htmldocvisitor.cpp.

795 {
796  return parent->children().getLast()==node;
797 }
def parent(G, child, parent_type)
Definition: graph.py:67
bool isSeparatedParagraph ( DocSimpleSect parent,
DocPara par 
)

Definition at line 799 of file htmldocvisitor.cpp.

800 {
801  QList<DocNode> nodes = parent->children();
802  int i = nodes.findRef(par);
803  if (i==-1) return FALSE;
804  int count = parent->children().count();
805  if (count>1 && i==0) // first node
806  {
807  if (nodes.at(i+1)->kind()==DocNode::Kind_SimpleSectSep)
808  {
809  return TRUE;
810  }
811  }
812  else if (count>1 && i==count-1) // last node
813  {
814  if (nodes.at(i-1)->kind()==DocNode::Kind_SimpleSectSep)
815  {
816  return TRUE;
817  }
818  }
819  else if (count>2 && i>0 && i<count-1) // intermediate node
820  {
821  if (nodes.at(i-1)->kind()==DocNode::Kind_SimpleSectSep &&
822  nodes.at(i+1)->kind()==DocNode::Kind_SimpleSectSep)
823  {
824  return TRUE;
825  }
826  }
827  return FALSE;
828 }
int findRef(const type *d) const
Definition: qlist.h:89
const bool FALSE
Definition: qglobal.h:370
type * at(uint i) const
Definition: qlist.h:94
virtual Kind kind() const =0
uint count() const
Definition: qlist.h:66
#define nodes
const bool TRUE
Definition: qglobal.h:371
const QList< DocNode > & children() const
Definition: docparser.h:185
static bool mustBeOutsideParagraph ( DocNode n)
static

Definition at line 76 of file htmldocvisitor.cpp.

77 {
78  switch (n->kind())
79  {
80  /* <ul> */
84  /* <dl> */
89  /* <table> */
91  /* <h?> */
94  /* \internal */
96  /* <div> */
100  /* <hr> */
102  /* CopyDoc gets paragraph markers from the wrapping DocPara node,
103  * but needs to insert them for all documentation being copied to
104  * preserve formatting.
105  */
106  case DocNode::Kind_Copy:
107  /* <blockquote> */
109  /* \parblock */
111  return TRUE;
113  {
114  DocVerbatim *dv = (DocVerbatim*)n;
115  return dv->type()!=DocVerbatim::HtmlOnly || dv->isBlock();
116  }
118  return ((DocStyleChange*)n)->style()==DocStyleChange::Preformatted ||
119  ((DocStyleChange*)n)->style()==DocStyleChange::Div ||
120  ((DocStyleChange*)n)->style()==DocStyleChange::Center;
122  return !((DocFormula*)n)->isInline();
123  default:
124  break;
125  }
126  return FALSE;
127 }
const bool FALSE
Definition: qglobal.h:370
virtual Kind kind() const =0
bool isBlock() const
Definition: docparser.h:457
Type type() const
Definition: docparser.h:449
const bool TRUE
Definition: qglobal.h:371
static void visitCaption ( HtmlDocVisitor parent,
QList< DocNode children 
)
static

Definition at line 345 of file htmldocvisitor.cpp.

346 {
347  QListIterator<DocNode> cli(children);
348  DocNode *n;
349  for (cli.toFirst();(n=cli.current());++cli) n->accept(parent);
350 }
def cli(ctx)
Definition: main.py:7
std::void_t< T > n
virtual void accept(DocVisitor *v)=0
static void visitPostCaption ( FTextStream t,
DocVerbatim s 
)
static

Definition at line 336 of file htmldocvisitor.cpp.

337 {
338  if (s->hasCaption())
339  {
340  t << "</div>" << endl;
341  }
342 }
bool hasCaption() const
Definition: docparser.h:458
QTextStream & endl(QTextStream &s)
static void visitPreCaption ( FTextStream t,
DocVerbatim s 
)
static

Definition at line 327 of file htmldocvisitor.cpp.

328 {
329  if (s->hasCaption())
330  {
331  t << "<div class=\"caption\">" << endl;
332  }
333 }
bool hasCaption() const
Definition: docparser.h:458
QTextStream & endl(QTextStream &s)

Variable Documentation

const int NUM_HTML_LIST_TYPES = 4
static

Definition at line 39 of file htmldocvisitor.cpp.

const char types[][NUM_HTML_LIST_TYPES] = {"1", "a", "i", "A"}
static

Definition at line 40 of file htmldocvisitor.cpp.