My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
docbookvisitor.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  *
4  *
5  *
6  * Copyright (C) 1997-2015 by Dimitri van Heesch.
7  *
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.
13  *
14  * Documents produced by Doxygen are derivative works derived from the
15  * input used in their production; they are not affected by this license.
16  *
17  */
18 
19 #include <qfileinfo.h>
20 
21 #include "docbookvisitor.h"
22 #include "docparser.h"
23 #include "language.h"
24 #include "doxygen.h"
25 #include "outputgen.h"
26 #include "docbookgen.h"
27 #include "dot.h"
28 #include "message.h"
29 #include "util.h"
30 #include "parserintf.h"
31 #include "filename.h"
32 #include "config.h"
33 #include "filedef.h"
34 #include "msc.h"
35 #include "dia.h"
36 #include "htmlentity.h"
37 #include "plantuml.h"
38 
39 static void visitPreStart(FTextStream &t, const bool hasCaption, QCString name, QCString width, QCString height)
40 {
41  QCString tmpStr;
42  t << " <figure>" << endl;
43  t << " <title></title>" << endl;
44  t << " <mediaobject>" << endl;
45  t << " <imageobject>" << endl;
46  t << " <imagedata";
47  if (!width.isEmpty())
48  {
49  t << " width=\"" << convertToXML(width) << "\"";
50  }
51  else
52  {
53  t << " width=\"50%\"";
54  }
55  if (!height.isEmpty())
56  {
57  t << " depth=\"" << convertToXML(tmpStr) << "\"";
58  }
59  t << " align=\"center\" valign=\"middle\" scalefit=\"1\" fileref=\"" << name << "\">";
60  t << "</imagedata>" << endl;
61  t << " </imageobject>" << endl;
62  if (hasCaption)
63  {
64  t << " <caption>" << endl;
65  }
66 }
67 
68 static void visitPostEnd(FTextStream &t, const bool hasCaption)
69 {
70  t << endl;
71  if (hasCaption)
72  {
73  t << " </caption>" << endl;
74  }
75  t << " </mediaobject>" << endl;
76  t << " </figure>" << endl;
77 }
78 
79 static void visitCaption(DocbookDocVisitor *parent, QList<DocNode> children)
80 {
81  QListIterator<DocNode> cli(children);
82  DocNode *n;
83  for (cli.toFirst();(n=cli.current());++cli) n->accept(parent);
84 }
85 
87  : DocVisitor(DocVisitor_Docbook), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE)
88 {
89 }
90 
91 //--------------------------------------
92 // visitor functions for leaf nodes
93 //--------------------------------------
94 
96 {
97  if (m_hide) return;
98  filter(w->word());
99 }
100 
102 {
103  if (m_hide) return;
104  startLink(w->file(),w->anchor());
105  filter(w->word());
106  endLink();
107 }
108 
110 {
111  if (m_hide) return;
112  if (m_insidePre)
113  {
114  m_t << w->chars();
115  }
116  else
117  {
118  m_t << " ";
119  }
120 }
121 
123 {
124  if (m_hide) return;
125  const char *res = HtmlEntityMapper::instance()->docbook(s->symbol());
126  if (res)
127  {
128  m_t << res;
129  }
130  else
131  {
132  err("DocBook: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(s->symbol(),TRUE));
133  }
134 }
135 
137 {
138  if (m_hide) return;
139  m_t << "<link xlink:href=\"";
140  if (u->isEmail()) m_t << "mailto:";
141  filter(u->url());
142  m_t << "\">";
143  filter(u->url());
144  m_t << "</link>";
145 }
146 
148 {
149  if (m_hide) return;
150  m_t << endl << "<literallayout>\n</literallayout>" << endl;
151 }
152 
154 {
155  if (m_hide) return;
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";
158 }
159 
161 {
162  if (m_hide) return;
163  switch (s->style())
164  {
166  if (s->enable()) m_t << "<emphasis role=\"bold\">"; else m_t << "</emphasis>";
167  break;
169  if (s->enable()) m_t << "<emphasis>"; else m_t << "</emphasis>";
170  break;
172  if (s->enable()) m_t << "<computeroutput>"; else m_t << "</computeroutput>";
173  break;
175  if (s->enable()) m_t << "<subscript>"; else m_t << "</subscript>";
176  break;
178  if (s->enable()) m_t << "<superscript>"; else m_t << "</superscript>";
179  break;
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>";
183  break;
185  if (s->enable())
186  {
187  m_t << "<literallayout>";
188  m_insidePre=TRUE;
189  }
190  else
191  {
192  m_t << "</literallayout>";
193  m_insidePre=FALSE;
194  }
195  break;
196  /* There is no equivalent Docbook tag for rendering Small text */
197  case DocStyleChange::Small: /* XSLT Stylesheets can be used */ break;
198  /* HTML only */
199  case DocStyleChange::Div: /* HTML only */ break;
200  case DocStyleChange::Span: /* HTML only */ break;
201  }
202 }
203 
205 {
206  if (m_hide) return;
208  switch(s->type())
209  {
210  case DocVerbatim::Code: // fall though
211  m_t << "<literallayout><computeroutput>";
213  ->parseCode(m_ci,s->context(),s->text(),langExt,
214  s->isExample(),s->exampleFile());
215  m_t << "</computeroutput></literallayout>";
216  break;
218  m_t << "<literallayout>";
219  filter(s->text());
220  m_t << "</literallayout>";
221  break;
222  case DocVerbatim::HtmlOnly:
223  break;
224  case DocVerbatim::RtfOnly:
225  break;
226  case DocVerbatim::ManOnly:
227  break;
229  break;
230  case DocVerbatim::XmlOnly:
231  break;
233  break;
234  m_t << s->text();
235  break;
236  case DocVerbatim::Dot:
237  {
238  static int dotindex = 1;
239  QCString baseName(4096);
240  QCString name;
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(),
246  dotindex++
247  );
248  QFile file(baseName+".dot");
249  if (!file.open(IO_WriteOnly))
250  {
251  err("Could not open file %s.msc for writing\n",baseName.data());
252  }
253  file.writeBlock( stext, stext.length() );
254  file.close();
255  writeDotFile(baseName, s);
256  m_t << "</para>" << endl;
257  }
258  break;
259  case DocVerbatim::Msc:
260  {
261  static int mscindex = 1;
262  QCString baseName(4096);
263  QCString name;
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(),
269  mscindex++
270  );
271  QFile file(baseName+".msc");
272  if (!file.open(IO_WriteOnly))
273  {
274  err("Could not open file %s.msc for writing\n",baseName.data());
275  }
276  QCString text = "msc {";
277  text+=stext;
278  text+="}";
279  file.writeBlock( text, text.length() );
280  file.close();
281  writeMscFile(baseName,s);
282  m_t << "</para>" << endl;
283  }
284  break;
286  {
287  static QCString docbookOutput = Config_getString(DOCBOOK_OUTPUT);
288  QCString baseName = writePlantUMLSource(docbookOutput,s->exampleFile(),s->text());
289  QCString shortName = baseName;
290  int i;
291  if ((i=shortName.findRev('/'))!=-1)
292  {
293  shortName=shortName.right(shortName.length()-i-1);
294  }
295  m_t << "<para>" << endl;
296  writePlantUMLFile(baseName,s);
297  m_t << "</para>" << endl;
298  }
299  break;
300  }
301 }
302 
304 {
305  if (m_hide) return;
306  m_t << "<anchor id=\"" << anc->file() << "_1" << anc->anchor() << "\"/>";
307 }
308 
310 {
311  if (m_hide) return;
312  SrcLangExt langExt = getLanguageFromFileName(inc->extension());
313  switch(inc->type())
314  {
316  {
317  m_t << "<literallayout><computeroutput>";
318  QFileInfo cfi( inc->file() );
319  FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
321  ->parseCode(m_ci,inc->context(),
322  inc->text(),
323  langExt,
324  inc->isExample(),
325  inc->exampleFile(), &fd);
326  m_t << "</computeroutput></literallayout>";
327  }
328  break;
329  case DocInclude::Include:
330  m_t << "<literallayout><computeroutput>";
332  ->parseCode(m_ci,inc->context(),
333  inc->text(),
334  langExt,
335  inc->isExample(),
336  inc->exampleFile());
337  m_t << "</computeroutput></literallayout>";
338  break;
340  break;
342  break;
344  break;
346  m_t << "<verbatim>";
347  filter(inc->text());
348  m_t << "</verbatim>";
349  break;
350  case DocInclude::Snippet:
351  m_t << "<literallayout><computeroutput>";
353  ->parseCode(m_ci,
354  inc->context(),
355  extractBlock(inc->text(),inc->blockId()),
356  langExt,
357  inc->isExample(),
358  inc->exampleFile()
359  );
360  m_t << "</computeroutput></literallayout>";
361  break;
364  err("Internal inconsistency: found switch SnippetDoc / IncludeDoc in file: %s"
365  "Please create a bug report\n",__FILE__);
366  break;
367  }
368 }
369 
371 {
372  if (op->isFirst())
373  {
374  if (!m_hide)
375  {
376  m_t << "<programlisting>";
377  }
378  pushEnabled();
379  m_hide = TRUE;
380  }
382  if (op->type()!=DocIncOperator::Skip)
383  {
384  popEnabled();
385  if (!m_hide)
386  {
388  ->parseCode(m_ci,op->context(),
389  op->text(),langExt,op->isExample(),
390  op->exampleFile());
391  }
392  pushEnabled();
393  m_hide=TRUE;
394  }
395  if (op->isLast())
396  {
397  popEnabled();
398  if (!m_hide) m_t << "</programlisting>";
399  }
400  else
401  {
402  if (!m_hide) m_t << endl;
403  }
404 }
405 
407 {
408  if (m_hide) return;
409  m_t << "<equation><title>" << f->name() << "</title>";
410  filter(f->text());
411  m_t << "</equation>";
412 }
413 
415 {
416  if (m_hide) return;
417  m_t << "<indexentry><primaryie>" << endl;
418  filter(ie->entry());
419  m_t << "</primaryie><secondaryie></secondaryie></indexentry>" << endl;
420 }
421 
423 {
424  m_t << "<simplesect/>";
425 }
426 
428 {
429  if (m_hide) return;
430  if (!cite->file().isEmpty()) startLink(cite->file(),cite->anchor());
431  filter(cite->text());
432  if (!cite->file().isEmpty()) endLink();
433 }
434 
435 //--------------------------------------
436 // visitor functions for compound nodes
437 //--------------------------------------
438 
440 {
441  if (m_hide) return;
442  if (l->isEnumList())
443  {
444  m_t << "<orderedlist>\n";
445  }
446  else
447  {
448  m_t << "<itemizedlist>\n";
449  }
450 }
451 
453 {
454  if (m_hide) return;
455  if (l->isEnumList())
456  {
457  m_t << "</orderedlist>\n";
458  }
459  else
460  {
461  m_t << "</itemizedlist>\n";
462  }
463 }
464 
466 {
467  if (m_hide) return;
468  m_t << "<listitem>";
469 }
470 
472 {
473  if (m_hide) return;
474  m_t << "</listitem>";
475 }
476 
478 {
479  if (m_hide) return;
480  m_t << endl;
481  m_t << "<para>";
482 }
483 
485 {
486  if (m_hide) return;
487  m_t << "</para>";
488  m_t << endl;
489 }
490 
492 {
493  //m_t << "<hr><h4><font color=\"red\">New parser:</font></h4>\n";
494 }
495 
497 {
498  //m_t << "<hr><h4><font color=\"red\">Old parser:</font></h4>\n";
499 }
500 
502 {
503  if (m_hide) return;
504  switch(s->type())
505  {
506  case DocSimpleSect::See:
507  if (m_insidePre)
508  {
509  m_t << "<formalpara><title>" << theTranslator->trSeeAlso() << ": </title>" << endl;
510  }
511  else
512  {
513  m_t << "<formalpara><title>" << convertToXML(theTranslator->trSeeAlso()) << ": </title>" << endl;
514  }
515  break;
517  if (m_insidePre)
518  {
519  m_t << "<formalpara><title>" << theTranslator->trReturns()<< ": </title>" << endl;
520  }
521  else
522  {
523  m_t << "<formalpara><title>" << convertToXML(theTranslator->trReturns()) << ": </title>" << endl;
524  }
525  break;
527  if (m_insidePre)
528  {
529  m_t << "<formalpara><title>" << theTranslator->trAuthor(TRUE, TRUE) << ": </title>" << endl;
530  }
531  else
532  {
533  m_t << "<formalpara><title>" << convertToXML(theTranslator->trAuthor(TRUE, TRUE)) << ": </title>" << endl;
534  }
535  break;
537  if (m_insidePre)
538  {
539  m_t << "<formalpara><title>" << theTranslator->trAuthor(TRUE, FALSE) << ": </title>" << endl;
540  }
541  else
542  {
543  m_t << "<formalpara><title>" << convertToXML(theTranslator->trAuthor(TRUE, FALSE)) << ": </title>" << endl;
544  }
545  break;
547  if (m_insidePre)
548  {
549  m_t << "<formalpara><title>" << theTranslator->trVersion() << ": </title>" << endl;
550  }
551  else
552  {
553  m_t << "<formalpara><title>" << convertToXML(theTranslator->trVersion()) << ": </title>" << endl;
554  }
555  break;
557  if (m_insidePre)
558  {
559  m_t << "<formalpara><title>" << theTranslator->trSince() << ": </title>" << endl;
560  }
561  else
562  {
563  m_t << "<formalpara><title>" << convertToXML(theTranslator->trSince()) << ": </title>" << endl;
564  }
565  break;
566  case DocSimpleSect::Date:
567  if (m_insidePre)
568  {
569  m_t << "<formalpara><title>" << theTranslator->trDate() << ": </title>" << endl;
570  }
571  else
572  {
573  m_t << "<formalpara><title>" << convertToXML(theTranslator->trDate()) << ": </title>" << endl;
574  }
575  break;
576  case DocSimpleSect::Note:
577  if (m_insidePre)
578  {
579  m_t << "<formalpara><title>" << theTranslator->trNote() << ": </title>" << endl;
580  }
581  else
582  {
583  m_t << "<formalpara><title>" << convertToXML(theTranslator->trNote()) << ": </title>" << endl;
584  }
585  break;
587  if (m_insidePre)
588  {
589  m_t << "<formalpara><title>" << theTranslator->trWarning() << ": </title>" << endl;
590  }
591  else
592  {
593  m_t << "<formalpara><title>" << convertToXML(theTranslator->trWarning()) << ": </title>" << endl;
594  }
595  break;
596  case DocSimpleSect::Pre:
597  if (m_insidePre)
598  {
599  m_t << "<formalpara><title>" << theTranslator->trPrecondition() << ": </title>" << endl;
600  }
601  else
602  {
603  m_t << "<formalpara><title>" << convertToXML(theTranslator->trPrecondition()) << ": </title>" << endl;
604  }
605  break;
606  case DocSimpleSect::Post:
607  if (m_insidePre)
608  {
609  m_t << "<formalpara><title>" << theTranslator->trPostcondition() << ": </title>" << endl;
610  }
611  else
612  {
613  m_t << "<formalpara><title>" << convertToXML(theTranslator->trPostcondition()) << ": </title>" << endl;
614  }
615  break;
617  if (m_insidePre)
618  {
619  m_t << "<formalpara><title>" << theTranslator->trCopyright() << ": </title>" << endl;
620  }
621  else
622  {
623  m_t << "<formalpara><title>" << convertToXML(theTranslator->trCopyright()) << ": </title>" << endl;
624  }
625  break;
627  if (m_insidePre)
628  {
629  m_t << "<formalpara><title>" << theTranslator->trInvariant() << ": </title>" << endl;
630  }
631  else
632  {
633  m_t << "<formalpara><title>" << convertToXML(theTranslator->trInvariant()) << ": </title>" << endl;
634  }
635  break;
637  if (m_insidePre)
638  {
639  m_t << "<formalpara><title>" << theTranslator->trRemarks() << ": </title>" << endl;
640  }
641  else
642  {
643  m_t << "<formalpara><title>" << convertToXML(theTranslator->trRemarks()) << ": </title>" << endl;
644  }
645  break;
647  if (m_insidePre)
648  {
649  m_t << "<formalpara><title>" << theTranslator->trAttention() << ": </title>" << endl;
650  }
651  else
652  {
653  m_t << "<formalpara><title>" << convertToXML(theTranslator->trAttention()) << ": </title>" << endl;
654  }
655  break;
656  case DocSimpleSect::User:
657  m_t << "<formalpara><title></title>" << endl;
658  break;
659  case DocSimpleSect::Rcs:
660  m_t << "<formalpara><title></title>" << endl;
661  break;
662  case DocSimpleSect::Unknown: m_t << "<formalpara><title></title>" << endl; break;
663  }
664 }
665 
667 {
668  if (m_hide) return;
669  m_t << "</formalpara>" << endl;
670 }
671 
673 {
674  if (m_hide) return;
675  m_t << "<title>";
676 }
677 
679 {
680  if (m_hide) return;
681  m_t << "</title>";
682 }
683 
685 {
686  if (m_hide) return;
687  m_t << "<itemizedlist>\n";
688 }
689 
691 {
692  if (m_hide) return;
693  m_t << "</itemizedlist>\n";
694 }
695 
697 {
698  if (m_hide) return;
699  m_t << "<listitem>";
700 }
701 
703 {
704  if (m_hide) return;
705  m_t << "</listitem>\n";
706 }
707 
709 {
710  if (m_hide) return;
711  m_t << "<section xml:id=\"" << s->file();
712  if (!s->anchor().isEmpty()) m_t << "_1" << s->anchor();
713  m_t << "\">" << endl;
714  m_t << "<title>";
715  filter(s->title());
716  m_t << "</title>" << endl;
717 }
718 
720 {
721  m_t << "</section>\n";
722 }
723 
725 {
726  if (m_hide) return;
727  if (s->type()==DocHtmlList::Ordered)
728  m_t << "<orderedlist>\n";
729  else
730  m_t << "<itemizedlist>\n";
731 }
732 
734 {
735  if (m_hide) return;
736  if (s->type()==DocHtmlList::Ordered)
737  m_t << "</orderedlist>\n";
738  else
739  m_t << "</itemizedlist>\n";
740 }
741 
743 {
744  if (m_hide) return;
745  m_t << "<listitem>\n";
746 }
747 
749 {
750  if (m_hide) return;
751  m_t << "</listitem>\n";
752 }
753 
755 {
756  if (m_hide) return;
757  m_t << "<variablelist>\n";
758 }
759 
761 {
762  if (m_hide) return;
763  m_t << "</variablelist>\n";
764 }
765 
767 {
768  if (m_hide) return;
769  m_t << "<varlistentry><term>";
770 }
771 
773 {
774  if (m_hide) return;
775  m_t << "</term>\n";
776 }
777 
779 {
780  if (m_hide) return;
781  m_t << "<listitem>";
782 }
783 
785 {
786  if (m_hide) return;
787  m_t << "</listitem></varlistentry>\n";
788 }
789 
791 {
792  if (m_hide) return;
793  m_t << "<table frame=\"all\">" << endl;
794  m_t << " <title></title>" << endl;
795  m_t << " <tgroup cols=\"" << t->numColumns() << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl;
796  m_t << " <tbody>" << endl;
797 }
798 
800 {
801  if (m_hide) return;
802  m_t << " </tbody>" << endl;
803  m_t << " </tgroup>" << endl;
804  m_t << "</table>" << endl;
805 }
806 
808 {
809  if (m_hide) return;
810  m_t << "<row>\n";
811 }
812 
814 {
815  if (m_hide) return;
816  m_t << "</row>\n";
817 }
818 
820 {
821  if (m_hide) return;
822  m_t << "<entry>";
823 }
824 
826 {
827  if (m_hide) return;
828  m_t << "</entry>";
829 }
830 
832 {
833  if (m_hide) return;
834  m_t << "<caption>";
835 }
836 
838 {
839  if (m_hide) return;
840  m_t << "</caption>\n";
841 }
842 
844 {
845  if (m_hide) return;
846  // TODO: to be implemented
847 }
848 
850 {
851  if (m_hide) return;
852  // TODO: to be implemented
853 }
854 
856 {
857  if (m_hide) return;
858  m_t << "<link xlink:href=\"" << href->url() << "\">";
859 }
860 
862 {
863  if (m_hide) return;
864  m_t << "</link>";
865 }
866 
868 {
869  if (m_hide) return;
870  m_t << "<formalpara><title>";
871 }
872 
874 {
875  if (m_hide) return;
876  m_t << "</title></formalpara>\n";
877 }
878 
880 {
881  if (img->type()==DocImage::DocBook)
882  {
883  if (m_hide) return;
884  m_t << endl;
885  QCString baseName=img->name();
886  int i;
887  if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
888  {
889  baseName=baseName.right(baseName.length()-i-1);
890  }
891  visitPreStart(m_t, img -> hasCaption(), baseName, img -> width(), img -> height());
892  }
893  else
894  {
895  pushEnabled();
896  m_hide=TRUE;
897  }
898 }
899 
901 {
902  if (img->type()==DocImage::DocBook)
903  {
904  if (m_hide) return;
905  visitPostEnd(m_t, img -> hasCaption());
906  // copy the image to the output dir
907  QCString baseName=img->name();
908  int i;
909  if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
910  {
911  baseName=baseName.right(baseName.length()-i-1);
912  }
913  QCString m_file;
914  bool ambig;
915  FileDef *fd=findFileDef(Doxygen::imageNameDict, baseName, ambig);
916  if (fd)
917  {
918  m_file=fd->absFilePath();
919  }
920  QFile inImage(m_file);
921  QFile outImage(Config_getString(DOCBOOK_OUTPUT)+"/"+baseName.data());
922  if (inImage.open(IO_ReadOnly))
923  {
924  if (outImage.open(IO_WriteOnly))
925  {
926  char *buffer = new char[inImage.size()];
927  inImage.readBlock(buffer,inImage.size());
928  outImage.writeBlock(buffer,inImage.size());
929  outImage.flush();
930  delete[] buffer;
931  }
932  }
933  }
934  else
935  {
936  popEnabled();
937  }
938 }
939 
941 {
942  if (m_hide) return;
943  startDotFile(df->file(),df->width(),df->height(),df->hasCaption());
944 }
945 
947 {
948  if (m_hide) return;
949  endDotFile(df->hasCaption());
950 }
951 
953 {
954  if (m_hide) return;
955  startMscFile(df->file(),df->width(),df->height(),df->hasCaption());
956 }
957 
959 {
960  if (m_hide) return;
961  endMscFile(df->hasCaption());
962 }
964 {
965  if (m_hide) return;
966  startDiaFile(df->file(),df->width(),df->height(),df->hasCaption());
967 }
968 
970 {
971  if (m_hide) return;
972  endDiaFile(df->hasCaption());
973 }
974 
976 {
977  if (m_hide) return;
978  startLink(lnk->file(),lnk->anchor());
979 }
980 
982 {
983  if (m_hide) return;
984  endLink();
985 }
986 
988 {
989  if (m_hide) return;
990  if (!ref->file().isEmpty()) startLink(ref->file(),ref->anchor());
991  if (!ref->hasLinkText()) filter(ref->targetTitle());
992 }
993 
995 {
996  if (m_hide) return;
997  if (!ref->file().isEmpty()) endLink();
998 }
999 
1001 {
1002  if (m_hide) return;
1003  m_t << "<tocitem id=\"" << ref->file() << "_1" << ref->anchor() << "\">";
1004 }
1005 
1007 {
1008  if (m_hide) return;
1009  m_t << "</tocitem>" << endl;
1010 }
1011 
1013 {
1014  if (m_hide) return;
1015  m_t << "<toclist>" << endl;
1016 }
1017 
1019 {
1020  if (m_hide) return;
1021  m_t << "</toclist>" << endl;
1022 }
1023 
1025 {
1026  if (m_hide) return;
1027  m_t << endl;
1028  m_t << " <formalpara>" << endl;
1029  m_t << " <title/>" << endl;
1030  m_t << " <table frame=\"all\">" << endl;
1031  m_t << " <title>";
1032  switch(s->type())
1033  {
1038  default:
1039  ASSERT(0);
1040  }
1041  m_t << " </title>" << endl;
1042  m_t << " <tgroup cols=\"2\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl;
1043  m_t << " <colspec colwidth=\"1*\"/>" << endl;
1044  m_t << " <colspec colwidth=\"4*\"/>" << endl;
1045  m_t << " <tbody>" << endl;
1046 }
1047 
1049 {
1050  if (m_hide) return;
1051  m_t << " </tbody>" << endl;
1052  m_t << " </tgroup>" << endl;
1053  m_t << " </table>" << endl;
1054  m_t << " </formalpara>" << endl;
1055  m_t << " ";
1056 }
1057 
1059 {
1060  if (m_hide) return;
1061  QListIterator<DocNode> li(pl->parameters());
1062  DocNode *param;
1063  m_t << " <row>" << endl;
1064  if (!li.toFirst())
1065  {
1066  m_t << " <entry></entry>" << endl;
1067  }
1068  else
1069  {
1070  m_t << " <entry>";
1071  int cnt = 0;
1072  for (li.toFirst();(param=li.current());++li)
1073  {
1074  if (cnt)
1075  {
1076  m_t << ", ";
1077  }
1078  if (param->kind()==DocNode::Kind_Word)
1079  {
1080  visit((DocWord*)param);
1081  }
1082  else if (param->kind()==DocNode::Kind_LinkedWord)
1083  {
1084  visit((DocLinkedWord*)param);
1085  }
1086  cnt++;
1087  }
1088  m_t << "</entry>" << endl;
1089  }
1090  m_t << " <entry>";
1091 }
1092 
1094 {
1095  if (m_hide) return;
1096  m_t << "</entry>" << endl;
1097  m_t << " </row>" << endl;
1098 }
1099 
1101 {
1102  if (m_hide) return;
1103  if (x->title().isEmpty()) return;
1104  m_t << "<para><link linkend=\"";
1105  m_t << x->file() << "_1" << x->anchor();
1106  m_t << "\">";
1107  filter(x->title());
1108  m_t << "</link>";
1109  m_t << " ";
1110 }
1111 
1113 {
1114  if (m_hide) return;
1115  if (x->title().isEmpty()) return;
1116  m_t << "</para>";
1117 }
1118 
1120 {
1121  if (m_hide) return;
1122  startLink(ref->file(),ref->anchor());
1123 }
1124 
1126 {
1127  if (m_hide) return;
1128  endLink();
1129  m_t << " ";
1130 }
1131 
1133 {
1134  if (m_hide) return;
1135  // TODO: to be implemented
1136 }
1137 
1138 
1140 {
1141  if (m_hide) return;
1142  // TODO: to be implemented
1143 }
1144 
1145 
1147 {
1148  // TODO: to be implemented
1149 }
1150 
1151 
1153 {
1154  // TODO: to be implemented
1155 }
1156 
1157 
1159 {
1160  if (m_hide) return;
1161  m_t << "<blockquote>";
1162 }
1163 
1165 {
1166  if (m_hide) return;
1167  m_t << "</blockquote>";
1168 }
1169 
1171 {
1172  // TODO: to be implemented
1173 }
1174 
1175 
1177 {
1178  // TODO: to be implemented
1179 }
1180 
1182 {
1183 }
1184 
1186 {
1187 }
1188 
1189 
1190 void DocbookDocVisitor::filter(const char *str)
1191 {
1192  m_t << convertToXML(str);
1193 }
1194 
1195 void DocbookDocVisitor::startLink(const QCString &file,const QCString &anchor)
1196 {
1197  m_t << "<link linkend=\"" << file;
1198  if (!anchor.isEmpty()) m_t << "_1" << anchor;
1199  m_t << "\">";
1200 }
1201 
1203 {
1204  m_t << "</link>";
1205 }
1206 
1208 {
1209  m_enabled.push(new bool(m_hide));
1210 }
1211 
1213 {
1214  bool *v=m_enabled.pop();
1215  ASSERT(v!=0);
1216  m_hide = *v;
1217  delete v;
1218 }
1219 
1220 void DocbookDocVisitor::writeMscFile(const QCString &baseName, DocVerbatim *s)
1221 {
1222  QCString shortName = baseName;
1223  int i;
1224  if ((i=shortName.findRev('/'))!=-1)
1225  {
1226  shortName=shortName.right(shortName.length()-i-1);
1227  }
1228  QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1229  writeMscGraphFromFile(baseName+".msc",outDir,shortName,MSC_BITMAP);
1230  visitPreStart(m_t, s->hasCaption(), shortName, s->width(),s->height());
1231  visitCaption(this, s->children());
1232  visitPostEnd(m_t, s->hasCaption());
1233 }
1234 
1235 void DocbookDocVisitor::writePlantUMLFile(const QCString &baseName, DocVerbatim *s)
1236 {
1237  QCString shortName = baseName;
1238  int i;
1239  if ((i=shortName.findRev('/'))!=-1)
1240  {
1241  shortName=shortName.right(shortName.length()-i-1);
1242  }
1243  QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1244  generatePlantUMLOutput(baseName,outDir,PUML_BITMAP);
1245  visitPreStart(m_t, s->hasCaption(), shortName, s->width(),s->height());
1246  visitCaption(this, s->children());
1247  visitPostEnd(m_t, s->hasCaption());
1248 }
1249 
1250 void DocbookDocVisitor::startMscFile(const QCString &fileName,
1251  const QCString &width,
1252  const QCString &height,
1253  bool hasCaption
1254  )
1255 {
1256  QCString baseName=fileName;
1257  int i;
1258  if ((i=baseName.findRev('/'))!=-1)
1259  {
1260  baseName=baseName.right(baseName.length()-i-1);
1261  }
1262  if ((i=baseName.find('.'))!=-1)
1263  {
1264  baseName=baseName.left(i);
1265  }
1266  baseName.prepend("msc_");
1267  QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1268  writeMscGraphFromFile(fileName,outDir,baseName,MSC_BITMAP);
1269  m_t << "<para>" << endl;
1270  visitPreStart(m_t, hasCaption, baseName + ".png", width, height);
1271 }
1272 
1273 void DocbookDocVisitor::endMscFile(bool hasCaption)
1274 {
1275  if (m_hide) return;
1276  visitPostEnd(m_t, hasCaption);
1277  m_t << "</para>" << endl;
1278 }
1279 
1280 void DocbookDocVisitor::writeDiaFile(const QCString &baseName, DocVerbatim *s)
1281 {
1282  QCString shortName = baseName;
1283  int i;
1284  if ((i=shortName.findRev('/'))!=-1)
1285  {
1286  shortName=shortName.right(shortName.length()-i-1);
1287  }
1288  QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1289  writeDiaGraphFromFile(baseName+".dia",outDir,shortName,DIA_BITMAP);
1290  visitPreStart(m_t, s->hasCaption(), shortName, s->width(),s->height());
1291  visitCaption(this, s->children());
1292  visitPostEnd(m_t, s->hasCaption());
1293 }
1294 
1295 void DocbookDocVisitor::startDiaFile(const QCString &fileName,
1296  const QCString &width,
1297  const QCString &height,
1298  bool hasCaption
1299  )
1300 {
1301  QCString baseName=fileName;
1302  int i;
1303  if ((i=baseName.findRev('/'))!=-1)
1304  {
1305  baseName=baseName.right(baseName.length()-i-1);
1306  }
1307  if ((i=baseName.find('.'))!=-1)
1308  {
1309  baseName=baseName.left(i);
1310  }
1311  baseName.prepend("dia_");
1312  QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1313  writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP);
1314  m_t << "<para>" << endl;
1315  visitPreStart(m_t, hasCaption, baseName + ".png", width, height);
1316 }
1317 
1318 void DocbookDocVisitor::endDiaFile(bool hasCaption)
1319 {
1320  if (m_hide) return;
1321  visitPostEnd(m_t, hasCaption);
1322  m_t << "</para>" << endl;
1323 }
1324 
1325 void DocbookDocVisitor::writeDotFile(const QCString &baseName, DocVerbatim *s)
1326 {
1327  QCString shortName = baseName;
1328  int i;
1329  if ((i=shortName.findRev('/'))!=-1)
1330  {
1331  shortName=shortName.right(shortName.length()-i-1);
1332  }
1333  QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1334  writeDotGraphFromFile(baseName+".dot",outDir,shortName,GOF_BITMAP);
1335  visitPreStart(m_t, s->hasCaption(), baseName + ".dot", s->width(),s->height());
1336  visitCaption(this, s->children());
1337  visitPostEnd(m_t, s->hasCaption());
1338 }
1339 
1340 void DocbookDocVisitor::startDotFile(const QCString &fileName,
1341  const QCString &width,
1342  const QCString &height,
1343  bool hasCaption
1344  )
1345 {
1346  QCString baseName=fileName;
1347  int i;
1348  if ((i=baseName.findRev('/'))!=-1)
1349  {
1350  baseName=baseName.right(baseName.length()-i-1);
1351  }
1352  if ((i=baseName.find('.'))!=-1)
1353  {
1354  baseName=baseName.left(i);
1355  }
1356  baseName.prepend("dot_");
1357  QCString outDir = Config_getString(DOCBOOK_OUTPUT);
1358  QCString imgExt = getDotImageExtension();
1359  writeDotGraphFromFile(fileName,outDir,baseName,GOF_BITMAP);
1360  m_t << "<para>" << endl;
1361  visitPreStart(m_t, hasCaption, baseName + "." + imgExt, width, height);
1362 }
1363 
1364 void DocbookDocVisitor::endDotFile(bool hasCaption)
1365 {
1366  if (m_hide) return;
1367  m_t << endl;
1368  visitPostEnd(m_t, hasCaption);
1369  m_t << "</para>" << endl;
1370 }
1371