summaryrefslogtreecommitdiffstats
path: root/src/htmldocvisitor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/htmldocvisitor.cpp')
-rw-r--r--src/htmldocvisitor.cpp437
1 files changed, 179 insertions, 258 deletions
diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp
index fc3ca57..4bed69a 100644
--- a/src/htmldocvisitor.cpp
+++ b/src/htmldocvisitor.cpp
@@ -13,7 +13,6 @@
*
*/
-#include <qdir.h>
#include "htmldocvisitor.h"
#include "docparser.h"
#include "language.h"
@@ -34,6 +33,7 @@
#include "emoji.h"
#include "plantuml.h"
#include "formula.h"
+#include "fileinfo.h"
static const int NUM_HTML_LIST_TYPES = 4;
static const char types[][NUM_HTML_LIST_TYPES] = {"1", "a", "i", "A"};
@@ -102,7 +102,7 @@ static QCString convertIndexWordToAnchor(const QCString &word)
return result;
}
-static bool mustBeOutsideParagraph(DocNode *n)
+static bool mustBeOutsideParagraph(const DocNode *n)
{
switch (n->kind())
{
@@ -157,7 +157,7 @@ static bool mustBeOutsideParagraph(DocNode *n)
return FALSE;
}
-static bool isDocVerbatimVisible(DocVerbatim *s)
+static bool isDocVerbatimVisible(const DocVerbatim *s)
{
switch(s->type())
{
@@ -172,7 +172,7 @@ static bool isDocVerbatimVisible(DocVerbatim *s)
}
}
-static bool isDocIncludeVisible(DocInclude *s)
+static bool isDocIncludeVisible(const DocInclude *s)
{
switch (s->type())
{
@@ -188,7 +188,7 @@ static bool isDocIncludeVisible(DocInclude *s)
}
}
-static bool isDocIncOperatorVisible(DocIncOperator *s)
+static bool isDocIncOperatorVisible(const DocIncOperator *s)
{
switch (s->type())
{
@@ -199,7 +199,7 @@ static bool isDocIncOperatorVisible(DocIncOperator *s)
}
}
-static bool isInvisibleNode(DocNode *node)
+static bool isInvisibleNode(const DocNode *node)
{
return (node->kind()==DocNode::Kind_WhiteSpace)
|| // skip over image nodes that are not for HTML output
@@ -213,30 +213,19 @@ static bool isInvisibleNode(DocNode *node)
;
}
-static void mergeHtmlAttributes(const HtmlAttribList &attribs, HtmlAttribList *mergeInto)
+static void mergeHtmlAttributes(const HtmlAttribList &attribs, HtmlAttribList &mergeInto)
{
- HtmlAttribListIterator li(attribs);
- HtmlAttrib *att;
- for (li.toFirst();(att=li.current());++li)
+ for (const auto &att : attribs)
{
- HtmlAttribListIterator ml(*mergeInto);
- HtmlAttrib *opt;
- bool found = false;
- for (ml.toFirst();(opt=ml.current());++ml)
+ auto it = std::find_if(mergeInto.begin(),mergeInto.end(),
+ [&att](const auto &opt) { return opt.name==att.name; });
+ if (it!=mergeInto.end()) // attribute name already in mergeInto
{
- if (opt->name == att -> name)
- {
- found = true;
- break;
- }
- }
- if (found)
- {
- opt->value = opt->value + " " + att->value;
+ it->value = it->value + " " + att.value;
}
- else
+ else // attribute name not yet in mergeInto
{
- mergeInto->append(att);
+ mergeInto.push_back(att);
}
}
}
@@ -244,31 +233,29 @@ static void mergeHtmlAttributes(const HtmlAttribList &attribs, HtmlAttribList *m
static QCString htmlAttribsToString(const HtmlAttribList &attribs, QCString *pAltValue = 0)
{
QCString result;
- HtmlAttribListIterator li(attribs);
- HtmlAttrib *att;
- for (li.toFirst();(att=li.current());++li)
+ for (const auto &att : attribs)
{
- if (!att->value.isEmpty()) // ignore attribute without values as they
+ if (!att.value.isEmpty()) // ignore attribute without values as they
// are not XHTML compliant, with the exception
// of the alt attribute with the img tag
{
- if (att->name=="alt" && pAltValue) // optionally return the value of alt separately
+ if (att.name=="alt" && pAltValue) // optionally return the value of alt separately
// need to convert <img> to <object> for SVG images,
// which do not support the alt attribute
{
- *pAltValue = att->value;
+ *pAltValue = att.value;
}
else
{
result+=" ";
- result+=att->name;
- result+="=\""+convertToXML(att->value)+"\"";
+ result+=att.name;
+ result+="=\""+convertToXML(att.value)+"\"";
}
}
- else if (att->name=="nowrap") // In XHTML, attribute minimization is forbidden, and the nowrap attribute must be defined as <td nowrap="nowrap">.
+ else if (att.name=="nowrap") // In XHTML, attribute minimization is forbidden, and the nowrap attribute must be defined as <td nowrap="nowrap">.
{
result+=" ";
- result+=att->name;
+ result+=att.name;
result+="=\"nowrap\"";
}
}
@@ -277,7 +264,7 @@ static QCString htmlAttribsToString(const HtmlAttribList &attribs, QCString *pAl
//-------------------------------------------------------------------------
-HtmlDocVisitor::HtmlDocVisitor(FTextStream &t,CodeOutputInterface &ci,
+HtmlDocVisitor::HtmlDocVisitor(TextStream &t,CodeOutputInterface &ci,
const Definition *ctx)
: DocVisitor(DocVisitor_Html), m_t(t), m_ci(ci), m_insidePre(FALSE),
m_hide(FALSE), m_ctx(ctx)
@@ -291,7 +278,7 @@ HtmlDocVisitor::HtmlDocVisitor(FTextStream &t,CodeOutputInterface &ci,
void HtmlDocVisitor::visit(DocWord *w)
{
- //printf("word: %s\n",w->word().data());
+ //printf("word: %s\n",qPrint(w->word()));
if (m_hide) return;
filter(w->word());
}
@@ -299,7 +286,7 @@ void HtmlDocVisitor::visit(DocWord *w)
void HtmlDocVisitor::visit(DocLinkedWord *w)
{
if (m_hide) return;
- //printf("linked word: %s\n",w->word().data());
+ //printf("linked word: %s\n",qPrint(w->word()));
startLink(w->ref(),w->file(),w->relPath(),w->anchor(),w->tooltip());
filter(w->word());
endLink();
@@ -484,29 +471,27 @@ void HtmlDocVisitor::visit(DocStyleChange *s)
}
-static void visitPreCaption(FTextStream &t, DocVerbatim *s)
+static void visitPreCaption(TextStream &t, DocVerbatim *s)
{
if (s->hasCaption())
{
- t << "<div class=\"caption\">" << endl;
+ t << "<div class=\"caption\">\n";
}
}
-static void visitPostCaption(FTextStream &t, DocVerbatim *s)
+static void visitPostCaption(TextStream &t, DocVerbatim *s)
{
if (s->hasCaption())
{
- t << "</div>" << endl;
+ t << "</div>\n";
}
}
-static void visitCaption(HtmlDocVisitor *parent, QList<DocNode> children)
+static void visitCaption(HtmlDocVisitor *parent, DocNodeList &children)
{
- QListIterator<DocNode> cli(children);
- DocNode *n;
- for (cli.toFirst();(n=cli.current());++cli) n->accept(parent);
+ for (const auto &n : children) n->accept(parent);
}
void HtmlDocVisitor::visit(DocVerbatim *s)
@@ -569,28 +554,29 @@ void HtmlDocVisitor::visit(DocVerbatim *s)
forceEndParagraph(s);
fileName.sprintf("%s%d%s",
- (Config_getString(HTML_OUTPUT)+"/inline_dotgraph_").data(),
+ qPrint(Config_getString(HTML_OUTPUT)+"/inline_dotgraph_"),
dotindex++,
".dot"
);
- QFile file(fileName);
- if (!file.open(IO_WriteOnly))
+ std::ofstream file(fileName.str(),std::ofstream::out | std::ofstream::binary);
+ if (!file.is_open())
{
- err("Could not open file %s for writing\n",fileName.data());
+ err("Could not open file %s for writing\n",qPrint(fileName));
}
else
{
- file.writeBlock( s->text(), s->text().length() );
+ QCString stext = s->text();
+ file.write( stext.data(), stext.length() );
file.close();
- m_t << "<div class=\"dotgraph\">" << endl;
+ m_t << "<div class=\"dotgraph\">\n";
writeDotFile(fileName,s->relPath(),s->context());
visitPreCaption(m_t, s);
visitCaption(this, s->children());
visitPostCaption(m_t, s);
- m_t << "</div>" << endl;
+ m_t << "</div>\n";
- if (Config_getBool(DOT_CLEANUP)) file.remove();
+ if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName.str());
}
forceStartParagraph(s);
}
@@ -603,13 +589,13 @@ void HtmlDocVisitor::visit(DocVerbatim *s)
QCString baseName(4096);
baseName.sprintf("%s%d",
- (Config_getString(HTML_OUTPUT)+"/inline_mscgraph_").data(),
+ qPrint(Config_getString(HTML_OUTPUT)+"/inline_mscgraph_"),
mscindex++
);
- QFile file(baseName+".msc");
- if (!file.open(IO_WriteOnly))
+ std::ofstream file(baseName.str()+".msc",std::ofstream::out | std::ofstream::binary);
+ if (!file.is_open())
{
- err("Could not open file %s.msc for writing\n",baseName.data());
+ err("Could not open file %s.msc for writing\n",qPrint(baseName));
}
else
{
@@ -617,17 +603,17 @@ void HtmlDocVisitor::visit(DocVerbatim *s)
text+=s->text();
text+="}";
- file.writeBlock( text, text.length() );
+ file.write( text.data(), text.length() );
file.close();
- m_t << "<div class=\"mscgraph\">" << endl;
+ m_t << "<div class=\"mscgraph\">\n";
writeMscFile(baseName+".msc",s->relPath(),s->context());
visitPreCaption(m_t, s);
visitCaption(this, s->children());
visitPostCaption(m_t, s);
- m_t << "</div>" << endl;
+ m_t << "</div>\n";
- if (Config_getBool(DOT_CLEANUP)) file.remove();
+ if (Config_getBool(DOT_CLEANUP)) Dir().remove(baseName.str()+".msc");
}
forceStartParagraph(s);
}
@@ -642,13 +628,13 @@ void HtmlDocVisitor::visit(DocVerbatim *s)
{
format = PlantumlManager::PUML_SVG;
}
- QCString baseName = PlantumlManager::instance()->writePlantUMLSource(htmlOutput,s->exampleFile(),s->text(),format);
- m_t << "<div class=\"plantumlgraph\">" << endl;
+ QCString baseName = PlantumlManager::instance().writePlantUMLSource(htmlOutput,s->exampleFile(),s->text(),format,s->engine());
+ m_t << "<div class=\"plantumlgraph\">\n";
writePlantUMLFile(baseName,s->relPath(),s->context());
visitPreCaption(m_t, s);
visitCaption(this, s->children());
visitPostCaption(m_t, s);
- m_t << "</div>" << endl;
+ m_t << "</div>\n";
forceStartParagraph(s);
}
break;
@@ -691,8 +677,8 @@ void HtmlDocVisitor::visit(DocInclude *inc)
{
forceEndParagraph(inc);
m_ci.startCodeFragment("DoxyCode");
- QFileInfo cfi( inc->file() );
- FileDef *fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() );
+ FileInfo cfi( inc->file().str() );
+ FileDef *fd = createFileDef( cfi.dirPath(), cfi.fileName() );
getCodeParser(inc->extension()).parseCode(m_ci,
inc->context(),
inc->text(),
@@ -760,8 +746,8 @@ void HtmlDocVisitor::visit(DocInclude *inc)
{
forceEndParagraph(inc);
m_ci.startCodeFragment("DoxyCode");
- QFileInfo cfi( inc->file() );
- FileDef *fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() );
+ FileInfo cfi( inc->file().str() );
+ FileDef *fd = createFileDef( cfi.dirPath(), cfi.fileName() );
getCodeParser(inc->extension()).parseCode(m_ci,
inc->context(),
extractBlock(inc->text(),inc->blockId()),
@@ -792,12 +778,12 @@ void HtmlDocVisitor::visit(DocInclude *inc)
void HtmlDocVisitor::visit(DocIncOperator *op)
{
//printf("DocIncOperator: type=%d first=%d, last=%d text='%s'\n",
- // op->type(),op->isFirst(),op->isLast(),op->text().data());
+ // op->type(),op->isFirst(),op->isLast(),qPrint(op->text()));
if (op->isFirst())
{
forceEndParagraph(op);
if (!m_hide) m_ci.startCodeFragment("DoxyCode");
- pushEnabled();
+ pushHidden(m_hide);
m_hide=TRUE;
}
QCString locLangExt = getFileNameExtension(op->includeFileName());
@@ -805,14 +791,14 @@ void HtmlDocVisitor::visit(DocIncOperator *op)
SrcLangExt langExt = getLanguageFromFileName(locLangExt);
if (op->type()!=DocIncOperator::Skip)
{
- popEnabled();
+ m_hide = popHidden();
if (!m_hide)
{
FileDef *fd = 0;
if (!op->includeFileName().isEmpty())
{
- QFileInfo cfi( op->includeFileName() );
- fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() );
+ FileInfo cfi( op->includeFileName().str() );
+ fd = createFileDef( cfi.dirPath(), cfi.fileName() );
}
getCodeParser(locLangExt).parseCode(
m_ci,
@@ -831,18 +817,18 @@ void HtmlDocVisitor::visit(DocIncOperator *op)
);
if (fd) delete fd;
}
- pushEnabled();
+ pushHidden(m_hide);
m_hide=TRUE;
}
if (op->isLast())
{
- popEnabled();
+ m_hide = popHidden();
if (!m_hide) m_ci.endCodeFragment("DoxyCode");
forceStartParagraph(op);
}
else
{
- if (!m_hide) m_t << endl;
+ if (!m_hide) m_t << "\n";
}
}
@@ -853,7 +839,7 @@ void HtmlDocVisitor::visit(DocFormula *f)
if (bDisplay)
{
forceEndParagraph(f);
- m_t << "<p class=\"formulaDsp\">" << endl;
+ m_t << "<p class=\"formulaDsp\">\n";
}
if (Config_getBool(USE_MATHJAX))
@@ -867,6 +853,11 @@ void HtmlDocVisitor::visit(DocFormula *f)
text = text.mid(1,text.length()-2);
m_t << "\\(";
}
+ else if (!bDisplay && !text.isEmpty())
+ {
+ closeInline=TRUE;
+ m_t << "\\(";
+ }
m_t << convertToHtml(text);
if (closeInline)
{
@@ -902,7 +893,7 @@ void HtmlDocVisitor::visit(DocFormula *f)
}
if (bDisplay)
{
- m_t << endl << "</p>" << endl;
+ m_t << "\n</p>\n";
forceStartParagraph(f);
}
}
@@ -916,17 +907,17 @@ void HtmlDocVisitor::visit(DocIndexEntry *e)
}
m_t << "<a name=\"" << anchor << "\"></a>";
//printf("*** DocIndexEntry: word='%s' scope='%s' member='%s'\n",
- // e->entry().data(),
- // e->scope() ? e->scope()->name().data() : "<null>",
- // e->member() ? e->member()->name().data() : "<null>"
+ // qPrint(e->entry()),
+ // e->scope() ? qPrint(e->scope()->name()) : "<null>",
+ // e->member() ? qPrint(e->member()->name()) : "<null>"
// );
Doxygen::indexList->addIndexItem(e->scope(),e->member(),anchor,e->entry());
}
void HtmlDocVisitor::visit(DocSimpleSectSep *)
{
- m_t << "</dd>" << endl;
- m_t << "<dd>" << endl;
+ m_t << "</dd>\n";
+ m_t << "<dd>\n";
}
void HtmlDocVisitor::visit(DocCite *cite)
@@ -972,13 +963,12 @@ void HtmlDocVisitor::visitPre(DocAutoList *l)
// A.
// 1. (repeat)...
//
- m_t << "<ol type=\"" << types[l->depth() % NUM_HTML_LIST_TYPES] << "\"";
+ m_t << "<ol type=\"" << types[l->depth() % NUM_HTML_LIST_TYPES] << "\">";
}
else
{
- m_t << "<ul";
+ m_t << "<ul>";
}
- m_t << getDirHtmlClassOfNode(getTextDirByConfig(l)) << ">";
if (!l->isPreformatted()) m_t << "\n";
}
@@ -1014,21 +1004,22 @@ void HtmlDocVisitor::visitPost(DocAutoListItem *li)
template<class T>
bool isFirstChildNode(T *parent, DocNode *node)
{
- return parent->children().getFirst()==node;
+ return !parent->children().empty() && parent->children().front().get()==node;
}
template<class T>
bool isLastChildNode(T *parent, DocNode *node)
{
- return parent->children().getLast()==node;
+ return !parent->children().empty() && parent->children().back().get()==node;
}
bool isSeparatedParagraph(DocSimpleSect *parent,DocPara *par)
{
- QList<DocNode> nodes = parent->children();
- int i = nodes.findRef(par);
- if (i==-1) return FALSE;
- int count = parent->children().count();
+ const DocNodeList &nodes = parent->children();
+ auto it = std::find_if(nodes.begin(),nodes.end(),[par](const auto &n) { return n.get()==par; });
+ if (it==nodes.end()) return FALSE;
+ size_t i = it - nodes.begin();
+ size_t count = parent->children().size();
if (count>1 && i==0) // first node
{
if (nodes.at(i+1)->kind()==DocNode::Kind_SimpleSectSep)
@@ -1243,20 +1234,18 @@ void HtmlDocVisitor::visitPre(DocPara *p)
// if the first element of a paragraph is something that should be outside of
// the paragraph (<ul>,<dl>,<table>,..) then that will already started the
// paragraph and we don't need to do it here
- bool paragraphAlreadyStarted = false;
- uint nodeIndex = 0;
- if (p && nodeIndex<p->children().count())
+ size_t nodeIndex = 0;
+ if (p && nodeIndex<p->children().size())
{
- while (nodeIndex<p->children().count() && isInvisibleNode(p->children().at(nodeIndex)))
+ while (nodeIndex<p->children().size() && isInvisibleNode(p->children().at(nodeIndex).get()))
{
nodeIndex++;
}
- if (nodeIndex<p->children().count())
+ if (nodeIndex<p->children().size())
{
- DocNode *n = p->children().at(nodeIndex);
+ const DocNode *n = p->children().at(nodeIndex).get();
if (mustBeOutsideParagraph(n))
{
- paragraphAlreadyStarted = true;
needsTag = FALSE;
}
}
@@ -1275,9 +1264,7 @@ void HtmlDocVisitor::visitPre(DocPara *p)
//printf(" needsTag=%d\n",needsTag);
// write the paragraph tag (if needed)
if (needsTag)
- m_t << "<p" << getDirHtmlClassOfNode(getTextDirByConfig(p), contexts[t]) << htmlAttribsToString(p->attribs()) << ">";
- else if(!paragraphAlreadyStarted)
- m_t << getHtmlDirEmbeddingChar(getTextDirByConfig(p)) << htmlAttribsToString(p->attribs());
+ m_t << "<p class=\"" << contexts[t] << "\"" << htmlAttribsToString(p->attribs()) << ">";
}
void HtmlDocVisitor::visitPost(DocPara *p)
@@ -1316,16 +1303,16 @@ void HtmlDocVisitor::visitPost(DocPara *p)
// if the last element of a paragraph is something that should be outside of
// the paragraph (<ul>,<dl>,<table>) then that will already have ended the
// paragraph and we don't need to do it here
- int nodeIndex = p->children().count()-1;
- if (nodeIndex>=0)
+ if (!p->children().empty())
{
- while (nodeIndex>=0 && isInvisibleNode(p->children().at(nodeIndex)))
+ int nodeIndex = static_cast<int>(p->children().size()-1);
+ while (nodeIndex>=0 && isInvisibleNode(p->children().at(nodeIndex).get()))
{
nodeIndex--;
}
if (nodeIndex>=0)
{
- DocNode *n = p->children().at(nodeIndex);
+ const DocNode *n = p->children().at(nodeIndex).get();
if (mustBeOutsideParagraph(n))
{
needsTag = FALSE;
@@ -1357,10 +1344,7 @@ void HtmlDocVisitor::visitPre(DocSimpleSect *s)
{
if (m_hide) return;
forceEndParagraph(s);
- if (s->type() != DocSimpleSect::Return)
- m_t << "<dl" << getDirHtmlClassOfNode(getTextDirByConfig(s), "section " + s->typeString()) << "><dt>";
- else
- m_t << "<dl class=\"section " << s->typeString() << "\"><dt>";
+ m_t << "<dl class=\"section " << s->typeString() << "\"><dt>";
switch(s->type())
{
case DocSimpleSect::See:
@@ -1456,10 +1440,10 @@ void HtmlDocVisitor::visitPre(DocSection *s)
{
if (m_hide) return;
forceEndParagraph(s);
- m_t << "<h" << s->level() << getDirHtmlClassOfNode(getTextDirByConfig(s->title())) << ">";
+ m_t << "<h" << s->level() << ">";
m_t << "<a class=\"anchor\" id=\"" << s->anchor();
- m_t << "\"></a>" << endl;
- filter(convertCharEntitiesToUTF8(s->title().data()));
+ m_t << "\"></a>\n";
+ filter(convertCharEntitiesToUTF8(s->title()));
m_t << "</h" << s->level() << ">\n";
}
@@ -1480,7 +1464,7 @@ void HtmlDocVisitor::visitPre(DocHtmlList *s)
{
m_t << "<ul" << htmlAttribsToString(s->attribs());
}
- m_t << getDirHtmlClassOfNode(getTextDirByConfig(s)) << ">\n";
+ m_t << ">\n";
}
void HtmlDocVisitor::visitPost(DocHtmlList *s)
@@ -1528,9 +1512,7 @@ void HtmlDocVisitor::visitPost(DocHtmlDescList *dl)
void HtmlDocVisitor::visitPre(DocHtmlDescTitle *dt)
{
if (m_hide) return;
- m_t << "<dt" << htmlAttribsToString(dt->attribs())
- << getDirHtmlClassOfNode(getTextDirByConfig(dt))
- << ">";
+ m_t << "<dt" << htmlAttribsToString(dt->attribs()) << ">";
}
void HtmlDocVisitor::visitPost(DocHtmlDescTitle *)
@@ -1542,9 +1524,7 @@ void HtmlDocVisitor::visitPost(DocHtmlDescTitle *)
void HtmlDocVisitor::visitPre(DocHtmlDescData *dd)
{
if (m_hide) return;
- m_t << "<dd" << htmlAttribsToString(dd->attribs())
- << getDirHtmlClassOfNode(getTextDirByConfig(dd))
- << ">";
+ m_t << "<dd" << htmlAttribsToString(dd->attribs()) << ">";
}
void HtmlDocVisitor::visitPost(DocHtmlDescData *)
@@ -1571,21 +1551,11 @@ void HtmlDocVisitor::visitPre(DocHtmlTable *t)
QCString attrs = htmlAttribsToString(t->attribs());
if (attrs.isEmpty())
{
- m_t << "<table";
- if(t->hasCaption())
- m_t << getDirHtmlClassOfNode(getTextDirByConfig(t->caption()), "doxtable");
- else
- m_t << getDirHtmlClassOfNode(getTextDirByConfig(t), "doxtable");
- m_t << ">\n";
+ m_t << "<table class=\"doxtable\">\n";
}
else
{
- m_t << "<table";
- if (t->hasCaption())
- m_t << getDirHtmlClassOfNode(getTextDirByConfig(t->caption()));
- else
- m_t << getDirHtmlClassOfNode(getTextDirByConfig(t));
- m_t << htmlAttribsToString(t->attribs()) << ">\n";
+ m_t << "<table" << htmlAttribsToString(t->attribs()) << ">\n";
}
}
@@ -1643,7 +1613,7 @@ void HtmlDocVisitor::visitPre(DocInternal *)
{
if (m_hide) return;
//forceEndParagraph(i);
- //m_t << "<p><b>" << theTranslator->trForInternalUseOnly() << "</b></p>" << endl;
+ //m_t << "<p><b>" << theTranslator->trForInternalUseOnly() << "</b></p>\n";
}
void HtmlDocVisitor::visitPost(DocInternal *)
@@ -1677,10 +1647,7 @@ void HtmlDocVisitor::visitPre(DocHtmlHeader *header)
{
if (m_hide) return;
forceEndParagraph(header);
- m_t << "<h" << header->level()
- << htmlAttribsToString(header->attribs())
- << getDirHtmlClassOfNode(getTextDirByConfig(header))
- << ">";
+ m_t << "<h" << header->level() << htmlAttribsToString(header->attribs()) << ">";
}
void HtmlDocVisitor::visitPost(DocHtmlHeader *header)
@@ -1709,7 +1676,7 @@ void HtmlDocVisitor::visitPre(DocImage *img)
{
baseName=baseName.right(baseName.length()-i-1);
}
- if (!inlineImage) m_t << "<div class=\"image\">" << endl;
+ if (!inlineImage) m_t << "<div class=\"image\">\n";
QCString sizeAttribs;
if (!img->width().isEmpty())
{
@@ -1727,10 +1694,10 @@ void HtmlDocVisitor::visitPre(DocImage *img)
HtmlAttrib opt;
opt.name = "style";
opt.value = "pointer-events: none;";
- extraAttribs.append(&opt);
+ extraAttribs.push_back(opt);
}
QCString alt;
- mergeHtmlAttributes(img->attribs(),&extraAttribs);
+ mergeHtmlAttributes(img->attribs(),extraAttribs);
QCString attrs = htmlAttribsToString(extraAttribs,&alt);
QCString src;
if (url.isEmpty())
@@ -1751,7 +1718,7 @@ void HtmlDocVisitor::visitPre(DocImage *img)
}
else
{
- m_t << ">" << alt << "</object>" << endl;
+ m_t << ">" << alt << "</object>\n";
}
}
else
@@ -1774,8 +1741,7 @@ void HtmlDocVisitor::visitPre(DocImage *img)
}
else
{
- m_t << "<div class=\"caption\">" << endl;
- m_t << getHtmlDirEmbeddingChar(getTextDirByConfig(img));
+ m_t << "<div class=\"caption\">\n";
}
}
else if (inlineImage)
@@ -1785,7 +1751,7 @@ void HtmlDocVisitor::visitPre(DocImage *img)
}
else // other format -> skip
{
- pushEnabled();
+ pushHidden(m_hide);
m_hide=TRUE;
}
}
@@ -1809,24 +1775,24 @@ void HtmlDocVisitor::visitPost(DocImage *img)
}
if (!inlineImage) // end <div class="image">
{
- m_t << "</div>" << endl;
+ m_t << "</div>\n";
forceStartParagraph(img);
}
}
else // other format
{
- popEnabled();
+ m_hide = popHidden();
}
}
void HtmlDocVisitor::visitPre(DocDotFile *df)
{
if (m_hide) return;
- m_t << "<div class=\"dotgraph\">" << endl;
+ m_t << "<div class=\"dotgraph\">\n";
writeDotFile(df->file(),df->relPath(),df->context());
if (df->hasCaption())
{
- m_t << "<div class=\"caption\">" << endl;
+ m_t << "<div class=\"caption\">\n";
}
}
@@ -1835,19 +1801,19 @@ void HtmlDocVisitor::visitPost(DocDotFile *df)
if (m_hide) return;
if (df->hasCaption())
{
- m_t << "</div>" << endl;
+ m_t << "</div>\n";
}
- m_t << "</div>" << endl;
+ m_t << "</div>\n";
}
void HtmlDocVisitor::visitPre(DocMscFile *df)
{
if (m_hide) return;
- m_t << "<div class=\"mscgraph\">" << endl;
+ m_t << "<div class=\"mscgraph\">\n";
writeMscFile(df->file(),df->relPath(),df->context());
if (df->hasCaption())
{
- m_t << "<div class=\"caption\">" << endl;
+ m_t << "<div class=\"caption\">\n";
}
}
void HtmlDocVisitor::visitPost(DocMscFile *df)
@@ -1855,19 +1821,19 @@ void HtmlDocVisitor::visitPost(DocMscFile *df)
if (m_hide) return;
if (df->hasCaption())
{
- m_t << "</div>" << endl;
+ m_t << "</div>\n";
}
- m_t << "</div>" << endl;
+ m_t << "</div>\n";
}
void HtmlDocVisitor::visitPre(DocDiaFile *df)
{
if (m_hide) return;
- m_t << "<div class=\"diagraph\">" << endl;
+ m_t << "<div class=\"diagraph\">\n";
writeDiaFile(df->file(),df->relPath(),df->context());
if (df->hasCaption())
{
- m_t << "<div class=\"caption\">" << endl;
+ m_t << "<div class=\"caption\">\n";
}
}
void HtmlDocVisitor::visitPost(DocDiaFile *df)
@@ -1875,9 +1841,9 @@ void HtmlDocVisitor::visitPost(DocDiaFile *df)
if (m_hide) return;
if (df->hasCaption())
{
- m_t << "</div>" << endl;
+ m_t << "</div>\n";
}
- m_t << "</div>" << endl;
+ m_t << "</div>\n";
}
void HtmlDocVisitor::visitPre(DocLink *lnk)
@@ -1929,37 +1895,18 @@ void HtmlDocVisitor::visitPre(DocSecRefList *s)
{
if (m_hide) return;
forceEndParagraph(s);
- m_t << "<div>" << endl;
- m_t << "<ul class=\"multicol\">" << endl;
+ m_t << "<div>\n";
+ m_t << "<ul class=\"multicol\">\n";
}
void HtmlDocVisitor::visitPost(DocSecRefList *s)
{
if (m_hide) return;
- m_t << "</ul>" << endl;
- m_t << "</div>" << endl;
+ m_t << "</ul>\n";
+ m_t << "</div>\n";
forceStartParagraph(s);
}
-//void HtmlDocVisitor::visitPre(DocLanguage *l)
-//{
-// QCString langId = Config_getEnum(OUTPUT_LANGUAGE);
-// if (l->id().lower()!=langId.lower())
-// {
-// pushEnabled();
-// m_hide = TRUE;
-// }
-//}
-//
-//void HtmlDocVisitor::visitPost(DocLanguage *l)
-//{
-// QCString langId = Config_getEnum(OUTPUT_LANGUAGE);
-// if (l->id().lower()!=langId.lower())
-// {
-// popEnabled();
-// }
-//}
-
void HtmlDocVisitor::visitPre(DocParamSect *s)
{
if (m_hide) return;
@@ -1989,16 +1936,16 @@ void HtmlDocVisitor::visitPre(DocParamSect *s)
}
m_t << "<dl class=\"" << className << "\"><dt>";
m_t << heading;
- m_t << "</dt><dd>" << endl;
- m_t << " <table class=\"" << className << "\">" << endl;
+ m_t << "</dt><dd>\n";
+ m_t << " <table class=\"" << className << "\">\n";
}
void HtmlDocVisitor::visitPost(DocParamSect *s)
{
if (m_hide) return;
- m_t << " </table>" << endl;
- m_t << " </dd>" << endl;
- m_t << "</dl>" << endl;
+ m_t << " </table>\n";
+ m_t << " </dd>\n";
+ m_t << "</dl>\n";
forceStartParagraph(s);
}
@@ -2037,41 +1984,35 @@ void HtmlDocVisitor::visitPre(DocParamList *pl)
if (sect && sect->hasTypeSpecifier())
{
m_t << "<td class=\"paramtype\">";
- QListIterator<DocNode> li(pl->paramTypes());
- DocNode *type;
- for (li.toFirst();(type=li.current());++li)
+ for (const auto &type : pl->paramTypes())
{
if (type->kind()==DocNode::Kind_Word)
{
- visit((DocWord*)type);
+ visit((DocWord*)type.get());
}
else if (type->kind()==DocNode::Kind_LinkedWord)
{
- visit((DocLinkedWord*)type);
+ visit((DocLinkedWord*)type.get());
}
else if (type->kind()==DocNode::Kind_Sep)
{
- m_t << "&#160;" << ((DocSeparator *)type)->chars() << "&#160;";
+ m_t << "&#160;" << ((DocSeparator *)type.get())->chars() << "&#160;";
}
}
m_t << "</td>";
}
m_t << "<td class=\"paramname\">";
- //QStrListIterator li(pl->parameters());
- //const char *s;
- QListIterator<DocNode> li(pl->parameters());
- DocNode *param;
bool first=TRUE;
- for (li.toFirst();(param=li.current());++li)
+ for (const auto &param : pl->parameters())
{
if (!first) m_t << ","; else first=FALSE;
if (param->kind()==DocNode::Kind_Word)
{
- visit((DocWord*)param);
+ visit((DocWord*)param.get());
}
else if (param->kind()==DocNode::Kind_LinkedWord)
{
- visit((DocLinkedWord*)param);
+ visit((DocLinkedWord*)param.get());
}
}
m_t << "</td><td>";
@@ -2081,7 +2022,7 @@ void HtmlDocVisitor::visitPost(DocParamList *)
{
//printf("DocParamList::visitPost\n");
if (m_hide) return;
- m_t << "</td></tr>" << endl;
+ m_t << "</td></tr>\n";
}
void HtmlDocVisitor::visitPre(DocXRefItem *x)
@@ -2093,8 +2034,7 @@ void HtmlDocVisitor::visitPre(DocXRefItem *x)
bool anonymousEnum = x->file()=="@";
if (!anonymousEnum)
{
- m_t << "<dl" << getDirHtmlClassOfNode(getTextDirByConfig(x), x->key())
- << "><dt><b><a class=\"el\" href=\""
+ m_t << "<dl class=\"" << x->key() << "\"><dt><b><a class=\"el\" href=\""
<< x->relPath() << addHtmlExtensionIfMissing(x->file())
<< "#" << x->anchor() << "\">";
}
@@ -2112,14 +2052,14 @@ void HtmlDocVisitor::visitPost(DocXRefItem *x)
{
if (m_hide) return;
if (x->title().isEmpty()) return;
- m_t << "</dd></dl>" << endl;
+ m_t << "</dd></dl>\n";
forceStartParagraph(x);
}
void HtmlDocVisitor::visitPre(DocInternalRef *ref)
{
if (m_hide) return;
- startLink(0,ref->file(),ref->relPath(),ref->anchor());
+ startLink(QCString(),ref->file(),ref->relPath(),ref->anchor());
}
void HtmlDocVisitor::visitPost(DocInternalRef *)
@@ -2142,22 +2082,13 @@ void HtmlDocVisitor::visitPre(DocHtmlBlockQuote *b)
if (m_hide) return;
forceEndParagraph(b);
QCString attrs = htmlAttribsToString(b->attribs());
- if (attrs.isEmpty())
- {
- m_t << "<blockquote" << getDirHtmlClassOfNode(getTextDirByConfig(b), "doxtable")
- << ">\n";
- }
- else
- {
- m_t << "<blockquote" << getDirHtmlClassOfNode(getTextDirByConfig(b))
- << htmlAttribsToString(b->attribs()) << ">\n";
- }
+ m_t << "<blockquote class=\"doxtable\"" << htmlAttribsToString(b->attribs()) << ">\n";
}
void HtmlDocVisitor::visitPost(DocHtmlBlockQuote *b)
{
if (m_hide) return;
- m_t << "</blockquote>" << endl;
+ m_t << "</blockquote>\n";
forceStartParagraph(b);
}
@@ -2171,9 +2102,9 @@ void HtmlDocVisitor::visitPre(DocVhdlFlow *vf)
m_t << "<p>";
m_t << "flowchart: " ; // TODO: translate me
m_t << "<a href=\"";
- m_t << fname.data();
+ m_t << fname;
m_t << ".svg\">";
- m_t << VhdlDocGen::getFlowMember()->name().data();
+ m_t << VhdlDocGen::getFlowMember()->name();
m_t << "</a>";
if (vf->hasCaption())
{
@@ -2204,10 +2135,10 @@ void HtmlDocVisitor::visitPost(DocParBlock *)
-void HtmlDocVisitor::filter(const char *str)
+void HtmlDocVisitor::filter(const QCString &str)
{
- if (str==0) return;
- const char *p=str;
+ if (str.isEmpty()) return;
+ const char *p=str.data();
char c;
while (*p)
{
@@ -2241,10 +2172,10 @@ void HtmlDocVisitor::filter(const char *str)
/// Escape basic entities to produce a valid CDATA attribute value,
/// assume that the outer quoting will be using the double quote &quot;
-void HtmlDocVisitor::filterQuotedCdataAttr(const char* str)
+void HtmlDocVisitor::filterQuotedCdataAttr(const QCString &str)
{
- if (str==0) return;
- const char *p=str;
+ if (str.isEmpty()) return;
+ const char *p=str.data();
char c;
while (*p)
{
@@ -2281,7 +2212,7 @@ void HtmlDocVisitor::startLink(const QCString &ref,const QCString &file,
const QCString &relPath,const QCString &anchor,
const QCString &tooltip)
{
- //printf("HtmlDocVisitor: file=%s anchor=%s\n",file.data(),anchor.data());
+ //printf("HtmlDocVisitor: file=%s anchor=%s\n",qPrint(file),qPrint(anchor));
if (!ref.isEmpty()) // link to entity imported via tag file
{
m_t << "<a class=\"elRef\" ";
@@ -2308,19 +2239,6 @@ void HtmlDocVisitor::endLink()
m_t << "</a>";
}
-void HtmlDocVisitor::pushEnabled()
-{
- m_enabled.push(new bool(m_hide));
-}
-
-void HtmlDocVisitor::popEnabled()
-{
- bool *v=m_enabled.pop();
- ASSERT(v!=0);
- m_hide = *v;
- delete v;
-}
-
void HtmlDocVisitor::writeDotFile(const QCString &fn,const QCString &relPath,
const QCString &context)
{
@@ -2382,7 +2300,7 @@ void HtmlDocVisitor::writeDiaFile(const QCString &fileName,
QCString outDir = Config_getString(HTML_OUTPUT);
writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP);
- m_t << "<img src=\"" << relPath << baseName << ".png" << "\" />" << endl;
+ m_t << "<img src=\"" << relPath << baseName << ".png" << "\" />\n";
}
void HtmlDocVisitor::writePlantUMLFile(const QCString &fileName,
@@ -2403,16 +2321,16 @@ void HtmlDocVisitor::writePlantUMLFile(const QCString &fileName,
QCString imgExt = getDotImageExtension();
if (imgExt=="svg")
{
- PlantumlManager::instance()->generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_SVG);
- //m_t << "<iframe scrolling=\"no\" frameborder=\"0\" src=\"" << relPath << baseName << ".svg" << "\" />" << endl;
+ PlantumlManager::instance().generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_SVG);
+ //m_t << "<iframe scrolling=\"no\" frameborder=\"0\" src=\"" << relPath << baseName << ".svg" << "\" />\n";
//m_t << "<p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p>";
- //m_t << "</iframe>" << endl;
- m_t << "<object type=\"image/svg+xml\" data=\"" << relPath << baseName << ".svg\"></object>" << endl;
+ //m_t << "</iframe>\n";
+ m_t << "<object type=\"image/svg+xml\" data=\"" << relPath << baseName << ".svg\"></object>\n";
}
else
{
- PlantumlManager::instance()->generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_BITMAP);
- m_t << "<img src=\"" << relPath << baseName << ".png" << "\" />" << endl;
+ PlantumlManager::instance().generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_BITMAP);
+ m_t << "<img src=\"" << relPath << baseName << ".png" << "\" />\n";
}
}
@@ -2428,7 +2346,7 @@ static bool insideStyleChangeThatIsOutsideParagraph(DocPara *para,int nodeIndex)
bool styleOutsideParagraph=FALSE;
while (nodeIndex>=0 && !styleOutsideParagraph)
{
- DocNode *n = para->children().at(nodeIndex);
+ DocNode *n = para->children().at(nodeIndex).get();
if (n->kind()==DocNode::Kind_StyleChange)
{
DocStyleChange *sc = (DocStyleChange*)n;
@@ -2462,15 +2380,18 @@ void HtmlDocVisitor::forceEndParagraph(DocNode *n)
if (n->parent() && n->parent()->kind()==DocNode::Kind_Para)
{
DocPara *para = (DocPara*)n->parent();
- int nodeIndex = para->children().findRef(n);
+ const DocNodeList &children = para->children();
+ auto it = std::find_if(children.begin(),children.end(),[n](const auto &np) { return np.get()==n; });
+ if (it==children.end()) return;
+ int nodeIndex = static_cast<int>(it - children.begin());
nodeIndex--;
if (nodeIndex<0) return; // first node in paragraph
- while (nodeIndex>=0 && isInvisibleNode(para->children().at(nodeIndex)))
+ while (nodeIndex>=0 && isInvisibleNode(children.at(nodeIndex).get()))
{
- nodeIndex--;
+ nodeIndex--;
}
if (nodeIndex<0) return; // first visible node in paragraph
- n = para->children().at(nodeIndex);
+ n = children.at(nodeIndex).get();
if (mustBeOutsideParagraph(n)) return; // previous node already outside paragraph context
nodeIndex--;
bool styleOutsideParagraph=insideStyleChangeThatIsOutsideParagraph(para,nodeIndex);
@@ -2495,19 +2416,22 @@ void HtmlDocVisitor::forceStartParagraph(DocNode *n)
if (n->parent() && n->parent()->kind()==DocNode::Kind_Para) // if we are inside a paragraph
{
DocPara *para = (DocPara*)n->parent();
- int nodeIndex = para->children().findRef(n);
- int numNodes = para->children().count();
+ const DocNodeList &children = para->children();
+ auto it = std::find_if(children.begin(),children.end(),[n](const auto &np) { return np.get()==n; });
+ if (it==children.end()) return;
+ int nodeIndex = static_cast<int>(it - children.begin());
+ int numNodes = static_cast<int>(para->children().size());
bool styleOutsideParagraph=insideStyleChangeThatIsOutsideParagraph(para,nodeIndex);
if (styleOutsideParagraph) return;
nodeIndex++;
if (nodeIndex==numNodes) return; // last node
- while (nodeIndex<numNodes && isInvisibleNode(para->children().at(nodeIndex)))
+ while (nodeIndex<numNodes && isInvisibleNode(para->children().at(nodeIndex).get()))
{
nodeIndex++;
}
if (nodeIndex<numNodes)
{
- n = para->children().at(nodeIndex);
+ n = para->children().at(nodeIndex).get();
if (mustBeOutsideParagraph(n)) return; // next element also outside paragraph
}
else
@@ -2522,10 +2446,7 @@ void HtmlDocVisitor::forceStartParagraph(DocNode *n)
if (isFirst && isLast) needsTag = FALSE;
//printf("forceStart first=%d last=%d needsTag=%d\n",isFirst,isLast,needsTag);
- if (needsTag)
- m_t << "<p" << getDirHtmlClassOfNode(getTextDirByConfig(para, nodeIndex)) << ">";
- else
- m_t << getHtmlDirEmbeddingChar(getTextDirByConfig(para, nodeIndex));
+ if (needsTag) m_t << "<p>";
}
}