540332423e7285fc92663703766e13ea75acb7e9
[platform/upstream/doxygen.git] / src / mandocvisitor.cpp
1 /******************************************************************************
2  *
3  * 
4  *
5  *
6  * Copyright (C) 1997-2014 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 "mandocvisitor.h"
22 #include "docparser.h"
23 #include "language.h"
24 #include "doxygen.h"
25 #include "outputgen.h"
26 #include "code.h"
27 #include "dot.h"
28 #include "util.h"
29 #include "message.h"
30 #include "parserintf.h"
31 #include "filedef.h"
32 #include "htmlentity.h"
33
34 ManDocVisitor::ManDocVisitor(FTextStream &t,CodeOutputInterface &ci,
35                              const char *langExt) 
36   : DocVisitor(DocVisitor_Man), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE), m_firstCol(FALSE),
37     m_indent(0), m_langExt(langExt)
38 {
39 }
40
41   //--------------------------------------
42   // visitor functions for leaf nodes
43   //--------------------------------------
44
45 void ManDocVisitor::visit(DocWord *w)
46 {
47   if (m_hide) return;
48   filter(w->word());
49   m_firstCol=FALSE;
50 }
51
52 void ManDocVisitor::visit(DocLinkedWord *w)
53 {
54   if (m_hide) return;
55   m_t << "\\fB";
56   filter(w->word());
57   m_t << "\\fP";
58   m_firstCol=FALSE;
59 }
60
61 void ManDocVisitor::visit(DocWhiteSpace *w)
62 {
63   if (m_hide) return;
64   if (m_insidePre)
65   {
66     m_t << w->chars();
67     m_firstCol=w->chars().at(w->chars().length()-1)=='\n';
68   }
69   else
70   {
71     m_t << " ";
72     m_firstCol=FALSE;
73   }
74 }
75
76 void ManDocVisitor::visit(DocSymbol *s)
77 {
78   if (m_hide) return;
79   const char *res = HtmlEntityMapper::instance()->man(s->symbol());
80   if (res)
81   {
82     m_t << res;
83   }
84   else
85   {
86     // no error or warning to be supplied
87     // err("man: non supported HTML-entity found: &%s;\n",get_symbol_item(s->symbol()));
88   }
89   m_firstCol=FALSE;
90 }
91
92 void ManDocVisitor::visit(DocURL *u)
93 {
94   if (m_hide) return;
95   m_t << u->url();
96   m_firstCol=FALSE;
97 }
98
99 void ManDocVisitor::visit(DocLineBreak *)
100 {
101   if (m_hide) return;
102   m_t << endl << ".br" << endl;
103   m_firstCol=TRUE;
104 }
105
106 void ManDocVisitor::visit(DocHorRuler *)
107 {
108   if (m_hide) return;
109   if (!m_firstCol) m_t << endl;
110   m_t << ".PP" << endl;
111   m_firstCol=TRUE;
112 }
113
114 void ManDocVisitor::visit(DocStyleChange *s)
115 {
116   if (m_hide) return;
117   switch (s->style())
118   {
119     case DocStyleChange::Bold:
120       if (s->enable()) m_t << "\\fB";      else m_t << "\\fP";
121       m_firstCol=FALSE;
122       break;
123     case DocStyleChange::Italic:
124       if (s->enable()) m_t << "\\fI";     else m_t << "\\fP";
125       m_firstCol=FALSE;
126       break;
127     case DocStyleChange::Code:
128       if (s->enable()) m_t << "\\fC";   else m_t << "\\fP";
129       m_firstCol=FALSE;
130       break;
131     case DocStyleChange::Subscript:
132       if (s->enable()) m_t << "\\*<";    else m_t << "\\*> ";
133       m_firstCol=FALSE;
134       break;
135     case DocStyleChange::Superscript:
136       if (s->enable()) m_t << "\\*{";    else m_t << "\\*} ";
137       m_firstCol=FALSE;
138       break;
139     case DocStyleChange::Center:
140       /* not supported */
141       break;
142     case DocStyleChange::Small:
143       /* not supported */
144       break;
145     case DocStyleChange::Preformatted:
146       if (s->enable())
147       {
148         if (!m_firstCol) m_t << endl;
149         m_t << ".PP" << endl;
150         m_t << ".nf" << endl;
151         m_insidePre=TRUE;
152       }
153       else
154       {
155         m_insidePre=FALSE;
156         if (!m_firstCol) m_t << endl;
157         m_t << ".fi" << endl;
158         m_t << ".PP" << endl;
159         m_firstCol=TRUE;
160       }
161       break;
162     case DocStyleChange::Div:  /* HTML only */ break;
163     case DocStyleChange::Span: /* HTML only */ break;
164   }
165 }
166
167 void ManDocVisitor::visit(DocVerbatim *s)
168 {
169   if (m_hide) return;
170   QCString lang = m_langExt;
171   if (!s->language().isEmpty()) // explicit language setting
172   {
173     lang = s->language();
174   }
175   SrcLangExt langExt = getLanguageFromFileName(lang);
176   switch (s->type())
177   {
178     case DocVerbatim::Code: // fall though
179       if (!m_firstCol) m_t << endl;
180       m_t << ".PP" << endl;
181       m_t << ".nf" << endl;
182       Doxygen::parserManager->getParser(lang)
183                             ->parseCode(m_ci,s->context(),s->text(),
184                                         langExt,
185                                         s->isExample(),s->exampleFile());
186       if (!m_firstCol) m_t << endl;
187       m_t << ".fi" << endl;
188       m_t << ".PP" << endl;
189       m_firstCol=TRUE;
190       break;
191     case DocVerbatim::Verbatim: 
192       if (!m_firstCol) m_t << endl;
193       m_t << ".PP" << endl;
194       m_t << ".nf" << endl;
195       m_t << s->text();
196       if (!m_firstCol) m_t << endl;
197       m_t << ".fi" << endl;
198       m_t << ".PP" << endl;
199       m_firstCol=TRUE;
200       break;
201     case DocVerbatim::ManOnly: 
202       m_t << s->text(); 
203       break;
204     case DocVerbatim::HtmlOnly: 
205     case DocVerbatim::XmlOnly: 
206     case DocVerbatim::LatexOnly: 
207     case DocVerbatim::RtfOnly:
208     case DocVerbatim::DocbookOnly:
209     case DocVerbatim::Dot: 
210     case DocVerbatim::Msc: 
211       /* nothing */ 
212       break;
213   }
214 }
215
216 void ManDocVisitor::visit(DocAnchor *)
217 {
218   /* no support for anchors in man pages */
219 }
220
221 void ManDocVisitor::visit(DocInclude *inc)
222 {
223   if (m_hide) return;
224   SrcLangExt langExt = getLanguageFromFileName(inc->extension());
225   switch(inc->type())
226   {
227     case DocInclude::IncWithLines:
228       { 
229          if (!m_firstCol) m_t << endl;
230          m_t << ".PP" << endl;
231          m_t << ".nf" << endl;
232          QFileInfo cfi( inc->file() );
233          FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() );
234          Doxygen::parserManager->getParser(inc->extension())
235                                ->parseCode(m_ci,inc->context(),
236                                            inc->text(),
237                                            langExt,
238                                            inc->isExample(),
239                                            inc->exampleFile(), &fd);
240          if (!m_firstCol) m_t << endl;
241          m_t << ".fi" << endl;
242          m_t << ".PP" << endl;
243          m_firstCol=TRUE;
244       }
245       break;
246     case DocInclude::Include: 
247       if (!m_firstCol) m_t << endl;
248       m_t << ".PP" << endl;
249       m_t << ".nf" << endl;
250       Doxygen::parserManager->getParser(inc->extension())
251                             ->parseCode(m_ci,inc->context(),
252                                         inc->text(),
253                                         langExt,
254                                         inc->isExample(),
255                                         inc->exampleFile());
256       if (!m_firstCol) m_t << endl;
257       m_t << ".fi" << endl;
258       m_t << ".PP" << endl;
259       m_firstCol=TRUE;
260       break;
261     case DocInclude::DontInclude: 
262       break;
263     case DocInclude::HtmlInclude: 
264       break;
265     case DocInclude::LatexInclude:
266       break;
267     case DocInclude::VerbInclude: 
268       if (!m_firstCol) m_t << endl;
269       m_t << ".PP" << endl;
270       m_t << ".nf" << endl;
271       m_t << inc->text();
272       if (!m_firstCol) m_t << endl;
273       m_t << ".fi" << endl;
274       m_t << ".PP" << endl;
275       m_firstCol=TRUE;
276       break;
277     case DocInclude::Snippet:
278       if (!m_firstCol) m_t << endl;
279       m_t << ".PP" << endl;
280       m_t << ".nf" << endl;
281       Doxygen::parserManager->getParser(inc->extension())
282                             ->parseCode(m_ci,
283                                         inc->context(),
284                                         extractBlock(inc->text(),inc->blockId()),
285                                         langExt,
286                                         inc->isExample(),
287                                         inc->exampleFile()
288                                        );
289       if (!m_firstCol) m_t << endl;
290       m_t << ".fi" << endl;
291       m_t << ".PP" << endl;
292       m_firstCol=TRUE;
293       break;
294   }
295 }
296
297 void ManDocVisitor::visit(DocIncOperator *op)
298 {
299   SrcLangExt langExt = getLanguageFromFileName(m_langExt);
300   //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n",
301   //    op->type(),op->isFirst(),op->isLast(),op->text().data());
302   if (op->isFirst()) 
303   {
304     if (!m_hide)
305     {
306       if (!m_firstCol) m_t << endl;
307       m_t << ".PP" << endl;
308       m_t << ".nf" << endl;
309     }
310     pushEnabled();
311     m_hide = TRUE;
312   }
313   if (op->type()!=DocIncOperator::Skip) 
314   {
315     popEnabled();
316     if (!m_hide) 
317     {
318       Doxygen::parserManager->getParser(m_langExt)
319                             ->parseCode(m_ci,op->context(),op->text(),langExt,
320                                         op->isExample(),op->exampleFile());
321     }
322     pushEnabled();
323     m_hide=TRUE;
324   }
325   if (op->isLast())  
326   {
327     popEnabled();
328     if (!m_hide)
329     {
330       if (!m_firstCol) m_t << endl;
331       m_t << ".fi" << endl;
332       m_t << ".PP" << endl;
333       m_firstCol=TRUE;
334     }
335   }
336   else
337   {
338     if (!m_hide) m_t << endl;
339   }
340 }
341
342 void ManDocVisitor::visit(DocFormula *f)
343 {
344   if (m_hide) return;
345   m_t << f->text();
346 }
347
348 void ManDocVisitor::visit(DocIndexEntry *)
349 {
350 }
351
352 void ManDocVisitor::visit(DocSimpleSectSep *)
353 {
354 }
355
356 void ManDocVisitor::visit(DocCite *cite)
357 {
358   if (m_hide) return;
359   m_t << "\\fB";
360   if (cite->file().isEmpty()) m_t << "[";
361   filter(cite->text());
362   if (cite->file().isEmpty()) m_t << "]";
363   m_t << "\\fP";
364 }
365
366
367 //--------------------------------------
368 // visitor functions for compound nodes
369 //--------------------------------------
370
371 void ManDocVisitor::visitPre(DocAutoList *)
372 {
373   if (m_hide) return;
374   m_indent+=2;
375 }
376
377 void ManDocVisitor::visitPost(DocAutoList *)
378 {
379   if (m_hide) return;
380   m_indent-=2;
381   m_t << ".PP" << endl;
382 }
383
384 void ManDocVisitor::visitPre(DocAutoListItem *li)
385 {
386   if (m_hide) return;
387   QCString ws;
388   ws.fill(' ',m_indent-2);
389   if (!m_firstCol) m_t << endl;
390   m_t << ".IP \"" << ws; 
391   if (((DocAutoList *)li->parent())->isEnumList())
392   {
393     m_t << li->itemNumber() << ".\" " << m_indent+2;
394   }
395   else // bullet list
396   {
397     m_t << "\\(bu\" " << m_indent;
398   }
399   m_t << endl;
400   m_firstCol=TRUE;
401 }
402
403 void ManDocVisitor::visitPost(DocAutoListItem *) 
404 {
405   if (m_hide) return;
406   m_t << endl;
407   m_firstCol=TRUE;
408 }
409
410 void ManDocVisitor::visitPre(DocPara *) 
411 {
412 }
413
414 void ManDocVisitor::visitPost(DocPara *p)
415 {
416   if (m_hide) return;
417   if (!p->isLast() &&            // omit <p> for last paragraph
418       !(p->parent() &&           // and for parameter sections
419         p->parent()->kind()==DocNode::Kind_ParamSect
420        )
421      ) 
422   {
423     if (!m_firstCol) m_t << endl;
424     m_t << ".PP" << endl;
425     m_firstCol=TRUE;
426   }
427 }
428
429 void ManDocVisitor::visitPre(DocRoot *)
430 {
431 }
432
433 void ManDocVisitor::visitPost(DocRoot *)
434 {
435 }
436
437 void ManDocVisitor::visitPre(DocSimpleSect *s)
438 {
439   if (m_hide) return;
440   if (!m_firstCol)
441   { 
442     m_t << endl;
443     m_t << ".PP" << endl;
444   }
445   m_t << "\\fB";
446   switch(s->type())
447   {
448     case DocSimpleSect::See: 
449       m_t << theTranslator->trSeeAlso(); break;
450     case DocSimpleSect::Return: 
451       m_t << theTranslator->trReturns(); break;
452     case DocSimpleSect::Author: 
453       m_t << theTranslator->trAuthor(TRUE,TRUE); break;
454     case DocSimpleSect::Authors: 
455       m_t << theTranslator->trAuthor(TRUE,FALSE); break;
456     case DocSimpleSect::Version: 
457       m_t << theTranslator->trVersion(); break;
458     case DocSimpleSect::Since: 
459       m_t << theTranslator->trSince(); break;
460     case DocSimpleSect::Date: 
461       m_t << theTranslator->trDate(); break;
462     case DocSimpleSect::Note: 
463       m_t << theTranslator->trNote(); break;
464     case DocSimpleSect::Warning:
465       m_t << theTranslator->trWarning(); break;
466     case DocSimpleSect::Pre:
467       m_t << theTranslator->trPrecondition(); break;
468     case DocSimpleSect::Post:
469       m_t << theTranslator->trPostcondition(); break;
470     case DocSimpleSect::Copyright:
471       m_t << theTranslator->trCopyright(); break;
472     case DocSimpleSect::Invar:
473       m_t << theTranslator->trInvariant(); break;
474     case DocSimpleSect::Remark:
475       m_t << theTranslator->trRemarks(); break;
476     case DocSimpleSect::Attention:
477       m_t << theTranslator->trAttention(); break;
478     case DocSimpleSect::User: break;
479     case DocSimpleSect::Rcs: break;
480     case DocSimpleSect::Unknown:  break;
481   }
482
483   // special case 1: user defined title
484   if (s->type()!=DocSimpleSect::User && s->type()!=DocSimpleSect::Rcs)
485   {
486     m_t << ":\\fP" << endl;
487     m_t << ".RS 4" << endl;
488   }
489 }
490
491 void ManDocVisitor::visitPost(DocSimpleSect *)
492 {
493   if (m_hide) return;
494   if (!m_firstCol) m_t << endl;
495   m_t << ".RE" << endl;
496   m_t << ".PP" << endl;
497   m_firstCol=TRUE;
498 }
499
500 void ManDocVisitor::visitPre(DocTitle *)
501 {
502 }
503
504 void ManDocVisitor::visitPost(DocTitle *)
505 {
506   if (m_hide) return;
507   m_t << "\\fP" << endl;
508   m_t << ".RS 4" << endl;
509 }
510
511 void ManDocVisitor::visitPre(DocSimpleList *)
512 {
513   if (m_hide) return;
514   m_indent+=2;
515   if (!m_firstCol) m_t << endl;
516   m_t << ".PD 0" << endl;
517 }
518
519 void ManDocVisitor::visitPost(DocSimpleList *)
520 {
521   if (m_hide) return;
522   m_indent-=2;
523   m_t << ".PP" << endl;
524 }
525
526 void ManDocVisitor::visitPre(DocSimpleListItem *)
527 {
528   if (m_hide) return;
529   QCString ws;
530   ws.fill(' ',m_indent-2);
531   if (!m_firstCol) m_t << endl;
532   m_t << ".IP \"" << ws << "\\(bu\" " << m_indent << endl;
533   m_firstCol=TRUE;
534 }
535
536 void ManDocVisitor::visitPost(DocSimpleListItem *) 
537 {
538   if (m_hide) return;
539   m_t << endl;
540   m_firstCol=TRUE;
541 }
542
543 void ManDocVisitor::visitPre(DocSection *s)
544 {
545   if (m_hide) return;
546   if (!m_firstCol) m_t << endl;
547   if (s->level()==1) m_t << ".SH"; else m_t << ".SS";
548   m_t << " \"";
549   filter(s->title());
550   m_t << "\"" << endl;
551   if (s->level()==1) m_t << ".PP" << endl;
552   m_firstCol=TRUE;
553 }
554
555 void ManDocVisitor::visitPost(DocSection *) 
556 {
557 }
558
559 void ManDocVisitor::visitPre(DocHtmlList *)
560 {
561   if (m_hide) return;
562   m_indent+=2;
563   if (!m_firstCol) m_t << endl;
564   m_t << ".PD 0" << endl;
565 }
566
567 void ManDocVisitor::visitPost(DocHtmlList *) 
568 {
569   if (m_hide) return;
570   m_indent-=2;
571   if (!m_firstCol) m_t << endl;
572   m_t << ".PP" << endl;
573 }
574
575 void ManDocVisitor::visitPre(DocHtmlListItem *li)
576 {
577   if (m_hide) return;
578   QCString ws;
579   ws.fill(' ',m_indent-2);
580   if (!m_firstCol) m_t << endl;
581   m_t << ".IP \"" << ws; 
582   if (((DocHtmlList *)li->parent())->type()==DocHtmlList::Ordered)
583   {
584     m_t << li->itemNumber() << ".\" " << m_indent+2;
585   }
586   else // bullet list
587   {
588     m_t << "\\(bu\" " << m_indent;
589   }
590   m_t << endl;
591   m_firstCol=TRUE;
592 }
593
594 void ManDocVisitor::visitPost(DocHtmlListItem *) 
595 {
596   if (m_hide) return;
597   m_t << endl;
598   m_firstCol=TRUE;
599 }
600
601 //void ManDocVisitor::visitPre(DocHtmlPre *)
602 //{
603 //  if (!m_firstCol) m_t << endl;
604 //  m_t << ".PP" << endl;
605 //  m_t << ".nf" << endl;
606 //  m_insidePre=TRUE;
607 //}
608 //
609 //void ManDocVisitor::visitPost(DocHtmlPre *) 
610 //{
611 //  m_insidePre=FALSE;
612 //  if (!m_firstCol) m_t << endl;
613 //  m_t << ".fi" << endl;
614 //  m_t << ".PP" << endl;
615 //  m_firstCol=TRUE;
616 //}
617
618 void ManDocVisitor::visitPre(DocHtmlDescList *)
619 {
620 }
621
622 void ManDocVisitor::visitPost(DocHtmlDescList *) 
623 {
624   if (m_hide) return;
625   if (!m_firstCol) m_t << endl;
626   m_t << ".PP" << endl;
627   m_firstCol=TRUE;
628 }
629
630 void ManDocVisitor::visitPre(DocHtmlDescTitle *)
631 {
632   if (m_hide) return;
633   if (!m_firstCol) m_t << endl;
634   m_t << ".IP \"\\fB";
635   m_firstCol=FALSE;
636 }
637
638 void ManDocVisitor::visitPost(DocHtmlDescTitle *) 
639 {
640   if (m_hide) return;
641   m_t << "\\fP\" 1c" << endl;
642   m_firstCol=TRUE;
643 }
644
645 void ManDocVisitor::visitPre(DocHtmlDescData *)
646 {
647 }
648
649 void ManDocVisitor::visitPost(DocHtmlDescData *) 
650 {
651 }
652
653 void ManDocVisitor::visitPre(DocHtmlTable *)
654 {
655 }
656
657 void ManDocVisitor::visitPost(DocHtmlTable *) 
658 {
659 }
660
661 void ManDocVisitor::visitPre(DocHtmlCaption *)
662 {
663 }
664
665 void ManDocVisitor::visitPost(DocHtmlCaption *) 
666 {
667 }
668
669 void ManDocVisitor::visitPre(DocHtmlRow *)
670 {
671 }
672
673 void ManDocVisitor::visitPost(DocHtmlRow *) 
674 {
675 }
676
677 void ManDocVisitor::visitPre(DocHtmlCell *)
678 {
679 }
680
681 void ManDocVisitor::visitPost(DocHtmlCell *) 
682 {
683 }
684
685 void ManDocVisitor::visitPre(DocInternal *)
686 {
687   if (m_hide) return;
688   //if (!m_firstCol) m_t << endl;
689   //m_t << ".PP" << endl;
690   //m_t << "\\fB" << theTranslator->trForInternalUseOnly() << "\\fP" << endl;
691   //m_t << ".RS 4" << endl;
692 }
693
694 void ManDocVisitor::visitPost(DocInternal *) 
695 {
696   if (m_hide) return;
697   //if (!m_firstCol) m_t << endl;
698   //m_t << ".RE" << endl;
699   //m_t << ".PP" << endl;
700   //m_firstCol=TRUE;
701 }
702
703 void ManDocVisitor::visitPre(DocHRef *)
704 {
705   if (m_hide) return;
706   m_t << "\\fC";
707 }
708
709 void ManDocVisitor::visitPost(DocHRef *) 
710 {
711   if (m_hide) return;
712   m_t << "\\fP";
713 }
714
715 void ManDocVisitor::visitPre(DocHtmlHeader *header)
716 {
717   if (m_hide) return;
718   if (!m_firstCol) m_t << endl;
719   if (header->level()==1) m_t << ".SH"; else m_t << ".SS";
720   m_t << " \"";
721 }
722
723 void ManDocVisitor::visitPost(DocHtmlHeader *header) 
724 {
725   if (m_hide) return;
726   m_t << "\"" << endl;
727   if (header->level()==1) m_t << ".PP" << endl;
728   m_firstCol=TRUE;
729 }
730
731 void ManDocVisitor::visitPre(DocImage *)
732 {
733 }
734
735 void ManDocVisitor::visitPost(DocImage *) 
736 {
737 }
738
739 void ManDocVisitor::visitPre(DocDotFile *)
740 {
741 }
742
743 void ManDocVisitor::visitPost(DocDotFile *) 
744 {
745 }
746 void ManDocVisitor::visitPre(DocMscFile *)
747 {
748 }
749
750 void ManDocVisitor::visitPost(DocMscFile *) 
751 {
752 }
753
754 void ManDocVisitor::visitPre(DocDiaFile *)
755 {
756 }
757
758 void ManDocVisitor::visitPost(DocDiaFile *)
759 {
760 }
761
762 void ManDocVisitor::visitPre(DocLink *)
763 {
764   if (m_hide) return;
765   m_t << "\\fB";
766 }
767
768 void ManDocVisitor::visitPost(DocLink *) 
769 {
770   if (m_hide) return;
771   m_t << "\\fP";
772 }
773
774 void ManDocVisitor::visitPre(DocRef *ref)
775 {
776   if (m_hide) return;
777   m_t << "\\fB";
778   if (!ref->hasLinkText()) filter(ref->targetTitle());
779 }
780
781 void ManDocVisitor::visitPost(DocRef *) 
782 {
783   if (m_hide) return;
784   m_t << "\\fP";
785 }
786
787 void ManDocVisitor::visitPre(DocSecRefItem *)
788 {
789   if (m_hide) return;
790   QCString ws;
791   ws.fill(' ',m_indent-2);
792   if (!m_firstCol) m_t << endl;
793   m_t << ".IP \"" << ws << "\\(bu\" " << m_indent << endl;
794   m_firstCol=TRUE;
795 }
796
797 void ManDocVisitor::visitPost(DocSecRefItem *) 
798 {
799   if (m_hide) return;
800   m_t << endl;
801   m_firstCol=TRUE;
802 }
803
804 void ManDocVisitor::visitPre(DocSecRefList *)
805 {
806   if (m_hide) return;
807   m_indent+=2;
808 }
809
810 void ManDocVisitor::visitPost(DocSecRefList *) 
811 {
812   if (m_hide) return;
813   m_indent-=2;
814   if (!m_firstCol) m_t << endl;
815   m_t << ".PP" << endl;
816 }
817
818 //void ManDocVisitor::visitPre(DocLanguage *l)
819 //{
820 //  QString langId = Config_getEnum("OUTPUT_LANGUAGE");
821 //  if (l->id().lower()!=langId.lower())
822 //  {
823 //    pushEnabled();
824 //    m_hide = TRUE;
825 //  }
826 //}
827 //
828 //void ManDocVisitor::visitPost(DocLanguage *l) 
829 //{
830 //  QString langId = Config_getEnum("OUTPUT_LANGUAGE");
831 //  if (l->id().lower()!=langId.lower())
832 //  {
833 //    popEnabled();
834 //  }
835 //}
836
837 void ManDocVisitor::visitPre(DocParamSect *s)
838 {
839   if (m_hide) return;
840   if (!m_firstCol)
841   { 
842     m_t << endl;
843     m_t << ".PP" << endl;
844   }
845   m_t << "\\fB";
846   switch(s->type())
847   {
848     case DocParamSect::Param: 
849       m_t << theTranslator->trParameters(); break;
850     case DocParamSect::RetVal: 
851       m_t << theTranslator->trReturnValues(); break;
852     case DocParamSect::Exception: 
853       m_t << theTranslator->trExceptions(); break;
854     case DocParamSect::TemplateParam: 
855       /* TODO: add this 
856       m_t << theTranslator->trTemplateParam(); break;
857       */
858       m_t << "Template Parameters"; break;
859     default:
860       ASSERT(0);
861   }
862   m_t << ":\\fP" << endl;
863   m_t << ".RS 4" << endl;
864 }
865
866 void ManDocVisitor::visitPost(DocParamSect *)
867 {
868   if (m_hide) return;
869   if (!m_firstCol) m_t << endl;
870   m_t << ".RE" << endl;
871   m_t << ".PP" << endl;
872   m_firstCol=TRUE;
873 }
874
875 void ManDocVisitor::visitPre(DocParamList *pl)
876 {
877   if (m_hide) return;
878   m_t << "\\fI";
879   //QStrListIterator li(pl->parameters());
880   //const char *s;
881   QListIterator<DocNode> li(pl->parameters());
882   DocNode *param;
883   bool first=TRUE;
884   for (li.toFirst();(param=li.current());++li)
885   {
886     if (!first) m_t << ","; else first=FALSE;
887     if (param->kind()==DocNode::Kind_Word)
888     {
889       visit((DocWord*)param); 
890     }
891     else if (param->kind()==DocNode::Kind_LinkedWord)
892     {
893       visit((DocLinkedWord*)param); 
894     }
895   }
896   m_t << "\\fP ";
897 }
898
899 void ManDocVisitor::visitPost(DocParamList *pl)
900 {
901   if (m_hide) return;
902   if (!pl->isLast())
903   {
904     if (!m_firstCol) m_t << endl;
905     m_t << ".br" << endl;
906   }
907 }
908
909 void ManDocVisitor::visitPre(DocXRefItem *x)
910 {
911   if (m_hide) return;
912   if (x->title().isEmpty()) return;
913   if (!m_firstCol)
914   { 
915     m_t << endl;
916     m_t << ".PP" << endl;
917   }
918   m_t << "\\fB";
919   filter(x->title());
920   m_t << "\\fP" << endl;
921   m_t << ".RS 4" << endl;
922 }
923
924 void ManDocVisitor::visitPost(DocXRefItem *x)
925 {
926   if (m_hide) return;
927   if (x->title().isEmpty()) return;
928   if (!m_firstCol) m_t << endl;
929   m_t << ".RE" << endl;
930   m_t << ".PP" << endl;
931   m_firstCol=TRUE;
932 }
933
934 void ManDocVisitor::visitPre(DocInternalRef *)
935 {
936   if (m_hide) return;
937   m_t << "\\fB";
938 }
939
940 void ManDocVisitor::visitPost(DocInternalRef *) 
941 {
942   if (m_hide) return;
943   m_t << "\\fP";
944 }
945
946 void ManDocVisitor::visitPre(DocCopy *)
947 {
948 }
949
950 void ManDocVisitor::visitPost(DocCopy *)
951 {
952 }
953
954 void ManDocVisitor::visitPre(DocText *)
955 {
956 }
957
958 void ManDocVisitor::visitPost(DocText *)
959 {
960 }
961
962 void ManDocVisitor::visitPre(DocHtmlBlockQuote *)
963 {
964   if (m_hide) return;
965   if (!m_firstCol)
966   { 
967     m_t << endl;
968     m_t << ".PP" << endl;
969   }
970   m_t << ".RS 4" << endl; // TODO: add support for nested block quotes
971 }
972
973 void ManDocVisitor::visitPost(DocHtmlBlockQuote *)
974 {
975   if (m_hide) return;
976   if (!m_firstCol) m_t << endl;
977   m_t << ".RE" << endl;
978   m_t << ".PP" << endl;
979   m_firstCol=TRUE;
980 }
981
982 void ManDocVisitor::visitPre(DocVhdlFlow *)
983 {
984 }
985
986 void ManDocVisitor::visitPost(DocVhdlFlow *)
987 {
988 }
989
990 void ManDocVisitor::visitPre(DocParBlock *)
991 {
992 }
993
994 void ManDocVisitor::visitPost(DocParBlock *)
995 {
996 }
997
998
999 void ManDocVisitor::filter(const char *str)
1000
1001   if (str)
1002   {
1003     const char *p=str;
1004     char c=0;
1005     while ((c=*p++)) 
1006     {
1007       switch(c)
1008       {
1009         case '.':  m_t << "\\&."; break; // see  bug652277
1010         case '\\': m_t << "\\\\"; break;
1011         case '"':  c = '\''; // fall through
1012         default: m_t << c; break;
1013       }
1014     }
1015   }
1016 }
1017
1018 void ManDocVisitor::pushEnabled()
1019 {
1020   m_enabled.push(new bool(m_hide));
1021 }
1022
1023 void ManDocVisitor::popEnabled()
1024 {
1025   bool *v=m_enabled.pop();
1026   ASSERT(v!=0);
1027   m_hide = *v;
1028   delete v;
1029 }
1030