My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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.

Referenced by HtmlDocVisitor::visit().

{
static char hex[] = "0123456789abcdef";
QCString result="a";
const char *str = word.data();
unsigned char c;
if (str)
{
while ((c = *str++))
{
if ((c >= 'a' && c <= 'z') || // ALPHA
(c >= 'A' && c <= 'Z') || // ALPHA
(c >= '0' && c <= '9') || // DIGIT
c == '-' ||
c == '.' ||
c == '_'
)
{
result += c;
}
else
{
char enc[4];
enc[0] = ':';
enc[1] = hex[(c & 0xf0) >> 4];
enc[2] = hex[c & 0xf];
enc[3] = 0;
result += enc;
}
}
}
return result;
}
static int getParagraphContext ( DocPara p,
bool &  isFirst,
bool &  isLast 
)
static

Definition at line 835 of file htmldocvisitor.cpp.

References isFirstChildNode(), isLastChildNode(), isSeparatedParagraph(), DocNode::kind(), DocNode::Kind_AutoListItem, DocNode::Kind_HtmlCell, DocNode::Kind_HtmlDescData, DocNode::Kind_HtmlListItem, DocNode::Kind_Para, DocNode::Kind_ParamList, DocNode::Kind_ParBlock, DocNode::Kind_SecRefItem, DocNode::Kind_SimpleListItem, DocNode::Kind_SimpleSect, DocNode::Kind_XRefItem, and DocNode::parent().

Referenced by HtmlDocVisitor::forceEndParagraph(), HtmlDocVisitor::forceStartParagraph(), HtmlDocVisitor::visitPost(), and HtmlDocVisitor::visitPre().

{
int t=0;
isFirst=FALSE;
isLast=FALSE;
if (p && p->parent())
{
switch (p->parent()->kind())
{
{ // hierarchy: node N -> para -> parblock -> para
// adapt return value to kind of N
if ( p->parent()->parent() && p->parent()->parent()->parent() )
{
kind = p->parent()->parent()->parent()->kind();
}
isFirst=isFirstChildNode((DocParBlock*)p->parent(),p);
isLast =isLastChildNode ((DocParBlock*)p->parent(),p);
t=0;
if (isFirst)
{
{
t=1;
}
else if (kind==DocNode::Kind_HtmlDescData ||
{
t=2;
}
else if (kind==DocNode::Kind_HtmlCell ||
{
t=5;
}
}
if (isLast)
{
{
t=3;
}
else if (kind==DocNode::Kind_HtmlDescData ||
{
t=4;
}
else if (kind==DocNode::Kind_HtmlCell ||
{
t=6;
}
}
break;
}
t=1; // not used
break;
isFirst=TRUE;
isLast =TRUE;
t=1; // not used
break;
isFirst=TRUE;
isLast =TRUE;
t=1; // not used
break;
if (isFirst) t=1;
if (isLast) t=3;
break;
isLast =isLastChildNode ((DocSecRefItem*)p->parent(),p);
if (isFirst) t=1;
if (isLast) t=3;
break;
if (isFirst) t=2;
if (isLast) t=4;
break;
isFirst=isFirstChildNode((DocXRefItem*)p->parent(),p);
isLast =isLastChildNode ((DocXRefItem*)p->parent(),p);
if (isFirst) t=2;
if (isLast) t=4;
break;
isLast =isLastChildNode ((DocSimpleSect*)p->parent(),p);
if (isFirst) t=2;
if (isLast) t=4;
// if the paragraph is enclosed with separators it will
// be included in <dd>..</dd> so avoid addition paragraph
// markers
{
isFirst=isLast=TRUE;
}
break;
isFirst=isFirstChildNode((DocHtmlCell*)p->parent(),p);
isLast =isLastChildNode ((DocHtmlCell*)p->parent(),p);
if (isFirst) t=5;
if (isLast) t=6;
break;
default:
break;
}
//printf("para=%p parent()->kind=%d isFirst=%d isLast=%d t=%d\n",
// p,p->parent()->kind(),isFirst,isLast,t);
}
return t;
}
static QString htmlAttribsToString ( const HtmlAttribList attribs)
static

Definition at line 129 of file htmldocvisitor.cpp.

References convertToXML(), HtmlAttrib::name, and HtmlAttrib::value.

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

{
QString result;
HtmlAttrib *att;
for (li.toFirst();(att=li.current());++li)
{
if (!att->value.isEmpty()) // ignore attribute without values as they
// are not XHTML compliant
{
result+=" ";
result+=att->name;
result+="=\""+convertToXML(att->value)+"\"";
}
}
return result;
}
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 2078 of file htmldocvisitor.cpp.

References DocStyleChange::Center, CompAccept< T >::children(), DocStyleChange::Div, DocStyleChange::enable(), DocNode::kind(), DocNode::Kind_StyleChange, DocStyleChange::Preformatted, and DocStyleChange::style().

Referenced by HtmlDocVisitor::forceEndParagraph(), and HtmlDocVisitor::forceStartParagraph().

{
//printf("insideStyleChangeThatIsOutputParagraph(index=%d)\n",nodeIndex);
int styleMask=0;
bool styleOutsideParagraph=FALSE;
while (nodeIndex>=0 && !styleOutsideParagraph)
{
DocNode *n = para->children().at(nodeIndex);
{
if (!sc->enable()) // remember styles that has been closed already
{
styleMask|=(int)sc->style();
}
bool paraStyle = sc->style()==DocStyleChange::Center ||
//printf("Found style change %s enabled=%d\n",sc->styleString(),sc->enable());
if (sc->enable() && (styleMask&(int)sc->style())==0 && // style change that is still active
paraStyle
)
{
styleOutsideParagraph=TRUE;
}
}
nodeIndex--;
}
return styleOutsideParagraph;
}
template<class T >
bool isFirstChildNode ( T *  parent,
DocNode node 
)

Definition at line 793 of file htmldocvisitor.cpp.

Referenced by getParagraphContext().

{
return parent->children().getFirst()==node;
}
template<class T >
bool isLastChildNode ( T *  parent,
DocNode node 
)

Definition at line 799 of file htmldocvisitor.cpp.

Referenced by getParagraphContext().

{
return parent->children().getLast()==node;
}
bool isSeparatedParagraph ( DocSimpleSect parent,
DocPara par 
)

Definition at line 804 of file htmldocvisitor.cpp.

References CompAccept< T >::children(), and DocNode::Kind_SimpleSectSep.

Referenced by getParagraphContext().

{
QList<DocNode> nodes = parent->children();
int i = nodes.findRef(par);
if (i==-1) return FALSE;
int count = parent->children().count();
if (count>1 && i==0) // first node
{
if (nodes.at(i+1)->kind()==DocNode::Kind_SimpleSectSep)
{
return TRUE;
}
}
else if (count>1 && i==count-1) // last node
{
if (nodes.at(i-1)->kind()==DocNode::Kind_SimpleSectSep)
{
return TRUE;
}
}
else if (count>2 && i>0 && i<count-1) // intermediate node
{
if (nodes.at(i-1)->kind()==DocNode::Kind_SimpleSectSep &&
nodes.at(i+1)->kind()==DocNode::Kind_SimpleSectSep)
{
return TRUE;
}
}
return FALSE;
}
static bool mustBeOutsideParagraph ( DocNode n)
static

Definition at line 76 of file htmldocvisitor.cpp.

References DocStyleChange::Center, DocStyleChange::Div, DocVerbatim::HtmlOnly, DocVerbatim::isBlock(), DocNode::kind(), DocNode::Kind_AutoList, DocNode::Kind_Copy, DocNode::Kind_Formula, DocNode::Kind_HorRuler, DocNode::Kind_HtmlBlockQuote, DocNode::Kind_HtmlDescList, DocNode::Kind_HtmlHeader, DocNode::Kind_HtmlList, DocNode::Kind_HtmlTable, DocNode::Kind_Image, DocNode::Kind_Include, DocNode::Kind_Internal, DocNode::Kind_ParamSect, DocNode::Kind_ParBlock, DocNode::Kind_SecRefList, DocNode::Kind_Section, DocNode::Kind_SimpleList, DocNode::Kind_SimpleSect, DocNode::Kind_StyleChange, DocNode::Kind_Verbatim, DocNode::Kind_XRefItem, DocStyleChange::Preformatted, and DocVerbatim::type().

Referenced by HtmlDocVisitor::forceEndParagraph(), HtmlDocVisitor::forceStartParagraph(), HtmlDocVisitor::visitPost(), and HtmlDocVisitor::visitPre().

{
switch (n->kind())
{
/* <ul> */
/* <dl> */
/* <table> */
/* <h?> */
/* \internal */
/* <div> */
/* <hr> */
/* CopyDoc gets paragraph markers from the wrapping DocPara node,
* but needs to insert them for all documentation being copied to
* preserve formatting.
*/
/* <blockquote> */
/* \parblock */
return TRUE;
{
return dv->type()!=DocVerbatim::HtmlOnly || dv->isBlock();
}
return ((DocStyleChange*)n)->style()==DocStyleChange::Preformatted ||
return !((DocFormula*)n)->isInline();
default:
break;
}
return FALSE;
}
static void visitCaption ( HtmlDocVisitor parent,
QList< DocNode children 
)
static

Definition at line 345 of file htmldocvisitor.cpp.

References DocNode::accept().

Referenced by HtmlDocVisitor::visit().

{
QListIterator<DocNode> cli(children);
DocNode *n;
for (cli.toFirst();(n=cli.current());++cli) n->accept(parent);
}
static void visitPostCaption ( FTextStream t,
DocVerbatim s 
)
static

Definition at line 336 of file htmldocvisitor.cpp.

References endl(), and DocVerbatim::hasCaption().

Referenced by HtmlDocVisitor::visit().

{
if (s->hasCaption())
{
t << "</div>" << endl;
}
}
static void visitPreCaption ( FTextStream t,
DocVerbatim s 
)
static

Definition at line 327 of file htmldocvisitor.cpp.

References endl(), and DocVerbatim::hasCaption().

Referenced by HtmlDocVisitor::visit().

{
if (s->hasCaption())
{
t << "<div class=\"caption\">" << endl;
}
}

Variable Documentation

const int NUM_HTML_LIST_TYPES = 4
static

Definition at line 39 of file htmldocvisitor.cpp.

Referenced by HtmlDocVisitor::visitPre().

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

Definition at line 40 of file htmldocvisitor.cpp.

Referenced by HtmlDocVisitor::visitPre().