Doxygen
Loading...
Searching...
No Matches
rtfdocvisitor.cpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2022 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#include <algorithm>
17
18#include "rtfdocvisitor.h"
19#include "docparser.h"
20#include "language.h"
21#include "doxygen.h"
22#include "outputgen.h"
23#include "dot.h"
24#include "msc.h"
25#include "util.h"
26#include "rtfstyle.h"
27#include "rtfgen.h"
28#include "message.h"
29#include "parserintf.h"
30#include "dia.h"
31#include "filedef.h"
32#include "config.h"
33#include "htmlentity.h"
34#include "emoji.h"
35#include "plantuml.h"
36#include "fileinfo.h"
37#include "portable.h"
38#include "codefragment.h"
39#include "cite.h"
40#include "md5.h"
41
42//#define DBG_RTF(x) m_t << x
43#define DBG_RTF(x) do {} while(0)
44
45static QCString align(const DocHtmlCell &cell)
46{
47 for (const auto &attr : cell.attribs())
48 {
49 if (attr.name.lower()=="align")
50 {
51 if (attr.value.lower()=="center") return "\\qc ";
52 else if (attr.value.lower()=="right") return "\\qr ";
53 else return "";
54 }
55 }
56 return "";
57}
58
60 const QCString &langExt, int hierarchyLevel)
61 : m_t(t), m_ci(ci), m_langExt(langExt), m_hierarchyLevel(hierarchyLevel)
62{
63}
64
66{
67 QCString n = name + QCString().setNum(indentLevel());
68 StyleData &sd = rtf_Style[n.str()];
69 return sd.reference();
70}
71
73{
74 for (int i=0 ; rtf_Table_Default[i].definition ; i++ )
75 {
76 if ((id == rtf_Table_Default[i].id) && (m_indentLevel == rtf_Table_Default[i].lvl))
77 {
78 return rtf_Table_Default[i].place;
79 }
80 }
81 ASSERT(0);
82 return "";
83}
84
86{
87 return std::min(m_indentLevel,maxIndentLevels-1);
88}
89
91{
94 {
95 err("Maximum indent level ({}) exceeded while generating RTF output!\n",maxIndentLevels-1);
96 }
97}
98
103
104 //------------------------------------
105 // visitor functions for leaf nodes
106 //--------------------------------------
107
109{
110 if (m_hide) return;
111 DBG_RTF("{\\comment RTFDocVisitor::visit(DocWord)}\n");
112 filter(w.word());
114}
115
117{
118 if (m_hide) return;
119 DBG_RTF("{\\comment RTFDocVisitor::visit(DocLinkedWord)}\n");
120 startLink(w.ref(),w.file(),w.anchor());
121 filter(w.word());
122 endLink(w.ref());
124}
125
127{
128 if (m_hide) return;
129 DBG_RTF("{\\comment RTFDocVisitor::visit(DocWhiteSpace)}\n");
130 if (m_insidePre)
131 {
132 m_t << w.chars();
133 }
134 else
135 {
136 m_t << " ";
137 }
139}
140
142{
143 if (m_hide) return;
144 DBG_RTF("{\\comment RTFDocVisitor::visit(DocSymbol)}\n");
145 const char *res = HtmlEntityMapper::instance().rtf(s.symbol());
146 if (res)
147 {
148 m_t << res;
149 }
150 else
151 {
152 err("RTF: non supported HTML-entity found: {}\n",HtmlEntityMapper::instance().html(s.symbol(),TRUE));
153 }
155}
156
158{
159 if (m_hide) return;
160 DBG_RTF("{\\comment RTFDocVisitor::visit(DocEmoji)}\n");
161 const char *res = EmojiEntityMapper::instance().unicode(s.index());
162 if (res)
163 {
164 const char *p = res;
165 int val = 0;
166 int val1 = 0;
167 while (*p)
168 {
169 switch(*p)
170 {
171 case '&': case '#': case 'x':
172 break;
173 case ';':
174 val1 = val;
175 val = 0xd800 + ( ( val1 - 0x10000 ) & 0xffc00 ) / 0x400 - 0x10000;
176 m_t << "\\u" << val << "?";
177 val = 0xdC00 + ( ( val1 - 0x10000 ) & 0x3ff ) - 0x10000 ;
178 m_t << "\\u" << val << "?";
179 val = 0;
180 break;
181 case '0': case '1': case '2': case '3': case '4':
182 case '5': case '6': case '7': case '8': case '9':
183 val = val * 16 + *p - '0';
184 break;
185 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
186 val = val * 16 + *p - 'a' + 10;
187 break;
188 }
189 p++;
190 }
191 }
192 else
193 {
194 m_t << s.name();
195 }
197}
198
200{
201 if (m_hide) return;
202 DBG_RTF("{\\comment RTFDocVisitor::visit(DocURL)}\n");
203 if (Config_getBool(RTF_HYPERLINKS))
204 {
205 m_t << "{\\field "
206 "{\\*\\fldinst "
207 "{ HYPERLINK \"";
208 if (u.isEmail()) m_t << "mailto:";
209 m_t << u.url();
210 m_t << "\" }"
211 "{}";
212 m_t << "}"
213 "{\\fldrslt "
214 "{\\cs37\\ul\\cf2 ";
215 filter(u.url());
216 m_t << "}"
217 "}"
218 "}\n";
219 }
220 else
221 {
222 m_t << "{\\f2 ";
223 filter(u.url());
224 m_t << "}";
225 }
227}
228
230{
231 if (m_hide) return;
232 DBG_RTF("{\\comment RTFDocVisitor::visit(DocLineBreak)}\n");
233 m_t << "\\par\n";
235}
236
238{
239 if (m_hide) return;
240 DBG_RTF("{\\comment RTFDocVisitor::visit(DocHorRuler)}\n");
241 m_t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}\n";
243}
244
246{
247 if (m_hide) return;
249 DBG_RTF("{\\comment RTFDocVisitor::visit(DocStyleChange)}\n");
250 switch (s.style())
251 {
253 if (s.enable()) m_t << "{\\b "; else m_t << "} ";
254 break;
258 if (s.enable()) m_t << "{\\strike "; else m_t << "} ";
259 break;
262 if (s.enable()) m_t << "{\\ul "; else m_t << "} ";
263 break;
265 if (s.enable()) m_t << "{\\i "; else m_t << "} ";
266 break;
270 if (s.enable()) m_t << "{\\f2 "; else m_t << "} ";
271 break;
273 if (s.enable()) m_t << "{\\sub "; else m_t << "} ";
274 break;
276 if (s.enable()) m_t << "{\\super "; else m_t << "} ";
277 break;
279 if (s.enable()) m_t << "{\\qc "; else m_t << "} ";
280 break;
282 if (s.enable()) m_t << "{\\sub "; else m_t << "} ";
283 break;
285 if (s.enable()) m_t << "{\\i "; else m_t << "} ";
286 break;
288 if (s.enable())
289 {
290 m_t << "{\n";
291 m_t << "\\par\n";
292 m_t << rtf_Style_Reset << getStyle("CodeExample");
294 }
295 else
296 {
298 m_t << "\\par";
299 m_t << "}\n";
300 }
302 break;
303 case DocStyleChange::Div: /* HTML only */ break;
304 case DocStyleChange::Span: /* HTML only */ break;
305 }
306}
307
309{
310 if (m_hide) return;
311 DBG_RTF("{\\comment RTFDocVisitor::visit(DocVerbatim)}\n");
312 QCString lang = m_langExt;
313 if (!s.language().isEmpty()) // explicit language setting
314 {
315 lang = s.language();
316 }
317 SrcLangExt langExt = getLanguageFromCodeLang(lang);
318 switch(s.type())
319 {
321 m_t << "{\n";
322 m_t << "\\par\n";
323 m_t << rtf_Style_Reset << getStyle("CodeExample");
324 getCodeParser(lang).parseCode(m_ci,s.context(),s.text(),langExt,
325 Config_getBool(STRIP_CODE_COMMENTS),
326 CodeParserOptions().setExample(s.isExample(),s.exampleFile()));
327 //m_t << "\\par\n";
328 m_t << "}\n";
329 break;
331 filter(s.text(),TRUE);
332 break;
334 m_t << "{\n";
335 m_t << "{\\f2 ";
336 filter(s.text(),TRUE);
337 m_t << "}";
338 m_t << "}\n";
339 break;
341 m_t << "{\n";
342 m_t << "\\par\n";
343 m_t << rtf_Style_Reset << getStyle("CodeExample");
344 filter(s.text(),TRUE);
345 //m_t << "\\par\n";
346 m_t << "}\n";
347 break;
349 m_t << s.text();
350 break;
356 /* nothing */
357 break;
358 case DocVerbatim::Dot:
359 {
360 bool exists = false;
361 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/inline_dotgraph_", // baseName
362 ".dot", // extension
363 s.text(), // contents
364 exists);
365 if (!fileName.isEmpty())
366 {
367 writeDotFile(fileName, s.hasCaption(), s.srcFile(), s.srcLine(), !exists);
368 visitChildren(s);
370 }
371 }
372 break;
373 case DocVerbatim::Msc:
374 {
375 bool exists = false;
376 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/inline_mscgraph_", // baseName
377 ".msc", // extension
378 "msc {"+s.text()+"}", // contents
379 exists);
380 if (!fileName.isEmpty())
381 {
382 writeMscFile(fileName, s.hasCaption(), s.srcFile(), s.srcLine(), !exists);
383 visitChildren(s);
385 }
386 }
387 break;
389 {
390 QCString rtfOutput = Config_getString(RTF_OUTPUT);
391 auto baseNameVector = PlantumlManager::instance().writePlantUMLSource(
393 s.engine(),s.srcFile(),s.srcLine(),true);
394
395 for (const auto &baseName: baseNameVector)
396 {
397 writePlantUMLFile(baseName, s.hasCaption());
398 visitChildren(s);
400 }
401 }
402 break;
403 }
405}
406
408{
409 if (m_hide) return;
410 DBG_RTF("{\\comment RTFDocVisitor::visit(DocAnchor)}\n");
411 QCString anchor;
412 if (!anc.file().isEmpty())
413 {
414 anchor+=stripPath(anc.file());
415 }
416 if (!anc.file().isEmpty() && !anc.anchor().isEmpty())
417 {
418 anchor+="_";
419 }
420 if (!anc.anchor().isEmpty())
421 {
422 anchor+=anc.anchor();
423 }
424 m_t << "{\\bkmkstart " << rtfFormatBmkStr(anchor) << "}\n";
425 m_t << "{\\bkmkend " << rtfFormatBmkStr(anchor) << "}\n";
427}
428
430{
431 if (m_hide) return;
433 DBG_RTF("{\\comment RTFDocVisitor::visit(DocInclude)}\n");
434 switch(inc.type())
435 {
437 {
438 m_t << "{\n";
439 m_t << "\\par\n";
440 m_t << rtf_Style_Reset << getStyle("CodeExample");
441 FileInfo cfi( inc.file().str() );
442 auto fd = createFileDef( cfi.dirPath(), cfi.fileName() );
444 inc.text(),
445 langExt,
446 inc.stripCodeComments(),
448 .setExample(inc.isExample(),inc.exampleFile())
449 .setFileDef(fd.get())
450 .setInlineFragment(true)
451 );
452 m_t << "\\par";
453 m_t << "}\n";
454 }
455 break;
457 m_t << "{\n";
458 m_t << "\\par\n";
459 m_t << rtf_Style_Reset << getStyle("CodeExample");
461 inc.text(),langExt,
462 inc.stripCodeComments(),
464 .setExample(inc.isExample(),inc.exampleFile())
465 .setInlineFragment(true)
466 .setShowLineNumbers(false)
467 );
468 m_t << "\\par";
469 m_t << "}\n";
470 break;
478 break;
480 m_t << inc.text();
481 break;
483 m_t << "{\n";
484 m_t << "\\par\n";
485 m_t << rtf_Style_Reset << getStyle("CodeExample");
486 filter(inc.text());
487 m_t << "\\par";
488 m_t << "}\n";
489 break;
492 m_t << "{\n";
493 if (!m_lastIsPara) m_t << "\\par\n";
494 m_t << rtf_Style_Reset << getStyle("CodeExample");
496 inc.file(),
497 inc.blockId(),
498 inc.context(),
500 inc.trimLeft(),
502 );
503 m_t << "}";
504 break;
505 }
507}
508
510{
511 //printf("DocIncOperator: type=%d first=%d, last=%d text='%s'\n",
512 // op.type(),op.isFirst(),op.isLast(),qPrint(op.text()));
513 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIncOperator)}\n");
515 if (locLangExt.isEmpty()) locLangExt = m_langExt;
516 SrcLangExt langExt = getLanguageFromFileName(locLangExt);
517 if (op.isFirst())
518 {
519 if (!m_hide)
520 {
521 m_t << "{\n";
522 m_t << "\\par\n";
523 m_t << rtf_Style_Reset << getStyle("CodeExample");
524 }
526 m_hide = TRUE;
527 }
528 if (op.type()!=DocIncOperator::Skip)
529 {
530 m_hide = popHidden();
531 if (!m_hide)
532 {
533 std::unique_ptr<FileDef> fd = nullptr;
534 if (!op.includeFileName().isEmpty())
535 {
536 FileInfo cfi( op.includeFileName().str() );
537 fd = createFileDef( cfi.dirPath(), cfi.fileName() );
538 }
539
540 getCodeParser(locLangExt).parseCode(m_ci,op.context(),op.text(),langExt,
543 .setExample(op.isExample(),op.exampleFile())
544 .setFileDef(fd.get())
545 .setStartLine(op.line())
547 );
548 }
550 m_hide=TRUE;
551 }
552 if (op.isLast())
553 {
554 m_hide = popHidden();
555 if (!m_hide)
556 {
557 m_t << "\\par";
558 m_t << "}\n";
559 }
561 }
562 else
563 {
564 if (!m_hide) m_t << "\n";
566 }
567}
568
570{
571 if (m_hide) return;
572 DBG_RTF("{\\comment RTFDocVisitor::visit(DocFormula)}\n");
573 bool bDisplay = !f.isInline();
574 if (bDisplay)
575 {
576 m_t << "\\par";
577 m_t << "{";
578 m_t << "\\pard\\plain";
579 m_t << "\\pard";
580 m_t << "\\qc";
581 }
582 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"" << f.relPath() << f.name() << ".png\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}";
583 if (bDisplay)
584 {
585 m_t << "\\par}";
586 }
588}
589
591{
592 if (m_hide) return;
593 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIndexEntry)}\n");
594 m_t << "{\\xe \\v " << i.entry() << "}\n";
596}
597
601
603{
604 if (m_hide) return;
605 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocCite &)}\n");
606 auto opt = cite.option();
607 if (!cite.file().isEmpty())
608 {
609 if (!opt.noCite()) startLink(cite.ref(),cite.file(),cite.anchor());
610
611 filter(cite.getText());
612
613 if (!opt.noCite()) endLink(cite.ref());
614 }
615 else
616 {
617 m_t << "{\\b";
618 if (!opt.noPar()) filter("[");
619 filter(cite.target());
620 if (!opt.noPar()) filter("]");
621 m_t << "}";
622 }
623}
624
625
626//--------------------------------------
627// visitor functions for compound nodes
628//--------------------------------------
629
631{
632 if (m_hide) return;
633 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoList &)}\n");
634 m_t << "{\n";
635 int level = indentLevel();
636 m_listItemInfo[level].isEnum = l.isEnumList();
637 m_listItemInfo[level].isCheck = l.isCheckedList();
638 m_listItemInfo[level].type = '1';
639 m_listItemInfo[level].number = 1;
641 visitChildren(l);
642 if (!m_lastIsPara) m_t << "\\par";
643 m_t << "}\n";
645 if (!l.isCheckedList() && indentLevel()==0) m_t << "\\par\n";
646}
647
649{
650 static int prevLevel = -1;
651 if (m_hide) return;
652 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoListItem &)}\n");
653 int level = indentLevel();
654 if ((level != prevLevel-1) &&
655 (!(level==prevLevel && level != 0 && m_listItemInfo[level].isCheck)) &&
656 (!m_lastIsPara))
657 m_t << "\\par\n";
658 prevLevel= level;
660 if (m_listItemInfo[level].isEnum)
661 {
662 m_t << getStyle("ListEnum") << "\n";
663 m_t << m_listItemInfo[level].number << ".\\tab ";
664 m_listItemInfo[level].number++;
665 }
666 else
667 {
668 switch (li.itemNumber())
669 {
670 case DocAutoList::Unchecked: // unchecked
671 m_t << getListTable(2) << "\n";
672 break;
673 case DocAutoList::Checked_x: // checked with x
674 case DocAutoList::Checked_X: // checked with X
675 m_t << getListTable(3) << "\n";
676 break;
677 default:
678 m_t << getListTable(1) << "\n";
679 break;
680 }
681 }
683 m_lastIsPara=false;
684 visitChildren(li);
686}
687
689{
690 if (m_hide) return;
691 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPara &)}\n");
692 visitChildren(p);
693 if (!m_lastIsPara &&
694 !p.isLast() && // omit <p> for last paragraph
695 !(p.parent() && // and for parameters & sections
696 std::get_if<DocParamSect>(p.parent())
697 )
698 )
699 {
700 m_t << "\\par\n";
702 }
703}
704
706{
707 if (m_hide) return;
708 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRoot &)}\n");
709 if (r.indent()) incIndentLevel();
710 m_t << "{" << rtf_Style["BodyText"].reference() << "\n";
711 visitChildren(r);
712 if (!m_lastIsPara && !r.singleLine()) m_t << "\\par\n";
713 m_t << "}";
715 if (r.indent()) decIndentLevel();
716}
717
719{
720 if (m_hide) return;
721 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
722 if (!m_lastIsPara) m_t << "\\par\n";
723 m_t << "{"; // start desc
724 //m_t << "{\\b "; // start bold
725 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
726 switch(s.type())
727 {
729 m_t << theTranslator->trSeeAlso(); break;
731 m_t << theTranslator->trReturns(); break;
733 m_t << theTranslator->trAuthor(TRUE,TRUE); break;
735 m_t << theTranslator->trAuthor(TRUE,FALSE); break;
737 m_t << theTranslator->trVersion(); break;
739 m_t << theTranslator->trSince(); break;
741 m_t << theTranslator->trDate(); break;
743 m_t << theTranslator->trNote(); break;
745 m_t << theTranslator->trWarning(); break;
747 m_t << theTranslator->trPrecondition(); break;
749 m_t << theTranslator->trPostcondition(); break;
751 m_t << theTranslator->trCopyright(); break;
753 m_t << theTranslator->trInvariant(); break;
755 m_t << theTranslator->trRemarks(); break;
757 m_t << theTranslator->trAttention(); break;
759 m_t << theTranslator->trImportant(); break;
760 case DocSimpleSect::User: break;
761 case DocSimpleSect::Rcs: break;
762 case DocSimpleSect::Unknown: break;
763 }
764
767 {
768 m_t << "\\par";
769 m_t << "}"; // end bold
770 m_t << rtf_Style_Reset << getStyle("DescContinue");
771 m_t << "{\\s17 \\sa60 \\sb30\n";
772 }
773 else
774 {
775 if (s.title())
776 {
777 std::visit(*this,*s.title());
778 }
779 m_t << "\\par\n";
780 m_t << "}"; // end bold
781 m_t << rtf_Style_Reset << getStyle("DescContinue");
782 }
784 visitChildren(s);
785 if (!m_lastIsPara) m_t << "\\par\n";
788 {
789 m_t << "}"; // end DescContinue
790 }
791 m_t << "}"; // end desc
793}
794
796{
797 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocTitle &)}\n");
798 if (m_hide) return;
799 visitChildren(t);
800}
801
803{
804 if (m_hide) return;
805 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
806 m_t << "{\n";
807 m_listItemInfo[indentLevel()].isEnum = false;
808 m_listItemInfo[indentLevel()].isCheck = false;
810 visitChildren(l);
811 if (!m_lastIsPara) m_t << "\\par\n";
812 m_t << "}\n";
814}
815
817{
818 if (m_hide) return;
819 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleListItem &)}\n");
820 m_t << "\\par" << rtf_Style_Reset << getStyle("ListBullet") << "\n";
823 if (li.paragraph())
824 {
825 std::visit(*this,*li.paragraph());
826 }
828 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSimpleListItem)}\n");
829}
830
832{
833 if (m_hide) return;
834 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSection &)}\n");
835 if (!m_lastIsPara) m_t << "\\par\n";
836 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
837 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
838 m_t << "{{" // start section
840 QCString heading;
841 int level = std::min(s.level()+2+m_hierarchyLevel,4);
842 if (level <= 0)
843 level = 1;
844 heading.sprintf("Heading%d",level);
845 // set style
846 m_t << rtf_Style[heading.str()].reference() << "\n";
847 // make table of contents entry
848 if (s.title())
849 {
850 std::visit(*this,*s.title());
851 }
852 m_t << "\n\\par" << "}\n";
853 m_t << "{\\tc\\tcl" << level << " \\v ";
854 if (s.title())
855 {
856 std::visit(*this,*s.title());
857 }
858 m_t << "}\n";
860 visitChildren(s);
861 m_t << "\\par}\n"; // end section
863}
864
866{
867 if (m_hide) return;
868 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlList &)}\n");
869 m_t << "{\n";
870 int level = indentLevel();
871 m_listItemInfo[level].isEnum = l.type()==DocHtmlList::Ordered;
872 m_listItemInfo[level].isCheck = false;
873 m_listItemInfo[level].number = 1;
874 m_listItemInfo[level].type = '1';
875 for (const auto &opt : l.attribs())
876 {
877 if (opt.name=="type")
878 {
879 m_listItemInfo[level].type = opt.value[0];
880 }
881 if (opt.name=="start")
882 {
883 bool ok = false;
884 int val = opt.value.toInt(&ok);
885 if (ok) m_listItemInfo[level].number = val;
886 }
887 }
889 visitChildren(l);
890 m_t << "\\par" << "}\n";
892}
893
895{
896 if (m_hide) return;
897 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlListItem &)}\n");
898 m_t << "\\par\n";
900 int level = indentLevel();
901 if (m_listItemInfo[level].isEnum)
902 {
903 for (const auto &opt : l.attribs())
904 {
905 if (opt.name=="value")
906 {
907 bool ok = false;
908 int val = opt.value.toInt(&ok);
909 if (ok) m_listItemInfo[level].number = val;
910 }
911 }
912 m_t << getStyle("ListEnum") << "\n";
913 switch (m_listItemInfo[level].type)
914 {
915 case '1':
916 m_t << m_listItemInfo[level].number;
917 break;
918 case 'a':
919 m_t << integerToAlpha(m_listItemInfo[level].number,false);
920 break;
921 case 'A':
922 m_t << integerToAlpha(m_listItemInfo[level].number);
923 break;
924 case 'i':
925 m_t << integerToRoman(m_listItemInfo[level].number,false);
926 break;
927 case 'I':
928 m_t << integerToRoman(m_listItemInfo[level].number);
929 break;
930 default:
931 m_t << m_listItemInfo[level].number;
932 break;
933 }
934 m_t << ".\\tab ";
935 m_listItemInfo[level].number++;
936 }
937 else
938 {
939 m_t << getStyle("ListBullet") << "\n";
940 }
943 visitChildren(l);
945 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlListItem)}\n");
946}
947
949{
950 if (m_hide) return;
951 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescList &)}\n");
952 //m_t << "{\n";
953 //m_t << rtf_Style_Reset << getStyle("ListContinue");
954 //m_lastIsPara=FALSE;
955 visitChildren(dl);
956 //m_t << "}\n";
957 //m_t << "\\par\n";
958 //m_lastIsPara=TRUE;
959}
960
962{
963 if (m_hide) return;
964 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescTitle &)}\n");
965 //m_t << "\\par\n";
966 //m_t << "{\\b ";
967 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
969 visitChildren(dt);
970 m_t << "\\par\n";
971 m_t << "}\n";
973}
974
976{
977 if (m_hide) return;
978 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescData &)}\n");
980 m_t << "{" << rtf_Style_Reset << getStyle("DescContinue");
981 visitChildren(dd);
982 m_t << "\\par";
983 m_t << "}\n";
986}
987
989{
990 if (m_hide) return;
991 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlTable &)}\n");
992 if (!m_lastIsPara) m_t << "\\par\n";
994 if (t.caption())
995 {
996 const DocHtmlCaption &c = std::get<DocHtmlCaption>(*t.caption());
997 m_t << "\\pard \\qc \\b";
998 if (!c.file().isEmpty())
999 {
1000 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1001 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1002 }
1003 m_t << "{Table \\field\\flddirty{\\*\\fldinst { SEQ Table \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1004 std::visit(*this,*t.caption());
1005 }
1006 visitChildren(t);
1007 m_t << "\\pard\\plain\n";
1008 m_t << "\\par\n";
1010}
1011
1013{
1014 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCaption &)}\n");
1015 visitChildren(c);
1016 m_t << "}\n\\par\n";
1017}
1018
1020{
1021 if (m_hide) return;
1022 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlRow &)}\n");
1023 size_t columnWidth=r.numCells()>0 ? rtf_pageWidth/r.numCells() : 10;
1024 m_t << "\\trowd \\trgaph108\\trleft-108"
1025 "\\trbrdrt\\brdrs\\brdrw10 "
1026 "\\trbrdrl\\brdrs\\brdrw10 "
1027 "\\trbrdrb\\brdrs\\brdrw10 "
1028 "\\trbrdrr\\brdrs\\brdrw10 "
1029 "\\trbrdrh\\brdrs\\brdrw10 "
1030 "\\trbrdrv\\brdrs\\brdrw10 \n";
1031 for (size_t i=0;i<r.numCells();i++)
1032 {
1033 if (r.isHeading())
1034 {
1035 m_t << "\\clcbpat16"; // set cell shading to light grey (color 16 in the clut)
1036 }
1037 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10 "
1038 "\\clbrdrl\\brdrs\\brdrw10 "
1039 "\\clbrdrb\\brdrs\\brdrw10 "
1040 "\\clbrdrr \\brdrs\\brdrw10 "
1041 "\\cltxlrtb "
1042 "\\cellx" << ((i+1)*columnWidth) << "\n";
1043 }
1044 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1046 visitChildren(r);
1047 m_t << "\n";
1048 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1049 m_t << "{\\row }\n";
1051}
1052
1054{
1055 if (m_hide) return;
1056 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCell &)}\n");
1057 m_t << "{" << align(c);
1059 visitChildren(c);
1060 m_t << "\\cell }";
1062}
1063
1065{
1066 if (m_hide) return;
1067 visitChildren(i);
1068}
1069
1071{
1072 if (m_hide) return;
1073 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHRef &)}\n");
1074 if (Config_getBool(RTF_HYPERLINKS))
1075 {
1076 if (href.url().startsWith("#"))
1077 {
1078 // when starting with # so a local link
1079 QCString cite;
1080 cite = href.file() + "_" + href.url().right(href.url().length()-1);
1081 m_t << "{\\field "
1082 "{\\*\\fldinst "
1083 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(cite) << "\" "
1084 "}{}"
1085 "}"
1086 "{\\fldrslt "
1087 "{\\cs37\\ul\\cf2 ";
1088 }
1089 else
1090 {
1091 m_t << "{\\field "
1092 "{\\*\\fldinst "
1093 "{ HYPERLINK \"" << href.url() << "\" "
1094 "}{}"
1095 "}"
1096 "{\\fldrslt "
1097 "{\\cs37\\ul\\cf2 ";
1098 }
1099 }
1100 else
1101 {
1102 m_t << "{\\f2 ";
1103 }
1105 visitChildren(href);
1106 if (Config_getBool(RTF_HYPERLINKS))
1107 {
1108 m_t << "}"
1109 "}"
1110 "}";
1111 }
1112 else
1113 {
1114 m_t << "}";
1115 }
1117}
1118
1120{
1121 if (m_hide) return;
1122 m_t << "{\\b ";
1123 visitChildren(s);
1124 m_t << "}\\par ";
1125}
1126
1128{
1129 if (m_hide) return;
1130 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDetails &)}\n");
1131 if (!m_lastIsPara) m_t << "\\par\n";
1132 auto summary = d.summary();
1133 if (summary)
1134 {
1135 std::visit(*this,*summary);
1136 m_t << "{"; // start desc
1138 m_t << rtf_Style_Reset << getStyle("DescContinue");
1139 }
1140 visitChildren(d);
1141 if (!m_lastIsPara) m_t << "\\par\n";
1142 if (summary)
1143 {
1145 m_t << "}"; // end desc
1146 }
1148}
1149
1151{
1152 if (m_hide) return;
1153 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlHeader &)}\n");
1154 m_t << "{" // start section
1155 << rtf_Style_Reset;
1156 QCString heading;
1157 int level = std::clamp(header.level()+m_hierarchyLevel,SectionType::MinLevel,SectionType::MaxLevel);
1158 heading.sprintf("Heading%d",level);
1159 // set style
1160 m_t << rtf_Style[heading.str()].reference();
1161 // make open table of contents entry that will be closed in visitPost method
1162 m_t << "{\\tc\\tcl" << level << " ";
1164 visitChildren(header);
1165 // close open table of contents entry
1166 m_t << "} \\par";
1167 m_t << "}\n"; // end section
1169}
1170
1171void RTFDocVisitor::includePicturePreRTF(const QCString &name, bool isTypeRTF, bool hasCaption, bool inlineImage)
1172{
1173 if (isTypeRTF)
1174 {
1175 if (!inlineImage)
1176 {
1177 m_t << "\\par\n";
1178 m_t << "{\n";
1179 m_t << rtf_Style_Reset << "\n";
1180 if (hasCaption || m_lastIsPara) m_t << "\\par\n";
1181 m_t << "\\pard \\qc ";
1182 }
1183 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"";
1184 m_t << name;
1185 m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}\n";
1186 if (!inlineImage)
1187 {
1188 m_t << "\\par\n";
1189 if (hasCaption)
1190 {
1191 m_t << "\\pard \\qc \\b";
1192 m_t << "{Image \\field\\flddirty{\\*\\fldinst { SEQ Image \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1193 }
1195 }
1196 else
1197 {
1198 if (hasCaption) m_t << "{\\comment "; // to prevent caption to be shown
1199 }
1200 }
1201 else // other format -> skip
1202 {
1204 m_hide=TRUE;
1205 }
1206}
1207
1208void RTFDocVisitor::includePicturePostRTF(bool isTypeRTF, bool hasCaption, bool inlineImage)
1209{
1210 if (isTypeRTF)
1211 {
1212 if (m_hide) return;
1213 if (inlineImage)
1214 {
1215 if (hasCaption) m_t << " }";
1216 }
1217 else
1218 {
1219 if (hasCaption)
1220 {
1221 m_t << "}\n";
1222 m_t << "\\par}\n";
1223 }
1224 else
1225 {
1226 m_t << "}\n";
1227 }
1228 }
1229 }
1230 else
1231 {
1232 m_hide = popHidden();
1233 }
1234}
1235
1237{
1238 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocImage &)}\n");
1240 visitChildren(img);
1242}
1243
1244
1246{
1247 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDotFile &)}\n");
1248 bool exists = false;
1249 std::string inBuf;
1250 if (readInputFile(df.file(),inBuf))
1251 {
1252 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1253 ".dot", // extension
1254 inBuf, // contents
1255 exists);
1256 if (!fileName.isEmpty())
1257 {
1258 writeDotFile(fileName, df.hasCaption(), df.srcFile(), df.srcLine(), !exists);
1259 visitChildren(df);
1261 }
1262 }
1263}
1265{
1266 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocMscFile &)}\n");
1267 bool exists = false;
1268 std::string inBuf;
1269 if (readInputFile(df.file(),inBuf))
1270 {
1271 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1272 ".msc", // extension
1273 inBuf, // contents
1274 exists);
1275 if (!fileName.isEmpty())
1276 {
1277 writeMscFile(fileName, df.hasCaption(), df.srcFile(), df.srcLine(), !exists);
1278 visitChildren(df);
1280 }
1281 }
1282}
1283
1285{
1286 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDiaFile &)}\n");
1287 bool exists = false;
1288 std::string inBuf;
1289 if (readInputFile(df.file(),inBuf))
1290 {
1291 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1292 ".dia", // extension
1293 inBuf, // contents
1294 exists);
1295 if (!fileName.isEmpty())
1296 {
1297 writeDiaFile(fileName, df.hasCaption(), df.srcFile(), df.srcLine(), !exists);
1298 visitChildren(df);
1300 }
1301 }
1302}
1303
1305{
1306 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPlantUmlFile &)}\n");
1307 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1308 QCString rtfOutput = Config_getString(RTF_OUTPUT);
1309 std::string inBuf;
1310 readInputFile(df.file(),inBuf);
1311 auto baseNameVector = PlantumlManager::instance().writePlantUMLSource(
1312 rtfOutput,QCString(),inBuf,PlantumlManager::PUML_BITMAP,
1313 QCString(),df.srcFile(),df.srcLine(),false);
1314 for(const auto &baseName: baseNameVector)
1315 {
1316 writePlantUMLFile(baseName, df.hasCaption());
1317 visitChildren(df);
1319 }
1320}
1321
1323{
1324 if (m_hide) return;
1325 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocLink &)}\n");
1326 startLink(lnk.ref(),lnk.file(),lnk.anchor());
1327 visitChildren(lnk);
1328 endLink(lnk.ref());
1329}
1330
1332{
1333 if (m_hide) return;
1334 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRef &)}\n");
1335 // when ref.isSubPage()==TRUE we use ref.file() for HTML and
1336 // ref.anchor() for LaTeX/RTF
1337 if (ref.isSubPage())
1338 {
1339 startLink(ref.ref(),QCString(),ref.anchor());
1340 }
1341 else
1342 {
1343 if (!ref.file().isEmpty()) startLink(ref.ref(),ref.file(),ref.anchor());
1344 }
1345 if (!ref.hasLinkText()) filter(ref.targetTitle());
1346 visitChildren(ref);
1347 if (!ref.file().isEmpty()) endLink(ref.ref());
1348 //m_t << " ";
1349}
1350
1351
1353{
1354 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefItem &)}\n");
1355 visitChildren(ref);
1356}
1357
1359{
1360 if (m_hide) return;
1361 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefList &)}\n");
1362 m_t << "{\n";
1364 m_t << rtf_Style_Reset << getStyle("LatexTOC") << "\n";
1365 m_t << "\\par\n";
1367 visitChildren(l);
1369 m_t << "\\par";
1370 m_t << "}\n";
1372}
1373
1375{
1376 if (m_hide) return;
1377 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamSect &)}\n");
1378 m_t << "{"; // start param list
1379 if (!m_lastIsPara) m_t << "\\par\n";
1380 //m_t << "{\\b "; // start bold
1381 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1382 switch(s.type())
1383 {
1385 m_t << theTranslator->trParameters(); break;
1387 m_t << theTranslator->trReturnValues(); break;
1389 m_t << theTranslator->trExceptions(); break;
1391 m_t << theTranslator->trTemplateParameters(); break;
1392 default:
1393 ASSERT(0);
1394 }
1395 m_t << "\\par";
1396 m_t << "}\n";
1397 bool useTable = s.type()==DocParamSect::Param ||
1401 if (!useTable)
1402 {
1404 }
1405 m_t << rtf_Style_Reset << getStyle("DescContinue");
1407 visitChildren(s);
1408 //m_t << "\\par\n";
1409 if (!useTable)
1410 {
1412 }
1413 m_t << "}\n";
1414}
1415
1417{
1418 m_t << " " << sep.chars() << " ";
1419}
1420
1422{
1423 static int columnPos[4][5] =
1424 { { 2, 25, 100, 100, 100 }, // no inout, no type
1425 { 3, 14, 35, 100, 100 }, // inout, no type
1426 { 3, 25, 50, 100, 100 }, // no inout, type
1427 { 4, 14, 35, 55, 100 }, // inout, type
1428 };
1429 int config=0;
1430 if (m_hide) return;
1431 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamList &)}\n");
1432
1434 const DocParamSect *sect = std::get_if<DocParamSect>(pl.parent());
1435 if (sect)
1436 {
1437 parentType = sect->type();
1438 }
1439 bool useTable = parentType==DocParamSect::Param ||
1440 parentType==DocParamSect::RetVal ||
1441 parentType==DocParamSect::Exception ||
1442 parentType==DocParamSect::TemplateParam;
1443 if (sect && sect->hasInOutSpecifier()) config+=1;
1444 if (sect && sect->hasTypeSpecifier()) config+=2;
1445 if (useTable)
1446 {
1447 m_t << "\\trowd \\trgaph108\\trleft426\\tblind426"
1448 "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1449 "\\trbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1450 "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1451 "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 "
1452 "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 "
1453 "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< "\n";
1454 for (int i=0;i<columnPos[config][0];i++)
1455 {
1456 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1457 "\\clbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1458 "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1459 "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 "
1460 "\\cltxlrtb "
1461 "\\cellx" << (rtf_pageWidth*columnPos[config][i+1]/100) << "\n";
1462 }
1463 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1464 }
1465
1466 if (sect && sect->hasInOutSpecifier())
1467 {
1468 if (useTable)
1469 {
1470 m_t << "{";
1471 }
1472
1473 // Put in the direction: in/out/in,out if specified.
1475 {
1476 if (pl.direction()==DocParamSect::In)
1477 {
1478 m_t << "in";
1479 }
1480 else if (pl.direction()==DocParamSect::Out)
1481 {
1482 m_t << "out";
1483 }
1484 else if (pl.direction()==DocParamSect::InOut)
1485 {
1486 m_t << "in,out";
1487 }
1488 }
1489
1490 if (useTable)
1491 {
1492 m_t << "\\cell }";
1493 }
1494 }
1495
1496 if (sect && sect->hasTypeSpecifier())
1497 {
1498 if (useTable)
1499 {
1500 m_t << "{";
1501 }
1502 for (const auto &type : pl.paramTypes())
1503 {
1504 std::visit(*this,type);
1505 }
1506 if (useTable)
1507 {
1508 m_t << "\\cell }";
1509 }
1510 }
1511
1512
1513 if (useTable)
1514 {
1515 m_t << "{";
1516 }
1517
1518 m_t << "{\\i ";
1519 bool first=TRUE;
1520 for (const auto &param : pl.parameters())
1521 {
1522 if (!first) m_t << ","; else first=FALSE;
1523 std::visit(*this,param);
1524 }
1525 m_t << "} ";
1526
1527 if (useTable)
1528 {
1529 m_t << "\\cell }{";
1530 }
1532
1533 for (const auto &par : pl.paragraphs())
1534 {
1535 std::visit(*this,par);
1536 }
1537
1538 if (useTable)
1539 {
1540 m_t << "\\cell }\n";
1541 //m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1542 m_t << "{\\row }\n";
1543 }
1544 else
1545 {
1546 m_t << "\\par\n";
1547 }
1548
1550}
1551
1553{
1554 if (m_hide) return;
1555 if (x.title().isEmpty()) return;
1556 bool anonymousEnum = x.file()=="@";
1557 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocXRefItem &)}\n");
1558 if (!m_lastIsPara)
1559 {
1560 m_t << "\\par\n";
1562 }
1563 m_t << "{"; // start param list
1564 //m_t << "{\\b "; // start bold
1565 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1566 if (Config_getBool(RTF_HYPERLINKS) && !anonymousEnum)
1567 {
1568 QCString refName;
1569 if (!x.file().isEmpty())
1570 {
1571 refName+=stripPath(x.file());
1572 }
1573 if (!x.file().isEmpty() && !x.anchor().isEmpty())
1574 {
1575 refName+="_";
1576 }
1577 if (!x.anchor().isEmpty())
1578 {
1579 refName+=x.anchor();
1580 }
1581
1582 m_t << "{\\field "
1583 "{\\*\\fldinst "
1584 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(refName) << "\" "
1585 "}{}"
1586 "}"
1587 "{\\fldrslt "
1588 "{\\cs37\\ul\\cf2 ";
1589 filter(x.title());
1590 m_t << "}"
1591 "}"
1592 "}";
1593 }
1594 else
1595 {
1596 filter(x.title());
1597 }
1598 m_t << ":";
1599 m_t << "\\par";
1600 m_t << "}"; // end bold
1602 m_t << rtf_Style_Reset << getStyle("DescContinue");
1604 visitChildren(x);
1605 if (x.title().isEmpty()) return;
1606 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocXRefItem)}\n");
1607 m_t << "\\par\n";
1609 m_t << "}\n"; // end xref item
1611}
1612
1614{
1615 if (m_hide) return;
1616 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocInternalRef &)}\n");
1617 startLink("",ref.file(),ref.anchor());
1618 visitChildren(ref);
1619 endLink("");
1620 m_t << " ";
1621}
1622
1624{
1625 if (m_hide) return;
1626 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocText &)}\n");
1627 visitChildren(t);
1628}
1629
1631{
1632 if (m_hide) return;
1633 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlBlockQuote &)}\n");
1634 if (!m_lastIsPara) m_t << "\\par\n";
1635 m_t << "{"; // start desc
1637 m_t << rtf_Style_Reset << getStyle("DescContinue");
1638 visitChildren(q);
1639 if (!m_lastIsPara) m_t << "\\par\n";
1641 m_t << "}"; // end desc
1643}
1644
1646{
1647}
1648
1650{
1651 if (m_hide) return;
1652 visitChildren(pb);
1653}
1654
1655
1656//static char* getMultiByte(int c)
1657//{
1658// static char s[10];
1659// sprintf(s,"\\'%X",c);
1660// return s;
1661//}
1662
1663void RTFDocVisitor::filter(const QCString &str,bool verbatim)
1664{
1665 if (!str.isEmpty())
1666 {
1667 const char *p=str.data();
1668 while (*p)
1669 {
1670 char c=*p++;
1671 switch (c)
1672 {
1673 case '{': m_t << "\\{"; break;
1674 case '}': m_t << "\\}"; break;
1675 case '\\': m_t << "\\\\"; break;
1676 case '\n': if (verbatim)
1677 {
1678 m_t << "\\par\n";
1679 }
1680 else
1681 {
1682 m_t << '\n';
1683 }
1684 break;
1685 default: m_t << c;
1686 }
1687 }
1688 }
1689}
1690
1691void RTFDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)
1692{
1693 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1694 {
1695 QCString refName;
1696 if (!file.isEmpty())
1697 {
1698 refName+=stripPath(file);
1699 }
1700 if (!file.isEmpty() && !anchor.isEmpty())
1701 {
1702 refName+='_';
1703 }
1704 if (!anchor.isEmpty())
1705 {
1706 refName+=anchor;
1707 }
1708
1709 m_t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \"";
1710 m_t << rtfFormatBmkStr(refName);
1711 m_t << "\" }{}";
1712 m_t << "}{\\fldrslt {\\cs37\\ul\\cf2 ";
1713 }
1714 else
1715 {
1716 m_t << "{\\b ";
1717 }
1719}
1720
1722{
1723 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1724 {
1725 m_t << "}}}";
1726 }
1727 else
1728 {
1729 m_t << "}";
1730 }
1732}
1733
1734void RTFDocVisitor::writeDotFile(const QCString &filename, bool hasCaption,
1735 const QCString &srcFile, int srcLine, bool newFile)
1736{
1737 QCString baseName=makeBaseName(filename,".dot");
1738 QCString outDir = Config_getString(RTF_OUTPUT);
1739 if (newFile) writeDotGraphFromFile(filename,outDir,baseName,GraphOutputFormat::BITMAP,srcFile,srcLine);
1740 QCString imgExt = getDotImageExtension();
1741 includePicturePreRTF(baseName + "." + imgExt, true, hasCaption);
1742}
1743
1744void RTFDocVisitor::writeMscFile(const QCString &fileName, bool hasCaption,
1745 const QCString &srcFile, int srcLine, bool newFile)
1746{
1747 QCString baseName=makeBaseName(fileName,".msc");
1748 QCString outDir = Config_getString(RTF_OUTPUT);
1749 if (newFile) writeMscGraphFromFile(fileName,outDir,baseName,MscOutputFormat::BITMAP,srcFile,srcLine);
1750 includePicturePreRTF(baseName + ".png", true, hasCaption);
1751}
1752
1753void RTFDocVisitor::writeDiaFile(const QCString &fileName, bool hasCaption,
1754 const QCString &srcFile, int srcLine, bool newFile)
1755{
1756 QCString baseName=makeBaseName(fileName,".dia");
1757 QCString outDir = Config_getString(RTF_OUTPUT);
1758 if (newFile) writeDiaGraphFromFile(fileName,outDir,baseName,DiaOutputFormat::BITMAP,srcFile,srcLine);
1759 includePicturePreRTF(baseName + ".png", true, hasCaption);
1760}
1761
1762void RTFDocVisitor::writePlantUMLFile(const QCString &fileName, bool hasCaption)
1763{
1764 QCString baseName=makeBaseName(fileName,".pu");
1765 QCString outDir = Config_getString(RTF_OUTPUT);
1767 includePicturePreRTF(baseName + ".png", true, hasCaption);
1768}
void parseCodeFragment(OutputCodeList &codeOutList, const QCString &fileName, const QCString &blockId, const QCString &scopeName, bool showLineNumbers, bool trimLeft, bool stripCodeComments)
static CodeFragmentManager & instance()
virtual void parseCode(OutputCodeList &codeOutList, const QCString &scopeName, const QCString &input, SrcLangExt lang, bool stripCodeComments, const CodeParserOptions &options)=0
Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
Node representing an anchor.
Definition docnode.h:229
QCString anchor() const
Definition docnode.h:232
QCString file() const
Definition docnode.h:233
Node representing an auto List.
Definition docnode.h:571
bool isCheckedList() const
Definition docnode.h:582
bool isEnumList() const
Definition docnode.h:580
Node representing an item of a auto list.
Definition docnode.h:595
int itemNumber() const
Definition docnode.h:598
Node representing a citation of some bibliographic reference.
Definition docnode.h:245
QCString getText() const
Definition docnode.cpp:972
CiteInfoOption option() const
Definition docnode.h:253
QCString target() const
Definition docnode.h:252
QCString anchor() const
Definition docnode.h:251
QCString ref() const
Definition docnode.h:250
QCString file() const
Definition docnode.h:248
Node representing a dia file.
Definition docnode.h:731
QCString srcFile() const
Definition docnode.h:691
QCString file() const
Definition docnode.h:685
int srcLine() const
Definition docnode.h:692
bool hasCaption() const
Definition docnode.h:687
Node representing a dot file.
Definition docnode.h:713
Node representing an emoji.
Definition docnode.h:341
int index() const
Definition docnode.h:345
QCString name() const
Definition docnode.h:344
Node representing an item of a cross-referenced list.
Definition docnode.h:529
QCString name() const
Definition docnode.h:532
bool isInline() const
Definition docnode.h:536
QCString relPath() const
Definition docnode.h:534
Node representing a Hypertext reference.
Definition docnode.h:823
QCString url() const
Definition docnode.h:830
QCString file() const
Definition docnode.h:831
Node representing a horizontal ruler.
Definition docnode.h:216
Node representing an HTML blockquote.
Definition docnode.h:1288
Node representing a HTML table caption.
Definition docnode.h:1225
QCString anchor() const
Definition docnode.h:1232
QCString file() const
Definition docnode.h:1231
Node representing a HTML table cell.
Definition docnode.h:1190
const HtmlAttribList & attribs() const
Definition docnode.h:1202
Node representing a HTML description data.
Definition docnode.h:1178
Node representing a Html description list.
Definition docnode.h:901
Node representing a Html description item.
Definition docnode.h:888
Node Html details.
Definition docnode.h:857
const DocNodeVariant * summary() const
Definition docnode.h:864
Node Html heading.
Definition docnode.h:873
int level() const
Definition docnode.h:877
Node representing a Html list.
Definition docnode.h:1000
const HtmlAttribList & attribs() const
Definition docnode.h:1006
Type type() const
Definition docnode.h:1005
Node representing a HTML list item.
Definition docnode.h:1162
const HtmlAttribList & attribs() const
Definition docnode.h:1167
Node representing a HTML table row.
Definition docnode.h:1243
bool isHeading() const
Definition docnode.cpp:1960
size_t numCells() const
Definition docnode.h:1248
Node Html summary.
Definition docnode.h:844
Node representing a HTML table.
Definition docnode.h:1266
const DocNodeVariant * caption() const
Definition docnode.cpp:2208
Node representing an image.
Definition docnode.h:642
QCString name() const
Definition docnode.h:648
Type type() const
Definition docnode.h:647
bool isInlineImage() const
Definition docnode.h:654
bool hasCaption() const
Definition docnode.h:649
Node representing a include/dontinclude operator block.
Definition docnode.h:477
bool stripCodeComments() const
Definition docnode.h:506
bool isLast() const
Definition docnode.h:503
QCString includeFileName() const
Definition docnode.h:509
QCString text() const
Definition docnode.h:499
QCString context() const
Definition docnode.h:501
QCString exampleFile() const
Definition docnode.h:508
int line() const
Definition docnode.h:497
Type type() const
Definition docnode.h:485
bool isFirst() const
Definition docnode.h:502
bool showLineNo() const
Definition docnode.h:498
bool isExample() const
Definition docnode.h:507
Node representing an included text block from file.
Definition docnode.h:435
QCString blockId() const
Definition docnode.h:454
QCString extension() const
Definition docnode.h:450
bool stripCodeComments() const
Definition docnode.h:455
@ LatexInclude
Definition docnode.h:437
@ SnippetWithLines
Definition docnode.h:438
@ DontIncWithLines
Definition docnode.h:439
@ IncWithLines
Definition docnode.h:438
@ HtmlInclude
Definition docnode.h:437
@ VerbInclude
Definition docnode.h:437
@ DontInclude
Definition docnode.h:437
@ DocbookInclude
Definition docnode.h:439
Type type() const
Definition docnode.h:451
QCString exampleFile() const
Definition docnode.h:457
QCString text() const
Definition docnode.h:452
QCString file() const
Definition docnode.h:449
bool trimLeft() const
Definition docnode.h:459
bool isExample() const
Definition docnode.h:456
QCString context() const
Definition docnode.h:453
Node representing an entry in the index.
Definition docnode.h:552
QCString entry() const
Definition docnode.h:559
Node representing an internal section of documentation.
Definition docnode.h:969
Node representing an internal reference to some item.
Definition docnode.h:807
QCString file() const
Definition docnode.h:811
QCString anchor() const
Definition docnode.h:813
Node representing a line break.
Definition docnode.h:202
Node representing a word that can be linked to something.
Definition docnode.h:165
QCString file() const
Definition docnode.h:171
QCString ref() const
Definition docnode.h:173
QCString word() const
Definition docnode.h:170
QCString anchor() const
Definition docnode.h:174
Node representing a msc file.
Definition docnode.h:722
DocNodeVariant * parent()
Definition docnode.h:90
Node representing an block of paragraphs.
Definition docnode.h:979
Node representing a paragraph in the documentation tree.
Definition docnode.h:1080
bool isLast() const
Definition docnode.h:1088
Node representing a parameter list.
Definition docnode.h:1122
const DocNodeList & parameters() const
Definition docnode.h:1126
const DocNodeList & paramTypes() const
Definition docnode.h:1127
DocParamSect::Direction direction() const
Definition docnode.h:1130
const DocNodeList & paragraphs() const
Definition docnode.h:1128
Node representing a parameter section.
Definition docnode.h:1053
bool hasInOutSpecifier() const
Definition docnode.h:1069
bool hasTypeSpecifier() const
Definition docnode.h:1070
Type type() const
Definition docnode.h:1068
Node representing a uml file.
Definition docnode.h:740
Node representing a reference to some item.
Definition docnode.h:778
QCString anchor() const
Definition docnode.h:785
QCString targetTitle() const
Definition docnode.h:786
bool isSubPage() const
Definition docnode.h:792
QCString file() const
Definition docnode.h:782
QCString ref() const
Definition docnode.h:784
bool hasLinkText() const
Definition docnode.h:788
Root node of documentation tree.
Definition docnode.h:1310
bool singleLine() const
Definition docnode.h:1316
bool indent() const
Definition docnode.h:1315
Node representing a reference to a section.
Definition docnode.h:935
Node representing a list of section references.
Definition docnode.h:959
Node representing a normal section.
Definition docnode.h:914
QCString file() const
Definition docnode.h:922
int level() const
Definition docnode.h:918
QCString anchor() const
Definition docnode.h:920
const DocNodeVariant * title() const
Definition docnode.h:919
Node representing a separator.
Definition docnode.h:365
QCString chars() const
Definition docnode.h:369
Node representing a simple list.
Definition docnode.h:990
Node representing a simple list item.
Definition docnode.h:1150
const DocNodeVariant * paragraph() const
Definition docnode.h:1154
Node representing a simple section.
Definition docnode.h:1017
Type type() const
Definition docnode.h:1026
const DocNodeVariant * title() const
Definition docnode.h:1033
Node representing a separator between two simple sections of the same type.
Definition docnode.h:1044
Node representing a style change.
Definition docnode.h:268
Style style() const
Definition docnode.h:307
bool enable() const
Definition docnode.h:309
Node representing a special symbol.
Definition docnode.h:328
HtmlEntityMapper::SymType symbol() const
Definition docnode.h:332
Root node of a text fragment.
Definition docnode.h:1301
Node representing a simple section title.
Definition docnode.h:608
Node representing a URL (or email address).
Definition docnode.h:188
QCString url() const
Definition docnode.h:192
bool isEmail() const
Definition docnode.h:193
Node representing a verbatim, unparsed text fragment.
Definition docnode.h:376
QCString srcFile() const
Definition docnode.h:397
int srcLine() const
Definition docnode.h:398
bool hasCaption() const
Definition docnode.h:390
QCString language() const
Definition docnode.h:388
bool isExample() const
Definition docnode.h:385
QCString context() const
Definition docnode.h:384
Type type() const
Definition docnode.h:382
QCString text() const
Definition docnode.h:383
QCString exampleFile() const
Definition docnode.h:386
QCString engine() const
Definition docnode.h:393
@ JavaDocLiteral
Definition docnode.h:378
Node representing a VHDL flow chart.
Definition docnode.h:749
CodeParserInterface & getCodeParser(const QCString &langExt)
void pushHidden(bool hide)
bool popHidden()
Node representing some amount of white space.
Definition docnode.h:354
QCString chars() const
Definition docnode.h:358
Node representing a word.
Definition docnode.h:153
QCString word() const
Definition docnode.h:156
Node representing an item of a cross-referenced list.
Definition docnode.h:621
QCString anchor() const
Definition docnode.h:625
QCString file() const
Definition docnode.h:624
QCString title() const
Definition docnode.h:626
const char * unicode(int index) const
Access routine to the unicode sequence for the Emoji entity.
Definition emoji.cpp:2016
static EmojiEntityMapper & instance()
Returns the one and only instance of the Emoji entity mapper.
Definition emoji.cpp:1978
Minimal replacement for QFileInfo.
Definition fileinfo.h:23
std::string fileName() const
Definition fileinfo.cpp:118
std::string dirPath(bool absPath=true) const
Definition fileinfo.cpp:137
static HtmlEntityMapper & instance()
Returns the one and only instance of the HTML entity mapper.
const char * rtf(SymType symb) const
Access routine to the RTF code of the HTML entity.
Class representing a list of different code generators.
Definition outputlist.h:165
StringVector writePlantUMLSource(const QCString &outDirArg, const QCString &fileName, const QCString &content, OutputFormat format, const QCString &engine, const QCString &srcFile, int srcLine, bool inlineCode)
Write a PlantUML compatible file.
Definition plantuml.cpp:31
static PlantumlManager & instance()
Definition plantuml.cpp:231
void generatePlantUMLOutput(const QCString &baseName, const QCString &outDir, OutputFormat format)
Convert a PlantUML file to an image.
Definition plantuml.cpp:202
This is an alternative implementation of QCString.
Definition qcstring.h:101
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
bool startsWith(const char *s) const
Definition qcstring.h:507
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
const std::string & str() const
Definition qcstring.h:552
QCString & setNum(short n)
Definition qcstring.h:459
QCString right(size_t len) const
Definition qcstring.h:234
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:172
void startLink(const QCString &ref, const QCString &file, const QCString &anchor)
void filter(const QCString &str, bool verbatim=FALSE)
int indentLevel() const
void visitChildren(const T &t)
void includePicturePreRTF(const QCString &name, bool isTypeRTF, bool hasCaption, bool inlineImage=FALSE)
QCString m_langExt
void writeDotFile(const QCString &fileName, bool hasCaption, const QCString &srcFile, int srcLine, bool newFile=true)
void includePicturePostRTF(bool isTypeRTF, bool hasCaption, bool inlineImage=FALSE)
OutputCodeList & m_ci
RTFDocVisitor(TextStream &t, OutputCodeList &ci, const QCString &langExt, int hierarchyLevel=0)
QCString getStyle(const QCString &name)
void writePlantUMLFile(const QCString &fileName, bool hasCaption)
static const int maxIndentLevels
TextStream & m_t
QCString getListTable(const int id)
void writeMscFile(const QCString &fileName, bool hasCaption, const QCString &srcFile, int srcLine, bool newFile=true)
void endLink(const QCString &ref)
RTFListItemInfo m_listItemInfo[maxIndentLevels]
void operator()(const DocWord &)
void writeDiaFile(const QCString &fileName, bool hasCaption, const QCString &srcFile, int srcLine, bool newFile=true)
static constexpr int MaxLevel
Definition section.h:39
static constexpr int MinLevel
Definition section.h:32
Text streaming class that buffers data.
Definition textstream.h:36
#define Config_getBool(name)
Definition config.h:33
#define Config_getString(name)
Definition config.h:32
void writeDiaGraphFromFile(const QCString &inFile, const QCString &outDir, const QCString &outFile, DiaOutputFormat format, const QCString &srcFile, int srcLine)
Definition dia.cpp:26
void writeDotGraphFromFile(const QCString &inFile, const QCString &outDir, const QCString &outFile, GraphOutputFormat format, const QCString &srcFile, int srcLine)
Definition dot.cpp:230
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
Definition filedef.cpp:268
Translator * theTranslator
Definition language.cpp:71
#define err(fmt,...)
Definition message.h:127
void writeMscGraphFromFile(const QCString &inFile, const QCString &outDir, const QCString &outFile, MscOutputFormat format, const QCString &srcFile, int srcLine)
Definition msc.cpp:157
Portable versions of functions that are platform dependent.
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
#define ASSERT(x)
Definition qcstring.h:39
static QCString align(const DocHtmlCell &cell)
#define DBG_RTF(x)
QCString rtfFormatBmkStr(const QCString &name)
Definition rtfgen.cpp:2873
StyleDataMap rtf_Style
Definition rtfstyle.cpp:362
char rtf_Style_Reset[]
Definition rtfstyle.cpp:49
Rtf_Table_Default rtf_Table_Default[]
Definition rtfstyle.cpp:245
const int rtf_pageWidth
Definition rtfstyle.h:26
Options to configure the code parser.
Definition parserintf.h:78
CodeParserOptions & setStartLine(int lineNr)
Definition parserintf.h:101
CodeParserOptions & setInlineFragment(bool enable)
Definition parserintf.h:107
CodeParserOptions & setShowLineNumbers(bool enable)
Definition parserintf.h:113
CodeParserOptions & setFileDef(const FileDef *fd)
Definition parserintf.h:98
QCString reference() const
Definition rtfstyle.h:69
SrcLangExt
Definition types.h:207
QCString writeFileContents(const QCString &baseName, const QCString &extension, const QCString &content, bool &exists)
Thread-safe function to write a string to a file.
Definition util.cpp:6961
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5193
QCString integerToRoman(int n, bool upper)
Definition util.cpp:6700
QCString stripPath(const QCString &s)
Definition util.cpp:4931
bool readInputFile(const QCString &fileName, std::string &contents, bool filter, bool isSourceCode)
read a file name fileName and optionally filter and transcode it
Definition util.cpp:5532
SrcLangExt getLanguageFromCodeLang(QCString &fileName)
Routine to handle the language attribute of the \code command.
Definition util.cpp:5211
QCString integerToAlpha(int n, bool upper)
Definition util.cpp:6684
QCString getDotImageExtension()
Definition util.cpp:6291
QCString makeBaseName(const QCString &name, const QCString &ext)
Definition util.cpp:4947
bool copyFile(const QCString &src, const QCString &dest)
Copies the contents of file with name src to the newly created file with name dest.
Definition util.cpp:5859
QCString getFileNameExtension(const QCString &fn)
Definition util.cpp:5235
A bunch of utility functions.