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 "mermaid.h"
37#include "fileinfo.h"
38#include "portable.h"
39#include "codefragment.h"
40#include "cite.h"
41#include "md5.h"
42
43//#define DBG_RTF(x) m_t << x
44#define DBG_RTF(x) do {} while(0)
45
46static QCString align(const DocHtmlCell &cell)
47{
48 for (const auto &attr : cell.attribs())
49 {
50 if (attr.name.lower()=="align")
51 {
52 if (attr.value.lower()=="center") return "\\qc ";
53 else if (attr.value.lower()=="right") return "\\qr ";
54 else return "";
55 }
56 }
57 return "";
58}
59
61 const QCString &langExt, int hierarchyLevel)
62 : m_t(t), m_ci(ci), m_langExt(langExt), m_hierarchyLevel(hierarchyLevel)
63{
64}
65
67{
68 QCString n = name + QCString().setNum(indentLevel());
69 StyleData &sd = rtf_Style[n.str()];
70 return sd.reference();
71}
72
74{
75 for (int i=0 ; rtf_Table_Default[i].definition ; i++ )
76 {
77 if ((id == rtf_Table_Default[i].id) && (m_indentLevel == rtf_Table_Default[i].lvl))
78 {
79 return rtf_Table_Default[i].place;
80 }
81 }
82 ASSERT(0);
83 return "";
84}
85
87{
88 return std::min(m_indentLevel,maxIndentLevels-1);
89}
90
92{
95 {
96 err("Maximum indent level ({}) exceeded while generating RTF output!\n",maxIndentLevels-1);
97 }
98}
99
104
105 //------------------------------------
106 // visitor functions for leaf nodes
107 //--------------------------------------
108
110{
111 if (m_hide) return;
112 DBG_RTF("{\\comment RTFDocVisitor::visit(DocWord)}\n");
113 filter(w.word());
115}
116
118{
119 if (m_hide) return;
120 DBG_RTF("{\\comment RTFDocVisitor::visit(DocLinkedWord)}\n");
121 startLink(w.ref(),w.file(),w.anchor());
122 filter(w.word());
123 endLink(w.ref());
125}
126
128{
129 if (m_hide) return;
130 DBG_RTF("{\\comment RTFDocVisitor::visit(DocWhiteSpace)}\n");
131 if (m_insidePre)
132 {
133 m_t << w.chars();
134 }
135 else
136 {
137 m_t << " ";
138 }
140}
141
143{
144 if (m_hide) return;
145 DBG_RTF("{\\comment RTFDocVisitor::visit(DocSymbol)}\n");
146 const char *res = HtmlEntityMapper::instance().rtf(s.symbol());
147 if (res)
148 {
149 m_t << res;
150 }
151 else
152 {
153 err("RTF: non supported HTML-entity found: {}\n",HtmlEntityMapper::instance().html(s.symbol(),TRUE));
154 }
156}
157
159{
160 if (m_hide) return;
161 DBG_RTF("{\\comment RTFDocVisitor::visit(DocEmoji)}\n");
162 const char *res = EmojiEntityMapper::instance().unicode(s.index());
163 if (res)
164 {
165 const char *p = res;
166 int val = 0;
167 int val1 = 0;
168 while (*p)
169 {
170 switch(*p)
171 {
172 case '&': case '#': case 'x':
173 break;
174 case ';':
175 val1 = val;
176 val = 0xd800 + ( ( val1 - 0x10000 ) & 0xffc00 ) / 0x400 - 0x10000;
177 m_t << "\\u" << val << "?";
178 val = 0xdC00 + ( ( val1 - 0x10000 ) & 0x3ff ) - 0x10000 ;
179 m_t << "\\u" << val << "?";
180 val = 0;
181 break;
182 case '0': case '1': case '2': case '3': case '4':
183 case '5': case '6': case '7': case '8': case '9':
184 val = val * 16 + *p - '0';
185 break;
186 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
187 val = val * 16 + *p - 'a' + 10;
188 break;
189 }
190 p++;
191 }
192 }
193 else
194 {
195 m_t << s.name();
196 }
198}
199
201{
202 if (m_hide) return;
203 DBG_RTF("{\\comment RTFDocVisitor::visit(DocURL)}\n");
204 if (Config_getBool(RTF_HYPERLINKS))
205 {
206 m_t << "{\\field "
207 "{\\*\\fldinst "
208 "{ HYPERLINK \"";
209 if (u.isEmail()) m_t << "mailto:";
210 m_t << u.url();
211 m_t << "\" }"
212 "{}";
213 m_t << "}"
214 "{\\fldrslt "
215 "{\\cs37\\ul\\cf2 ";
216 filter(u.url());
217 m_t << "}"
218 "}"
219 "}\n";
220 }
221 else
222 {
223 m_t << "{\\f2 ";
224 filter(u.url());
225 m_t << "}";
226 }
228}
229
231{
232 if (m_hide) return;
233 DBG_RTF("{\\comment RTFDocVisitor::visit(DocLineBreak)}\n");
234 m_t << "\\par\n";
236}
237
239{
240 if (m_hide) return;
241 DBG_RTF("{\\comment RTFDocVisitor::visit(DocHorRuler)}\n");
242 m_t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}\n";
244}
245
247{
248 if (m_hide) return;
250 DBG_RTF("{\\comment RTFDocVisitor::visit(DocStyleChange)}\n");
251 switch (s.style())
252 {
254 if (s.enable()) m_t << "{\\b "; else m_t << "} ";
255 break;
259 if (s.enable()) m_t << "{\\strike "; else m_t << "} ";
260 break;
263 if (s.enable()) m_t << "{\\ul "; else m_t << "} ";
264 break;
266 if (s.enable()) m_t << "{\\i "; else m_t << "} ";
267 break;
271 if (s.enable()) m_t << "{\\f2 "; else m_t << "} ";
272 break;
274 if (s.enable()) m_t << "{\\sub "; else m_t << "} ";
275 break;
277 if (s.enable()) m_t << "{\\super "; else m_t << "} ";
278 break;
280 if (s.enable()) m_t << "{\\qc "; else m_t << "} ";
281 break;
283 if (s.enable()) m_t << "{\\sub "; else m_t << "} ";
284 break;
286 if (s.enable()) m_t << "{\\i "; else m_t << "} ";
287 break;
289 if (s.enable())
290 {
291 m_t << "{\n";
292 m_t << "\\par\n";
293 m_t << rtf_Style_Reset << getStyle("CodeExample");
295 }
296 else
297 {
299 m_t << "\\par";
300 m_t << "}\n";
301 }
303 break;
304 case DocStyleChange::Div: /* HTML only */ break;
305 case DocStyleChange::Span: /* HTML only */ break;
306 }
307}
308
310{
311 if (m_hide) return;
312 DBG_RTF("{\\comment RTFDocVisitor::visit(DocVerbatim)}\n");
313 QCString lang = m_langExt;
314 if (!s.language().isEmpty()) // explicit language setting
315 {
316 lang = s.language();
317 }
318 SrcLangExt langExt = getLanguageFromCodeLang(lang);
319 switch(s.type())
320 {
322 m_t << "{\n";
323 m_t << "\\par\n";
324 m_t << rtf_Style_Reset << getStyle("CodeExample");
325 getCodeParser(lang).parseCode(m_ci,s.context(),s.text(),langExt,
326 Config_getBool(STRIP_CODE_COMMENTS),
327 CodeParserOptions().setExample(s.isExample(),s.exampleFile()));
328 //m_t << "\\par\n";
329 m_t << "}\n";
330 break;
332 filter(s.text(),TRUE);
333 break;
335 m_t << "{\n";
336 m_t << "{\\f2 ";
337 filter(s.text(),TRUE);
338 m_t << "}";
339 m_t << "}\n";
340 break;
342 m_t << "{\n";
343 m_t << "\\par\n";
344 m_t << rtf_Style_Reset << getStyle("CodeExample");
345 filter(s.text(),TRUE);
346 //m_t << "\\par\n";
347 m_t << "}\n";
348 break;
350 m_t << s.text();
351 break;
357 /* nothing */
358 break;
359 case DocVerbatim::Dot:
360 {
361 bool exists = false;
362 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/inline_dotgraph_", // baseName
363 ".dot", // extension
364 s.text(), // contents
365 exists);
366 if (!fileName.isEmpty())
367 {
368 writeDotFile(fileName, s.hasCaption(), s.srcFile(), s.srcLine(), !exists);
369 visitChildren(s);
371 }
372 }
373 break;
374 case DocVerbatim::Msc:
375 {
376 bool exists = false;
377 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/inline_mscgraph_", // baseName
378 ".msc", // extension
379 "msc {"+s.text()+"}", // contents
380 exists);
381 if (!fileName.isEmpty())
382 {
383 writeMscFile(fileName, s.hasCaption(), s.srcFile(), s.srcLine(), !exists);
384 visitChildren(s);
386 }
387 }
388 break;
390 {
391 QCString rtfOutput = Config_getString(RTF_OUTPUT);
392 auto baseNameVector = PlantumlManager::instance().writePlantUMLSource(
394 s.engine(),s.srcFile(),s.srcLine(),true);
395
396 for (const auto &baseName: baseNameVector)
397 {
398 writePlantUMLFile(baseName, s.hasCaption());
399 visitChildren(s);
401 }
402 }
403 break;
405 if (Config_getBool(MERMAID_RENDER_MODE)!=MERMAID_RENDER_MODE_t::CLIENT_SIDE)
406 {
407 QCString rtfOutput = Config_getString(RTF_OUTPUT);
410 s.srcFile(),s.srcLine());
411 writeMermaidFile(baseName, s.hasCaption());
412 visitChildren(s);
414 }
415 break;
416 }
418}
419
421{
422 if (m_hide) return;
423 DBG_RTF("{\\comment RTFDocVisitor::visit(DocAnchor)}\n");
424 QCString anchor;
425 if (!anc.file().isEmpty())
426 {
427 anchor+=stripPath(anc.file());
428 }
429 if (!anc.file().isEmpty() && !anc.anchor().isEmpty())
430 {
431 anchor+="_";
432 }
433 if (!anc.anchor().isEmpty())
434 {
435 anchor+=anc.anchor();
436 }
437 m_t << "{\\bkmkstart " << rtfFormatBmkStr(anchor) << "}\n";
438 m_t << "{\\bkmkend " << rtfFormatBmkStr(anchor) << "}\n";
440}
441
443{
444 if (m_hide) return;
446 DBG_RTF("{\\comment RTFDocVisitor::visit(DocInclude)}\n");
447 switch(inc.type())
448 {
450 {
451 m_t << "{\n";
452 m_t << "\\par\n";
453 m_t << rtf_Style_Reset << getStyle("CodeExample");
454 FileInfo cfi( inc.file().str() );
455 auto fd = createFileDef( cfi.dirPath(), cfi.fileName() );
457 inc.text(),
458 langExt,
459 inc.stripCodeComments(),
461 .setExample(inc.isExample(),inc.exampleFile())
462 .setFileDef(fd.get())
463 .setInlineFragment(true)
464 );
465 m_t << "\\par";
466 m_t << "}\n";
467 }
468 break;
470 m_t << "{\n";
471 m_t << "\\par\n";
472 m_t << rtf_Style_Reset << getStyle("CodeExample");
474 inc.text(),langExt,
475 inc.stripCodeComments(),
477 .setExample(inc.isExample(),inc.exampleFile())
478 .setInlineFragment(true)
479 .setShowLineNumbers(false)
480 );
481 m_t << "\\par";
482 m_t << "}\n";
483 break;
491 break;
493 m_t << inc.text();
494 break;
496 m_t << "{\n";
497 m_t << "\\par\n";
498 m_t << rtf_Style_Reset << getStyle("CodeExample");
499 filter(inc.text());
500 m_t << "\\par";
501 m_t << "}\n";
502 break;
505 m_t << "{\n";
506 if (!m_lastIsPara) m_t << "\\par\n";
507 m_t << rtf_Style_Reset << getStyle("CodeExample");
509 inc.file(),
510 inc.blockId(),
511 inc.context(),
513 inc.trimLeft(),
515 );
516 m_t << "}";
517 break;
518 }
520}
521
523{
524 //printf("DocIncOperator: type=%d first=%d, last=%d text='%s'\n",
525 // op.type(),op.isFirst(),op.isLast(),qPrint(op.text()));
526 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIncOperator)}\n");
528 if (locLangExt.isEmpty()) locLangExt = m_langExt;
529 SrcLangExt langExt = getLanguageFromFileName(locLangExt);
530 if (op.isFirst())
531 {
532 if (!m_hide)
533 {
534 m_t << "{\n";
535 m_t << "\\par\n";
536 m_t << rtf_Style_Reset << getStyle("CodeExample");
537 }
539 m_hide = TRUE;
540 }
541 if (op.type()!=DocIncOperator::Skip)
542 {
543 m_hide = popHidden();
544 if (!m_hide)
545 {
546 std::unique_ptr<FileDef> fd = nullptr;
547 if (!op.includeFileName().isEmpty())
548 {
549 FileInfo cfi( op.includeFileName().str() );
550 fd = createFileDef( cfi.dirPath(), cfi.fileName() );
551 }
552
553 getCodeParser(locLangExt).parseCode(m_ci,op.context(),op.text(),langExt,
556 .setExample(op.isExample(),op.exampleFile())
557 .setFileDef(fd.get())
558 .setStartLine(op.line())
560 );
561 }
563 m_hide=TRUE;
564 }
565 if (op.isLast())
566 {
567 m_hide = popHidden();
568 if (!m_hide)
569 {
570 m_t << "\\par";
571 m_t << "}\n";
572 }
574 }
575 else
576 {
577 if (!m_hide) m_t << "\n";
579 }
580}
581
583{
584 if (m_hide) return;
585 DBG_RTF("{\\comment RTFDocVisitor::visit(DocFormula)}\n");
586 bool bDisplay = !f.isInline();
587 if (bDisplay)
588 {
589 m_t << "\\par";
590 m_t << "{";
591 m_t << "\\pard\\plain";
592 m_t << "\\pard";
593 m_t << "\\qc";
594 }
595 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"" << f.relPath() << f.name() << ".png\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}";
596 if (bDisplay)
597 {
598 m_t << "\\par}";
599 }
601}
602
604{
605 if (m_hide) return;
606 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIndexEntry)}\n");
607 m_t << "{\\xe \\v " << i.entry() << "}\n";
609}
610
614
616{
617 if (m_hide) return;
618 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocCite &)}\n");
619 auto opt = cite.option();
620 if (!cite.file().isEmpty())
621 {
622 if (!opt.noCite()) startLink(cite.ref(),cite.file(),cite.anchor());
623
624 filter(cite.getText());
625
626 if (!opt.noCite()) endLink(cite.ref());
627 }
628 else
629 {
630 m_t << "{\\b";
631 if (!opt.noPar()) filter("[");
632 filter(cite.target());
633 if (!opt.noPar()) filter("]");
634 m_t << "}";
635 }
636}
637
638
639//--------------------------------------
640// visitor functions for compound nodes
641//--------------------------------------
642
644{
645 if (m_hide) return;
646 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoList &)}\n");
647 m_t << "{\n";
648 int level = indentLevel();
649 m_listItemInfo[level].isEnum = l.isEnumList();
650 m_listItemInfo[level].isCheck = l.isCheckedList();
651 m_listItemInfo[level].type = '1';
652 m_listItemInfo[level].number = 1;
654 visitChildren(l);
655 if (!m_lastIsPara) m_t << "\\par";
656 m_t << "}\n";
658 if (!l.isCheckedList() && indentLevel()==0) m_t << "\\par\n";
659}
660
662{
663 static int prevLevel = -1;
664 if (m_hide) return;
665 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoListItem &)}\n");
666 int level = indentLevel();
667 if ((level != prevLevel-1) &&
668 (!(level==prevLevel && level != 0 && m_listItemInfo[level].isCheck)) &&
669 (!m_lastIsPara))
670 m_t << "\\par\n";
671 prevLevel= level;
673 if (m_listItemInfo[level].isEnum)
674 {
675 m_t << getStyle("ListEnum") << "\n";
676 m_t << m_listItemInfo[level].number << ".\\tab ";
677 m_listItemInfo[level].number++;
678 }
679 else
680 {
681 switch (li.itemNumber())
682 {
683 case DocAutoList::Unchecked: // unchecked
684 m_t << getListTable(2) << "\n";
685 break;
686 case DocAutoList::Checked_x: // checked with x
687 case DocAutoList::Checked_X: // checked with X
688 m_t << getListTable(3) << "\n";
689 break;
690 default:
691 m_t << getListTable(1) << "\n";
692 break;
693 }
694 }
696 m_lastIsPara=false;
697 visitChildren(li);
699}
700
702{
703 if (m_hide) return;
704 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPara &)}\n");
705 visitChildren(p);
706 if (!m_lastIsPara &&
707 !p.isLast() && // omit <p> for last paragraph
708 !(p.parent() && // and for parameters & sections
709 std::get_if<DocParamSect>(p.parent())
710 )
711 )
712 {
713 m_t << "\\par\n";
715 }
716}
717
719{
720 if (m_hide) return;
721 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRoot &)}\n");
722 if (r.indent()) incIndentLevel();
723 m_t << "{" << rtf_Style["BodyText"].reference() << "\n";
724 visitChildren(r);
725 if (!m_lastIsPara && !r.singleLine()) m_t << "\\par\n";
726 m_t << "}";
728 if (r.indent()) decIndentLevel();
729}
730
732{
733 if (m_hide) return;
734 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
735 if (!m_lastIsPara) m_t << "\\par\n";
736 m_t << "{"; // start desc
737 //m_t << "{\\b "; // start bold
738 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
739 switch(s.type())
740 {
742 m_t << theTranslator->trSeeAlso(); break;
744 m_t << theTranslator->trReturns(); break;
746 m_t << theTranslator->trAuthor(TRUE,TRUE); break;
748 m_t << theTranslator->trAuthor(TRUE,FALSE); break;
750 m_t << theTranslator->trVersion(); break;
752 m_t << theTranslator->trSince(); break;
754 m_t << theTranslator->trDate(); break;
756 m_t << theTranslator->trNote(); break;
758 m_t << theTranslator->trWarning(); break;
760 m_t << theTranslator->trPrecondition(); break;
762 m_t << theTranslator->trPostcondition(); break;
764 m_t << theTranslator->trCopyright(); break;
766 m_t << theTranslator->trInvariant(); break;
768 m_t << theTranslator->trRemarks(); break;
770 m_t << theTranslator->trAttention(); break;
772 m_t << theTranslator->trImportant(); break;
773 case DocSimpleSect::User: break;
774 case DocSimpleSect::Rcs: break;
775 case DocSimpleSect::Unknown: break;
776 }
777
780 {
781 m_t << "\\par";
782 m_t << "}"; // end bold
783 m_t << rtf_Style_Reset << getStyle("DescContinue");
784 m_t << "{\\s17 \\sa60 \\sb30\n";
785 }
786 else
787 {
788 if (s.title())
789 {
790 std::visit(*this,*s.title());
791 }
792 m_t << "\\par\n";
793 m_t << "}"; // end bold
794 m_t << rtf_Style_Reset << getStyle("DescContinue");
795 }
797 visitChildren(s);
798 if (!m_lastIsPara) m_t << "\\par\n";
801 {
802 m_t << "}"; // end DescContinue
803 }
804 m_t << "}"; // end desc
806}
807
809{
810 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocTitle &)}\n");
811 if (m_hide) return;
812 visitChildren(t);
813}
814
816{
817 if (m_hide) return;
818 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
819 m_t << "{\n";
820 m_listItemInfo[indentLevel()].isEnum = false;
821 m_listItemInfo[indentLevel()].isCheck = false;
823 visitChildren(l);
824 if (!m_lastIsPara) m_t << "\\par\n";
825 m_t << "}\n";
827}
828
830{
831 if (m_hide) return;
832 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleListItem &)}\n");
833 m_t << "\\par" << rtf_Style_Reset << getStyle("ListBullet") << "\n";
836 if (li.paragraph())
837 {
838 std::visit(*this,*li.paragraph());
839 }
841 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSimpleListItem)}\n");
842}
843
845{
846 if (m_hide) return;
847 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSection &)}\n");
848 if (!m_lastIsPara) m_t << "\\par\n";
849 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
850 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
851 m_t << "{{" // start section
853 QCString heading;
854 int level = std::min(s.level()+2+m_hierarchyLevel,4);
855 if (level <= 0)
856 level = 1;
857 heading.sprintf("Heading%d",level);
858 // set style
859 m_t << rtf_Style[heading.str()].reference() << "\n";
860 // make table of contents entry
861 if (s.title())
862 {
863 std::visit(*this,*s.title());
864 }
865 m_t << "\n\\par" << "}\n";
866 m_t << "{\\tc\\tcl" << level << " \\v ";
867 if (s.title())
868 {
869 std::visit(*this,*s.title());
870 }
871 m_t << "}\n";
873 visitChildren(s);
874 m_t << "\\par}\n"; // end section
876}
877
879{
880 if (m_hide) return;
881 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlList &)}\n");
882 m_t << "{\n";
883 int level = indentLevel();
884 m_listItemInfo[level].isEnum = l.type()==DocHtmlList::Ordered;
885 m_listItemInfo[level].isCheck = false;
886 m_listItemInfo[level].number = 1;
887 m_listItemInfo[level].type = '1';
888 for (const auto &opt : l.attribs())
889 {
890 if (opt.name=="type")
891 {
892 m_listItemInfo[level].type = opt.value[0];
893 }
894 if (opt.name=="start")
895 {
896 bool ok = false;
897 int val = opt.value.toInt(&ok);
898 if (ok) m_listItemInfo[level].number = val;
899 }
900 }
902 visitChildren(l);
903 m_t << "\\par" << "}\n";
905}
906
908{
909 if (m_hide) return;
910 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlListItem &)}\n");
911 m_t << "\\par\n";
913 int level = indentLevel();
914 if (m_listItemInfo[level].isEnum)
915 {
916 for (const auto &opt : l.attribs())
917 {
918 if (opt.name=="value")
919 {
920 bool ok = false;
921 int val = opt.value.toInt(&ok);
922 if (ok) m_listItemInfo[level].number = val;
923 }
924 }
925 m_t << getStyle("ListEnum") << "\n";
926 switch (m_listItemInfo[level].type)
927 {
928 case '1':
929 m_t << m_listItemInfo[level].number;
930 break;
931 case 'a':
932 m_t << integerToAlpha(m_listItemInfo[level].number,false);
933 break;
934 case 'A':
935 m_t << integerToAlpha(m_listItemInfo[level].number);
936 break;
937 case 'i':
938 m_t << integerToRoman(m_listItemInfo[level].number,false);
939 break;
940 case 'I':
941 m_t << integerToRoman(m_listItemInfo[level].number);
942 break;
943 default:
944 m_t << m_listItemInfo[level].number;
945 break;
946 }
947 m_t << ".\\tab ";
948 m_listItemInfo[level].number++;
949 }
950 else
951 {
952 m_t << getStyle("ListBullet") << "\n";
953 }
956 visitChildren(l);
958 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlListItem)}\n");
959}
960
962{
963 if (m_hide) return;
964 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescList &)}\n");
965 //m_t << "{\n";
966 //m_t << rtf_Style_Reset << getStyle("ListContinue");
967 //m_lastIsPara=FALSE;
968 visitChildren(dl);
969 //m_t << "}\n";
970 //m_t << "\\par\n";
971 //m_lastIsPara=TRUE;
972}
973
975{
976 if (m_hide) return;
977 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescTitle &)}\n");
978 //m_t << "\\par\n";
979 //m_t << "{\\b ";
980 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
982 visitChildren(dt);
983 m_t << "\\par\n";
984 m_t << "}\n";
986}
987
989{
990 if (m_hide) return;
991 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescData &)}\n");
993 m_t << "{" << rtf_Style_Reset << getStyle("DescContinue");
994 visitChildren(dd);
995 m_t << "\\par";
996 m_t << "}\n";
999}
1000
1002{
1003 if (m_hide) return;
1004 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlTable &)}\n");
1005 if (!m_lastIsPara) m_t << "\\par\n";
1007 if (t.caption())
1008 {
1009 const DocHtmlCaption &c = std::get<DocHtmlCaption>(*t.caption());
1010 m_t << "\\pard \\qc \\b";
1011 if (!c.file().isEmpty())
1012 {
1013 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1014 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1015 }
1016 m_t << "{Table \\field\\flddirty{\\*\\fldinst { SEQ Table \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1017 std::visit(*this,*t.caption());
1018 }
1019 visitChildren(t);
1020 m_t << "\\pard\\plain\n";
1021 m_t << "\\par\n";
1023}
1024
1026{
1027 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCaption &)}\n");
1028 visitChildren(c);
1029 m_t << "}\n\\par\n";
1030}
1031
1033{
1034 if (m_hide) return;
1035 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlRow &)}\n");
1036 size_t columnWidth=r.numCells()>0 ? rtf_pageWidth/r.numCells() : 10;
1037 m_t << "\\trowd \\trgaph108\\trleft-108"
1038 "\\trbrdrt\\brdrs\\brdrw10 "
1039 "\\trbrdrl\\brdrs\\brdrw10 "
1040 "\\trbrdrb\\brdrs\\brdrw10 "
1041 "\\trbrdrr\\brdrs\\brdrw10 "
1042 "\\trbrdrh\\brdrs\\brdrw10 "
1043 "\\trbrdrv\\brdrs\\brdrw10 \n";
1044 for (size_t i=0;i<r.numCells();i++)
1045 {
1046 if (r.isHeading())
1047 {
1048 m_t << "\\clcbpat16"; // set cell shading to light grey (color 16 in the clut)
1049 }
1050 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10 "
1051 "\\clbrdrl\\brdrs\\brdrw10 "
1052 "\\clbrdrb\\brdrs\\brdrw10 "
1053 "\\clbrdrr \\brdrs\\brdrw10 "
1054 "\\cltxlrtb "
1055 "\\cellx" << ((i+1)*columnWidth) << "\n";
1056 }
1057 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1059 visitChildren(r);
1060 m_t << "\n";
1061 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1062 m_t << "{\\row }\n";
1064}
1065
1067{
1068 if (m_hide) return;
1069 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCell &)}\n");
1070 m_t << "{" << align(c);
1072 visitChildren(c);
1073 m_t << "\\cell }";
1075}
1076
1078{
1079 if (m_hide) return;
1080 visitChildren(i);
1081}
1082
1084{
1085 if (m_hide) return;
1086 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHRef &)}\n");
1087 if (Config_getBool(RTF_HYPERLINKS))
1088 {
1089 if (href.url().startsWith("#"))
1090 {
1091 // when starting with # so a local link
1092 QCString cite;
1093 cite = href.file() + "_" + href.url().right(href.url().length()-1);
1094 m_t << "{\\field "
1095 "{\\*\\fldinst "
1096 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(cite) << "\" "
1097 "}{}"
1098 "}"
1099 "{\\fldrslt "
1100 "{\\cs37\\ul\\cf2 ";
1101 }
1102 else
1103 {
1104 m_t << "{\\field "
1105 "{\\*\\fldinst "
1106 "{ HYPERLINK \"" << href.url() << "\" "
1107 "}{}"
1108 "}"
1109 "{\\fldrslt "
1110 "{\\cs37\\ul\\cf2 ";
1111 }
1112 }
1113 else
1114 {
1115 m_t << "{\\f2 ";
1116 }
1118 visitChildren(href);
1119 if (Config_getBool(RTF_HYPERLINKS))
1120 {
1121 m_t << "}"
1122 "}"
1123 "}";
1124 }
1125 else
1126 {
1127 m_t << "}";
1128 }
1130}
1131
1133{
1134 if (m_hide) return;
1135 m_t << "{\\b ";
1136 visitChildren(s);
1137 m_t << "}\\par ";
1138}
1139
1141{
1142 if (m_hide) return;
1143 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDetails &)}\n");
1144 if (!m_lastIsPara) m_t << "\\par\n";
1145 auto summary = d.summary();
1146 if (summary)
1147 {
1148 std::visit(*this,*summary);
1149 m_t << "{"; // start desc
1151 m_t << rtf_Style_Reset << getStyle("DescContinue");
1152 }
1153 visitChildren(d);
1154 if (!m_lastIsPara) m_t << "\\par\n";
1155 if (summary)
1156 {
1158 m_t << "}"; // end desc
1159 }
1161}
1162
1164{
1165 if (m_hide) return;
1166 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlHeader &)}\n");
1167 m_t << "{" // start section
1168 << rtf_Style_Reset;
1169 QCString heading;
1170 int level = std::clamp(header.level()+m_hierarchyLevel,SectionType::MinLevel,SectionType::MaxLevel);
1171 heading.sprintf("Heading%d",level);
1172 // set style
1173 m_t << rtf_Style[heading.str()].reference();
1174 // make open table of contents entry that will be closed in visitPost method
1175 m_t << "{\\tc\\tcl" << level << " ";
1177 visitChildren(header);
1178 // close open table of contents entry
1179 m_t << "} \\par";
1180 m_t << "}\n"; // end section
1182}
1183
1184void RTFDocVisitor::includePicturePreRTF(const QCString &name, bool isTypeRTF, bool hasCaption, bool inlineImage)
1185{
1186 if (isTypeRTF)
1187 {
1188 if (!inlineImage)
1189 {
1190 m_t << "\\par\n";
1191 m_t << "{\n";
1192 m_t << rtf_Style_Reset << "\n";
1193 if (hasCaption || m_lastIsPara) m_t << "\\par\n";
1194 m_t << "\\pard \\qc ";
1195 }
1196 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"";
1197 m_t << name;
1198 m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}\n";
1199 if (!inlineImage)
1200 {
1201 m_t << "\\par\n";
1202 if (hasCaption)
1203 {
1204 m_t << "\\pard \\qc \\b";
1205 m_t << "{Image \\field\\flddirty{\\*\\fldinst { SEQ Image \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1206 }
1208 }
1209 else
1210 {
1211 if (hasCaption) m_t << "{\\comment "; // to prevent caption to be shown
1212 }
1213 }
1214 else // other format -> skip
1215 {
1217 m_hide=TRUE;
1218 }
1219}
1220
1221void RTFDocVisitor::includePicturePostRTF(bool isTypeRTF, bool hasCaption, bool inlineImage)
1222{
1223 if (isTypeRTF)
1224 {
1225 if (m_hide) return;
1226 if (inlineImage)
1227 {
1228 if (hasCaption) m_t << " }";
1229 }
1230 else
1231 {
1232 if (hasCaption)
1233 {
1234 m_t << "}\n";
1235 m_t << "\\par}\n";
1236 }
1237 else
1238 {
1239 m_t << "}\n";
1240 }
1241 }
1242 }
1243 else
1244 {
1245 m_hide = popHidden();
1246 }
1247}
1248
1250{
1251 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocImage &)}\n");
1253 visitChildren(img);
1255}
1256
1257
1259{
1260 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDotFile &)}\n");
1261 bool exists = false;
1262 std::string inBuf;
1263 if (readInputFile(df.file(),inBuf))
1264 {
1265 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1266 ".dot", // extension
1267 inBuf, // contents
1268 exists);
1269 if (!fileName.isEmpty())
1270 {
1271 writeDotFile(fileName, df.hasCaption(), df.srcFile(), df.srcLine(), !exists);
1272 visitChildren(df);
1274 }
1275 }
1276}
1278{
1279 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocMscFile &)}\n");
1280 bool exists = false;
1281 std::string inBuf;
1282 if (readInputFile(df.file(),inBuf))
1283 {
1284 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1285 ".msc", // extension
1286 inBuf, // contents
1287 exists);
1288 if (!fileName.isEmpty())
1289 {
1290 writeMscFile(fileName, df.hasCaption(), df.srcFile(), df.srcLine(), !exists);
1291 visitChildren(df);
1293 }
1294 }
1295}
1296
1298{
1299 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDiaFile &)}\n");
1300 bool exists = false;
1301 std::string inBuf;
1302 if (readInputFile(df.file(),inBuf))
1303 {
1304 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1305 ".dia", // extension
1306 inBuf, // contents
1307 exists);
1308 if (!fileName.isEmpty())
1309 {
1310 writeDiaFile(fileName, df.hasCaption(), df.srcFile(), df.srcLine(), !exists);
1311 visitChildren(df);
1313 }
1314 }
1315}
1316
1318{
1319 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPlantUmlFile &)}\n");
1320 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1321 QCString rtfOutput = Config_getString(RTF_OUTPUT);
1322 std::string inBuf;
1323 readInputFile(df.file(),inBuf);
1324 auto baseNameVector = PlantumlManager::instance().writePlantUMLSource(
1325 rtfOutput,QCString(),inBuf,PlantumlManager::PUML_BITMAP,
1326 QCString(),df.srcFile(),df.srcLine(),false);
1327 for(const auto &baseName: baseNameVector)
1328 {
1329 writePlantUMLFile(baseName, df.hasCaption());
1330 visitChildren(df);
1332 }
1333}
1334
1336{
1337 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocMermaidFile &)}\n");
1338 if (Config_getBool(MERMAID_RENDER_MODE)==MERMAID_RENDER_MODE_t::CLIENT_SIDE) return;
1339 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1340 QCString rtfOutput = Config_getString(RTF_OUTPUT);
1341 std::string inBuf;
1342 readInputFile(df.file(),inBuf);
1345 df.srcFile(),df.srcLine());
1346 writeMermaidFile(baseName, df.hasCaption());
1347 visitChildren(df);
1349}
1350
1352{
1353 if (m_hide) return;
1354 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocLink &)}\n");
1355 startLink(lnk.ref(),lnk.file(),lnk.anchor());
1356 visitChildren(lnk);
1357 endLink(lnk.ref());
1358}
1359
1361{
1362 if (m_hide) return;
1363 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRef &)}\n");
1364 // when ref.isSubPage()==TRUE we use ref.file() for HTML and
1365 // ref.anchor() for LaTeX/RTF
1366 if (ref.isSubPage())
1367 {
1368 startLink(ref.ref(),QCString(),ref.anchor());
1369 }
1370 else
1371 {
1372 if (!ref.file().isEmpty()) startLink(ref.ref(),ref.file(),ref.anchor());
1373 }
1374 if (!ref.hasLinkText()) filter(ref.targetTitle());
1375 visitChildren(ref);
1376 if (!ref.file().isEmpty()) endLink(ref.ref());
1377 //m_t << " ";
1378}
1379
1380
1382{
1383 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefItem &)}\n");
1384 visitChildren(ref);
1385}
1386
1388{
1389 if (m_hide) return;
1390 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefList &)}\n");
1391 m_t << "{\n";
1393 m_t << rtf_Style_Reset << getStyle("LatexTOC") << "\n";
1394 m_t << "\\par\n";
1396 visitChildren(l);
1398 m_t << "\\par";
1399 m_t << "}\n";
1401}
1402
1404{
1405 if (m_hide) return;
1406 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamSect &)}\n");
1407 m_t << "{"; // start param list
1408 if (!m_lastIsPara) m_t << "\\par\n";
1409 //m_t << "{\\b "; // start bold
1410 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1411 switch(s.type())
1412 {
1414 m_t << theTranslator->trParameters(); break;
1416 m_t << theTranslator->trReturnValues(); break;
1418 m_t << theTranslator->trExceptions(); break;
1420 m_t << theTranslator->trTemplateParameters(); break;
1421 default:
1422 ASSERT(0);
1423 }
1424 m_t << "\\par";
1425 m_t << "}\n";
1426 bool useTable = s.type()==DocParamSect::Param ||
1430 if (!useTable)
1431 {
1433 }
1434 m_t << rtf_Style_Reset << getStyle("DescContinue");
1436 visitChildren(s);
1437 //m_t << "\\par\n";
1438 if (!useTable)
1439 {
1441 }
1442 m_t << "}\n";
1443}
1444
1446{
1447 m_t << " " << sep.chars() << " ";
1448}
1449
1451{
1452 static int columnPos[4][5] =
1453 { { 2, 25, 100, 100, 100 }, // no inout, no type
1454 { 3, 14, 35, 100, 100 }, // inout, no type
1455 { 3, 25, 50, 100, 100 }, // no inout, type
1456 { 4, 14, 35, 55, 100 }, // inout, type
1457 };
1458 int config=0;
1459 if (m_hide) return;
1460 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamList &)}\n");
1461
1463 const DocParamSect *sect = std::get_if<DocParamSect>(pl.parent());
1464 if (sect)
1465 {
1466 parentType = sect->type();
1467 }
1468 bool useTable = parentType==DocParamSect::Param ||
1469 parentType==DocParamSect::RetVal ||
1470 parentType==DocParamSect::Exception ||
1471 parentType==DocParamSect::TemplateParam;
1472 if (sect && sect->hasInOutSpecifier()) config+=1;
1473 if (sect && sect->hasTypeSpecifier()) config+=2;
1474 if (useTable)
1475 {
1476 m_t << "\\trowd \\trgaph108\\trleft426\\tblind426"
1477 "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1478 "\\trbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1479 "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1480 "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 "
1481 "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 "
1482 "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< "\n";
1483 for (int i=0;i<columnPos[config][0];i++)
1484 {
1485 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1486 "\\clbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1487 "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1488 "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 "
1489 "\\cltxlrtb "
1490 "\\cellx" << (rtf_pageWidth*columnPos[config][i+1]/100) << "\n";
1491 }
1492 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1493 }
1494
1495 if (sect && sect->hasInOutSpecifier())
1496 {
1497 if (useTable)
1498 {
1499 m_t << "{";
1500 }
1501
1502 // Put in the direction: in/out/in,out if specified.
1504 {
1505 if (pl.direction()==DocParamSect::In)
1506 {
1507 m_t << "in";
1508 }
1509 else if (pl.direction()==DocParamSect::Out)
1510 {
1511 m_t << "out";
1512 }
1513 else if (pl.direction()==DocParamSect::InOut)
1514 {
1515 m_t << "in,out";
1516 }
1517 }
1518
1519 if (useTable)
1520 {
1521 m_t << "\\cell }";
1522 }
1523 }
1524
1525 if (sect && sect->hasTypeSpecifier())
1526 {
1527 if (useTable)
1528 {
1529 m_t << "{";
1530 }
1531 for (const auto &type : pl.paramTypes())
1532 {
1533 std::visit(*this,type);
1534 }
1535 if (useTable)
1536 {
1537 m_t << "\\cell }";
1538 }
1539 }
1540
1541
1542 if (useTable)
1543 {
1544 m_t << "{";
1545 }
1546
1547 m_t << "{\\i ";
1548 bool first=TRUE;
1549 for (const auto &param : pl.parameters())
1550 {
1551 if (!first) m_t << ","; else first=FALSE;
1552 std::visit(*this,param);
1553 }
1554 m_t << "} ";
1555
1556 if (useTable)
1557 {
1558 m_t << "\\cell }{";
1559 }
1561
1562 for (const auto &par : pl.paragraphs())
1563 {
1564 std::visit(*this,par);
1565 }
1566
1567 if (useTable)
1568 {
1569 m_t << "\\cell }\n";
1570 //m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1571 m_t << "{\\row }\n";
1572 }
1573 else
1574 {
1575 m_t << "\\par\n";
1576 }
1577
1579}
1580
1582{
1583 if (m_hide) return;
1584 if (x.title().isEmpty()) return;
1585 bool anonymousEnum = x.file()=="@";
1586 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocXRefItem &)}\n");
1587 if (!m_lastIsPara)
1588 {
1589 m_t << "\\par\n";
1591 }
1592 m_t << "{"; // start param list
1593 //m_t << "{\\b "; // start bold
1594 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1595 if (Config_getBool(RTF_HYPERLINKS) && !anonymousEnum)
1596 {
1597 QCString refName;
1598 if (!x.file().isEmpty())
1599 {
1600 refName+=stripPath(x.file());
1601 }
1602 if (!x.file().isEmpty() && !x.anchor().isEmpty())
1603 {
1604 refName+="_";
1605 }
1606 if (!x.anchor().isEmpty())
1607 {
1608 refName+=x.anchor();
1609 }
1610
1611 m_t << "{\\field "
1612 "{\\*\\fldinst "
1613 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(refName) << "\" "
1614 "}{}"
1615 "}"
1616 "{\\fldrslt "
1617 "{\\cs37\\ul\\cf2 ";
1618 filter(x.title());
1619 m_t << "}"
1620 "}"
1621 "}";
1622 }
1623 else
1624 {
1625 filter(x.title());
1626 }
1627 m_t << ":";
1628 m_t << "\\par";
1629 m_t << "}"; // end bold
1631 m_t << rtf_Style_Reset << getStyle("DescContinue");
1633 visitChildren(x);
1634 if (x.title().isEmpty()) return;
1635 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocXRefItem)}\n");
1636 m_t << "\\par\n";
1638 m_t << "}\n"; // end xref item
1640}
1641
1643{
1644 if (m_hide) return;
1645 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocInternalRef &)}\n");
1646 startLink("",ref.file(),ref.anchor());
1647 visitChildren(ref);
1648 endLink("");
1649 m_t << " ";
1650}
1651
1653{
1654 if (m_hide) return;
1655 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocText &)}\n");
1656 visitChildren(t);
1657}
1658
1660{
1661 if (m_hide) return;
1662 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlBlockQuote &)}\n");
1663 if (!m_lastIsPara) m_t << "\\par\n";
1664 m_t << "{"; // start desc
1666 m_t << rtf_Style_Reset << getStyle("DescContinue");
1667 visitChildren(q);
1668 if (!m_lastIsPara) m_t << "\\par\n";
1670 m_t << "}"; // end desc
1672}
1673
1675{
1676}
1677
1679{
1680 if (m_hide) return;
1681 visitChildren(pb);
1682}
1683
1684
1685//static char* getMultiByte(int c)
1686//{
1687// static char s[10];
1688// sprintf(s,"\\'%X",c);
1689// return s;
1690//}
1691
1692void RTFDocVisitor::filter(const QCString &str,bool verbatim)
1693{
1694 if (!str.isEmpty())
1695 {
1696 const char *p=str.data();
1697 while (*p)
1698 {
1699 char c=*p++;
1700 switch (c)
1701 {
1702 case '{': m_t << "\\{"; break;
1703 case '}': m_t << "\\}"; break;
1704 case '\\': m_t << "\\\\"; break;
1705 case '\n': if (verbatim)
1706 {
1707 m_t << "\\par\n";
1708 }
1709 else
1710 {
1711 m_t << '\n';
1712 }
1713 break;
1714 default: m_t << c;
1715 }
1716 }
1717 }
1718}
1719
1720void RTFDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)
1721{
1722 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1723 {
1724 QCString refName;
1725 if (!file.isEmpty())
1726 {
1727 refName+=stripPath(file);
1728 }
1729 if (!file.isEmpty() && !anchor.isEmpty())
1730 {
1731 refName+='_';
1732 }
1733 if (!anchor.isEmpty())
1734 {
1735 refName+=anchor;
1736 }
1737
1738 m_t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \"";
1739 m_t << rtfFormatBmkStr(refName);
1740 m_t << "\" }{}";
1741 m_t << "}{\\fldrslt {\\cs37\\ul\\cf2 ";
1742 }
1743 else
1744 {
1745 m_t << "{\\b ";
1746 }
1748}
1749
1751{
1752 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1753 {
1754 m_t << "}}}";
1755 }
1756 else
1757 {
1758 m_t << "}";
1759 }
1761}
1762
1763void RTFDocVisitor::writeDotFile(const QCString &filename, bool hasCaption,
1764 const QCString &srcFile, int srcLine, bool newFile)
1765{
1766 QCString baseName=makeBaseName(filename,".dot");
1767 QCString outDir = Config_getString(RTF_OUTPUT);
1768 if (newFile) writeDotGraphFromFile(filename,outDir,baseName,GraphOutputFormat::BITMAP,srcFile,srcLine);
1769 QCString imgExt = getDotImageExtension();
1770 includePicturePreRTF(baseName + "." + imgExt, true, hasCaption);
1771}
1772
1773void RTFDocVisitor::writeMscFile(const QCString &fileName, bool hasCaption,
1774 const QCString &srcFile, int srcLine, bool newFile)
1775{
1776 QCString baseName=makeBaseName(fileName,".msc");
1777 QCString outDir = Config_getString(RTF_OUTPUT);
1778 if (newFile) writeMscGraphFromFile(fileName,outDir,baseName,MscOutputFormat::BITMAP,srcFile,srcLine);
1779 includePicturePreRTF(baseName + ".png", true, hasCaption);
1780}
1781
1782void RTFDocVisitor::writeDiaFile(const QCString &fileName, bool hasCaption,
1783 const QCString &srcFile, int srcLine, bool newFile)
1784{
1785 QCString baseName=makeBaseName(fileName,".dia");
1786 QCString outDir = Config_getString(RTF_OUTPUT);
1787 if (newFile) writeDiaGraphFromFile(fileName,outDir,baseName,DiaOutputFormat::BITMAP,srcFile,srcLine);
1788 includePicturePreRTF(baseName + ".png", true, hasCaption);
1789}
1790
1791void RTFDocVisitor::writePlantUMLFile(const QCString &fileName, bool hasCaption)
1792{
1793 QCString baseName=makeBaseName(fileName,".pu");
1794 QCString outDir = Config_getString(RTF_OUTPUT);
1796 includePicturePreRTF(baseName + ".png", true, hasCaption);
1797}
1798
1799void RTFDocVisitor::writeMermaidFile(const QCString &fileName, bool hasCaption)
1800{
1801 if (Config_getBool(MERMAID_RENDER_MODE)==MERMAID_RENDER_MODE_t::CLIENT_SIDE) return;
1802 QCString baseName=makeBaseName(fileName,".mmd");
1803 QCString outDir = Config_getString(RTF_OUTPUT);
1805 includePicturePreRTF(baseName + ".png", true, hasCaption);
1806}
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:974
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:832
QCString url() const
Definition docnode.h:839
QCString file() const
Definition docnode.h:840
Node representing a horizontal ruler.
Definition docnode.h:216
Node representing an HTML blockquote.
Definition docnode.h:1297
Node representing a HTML table caption.
Definition docnode.h:1234
QCString anchor() const
Definition docnode.h:1241
QCString file() const
Definition docnode.h:1240
Node representing a HTML table cell.
Definition docnode.h:1199
const HtmlAttribList & attribs() const
Definition docnode.h:1211
Node representing a HTML description data.
Definition docnode.h:1187
Node representing a Html description list.
Definition docnode.h:910
Node representing a Html description item.
Definition docnode.h:897
Node Html details.
Definition docnode.h:866
const DocNodeVariant * summary() const
Definition docnode.h:873
Node Html heading.
Definition docnode.h:882
int level() const
Definition docnode.h:886
Node representing a Html list.
Definition docnode.h:1009
const HtmlAttribList & attribs() const
Definition docnode.h:1015
Type type() const
Definition docnode.h:1014
Node representing a HTML list item.
Definition docnode.h:1171
const HtmlAttribList & attribs() const
Definition docnode.h:1176
Node representing a HTML table row.
Definition docnode.h:1252
bool isHeading() const
Definition docnode.cpp:2002
size_t numCells() const
Definition docnode.h:1257
Node Html summary.
Definition docnode.h:853
Node representing a HTML table.
Definition docnode.h:1275
const DocNodeVariant * caption() const
Definition docnode.cpp:2250
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:978
Node representing an internal reference to some item.
Definition docnode.h:816
QCString file() const
Definition docnode.h:820
QCString anchor() const
Definition docnode.h:822
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 mermaid file.
Definition docnode.h:749
Node representing a msc file.
Definition docnode.h:722
DocNodeVariant * parent()
Definition docnode.h:90
Node representing an block of paragraphs.
Definition docnode.h:988
Node representing a paragraph in the documentation tree.
Definition docnode.h:1089
bool isLast() const
Definition docnode.h:1097
Node representing a parameter list.
Definition docnode.h:1131
const DocNodeList & parameters() const
Definition docnode.h:1135
const DocNodeList & paramTypes() const
Definition docnode.h:1136
DocParamSect::Direction direction() const
Definition docnode.h:1139
const DocNodeList & paragraphs() const
Definition docnode.h:1137
Node representing a parameter section.
Definition docnode.h:1062
bool hasInOutSpecifier() const
Definition docnode.h:1078
bool hasTypeSpecifier() const
Definition docnode.h:1079
Type type() const
Definition docnode.h:1077
Node representing a uml file.
Definition docnode.h:740
Node representing a reference to some item.
Definition docnode.h:787
QCString anchor() const
Definition docnode.h:794
QCString targetTitle() const
Definition docnode.h:795
bool isSubPage() const
Definition docnode.h:801
QCString file() const
Definition docnode.h:791
QCString ref() const
Definition docnode.h:793
bool hasLinkText() const
Definition docnode.h:797
Root node of documentation tree.
Definition docnode.h:1319
bool singleLine() const
Definition docnode.h:1325
bool indent() const
Definition docnode.h:1324
Node representing a reference to a section.
Definition docnode.h:944
Node representing a list of section references.
Definition docnode.h:968
Node representing a normal section.
Definition docnode.h:923
QCString file() const
Definition docnode.h:931
int level() const
Definition docnode.h:927
QCString anchor() const
Definition docnode.h:929
const DocNodeVariant * title() const
Definition docnode.h:928
Node representing a separator.
Definition docnode.h:365
QCString chars() const
Definition docnode.h:369
Node representing a simple list.
Definition docnode.h:999
Node representing a simple list item.
Definition docnode.h:1159
const DocNodeVariant * paragraph() const
Definition docnode.h:1163
Node representing a simple section.
Definition docnode.h:1026
Type type() const
Definition docnode.h:1035
const DocNodeVariant * title() const
Definition docnode.h:1042
Node representing a separator between two simple sections of the same type.
Definition docnode.h:1053
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:1310
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:758
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.
QCString writeMermaidSource(const QCString &outDirArg, const QCString &fileName, const QCString &content, OutputFormat format, const QCString &srcFile, int srcLine)
Write a Mermaid source file and register it for CLI rendering.
Definition mermaid.cpp:54
void generateMermaidOutput(const QCString &baseName, const QCString &outDir, OutputFormat format)
Register a generated Mermaid image with the index.
Definition mermaid.cpp:101
static MermaidManager & instance()
Definition mermaid.cpp:33
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
void writeMermaidFile(const QCString &fileName, bool hasCaption)
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:6989
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5221
QCString integerToRoman(int n, bool upper)
Definition util.cpp:6728
QCString stripPath(const QCString &s)
Definition util.cpp:4959
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:5560
SrcLangExt getLanguageFromCodeLang(QCString &fileName)
Routine to handle the language attribute of the \code command.
Definition util.cpp:5239
QCString integerToAlpha(int n, bool upper)
Definition util.cpp:6712
QCString getDotImageExtension()
Definition util.cpp:6319
QCString makeBaseName(const QCString &name, const QCString &ext)
Definition util.cpp:4975
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:5887
QCString getFileNameExtension(const QCString &fn)
Definition util.cpp:5263
A bunch of utility functions.