diff options
Diffstat (limited to 'src/docbookvisitor.cpp')
-rw-r--r-- | src/docbookvisitor.cpp | 614 |
1 files changed, 501 insertions, 113 deletions
diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index d3af3ac..d35e6ad 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -34,58 +34,99 @@ #include "msc.h" #include "dia.h" #include "htmlentity.h" +#include "emoji.h" #include "plantuml.h" -static void visitPreStart(FTextStream &t, const bool hasCaption, QCString name, QCString width, QCString height) +#if 0 +#define DB_VIS_C DB_VIS_C1(m_t) +#define DB_VIS_C1(x) x << "<!-- DB_VIS_C " << __LINE__ << " -->\n"; +#define DB_VIS_C2(y) DB_VIS_C2a(m_t,y) +#define DB_VIS_C2a(x,y) x << "<!-- DB_VIS_C " << __LINE__ << " " << y << " -->\n"; +#else +#define DB_VIS_C +#define DB_VIS_C1(x) +#define DB_VIS_C2(y) +#define DB_VIS_C2a(x,y) +#endif + +void DocbookDocVisitor::visitCaption(const QList<DocNode> &children) +{ + QListIterator<DocNode> cli(children); + DocNode *n; + for (cli.toFirst();(n=cli.current());++cli) n->accept(this); +} + +void DocbookDocVisitor::visitPreStart(FTextStream &t, + const QList<DocNode> &children, + bool hasCaption, + const QCString &name, + const QCString &width, + const QCString &height, + bool inlineImage) { - QCString tmpStr; - t << " <figure>" << endl; - t << " <title></title>" << endl; + if (hasCaption && !inlineImage) + { + t << " <figure>" << endl; + t << " <title>" << endl; + visitCaption(children); + t << " </title>" << endl; + } + else + { + t << " <informalfigure>" << endl; + } t << " <mediaobject>" << endl; t << " <imageobject>" << endl; t << " <imagedata"; if (!width.isEmpty()) { - t << " width=\"" << convertToXML(width) << "\""; + t << " width=\"" << convertToDocBook(width) << "\""; } else { - t << " width=\"50%\""; + if (!height.isEmpty() && !inlineImage) t << " width=\"50%\""; } if (!height.isEmpty()) { - t << " depth=\"" << convertToXML(tmpStr) << "\""; + t << " depth=\"" << convertToDocBook(height) << "\""; } - t << " align=\"center\" valign=\"middle\" scalefit=\"1\" fileref=\"" << name << "\">"; + t << " align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\"" << name << "\">"; t << "</imagedata>" << endl; t << " </imageobject>" << endl; - if (hasCaption) + if (hasCaption && !inlineImage) { - t << " <caption>" << endl; + t << " <!--" << endl; // Needed for general formatting with title for other formats } } -static void visitPostEnd(FTextStream &t, const bool hasCaption) +void DocbookDocVisitor::visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage) { t << endl; - if (hasCaption) + if (hasCaption && !inlineImage) { - t << " </caption>" << endl; + t << " -->" << endl; // Needed for general formatting with title for other formats } t << " </mediaobject>" << endl; - t << " </figure>" << endl; -} - -static void visitCaption(DocbookDocVisitor *parent, QList<DocNode> children) -{ - QListIterator<DocNode> cli(children); - DocNode *n; - for (cli.toFirst();(n=cli.current());++cli) n->accept(parent); + if (hasCaption && !inlineImage) + { + t << " </figure>" << endl; + } + else + { + t << " </informalfigure>" << endl; + } } DocbookDocVisitor::DocbookDocVisitor(FTextStream &t,CodeOutputInterface &ci) : DocVisitor(DocVisitor_Docbook), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) { +DB_VIS_C + // m_t << "<section>" << endl; +} +DocbookDocVisitor::~DocbookDocVisitor() +{ +DB_VIS_C + // m_t << "</section>" << endl; } //-------------------------------------- @@ -94,12 +135,14 @@ DocbookDocVisitor::DocbookDocVisitor(FTextStream &t,CodeOutputInterface &ci) void DocbookDocVisitor::visit(DocWord *w) { +DB_VIS_C if (m_hide) return; filter(w->word()); } void DocbookDocVisitor::visit(DocLinkedWord *w) { +DB_VIS_C if (m_hide) return; startLink(w->file(),w->anchor()); filter(w->word()); @@ -108,6 +151,7 @@ void DocbookDocVisitor::visit(DocLinkedWord *w) void DocbookDocVisitor::visit(DocWhiteSpace *w) { +DB_VIS_C if (m_hide) return; if (m_insidePre) { @@ -121,6 +165,7 @@ void DocbookDocVisitor::visit(DocWhiteSpace *w) void DocbookDocVisitor::visit(DocSymbol *s) { +DB_VIS_C if (m_hide) return; const char *res = HtmlEntityMapper::instance()->docbook(s->symbol()); if (res) @@ -133,8 +178,24 @@ void DocbookDocVisitor::visit(DocSymbol *s) } } +void DocbookDocVisitor::visit(DocEmoji *s) +{ +DB_VIS_C + if (m_hide) return; + const char *res = EmojiEntityMapper::instance()->unicode(s->index()); + if (res) + { + m_t << res; + } + else + { + m_t << s->name(); + } +} + void DocbookDocVisitor::visit(DocURL *u) { +DB_VIS_C if (m_hide) return; m_t << "<link xlink:href=\""; if (u->isEmail()) m_t << "mailto:"; @@ -146,12 +207,16 @@ void DocbookDocVisitor::visit(DocURL *u) void DocbookDocVisitor::visit(DocLineBreak *) { +DB_VIS_C if (m_hide) return; - m_t << endl << "<literallayout>\n</literallayout>" << endl; + m_t << endl << "<literallayout> 
</literallayout>" << endl; + // gives nicer results but gives problems as it is not allowed in <pare> and also problems with dblatex + // m_t << endl << "<sbr/>" << endl; } void DocbookDocVisitor::visit(DocHorRuler *) { +DB_VIS_C if (m_hide) return; m_t << "<informaltable frame='bottom'><tgroup cols='1'><colspec align='center'/><tbody><row><entry align='center'>\n"; m_t << "</entry></row></tbody></tgroup></informaltable>\n"; @@ -159,6 +224,7 @@ void DocbookDocVisitor::visit(DocHorRuler *) void DocbookDocVisitor::visit(DocStyleChange *s) { +DB_VIS_C if (m_hide) return; switch (s->style()) { @@ -205,6 +271,7 @@ void DocbookDocVisitor::visit(DocStyleChange *s) void DocbookDocVisitor::visit(DocVerbatim *s) { +DB_VIS_C if (m_hide) return; SrcLangExt langExt = getLanguageFromFileName(m_langExt); switch(s->type()) @@ -217,9 +284,9 @@ void DocbookDocVisitor::visit(DocVerbatim *s) m_t << "</computeroutput></literallayout>"; break; case DocVerbatim::Verbatim: - m_t << "<literallayout>"; + m_t << "<literallayout><computeroutput>"; filter(s->text()); - m_t << "</literallayout>"; + m_t << "</computeroutput></literallayout>"; break; case DocVerbatim::HtmlOnly: break; @@ -232,7 +299,6 @@ void DocbookDocVisitor::visit(DocVerbatim *s) case DocVerbatim::XmlOnly: break; case DocVerbatim::DocbookOnly: - break; m_t << s->text(); break; case DocVerbatim::Dot: @@ -304,12 +370,14 @@ void DocbookDocVisitor::visit(DocVerbatim *s) void DocbookDocVisitor::visit(DocAnchor *anc) { +DB_VIS_C if (m_hide) return; - m_t << "<anchor id=\"" << anc->file() << "_1" << anc->anchor() << "\"/>"; + m_t << "<anchor xml:id=\"_" << stripPath(anc->file()) << "_1" << anc->anchor() << "\"/>"; } void DocbookDocVisitor::visit(DocInclude *inc) { +DB_VIS_C if (m_hide) return; SrcLangExt langExt = getLanguageFromFileName(inc->extension()); switch(inc->type()) @@ -345,9 +413,9 @@ void DocbookDocVisitor::visit(DocInclude *inc) case DocInclude::LatexInclude: break; case DocInclude::VerbInclude: - m_t << "<verbatim>"; + m_t << "<literallayout>"; filter(inc->text()); - m_t << "</verbatim>"; + m_t << "</literallayout>"; break; case DocInclude::Snippet: m_t << "<literallayout><computeroutput>"; @@ -393,6 +461,7 @@ void DocbookDocVisitor::visit(DocInclude *inc) void DocbookDocVisitor::visit(DocIncOperator *op) { +DB_VIS_C if (op->isFirst()) { if (!m_hide) @@ -429,27 +498,37 @@ void DocbookDocVisitor::visit(DocIncOperator *op) void DocbookDocVisitor::visit(DocFormula *f) { +DB_VIS_C if (m_hide) return; - m_t << "<equation><title>" << f->name() << "</title>"; - filter(f->text()); - m_t << "</equation>"; + + if (f->isInline()) m_t << "<inlinemediaobject>" << endl; + else m_t << " <mediaobject>" << endl; + m_t << " <imageobject>" << endl; + m_t << " <imagedata "; + m_t << "align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\"" << f->relPath() << f->name() << ".png\"/>" << endl; + m_t << " </imageobject>" << endl; + if (f->isInline()) m_t << "</inlinemediaobject>" << endl; + else m_t << " </mediaobject>" << endl; } void DocbookDocVisitor::visit(DocIndexEntry *ie) { +DB_VIS_C if (m_hide) return; - m_t << "<indexentry><primaryie>" << endl; + m_t << "<indexterm><primary>"; filter(ie->entry()); - m_t << "</primaryie><secondaryie></secondaryie></indexentry>" << endl; + m_t << "</primary></indexterm>" << endl; } void DocbookDocVisitor::visit(DocSimpleSectSep *) { - m_t << "<simplesect/>"; +DB_VIS_C + // m_t << "<simplesect/>"; } void DocbookDocVisitor::visit(DocCite *cite) { +DB_VIS_C if (m_hide) return; if (!cite->file().isEmpty()) startLink(cite->file(),cite->anchor()); filter(cite->text()); @@ -462,6 +541,7 @@ void DocbookDocVisitor::visit(DocCite *cite) void DocbookDocVisitor::visitPre(DocAutoList *l) { +DB_VIS_C if (m_hide) return; if (l->isEnumList()) { @@ -475,6 +555,7 @@ void DocbookDocVisitor::visitPre(DocAutoList *l) void DocbookDocVisitor::visitPost(DocAutoList *l) { +DB_VIS_C if (m_hide) return; if (l->isEnumList()) { @@ -488,18 +569,21 @@ void DocbookDocVisitor::visitPost(DocAutoList *l) void DocbookDocVisitor::visitPre(DocAutoListItem *) { +DB_VIS_C if (m_hide) return; m_t << "<listitem>"; } void DocbookDocVisitor::visitPost(DocAutoListItem *) { +DB_VIS_C if (m_hide) return; m_t << "</listitem>"; } void DocbookDocVisitor::visitPre(DocPara *) { +DB_VIS_C if (m_hide) return; m_t << endl; m_t << "<para>"; @@ -507,6 +591,7 @@ void DocbookDocVisitor::visitPre(DocPara *) void DocbookDocVisitor::visitPost(DocPara *) { +DB_VIS_C if (m_hide) return; m_t << "</para>"; m_t << endl; @@ -514,16 +599,19 @@ void DocbookDocVisitor::visitPost(DocPara *) void DocbookDocVisitor::visitPre(DocRoot *) { +DB_VIS_C //m_t << "<hr><h4><font color=\"red\">New parser:</font></h4>\n"; } void DocbookDocVisitor::visitPost(DocRoot *) { +DB_VIS_C //m_t << "<hr><h4><font color=\"red\">Old parser:</font></h4>\n"; } void DocbookDocVisitor::visitPre(DocSimpleSect *s) { +DB_VIS_C if (m_hide) return; switch(s->type()) { @@ -534,7 +622,7 @@ void DocbookDocVisitor::visitPre(DocSimpleSect *s) } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trSeeAlso()) << ": </title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trSeeAlso()) << ": </title>" << endl; } break; case DocSimpleSect::Return: @@ -544,7 +632,7 @@ void DocbookDocVisitor::visitPre(DocSimpleSect *s) } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trReturns()) << ": </title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trReturns()) << ": </title>" << endl; } break; case DocSimpleSect::Author: @@ -554,7 +642,7 @@ void DocbookDocVisitor::visitPre(DocSimpleSect *s) } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trAuthor(TRUE, TRUE)) << ": </title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trAuthor(TRUE, TRUE)) << ": </title>" << endl; } break; case DocSimpleSect::Authors: @@ -564,7 +652,7 @@ void DocbookDocVisitor::visitPre(DocSimpleSect *s) } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trAuthor(TRUE, FALSE)) << ": </title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trAuthor(TRUE, FALSE)) << ": </title>" << endl; } break; case DocSimpleSect::Version: @@ -574,7 +662,7 @@ void DocbookDocVisitor::visitPre(DocSimpleSect *s) } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trVersion()) << ": </title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trVersion()) << ": </title>" << endl; } break; case DocSimpleSect::Since: @@ -584,7 +672,7 @@ void DocbookDocVisitor::visitPre(DocSimpleSect *s) } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trSince()) << ": </title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trSince()) << ": </title>" << endl; } break; case DocSimpleSect::Date: @@ -594,27 +682,27 @@ void DocbookDocVisitor::visitPre(DocSimpleSect *s) } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trDate()) << ": </title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trDate()) << ": </title>" << endl; } break; case DocSimpleSect::Note: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trNote() << ": </title>" << endl; + m_t << "<note><title>" << theTranslator->trNote() << ": </title>" << endl; } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trNote()) << ": </title>" << endl; + m_t << "<note><title>" << convertToDocBook(theTranslator->trNote()) << ": </title>" << endl; } break; case DocSimpleSect::Warning: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trWarning() << ": </title>" << endl; + m_t << "<warning><title>" << theTranslator->trWarning() << ": </title>" << endl; } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trWarning()) << ": </title>" << endl; + m_t << "<warning><title>" << convertToDocBook(theTranslator->trWarning()) << ": </title>" << endl; } break; case DocSimpleSect::Pre: @@ -624,7 +712,7 @@ void DocbookDocVisitor::visitPre(DocSimpleSect *s) } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trPrecondition()) << ": </title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trPrecondition()) << ": </title>" << endl; } break; case DocSimpleSect::Post: @@ -634,7 +722,7 @@ void DocbookDocVisitor::visitPre(DocSimpleSect *s) } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trPostcondition()) << ": </title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trPostcondition()) << ": </title>" << endl; } break; case DocSimpleSect::Copyright: @@ -644,7 +732,7 @@ void DocbookDocVisitor::visitPre(DocSimpleSect *s) } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trCopyright()) << ": </title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trCopyright()) << ": </title>" << endl; } break; case DocSimpleSect::Invar: @@ -654,85 +742,121 @@ void DocbookDocVisitor::visitPre(DocSimpleSect *s) } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trInvariant()) << ": </title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trInvariant()) << ": </title>" << endl; } break; case DocSimpleSect::Remark: + // <remark> is miising the <title> possibility if (m_insidePre) { m_t << "<formalpara><title>" << theTranslator->trRemarks() << ": </title>" << endl; } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trRemarks()) << ": </title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trRemarks()) << ": </title>" << endl; } break; case DocSimpleSect::Attention: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trAttention() << ": </title>" << endl; + m_t << "<caution><title>" << theTranslator->trAttention() << ": </title>" << endl; } else { - m_t << "<formalpara><title>" << convertToXML(theTranslator->trAttention()) << ": </title>" << endl; + m_t << "<caution><title>" << convertToDocBook(theTranslator->trAttention()) << ": </title>" << endl; } break; case DocSimpleSect::User: - m_t << "<formalpara><title></title>" << endl; + if (s->hasTitle()) + m_t << "<formalpara>" << endl; + else + m_t << "<para>" << endl; break; case DocSimpleSect::Rcs: - m_t << "<formalpara><title></title>" << endl; + case DocSimpleSect::Unknown: + m_t << "<para>" << endl; break; - case DocSimpleSect::Unknown: m_t << "<formalpara><title></title>" << endl; break; } } -void DocbookDocVisitor::visitPost(DocSimpleSect *) +void DocbookDocVisitor::visitPost(DocSimpleSect *s) { +DB_VIS_C if (m_hide) return; - m_t << "</formalpara>" << endl; + switch(s->type()) + { + case DocSimpleSect::Rcs: + case DocSimpleSect::Unknown: + m_t << "</para>" << endl; + break; + case DocSimpleSect::User: + if (s->hasTitle()) + m_t << "</formalpara>" << endl; + else + m_t << "</para>" << endl; + break; + case DocSimpleSect::Note: + m_t << "</note>" << endl; + break; + case DocSimpleSect::Attention: + m_t << "</caution>" << endl; + break; + case DocSimpleSect::Warning: + m_t << "</warning>" << endl; + break; + default: + m_t << "</formalpara>" << endl; + break; + } } -void DocbookDocVisitor::visitPre(DocTitle *) +void DocbookDocVisitor::visitPre(DocTitle *t) { +DB_VIS_C if (m_hide) return; - m_t << "<title>"; + if (t->hasTitle()) m_t << "<title>"; } -void DocbookDocVisitor::visitPost(DocTitle *) +void DocbookDocVisitor::visitPost(DocTitle *t) { +DB_VIS_C if (m_hide) return; - m_t << "</title>"; + if (t->hasTitle()) m_t << "</title>"; } void DocbookDocVisitor::visitPre(DocSimpleList *) { +DB_VIS_C if (m_hide) return; m_t << "<itemizedlist>\n"; } void DocbookDocVisitor::visitPost(DocSimpleList *) { +DB_VIS_C if (m_hide) return; m_t << "</itemizedlist>\n"; } void DocbookDocVisitor::visitPre(DocSimpleListItem *) { +DB_VIS_C if (m_hide) return; m_t << "<listitem>"; } void DocbookDocVisitor::visitPost(DocSimpleListItem *) { +DB_VIS_C if (m_hide) return; m_t << "</listitem>\n"; } void DocbookDocVisitor::visitPre(DocSection *s) { +DB_VIS_C if (m_hide) return; - m_t << "<section xml:id=\"" << s->file(); + m_t << "<section xml:id=\"_" << stripPath(s->file()); if (!s->anchor().isEmpty()) m_t << "_1" << s->anchor(); m_t << "\">" << endl; m_t << "<title>"; @@ -742,11 +866,13 @@ void DocbookDocVisitor::visitPre(DocSection *s) void DocbookDocVisitor::visitPost(DocSection *) { +DB_VIS_C m_t << "</section>\n"; } void DocbookDocVisitor::visitPre(DocHtmlList *s) { +DB_VIS_C if (m_hide) return; if (s->type()==DocHtmlList::Ordered) m_t << "<orderedlist>\n"; @@ -756,6 +882,7 @@ void DocbookDocVisitor::visitPre(DocHtmlList *s) void DocbookDocVisitor::visitPost(DocHtmlList *s) { +DB_VIS_C if (m_hide) return; if (s->type()==DocHtmlList::Ordered) m_t << "</orderedlist>\n"; @@ -765,143 +892,277 @@ void DocbookDocVisitor::visitPost(DocHtmlList *s) void DocbookDocVisitor::visitPre(DocHtmlListItem *) { +DB_VIS_C if (m_hide) return; m_t << "<listitem>\n"; } void DocbookDocVisitor::visitPost(DocHtmlListItem *) { +DB_VIS_C if (m_hide) return; m_t << "</listitem>\n"; } void DocbookDocVisitor::visitPre(DocHtmlDescList *) { +DB_VIS_C if (m_hide) return; m_t << "<variablelist>\n"; } void DocbookDocVisitor::visitPost(DocHtmlDescList *) { +DB_VIS_C if (m_hide) return; m_t << "</variablelist>\n"; } void DocbookDocVisitor::visitPre(DocHtmlDescTitle *) { +DB_VIS_C if (m_hide) return; m_t << "<varlistentry><term>"; } void DocbookDocVisitor::visitPost(DocHtmlDescTitle *) { +DB_VIS_C if (m_hide) return; m_t << "</term>\n"; } void DocbookDocVisitor::visitPre(DocHtmlDescData *) { +DB_VIS_C if (m_hide) return; m_t << "<listitem>"; } void DocbookDocVisitor::visitPost(DocHtmlDescData *) { +DB_VIS_C if (m_hide) return; m_t << "</listitem></varlistentry>\n"; } +static int colCnt = 0; +static bool bodySet = FALSE; // it is possible to have tables without a header void DocbookDocVisitor::visitPre(DocHtmlTable *t) { +DB_VIS_C + bodySet = FALSE; if (m_hide) return; - m_t << "<table frame=\"all\">" << endl; - m_t << " <title></title>" << endl; + m_t << "<informaltable frame=\"all\">" << endl; m_t << " <tgroup cols=\"" << t->numColumns() << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl; - m_t << " <tbody>" << endl; + for (int i = 0; i <t->numColumns(); i++) + { + // do something with colwidth based of cell width specification (be aware of possible colspan in the header)? + m_t << " <colspec colname='c" << i+1 << "'/>\n"; + } } void DocbookDocVisitor::visitPost(DocHtmlTable *) { +DB_VIS_C if (m_hide) return; - m_t << " </tbody>" << endl; + if (bodySet) m_t << " </tbody>" << endl; + bodySet = FALSE; m_t << " </tgroup>" << endl; - m_t << "</table>" << endl; + m_t << "</informaltable>" << endl; } -void DocbookDocVisitor::visitPre(DocHtmlRow *) +void DocbookDocVisitor::visitPre(DocHtmlRow *tr) { +DB_VIS_C + colCnt = 0; if (m_hide) return; - m_t << "<row>\n"; + + if (tr->isHeading()) m_t << "<thead>\n"; + else if (!bodySet) + { + bodySet = TRUE; + m_t << "<tbody>\n"; + } + + m_t << " <row "; + + HtmlAttribListIterator li(tr->attribs()); + HtmlAttrib *opt; + for (li.toFirst();(opt=li.current());++li) + { + if (opt->name=="class") + { + // just skip it + } + else if (opt->name=="style") + { + // just skip it + } + else if (opt->name=="height") + { + // just skip it + } + else if (opt->name=="filter") + { + // just skip it + } + else + { + m_t << " " << opt->name << "='" << opt->value << "'"; + } + } + m_t << ">\n"; } -void DocbookDocVisitor::visitPost(DocHtmlRow *) +void DocbookDocVisitor::visitPost(DocHtmlRow *tr) { +DB_VIS_C if (m_hide) return; m_t << "</row>\n"; + if (tr->isHeading()) + { + bodySet = TRUE; + m_t << "</thead><tbody>\n"; + } } -void DocbookDocVisitor::visitPre(DocHtmlCell *) +void DocbookDocVisitor::visitPre(DocHtmlCell *c) { +DB_VIS_C + colCnt++; if (m_hide) return; - m_t << "<entry>"; + m_t << "<entry"; + + HtmlAttribListIterator li(c->attribs()); + HtmlAttrib *opt; + for (li.toFirst();(opt=li.current());++li) + { + if (opt->name=="colspan") + { + m_t << " namest='c" << colCnt << "'"; + int cols = opt->value.toInt(); + colCnt += (cols - 1); + m_t << " nameend='c" << colCnt << "'"; + } + else if (opt->name=="rowspan") + { + int extraRows = opt->value.toInt() - 1; + m_t << " morerows='" << extraRows << "'"; + } + else if (opt->name=="class") + { + if (opt->value == "markdownTableBodyRight") + { + m_t << " align='right'"; + } + else if (opt->value == "markdownTableBodyLeftt") + { + m_t << " align='left'"; + } + else if (opt->value == "markdownTableBodyCenter") + { + m_t << " align='center'"; + } + else if (opt->value == "markdownTableHeadRight") + { + m_t << " align='right'"; + } + else if (opt->value == "markdownTableHeadLeftt") + { + m_t << " align='left'"; + } + else if (opt->value == "markdownTableHeadCenter") + { + m_t << " align='center'"; + } + } + else if (opt->name=="style") + { + // just skip it + } + else if (opt->name=="width") + { + // just skip it + } + else if (opt->name=="height") + { + // just skip it + } + else + { + m_t << " " << opt->name << "='" << opt->value << "'"; + } + } + m_t << ">"; } -void DocbookDocVisitor::visitPost(DocHtmlCell *) +void DocbookDocVisitor::visitPost(DocHtmlCell *c) { +DB_VIS_C if (m_hide) return; m_t << "</entry>"; } -void DocbookDocVisitor::visitPre(DocHtmlCaption *) +void DocbookDocVisitor::visitPre(DocHtmlCaption *c) { +DB_VIS_C if (m_hide) return; - m_t << "<caption>"; + m_t << "<caption>"; } void DocbookDocVisitor::visitPost(DocHtmlCaption *) { +DB_VIS_C if (m_hide) return; m_t << "</caption>\n"; } void DocbookDocVisitor::visitPre(DocInternal *) { +DB_VIS_C if (m_hide) return; // TODO: to be implemented } void DocbookDocVisitor::visitPost(DocInternal *) { +DB_VIS_C if (m_hide) return; // TODO: to be implemented } void DocbookDocVisitor::visitPre(DocHRef *href) { +DB_VIS_C if (m_hide) return; - m_t << "<link xlink:href=\"" << href->url() << "\">"; + m_t << "<link xlink:href=\"" << convertToDocBook(href->url()) << "\">"; } void DocbookDocVisitor::visitPost(DocHRef *) { +DB_VIS_C if (m_hide) return; m_t << "</link>"; } void DocbookDocVisitor::visitPre(DocHtmlHeader *) { +DB_VIS_C if (m_hide) return; m_t << "<formalpara><title>"; } void DocbookDocVisitor::visitPost(DocHtmlHeader *) { +DB_VIS_C if (m_hide) return; m_t << "</title></formalpara>\n"; } void DocbookDocVisitor::visitPre(DocImage *img) { +DB_VIS_C if (img->type()==DocImage::DocBook) { if (m_hide) return; @@ -912,7 +1173,7 @@ void DocbookDocVisitor::visitPre(DocImage *img) { baseName=baseName.right(baseName.length()-i-1); } - visitPreStart(m_t, img -> hasCaption(), baseName, img -> width(), img -> height()); + visitPreStart(m_t, img->children(), img->hasCaption(), img->relPath() + baseName, img->width(), img->height(), img->isInlineImage()); } else { @@ -923,10 +1184,11 @@ void DocbookDocVisitor::visitPre(DocImage *img) void DocbookDocVisitor::visitPost(DocImage *img) { +DB_VIS_C if (img->type()==DocImage::DocBook) { if (m_hide) return; - visitPostEnd(m_t, img -> hasCaption()); + visitPostEnd(m_t, img -> hasCaption(),img -> isInlineImage()); // copy the image to the output dir QCString baseName=img->name(); int i; @@ -963,96 +1225,118 @@ void DocbookDocVisitor::visitPost(DocImage *img) void DocbookDocVisitor::visitPre(DocDotFile *df) { +DB_VIS_C if (m_hide) return; - startDotFile(df->file(),df->width(),df->height(),df->hasCaption()); + startDotFile(df->file(),df->width(),df->height(),df->hasCaption(),df->children()); } void DocbookDocVisitor::visitPost(DocDotFile *df) { +DB_VIS_C if (m_hide) return; endDotFile(df->hasCaption()); } void DocbookDocVisitor::visitPre(DocMscFile *df) { +DB_VIS_C if (m_hide) return; - startMscFile(df->file(),df->width(),df->height(),df->hasCaption()); + startMscFile(df->file(),df->width(),df->height(),df->hasCaption(),df->children()); } void DocbookDocVisitor::visitPost(DocMscFile *df) { +DB_VIS_C if (m_hide) return; endMscFile(df->hasCaption()); } void DocbookDocVisitor::visitPre(DocDiaFile *df) { +DB_VIS_C if (m_hide) return; - startDiaFile(df->file(),df->width(),df->height(),df->hasCaption()); + startDiaFile(df->file(),df->width(),df->height(),df->hasCaption(),df->children()); } void DocbookDocVisitor::visitPost(DocDiaFile *df) { +DB_VIS_C if (m_hide) return; endDiaFile(df->hasCaption()); } void DocbookDocVisitor::visitPre(DocLink *lnk) { +DB_VIS_C if (m_hide) return; startLink(lnk->file(),lnk->anchor()); } void DocbookDocVisitor::visitPost(DocLink *) { +DB_VIS_C if (m_hide) return; endLink(); } void DocbookDocVisitor::visitPre(DocRef *ref) { +DB_VIS_C if (m_hide) return; - if (!ref->file().isEmpty()) startLink(ref->file(),ref->anchor()); + if (ref->isSubPage()) + { + startLink(0,ref->anchor()); + } + else + { + if (!ref->file().isEmpty()) startLink(ref->file(),ref->anchor()); + } + if (!ref->hasLinkText()) filter(ref->targetTitle()); } void DocbookDocVisitor::visitPost(DocRef *ref) { +DB_VIS_C if (m_hide) return; if (!ref->file().isEmpty()) endLink(); } void DocbookDocVisitor::visitPre(DocSecRefItem *ref) { +DB_VIS_C if (m_hide) return; - m_t << "<tocitem id=\"" << ref->file() << "_1" << ref->anchor() << "\">"; + //m_t << "<tocentry xml:idref=\"_" << stripPath(ref->file()) << "_1" << ref->anchor() << "\">"; + m_t << "<tocentry>"; } void DocbookDocVisitor::visitPost(DocSecRefItem *) { +DB_VIS_C if (m_hide) return; - m_t << "</tocitem>" << endl; + m_t << "</tocentry>" << endl; } void DocbookDocVisitor::visitPre(DocSecRefList *) { +DB_VIS_C if (m_hide) return; - m_t << "<toclist>" << endl; + m_t << "<toc>" << endl; } void DocbookDocVisitor::visitPost(DocSecRefList *) { +DB_VIS_C if (m_hide) return; - m_t << "</toclist>" << endl; + m_t << "</toc>" << endl; } void DocbookDocVisitor::visitPre(DocParamSect *s) { +DB_VIS_C if (m_hide) return; m_t << endl; m_t << " <formalpara>" << endl; - m_t << " <title/>" << endl; - m_t << " <table frame=\"all\">" << endl; - m_t << " <title>"; + m_t << " <title>" << endl; switch(s->type()) { case DocParamSect::Param: m_t << theTranslator->trParameters(); break; @@ -1062,29 +1346,96 @@ void DocbookDocVisitor::visitPre(DocParamSect *s) default: ASSERT(0); } - m_t << " </title>" << endl; - m_t << " <tgroup cols=\"2\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl; - m_t << " <colspec colwidth=\"1*\"/>" << endl; - m_t << " <colspec colwidth=\"4*\"/>" << endl; + m_t << " </title>" << endl; + m_t << " <para>" << endl; + m_t << " <table frame=\"all\">" << endl; + int ncols = 2; + if (s->type() == DocParamSect::Param) + { + bool hasInOutSpecs = s->hasInOutSpecifier(); + bool hasTypeSpecs = s->hasTypeSpecifier(); + if (hasInOutSpecs && hasTypeSpecs) ncols += 2; + else if (hasInOutSpecs || hasTypeSpecs) ncols += 1; + } + m_t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl; + for (int i = 1; i <= ncols; i++) + { + if (i == ncols) m_t << " <colspec colwidth=\"4*\"/>" << endl; + else m_t << " <colspec colwidth=\"1*\"/>" << endl; + } m_t << " <tbody>" << endl; } void DocbookDocVisitor::visitPost(DocParamSect *) { +DB_VIS_C if (m_hide) return; m_t << " </tbody>" << endl; m_t << " </tgroup>" << endl; m_t << " </table>" << endl; + m_t << " </para>" << endl; m_t << " </formalpara>" << endl; m_t << " "; } void DocbookDocVisitor::visitPre(DocParamList *pl) { +DB_VIS_C if (m_hide) return; + m_t << " <row>" << endl; + + DocParamSect::Type parentType = DocParamSect::Unknown; + DocParamSect *sect = 0; + if (pl->parent() && pl->parent()->kind()==DocNode::Kind_ParamSect) + { + parentType = ((DocParamSect*)pl->parent())->type(); + sect=(DocParamSect*)pl->parent(); + } + + if (sect && sect->hasInOutSpecifier()) + { + m_t << " <entry>"; + if (pl->direction()!=DocParamSect::Unspecified) + { + if (pl->direction()==DocParamSect::In) + { + m_t << "in"; + } + else if (pl->direction()==DocParamSect::Out) + { + m_t << "out"; + } + else if (pl->direction()==DocParamSect::InOut) + { + m_t << "in,out"; + } + } + m_t << " </entry>"; + } + + if (sect && sect->hasTypeSpecifier()) + { + QListIterator<DocNode> li(pl->paramTypes()); + DocNode *type; + bool first=TRUE; + m_t << " <entry>"; + for (li.toFirst();(type=li.current());++li) + { + if (!first) m_t << " | "; else first=FALSE; + if (type->kind()==DocNode::Kind_Word) + { + visit((DocWord*)type); + } + else if (type->kind()==DocNode::Kind_LinkedWord) + { + visit((DocLinkedWord*)type); + } + } + m_t << " </entry>"; + } + QListIterator<DocNode> li(pl->parameters()); DocNode *param; - m_t << " <row>" << endl; if (!li.toFirst()) { m_t << " <entry></entry>" << endl; @@ -1116,6 +1467,7 @@ void DocbookDocVisitor::visitPre(DocParamList *pl) void DocbookDocVisitor::visitPost(DocParamList *) { +DB_VIS_C if (m_hide) return; m_t << "</entry>" << endl; m_t << " </row>" << endl; @@ -1123,10 +1475,11 @@ void DocbookDocVisitor::visitPost(DocParamList *) void DocbookDocVisitor::visitPre(DocXRefItem *x) { +DB_VIS_C if (m_hide) return; if (x->title().isEmpty()) return; - m_t << "<para><link linkend=\""; - m_t << x->file() << "_1" << x->anchor(); + m_t << "<para><link linkend=\"_"; + m_t << stripPath(x->file()) << "_1" << x->anchor(); m_t << "\">"; filter(x->title()); m_t << "</link>"; @@ -1135,6 +1488,7 @@ void DocbookDocVisitor::visitPre(DocXRefItem *x) void DocbookDocVisitor::visitPost(DocXRefItem *x) { +DB_VIS_C if (m_hide) return; if (x->title().isEmpty()) return; m_t << "</para>"; @@ -1142,12 +1496,14 @@ void DocbookDocVisitor::visitPost(DocXRefItem *x) void DocbookDocVisitor::visitPre(DocInternalRef *ref) { +DB_VIS_C if (m_hide) return; startLink(ref->file(),ref->anchor()); } void DocbookDocVisitor::visitPost(DocInternalRef *) { +DB_VIS_C if (m_hide) return; endLink(); m_t << " "; @@ -1155,6 +1511,7 @@ void DocbookDocVisitor::visitPost(DocInternalRef *) void DocbookDocVisitor::visitPre(DocCopy *) { +DB_VIS_C if (m_hide) return; // TODO: to be implemented } @@ -1162,6 +1519,7 @@ void DocbookDocVisitor::visitPre(DocCopy *) void DocbookDocVisitor::visitPost(DocCopy *) { +DB_VIS_C if (m_hide) return; // TODO: to be implemented } @@ -1169,72 +1527,89 @@ void DocbookDocVisitor::visitPost(DocCopy *) void DocbookDocVisitor::visitPre(DocText *) { +DB_VIS_C // TODO: to be implemented } void DocbookDocVisitor::visitPost(DocText *) { +DB_VIS_C // TODO: to be implemented } void DocbookDocVisitor::visitPre(DocHtmlBlockQuote *) { +DB_VIS_C if (m_hide) return; m_t << "<blockquote>"; } void DocbookDocVisitor::visitPost(DocHtmlBlockQuote *) { +DB_VIS_C if (m_hide) return; m_t << "</blockquote>"; } void DocbookDocVisitor::visitPre(DocVhdlFlow *) { +DB_VIS_C // TODO: to be implemented } void DocbookDocVisitor::visitPost(DocVhdlFlow *) { +DB_VIS_C // TODO: to be implemented } void DocbookDocVisitor::visitPre(DocParBlock *) { +DB_VIS_C } void DocbookDocVisitor::visitPost(DocParBlock *) { +DB_VIS_C } void DocbookDocVisitor::filter(const char *str) { - m_t << convertToXML(str); +DB_VIS_C + m_t << convertToDocBook(str); } void DocbookDocVisitor::startLink(const QCString &file,const QCString &anchor) { - m_t << "<link linkend=\"" << file; - if (!anchor.isEmpty()) m_t << "_1" << anchor; +DB_VIS_C + m_t << "<link linkend=\"_" << stripPath(file); + if (!anchor.isEmpty()) + { + if (file) m_t << "_1"; + m_t << anchor; + } m_t << "\">"; } void DocbookDocVisitor::endLink() { +DB_VIS_C m_t << "</link>"; } void DocbookDocVisitor::pushEnabled() { +DB_VIS_C m_enabled.push(new bool(m_hide)); } void DocbookDocVisitor::popEnabled() { +DB_VIS_C bool *v=m_enabled.pop(); ASSERT(v!=0); m_hide = *v; @@ -1243,6 +1618,7 @@ void DocbookDocVisitor::popEnabled() void DocbookDocVisitor::writeMscFile(const QCString &baseName, DocVerbatim *s) { +DB_VIS_C QCString shortName = baseName; int i; if ((i=shortName.findRev('/'))!=-1) @@ -1251,13 +1627,14 @@ void DocbookDocVisitor::writeMscFile(const QCString &baseName, DocVerbatim *s) } QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeMscGraphFromFile(baseName+".msc",outDir,shortName,MSC_BITMAP); - visitPreStart(m_t, s->hasCaption(), shortName, s->width(),s->height()); - visitCaption(this, s->children()); + visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + ".png", s->width(), s->height()); + visitCaption(s->children()); visitPostEnd(m_t, s->hasCaption()); } void DocbookDocVisitor::writePlantUMLFile(const QCString &baseName, DocVerbatim *s) { +DB_VIS_C QCString shortName = baseName; int i; if ((i=shortName.findRev('/'))!=-1) @@ -1266,17 +1643,19 @@ void DocbookDocVisitor::writePlantUMLFile(const QCString &baseName, DocVerbatim } QCString outDir = Config_getString(DOCBOOK_OUTPUT); generatePlantUMLOutput(baseName,outDir,PUML_BITMAP); - visitPreStart(m_t, s->hasCaption(), shortName, s->width(),s->height()); - visitCaption(this, s->children()); + visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + ".png", s->width(),s->height()); + visitCaption(s->children()); visitPostEnd(m_t, s->hasCaption()); } void DocbookDocVisitor::startMscFile(const QCString &fileName, const QCString &width, const QCString &height, - bool hasCaption + bool hasCaption, + const QList<DocNode> &children ) { +DB_VIS_C QCString baseName=fileName; int i; if ((i=baseName.findRev('/'))!=-1) @@ -1291,11 +1670,12 @@ void DocbookDocVisitor::startMscFile(const QCString &fileName, QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeMscGraphFromFile(fileName,outDir,baseName,MSC_BITMAP); m_t << "<para>" << endl; - visitPreStart(m_t, hasCaption, baseName + ".png", width, height); + visitPreStart(m_t, children, hasCaption, baseName + ".png", width, height); } void DocbookDocVisitor::endMscFile(bool hasCaption) { +DB_VIS_C if (m_hide) return; visitPostEnd(m_t, hasCaption); m_t << "</para>" << endl; @@ -1303,6 +1683,7 @@ void DocbookDocVisitor::endMscFile(bool hasCaption) void DocbookDocVisitor::writeDiaFile(const QCString &baseName, DocVerbatim *s) { +DB_VIS_C QCString shortName = baseName; int i; if ((i=shortName.findRev('/'))!=-1) @@ -1311,17 +1692,19 @@ void DocbookDocVisitor::writeDiaFile(const QCString &baseName, DocVerbatim *s) } QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeDiaGraphFromFile(baseName+".dia",outDir,shortName,DIA_BITMAP); - visitPreStart(m_t, s->hasCaption(), shortName, s->width(),s->height()); - visitCaption(this, s->children()); + visitPreStart(m_t, s->children(), s->hasCaption(), shortName, s->width(),s->height()); + visitCaption(s->children()); visitPostEnd(m_t, s->hasCaption()); } void DocbookDocVisitor::startDiaFile(const QCString &fileName, const QCString &width, const QCString &height, - bool hasCaption + bool hasCaption, + const QList<DocNode> &children ) { +DB_VIS_C QCString baseName=fileName; int i; if ((i=baseName.findRev('/'))!=-1) @@ -1336,11 +1719,12 @@ void DocbookDocVisitor::startDiaFile(const QCString &fileName, QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP); m_t << "<para>" << endl; - visitPreStart(m_t, hasCaption, baseName + ".png", width, height); + visitPreStart(m_t, children, hasCaption, baseName + ".png", width, height); } void DocbookDocVisitor::endDiaFile(bool hasCaption) { +DB_VIS_C if (m_hide) return; visitPostEnd(m_t, hasCaption); m_t << "</para>" << endl; @@ -1348,6 +1732,7 @@ void DocbookDocVisitor::endDiaFile(bool hasCaption) void DocbookDocVisitor::writeDotFile(const QCString &baseName, DocVerbatim *s) { +DB_VIS_C QCString shortName = baseName; int i; if ((i=shortName.findRev('/'))!=-1) @@ -1356,17 +1741,19 @@ void DocbookDocVisitor::writeDotFile(const QCString &baseName, DocVerbatim *s) } QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeDotGraphFromFile(baseName+".dot",outDir,shortName,GOF_BITMAP); - visitPreStart(m_t, s->hasCaption(), baseName + ".dot", s->width(),s->height()); - visitCaption(this, s->children()); + visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + "." + getDotImageExtension(), s->width(),s->height()); + visitCaption(s->children()); visitPostEnd(m_t, s->hasCaption()); } void DocbookDocVisitor::startDotFile(const QCString &fileName, const QCString &width, const QCString &height, - bool hasCaption + bool hasCaption, + const QList<DocNode> &children ) { +DB_VIS_C QCString baseName=fileName; int i; if ((i=baseName.findRev('/'))!=-1) @@ -1382,11 +1769,12 @@ void DocbookDocVisitor::startDotFile(const QCString &fileName, QCString imgExt = getDotImageExtension(); writeDotGraphFromFile(fileName,outDir,baseName,GOF_BITMAP); m_t << "<para>" << endl; - visitPreStart(m_t, hasCaption, baseName + "." + imgExt, width, height); + visitPreStart(m_t, children, hasCaption, baseName + "." + imgExt, width, height); } void DocbookDocVisitor::endDotFile(bool hasCaption) { +DB_VIS_C if (m_hide) return; m_t << endl; visitPostEnd(m_t, hasCaption); |