/******************************************************************************
*
*
*
*
* Copyright (C) 1997-2015 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation under the terms of the GNU General Public License is hereby
* granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
* Documents produced by Doxygen are derivative works derived from the
* input used in their production; they are not affected by this license.
*
*/
#ifndef _PRINTDOCVISITOR_H
#define _PRINTDOCVISITOR_H
#include "docvisitor.h"
#include "htmlentity.h"
#include "emoji.h"
#include "message.h"
/*! Concrete visitor implementation for pretty printing */
class PrintDocVisitor : public DocVisitor
{
public:
PrintDocVisitor() : DocVisitor(DocVisitor_Other), m_indent(0),
m_needsEnter(FALSE), m_insidePre(FALSE) {}
//--------------------------------------
void visit(DocWord *w)
{
indent_leaf();
printf("%s",qPrint(w->word()));
}
void visit(DocLinkedWord *w)
{
indent_leaf();
printf("%s",qPrint(w->word()));
}
void visit(DocWhiteSpace *w)
{
indent_leaf();
if (m_insidePre)
{
printf("%s",qPrint(w->chars()));
}
else
{
printf(" ");
}
}
void visit(DocSymbol *s)
{
indent_leaf();
const char *res = HtmlEntityMapper::instance()->utf8(s->symbol(),TRUE);
if (res)
{
printf("%s",res);
}
else
{
printf("print: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
}
}
void visit(DocEmoji *s)
{
indent_leaf();
const char *res = EmojiEntityMapper::instance()->name(s->index());
if (res)
{
printf("%s",res);
}
else
{
printf("print: non supported emoji found: %s\n",qPrint(s->name()));
}
}
void visit(DocURL *u)
{
indent_leaf();
printf("%s",qPrint(u->url()));
}
void visit(DocLineBreak *)
{
indent_leaf();
printf(" ");
}
void visit(DocHorRuler *)
{
indent_leaf();
printf("
");
}
void visit(DocStyleChange *s)
{
indent_leaf();
switch (s->style())
{
case DocStyleChange::Bold:
if (s->enable()) printf(""); else printf("");
break;
case DocStyleChange::S:
if (s->enable()) printf(""); else printf("");
break;
case DocStyleChange::Strike:
if (s->enable()) printf(""); else printf("");
break;
case DocStyleChange::Del:
if (s->enable()) printf(""); else printf("");
break;
case DocStyleChange::Underline:
if (s->enable()) printf(""); else printf("");
break;
case DocStyleChange::Ins:
if (s->enable()) printf(""); else printf("");
break;
case DocStyleChange::Italic:
if (s->enable()) printf(""); else printf("");
break;
case DocStyleChange::Code:
if (s->enable()) printf(""); else printf("");
break;
case DocStyleChange::Subscript:
if (s->enable()) printf(""); else printf("");
break;
case DocStyleChange::Superscript:
if (s->enable()) printf(""); else printf("");
break;
case DocStyleChange::Center:
if (s->enable()) printf("
"); else printf("
");
break;
case DocStyleChange::Small:
if (s->enable()) printf(""); else printf("");
break;
case DocStyleChange::Preformatted:
if (s->enable()) printf("
"); else printf("
");
break;
case DocStyleChange::Div:
if (s->enable()) printf("
"); else printf("
");
break;
case DocStyleChange::Span:
if (s->enable()) printf(""); else printf("");
break;
}
}
void visit(DocVerbatim *s)
{
indent_leaf();
switch(s->type())
{
case DocVerbatim::Code: printf(""); break;
case DocVerbatim::Verbatim: printf(""); break;
case DocVerbatim::HtmlOnly: printf(""); break;
case DocVerbatim::RtfOnly: printf(""); break;
case DocVerbatim::ManOnly: printf(""); break;
case DocVerbatim::LatexOnly: printf(""); break;
case DocVerbatim::XmlOnly: printf(""); break;
case DocVerbatim::DocbookOnly: printf(""); break;
case DocVerbatim::Dot: printf(""); break;
case DocVerbatim::Msc: printf(""); break;
case DocVerbatim::PlantUML: printf(""); break;
}
printf("%s",qPrint(s->text()));
switch(s->type())
{
case DocVerbatim::Code: printf(""); break;
case DocVerbatim::Verbatim: printf(""); break;
case DocVerbatim::HtmlOnly: printf(""); break;
case DocVerbatim::RtfOnly: printf(""); break;
case DocVerbatim::ManOnly: printf(""); break;
case DocVerbatim::LatexOnly: printf(""); break;
case DocVerbatim::XmlOnly: printf(""); break;
case DocVerbatim::DocbookOnly: printf(""); break;
case DocVerbatim::Dot: printf(""); break;
case DocVerbatim::Msc: printf(""); break;
case DocVerbatim::PlantUML: printf(""); break;
}
}
void visit(DocAnchor *a)
{
indent_leaf();
printf("",qPrint(a->anchor()));
}
void visit(DocInclude *inc)
{
indent_leaf();
printf("file()));
switch(inc->type())
{
case DocInclude::Include: printf("include"); break;
case DocInclude::IncWithLines: printf("incwithlines"); break;
case DocInclude::DontInclude: printf("dontinclude"); break;
case DocInclude::DontIncWithLines: printf("dontinwithlines"); break;
case DocInclude::HtmlInclude:
printf("htmlinclude");
if (inc->isBlock()) printf(" block=\"yes\"");
break;
case DocInclude::LatexInclude: printf("latexinclude"); break;
case DocInclude::RtfInclude: printf("rtfinclude"); break;
case DocInclude::DocbookInclude: printf("docbookinclude"); break;
case DocInclude::ManInclude: printf("maninclude"); break;
case DocInclude::XmlInclude: printf("xmlinclude"); break;
case DocInclude::VerbInclude: printf("verbinclude"); break;
case DocInclude::Snippet: printf("snippet"); break;
case DocInclude::SnipWithLines: printf("snipwithlines"); break;
case DocInclude::SnippetDoc:
case DocInclude::IncludeDoc:
err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s"
"Please create a bug report\n",__FILE__);
break;
}
printf("\"/>");
}
void visit(DocIncOperator *op)
{
indent_leaf();
printf("pattern()));
switch(op->type())
{
case DocIncOperator::Line: printf("line"); break;
case DocIncOperator::Skip: printf("skip"); break;
case DocIncOperator::SkipLine: printf("skipline"); break;
case DocIncOperator::Until: printf("until"); break;
}
printf("\"/>");
}
void visit(DocFormula *f)
{
indent_leaf();
printf("",qPrint(f->name()),qPrint(f->text()));
}
void visit(DocIndexEntry *i)
{
indent_leaf();
printf("%sentry()));
}
void visit(DocSimpleSectSep *)
{
indent_leaf();
printf("");
}
void visit(DocCite *cite)
{
indent_leaf();
printf("\n",
qPrint(cite->ref()),qPrint(cite->file()),qPrint(cite->anchor()),
qPrint(cite->text()));
}
//--------------------------------------
void visitPre(DocAutoList *l)
{
indent_pre();
if (l->isEnumList())
{
printf("\n");
}
else
{
printf("