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 auto rtfOutput = Config_getString(RTF_OUTPUT);
408 auto outputFormat = MermaidManager::OutputFormat::RTF;
409 auto imageFormat = MermaidManager::convertToImageFormat(outputFormat);
411 rtfOutput,s.exampleFile(),s.text(),imageFormat,
412 s.srcFile(),s.srcLine());
413 writeMermaidFile(baseName, s.hasCaption());
414 visitChildren(s);
416 }
417 break;
418 }
420}
421
423{
424 if (m_hide) return;
425 DBG_RTF("{\\comment RTFDocVisitor::visit(DocAnchor)}\n");
426 QCString anchor;
427 if (!anc.file().isEmpty())
428 {
429 anchor+=stripPath(anc.file());
430 }
431 if (!anc.file().isEmpty() && !anc.anchor().isEmpty())
432 {
433 anchor+="_";
434 }
435 if (!anc.anchor().isEmpty())
436 {
437 anchor+=anc.anchor();
438 }
439 m_t << "{\\bkmkstart " << rtfFormatBmkStr(anchor) << "}\n";
440 m_t << "{\\bkmkend " << rtfFormatBmkStr(anchor) << "}\n";
442}
443
445{
446 if (m_hide) return;
448 DBG_RTF("{\\comment RTFDocVisitor::visit(DocInclude)}\n");
449 switch(inc.type())
450 {
452 {
453 m_t << "{\n";
454 m_t << "\\par\n";
455 m_t << rtf_Style_Reset << getStyle("CodeExample");
456 FileInfo cfi( inc.file().str() );
457 auto fd = createFileDef( cfi.dirPath(), cfi.fileName() );
459 inc.text(),
460 langExt,
461 inc.stripCodeComments(),
463 .setExample(inc.isExample(),inc.exampleFile())
464 .setFileDef(fd.get())
465 .setInlineFragment(true)
466 );
467 m_t << "\\par";
468 m_t << "}\n";
469 }
470 break;
472 m_t << "{\n";
473 m_t << "\\par\n";
474 m_t << rtf_Style_Reset << getStyle("CodeExample");
476 inc.text(),langExt,
477 inc.stripCodeComments(),
479 .setExample(inc.isExample(),inc.exampleFile())
480 .setInlineFragment(true)
481 .setShowLineNumbers(false)
482 );
483 m_t << "\\par";
484 m_t << "}\n";
485 break;
493 break;
495 m_t << inc.text();
496 break;
498 m_t << "{\n";
499 m_t << "\\par\n";
500 m_t << rtf_Style_Reset << getStyle("CodeExample");
501 filter(inc.text());
502 m_t << "\\par";
503 m_t << "}\n";
504 break;
507 m_t << "{\n";
508 if (!m_lastIsPara) m_t << "\\par\n";
509 m_t << rtf_Style_Reset << getStyle("CodeExample");
511 inc.file(),
512 inc.blockId(),
513 inc.context(),
515 inc.trimLeft(),
517 );
518 m_t << "}";
519 break;
520 }
522}
523
525{
526 //printf("DocIncOperator: type=%d first=%d, last=%d text='%s'\n",
527 // op.type(),op.isFirst(),op.isLast(),qPrint(op.text()));
528 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIncOperator)}\n");
530 if (locLangExt.isEmpty()) locLangExt = m_langExt;
531 SrcLangExt langExt = getLanguageFromFileName(locLangExt);
532 if (op.isFirst())
533 {
534 if (!m_hide)
535 {
536 m_t << "{\n";
537 m_t << "\\par\n";
538 m_t << rtf_Style_Reset << getStyle("CodeExample");
539 }
541 m_hide = TRUE;
542 }
543 if (op.type()!=DocIncOperator::Skip)
544 {
545 m_hide = popHidden();
546 if (!m_hide)
547 {
548 std::unique_ptr<FileDef> fd = nullptr;
549 if (!op.includeFileName().isEmpty())
550 {
551 FileInfo cfi( op.includeFileName().str() );
552 fd = createFileDef( cfi.dirPath(), cfi.fileName() );
553 }
554
555 getCodeParser(locLangExt).parseCode(m_ci,op.context(),op.text(),langExt,
558 .setExample(op.isExample(),op.exampleFile())
559 .setFileDef(fd.get())
560 .setStartLine(op.line())
562 );
563 }
565 m_hide=TRUE;
566 }
567 if (op.isLast())
568 {
569 m_hide = popHidden();
570 if (!m_hide)
571 {
572 m_t << "\\par";
573 m_t << "}\n";
574 }
576 }
577 else
578 {
579 if (!m_hide) m_t << "\n";
581 }
582}
583
585{
586 if (m_hide) return;
587 DBG_RTF("{\\comment RTFDocVisitor::visit(DocFormula)}\n");
588 bool bDisplay = !f.isInline();
589 if (bDisplay)
590 {
591 m_t << "\\par";
592 m_t << "{";
593 m_t << "\\pard\\plain";
594 m_t << "\\pard";
595 m_t << "\\qc";
596 }
597 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"" << f.relPath() << f.name() << ".png\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}";
598 if (bDisplay)
599 {
600 m_t << "\\par}";
601 }
603}
604
606{
607 if (m_hide) return;
608 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIndexEntry)}\n");
609 m_t << "{\\xe \\v " << i.entry() << "}\n";
611}
612
616
618{
619 if (m_hide) return;
620 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocCite &)}\n");
621 auto opt = cite.option();
622 if (!cite.file().isEmpty())
623 {
624 if (!opt.noCite()) startLink(cite.ref(),cite.file(),cite.anchor());
625
626 filter(cite.getText());
627
628 if (!opt.noCite()) endLink(cite.ref());
629 }
630 else
631 {
632 m_t << "{\\b";
633 if (!opt.noPar()) filter("[");
634 filter(cite.target());
635 if (!opt.noPar()) filter("]");
636 m_t << "}";
637 }
638}
639
640
641//--------------------------------------
642// visitor functions for compound nodes
643//--------------------------------------
644
646{
647 if (m_hide) return;
648 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoList &)}\n");
649 m_t << "{\n";
650 int level = indentLevel();
651 m_listItemInfo[level].isEnum = l.isEnumList();
652 m_listItemInfo[level].isCheck = l.isCheckedList();
653 m_listItemInfo[level].type = '1';
654 m_listItemInfo[level].number = 1;
656 visitChildren(l);
657 if (!m_lastIsPara) m_t << "\\par";
658 m_t << "}\n";
660 if (!l.isCheckedList() && indentLevel()==0) m_t << "\\par\n";
661}
662
664{
665 static int prevLevel = -1;
666 if (m_hide) return;
667 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoListItem &)}\n");
668 int level = indentLevel();
669 if ((level != prevLevel-1) &&
670 (!(level==prevLevel && level != 0 && m_listItemInfo[level].isCheck)) &&
671 (!m_lastIsPara))
672 m_t << "\\par\n";
673 prevLevel= level;
675 if (m_listItemInfo[level].isEnum)
676 {
677 m_t << getStyle("ListEnum") << "\n";
678 m_t << m_listItemInfo[level].number << ".\\tab ";
679 m_listItemInfo[level].number++;
680 }
681 else
682 {
683 switch (li.itemNumber())
684 {
685 case DocAutoList::Unchecked: // unchecked
686 m_t << getListTable(2) << "\n";
687 break;
688 case DocAutoList::Checked_x: // checked with x
689 case DocAutoList::Checked_X: // checked with X
690 m_t << getListTable(3) << "\n";
691 break;
692 default:
693 m_t << getListTable(1) << "\n";
694 break;
695 }
696 }
698 m_lastIsPara=false;
699 visitChildren(li);
701}
702
704{
705 if (m_hide) return;
706 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPara &)}\n");
707 visitChildren(p);
708 if (!m_lastIsPara &&
709 !p.isLast() && // omit <p> for last paragraph
710 !(p.parent() && // and for parameters & sections
711 std::get_if<DocParamSect>(p.parent())
712 )
713 )
714 {
715 m_t << "\\par\n";
717 }
718}
719
721{
722 if (m_hide) return;
723 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRoot &)}\n");
724 if (r.indent()) incIndentLevel();
725 m_t << "{" << rtf_Style["BodyText"].reference() << "\n";
726 visitChildren(r);
727 if (!m_lastIsPara && !r.singleLine()) m_t << "\\par\n";
728 m_t << "}";
730 if (r.indent()) decIndentLevel();
731}
732
734{
735 if (m_hide) return;
736 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
737 if (!m_lastIsPara) m_t << "\\par\n";
738 m_t << "{"; // start desc
739 //m_t << "{\\b "; // start bold
740 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
741 switch(s.type())
742 {
744 m_t << theTranslator->trSeeAlso(); break;
746 m_t << theTranslator->trReturns(); break;
748 m_t << theTranslator->trAuthor(TRUE,TRUE); break;
750 m_t << theTranslator->trAuthor(TRUE,FALSE); break;
752 m_t << theTranslator->trVersion(); break;
754 m_t << theTranslator->trSince(); break;
756 m_t << theTranslator->trDate(); break;
758 m_t << theTranslator->trNote(); break;
760 m_t << theTranslator->trWarning(); break;
762 m_t << theTranslator->trPrecondition(); break;
764 m_t << theTranslator->trPostcondition(); break;
766 m_t << theTranslator->trCopyright(); break;
768 m_t << theTranslator->trInvariant(); break;
770 m_t << theTranslator->trRemarks(); break;
772 m_t << theTranslator->trAttention(); break;
774 m_t << theTranslator->trImportant(); break;
775 case DocSimpleSect::User: break;
776 case DocSimpleSect::Rcs: break;
777 case DocSimpleSect::Unknown: break;
778 }
779
782 {
783 m_t << "\\par";
784 m_t << "}"; // end bold
785 m_t << rtf_Style_Reset << getStyle("DescContinue");
786 m_t << "{\\s17 \\sa60 \\sb30\n";
787 }
788 else
789 {
790 if (s.title())
791 {
792 std::visit(*this,*s.title());
793 }
794 m_t << "\\par\n";
795 m_t << "}"; // end bold
796 m_t << rtf_Style_Reset << getStyle("DescContinue");
797 }
799 visitChildren(s);
800 if (!m_lastIsPara) m_t << "\\par\n";
803 {
804 m_t << "}"; // end DescContinue
805 }
806 m_t << "}"; // end desc
808}
809
811{
812 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocTitle &)}\n");
813 if (m_hide) return;
814 visitChildren(t);
815}
816
818{
819 if (m_hide) return;
820 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
821 m_t << "{\n";
822 m_listItemInfo[indentLevel()].isEnum = false;
823 m_listItemInfo[indentLevel()].isCheck = false;
825 visitChildren(l);
826 if (!m_lastIsPara) m_t << "\\par\n";
827 m_t << "}\n";
829}
830
832{
833 if (m_hide) return;
834 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleListItem &)}\n");
835 m_t << "\\par" << rtf_Style_Reset << getStyle("ListBullet") << "\n";
838 if (li.paragraph())
839 {
840 std::visit(*this,*li.paragraph());
841 }
843 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSimpleListItem)}\n");
844}
845
847{
848 if (m_hide) return;
849 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSection &)}\n");
850 if (!m_lastIsPara) m_t << "\\par\n";
851 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
852 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
853 m_t << "{{" // start section
855 QCString heading;
856 int level = std::min(s.level()+2+m_hierarchyLevel,4);
857 if (level <= 0)
858 level = 1;
859 heading.sprintf("Heading%d",level);
860 // set style
861 m_t << rtf_Style[heading.str()].reference() << "\n";
862 // make table of contents entry
863 if (s.title())
864 {
865 std::visit(*this,*s.title());
866 }
867 m_t << "\n\\par" << "}\n";
868 m_t << "{\\tc\\tcl" << level << " \\v ";
869 if (s.title())
870 {
871 std::visit(*this,*s.title());
872 }
873 m_t << "}\n";
875 visitChildren(s);
876 m_t << "\\par}\n"; // end section
878}
879
881{
882 if (m_hide) return;
883 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlList &)}\n");
884 m_t << "{\n";
885 int level = indentLevel();
886 m_listItemInfo[level].isEnum = l.type()==DocHtmlList::Ordered;
887 m_listItemInfo[level].isCheck = false;
888 m_listItemInfo[level].number = 1;
889 m_listItemInfo[level].type = '1';
890 for (const auto &opt : l.attribs())
891 {
892 if (opt.name=="type")
893 {
894 m_listItemInfo[level].type = opt.value[0];
895 }
896 if (opt.name=="start")
897 {
898 bool ok = false;
899 int val = opt.value.toInt(&ok);
900 if (ok) m_listItemInfo[level].number = val;
901 }
902 }
904 visitChildren(l);
905 m_t << "\\par" << "}\n";
907}
908
910{
911 if (m_hide) return;
912 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlListItem &)}\n");
913 m_t << "\\par\n";
915 int level = indentLevel();
916 if (m_listItemInfo[level].isEnum)
917 {
918 for (const auto &opt : l.attribs())
919 {
920 if (opt.name=="value")
921 {
922 bool ok = false;
923 int val = opt.value.toInt(&ok);
924 if (ok) m_listItemInfo[level].number = val;
925 }
926 }
927 m_t << getStyle("ListEnum") << "\n";
928 switch (m_listItemInfo[level].type)
929 {
930 case '1':
931 m_t << m_listItemInfo[level].number;
932 break;
933 case 'a':
934 m_t << integerToAlpha(m_listItemInfo[level].number,false);
935 break;
936 case 'A':
937 m_t << integerToAlpha(m_listItemInfo[level].number);
938 break;
939 case 'i':
940 m_t << integerToRoman(m_listItemInfo[level].number,false);
941 break;
942 case 'I':
943 m_t << integerToRoman(m_listItemInfo[level].number);
944 break;
945 default:
946 m_t << m_listItemInfo[level].number;
947 break;
948 }
949 m_t << ".\\tab ";
950 m_listItemInfo[level].number++;
951 }
952 else
953 {
954 m_t << getStyle("ListBullet") << "\n";
955 }
958 visitChildren(l);
960 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlListItem)}\n");
961}
962
964{
965 if (m_hide) return;
966 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescList &)}\n");
967 //m_t << "{\n";
968 //m_t << rtf_Style_Reset << getStyle("ListContinue");
969 //m_lastIsPara=FALSE;
970 visitChildren(dl);
971 //m_t << "}\n";
972 //m_t << "\\par\n";
973 //m_lastIsPara=TRUE;
974}
975
977{
978 if (m_hide) return;
979 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescTitle &)}\n");
980 //m_t << "\\par\n";
981 //m_t << "{\\b ";
982 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
984 visitChildren(dt);
985 m_t << "\\par\n";
986 m_t << "}\n";
988}
989
991{
992 if (m_hide) return;
993 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescData &)}\n");
995 m_t << "{" << rtf_Style_Reset << getStyle("DescContinue");
996 visitChildren(dd);
997 m_t << "\\par";
998 m_t << "}\n";
1001}
1002
1004{
1005 if (m_hide) return;
1006 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlTable &)}\n");
1007 if (!m_lastIsPara) m_t << "\\par\n";
1009 if (t.caption())
1010 {
1011 const DocHtmlCaption &c = std::get<DocHtmlCaption>(*t.caption());
1012 m_t << "\\pard \\qc \\b";
1013 if (!c.file().isEmpty())
1014 {
1015 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1016 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1017 }
1018 m_t << "{Table \\field\\flddirty{\\*\\fldinst { SEQ Table \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1019 std::visit(*this,*t.caption());
1020 }
1021 visitChildren(t);
1022 m_t << "\\pard\\plain\n";
1023 m_t << "\\par\n";
1025}
1026
1028{
1029 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCaption &)}\n");
1030 visitChildren(c);
1031 m_t << "}\n\\par\n";
1032}
1033
1035{
1036 if (m_hide) return;
1037 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlRow &)}\n");
1038 size_t columnWidth=r.numCells()>0 ? rtf_pageWidth/r.numCells() : 10;
1039 m_t << "\\trowd \\trgaph108\\trleft-108"
1040 "\\trbrdrt\\brdrs\\brdrw10 "
1041 "\\trbrdrl\\brdrs\\brdrw10 "
1042 "\\trbrdrb\\brdrs\\brdrw10 "
1043 "\\trbrdrr\\brdrs\\brdrw10 "
1044 "\\trbrdrh\\brdrs\\brdrw10 "
1045 "\\trbrdrv\\brdrs\\brdrw10 \n";
1046 for (size_t i=0;i<r.numCells();i++)
1047 {
1048 if (r.isHeading())
1049 {
1050 m_t << "\\clcbpat16"; // set cell shading to light grey (color 16 in the clut)
1051 }
1052 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10 "
1053 "\\clbrdrl\\brdrs\\brdrw10 "
1054 "\\clbrdrb\\brdrs\\brdrw10 "
1055 "\\clbrdrr \\brdrs\\brdrw10 "
1056 "\\cltxlrtb "
1057 "\\cellx" << ((i+1)*columnWidth) << "\n";
1058 }
1059 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1061 visitChildren(r);
1062 m_t << "\n";
1063 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1064 m_t << "{\\row }\n";
1066}
1067
1069{
1070 if (m_hide) return;
1071 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCell &)}\n");
1072 m_t << "{" << align(c);
1074 visitChildren(c);
1075 m_t << "\\cell }";
1077}
1078
1080{
1081 if (m_hide) return;
1082 visitChildren(i);
1083}
1084
1086{
1087 if (m_hide) return;
1088 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHRef &)}\n");
1089 if (Config_getBool(RTF_HYPERLINKS))
1090 {
1091 if (href.url().startsWith("#"))
1092 {
1093 // when starting with # so a local link
1094 QCString cite;
1095 cite = href.file() + "_" + href.url().right(href.url().length()-1);
1096 m_t << "{\\field "
1097 "{\\*\\fldinst "
1098 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(cite) << "\" "
1099 "}{}"
1100 "}"
1101 "{\\fldrslt "
1102 "{\\cs37\\ul\\cf2 ";
1103 }
1104 else
1105 {
1106 m_t << "{\\field "
1107 "{\\*\\fldinst "
1108 "{ HYPERLINK \"" << href.url() << "\" "
1109 "}{}"
1110 "}"
1111 "{\\fldrslt "
1112 "{\\cs37\\ul\\cf2 ";
1113 }
1114 }
1115 else
1116 {
1117 m_t << "{\\f2 ";
1118 }
1120 visitChildren(href);
1121 if (Config_getBool(RTF_HYPERLINKS))
1122 {
1123 m_t << "}"
1124 "}"
1125 "}";
1126 }
1127 else
1128 {
1129 m_t << "}";
1130 }
1132}
1133
1135{
1136 if (m_hide) return;
1137 m_t << "{\\b ";
1138 visitChildren(s);
1139 m_t << "}\\par ";
1140}
1141
1143{
1144 if (m_hide) return;
1145 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDetails &)}\n");
1146 if (!m_lastIsPara) m_t << "\\par\n";
1147 auto summary = d.summary();
1148 if (summary)
1149 {
1150 std::visit(*this,*summary);
1151 m_t << "{"; // start desc
1153 m_t << rtf_Style_Reset << getStyle("DescContinue");
1154 }
1155 visitChildren(d);
1156 if (!m_lastIsPara) m_t << "\\par\n";
1157 if (summary)
1158 {
1160 m_t << "}"; // end desc
1161 }
1163}
1164
1166{
1167 if (m_hide) return;
1168 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlHeader &)}\n");
1169 m_t << "{" // start section
1170 << rtf_Style_Reset;
1171 QCString heading;
1172 int level = std::clamp(header.level()+m_hierarchyLevel,SectionType::MinLevel,SectionType::MaxLevel);
1173 heading.sprintf("Heading%d",level);
1174 // set style
1175 m_t << rtf_Style[heading.str()].reference();
1176 // make open table of contents entry that will be closed in visitPost method
1177 m_t << "{\\tc\\tcl" << level << " ";
1179 visitChildren(header);
1180 // close open table of contents entry
1181 m_t << "} \\par";
1182 m_t << "}\n"; // end section
1184}
1185
1186void RTFDocVisitor::includePicturePreRTF(const QCString &name, bool isTypeRTF, bool hasCaption, bool inlineImage)
1187{
1188 if (isTypeRTF)
1189 {
1190 if (!inlineImage)
1191 {
1192 m_t << "\\par\n";
1193 m_t << "{\n";
1194 m_t << rtf_Style_Reset << "\n";
1195 if (hasCaption || m_lastIsPara) m_t << "\\par\n";
1196 m_t << "\\pard \\qc ";
1197 }
1198 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"";
1199 m_t << name;
1200 m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}\n";
1201 if (!inlineImage)
1202 {
1203 m_t << "\\par\n";
1204 if (hasCaption)
1205 {
1206 m_t << "\\pard \\qc \\b";
1207 m_t << "{Image \\field\\flddirty{\\*\\fldinst { SEQ Image \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1208 }
1210 }
1211 else
1212 {
1213 if (hasCaption) m_t << "{\\comment "; // to prevent caption to be shown
1214 }
1215 }
1216 else // other format -> skip
1217 {
1219 m_hide=TRUE;
1220 }
1221}
1222
1223void RTFDocVisitor::includePicturePostRTF(bool isTypeRTF, bool hasCaption, bool inlineImage)
1224{
1225 if (isTypeRTF)
1226 {
1227 if (m_hide) return;
1228 if (inlineImage)
1229 {
1230 if (hasCaption) m_t << " }";
1231 }
1232 else
1233 {
1234 if (hasCaption)
1235 {
1236 m_t << "}\n";
1237 m_t << "\\par}\n";
1238 }
1239 else
1240 {
1241 m_t << "}\n";
1242 }
1243 }
1244 }
1245 else
1246 {
1247 m_hide = popHidden();
1248 }
1249}
1250
1252{
1253 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocImage &)}\n");
1255 visitChildren(img);
1257}
1258
1259
1261{
1262 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDotFile &)}\n");
1263 bool exists = false;
1264 std::string inBuf;
1265 if (readInputFile(df.file(),inBuf))
1266 {
1267 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1268 ".dot", // extension
1269 inBuf, // contents
1270 exists);
1271 if (!fileName.isEmpty())
1272 {
1273 writeDotFile(fileName, df.hasCaption(), df.srcFile(), df.srcLine(), !exists);
1274 visitChildren(df);
1276 }
1277 }
1278}
1280{
1281 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocMscFile &)}\n");
1282 bool exists = false;
1283 std::string inBuf;
1284 if (readInputFile(df.file(),inBuf))
1285 {
1286 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1287 ".msc", // extension
1288 inBuf, // contents
1289 exists);
1290 if (!fileName.isEmpty())
1291 {
1292 writeMscFile(fileName, df.hasCaption(), df.srcFile(), df.srcLine(), !exists);
1293 visitChildren(df);
1295 }
1296 }
1297}
1298
1300{
1301 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDiaFile &)}\n");
1302 bool exists = false;
1303 std::string inBuf;
1304 if (readInputFile(df.file(),inBuf))
1305 {
1306 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1307 ".dia", // extension
1308 inBuf, // contents
1309 exists);
1310 if (!fileName.isEmpty())
1311 {
1312 writeDiaFile(fileName, df.hasCaption(), df.srcFile(), df.srcLine(), !exists);
1313 visitChildren(df);
1315 }
1316 }
1317}
1318
1320{
1321 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPlantUmlFile &)}\n");
1322 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1323 QCString rtfOutput = Config_getString(RTF_OUTPUT);
1324 std::string inBuf;
1325 readInputFile(df.file(),inBuf);
1326 auto baseNameVector = PlantumlManager::instance().writePlantUMLSource(
1327 rtfOutput,QCString(),inBuf,PlantumlManager::PUML_BITMAP,
1328 QCString(),df.srcFile(),df.srcLine(),false);
1329 for(const auto &baseName: baseNameVector)
1330 {
1331 writePlantUMLFile(baseName, df.hasCaption());
1332 visitChildren(df);
1334 }
1335}
1336
1338{
1339 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocMermaidFile &)}\n");
1340 if (Config_getBool(MERMAID_RENDER_MODE)==MERMAID_RENDER_MODE_t::CLIENT_SIDE) return;
1341 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1342 std::string inBuf;
1343 readInputFile(df.file(),inBuf);
1344 auto rtfOutput = Config_getString(RTF_OUTPUT);
1345 auto outputFormat = MermaidManager::OutputFormat::RTF;
1346 auto imageFormat = MermaidManager::convertToImageFormat(outputFormat);
1348 rtfOutput,QCString(),inBuf,imageFormat,
1349 df.srcFile(),df.srcLine());
1350 writeMermaidFile(baseName, df.hasCaption());
1351 visitChildren(df);
1353}
1354
1356{
1357 if (m_hide) return;
1358 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocLink &)}\n");
1359 startLink(lnk.ref(),lnk.file(),lnk.anchor());
1360 visitChildren(lnk);
1361 endLink(lnk.ref());
1362}
1363
1365{
1366 if (m_hide) return;
1367 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRef &)}\n");
1368 // when ref.isSubPage()==TRUE we use ref.file() for HTML and
1369 // ref.anchor() for LaTeX/RTF
1370 if (ref.isSubPage())
1371 {
1372 startLink(ref.ref(),QCString(),ref.anchor());
1373 }
1374 else
1375 {
1376 if (!ref.file().isEmpty()) startLink(ref.ref(),ref.file(),ref.anchor());
1377 }
1378 if (!ref.hasLinkText()) filter(ref.targetTitle());
1379 visitChildren(ref);
1380 if (!ref.file().isEmpty()) endLink(ref.ref());
1381 //m_t << " ";
1382}
1383
1384
1386{
1387 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefItem &)}\n");
1388 visitChildren(ref);
1389}
1390
1392{
1393 if (m_hide) return;
1394 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefList &)}\n");
1395 m_t << "{\n";
1397 m_t << rtf_Style_Reset << getStyle("LatexTOC") << "\n";
1398 m_t << "\\par\n";
1400 visitChildren(l);
1402 m_t << "\\par";
1403 m_t << "}\n";
1405}
1406
1408{
1409 if (m_hide) return;
1410 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamSect &)}\n");
1411 m_t << "{"; // start param list
1412 if (!m_lastIsPara) m_t << "\\par\n";
1413 //m_t << "{\\b "; // start bold
1414 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1415 switch(s.type())
1416 {
1418 m_t << theTranslator->trParameters(); break;
1420 m_t << theTranslator->trReturnValues(); break;
1422 m_t << theTranslator->trExceptions(); break;
1424 m_t << theTranslator->trTemplateParameters(); break;
1425 default:
1426 ASSERT(0);
1427 }
1428 m_t << "\\par";
1429 m_t << "}\n";
1430 bool useTable = s.type()==DocParamSect::Param ||
1434 if (!useTable)
1435 {
1437 }
1438 m_t << rtf_Style_Reset << getStyle("DescContinue");
1440 visitChildren(s);
1441 //m_t << "\\par\n";
1442 if (!useTable)
1443 {
1445 }
1446 m_t << "}\n";
1447}
1448
1450{
1451 m_t << " " << sep.chars() << " ";
1452}
1453
1455{
1456 static int columnPos[4][5] =
1457 { { 2, 25, 100, 100, 100 }, // no inout, no type
1458 { 3, 14, 35, 100, 100 }, // inout, no type
1459 { 3, 25, 50, 100, 100 }, // no inout, type
1460 { 4, 14, 35, 55, 100 }, // inout, type
1461 };
1462 int config=0;
1463 if (m_hide) return;
1464 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamList &)}\n");
1465
1467 const DocParamSect *sect = std::get_if<DocParamSect>(pl.parent());
1468 if (sect)
1469 {
1470 parentType = sect->type();
1471 }
1472 bool useTable = parentType==DocParamSect::Param ||
1473 parentType==DocParamSect::RetVal ||
1474 parentType==DocParamSect::Exception ||
1475 parentType==DocParamSect::TemplateParam;
1476 if (sect && sect->hasInOutSpecifier()) config+=1;
1477 if (sect && sect->hasTypeSpecifier()) config+=2;
1478 if (useTable)
1479 {
1480 m_t << "\\trowd \\trgaph108\\trleft426\\tblind426"
1481 "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1482 "\\trbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1483 "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1484 "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 "
1485 "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 "
1486 "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< "\n";
1487 for (int i=0;i<columnPos[config][0];i++)
1488 {
1489 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1490 "\\clbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1491 "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1492 "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 "
1493 "\\cltxlrtb "
1494 "\\cellx" << (rtf_pageWidth*columnPos[config][i+1]/100) << "\n";
1495 }
1496 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1497 }
1498
1499 if (sect && sect->hasInOutSpecifier())
1500 {
1501 if (useTable)
1502 {
1503 m_t << "{";
1504 }
1505
1506 // Put in the direction: in/out/in,out if specified.
1508 {
1509 if (pl.direction()==DocParamSect::In)
1510 {
1511 m_t << "in";
1512 }
1513 else if (pl.direction()==DocParamSect::Out)
1514 {
1515 m_t << "out";
1516 }
1517 else if (pl.direction()==DocParamSect::InOut)
1518 {
1519 m_t << "in,out";
1520 }
1521 }
1522
1523 if (useTable)
1524 {
1525 m_t << "\\cell }";
1526 }
1527 }
1528
1529 if (sect && sect->hasTypeSpecifier())
1530 {
1531 if (useTable)
1532 {
1533 m_t << "{";
1534 }
1535 for (const auto &type : pl.paramTypes())
1536 {
1537 std::visit(*this,type);
1538 }
1539 if (useTable)
1540 {
1541 m_t << "\\cell }";
1542 }
1543 }
1544
1545
1546 if (useTable)
1547 {
1548 m_t << "{";
1549 }
1550
1551 m_t << "{\\i ";
1552 bool first=TRUE;
1553 for (const auto &param : pl.parameters())
1554 {
1555 if (!first) m_t << ","; else first=FALSE;
1556 std::visit(*this,param);
1557 }
1558 m_t << "} ";
1559
1560 if (useTable)
1561 {
1562 m_t << "\\cell }{";
1563 }
1565
1566 for (const auto &par : pl.paragraphs())
1567 {
1568 std::visit(*this,par);
1569 }
1570
1571 if (useTable)
1572 {
1573 m_t << "\\cell }\n";
1574 //m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1575 m_t << "{\\row }\n";
1576 }
1577 else
1578 {
1579 m_t << "\\par\n";
1580 }
1581
1583}
1584
1586{
1587 if (m_hide) return;
1588 if (x.title().isEmpty()) return;
1589 bool anonymousEnum = x.file()=="@";
1590 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocXRefItem &)}\n");
1591 if (!m_lastIsPara)
1592 {
1593 m_t << "\\par\n";
1595 }
1596 m_t << "{"; // start param list
1597 //m_t << "{\\b "; // start bold
1598 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1599 if (Config_getBool(RTF_HYPERLINKS) && !anonymousEnum)
1600 {
1601 QCString refName;
1602 if (!x.file().isEmpty())
1603 {
1604 refName+=stripPath(x.file());
1605 }
1606 if (!x.file().isEmpty() && !x.anchor().isEmpty())
1607 {
1608 refName+="_";
1609 }
1610 if (!x.anchor().isEmpty())
1611 {
1612 refName+=x.anchor();
1613 }
1614
1615 m_t << "{\\field "
1616 "{\\*\\fldinst "
1617 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(refName) << "\" "
1618 "}{}"
1619 "}"
1620 "{\\fldrslt "
1621 "{\\cs37\\ul\\cf2 ";
1622 filter(x.title());
1623 m_t << "}"
1624 "}"
1625 "}";
1626 }
1627 else
1628 {
1629 filter(x.title());
1630 }
1631 m_t << ":";
1632 m_t << "\\par";
1633 m_t << "}"; // end bold
1635 m_t << rtf_Style_Reset << getStyle("DescContinue");
1637 visitChildren(x);
1638 if (x.title().isEmpty()) return;
1639 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocXRefItem)}\n");
1640 m_t << "\\par\n";
1642 m_t << "}\n"; // end xref item
1644}
1645
1647{
1648 if (m_hide) return;
1649 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocInternalRef &)}\n");
1650 startLink("",ref.file(),ref.anchor());
1651 visitChildren(ref);
1652 endLink("");
1653 m_t << " ";
1654}
1655
1657{
1658 if (m_hide) return;
1659 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocText &)}\n");
1660 visitChildren(t);
1661}
1662
1664{
1665 if (m_hide) return;
1666 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlBlockQuote &)}\n");
1667 if (!m_lastIsPara) m_t << "\\par\n";
1668 m_t << "{"; // start desc
1670 m_t << rtf_Style_Reset << getStyle("DescContinue");
1671 visitChildren(q);
1672 if (!m_lastIsPara) m_t << "\\par\n";
1674 m_t << "}"; // end desc
1676}
1677
1679{
1680}
1681
1683{
1684 if (m_hide) return;
1685 visitChildren(pb);
1686}
1687
1688
1689//static char* getMultiByte(int c)
1690//{
1691// static char s[10];
1692// sprintf(s,"\\'%X",c);
1693// return s;
1694//}
1695
1696void RTFDocVisitor::filter(const QCString &str,bool verbatim)
1697{
1698 if (!str.isEmpty())
1699 {
1700 const char *p=str.data();
1701 while (*p)
1702 {
1703 char c=*p++;
1704 switch (c)
1705 {
1706 case '{': m_t << "\\{"; break;
1707 case '}': m_t << "\\}"; break;
1708 case '\\': m_t << "\\\\"; break;
1709 case '\n': if (verbatim)
1710 {
1711 m_t << "\\par\n";
1712 }
1713 else
1714 {
1715 m_t << '\n';
1716 }
1717 break;
1718 default: m_t << c;
1719 }
1720 }
1721 }
1722}
1723
1724void RTFDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)
1725{
1726 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1727 {
1728 QCString refName;
1729 if (!file.isEmpty())
1730 {
1731 refName+=stripPath(file);
1732 }
1733 if (!file.isEmpty() && !anchor.isEmpty())
1734 {
1735 refName+='_';
1736 }
1737 if (!anchor.isEmpty())
1738 {
1739 refName+=anchor;
1740 }
1741
1742 m_t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \"";
1743 m_t << rtfFormatBmkStr(refName);
1744 m_t << "\" }{}";
1745 m_t << "}{\\fldrslt {\\cs37\\ul\\cf2 ";
1746 }
1747 else
1748 {
1749 m_t << "{\\b ";
1750 }
1752}
1753
1755{
1756 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1757 {
1758 m_t << "}}}";
1759 }
1760 else
1761 {
1762 m_t << "}";
1763 }
1765}
1766
1767void RTFDocVisitor::writeDotFile(const QCString &filename, bool hasCaption,
1768 const QCString &srcFile, int srcLine, bool newFile)
1769{
1770 QCString baseName=makeBaseName(filename,".dot");
1771 QCString outDir = Config_getString(RTF_OUTPUT);
1772 if (newFile) writeDotGraphFromFile(filename,outDir,baseName,GraphOutputFormat::BITMAP,srcFile,srcLine,false);
1773 QCString imgExt = getDotImageExtension();
1774 includePicturePreRTF(baseName + "." + imgExt, true, hasCaption);
1775}
1776
1777void RTFDocVisitor::writeMscFile(const QCString &fileName, bool hasCaption,
1778 const QCString &srcFile, int srcLine, bool newFile)
1779{
1780 QCString baseName=makeBaseName(fileName,".msc");
1781 QCString outDir = Config_getString(RTF_OUTPUT);
1782 if (newFile) writeMscGraphFromFile(fileName,outDir,baseName,MscOutputFormat::BITMAP,srcFile,srcLine,false);
1783 includePicturePreRTF(baseName + ".png", true, hasCaption);
1784}
1785
1786void RTFDocVisitor::writeDiaFile(const QCString &fileName, bool hasCaption,
1787 const QCString &srcFile, int srcLine, bool newFile)
1788{
1789 QCString baseName=makeBaseName(fileName,".dia");
1790 QCString outDir = Config_getString(RTF_OUTPUT);
1791 if (newFile) writeDiaGraphFromFile(fileName,outDir,baseName,DiaOutputFormat::BITMAP,srcFile,srcLine,false);
1792 includePicturePreRTF(baseName + ".png", true, hasCaption);
1793}
1794
1795void RTFDocVisitor::writePlantUMLFile(const QCString &fileName, bool hasCaption)
1796{
1797 QCString baseName=makeBaseName(fileName,".pu");
1798 QCString outDir = Config_getString(RTF_OUTPUT);
1800 includePicturePreRTF(baseName + ".png", true, hasCaption);
1801}
1802
1803void RTFDocVisitor::writeMermaidFile(const QCString &fileName, bool hasCaption)
1804{
1805 if (Config_getBool(MERMAID_RENDER_MODE)==MERMAID_RENDER_MODE_t::CLIENT_SIDE) return;
1806 auto baseName = makeBaseName(fileName,".mmd");
1807 auto outDir = Config_getString(RTF_OUTPUT);
1808 auto outputFormat = MermaidManager::OutputFormat::RTF;
1809 auto imageFormat = MermaidManager::convertToImageFormat(outputFormat);
1810 auto imgExt = MermaidManager::imageExtension(imageFormat);
1811 MermaidManager::instance().generateMermaidOutput(fileName,outDir,imageFormat,false);
1812 includePicturePreRTF(baseName + "." + imgExt, true, hasCaption);
1813}
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.
void generateMermaidOutput(const QCString &baseName, const QCString &outDir, ImageFormat format, bool toIndex)
Register a generated Mermaid image with the index.
Definition mermaid.cpp:117
static QCString imageExtension(ImageFormat imageFormat)
Definition mermaid.cpp:43
static MermaidManager & instance()
Definition mermaid.cpp:33
static ImageFormat convertToImageFormat(OutputFormat outputFormat)
Definition mermaid.cpp:54
QCString writeMermaidSource(const QCString &outDirArg, const QCString &fileName, const QCString &content, ImageFormat format, const QCString &srcFile, int srcLine)
Write a Mermaid source file and register it for CLI rendering.
Definition mermaid.cpp:70
Class representing a list of different code generators.
Definition outputlist.h:165
void generatePlantUMLOutput(const QCString &baseName, const QCString &outDir, OutputFormat format, bool toIndex)
Convert a PlantUML file to an image.
Definition plantuml.cpp:202
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:232
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, bool toIndex)
Definition dia.cpp:28
void writeDotGraphFromFile(const QCString &inFile, const QCString &outDir, const QCString &outFile, GraphOutputFormat format, const QCString &srcFile, int srcLine, bool toIndex)
Definition dot.cpp:196
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, bool toIndex)
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:6977
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5231
QCString integerToRoman(int n, bool upper)
Definition util.cpp:6716
QCString stripPath(const QCString &s)
Definition util.cpp:4969
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:5570
SrcLangExt getLanguageFromCodeLang(QCString &fileName)
Routine to handle the language attribute of the \code command.
Definition util.cpp:5249
QCString integerToAlpha(int n, bool upper)
Definition util.cpp:6700
QCString getDotImageExtension()
Definition util.cpp:6307
QCString makeBaseName(const QCString &name, const QCString &ext)
Definition util.cpp:4985
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:5875
QCString getFileNameExtension(const QCString &fn)
Definition util.cpp:5273
A bunch of utility functions.