1 /******************************************************************************
6 * Copyright (C) 1997-2015 by Dimitri van Heesch.
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation under the terms of the GNU General Public License is hereby
10 * granted. No representations are made about the suitability of this software
11 * for any purpose. It is provided "as is" without express or implied warranty.
12 * See the GNU General Public License for more details.
14 * Documents produced by Doxygen are derivative works derived from the
15 * input used in their production; they are not affected by this license.
19 #include <qfileinfo.h>
21 #include "docbookvisitor.h"
22 #include "docparser.h"
25 #include "outputgen.h"
26 #include "docbookgen.h"
30 #include "parserintf.h"
36 #include "htmlentity.h"
39 static void visitPreStart(FTextStream &t, const bool hasCaption, QCString name, QCString width, QCString height)
42 t << " <figure>" << endl;
43 t << " <title></title>" << endl;
44 t << " <mediaobject>" << endl;
45 t << " <imageobject>" << endl;
49 t << " width=\"" << convertToXML(width) << "\"";
53 t << " width=\"50%\"";
55 if (!height.isEmpty())
57 t << " depth=\"" << convertToXML(tmpStr) << "\"";
59 t << " align=\"center\" valign=\"middle\" scalefit=\"1\" fileref=\"" << name << "\">";
60 t << "</imagedata>" << endl;
61 t << " </imageobject>" << endl;
64 t << " <caption>" << endl;
68 static void visitPostEnd(FTextStream &t, const bool hasCaption)
73 t << " </caption>" << endl;
75 t << " </mediaobject>" << endl;
76 t << " </figure>" << endl;
79 static void visitCaption(DocbookDocVisitor *parent, QList<DocNode> children)
81 QListIterator<DocNode> cli(children);
83 for (cli.toFirst();(n=cli.current());++cli) n->accept(parent);
86 DocbookDocVisitor::DocbookDocVisitor(FTextStream &t,CodeOutputInterface &ci)
87 : DocVisitor(DocVisitor_Docbook), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE)
91 //--------------------------------------
92 // visitor functions for leaf nodes
93 //--------------------------------------
95 void DocbookDocVisitor::visit(DocWord *w)
101 void DocbookDocVisitor::visit(DocLinkedWord *w)
104 startLink(w->file(),w->anchor());
109 void DocbookDocVisitor::visit(DocWhiteSpace *w)
122 void DocbookDocVisitor::visit(DocSymbol *s)
125 const char *res = HtmlEntityMapper::instance()->docbook(s->symbol());
132 err("DocBook: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
136 void DocbookDocVisitor::visit(DocURL *u)
139 m_t << "<link xlink:href=\"";
140 if (u->isEmail()) m_t << "mailto:";
147 void DocbookDocVisitor::visit(DocLineBreak *)
150 m_t << endl << "<literallayout>\n</literallayout>" << endl;
153 void DocbookDocVisitor::visit(DocHorRuler *)
156 m_t << "<informaltable frame='bottom'><tgroup cols='1'><colspec align='center'/><tbody><row><entry align='center'>\n";
157 m_t << "</entry></row></tbody></tgroup></informaltable>\n";
160 void DocbookDocVisitor::visit(DocStyleChange *s)
165 case DocStyleChange::Bold:
166 if (s->enable()) m_t << "<emphasis role=\"bold\">"; else m_t << "</emphasis>";
168 case DocStyleChange::Italic:
169 if (s->enable()) m_t << "<emphasis>"; else m_t << "</emphasis>";
171 case DocStyleChange::Code:
172 if (s->enable()) m_t << "<computeroutput>"; else m_t << "</computeroutput>";
174 case DocStyleChange::Subscript:
175 if (s->enable()) m_t << "<subscript>"; else m_t << "</subscript>";
177 case DocStyleChange::Superscript:
178 if (s->enable()) m_t << "<superscript>"; else m_t << "</superscript>";
180 case DocStyleChange::Center:
181 if (s->enable()) m_t << "<informaltable frame='none'><tgroup cols='1'><colspec align='center'/><tbody><row><entry align='center'>";
182 else m_t << "</entry></row></tbody></tgroup></informaltable>";
184 case DocStyleChange::Preformatted:
187 m_t << "<literallayout>";
192 m_t << "</literallayout>";
196 /* There is no equivalent Docbook tag for rendering Small text */
197 case DocStyleChange::Small: /* XSLT Stylesheets can be used */ break;
199 case DocStyleChange::Div: /* HTML only */ break;
200 case DocStyleChange::Span: /* HTML only */ break;
204 void DocbookDocVisitor::visit(DocVerbatim *s)
207 SrcLangExt langExt = getLanguageFromFileName(m_langExt);
210 case DocVerbatim::Code: // fall though
211 m_t << "<literallayout><computeroutput>";
212 Doxygen::parserManager->getParser(m_langExt)
213 ->parseCode(m_ci,s->context(),s->text(),langExt,
214 s->isExample(),s->exampleFile());
215 m_t << "</computeroutput></literallayout>";
217 case DocVerbatim::Verbatim:
218 m_t << "<literallayout>";
220 m_t << "</literallayout>";
222 case DocVerbatim::HtmlOnly:
224 case DocVerbatim::RtfOnly:
226 case DocVerbatim::ManOnly:
228 case DocVerbatim::LatexOnly:
230 case DocVerbatim::XmlOnly:
232 case DocVerbatim::DocbookOnly:
236 case DocVerbatim::Dot:
238 static int dotindex = 1;
239 QCString baseName(4096);
241 QCString stext = s->text();
242 m_t << "<para>" << endl;
243 name.sprintf("%s%d", "dot_inline_dotgraph_", dotindex);
244 baseName.sprintf("%s%d",
245 (Config_getString(DOCBOOK_OUTPUT)+"/inline_dotgraph_").data(),
248 QFile file(baseName+".dot");
249 if (!file.open(IO_WriteOnly))
251 err("Could not open file %s.msc for writing\n",baseName.data());
253 file.writeBlock( stext, stext.length() );
255 writeDotFile(baseName, s);
256 m_t << "</para>" << endl;
259 case DocVerbatim::Msc:
261 static int mscindex = 1;
262 QCString baseName(4096);
264 QCString stext = s->text();
265 m_t << "<para>" << endl;
266 name.sprintf("%s%d", "msc_inline_mscgraph_", mscindex);
267 baseName.sprintf("%s%d",
268 (Config_getString(DOCBOOK_OUTPUT)+"/inline_mscgraph_").data(),
271 QFile file(baseName+".msc");
272 if (!file.open(IO_WriteOnly))
274 err("Could not open file %s.msc for writing\n",baseName.data());
276 QCString text = "msc {";
279 file.writeBlock( text, text.length() );
281 writeMscFile(baseName,s);
282 m_t << "</para>" << endl;
285 case DocVerbatim::PlantUML:
287 static QCString docbookOutput = Config_getString(DOCBOOK_OUTPUT);
288 QCString baseName = writePlantUMLSource(docbookOutput,s->exampleFile(),s->text());
289 QCString shortName = baseName;
291 if ((i=shortName.findRev('/'))!=-1)
293 shortName=shortName.right(shortName.length()-i-1);
295 m_t << "<para>" << endl;
296 writePlantUMLFile(baseName,s);
297 m_t << "</para>" << endl;
303 void DocbookDocVisitor::visit(DocAnchor *anc)
306 m_t << "<anchor id=\"" << anc->file() << "_1" << anc->anchor() << "\"/>";
309 void DocbookDocVisitor::visit(DocInclude *inc)
312 SrcLangExt langExt = getLanguageFromFileName(inc->extension());
315 case DocInclude::IncWithLines:
317 m_t << "<literallayout><computeroutput>";
318 QFileInfo cfi( inc->file() );
319 FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
320 Doxygen::parserManager->getParser(inc->extension())
321 ->parseCode(m_ci,inc->context(),
325 inc->exampleFile(), &fd);
326 m_t << "</computeroutput></literallayout>";
329 case DocInclude::Include:
330 m_t << "<literallayout><computeroutput>";
331 Doxygen::parserManager->getParser(inc->extension())
332 ->parseCode(m_ci,inc->context(),
337 m_t << "</computeroutput></literallayout>";
339 case DocInclude::DontInclude:
341 case DocInclude::HtmlInclude:
343 case DocInclude::LatexInclude:
345 case DocInclude::VerbInclude:
348 m_t << "</verbatim>";
350 case DocInclude::Snippet:
351 m_t << "<literallayout><computeroutput>";
352 Doxygen::parserManager->getParser(inc->extension())
355 extractBlock(inc->text(),inc->blockId()),
360 m_t << "</computeroutput></literallayout>";
362 case DocInclude::SnipWithLines:
364 QFileInfo cfi( inc->file() );
365 FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
366 m_t << "<literallayout><computeroutput>";
367 Doxygen::parserManager->getParser(inc->extension())
370 extractBlock(inc->text(),inc->blockId()),
375 lineBlock(inc->text(),inc->blockId()),
377 FALSE, // inlineFragment
379 TRUE // show line number
381 m_t << "</computeroutput></literallayout>";
384 case DocInclude::SnippetDoc:
385 case DocInclude::IncludeDoc:
386 err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s"
387 "Please create a bug report\n",__FILE__);
392 void DocbookDocVisitor::visit(DocIncOperator *op)
398 m_t << "<programlisting>";
403 SrcLangExt langExt = getLanguageFromFileName(m_langExt);
404 if (op->type()!=DocIncOperator::Skip)
409 Doxygen::parserManager->getParser(m_langExt)
410 ->parseCode(m_ci,op->context(),
411 op->text(),langExt,op->isExample(),
420 if (!m_hide) m_t << "</programlisting>";
424 if (!m_hide) m_t << endl;
428 void DocbookDocVisitor::visit(DocFormula *f)
431 m_t << "<equation><title>" << f->name() << "</title>";
433 m_t << "</equation>";
436 void DocbookDocVisitor::visit(DocIndexEntry *ie)
439 m_t << "<indexentry><primaryie>" << endl;
441 m_t << "</primaryie><secondaryie></secondaryie></indexentry>" << endl;
444 void DocbookDocVisitor::visit(DocSimpleSectSep *)
446 m_t << "<simplesect/>";
449 void DocbookDocVisitor::visit(DocCite *cite)
452 if (!cite->file().isEmpty()) startLink(cite->file(),cite->anchor());
453 filter(cite->text());
454 if (!cite->file().isEmpty()) endLink();
457 //--------------------------------------
458 // visitor functions for compound nodes
459 //--------------------------------------
461 void DocbookDocVisitor::visitPre(DocAutoList *l)
466 m_t << "<orderedlist>\n";
470 m_t << "<itemizedlist>\n";
474 void DocbookDocVisitor::visitPost(DocAutoList *l)
479 m_t << "</orderedlist>\n";
483 m_t << "</itemizedlist>\n";
487 void DocbookDocVisitor::visitPre(DocAutoListItem *)
493 void DocbookDocVisitor::visitPost(DocAutoListItem *)
496 m_t << "</listitem>";
499 void DocbookDocVisitor::visitPre(DocPara *)
506 void DocbookDocVisitor::visitPost(DocPara *)
513 void DocbookDocVisitor::visitPre(DocRoot *)
515 //m_t << "<hr><h4><font color=\"red\">New parser:</font></h4>\n";
518 void DocbookDocVisitor::visitPost(DocRoot *)
520 //m_t << "<hr><h4><font color=\"red\">Old parser:</font></h4>\n";
523 void DocbookDocVisitor::visitPre(DocSimpleSect *s)
528 case DocSimpleSect::See:
531 m_t << "<formalpara><title>" << theTranslator->trSeeAlso() << ": </title>" << endl;
535 m_t << "<formalpara><title>" << convertToXML(theTranslator->trSeeAlso()) << ": </title>" << endl;
538 case DocSimpleSect::Return:
541 m_t << "<formalpara><title>" << theTranslator->trReturns()<< ": </title>" << endl;
545 m_t << "<formalpara><title>" << convertToXML(theTranslator->trReturns()) << ": </title>" << endl;
548 case DocSimpleSect::Author:
551 m_t << "<formalpara><title>" << theTranslator->trAuthor(TRUE, TRUE) << ": </title>" << endl;
555 m_t << "<formalpara><title>" << convertToXML(theTranslator->trAuthor(TRUE, TRUE)) << ": </title>" << endl;
558 case DocSimpleSect::Authors:
561 m_t << "<formalpara><title>" << theTranslator->trAuthor(TRUE, FALSE) << ": </title>" << endl;
565 m_t << "<formalpara><title>" << convertToXML(theTranslator->trAuthor(TRUE, FALSE)) << ": </title>" << endl;
568 case DocSimpleSect::Version:
571 m_t << "<formalpara><title>" << theTranslator->trVersion() << ": </title>" << endl;
575 m_t << "<formalpara><title>" << convertToXML(theTranslator->trVersion()) << ": </title>" << endl;
578 case DocSimpleSect::Since:
581 m_t << "<formalpara><title>" << theTranslator->trSince() << ": </title>" << endl;
585 m_t << "<formalpara><title>" << convertToXML(theTranslator->trSince()) << ": </title>" << endl;
588 case DocSimpleSect::Date:
591 m_t << "<formalpara><title>" << theTranslator->trDate() << ": </title>" << endl;
595 m_t << "<formalpara><title>" << convertToXML(theTranslator->trDate()) << ": </title>" << endl;
598 case DocSimpleSect::Note:
601 m_t << "<formalpara><title>" << theTranslator->trNote() << ": </title>" << endl;
605 m_t << "<formalpara><title>" << convertToXML(theTranslator->trNote()) << ": </title>" << endl;
608 case DocSimpleSect::Warning:
611 m_t << "<formalpara><title>" << theTranslator->trWarning() << ": </title>" << endl;
615 m_t << "<formalpara><title>" << convertToXML(theTranslator->trWarning()) << ": </title>" << endl;
618 case DocSimpleSect::Pre:
621 m_t << "<formalpara><title>" << theTranslator->trPrecondition() << ": </title>" << endl;
625 m_t << "<formalpara><title>" << convertToXML(theTranslator->trPrecondition()) << ": </title>" << endl;
628 case DocSimpleSect::Post:
631 m_t << "<formalpara><title>" << theTranslator->trPostcondition() << ": </title>" << endl;
635 m_t << "<formalpara><title>" << convertToXML(theTranslator->trPostcondition()) << ": </title>" << endl;
638 case DocSimpleSect::Copyright:
641 m_t << "<formalpara><title>" << theTranslator->trCopyright() << ": </title>" << endl;
645 m_t << "<formalpara><title>" << convertToXML(theTranslator->trCopyright()) << ": </title>" << endl;
648 case DocSimpleSect::Invar:
651 m_t << "<formalpara><title>" << theTranslator->trInvariant() << ": </title>" << endl;
655 m_t << "<formalpara><title>" << convertToXML(theTranslator->trInvariant()) << ": </title>" << endl;
658 case DocSimpleSect::Remark:
661 m_t << "<formalpara><title>" << theTranslator->trRemarks() << ": </title>" << endl;
665 m_t << "<formalpara><title>" << convertToXML(theTranslator->trRemarks()) << ": </title>" << endl;
668 case DocSimpleSect::Attention:
671 m_t << "<formalpara><title>" << theTranslator->trAttention() << ": </title>" << endl;
675 m_t << "<formalpara><title>" << convertToXML(theTranslator->trAttention()) << ": </title>" << endl;
678 case DocSimpleSect::User:
679 m_t << "<formalpara><title></title>" << endl;
681 case DocSimpleSect::Rcs:
682 m_t << "<formalpara><title></title>" << endl;
684 case DocSimpleSect::Unknown: m_t << "<formalpara><title></title>" << endl; break;
688 void DocbookDocVisitor::visitPost(DocSimpleSect *)
691 m_t << "</formalpara>" << endl;
694 void DocbookDocVisitor::visitPre(DocTitle *)
700 void DocbookDocVisitor::visitPost(DocTitle *)
706 void DocbookDocVisitor::visitPre(DocSimpleList *)
709 m_t << "<itemizedlist>\n";
712 void DocbookDocVisitor::visitPost(DocSimpleList *)
715 m_t << "</itemizedlist>\n";
718 void DocbookDocVisitor::visitPre(DocSimpleListItem *)
724 void DocbookDocVisitor::visitPost(DocSimpleListItem *)
727 m_t << "</listitem>\n";
730 void DocbookDocVisitor::visitPre(DocSection *s)
733 m_t << "<section xml:id=\"" << s->file();
734 if (!s->anchor().isEmpty()) m_t << "_1" << s->anchor();
735 m_t << "\">" << endl;
738 m_t << "</title>" << endl;
741 void DocbookDocVisitor::visitPost(DocSection *)
743 m_t << "</section>\n";
746 void DocbookDocVisitor::visitPre(DocHtmlList *s)
749 if (s->type()==DocHtmlList::Ordered)
750 m_t << "<orderedlist>\n";
752 m_t << "<itemizedlist>\n";
755 void DocbookDocVisitor::visitPost(DocHtmlList *s)
758 if (s->type()==DocHtmlList::Ordered)
759 m_t << "</orderedlist>\n";
761 m_t << "</itemizedlist>\n";
764 void DocbookDocVisitor::visitPre(DocHtmlListItem *)
767 m_t << "<listitem>\n";
770 void DocbookDocVisitor::visitPost(DocHtmlListItem *)
773 m_t << "</listitem>\n";
776 void DocbookDocVisitor::visitPre(DocHtmlDescList *)
779 m_t << "<variablelist>\n";
782 void DocbookDocVisitor::visitPost(DocHtmlDescList *)
785 m_t << "</variablelist>\n";
788 void DocbookDocVisitor::visitPre(DocHtmlDescTitle *)
791 m_t << "<varlistentry><term>";
794 void DocbookDocVisitor::visitPost(DocHtmlDescTitle *)
800 void DocbookDocVisitor::visitPre(DocHtmlDescData *)
806 void DocbookDocVisitor::visitPost(DocHtmlDescData *)
809 m_t << "</listitem></varlistentry>\n";
812 void DocbookDocVisitor::visitPre(DocHtmlTable *t)
815 m_t << "<table frame=\"all\">" << endl;
816 m_t << " <title></title>" << endl;
817 m_t << " <tgroup cols=\"" << t->numColumns() << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl;
818 m_t << " <tbody>" << endl;
821 void DocbookDocVisitor::visitPost(DocHtmlTable *)
824 m_t << " </tbody>" << endl;
825 m_t << " </tgroup>" << endl;
826 m_t << "</table>" << endl;
829 void DocbookDocVisitor::visitPre(DocHtmlRow *)
835 void DocbookDocVisitor::visitPost(DocHtmlRow *)
841 void DocbookDocVisitor::visitPre(DocHtmlCell *)
847 void DocbookDocVisitor::visitPost(DocHtmlCell *)
853 void DocbookDocVisitor::visitPre(DocHtmlCaption *)
859 void DocbookDocVisitor::visitPost(DocHtmlCaption *)
862 m_t << "</caption>\n";
865 void DocbookDocVisitor::visitPre(DocInternal *)
868 // TODO: to be implemented
871 void DocbookDocVisitor::visitPost(DocInternal *)
874 // TODO: to be implemented
877 void DocbookDocVisitor::visitPre(DocHRef *href)
880 m_t << "<link xlink:href=\"" << href->url() << "\">";
883 void DocbookDocVisitor::visitPost(DocHRef *)
889 void DocbookDocVisitor::visitPre(DocHtmlHeader *)
892 m_t << "<formalpara><title>";
895 void DocbookDocVisitor::visitPost(DocHtmlHeader *)
898 m_t << "</title></formalpara>\n";
901 void DocbookDocVisitor::visitPre(DocImage *img)
903 if (img->type()==DocImage::DocBook)
907 QCString baseName=img->name();
909 if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
911 baseName=baseName.right(baseName.length()-i-1);
913 visitPreStart(m_t, img -> hasCaption(), baseName, img -> width(), img -> height());
922 void DocbookDocVisitor::visitPost(DocImage *img)
924 if (img->type()==DocImage::DocBook)
927 visitPostEnd(m_t, img -> hasCaption());
928 // copy the image to the output dir
929 QCString baseName=img->name();
931 if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
933 baseName=baseName.right(baseName.length()-i-1);
937 FileDef *fd=findFileDef(Doxygen::imageNameDict, baseName, ambig);
940 m_file=fd->absFilePath();
942 QFile inImage(m_file);
943 QFile outImage(Config_getString(DOCBOOK_OUTPUT)+"/"+baseName.data());
944 if (inImage.open(IO_ReadOnly))
946 if (outImage.open(IO_WriteOnly))
948 char *buffer = new char[inImage.size()];
949 inImage.readBlock(buffer,inImage.size());
950 outImage.writeBlock(buffer,inImage.size());
962 void DocbookDocVisitor::visitPre(DocDotFile *df)
965 startDotFile(df->file(),df->width(),df->height(),df->hasCaption());
968 void DocbookDocVisitor::visitPost(DocDotFile *df)
971 endDotFile(df->hasCaption());
974 void DocbookDocVisitor::visitPre(DocMscFile *df)
977 startMscFile(df->file(),df->width(),df->height(),df->hasCaption());
980 void DocbookDocVisitor::visitPost(DocMscFile *df)
983 endMscFile(df->hasCaption());
985 void DocbookDocVisitor::visitPre(DocDiaFile *df)
988 startDiaFile(df->file(),df->width(),df->height(),df->hasCaption());
991 void DocbookDocVisitor::visitPost(DocDiaFile *df)
994 endDiaFile(df->hasCaption());
997 void DocbookDocVisitor::visitPre(DocLink *lnk)
1000 startLink(lnk->file(),lnk->anchor());
1003 void DocbookDocVisitor::visitPost(DocLink *)
1009 void DocbookDocVisitor::visitPre(DocRef *ref)
1012 if (!ref->file().isEmpty()) startLink(ref->file(),ref->anchor());
1013 if (!ref->hasLinkText()) filter(ref->targetTitle());
1016 void DocbookDocVisitor::visitPost(DocRef *ref)
1019 if (!ref->file().isEmpty()) endLink();
1022 void DocbookDocVisitor::visitPre(DocSecRefItem *ref)
1025 m_t << "<tocitem id=\"" << ref->file() << "_1" << ref->anchor() << "\">";
1028 void DocbookDocVisitor::visitPost(DocSecRefItem *)
1031 m_t << "</tocitem>" << endl;
1034 void DocbookDocVisitor::visitPre(DocSecRefList *)
1037 m_t << "<toclist>" << endl;
1040 void DocbookDocVisitor::visitPost(DocSecRefList *)
1043 m_t << "</toclist>" << endl;
1046 void DocbookDocVisitor::visitPre(DocParamSect *s)
1050 m_t << " <formalpara>" << endl;
1051 m_t << " <title/>" << endl;
1052 m_t << " <table frame=\"all\">" << endl;
1056 case DocParamSect::Param: m_t << theTranslator->trParameters(); break;
1057 case DocParamSect::RetVal: m_t << theTranslator->trReturnValues(); break;
1058 case DocParamSect::Exception: m_t << theTranslator->trExceptions(); break;
1059 case DocParamSect::TemplateParam: m_t << theTranslator->trTemplateParameters(); break;
1063 m_t << " </title>" << endl;
1064 m_t << " <tgroup cols=\"2\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl;
1065 m_t << " <colspec colwidth=\"1*\"/>" << endl;
1066 m_t << " <colspec colwidth=\"4*\"/>" << endl;
1067 m_t << " <tbody>" << endl;
1070 void DocbookDocVisitor::visitPost(DocParamSect *)
1073 m_t << " </tbody>" << endl;
1074 m_t << " </tgroup>" << endl;
1075 m_t << " </table>" << endl;
1076 m_t << " </formalpara>" << endl;
1080 void DocbookDocVisitor::visitPre(DocParamList *pl)
1083 QListIterator<DocNode> li(pl->parameters());
1085 m_t << " <row>" << endl;
1088 m_t << " <entry></entry>" << endl;
1094 for (li.toFirst();(param=li.current());++li)
1100 if (param->kind()==DocNode::Kind_Word)
1102 visit((DocWord*)param);
1104 else if (param->kind()==DocNode::Kind_LinkedWord)
1106 visit((DocLinkedWord*)param);
1110 m_t << "</entry>" << endl;
1115 void DocbookDocVisitor::visitPost(DocParamList *)
1118 m_t << "</entry>" << endl;
1119 m_t << " </row>" << endl;
1122 void DocbookDocVisitor::visitPre(DocXRefItem *x)
1125 if (x->title().isEmpty()) return;
1126 m_t << "<para><link linkend=\"";
1127 m_t << x->file() << "_1" << x->anchor();
1134 void DocbookDocVisitor::visitPost(DocXRefItem *x)
1137 if (x->title().isEmpty()) return;
1141 void DocbookDocVisitor::visitPre(DocInternalRef *ref)
1144 startLink(ref->file(),ref->anchor());
1147 void DocbookDocVisitor::visitPost(DocInternalRef *)
1154 void DocbookDocVisitor::visitPre(DocCopy *)
1157 // TODO: to be implemented
1161 void DocbookDocVisitor::visitPost(DocCopy *)
1164 // TODO: to be implemented
1168 void DocbookDocVisitor::visitPre(DocText *)
1170 // TODO: to be implemented
1174 void DocbookDocVisitor::visitPost(DocText *)
1176 // TODO: to be implemented
1180 void DocbookDocVisitor::visitPre(DocHtmlBlockQuote *)
1183 m_t << "<blockquote>";
1186 void DocbookDocVisitor::visitPost(DocHtmlBlockQuote *)
1189 m_t << "</blockquote>";
1192 void DocbookDocVisitor::visitPre(DocVhdlFlow *)
1194 // TODO: to be implemented
1198 void DocbookDocVisitor::visitPost(DocVhdlFlow *)
1200 // TODO: to be implemented
1203 void DocbookDocVisitor::visitPre(DocParBlock *)
1207 void DocbookDocVisitor::visitPost(DocParBlock *)
1212 void DocbookDocVisitor::filter(const char *str)
1214 m_t << convertToXML(str);
1217 void DocbookDocVisitor::startLink(const QCString &file,const QCString &anchor)
1219 m_t << "<link linkend=\"" << file;
1220 if (!anchor.isEmpty()) m_t << "_1" << anchor;
1224 void DocbookDocVisitor::endLink()
1229 void DocbookDocVisitor::pushEnabled()
1231 m_enabled.push(new bool(m_hide));
1234 void DocbookDocVisitor::popEnabled()
1236 bool *v=m_enabled.pop();
1242 void DocbookDocVisitor::writeMscFile(const QCString &baseName, DocVerbatim *s)
1244 QCString shortName = baseName;
1246 if ((i=shortName.findRev('/'))!=-1)
1248 shortName=shortName.right(shortName.length()-i-1);
1250 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1251 writeMscGraphFromFile(baseName+".msc",outDir,shortName,MSC_BITMAP);
1252 visitPreStart(m_t, s->hasCaption(), shortName, s->width(),s->height());
1253 visitCaption(this, s->children());
1254 visitPostEnd(m_t, s->hasCaption());
1257 void DocbookDocVisitor::writePlantUMLFile(const QCString &baseName, DocVerbatim *s)
1259 QCString shortName = baseName;
1261 if ((i=shortName.findRev('/'))!=-1)
1263 shortName=shortName.right(shortName.length()-i-1);
1265 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1266 generatePlantUMLOutput(baseName,outDir,PUML_BITMAP);
1267 visitPreStart(m_t, s->hasCaption(), shortName, s->width(),s->height());
1268 visitCaption(this, s->children());
1269 visitPostEnd(m_t, s->hasCaption());
1272 void DocbookDocVisitor::startMscFile(const QCString &fileName,
1273 const QCString &width,
1274 const QCString &height,
1278 QCString baseName=fileName;
1280 if ((i=baseName.findRev('/'))!=-1)
1282 baseName=baseName.right(baseName.length()-i-1);
1284 if ((i=baseName.find('.'))!=-1)
1286 baseName=baseName.left(i);
1288 baseName.prepend("msc_");
1289 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1290 writeMscGraphFromFile(fileName,outDir,baseName,MSC_BITMAP);
1291 m_t << "<para>" << endl;
1292 visitPreStart(m_t, hasCaption, baseName + ".png", width, height);
1295 void DocbookDocVisitor::endMscFile(bool hasCaption)
1298 visitPostEnd(m_t, hasCaption);
1299 m_t << "</para>" << endl;
1302 void DocbookDocVisitor::writeDiaFile(const QCString &baseName, DocVerbatim *s)
1304 QCString shortName = baseName;
1306 if ((i=shortName.findRev('/'))!=-1)
1308 shortName=shortName.right(shortName.length()-i-1);
1310 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1311 writeDiaGraphFromFile(baseName+".dia",outDir,shortName,DIA_BITMAP);
1312 visitPreStart(m_t, s->hasCaption(), shortName, s->width(),s->height());
1313 visitCaption(this, s->children());
1314 visitPostEnd(m_t, s->hasCaption());
1317 void DocbookDocVisitor::startDiaFile(const QCString &fileName,
1318 const QCString &width,
1319 const QCString &height,
1323 QCString baseName=fileName;
1325 if ((i=baseName.findRev('/'))!=-1)
1327 baseName=baseName.right(baseName.length()-i-1);
1329 if ((i=baseName.find('.'))!=-1)
1331 baseName=baseName.left(i);
1333 baseName.prepend("dia_");
1334 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1335 writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP);
1336 m_t << "<para>" << endl;
1337 visitPreStart(m_t, hasCaption, baseName + ".png", width, height);
1340 void DocbookDocVisitor::endDiaFile(bool hasCaption)
1343 visitPostEnd(m_t, hasCaption);
1344 m_t << "</para>" << endl;
1347 void DocbookDocVisitor::writeDotFile(const QCString &baseName, DocVerbatim *s)
1349 QCString shortName = baseName;
1351 if ((i=shortName.findRev('/'))!=-1)
1353 shortName=shortName.right(shortName.length()-i-1);
1355 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1356 writeDotGraphFromFile(baseName+".dot",outDir,shortName,GOF_BITMAP);
1357 visitPreStart(m_t, s->hasCaption(), baseName + ".dot", s->width(),s->height());
1358 visitCaption(this, s->children());
1359 visitPostEnd(m_t, s->hasCaption());
1362 void DocbookDocVisitor::startDotFile(const QCString &fileName,
1363 const QCString &width,
1364 const QCString &height,
1368 QCString baseName=fileName;
1370 if ((i=baseName.findRev('/'))!=-1)
1372 baseName=baseName.right(baseName.length()-i-1);
1374 if ((i=baseName.find('.'))!=-1)
1376 baseName=baseName.left(i);
1378 baseName.prepend("dot_");
1379 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1380 QCString imgExt = getDotImageExtension();
1381 writeDotGraphFromFile(fileName,outDir,baseName,GOF_BITMAP);
1382 m_t << "<para>" << endl;
1383 visitPreStart(m_t, hasCaption, baseName + "." + imgExt, width, height);
1386 void DocbookDocVisitor::endDotFile(bool hasCaption)
1390 visitPostEnd(m_t, hasCaption);
1391 m_t << "</para>" << endl;