Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/util/doxygen/src/rtfdocvisitor.cpp

Source at commit 1322 created 12 years 8 months ago.
By meklort, Add doxygen to utils folder
1/******************************************************************************
2 *
3 * $Id: $
4 *
5 *
6 * Copyright (C) 1997-2011 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 "rtfdocvisitor.h"
20#include "docparser.h"
21#include "language.h"
22#include "doxygen.h"
23#include "outputgen.h"
24#include "dot.h"
25#include "msc.h"
26#include "util.h"
27#include "rtfstyle.h"
28#include "message.h"
29#include <qfileinfo.h>
30#include "parserintf.h"
31#include "msc.h"
32
33
34//#define DBG_RTF(x) m_t << x
35#define DBG_RTF(x) do {} while(0)
36
37RTFDocVisitor::RTFDocVisitor(FTextStream &t,CodeOutputInterface &ci,
38 const char *langExt)
39 : DocVisitor(DocVisitor_RTF), m_t(t), m_ci(ci), m_insidePre(FALSE),
40 m_hide(FALSE), m_indentLevel(0), m_lastIsPara(FALSE), m_langExt(langExt)
41{
42}
43
44QCString RTFDocVisitor::getStyle(const char *name)
45{
46 QCString n;
47 n.sprintf("%s%d",name,m_indentLevel);
48 StyleData *sd = rtf_Style[n];
49 ASSERT(sd!=0);
50 return sd->reference;
51}
52
53void RTFDocVisitor::incIndentLevel()
54{
55 if (m_indentLevel<rtf_maxIndentLevels-1) m_indentLevel++;
56}
57
58void RTFDocVisitor::decIndentLevel()
59{
60 if (m_indentLevel>0) m_indentLevel--;
61}
62
63 //--------------------------------------
64 // visitor functions for leaf nodes
65 //--------------------------------------
66
67void RTFDocVisitor::visit(DocWord *w)
68{
69 if (m_hide) return;
70 DBG_RTF("{\\comment RTFDocVisitor::visit(DocWord)}\n");
71 filter(w->word());
72 m_lastIsPara=FALSE;
73}
74
75void RTFDocVisitor::visit(DocLinkedWord *w)
76{
77 if (m_hide) return;
78 DBG_RTF("{\\comment RTFDocVisitor::visit(DocLinkedWord)}\n");
79 startLink(w->ref(),w->file(),w->anchor());
80 filter(w->word());
81 endLink(w->ref());
82 m_lastIsPara=FALSE;
83}
84
85void RTFDocVisitor::visit(DocWhiteSpace *w)
86{
87 if (m_hide) return;
88 DBG_RTF("{\\comment RTFDocVisitor::visit(DocWhiteSpace)}\n");
89 if (m_insidePre)
90 {
91 m_t << w->chars();
92 }
93 else
94 {
95 m_t << " ";
96 }
97 m_lastIsPara=FALSE;
98}
99
100void RTFDocVisitor::visit(DocSymbol *s)
101{
102 if (m_hide) return;
103 DBG_RTF("{\\comment RTFDocVisitor::visit(DocSymbol)}\n");
104 switch(s->symbol())
105 {
106 case DocSymbol::BSlash: m_t << "\\\\"; break;
107 case DocSymbol::At: m_t << "@"; break;
108 case DocSymbol::Less: m_t << "<"; break;
109 case DocSymbol::Greater: m_t << ">"; break;
110 case DocSymbol::Amp: m_t << "&"; break;
111 case DocSymbol::Dollar: m_t << "$"; break;
112 case DocSymbol::Hash: m_t << "#"; break;
113 case DocSymbol::DoubleColon: m_t << "::"; break;
114 case DocSymbol::Percent: m_t << "%"; break;
115 case DocSymbol::Copy: m_t << "(C)"; break;
116 case DocSymbol::Tm: m_t << "(TM)"; break;
117 case DocSymbol::Reg: m_t << "(R)"; break;
118 case DocSymbol::Apos: m_t << "'"; break;
119 case DocSymbol::Quot: m_t << "\""; break;
120 case DocSymbol::Lsquo: m_t << "`"; break;
121 case DocSymbol::Rsquo: m_t << "'"; break;
122 case DocSymbol::Ldquo: m_t << "\""; break;
123 case DocSymbol::Rdquo: m_t << "\""; break;
124 case DocSymbol::Ndash: m_t << "-"; break;
125 case DocSymbol::Mdash: m_t << "--"; break;
126 case DocSymbol::Uml: switch(s->letter())
127 {
128 case 'A' : m_t << '\304'; break;
129 case 'E' : m_t << '\313'; break;
130 case 'I' : m_t << '\317'; break;
131 case 'O' : m_t << '\326'; break;
132 case 'U' : m_t << '\334'; break;
133 case 'Y' : m_t << 'Y'; break;
134 case 'a' : m_t << '\344'; break;
135 case 'e' : m_t << '\353'; break;
136 case 'i' : m_t << '\357'; break;
137 case 'o' : m_t << '\366'; break;
138 case 'u' : m_t << '\374'; break;
139 case 'y' : m_t << '\377'; break;
140 default: m_t << '?'; break;
141 }
142 break;
143 case DocSymbol::Acute: switch(s->letter())
144 {
145 case 'A' : m_t << '\301'; break;
146 case 'E' : m_t << '\311'; break;
147 case 'I' : m_t << '\315'; break;
148 case 'O' : m_t << '\323'; break;
149 case 'U' : m_t << '\332'; break;
150 case 'Y' : m_t << '\335'; break;
151 case 'a' : m_t << '\341'; break;
152 case 'e' : m_t << '\351'; break;
153 case 'i' : m_t << '\355'; break;
154 case 'o' : m_t << '\363'; break;
155 case 'u' : m_t << '\372'; break;
156 case 'y' : m_t << '\375'; break;
157 default: m_t << '?'; break;
158 }
159 break;
160 case DocSymbol::Grave: switch(s->letter())
161 {
162 case 'A' : m_t << '\300'; break;
163 case 'E' : m_t << '\310'; break;
164 case 'I' : m_t << '\314'; break;
165 case 'O' : m_t << '\322'; break;
166 case 'U' : m_t << '\331'; break;
167 case 'a' : m_t << '\340'; break;
168 case 'e' : m_t << '\350'; break;
169 case 'i' : m_t << '\354'; break;
170 case 'o' : m_t << '\362'; break;
171 case 'u' : m_t << '\371'; break;
172 default: m_t << '?'; break;
173 }
174 break;
175 case DocSymbol::Circ: switch(s->letter())
176 {
177 case 'A' : m_t << '\302'; break;
178 case 'E' : m_t << '\312'; break;
179 case 'I' : m_t << '\316'; break;
180 case 'O' : m_t << '\324'; break;
181 case 'U' : m_t << '\333'; break;
182 case 'a' : m_t << '\342'; break;
183 case 'e' : m_t << '\352'; break;
184 case 'i' : m_t << '\356'; break;
185 case 'o' : m_t << '\364'; break;
186 case 'u' : m_t << '\373'; break;
187 default: m_t << '?'; break;
188 }
189 break;
190 case DocSymbol::Tilde: switch(s->letter())
191 {
192 case 'A' : m_t << '\303'; break;
193 case 'N' : m_t << '\321'; break;
194 case 'O' : m_t << '\325'; break;
195 case 'a' : m_t << '\343'; break;
196 case 'n' : m_t << '\361'; break;
197 case 'o' : m_t << '\365'; break;
198 default: m_t << '?'; break;
199 }
200 break;
201 case DocSymbol::Cedil: switch(s->letter())
202 {
203 case 'C' : m_t << '\307'; break;
204 case 'c' : m_t << '\347'; break;
205 default: m_t << '?'; break;
206 }
207 break;
208 case DocSymbol::Slash: switch(s->letter())
209 {
210 case 'O' : m_t << '\330'; break;
211 case 'o' : m_t << '\370'; break;
212 default: m_t << '?'; break;
213 }
214 break;
215 case DocSymbol::Ring: switch(s->letter())
216 {
217 case 'A' : m_t << '\305'; break;
218 case 'a' : m_t << '\345'; break;
219 default: m_t << '?'; break;
220 }
221 break;
222 case DocSymbol::Szlig: m_t << "\337"; break;
223 case DocSymbol::Nbsp: m_t << "\\~ "; break;
224 case DocSymbol::Aelig: m_t << "\346"; break;
225 case DocSymbol::AElig: m_t << "\306"; break;
226 default:
227 err("error: unknown symbol found\n");
228 }
229 m_lastIsPara=FALSE;
230}
231
232void RTFDocVisitor::visit(DocURL *u)
233{
234 if (m_hide) return;
235 DBG_RTF("{\\comment RTFDocVisitor::visit(DocURL)}\n");
236 if (Config_getBool("RTF_HYPERLINKS"))
237 {
238 m_t << "{\\field "
239 "{\\*\\fldinst "
240 "{ HYPERLINK \\\\l \"";
241 if (u->isEmail()) m_t << "mailto:";
242 m_t << u->url();
243 m_t << "\" }"
244 "{}";
245 m_t << "}"
246 "{\\fldrslt "
247 "{\\cs37\\ul\\cf2 ";
248 filter(u->url());
249 m_t << "}"
250 "}"
251 "}" << endl;
252 }
253 else
254 {
255 m_t << "{\\f2 ";
256 filter(u->url());
257 m_t << "}";
258 }
259 m_lastIsPara=FALSE;
260}
261
262void RTFDocVisitor::visit(DocLineBreak *)
263{
264 if (m_hide) return;
265 DBG_RTF("{\\comment RTFDocVisitor::visit(DocLineBreak)}\n");
266 m_t << "\\par";
267 m_lastIsPara=TRUE;
268}
269
270void RTFDocVisitor::visit(DocHorRuler *)
271{
272 if (m_hide) return;
273 DBG_RTF("{\\comment RTFDocVisitor::visit(DocHorRuler)}\n");
274 m_t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}" << endl;
275 m_lastIsPara=TRUE;
276}
277
278void RTFDocVisitor::visit(DocStyleChange *s)
279{
280 if (m_hide) return;
281 m_lastIsPara=FALSE;
282 DBG_RTF("{\\comment RTFDocVisitor::visit(DocStyleChange)}\n");
283 switch (s->style())
284 {
285 case DocStyleChange::Bold:
286 if (s->enable()) m_t << "{\\b "; else m_t << "} ";
287 break;
288 case DocStyleChange::Italic:
289 if (s->enable()) m_t << "{\\i "; else m_t << "} ";
290 break;
291 case DocStyleChange::Code:
292 if (s->enable()) m_t << "{\\f2 "; else m_t << "} ";
293 break;
294 case DocStyleChange::Subscript:
295 if (s->enable()) m_t << "{\\sub "; else m_t << "} ";
296 break;
297 case DocStyleChange::Superscript:
298 if (s->enable()) m_t << "{\\super "; else m_t << "} ";
299 break;
300 case DocStyleChange::Center:
301 if (s->enable()) m_t << "{\\qc "; else m_t << "} ";
302 break;
303 case DocStyleChange::Small:
304 if (s->enable()) m_t << "{\\sub "; else m_t << "} ";
305 break;
306 case DocStyleChange::Preformatted:
307 if (s->enable())
308 {
309 m_t << "{" << endl;
310 m_t << "\\par" << endl;
311 m_t << rtf_Style_Reset << getStyle("CodeExample");
312 m_insidePre=TRUE;
313 }
314 else
315 {
316 m_insidePre=FALSE;
317 m_t << "\\par";
318 m_t << "}" << endl;
319 }
320 m_lastIsPara=TRUE;
321 break;
322 case DocStyleChange::Div: /* HTML only */ break;
323 case DocStyleChange::Span: /* HTML only */ break;
324 }
325}
326
327void RTFDocVisitor::visit(DocVerbatim *s)
328{
329 if (m_hide) return;
330 DBG_RTF("{\\comment RTFDocVisitor::visit(DocVerbatim)}\n");
331 switch(s->type())
332 {
333 case DocVerbatim::Code: // fall though
334 m_t << "{" << endl;
335 m_t << "\\par" << endl;
336 m_t << rtf_Style_Reset << getStyle("CodeExample");
337 Doxygen::parserManager->getParser(m_langExt)
338 ->parseCode(m_ci,s->context(),s->text(),
339 s->isExample(),s->exampleFile());
340 //m_t << "\\par" << endl;
341 m_t << "}" << endl;
342 break;
343 case DocVerbatim::Verbatim:
344 m_t << "{" << endl;
345 m_t << "\\par" << endl;
346 m_t << rtf_Style_Reset << getStyle("CodeExample");
347 filter(s->text(),TRUE);
348 //m_t << "\\par" << endl;
349 m_t << "}" << endl;
350 break;
351 case DocVerbatim::HtmlOnly:
352 case DocVerbatim::LatexOnly:
353 case DocVerbatim::XmlOnly:
354 case DocVerbatim::ManOnly:
355 /* nothing */
356 break;
357 case DocVerbatim::Dot:
358 {
359 static int dotindex = 1;
360 QCString fileName(4096);
361
362 fileName.sprintf("%s%d%s",
363 (Config_getString("RTF_OUTPUT")+"/inline_dotgraph_").data(),
364 dotindex++,
365 ".dot"
366 );
367 QFile file(fileName);
368 if (!file.open(IO_WriteOnly))
369 {
370 err("Could not open file %s for writing\n",fileName.data());
371 }
372 file.writeBlock( s->text(), s->text().length() );
373 file.close();
374 m_t << "\\par{\\qc "; // center picture
375 writeDotFile(fileName);
376 m_t << "} ";
377 if (Config_getBool("DOT_CLEANUP")) file.remove();
378 }
379 break;
380 case DocVerbatim::Msc:
381 {
382 static int mscindex = 1;
383 QCString baseName(4096);
384
385 baseName.sprintf("%s%d",
386 (Config_getString("RTF_OUTPUT")+"/inline_mscgraph_").data(),
387 mscindex++
388 );
389 QFile file(baseName+".msc");
390 if (!file.open(IO_WriteOnly))
391 {
392 err("Could not open file %s for writing\n",baseName.data());
393 }
394 QCString text = "msc {";
395 text+=s->text();
396 text+="}";
397 file.writeBlock( text, text.length() );
398 file.close();
399 m_t << "\\par{\\qc "; // center picture
400 writeMscFile(baseName);
401 m_t << "} ";
402 if (Config_getBool("DOT_CLEANUP")) file.remove();
403 }
404 break;
405 }
406 m_lastIsPara=FALSE;
407}
408
409void RTFDocVisitor::visit(DocAnchor *anc)
410{
411 if (m_hide) return;
412 DBG_RTF("{\\comment RTFDocVisitor::visit(DocAnchor)}\n");
413 QCString anchor;
414 if (!anc->file().isEmpty())
415 {
416 anchor+=anc->file();
417 }
418 if (!anc->file().isEmpty() && !anc->anchor().isEmpty())
419 {
420 anchor+="_";
421 }
422 if (!anc->anchor().isEmpty())
423 {
424 anchor+=anc->anchor();
425 }
426 m_t << "{\\bkmkstart " << rtfFormatBmkStr(anchor) << "}" << endl;
427 m_t << "{\\bkmkend " << rtfFormatBmkStr(anchor) << "}" << endl;
428 m_lastIsPara=FALSE;
429}
430
431void RTFDocVisitor::visit(DocInclude *inc)
432{
433 if (m_hide) return;
434 DBG_RTF("{\\comment RTFDocVisitor::visit(DocInclude)}\n");
435 switch(inc->type())
436 {
437 case DocInclude::IncWithLines:
438 {
439 m_t << "{" << endl;
440 m_t << "\\par" << endl;
441 m_t << rtf_Style_Reset << getStyle("CodeExample");
442 QFileInfo cfi( inc->file() );
443 FileDef fd( cfi.dirPath(), cfi.fileName() );
444 Doxygen::parserManager->getParser(inc->extension())
445 ->parseCode(m_ci,inc->context(),
446 inc->text(),
447 inc->isExample(),
448 inc->exampleFile(), &fd);
449 m_t << "\\par";
450 m_t << "}" << endl;
451 }
452 break;
453 case DocInclude::Include:
454 m_t << "{" << endl;
455 m_t << "\\par" << endl;
456 m_t << rtf_Style_Reset << getStyle("CodeExample");
457 Doxygen::parserManager->getParser(inc->extension())
458 ->parseCode(m_ci,inc->context(),
459 inc->text(),inc->isExample(),
460 inc->exampleFile());
461 m_t << "\\par";
462 m_t << "}" << endl;
463 break;
464 case DocInclude::DontInclude:
465 break;
466 case DocInclude::HtmlInclude:
467 break;
468 case DocInclude::VerbInclude:
469 m_t << "{" << endl;
470 m_t << "\\par" << endl;
471 m_t << rtf_Style_Reset << getStyle("CodeExample");
472 filter(inc->text());
473 m_t << "\\par";
474 m_t << "}" << endl;
475 break;
476 }
477 m_lastIsPara=TRUE;
478}
479
480void RTFDocVisitor::visit(DocIncOperator *op)
481{
482 //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n",
483 // op->type(),op->isFirst(),op->isLast(),op->text().data());
484 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIncOperator)}\n");
485 if (op->isFirst())
486 {
487 if (!m_hide)
488 {
489 m_t << "{" << endl;
490 m_t << "\\par" << endl;
491 m_t << rtf_Style_Reset << getStyle("CodeExample");
492 }
493 pushEnabled();
494 m_hide = TRUE;
495 }
496 if (op->type()!=DocIncOperator::Skip)
497 {
498 popEnabled();
499 if (!m_hide)
500 {
501 Doxygen::parserManager->getParser(m_langExt)
502 ->parseCode(m_ci,op->context(),op->text(),
503 op->isExample(),op->exampleFile());
504 }
505 pushEnabled();
506 m_hide=TRUE;
507 }
508 if (op->isLast())
509 {
510 popEnabled();
511 if (!m_hide)
512 {
513 m_t << "\\par";
514 m_t << "}" << endl;
515 }
516 m_lastIsPara=TRUE;
517 }
518 else
519 {
520 if (!m_hide) m_t << endl;
521 m_lastIsPara=FALSE;
522 }
523}
524
525void RTFDocVisitor::visit(DocFormula *f)
526{
527 if (m_hide) return;
528 // TODO: do something sensible here, like including a bitmap
529 DBG_RTF("{\\comment RTFDocVisitor::visit(DocFormula)}\n");
530 m_t << f->text();
531 m_lastIsPara=FALSE;
532}
533
534void RTFDocVisitor::visit(DocIndexEntry *i)
535{
536 if (m_hide) return;
537 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIndexEntry)}\n");
538 m_t << "{\\xe \\v " << i->entry() << "}" << endl;
539 m_lastIsPara=FALSE;
540}
541
542void RTFDocVisitor::visit(DocSimpleSectSep *)
543{
544}
545
546//--------------------------------------
547// visitor functions for compound nodes
548//--------------------------------------
549
550void RTFDocVisitor::visitPre(DocAutoList *l)
551{
552 if (m_hide) return;
553 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocAutoList)}\n");
554 m_t << "{" << endl;
555 rtf_listItemInfo[m_indentLevel].isEnum = l->isEnumList();
556 rtf_listItemInfo[m_indentLevel].number = 1;
557 m_lastIsPara=FALSE;
558}
559
560void RTFDocVisitor::visitPost(DocAutoList *)
561{
562 if (m_hide) return;
563 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocAutoList)}\n");
564 m_t << "\\par";
565 m_t << "}" << endl;
566 m_lastIsPara=TRUE;
567}
568
569void RTFDocVisitor::visitPre(DocAutoListItem *)
570{
571 if (m_hide) return;
572 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocAutoListItem)}\n");
573 if (!m_lastIsPara) m_t << "\\par" << endl;
574 m_t << rtf_Style_Reset;
575 if (rtf_listItemInfo[m_indentLevel].isEnum)
576 {
577 m_t << getStyle("ListEnum") << endl;
578 m_t << rtf_listItemInfo[m_indentLevel].number << ".\\tab ";
579 rtf_listItemInfo[m_indentLevel].number++;
580 }
581 else
582 {
583 m_t << getStyle("ListBullet") << endl;
584 }
585 incIndentLevel();
586 m_lastIsPara=FALSE;
587}
588
589void RTFDocVisitor::visitPost(DocAutoListItem *)
590{
591 decIndentLevel();
592 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocAutoListItem)}\n");
593}
594
595void RTFDocVisitor::visitPre(DocPara *)
596{
597 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocPara)}\n");
598}
599
600void RTFDocVisitor::visitPost(DocPara *p)
601{
602 if (m_hide) return;
603 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocPara)}\n");
604 if (!m_lastIsPara &&
605 !p->isLast() && // omit <p> for last paragraph
606 !(p->parent() && // and for parameters & sections
607 p->parent()->kind()==DocNode::Kind_ParamSect
608 )
609 )
610 {
611 m_t << "\\par" << endl;
612 m_lastIsPara=TRUE;
613 }
614}
615
616void RTFDocVisitor::visitPre(DocRoot *r)
617{
618 if (m_hide) return;
619 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocRoot)}\n");
620 if (r->indent()) incIndentLevel();
621 m_t << "{" << rtf_Style["BodyText"]->reference << endl;
622}
623
624void RTFDocVisitor::visitPost(DocRoot *r)
625{
626 if (m_hide) return;
627 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocRoot)}\n");
628 if (!m_lastIsPara && !r->singleLine()) m_t << "\\par" << endl;
629 m_t << "}";
630 m_lastIsPara=TRUE;
631 if (r->indent()) decIndentLevel();
632}
633
634void RTFDocVisitor::visitPre(DocSimpleSect *s)
635{
636 if (m_hide) return;
637 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocSimpleSect)}\n");
638 if (!m_lastIsPara) m_t << "\\par" << endl;
639 m_t << "{"; // start desc
640 //m_t << "{\\b "; // start bold
641 m_t << "{" << rtf_Style["Heading5"]->reference << endl;
642 switch(s->type())
643 {
644 case DocSimpleSect::See:
645 m_t << theTranslator->trSeeAlso(); break;
646 case DocSimpleSect::Return:
647 m_t << theTranslator->trReturns(); break;
648 case DocSimpleSect::Author:
649 m_t << theTranslator->trAuthor(TRUE,TRUE); break;
650 case DocSimpleSect::Authors:
651 m_t << theTranslator->trAuthor(TRUE,FALSE); break;
652 case DocSimpleSect::Version:
653 m_t << theTranslator->trVersion(); break;
654 case DocSimpleSect::Since:
655 m_t << theTranslator->trSince(); break;
656 case DocSimpleSect::Date:
657 m_t << theTranslator->trDate(); break;
658 case DocSimpleSect::Note:
659 m_t << theTranslator->trNote(); break;
660 case DocSimpleSect::Warning:
661 m_t << theTranslator->trWarning(); break;
662 case DocSimpleSect::Pre:
663 m_t << theTranslator->trPrecondition(); break;
664 case DocSimpleSect::Post:
665 m_t << theTranslator->trPostcondition(); break;
666 case DocSimpleSect::Invar:
667 m_t << theTranslator->trInvariant(); break;
668 case DocSimpleSect::Remark:
669 m_t << theTranslator->trRemarks(); break;
670 case DocSimpleSect::Attention:
671 m_t << theTranslator->trAttention(); break;
672 case DocSimpleSect::User: break;
673 case DocSimpleSect::Rcs: break;
674 case DocSimpleSect::Unknown: break;
675 }
676
677 // special case 1: user defined title
678 if (s->type()!=DocSimpleSect::User && s->type()!=DocSimpleSect::Rcs)
679 {
680 m_t << ":";
681 m_t << "\\par";
682 m_t << "}"; // end bold
683 incIndentLevel();
684 m_t << rtf_Style_Reset << getStyle("DescContinue");
685 }
686 m_lastIsPara=FALSE;
687}
688
689void RTFDocVisitor::visitPost(DocSimpleSect *)
690{
691 if (m_hide) return;
692 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSimpleSect)}\n");
693 if (!m_lastIsPara) m_t << "\\par" << endl;
694 decIndentLevel();
695 m_t << "}"; // end desc
696 m_lastIsPara=TRUE;
697}
698
699void RTFDocVisitor::visitPre(DocTitle *)
700{
701 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocTitle)}\n");
702}
703
704void RTFDocVisitor::visitPost(DocTitle *)
705{
706 if (m_hide) return;
707 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocTitle)}\n");
708 m_t << "\\par" << endl;
709 m_t << "}"; // end bold
710 incIndentLevel();
711 m_t << rtf_Style_Reset << getStyle("DescContinue");
712 m_lastIsPara=FALSE;
713}
714
715void RTFDocVisitor::visitPre(DocSimpleList *)
716{
717 if (m_hide) return;
718 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocSimpleSect)}\n");
719 m_t << "{" << endl;
720 rtf_listItemInfo[m_indentLevel].isEnum = FALSE;
721 m_lastIsPara=FALSE;
722}
723
724void RTFDocVisitor::visitPost(DocSimpleList *)
725{
726 if (m_hide) return;
727 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSimpleSect)}\n");
728 if (!m_lastIsPara) m_t << "\\par" << endl;
729 m_t << "}" << endl;
730 m_lastIsPara=TRUE;
731}
732
733void RTFDocVisitor::visitPre(DocSimpleListItem *)
734{
735 if (m_hide) return;
736 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocSimpleListItem)}\n");
737 m_t << "\\par" << rtf_Style_Reset << getStyle("ListBullet") << endl;
738 m_lastIsPara=FALSE;
739 incIndentLevel();
740}
741
742void RTFDocVisitor::visitPost(DocSimpleListItem *)
743{
744 decIndentLevel();
745 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSimpleListItem)}\n");
746}
747
748void RTFDocVisitor::visitPre(DocSection *s)
749{
750 if (m_hide) return;
751 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocSection)}\n");
752 if (!m_lastIsPara) m_t << "\\par" << endl;
753 m_t << "{\\bkmkstart " << rtfFormatBmkStr(s->file()+"_"+s->anchor()) << "}" << endl;
754 m_t << "{\\bkmkend " << rtfFormatBmkStr(s->file()+"_"+s->anchor()) << "}" << endl;
755 m_t << "{{" // start section
756 << rtf_Style_Reset;
757 QCString heading;
758 int level = QMIN(s->level()+1,4);
759 heading.sprintf("Heading%d",level);
760 // set style
761 m_t << rtf_Style[heading]->reference << endl;
762 // make table of contents entry
763 filter(s->title());
764 m_t << endl << "\\par" << "}" << endl;
765 m_t << "{\\tc\\tcl" << level << " \\v ";
766 filter(s->title());
767 m_t << "}" << endl;
768 m_lastIsPara=TRUE;
769}
770
771void RTFDocVisitor::visitPost(DocSection *)
772{
773 if (m_hide) return;
774 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSection)}\n");
775 m_t << "\\par}" << endl; // end section
776 m_lastIsPara=TRUE;
777}
778
779void RTFDocVisitor::visitPre(DocHtmlList *l)
780{
781 if (m_hide) return;
782 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlList)}\n");
783 m_t << "{" << endl;
784 rtf_listItemInfo[m_indentLevel].isEnum = l->type()==DocHtmlList::Ordered;
785 rtf_listItemInfo[m_indentLevel].number = 1;
786 m_lastIsPara=FALSE;
787}
788
789void RTFDocVisitor::visitPost(DocHtmlList *)
790{
791 if (m_hide) return;
792 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlList)}\n");
793 m_t << "\\par" << "}" << endl;
794 m_lastIsPara=TRUE;
795}
796
797void RTFDocVisitor::visitPre(DocHtmlListItem *)
798{
799 if (m_hide) return;
800 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlListItem)}\n");
801 m_t << "\\par" << endl;
802 m_t << rtf_Style_Reset;
803 if (rtf_listItemInfo[m_indentLevel].isEnum)
804 {
805 m_t << getStyle("ListEnum") << endl;
806 m_t << rtf_listItemInfo[m_indentLevel].number << ".\\tab ";
807 rtf_listItemInfo[m_indentLevel].number++;
808 }
809 else
810 {
811 m_t << getStyle("ListBullet") << endl;
812 }
813 incIndentLevel();
814 m_lastIsPara=FALSE;
815}
816
817void RTFDocVisitor::visitPost(DocHtmlListItem *)
818{
819 decIndentLevel();
820 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlListItem)}\n");
821}
822
823void RTFDocVisitor::visitPre(DocHtmlDescList *)
824{
825 if (m_hide) return;
826 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlDescList)}\n");
827 //m_t << "{" << endl;
828 //m_t << rtf_Style_Reset << getStyle("ListContinue");
829 //m_lastIsPara=FALSE;
830}
831
832void RTFDocVisitor::visitPost(DocHtmlDescList *)
833{
834 if (m_hide) return;
835 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlDescList)}\n");
836 //m_t << "}" << endl;
837 //m_t << "\\par" << endl;
838 //m_lastIsPara=TRUE;
839}
840
841void RTFDocVisitor::visitPre(DocHtmlDescTitle *)
842{
843 if (m_hide) return;
844 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlDescTitle)}\n");
845 //m_t << "\\par" << endl;
846 //m_t << "{\\b ";
847 m_t << "{" << rtf_Style["Heading5"]->reference << endl;
848 m_lastIsPara=FALSE;
849}
850
851void RTFDocVisitor::visitPost(DocHtmlDescTitle *)
852{
853 if (m_hide) return;
854 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlDescTitle)}\n");
855 m_t << "\\par" << endl;
856 m_t << "}" << endl;
857 m_lastIsPara=TRUE;
858}
859
860void RTFDocVisitor::visitPre(DocHtmlDescData *)
861{
862 if (m_hide) return;
863 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlDescData)}\n");
864 incIndentLevel();
865 m_t << "{" << rtf_Style_Reset << getStyle("DescContinue");
866}
867
868void RTFDocVisitor::visitPost(DocHtmlDescData *)
869{
870 if (m_hide) return;
871 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlDescData)}\n");
872 m_t << "\\par";
873 m_t << "}" << endl;
874 decIndentLevel();
875 m_lastIsPara=TRUE;
876}
877
878void RTFDocVisitor::visitPre(DocHtmlTable *)
879{
880 if (m_hide) return;
881 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlTable)}\n");
882 if (!m_lastIsPara) m_t << "\\par" << endl;
883 m_lastIsPara=TRUE;
884}
885
886void RTFDocVisitor::visitPost(DocHtmlTable *)
887{
888 if (m_hide) return;
889 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlTable)}\n");
890 m_t << "\\pard" << endl;
891 m_lastIsPara=TRUE;
892}
893
894void RTFDocVisitor::visitPre(DocHtmlCaption *)
895{
896 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlCaption)}\n");
897}
898
899void RTFDocVisitor::visitPost(DocHtmlCaption *)
900{
901 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlCaption)}\n");
902}
903
904void RTFDocVisitor::visitPre(DocHtmlRow *r)
905{
906 if (m_hide) return;
907 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlRow)}\n");
908 uint i,columnWidth=r->numCells()>0 ? rtf_pageWidth/r->numCells() : 10;
909 m_t << "\\trowd \\trgaph108\\trleft-108"
910 "\\trbrdrt\\brdrs\\brdrw10 "
911 "\\trbrdrl\\brdrs\\brdrw10 "
912 "\\trbrdrb\\brdrs\\brdrw10 "
913 "\\trbrdrr\\brdrs\\brdrw10 "
914 "\\trbrdrh\\brdrs\\brdrw10 "
915 "\\trbrdrv\\brdrs\\brdrw10 "<< endl;
916 for (i=0;i<r->numCells();i++)
917 {
918 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10 "
919 "\\clbrdrl\\brdrs\\brdrw10 "
920 "\\clbrdrb\\brdrs\\brdrw10 "
921 "\\clbrdrr \\brdrs\\brdrw10 "
922 "\\cltxlrtb "
923 "\\cellx" << ((i+1)*columnWidth) << endl;
924 }
925 m_t << "\\pard \\widctlpar\\intbl\\adjustright" << endl;
926 m_lastIsPara=FALSE;
927}
928
929void RTFDocVisitor::visitPost(DocHtmlRow *)
930{
931 if (m_hide) return;
932 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlRow)}\n");
933 m_t << endl;
934 m_t << "\\pard \\widctlpar\\intbl\\adjustright" << endl;
935 m_t << "{\\row }" << endl;
936 m_lastIsPara=FALSE;
937}
938
939void RTFDocVisitor::visitPre(DocHtmlCell *)
940{
941 if (m_hide) return;
942 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlCell)}\n");
943 m_t << "{";
944 m_lastIsPara=FALSE;
945}
946
947void RTFDocVisitor::visitPost(DocHtmlCell *)
948{
949 if (m_hide) return;
950 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlCell)}\n");
951 m_t << "\\cell }";
952 m_lastIsPara=FALSE;
953}
954
955void RTFDocVisitor::visitPre(DocInternal *)
956{
957 if (m_hide) return;
958 //DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocInternal)}\n");
959 //m_t << "{"; // start desc
960 //m_t << "{\\b "; // start bold
961 //m_t << theTranslator->trForInternalUseOnly();
962 //m_t << "}"; // end bold
963 //m_t << "\\par" << endl;
964 //incIndentLevel();
965 //m_t << rtf_Style_Reset << getStyle("DescContinue");
966 //m_lastIsPara=FALSE;
967}
968
969void RTFDocVisitor::visitPost(DocInternal *)
970{
971 if (m_hide) return;
972 //DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocInternal)}\n");
973 //m_t << "\\par";
974 //decIndentLevel();
975 //m_t << "}"; // end desc
976 //m_lastIsPara=TRUE;
977}
978
979void RTFDocVisitor::visitPre(DocHRef *href)
980{
981 if (m_hide) return;
982 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHRef)}\n");
983 if (Config_getBool("RTF_HYPERLINKS"))
984 {
985 m_t << "{\\field "
986 "{\\*\\fldinst "
987 "{ HYPERLINK \\\\l \"" << href->url() << "\" "
988 "}{}"
989 "}"
990 "{\\fldrslt "
991 "{\\cs37\\ul\\cf2 ";
992
993 }
994 else
995 {
996 m_t << "{\\f2 ";
997 }
998 m_lastIsPara=FALSE;
999}
1000
1001void RTFDocVisitor::visitPost(DocHRef *)
1002{
1003 if (m_hide) return;
1004 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHRef)}\n");
1005 if (Config_getBool("RTF_HYPERLINKS"))
1006 {
1007 m_t << "}"
1008 "}"
1009 "}";
1010 }
1011 else
1012 {
1013 m_t << "}";
1014 }
1015 m_lastIsPara=FALSE;
1016}
1017
1018void RTFDocVisitor::visitPre(DocHtmlHeader *header)
1019{
1020 if (m_hide) return;
1021 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlHeader)}\n");
1022 m_t << "{" // start section
1023 << rtf_Style_Reset;
1024 QCString heading;
1025 int level = QMIN(header->level()+2,4);
1026 heading.sprintf("Heading%d",level);
1027 // set style
1028 m_t << rtf_Style[heading]->reference;
1029 // make table of contents entry
1030 m_t << "{\\tc\\tcl \\v " << level << "}";
1031 m_lastIsPara=FALSE;
1032
1033}
1034
1035void RTFDocVisitor::visitPost(DocHtmlHeader *)
1036{
1037 if (m_hide) return;
1038 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlHeader)}\n");
1039 m_t << "\\par";
1040 m_t << "}" << endl; // end section
1041 m_lastIsPara=TRUE;
1042}
1043
1044void RTFDocVisitor::visitPre(DocImage *img)
1045{
1046 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocImage)}\n");
1047 if (img->type()==DocImage::Rtf)
1048 {
1049 m_t << "\\par" << endl;
1050 m_t << "{" << endl;
1051 m_t << rtf_Style_Reset << endl;
1052 m_t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"";
1053 m_t << img->name();
1054 m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl;
1055 m_t << "}" << endl;
1056 m_lastIsPara=TRUE;
1057 }
1058 else // other format -> skip
1059 {
1060 }
1061 // hide caption since it is not supported at the moment
1062 pushEnabled();
1063 m_hide=TRUE;
1064}
1065
1066void RTFDocVisitor::visitPost(DocImage *)
1067{
1068 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocImage)}\n");
1069 popEnabled();
1070}
1071
1072void RTFDocVisitor::visitPre(DocDotFile *df)
1073{
1074 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocDotFile)}\n");
1075 writeDotFile(df->file());
1076
1077 // hide caption since it is not supported at the moment
1078 pushEnabled();
1079 m_hide=TRUE;
1080}
1081
1082void RTFDocVisitor::visitPost(DocDotFile *)
1083{
1084 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocDotFile)}\n");
1085 popEnabled();
1086}
1087void RTFDocVisitor::visitPre(DocMscFile *df)
1088{
1089 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocMscFile)}\n");
1090 writeMscFile(df->file());
1091
1092 // hide caption since it is not supported at the moment
1093 pushEnabled();
1094 m_hide=TRUE;
1095}
1096
1097void RTFDocVisitor::visitPost(DocMscFile *)
1098{
1099 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocMscFile)}\n");
1100 popEnabled();
1101}
1102
1103void RTFDocVisitor::visitPre(DocLink *lnk)
1104{
1105 if (m_hide) return;
1106 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocLink)}\n");
1107 startLink(lnk->ref(),lnk->file(),lnk->anchor());
1108}
1109
1110void RTFDocVisitor::visitPost(DocLink *lnk)
1111{
1112 if (m_hide) return;
1113 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocLink)}\n");
1114 endLink(lnk->ref());
1115}
1116
1117void RTFDocVisitor::visitPre(DocRef *ref)
1118{
1119 if (m_hide) return;
1120 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocRef)}\n");
1121 if (!ref->file().isEmpty()) startLink(ref->ref(),ref->file(),ref->anchor());
1122 if (!ref->hasLinkText()) filter(ref->targetTitle());
1123}
1124
1125void RTFDocVisitor::visitPost(DocRef *ref)
1126{
1127 if (m_hide) return;
1128 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocRef)}\n");
1129 if (!ref->file().isEmpty()) endLink(ref->ref());
1130 //m_t << " ";
1131}
1132
1133
1134void RTFDocVisitor::visitPre(DocSecRefItem *)
1135{
1136 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocSecRefItem)}\n");
1137}
1138
1139void RTFDocVisitor::visitPost(DocSecRefItem *)
1140{
1141 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSecRefItem)}\n");
1142}
1143
1144void RTFDocVisitor::visitPre(DocSecRefList *)
1145{
1146 if (m_hide) return;
1147 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocSecRefList)}\n");
1148 m_t << "{" << endl;
1149 incIndentLevel();
1150 m_t << rtf_Style_Reset << getStyle("LatexTOC") << endl;
1151 m_t << "\\par" << endl;
1152 m_lastIsPara=TRUE;
1153}
1154
1155void RTFDocVisitor::visitPost(DocSecRefList *)
1156{
1157 if (m_hide) return;
1158 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSecRefList)}\n");
1159 decIndentLevel();
1160 m_t << "\\par";
1161 m_t << "}" << endl;
1162 m_lastIsPara=TRUE;
1163}
1164
1165//void RTFDocVisitor::visitPre(DocLanguage *l)
1166//{
1167// DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocLanguage)}\n");
1168// QCString langId = Config_getEnum("OUTPUT_LANGUAGE");
1169// if (l->id().lower()!=langId.lower())
1170// {
1171// pushEnabled();
1172// m_hide = TRUE;
1173// }
1174//}
1175//
1176//void RTFDocVisitor::visitPost(DocLanguage *l)
1177//{
1178// DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocLanguage)}\n");
1179// QCString langId = Config_getEnum("OUTPUT_LANGUAGE");
1180// if (l->id().lower()!=langId.lower())
1181// {
1182// popEnabled();
1183// }
1184//}
1185
1186void RTFDocVisitor::visitPre(DocParamSect *s)
1187{
1188 if (m_hide) return;
1189 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocParamSect)}\n");
1190 m_t << "{"; // start param list
1191 if (!m_lastIsPara) m_t << "\\par" << endl;
1192 //m_t << "{\\b "; // start bold
1193 m_t << "{" << rtf_Style["Heading5"]->reference << endl;
1194 switch(s->type())
1195 {
1196 case DocParamSect::Param:
1197 m_t << theTranslator->trParameters(); break;
1198 case DocParamSect::RetVal:
1199 m_t << theTranslator->trReturnValues(); break;
1200 case DocParamSect::Exception:
1201 m_t << theTranslator->trExceptions(); break;
1202 case DocParamSect::TemplateParam:
1203 /* TODO: add this
1204 m_t << theTranslator->trTemplateParam(); break;
1205 */
1206 m_t << "Template Parameters"; break;
1207 default:
1208 ASSERT(0);
1209 }
1210 m_t << ":";
1211 m_t << "\\par";
1212 m_t << "}" << endl;
1213 bool useTable = s->type()==DocParamSect::Param ||
1214 s->type()==DocParamSect::RetVal ||
1215 s->type()==DocParamSect::Exception ||
1216 s->type()==DocParamSect::TemplateParam;
1217 if (!useTable)
1218 {
1219 incIndentLevel();
1220 }
1221 m_t << rtf_Style_Reset << getStyle("DescContinue");
1222 m_lastIsPara=TRUE;
1223}
1224
1225void RTFDocVisitor::visitPost(DocParamSect *s)
1226{
1227 if (m_hide) return;
1228 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocParamSect)}\n");
1229 //m_t << "\\par" << endl;
1230 bool useTable = s->type()==DocParamSect::Param ||
1231 s->type()==DocParamSect::RetVal ||
1232 s->type()==DocParamSect::Exception ||
1233 s->type()==DocParamSect::TemplateParam;
1234 if (!useTable)
1235 {
1236 decIndentLevel();
1237 }
1238 m_t << "}" << endl;
1239}
1240
1241void RTFDocVisitor::visitPre(DocParamList *pl)
1242{
1243 static int columnPos[4][5] =
1244 { { 2, 25, 100, 100, 100 }, // no inout, no type
1245 { 3, 14, 35, 100, 100 }, // inout, no type
1246 { 3, 25, 50, 100, 100 }, // no inout, type
1247 { 4, 14, 35, 55, 100 }, // no inout, type
1248 };
1249 int config=0;
1250 if (m_hide) return;
1251 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocParamList)}\n");
1252
1253 DocParamSect::Type parentType = DocParamSect::Unknown;
1254 DocParamSect *sect = 0;
1255 if (pl->parent() && pl->parent()->kind()==DocNode::Kind_ParamSect)
1256 {
1257 parentType = ((DocParamSect*)pl->parent())->type();
1258 sect=(DocParamSect*)pl->parent();
1259 }
1260 bool useTable = parentType==DocParamSect::Param ||
1261 parentType==DocParamSect::RetVal ||
1262 parentType==DocParamSect::Exception ||
1263 parentType==DocParamSect::TemplateParam;
1264 if (sect && sect->hasInOutSpecifier()) config+=1;
1265 if (sect && sect->hasTypeSpecifier()) config+=2;
1266 if (useTable)
1267 {
1268 int i;
1269 m_t << "\\trowd \\trgaph108\\trleft426\\tblind426"
1270 "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1271 "\\trbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1272 "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1273 "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 "
1274 "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 "
1275 "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< endl;
1276 for (i=0;i<columnPos[config][0];i++)
1277 {
1278 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1279 "\\clbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1280 "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1281 "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 "
1282 "\\cltxlrtb "
1283 "\\cellx" << (rtf_pageWidth*columnPos[config][i+1]/100) << endl;
1284 }
1285 m_t << "\\pard \\widctlpar\\intbl\\adjustright" << endl;
1286 }
1287
1288 if (sect && sect->hasInOutSpecifier())
1289 {
1290 if (useTable)
1291 {
1292 m_t << "{";
1293 }
1294
1295 // Put in the direction: in/out/in,out if specified.
1296 if (pl->direction()!=DocParamSect::Unspecified)
1297 {
1298 if (pl->direction()==DocParamSect::In)
1299 {
1300 m_t << "in";
1301 }
1302 else if (pl->direction()==DocParamSect::Out)
1303 {
1304 m_t << "out";
1305 }
1306 else if (pl->direction()==DocParamSect::InOut)
1307 {
1308 m_t << "in,out";
1309 }
1310 }
1311
1312 if (useTable)
1313 {
1314 m_t << "\\cell }";
1315 }
1316 }
1317
1318 if (sect && sect->hasTypeSpecifier())
1319 {
1320 if (useTable)
1321 {
1322 m_t << "{";
1323 }
1324 QListIterator<DocNode> li(pl->paramTypes());
1325 DocNode *type;
1326 bool first=TRUE;
1327 for (li.toFirst();(type=li.current());++li)
1328 {
1329 if (!first) m_t << " | "; else first=FALSE;
1330 if (type->kind()==DocNode::Kind_Word)
1331 {
1332 visit((DocWord*)type);
1333 }
1334 else if (type->kind()==DocNode::Kind_LinkedWord)
1335 {
1336 visit((DocLinkedWord*)type);
1337 }
1338 }
1339 if (useTable)
1340 {
1341 m_t << "\\cell }";
1342 }
1343 }
1344
1345
1346 if (useTable)
1347 {
1348 m_t << "{";
1349 }
1350
1351 m_t << "{\\i ";
1352 //QStrListIterator li(pl->parameters());
1353 //const char *s;
1354 QListIterator<DocNode> li(pl->parameters());
1355 DocNode *param;
1356 bool first=TRUE;
1357 for (li.toFirst();(param=li.current());++li)
1358 {
1359 if (!first) m_t << ","; else first=FALSE;
1360 if (param->kind()==DocNode::Kind_Word)
1361 {
1362 visit((DocWord*)param);
1363 }
1364 else if (param->kind()==DocNode::Kind_LinkedWord)
1365 {
1366 visit((DocLinkedWord*)param);
1367 }
1368 }
1369 m_t << "} ";
1370
1371 if (useTable)
1372 {
1373 m_t << "\\cell }{";
1374 }
1375 m_lastIsPara=TRUE;
1376}
1377
1378void RTFDocVisitor::visitPost(DocParamList *pl)
1379{
1380 if (m_hide) return;
1381 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocParamList)}\n");
1382
1383 DocParamSect::Type parentType = DocParamSect::Unknown;
1384 DocParamSect *sect = 0;
1385 if (pl->parent() && pl->parent()->kind()==DocNode::Kind_ParamSect)
1386 {
1387 parentType = ((DocParamSect*)pl->parent())->type();
1388 sect=(DocParamSect*)pl->parent();
1389 }
1390 bool useTable = parentType==DocParamSect::Param ||
1391 parentType==DocParamSect::RetVal ||
1392 parentType==DocParamSect::Exception ||
1393 parentType==DocParamSect::TemplateParam;
1394 if (useTable)
1395 {
1396 m_t << "\\cell }" << endl;
1397 //m_t << "\\pard \\widctlpar\\intbl\\adjustright" << endl;
1398 m_t << "{\\row }" << endl;
1399 }
1400 else
1401 {
1402 m_t << "\\par" << endl;
1403 }
1404
1405 m_lastIsPara=TRUE;
1406}
1407
1408void RTFDocVisitor::visitPre(DocXRefItem *x)
1409{
1410 if (m_hide) return;
1411 bool anonymousEnum = x->file()=="@";
1412 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocXRefItem)}\n");
1413 m_t << "{"; // start param list
1414 //m_t << "{\\b "; // start bold
1415 m_t << "{" << rtf_Style["Heading5"]->reference << endl;
1416 if (Config_getBool("RTF_HYPERLINKS") && !anonymousEnum)
1417 {
1418 QCString refName;
1419 if (!x->file().isEmpty())
1420 {
1421 refName+=x->file();
1422 }
1423 if (!x->file().isEmpty() && !x->anchor().isEmpty())
1424 {
1425 refName+="_";
1426 }
1427 if (!x->anchor().isEmpty())
1428 {
1429 refName+=x->anchor();
1430 }
1431
1432 m_t << "{\\field "
1433 "{\\*\\fldinst "
1434 "{ HYPERLINK \\\\l \"" << refName << "\" "
1435 "}{}"
1436 "}"
1437 "{\\fldrslt "
1438 "{\\cs37\\ul\\cf2 ";
1439 filter(x->title());
1440 m_t << "}"
1441 "}"
1442 "}";
1443 }
1444 else
1445 {
1446 filter(x->title());
1447 }
1448 m_t << ":";
1449 m_t << "\\par";
1450 m_t << "}"; // end bold
1451 incIndentLevel();
1452 m_t << rtf_Style_Reset << getStyle("DescContinue");
1453 m_lastIsPara=FALSE;
1454}
1455
1456void RTFDocVisitor::visitPost(DocXRefItem *)
1457{
1458 if (m_hide) return;
1459 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocXRefItem)}\n");
1460 m_t << "\\par" << endl;
1461 decIndentLevel();
1462 m_t << "}" << endl; // end xref item
1463 m_lastIsPara=TRUE;
1464}
1465
1466void RTFDocVisitor::visitPre(DocInternalRef *ref)
1467{
1468 if (m_hide) return;
1469 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocInternalRef)}\n");
1470 startLink("",ref->file(),ref->anchor());
1471}
1472
1473void RTFDocVisitor::visitPost(DocInternalRef *)
1474{
1475 if (m_hide) return;
1476 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocInternalRef)}\n");
1477 endLink("");
1478 m_t << " ";
1479}
1480
1481void RTFDocVisitor::visitPre(DocCopy *)
1482{
1483 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocCopy)}\n");
1484}
1485
1486void RTFDocVisitor::visitPost(DocCopy *)
1487{
1488 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocCopy)}\n");
1489}
1490
1491void RTFDocVisitor::visitPre(DocText *)
1492{
1493 DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocText)}\n");
1494}
1495
1496void RTFDocVisitor::visitPost(DocText *)
1497{
1498 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocText)}\n");
1499}
1500
1501//static char* getMultiByte(int c)
1502//{
1503// static char s[10];
1504// sprintf(s,"\\'%X",c);
1505// return s;
1506//}
1507
1508void RTFDocVisitor::filter(const char *str,bool verbatim)
1509{
1510 if (str)
1511 {
1512 const unsigned char *p=(const unsigned char *)str;
1513 unsigned char c;
1514 unsigned char pc='\0';
1515 while (*p)
1516 {
1517 //static bool MultiByte = FALSE;
1518 c=*p++;
1519
1520 //if ( MultiByte )
1521 //{
1522 // m_t << getMultiByte( c );
1523 // MultiByte = FALSE;
1524 // continue;
1525 //}
1526 //if ( c >= 0x80 )
1527 //{
1528 // MultiByte = TRUE;
1529 // m_t << getMultiByte( c );
1530 // continue;
1531 //}
1532
1533 switch (c)
1534 {
1535 case '{': m_t << "\\{"; break;
1536 case '}': m_t << "\\}"; break;
1537 case '\\': m_t << "\\\\"; break;
1538 case '\n': if (verbatim)
1539 {
1540 m_t << "\\par" << endl;
1541 }
1542 else
1543 {
1544 m_t << '\n';
1545 }
1546 break;
1547 default: m_t << (char)c;
1548 }
1549 pc = c;
1550 }
1551 }
1552}
1553
1554void RTFDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)
1555{
1556 if (ref.isEmpty() && Config_getBool("RTF_HYPERLINKS"))
1557 {
1558 QCString refName;
1559 if (!file.isEmpty())
1560 {
1561 refName+=file;
1562 }
1563 if (anchor)
1564 {
1565 refName+='_';
1566 refName+=anchor;
1567 }
1568
1569 m_t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \"";
1570 m_t << rtfFormatBmkStr(refName);
1571 m_t << "\" }{}";
1572 m_t << "}{\\fldrslt {\\cs37\\ul\\cf2 ";
1573 }
1574 else
1575 {
1576 m_t << "{\\b ";
1577 }
1578 m_lastIsPara=FALSE;
1579}
1580
1581void RTFDocVisitor::endLink(const QCString &ref)
1582{
1583 if (ref.isEmpty() && Config_getBool("RTF_HYPERLINKS"))
1584 {
1585 m_t << "}}}";
1586 }
1587 else
1588 {
1589 m_t << "}";
1590 }
1591 m_lastIsPara=FALSE;
1592}
1593
1594void RTFDocVisitor::pushEnabled()
1595{
1596 m_enabled.push(new bool(m_hide));
1597}
1598
1599void RTFDocVisitor::popEnabled()
1600{
1601 bool *v=m_enabled.pop();
1602 ASSERT(v!=0);
1603 m_hide = *v;
1604 delete v;
1605}
1606
1607void RTFDocVisitor::writeDotFile(const QCString &fileName)
1608{
1609 QCString baseName=fileName;
1610 int i;
1611 if ((i=baseName.findRev('/'))!=-1)
1612 {
1613 baseName=baseName.right(baseName.length()-i-1);
1614 }
1615 QCString outDir = Config_getString("RTF_OUTPUT");
1616 writeDotGraphFromFile(fileName,outDir,baseName,BITMAP);
1617 if (!m_lastIsPara) m_t << "\\par" << endl;
1618 m_t << "{" << endl;
1619 m_t << rtf_Style_Reset;
1620 m_t << "\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"";
1621 m_t << baseName << "." << Config_getEnum("DOT_IMAGE_FORMAT");
1622 m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl;
1623 m_t << "}" << endl;
1624 m_lastIsPara=TRUE;
1625}
1626
1627void RTFDocVisitor::writeMscFile(const QCString &fileName)
1628{
1629 QCString baseName=fileName;
1630 int i;
1631 if ((i=baseName.findRev('/'))!=-1)
1632 {
1633 baseName=baseName.right(baseName.length()-i-1);
1634 }
1635 QCString outDir = Config_getString("RTF_OUTPUT");
1636 writeMscGraphFromFile(fileName,outDir,baseName,MSC_BITMAP);
1637 if (!m_lastIsPara) m_t << "\\par" << endl;
1638 m_t << "{" << endl;
1639 m_t << rtf_Style_Reset;
1640 m_t << "\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"";
1641 m_t << baseName << ".png";
1642 m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl;
1643 m_t << "}" << endl;
1644 m_lastIsPara=TRUE;
1645}
1646
1647

Archive Download this file

Revision: 1322