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"
41 #define DB_VIS_C DB_VIS_C1(m_t)
42 #define DB_VIS_C1(x) x << "<!-- DB_VIS_C " << __LINE__ << " -->\n";
43 #define DB_VIS_C2(y) DB_VIS_C2a(m_t,y)
44 #define DB_VIS_C2a(x,y) x << "<!-- DB_VIS_C " << __LINE__ << " " << y << " -->\n";
49 #define DB_VIS_C2a(x,y)
52 void DocbookDocVisitor::visitCaption(const QList<DocNode> &children)
54 QListIterator<DocNode> cli(children);
56 for (cli.toFirst();(n=cli.current());++cli) n->accept(this);
59 void DocbookDocVisitor::visitPreStart(FTextStream &t,
60 const QList<DocNode> &children,
63 const QCString &width,
64 const QCString &height,
67 if (hasCaption && !inlineImage)
69 t << " <figure>" << endl;
70 t << " <title>" << endl;
71 visitCaption(children);
72 t << " </title>" << endl;
76 t << " <informalfigure>" << endl;
78 t << " <mediaobject>" << endl;
79 t << " <imageobject>" << endl;
83 t << " width=\"" << convertToDocBook(width) << "\"";
87 if (!height.isEmpty() && !inlineImage) t << " width=\"50%\"";
89 if (!height.isEmpty())
91 t << " depth=\"" << convertToDocBook(height) << "\"";
93 t << " align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\"" << name << "\">";
94 t << "</imagedata>" << endl;
95 t << " </imageobject>" << endl;
96 if (hasCaption && !inlineImage)
98 t << " <!--" << endl; // Needed for general formatting with title for other formats
102 void DocbookDocVisitor::visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage)
105 if (hasCaption && !inlineImage)
107 t << " -->" << endl; // Needed for general formatting with title for other formats
109 t << " </mediaobject>" << endl;
110 if (hasCaption && !inlineImage)
112 t << " </figure>" << endl;
116 t << " </informalfigure>" << endl;
120 DocbookDocVisitor::DocbookDocVisitor(FTextStream &t,CodeOutputInterface &ci)
121 : DocVisitor(DocVisitor_Docbook), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE)
124 // m_t << "<section>" << endl;
126 DocbookDocVisitor::~DocbookDocVisitor()
129 // m_t << "</section>" << endl;
132 //--------------------------------------
133 // visitor functions for leaf nodes
134 //--------------------------------------
136 void DocbookDocVisitor::visit(DocWord *w)
143 void DocbookDocVisitor::visit(DocLinkedWord *w)
147 startLink(w->file(),w->anchor());
152 void DocbookDocVisitor::visit(DocWhiteSpace *w)
166 void DocbookDocVisitor::visit(DocSymbol *s)
170 const char *res = HtmlEntityMapper::instance()->docbook(s->symbol());
177 err("DocBook: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
181 void DocbookDocVisitor::visit(DocEmoji *s)
185 const char *res = EmojiEntityMapper::instance()->unicode(s->index());
196 void DocbookDocVisitor::visit(DocURL *u)
200 m_t << "<link xlink:href=\"";
201 if (u->isEmail()) m_t << "mailto:";
208 void DocbookDocVisitor::visit(DocLineBreak *)
212 m_t << endl << "<literallayout> 
</literallayout>" << endl;
213 // gives nicer results but gives problems as it is not allowed in <pare> and also problems with dblatex
214 // m_t << endl << "<sbr/>" << endl;
217 void DocbookDocVisitor::visit(DocHorRuler *)
221 m_t << "<informaltable frame='bottom'><tgroup cols='1'><colspec align='center'/><tbody><row><entry align='center'>\n";
222 m_t << "</entry></row></tbody></tgroup></informaltable>\n";
225 void DocbookDocVisitor::visit(DocStyleChange *s)
231 case DocStyleChange::Bold:
232 if (s->enable()) m_t << "<emphasis role=\"bold\">"; else m_t << "</emphasis>";
234 case DocStyleChange::Italic:
235 if (s->enable()) m_t << "<emphasis>"; else m_t << "</emphasis>";
237 case DocStyleChange::Code:
238 if (s->enable()) m_t << "<computeroutput>"; else m_t << "</computeroutput>";
240 case DocStyleChange::Subscript:
241 if (s->enable()) m_t << "<subscript>"; else m_t << "</subscript>";
243 case DocStyleChange::Superscript:
244 if (s->enable()) m_t << "<superscript>"; else m_t << "</superscript>";
246 case DocStyleChange::Center:
247 if (s->enable()) m_t << "<informaltable frame='none'><tgroup cols='1'><colspec align='center'/><tbody><row><entry align='center'>";
248 else m_t << "</entry></row></tbody></tgroup></informaltable>";
250 case DocStyleChange::Preformatted:
253 m_t << "<literallayout>";
258 m_t << "</literallayout>";
262 /* There is no equivalent Docbook tag for rendering Small text */
263 case DocStyleChange::Small: /* XSLT Stylesheets can be used */ break;
265 case DocStyleChange::Strike: break;
266 case DocStyleChange::Underline: break;
267 case DocStyleChange::Div: /* HTML only */ break;
268 case DocStyleChange::Span: /* HTML only */ break;
272 void DocbookDocVisitor::visit(DocVerbatim *s)
276 SrcLangExt langExt = getLanguageFromFileName(m_langExt);
279 case DocVerbatim::Code: // fall though
280 m_t << "<literallayout><computeroutput>";
281 Doxygen::parserManager->getParser(m_langExt)
282 ->parseCode(m_ci,s->context(),s->text(),langExt,
283 s->isExample(),s->exampleFile());
284 m_t << "</computeroutput></literallayout>";
286 case DocVerbatim::Verbatim:
287 m_t << "<literallayout><computeroutput>";
289 m_t << "</computeroutput></literallayout>";
291 case DocVerbatim::HtmlOnly:
293 case DocVerbatim::RtfOnly:
295 case DocVerbatim::ManOnly:
297 case DocVerbatim::LatexOnly:
299 case DocVerbatim::XmlOnly:
301 case DocVerbatim::DocbookOnly:
304 case DocVerbatim::Dot:
306 static int dotindex = 1;
307 QCString baseName(4096);
309 QCString stext = s->text();
310 m_t << "<para>" << endl;
311 name.sprintf("%s%d", "dot_inline_dotgraph_", dotindex);
312 baseName.sprintf("%s%d",
313 (Config_getString(DOCBOOK_OUTPUT)+"/inline_dotgraph_").data(),
316 QFile file(baseName+".dot");
317 if (!file.open(IO_WriteOnly))
319 err("Could not open file %s.msc for writing\n",baseName.data());
321 file.writeBlock( stext, stext.length() );
323 writeDotFile(baseName, s);
324 m_t << "</para>" << endl;
327 case DocVerbatim::Msc:
329 static int mscindex = 1;
330 QCString baseName(4096);
332 QCString stext = s->text();
333 m_t << "<para>" << endl;
334 name.sprintf("%s%d", "msc_inline_mscgraph_", mscindex);
335 baseName.sprintf("%s%d",
336 (Config_getString(DOCBOOK_OUTPUT)+"/inline_mscgraph_").data(),
339 QFile file(baseName+".msc");
340 if (!file.open(IO_WriteOnly))
342 err("Could not open file %s.msc for writing\n",baseName.data());
344 QCString text = "msc {";
347 file.writeBlock( text, text.length() );
349 writeMscFile(baseName,s);
350 m_t << "</para>" << endl;
353 case DocVerbatim::PlantUML:
355 static QCString docbookOutput = Config_getString(DOCBOOK_OUTPUT);
356 QCString baseName = writePlantUMLSource(docbookOutput,s->exampleFile(),s->text());
357 QCString shortName = baseName;
359 if ((i=shortName.findRev('/'))!=-1)
361 shortName=shortName.right(shortName.length()-i-1);
363 m_t << "<para>" << endl;
364 writePlantUMLFile(baseName,s);
365 m_t << "</para>" << endl;
371 void DocbookDocVisitor::visit(DocAnchor *anc)
375 m_t << "<anchor xml:id=\"_" << stripPath(anc->file()) << "_1" << anc->anchor() << "\"/>";
378 void DocbookDocVisitor::visit(DocInclude *inc)
382 SrcLangExt langExt = getLanguageFromFileName(inc->extension());
385 case DocInclude::IncWithLines:
387 m_t << "<literallayout><computeroutput>";
388 QFileInfo cfi( inc->file() );
389 FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
390 Doxygen::parserManager->getParser(inc->extension())
391 ->parseCode(m_ci,inc->context(),
395 inc->exampleFile(), &fd);
396 m_t << "</computeroutput></literallayout>";
399 case DocInclude::Include:
400 m_t << "<literallayout><computeroutput>";
401 Doxygen::parserManager->getParser(inc->extension())
402 ->parseCode(m_ci,inc->context(),
407 m_t << "</computeroutput></literallayout>";
409 case DocInclude::DontInclude:
411 case DocInclude::HtmlInclude:
413 case DocInclude::LatexInclude:
415 case DocInclude::VerbInclude:
416 m_t << "<literallayout>";
418 m_t << "</literallayout>";
420 case DocInclude::Snippet:
421 m_t << "<literallayout><computeroutput>";
422 Doxygen::parserManager->getParser(inc->extension())
425 extractBlock(inc->text(),inc->blockId()),
430 m_t << "</computeroutput></literallayout>";
432 case DocInclude::SnipWithLines:
434 QFileInfo cfi( inc->file() );
435 FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
436 m_t << "<literallayout><computeroutput>";
437 Doxygen::parserManager->getParser(inc->extension())
440 extractBlock(inc->text(),inc->blockId()),
445 lineBlock(inc->text(),inc->blockId()),
447 FALSE, // inlineFragment
449 TRUE // show line number
451 m_t << "</computeroutput></literallayout>";
454 case DocInclude::SnippetDoc:
455 case DocInclude::IncludeDoc:
456 err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s"
457 "Please create a bug report\n",__FILE__);
462 void DocbookDocVisitor::visit(DocIncOperator *op)
469 m_t << "<programlisting>";
474 SrcLangExt langExt = getLanguageFromFileName(m_langExt);
475 if (op->type()!=DocIncOperator::Skip)
480 Doxygen::parserManager->getParser(m_langExt)
481 ->parseCode(m_ci,op->context(),
482 op->text(),langExt,op->isExample(),
491 if (!m_hide) m_t << "</programlisting>";
495 if (!m_hide) m_t << endl;
499 void DocbookDocVisitor::visit(DocFormula *f)
504 if (f->isInline()) m_t << "<inlinemediaobject>" << endl;
505 else m_t << " <mediaobject>" << endl;
506 m_t << " <imageobject>" << endl;
507 m_t << " <imagedata ";
508 m_t << "align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\"" << f->relPath() << f->name() << ".png\"/>" << endl;
509 m_t << " </imageobject>" << endl;
510 if (f->isInline()) m_t << "</inlinemediaobject>" << endl;
511 else m_t << " </mediaobject>" << endl;
514 void DocbookDocVisitor::visit(DocIndexEntry *ie)
518 m_t << "<indexterm><primary>";
520 m_t << "</primary></indexterm>" << endl;
523 void DocbookDocVisitor::visit(DocSimpleSectSep *)
526 // m_t << "<simplesect/>";
529 void DocbookDocVisitor::visit(DocCite *cite)
533 if (!cite->file().isEmpty()) startLink(cite->file(),cite->anchor());
534 filter(cite->text());
535 if (!cite->file().isEmpty()) endLink();
538 //--------------------------------------
539 // visitor functions for compound nodes
540 //--------------------------------------
542 void DocbookDocVisitor::visitPre(DocAutoList *l)
548 m_t << "<orderedlist>\n";
552 m_t << "<itemizedlist>\n";
556 void DocbookDocVisitor::visitPost(DocAutoList *l)
562 m_t << "</orderedlist>\n";
566 m_t << "</itemizedlist>\n";
570 void DocbookDocVisitor::visitPre(DocAutoListItem *)
577 void DocbookDocVisitor::visitPost(DocAutoListItem *)
581 m_t << "</listitem>";
584 void DocbookDocVisitor::visitPre(DocPara *)
592 void DocbookDocVisitor::visitPost(DocPara *)
600 void DocbookDocVisitor::visitPre(DocRoot *)
603 //m_t << "<hr><h4><font color=\"red\">New parser:</font></h4>\n";
606 void DocbookDocVisitor::visitPost(DocRoot *)
609 //m_t << "<hr><h4><font color=\"red\">Old parser:</font></h4>\n";
612 void DocbookDocVisitor::visitPre(DocSimpleSect *s)
618 case DocSimpleSect::See:
621 m_t << "<formalpara><title>" << theTranslator->trSeeAlso() << ": </title>" << endl;
625 m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trSeeAlso()) << ": </title>" << endl;
628 case DocSimpleSect::Return:
631 m_t << "<formalpara><title>" << theTranslator->trReturns()<< ": </title>" << endl;
635 m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trReturns()) << ": </title>" << endl;
638 case DocSimpleSect::Author:
641 m_t << "<formalpara><title>" << theTranslator->trAuthor(TRUE, TRUE) << ": </title>" << endl;
645 m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trAuthor(TRUE, TRUE)) << ": </title>" << endl;
648 case DocSimpleSect::Authors:
651 m_t << "<formalpara><title>" << theTranslator->trAuthor(TRUE, FALSE) << ": </title>" << endl;
655 m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trAuthor(TRUE, FALSE)) << ": </title>" << endl;
658 case DocSimpleSect::Version:
661 m_t << "<formalpara><title>" << theTranslator->trVersion() << ": </title>" << endl;
665 m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trVersion()) << ": </title>" << endl;
668 case DocSimpleSect::Since:
671 m_t << "<formalpara><title>" << theTranslator->trSince() << ": </title>" << endl;
675 m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trSince()) << ": </title>" << endl;
678 case DocSimpleSect::Date:
681 m_t << "<formalpara><title>" << theTranslator->trDate() << ": </title>" << endl;
685 m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trDate()) << ": </title>" << endl;
688 case DocSimpleSect::Note:
691 m_t << "<note><title>" << theTranslator->trNote() << ": </title>" << endl;
695 m_t << "<note><title>" << convertToDocBook(theTranslator->trNote()) << ": </title>" << endl;
698 case DocSimpleSect::Warning:
701 m_t << "<warning><title>" << theTranslator->trWarning() << ": </title>" << endl;
705 m_t << "<warning><title>" << convertToDocBook(theTranslator->trWarning()) << ": </title>" << endl;
708 case DocSimpleSect::Pre:
711 m_t << "<formalpara><title>" << theTranslator->trPrecondition() << ": </title>" << endl;
715 m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trPrecondition()) << ": </title>" << endl;
718 case DocSimpleSect::Post:
721 m_t << "<formalpara><title>" << theTranslator->trPostcondition() << ": </title>" << endl;
725 m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trPostcondition()) << ": </title>" << endl;
728 case DocSimpleSect::Copyright:
731 m_t << "<formalpara><title>" << theTranslator->trCopyright() << ": </title>" << endl;
735 m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trCopyright()) << ": </title>" << endl;
738 case DocSimpleSect::Invar:
741 m_t << "<formalpara><title>" << theTranslator->trInvariant() << ": </title>" << endl;
745 m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trInvariant()) << ": </title>" << endl;
748 case DocSimpleSect::Remark:
749 // <remark> is miising the <title> possibility
752 m_t << "<formalpara><title>" << theTranslator->trRemarks() << ": </title>" << endl;
756 m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trRemarks()) << ": </title>" << endl;
759 case DocSimpleSect::Attention:
762 m_t << "<caution><title>" << theTranslator->trAttention() << ": </title>" << endl;
766 m_t << "<caution><title>" << convertToDocBook(theTranslator->trAttention()) << ": </title>" << endl;
769 case DocSimpleSect::User:
771 m_t << "<formalpara>" << endl;
773 m_t << "<para>" << endl;
775 case DocSimpleSect::Rcs:
776 case DocSimpleSect::Unknown:
777 m_t << "<para>" << endl;
782 void DocbookDocVisitor::visitPost(DocSimpleSect *s)
788 case DocSimpleSect::Rcs:
789 case DocSimpleSect::Unknown:
790 m_t << "</para>" << endl;
792 case DocSimpleSect::User:
794 m_t << "</formalpara>" << endl;
796 m_t << "</para>" << endl;
798 case DocSimpleSect::Note:
799 m_t << "</note>" << endl;
801 case DocSimpleSect::Attention:
802 m_t << "</caution>" << endl;
804 case DocSimpleSect::Warning:
805 m_t << "</warning>" << endl;
808 m_t << "</formalpara>" << endl;
813 void DocbookDocVisitor::visitPre(DocTitle *t)
817 if (t->hasTitle()) m_t << "<title>";
820 void DocbookDocVisitor::visitPost(DocTitle *t)
824 if (t->hasTitle()) m_t << "</title>";
827 void DocbookDocVisitor::visitPre(DocSimpleList *)
831 m_t << "<itemizedlist>\n";
834 void DocbookDocVisitor::visitPost(DocSimpleList *)
838 m_t << "</itemizedlist>\n";
841 void DocbookDocVisitor::visitPre(DocSimpleListItem *)
848 void DocbookDocVisitor::visitPost(DocSimpleListItem *)
852 m_t << "</listitem>\n";
855 void DocbookDocVisitor::visitPre(DocSection *s)
859 m_t << "<section xml:id=\"_" << stripPath(s->file());
860 if (!s->anchor().isEmpty()) m_t << "_1" << s->anchor();
861 m_t << "\">" << endl;
864 m_t << "</title>" << endl;
867 void DocbookDocVisitor::visitPost(DocSection *)
870 m_t << "</section>\n";
873 void DocbookDocVisitor::visitPre(DocHtmlList *s)
877 if (s->type()==DocHtmlList::Ordered)
878 m_t << "<orderedlist>\n";
880 m_t << "<itemizedlist>\n";
883 void DocbookDocVisitor::visitPost(DocHtmlList *s)
887 if (s->type()==DocHtmlList::Ordered)
888 m_t << "</orderedlist>\n";
890 m_t << "</itemizedlist>\n";
893 void DocbookDocVisitor::visitPre(DocHtmlListItem *)
897 m_t << "<listitem>\n";
900 void DocbookDocVisitor::visitPost(DocHtmlListItem *)
904 m_t << "</listitem>\n";
907 void DocbookDocVisitor::visitPre(DocHtmlDescList *)
911 m_t << "<variablelist>\n";
914 void DocbookDocVisitor::visitPost(DocHtmlDescList *)
918 m_t << "</variablelist>\n";
921 void DocbookDocVisitor::visitPre(DocHtmlDescTitle *)
925 m_t << "<varlistentry><term>";
928 void DocbookDocVisitor::visitPost(DocHtmlDescTitle *)
935 void DocbookDocVisitor::visitPre(DocHtmlDescData *)
942 void DocbookDocVisitor::visitPost(DocHtmlDescData *)
946 m_t << "</listitem></varlistentry>\n";
949 static int colCnt = 0;
950 static bool bodySet = FALSE; // it is possible to have tables without a header
951 void DocbookDocVisitor::visitPre(DocHtmlTable *t)
956 m_t << "<informaltable frame=\"all\">" << endl;
957 m_t << " <tgroup cols=\"" << t->numColumns() << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl;
958 for (int i = 0; i <t->numColumns(); i++)
960 // do something with colwidth based of cell width specification (be aware of possible colspan in the header)?
961 m_t << " <colspec colname='c" << i+1 << "'/>\n";
965 void DocbookDocVisitor::visitPost(DocHtmlTable *)
969 if (bodySet) m_t << " </tbody>" << endl;
971 m_t << " </tgroup>" << endl;
972 m_t << "</informaltable>" << endl;
975 void DocbookDocVisitor::visitPre(DocHtmlRow *tr)
981 if (tr->isHeading()) m_t << "<thead>\n";
990 HtmlAttribListIterator li(tr->attribs());
992 for (li.toFirst();(opt=li.current());++li)
994 if (opt->name=="class")
998 else if (opt->name=="style")
1002 else if (opt->name=="height")
1006 else if (opt->name=="filter")
1012 m_t << " " << opt->name << "='" << opt->value << "'";
1018 void DocbookDocVisitor::visitPost(DocHtmlRow *tr)
1023 if (tr->isHeading())
1026 m_t << "</thead><tbody>\n";
1030 void DocbookDocVisitor::visitPre(DocHtmlCell *c)
1037 HtmlAttribListIterator li(c->attribs());
1039 for (li.toFirst();(opt=li.current());++li)
1041 if (opt->name=="colspan")
1043 m_t << " namest='c" << colCnt << "'";
1044 int cols = opt->value.toInt();
1045 colCnt += (cols - 1);
1046 m_t << " nameend='c" << colCnt << "'";
1048 else if (opt->name=="rowspan")
1050 int extraRows = opt->value.toInt() - 1;
1051 m_t << " morerows='" << extraRows << "'";
1053 else if (opt->name=="class")
1055 if (opt->value == "markdownTableBodyRight")
1057 m_t << " align='right'";
1059 else if (opt->value == "markdownTableBodyLeftt")
1061 m_t << " align='left'";
1063 else if (opt->value == "markdownTableBodyCenter")
1065 m_t << " align='center'";
1067 else if (opt->value == "markdownTableHeadRight")
1069 m_t << " align='right'";
1071 else if (opt->value == "markdownTableHeadLeftt")
1073 m_t << " align='left'";
1075 else if (opt->value == "markdownTableHeadCenter")
1077 m_t << " align='center'";
1080 else if (opt->name=="style")
1084 else if (opt->name=="width")
1088 else if (opt->name=="height")
1094 m_t << " " << opt->name << "='" << opt->value << "'";
1100 void DocbookDocVisitor::visitPost(DocHtmlCell *c)
1107 void DocbookDocVisitor::visitPre(DocHtmlCaption *c)
1114 void DocbookDocVisitor::visitPost(DocHtmlCaption *)
1118 m_t << "</caption>\n";
1121 void DocbookDocVisitor::visitPre(DocInternal *)
1125 // TODO: to be implemented
1128 void DocbookDocVisitor::visitPost(DocInternal *)
1132 // TODO: to be implemented
1135 void DocbookDocVisitor::visitPre(DocHRef *href)
1139 m_t << "<link xlink:href=\"" << convertToDocBook(href->url()) << "\">";
1142 void DocbookDocVisitor::visitPost(DocHRef *)
1149 void DocbookDocVisitor::visitPre(DocHtmlHeader *)
1153 m_t << "<formalpara><title>";
1156 void DocbookDocVisitor::visitPost(DocHtmlHeader *)
1160 m_t << "</title></formalpara>\n";
1163 void DocbookDocVisitor::visitPre(DocImage *img)
1166 if (img->type()==DocImage::DocBook)
1170 QCString baseName=img->name();
1172 if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
1174 baseName=baseName.right(baseName.length()-i-1);
1176 visitPreStart(m_t, img->children(), img->hasCaption(), img->relPath() + baseName, img->width(), img->height(), img->isInlineImage());
1185 void DocbookDocVisitor::visitPost(DocImage *img)
1188 if (img->type()==DocImage::DocBook)
1191 visitPostEnd(m_t, img -> hasCaption(),img -> isInlineImage());
1192 // copy the image to the output dir
1193 QCString baseName=img->name();
1195 if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
1197 baseName=baseName.right(baseName.length()-i-1);
1201 FileDef *fd=findFileDef(Doxygen::imageNameDict, baseName, ambig);
1204 m_file=fd->absFilePath();
1206 QFile inImage(m_file);
1207 QFile outImage(Config_getString(DOCBOOK_OUTPUT)+"/"+baseName.data());
1208 if (inImage.open(IO_ReadOnly))
1210 if (outImage.open(IO_WriteOnly))
1212 char *buffer = new char[inImage.size()];
1213 inImage.readBlock(buffer,inImage.size());
1214 outImage.writeBlock(buffer,inImage.size());
1226 void DocbookDocVisitor::visitPre(DocDotFile *df)
1230 startDotFile(df->file(),df->width(),df->height(),df->hasCaption(),df->children());
1233 void DocbookDocVisitor::visitPost(DocDotFile *df)
1237 endDotFile(df->hasCaption());
1240 void DocbookDocVisitor::visitPre(DocMscFile *df)
1244 startMscFile(df->file(),df->width(),df->height(),df->hasCaption(),df->children());
1247 void DocbookDocVisitor::visitPost(DocMscFile *df)
1251 endMscFile(df->hasCaption());
1253 void DocbookDocVisitor::visitPre(DocDiaFile *df)
1257 startDiaFile(df->file(),df->width(),df->height(),df->hasCaption(),df->children());
1260 void DocbookDocVisitor::visitPost(DocDiaFile *df)
1264 endDiaFile(df->hasCaption());
1267 void DocbookDocVisitor::visitPre(DocLink *lnk)
1271 startLink(lnk->file(),lnk->anchor());
1274 void DocbookDocVisitor::visitPost(DocLink *)
1281 void DocbookDocVisitor::visitPre(DocRef *ref)
1285 if (ref->isSubPage())
1287 startLink(0,ref->anchor());
1291 if (!ref->file().isEmpty()) startLink(ref->file(),ref->anchor());
1294 if (!ref->hasLinkText()) filter(ref->targetTitle());
1297 void DocbookDocVisitor::visitPost(DocRef *ref)
1301 if (!ref->file().isEmpty()) endLink();
1304 void DocbookDocVisitor::visitPre(DocSecRefItem *ref)
1308 //m_t << "<tocentry xml:idref=\"_" << stripPath(ref->file()) << "_1" << ref->anchor() << "\">";
1309 m_t << "<tocentry>";
1312 void DocbookDocVisitor::visitPost(DocSecRefItem *)
1316 m_t << "</tocentry>" << endl;
1319 void DocbookDocVisitor::visitPre(DocSecRefList *)
1323 m_t << "<toc>" << endl;
1326 void DocbookDocVisitor::visitPost(DocSecRefList *)
1330 m_t << "</toc>" << endl;
1333 void DocbookDocVisitor::visitPre(DocParamSect *s)
1338 m_t << " <formalpara>" << endl;
1339 m_t << " <title>" << endl;
1342 case DocParamSect::Param: m_t << theTranslator->trParameters(); break;
1343 case DocParamSect::RetVal: m_t << theTranslator->trReturnValues(); break;
1344 case DocParamSect::Exception: m_t << theTranslator->trExceptions(); break;
1345 case DocParamSect::TemplateParam: m_t << theTranslator->trTemplateParameters(); break;
1349 m_t << " </title>" << endl;
1350 m_t << " <para>" << endl;
1351 m_t << " <table frame=\"all\">" << endl;
1353 if (s->type() == DocParamSect::Param)
1355 bool hasInOutSpecs = s->hasInOutSpecifier();
1356 bool hasTypeSpecs = s->hasTypeSpecifier();
1357 if (hasInOutSpecs && hasTypeSpecs) ncols += 2;
1358 else if (hasInOutSpecs || hasTypeSpecs) ncols += 1;
1360 m_t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl;
1361 for (int i = 1; i <= ncols; i++)
1363 if (i == ncols) m_t << " <colspec colwidth=\"4*\"/>" << endl;
1364 else m_t << " <colspec colwidth=\"1*\"/>" << endl;
1366 m_t << " <tbody>" << endl;
1369 void DocbookDocVisitor::visitPost(DocParamSect *)
1373 m_t << " </tbody>" << endl;
1374 m_t << " </tgroup>" << endl;
1375 m_t << " </table>" << endl;
1376 m_t << " </para>" << endl;
1377 m_t << " </formalpara>" << endl;
1381 void DocbookDocVisitor::visitPre(DocParamList *pl)
1385 m_t << " <row>" << endl;
1387 DocParamSect::Type parentType = DocParamSect::Unknown;
1388 DocParamSect *sect = 0;
1389 if (pl->parent() && pl->parent()->kind()==DocNode::Kind_ParamSect)
1391 parentType = ((DocParamSect*)pl->parent())->type();
1392 sect=(DocParamSect*)pl->parent();
1395 if (sect && sect->hasInOutSpecifier())
1398 if (pl->direction()!=DocParamSect::Unspecified)
1400 if (pl->direction()==DocParamSect::In)
1404 else if (pl->direction()==DocParamSect::Out)
1408 else if (pl->direction()==DocParamSect::InOut)
1416 if (sect && sect->hasTypeSpecifier())
1418 QListIterator<DocNode> li(pl->paramTypes());
1422 for (li.toFirst();(type=li.current());++li)
1424 if (!first) m_t << " | "; else first=FALSE;
1425 if (type->kind()==DocNode::Kind_Word)
1427 visit((DocWord*)type);
1429 else if (type->kind()==DocNode::Kind_LinkedWord)
1431 visit((DocLinkedWord*)type);
1437 QListIterator<DocNode> li(pl->parameters());
1441 m_t << " <entry></entry>" << endl;
1447 for (li.toFirst();(param=li.current());++li)
1453 if (param->kind()==DocNode::Kind_Word)
1455 visit((DocWord*)param);
1457 else if (param->kind()==DocNode::Kind_LinkedWord)
1459 visit((DocLinkedWord*)param);
1463 m_t << "</entry>" << endl;
1468 void DocbookDocVisitor::visitPost(DocParamList *)
1472 m_t << "</entry>" << endl;
1473 m_t << " </row>" << endl;
1476 void DocbookDocVisitor::visitPre(DocXRefItem *x)
1480 if (x->title().isEmpty()) return;
1481 m_t << "<para><link linkend=\"_";
1482 m_t << stripPath(x->file()) << "_1" << x->anchor();
1489 void DocbookDocVisitor::visitPost(DocXRefItem *x)
1493 if (x->title().isEmpty()) return;
1497 void DocbookDocVisitor::visitPre(DocInternalRef *ref)
1501 startLink(ref->file(),ref->anchor());
1504 void DocbookDocVisitor::visitPost(DocInternalRef *)
1512 void DocbookDocVisitor::visitPre(DocCopy *)
1516 // TODO: to be implemented
1520 void DocbookDocVisitor::visitPost(DocCopy *)
1524 // TODO: to be implemented
1528 void DocbookDocVisitor::visitPre(DocText *)
1531 // TODO: to be implemented
1535 void DocbookDocVisitor::visitPost(DocText *)
1538 // TODO: to be implemented
1542 void DocbookDocVisitor::visitPre(DocHtmlBlockQuote *)
1546 m_t << "<blockquote>";
1549 void DocbookDocVisitor::visitPost(DocHtmlBlockQuote *)
1553 m_t << "</blockquote>";
1556 void DocbookDocVisitor::visitPre(DocVhdlFlow *)
1559 // TODO: to be implemented
1563 void DocbookDocVisitor::visitPost(DocVhdlFlow *)
1566 // TODO: to be implemented
1569 void DocbookDocVisitor::visitPre(DocParBlock *)
1574 void DocbookDocVisitor::visitPost(DocParBlock *)
1580 void DocbookDocVisitor::filter(const char *str)
1583 m_t << convertToDocBook(str);
1586 void DocbookDocVisitor::startLink(const QCString &file,const QCString &anchor)
1589 m_t << "<link linkend=\"_" << stripPath(file);
1590 if (!anchor.isEmpty())
1592 if (file) m_t << "_1";
1598 void DocbookDocVisitor::endLink()
1604 void DocbookDocVisitor::pushEnabled()
1607 m_enabled.push(new bool(m_hide));
1610 void DocbookDocVisitor::popEnabled()
1613 bool *v=m_enabled.pop();
1619 void DocbookDocVisitor::writeMscFile(const QCString &baseName, DocVerbatim *s)
1622 QCString shortName = baseName;
1624 if ((i=shortName.findRev('/'))!=-1)
1626 shortName=shortName.right(shortName.length()-i-1);
1628 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1629 writeMscGraphFromFile(baseName+".msc",outDir,shortName,MSC_BITMAP);
1630 visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + ".png", s->width(), s->height());
1631 visitCaption(s->children());
1632 visitPostEnd(m_t, s->hasCaption());
1635 void DocbookDocVisitor::writePlantUMLFile(const QCString &baseName, DocVerbatim *s)
1638 QCString shortName = baseName;
1640 if ((i=shortName.findRev('/'))!=-1)
1642 shortName=shortName.right(shortName.length()-i-1);
1644 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1645 generatePlantUMLOutput(baseName,outDir,PUML_BITMAP);
1646 visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + ".png", s->width(),s->height());
1647 visitCaption(s->children());
1648 visitPostEnd(m_t, s->hasCaption());
1651 void DocbookDocVisitor::startMscFile(const QCString &fileName,
1652 const QCString &width,
1653 const QCString &height,
1655 const QList<DocNode> &children
1659 QCString baseName=fileName;
1661 if ((i=baseName.findRev('/'))!=-1)
1663 baseName=baseName.right(baseName.length()-i-1);
1665 if ((i=baseName.find('.'))!=-1)
1667 baseName=baseName.left(i);
1669 baseName.prepend("msc_");
1670 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1671 writeMscGraphFromFile(fileName,outDir,baseName,MSC_BITMAP);
1672 m_t << "<para>" << endl;
1673 visitPreStart(m_t, children, hasCaption, baseName + ".png", width, height);
1676 void DocbookDocVisitor::endMscFile(bool hasCaption)
1680 visitPostEnd(m_t, hasCaption);
1681 m_t << "</para>" << endl;
1684 void DocbookDocVisitor::writeDiaFile(const QCString &baseName, DocVerbatim *s)
1687 QCString shortName = baseName;
1689 if ((i=shortName.findRev('/'))!=-1)
1691 shortName=shortName.right(shortName.length()-i-1);
1693 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1694 writeDiaGraphFromFile(baseName+".dia",outDir,shortName,DIA_BITMAP);
1695 visitPreStart(m_t, s->children(), s->hasCaption(), shortName, s->width(),s->height());
1696 visitCaption(s->children());
1697 visitPostEnd(m_t, s->hasCaption());
1700 void DocbookDocVisitor::startDiaFile(const QCString &fileName,
1701 const QCString &width,
1702 const QCString &height,
1704 const QList<DocNode> &children
1708 QCString baseName=fileName;
1710 if ((i=baseName.findRev('/'))!=-1)
1712 baseName=baseName.right(baseName.length()-i-1);
1714 if ((i=baseName.find('.'))!=-1)
1716 baseName=baseName.left(i);
1718 baseName.prepend("dia_");
1719 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1720 writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP);
1721 m_t << "<para>" << endl;
1722 visitPreStart(m_t, children, hasCaption, baseName + ".png", width, height);
1725 void DocbookDocVisitor::endDiaFile(bool hasCaption)
1729 visitPostEnd(m_t, hasCaption);
1730 m_t << "</para>" << endl;
1733 void DocbookDocVisitor::writeDotFile(const QCString &baseName, DocVerbatim *s)
1736 QCString shortName = baseName;
1738 if ((i=shortName.findRev('/'))!=-1)
1740 shortName=shortName.right(shortName.length()-i-1);
1742 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1743 writeDotGraphFromFile(baseName+".dot",outDir,shortName,GOF_BITMAP);
1744 visitPreStart(m_t, s->children(), s->hasCaption(), s->relPath() + shortName + "." + getDotImageExtension(), s->width(),s->height());
1745 visitCaption(s->children());
1746 visitPostEnd(m_t, s->hasCaption());
1749 void DocbookDocVisitor::startDotFile(const QCString &fileName,
1750 const QCString &width,
1751 const QCString &height,
1753 const QList<DocNode> &children
1757 QCString baseName=fileName;
1759 if ((i=baseName.findRev('/'))!=-1)
1761 baseName=baseName.right(baseName.length()-i-1);
1763 if ((i=baseName.find('.'))!=-1)
1765 baseName=baseName.left(i);
1767 baseName.prepend("dot_");
1768 QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1769 QCString imgExt = getDotImageExtension();
1770 writeDotGraphFromFile(fileName,outDir,baseName,GOF_BITMAP);
1771 m_t << "<para>" << endl;
1772 visitPreStart(m_t, children, hasCaption, baseName + "." + imgExt, width, height);
1775 void DocbookDocVisitor::endDotFile(bool hasCaption)
1780 visitPostEnd(m_t, hasCaption);
1781 m_t << "</para>" << endl;