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 "msc.h"
31#include "dia.h"
32#include "filedef.h"
33#include "config.h"
34#include "htmlentity.h"
35#include "emoji.h"
36#include "plantuml.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;
404 }
406}
407
409{
410 if (m_hide) return;
411 DBG_RTF("{\\comment RTFDocVisitor::visit(DocAnchor)}\n");
412 QCString anchor;
413 if (!anc.file().isEmpty())
414 {
415 anchor+=stripPath(anc.file());
416 }
417 if (!anc.file().isEmpty() && !anc.anchor().isEmpty())
418 {
419 anchor+="_";
420 }
421 if (!anc.anchor().isEmpty())
422 {
423 anchor+=anc.anchor();
424 }
425 m_t << "{\\bkmkstart " << rtfFormatBmkStr(anchor) << "}\n";
426 m_t << "{\\bkmkend " << rtfFormatBmkStr(anchor) << "}\n";
428}
429
431{
432 if (m_hide) return;
434 DBG_RTF("{\\comment RTFDocVisitor::visit(DocInclude)}\n");
435 switch(inc.type())
436 {
438 {
439 m_t << "{\n";
440 m_t << "\\par\n";
441 m_t << rtf_Style_Reset << getStyle("CodeExample");
442 FileInfo cfi( inc.file().str() );
443 auto fd = createFileDef( cfi.dirPath(), cfi.fileName() );
445 inc.text(),
446 langExt,
447 inc.stripCodeComments(),
449 .setExample(inc.isExample(),inc.exampleFile())
450 .setFileDef(fd.get())
451 .setInlineFragment(true)
452 );
453 m_t << "\\par";
454 m_t << "}\n";
455 }
456 break;
458 m_t << "{\n";
459 m_t << "\\par\n";
460 m_t << rtf_Style_Reset << getStyle("CodeExample");
462 inc.text(),langExt,
463 inc.stripCodeComments(),
465 .setExample(inc.isExample(),inc.exampleFile())
466 .setInlineFragment(true)
467 .setShowLineNumbers(false)
468 );
469 m_t << "\\par";
470 m_t << "}\n";
471 break;
479 break;
481 m_t << inc.text();
482 break;
484 m_t << "{\n";
485 m_t << "\\par\n";
486 m_t << rtf_Style_Reset << getStyle("CodeExample");
487 filter(inc.text());
488 m_t << "\\par";
489 m_t << "}\n";
490 break;
493 m_t << "{\n";
494 if (!m_lastIsPara) m_t << "\\par\n";
495 m_t << rtf_Style_Reset << getStyle("CodeExample");
497 inc.file(),
498 inc.blockId(),
499 inc.context(),
501 inc.trimLeft(),
503 );
504 m_t << "}";
505 break;
506 }
508}
509
511{
512 //printf("DocIncOperator: type=%d first=%d, last=%d text='%s'\n",
513 // op.type(),op.isFirst(),op.isLast(),qPrint(op.text()));
514 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIncOperator)}\n");
516 if (locLangExt.isEmpty()) locLangExt = m_langExt;
517 SrcLangExt langExt = getLanguageFromFileName(locLangExt);
518 if (op.isFirst())
519 {
520 if (!m_hide)
521 {
522 m_t << "{\n";
523 m_t << "\\par\n";
524 m_t << rtf_Style_Reset << getStyle("CodeExample");
525 }
527 m_hide = TRUE;
528 }
529 if (op.type()!=DocIncOperator::Skip)
530 {
531 m_hide = popHidden();
532 if (!m_hide)
533 {
534 std::unique_ptr<FileDef> fd = nullptr;
535 if (!op.includeFileName().isEmpty())
536 {
537 FileInfo cfi( op.includeFileName().str() );
538 fd = createFileDef( cfi.dirPath(), cfi.fileName() );
539 }
540
541 getCodeParser(locLangExt).parseCode(m_ci,op.context(),op.text(),langExt,
544 .setExample(op.isExample(),op.exampleFile())
545 .setFileDef(fd.get())
546 .setStartLine(op.line())
548 );
549 }
551 m_hide=TRUE;
552 }
553 if (op.isLast())
554 {
555 m_hide = popHidden();
556 if (!m_hide)
557 {
558 m_t << "\\par";
559 m_t << "}\n";
560 }
562 }
563 else
564 {
565 if (!m_hide) m_t << "\n";
567 }
568}
569
571{
572 if (m_hide) return;
573 DBG_RTF("{\\comment RTFDocVisitor::visit(DocFormula)}\n");
574 bool bDisplay = !f.isInline();
575 if (bDisplay)
576 {
577 m_t << "\\par";
578 m_t << "{";
579 m_t << "\\pard\\plain";
580 m_t << "\\pard";
581 m_t << "\\qc";
582 }
583 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"" << f.relPath() << f.name() << ".png\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}";
584 if (bDisplay)
585 {
586 m_t << "\\par}";
587 }
589}
590
592{
593 if (m_hide) return;
594 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIndexEntry)}\n");
595 m_t << "{\\xe \\v " << i.entry() << "}\n";
597}
598
602
604{
605 if (m_hide) return;
606 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocCite &)}\n");
607 auto opt = cite.option();
608 if (!cite.file().isEmpty())
609 {
610 if (!opt.noCite()) startLink(cite.ref(),cite.file(),cite.anchor());
611
612 filter(cite.getText());
613
614 if (!opt.noCite()) endLink(cite.ref());
615 }
616 else
617 {
618 m_t << "{\\b";
619 if (!opt.noPar()) filter("[");
620 filter(cite.target());
621 if (!opt.noPar()) filter("]");
622 m_t << "}";
623 }
624}
625
626
627//--------------------------------------
628// visitor functions for compound nodes
629//--------------------------------------
630
632{
633 if (m_hide) return;
634 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoList &)}\n");
635 m_t << "{\n";
636 int level = indentLevel();
637 m_listItemInfo[level].isEnum = l.isEnumList();
638 m_listItemInfo[level].isCheck = l.isCheckedList();
639 m_listItemInfo[level].type = '1';
640 m_listItemInfo[level].number = 1;
642 visitChildren(l);
643 if (!m_lastIsPara) m_t << "\\par";
644 m_t << "}\n";
646 if (!l.isCheckedList() && indentLevel()==0) m_t << "\\par\n";
647}
648
650{
651 static int prevLevel = -1;
652 if (m_hide) return;
653 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoListItem &)}\n");
654 int level = indentLevel();
655 if ((level != prevLevel-1) &&
656 (!(level==prevLevel && level != 0 && m_listItemInfo[level].isCheck)) &&
657 (!m_lastIsPara))
658 m_t << "\\par\n";
659 prevLevel= level;
661 if (m_listItemInfo[level].isEnum)
662 {
663 m_t << getStyle("ListEnum") << "\n";
664 m_t << m_listItemInfo[level].number << ".\\tab ";
665 m_listItemInfo[level].number++;
666 }
667 else
668 {
669 switch (li.itemNumber())
670 {
671 case DocAutoList::Unchecked: // unchecked
672 m_t << getListTable(2) << "\n";
673 break;
674 case DocAutoList::Checked_x: // checked with x
675 case DocAutoList::Checked_X: // checked with X
676 m_t << getListTable(3) << "\n";
677 break;
678 default:
679 m_t << getListTable(1) << "\n";
680 break;
681 }
682 }
684 m_lastIsPara=false;
685 visitChildren(li);
687}
688
690{
691 if (m_hide) return;
692 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPara &)}\n");
693 visitChildren(p);
694 if (!m_lastIsPara &&
695 !p.isLast() && // omit <p> for last paragraph
696 !(p.parent() && // and for parameters & sections
697 std::get_if<DocParamSect>(p.parent())
698 )
699 )
700 {
701 m_t << "\\par\n";
703 }
704}
705
707{
708 if (m_hide) return;
709 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRoot &)}\n");
710 if (r.indent()) incIndentLevel();
711 m_t << "{" << rtf_Style["BodyText"].reference() << "\n";
712 visitChildren(r);
713 if (!m_lastIsPara && !r.singleLine()) m_t << "\\par\n";
714 m_t << "}";
716 if (r.indent()) decIndentLevel();
717}
718
720{
721 if (m_hide) return;
722 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
723 if (!m_lastIsPara) m_t << "\\par\n";
724 m_t << "{"; // start desc
725 //m_t << "{\\b "; // start bold
726 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
727 switch(s.type())
728 {
730 m_t << theTranslator->trSeeAlso(); break;
732 m_t << theTranslator->trReturns(); break;
734 m_t << theTranslator->trAuthor(TRUE,TRUE); break;
736 m_t << theTranslator->trAuthor(TRUE,FALSE); break;
738 m_t << theTranslator->trVersion(); break;
740 m_t << theTranslator->trSince(); break;
742 m_t << theTranslator->trDate(); break;
744 m_t << theTranslator->trNote(); break;
746 m_t << theTranslator->trWarning(); break;
748 m_t << theTranslator->trPrecondition(); break;
750 m_t << theTranslator->trPostcondition(); break;
752 m_t << theTranslator->trCopyright(); break;
754 m_t << theTranslator->trInvariant(); break;
756 m_t << theTranslator->trRemarks(); break;
758 m_t << theTranslator->trAttention(); break;
760 m_t << theTranslator->trImportant(); break;
761 case DocSimpleSect::User: break;
762 case DocSimpleSect::Rcs: break;
763 case DocSimpleSect::Unknown: break;
764 }
765
768 {
769 m_t << "\\par";
770 m_t << "}"; // end bold
771 m_t << rtf_Style_Reset << getStyle("DescContinue");
772 m_t << "{\\s17 \\sa60 \\sb30\n";
773 }
774 else
775 {
776 if (s.title())
777 {
778 std::visit(*this,*s.title());
779 }
780 m_t << "\\par\n";
781 m_t << "}"; // end bold
782 m_t << rtf_Style_Reset << getStyle("DescContinue");
783 }
785 visitChildren(s);
786 if (!m_lastIsPara) m_t << "\\par\n";
789 {
790 m_t << "}"; // end DescContinue
791 }
792 m_t << "}"; // end desc
794}
795
797{
798 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocTitle &)}\n");
799 if (m_hide) return;
800 visitChildren(t);
801}
802
804{
805 if (m_hide) return;
806 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
807 m_t << "{\n";
808 m_listItemInfo[indentLevel()].isEnum = false;
809 m_listItemInfo[indentLevel()].isCheck = false;
811 visitChildren(l);
812 if (!m_lastIsPara) m_t << "\\par\n";
813 m_t << "}\n";
815}
816
818{
819 if (m_hide) return;
820 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleListItem &)}\n");
821 m_t << "\\par" << rtf_Style_Reset << getStyle("ListBullet") << "\n";
824 if (li.paragraph())
825 {
826 std::visit(*this,*li.paragraph());
827 }
829 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSimpleListItem)}\n");
830}
831
833{
834 if (m_hide) return;
835 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSection &)}\n");
836 if (!m_lastIsPara) m_t << "\\par\n";
837 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
838 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
839 m_t << "{{" // start section
841 QCString heading;
842 int level = std::min(s.level()+2+m_hierarchyLevel,4);
843 if (level <= 0)
844 level = 1;
845 heading.sprintf("Heading%d",level);
846 // set style
847 m_t << rtf_Style[heading.str()].reference() << "\n";
848 // make table of contents entry
849 if (s.title())
850 {
851 std::visit(*this,*s.title());
852 }
853 m_t << "\n\\par" << "}\n";
854 m_t << "{\\tc\\tcl" << level << " \\v ";
855 if (s.title())
856 {
857 std::visit(*this,*s.title());
858 }
859 m_t << "}\n";
861 visitChildren(s);
862 m_t << "\\par}\n"; // end section
864}
865
867{
868 if (m_hide) return;
869 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlList &)}\n");
870 m_t << "{\n";
871 int level = indentLevel();
872 m_listItemInfo[level].isEnum = l.type()==DocHtmlList::Ordered;
873 m_listItemInfo[level].isCheck = false;
874 m_listItemInfo[level].number = 1;
875 m_listItemInfo[level].type = '1';
876 for (const auto &opt : l.attribs())
877 {
878 if (opt.name=="type")
879 {
880 m_listItemInfo[level].type = opt.value[0];
881 }
882 if (opt.name=="start")
883 {
884 bool ok = false;
885 int val = opt.value.toInt(&ok);
886 if (ok) m_listItemInfo[level].number = val;
887 }
888 }
890 visitChildren(l);
891 m_t << "\\par" << "}\n";
893}
894
896{
897 if (m_hide) return;
898 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlListItem &)}\n");
899 m_t << "\\par\n";
901 int level = indentLevel();
902 if (m_listItemInfo[level].isEnum)
903 {
904 for (const auto &opt : l.attribs())
905 {
906 if (opt.name=="value")
907 {
908 bool ok = false;
909 int val = opt.value.toInt(&ok);
910 if (ok) m_listItemInfo[level].number = val;
911 }
912 }
913 m_t << getStyle("ListEnum") << "\n";
914 switch (m_listItemInfo[level].type)
915 {
916 case '1':
917 m_t << m_listItemInfo[level].number;
918 break;
919 case 'a':
920 m_t << integerToAlpha(m_listItemInfo[level].number,false);
921 break;
922 case 'A':
923 m_t << integerToAlpha(m_listItemInfo[level].number);
924 break;
925 case 'i':
926 m_t << integerToRoman(m_listItemInfo[level].number,false);
927 break;
928 case 'I':
929 m_t << integerToRoman(m_listItemInfo[level].number);
930 break;
931 default:
932 m_t << m_listItemInfo[level].number;
933 break;
934 }
935 m_t << ".\\tab ";
936 m_listItemInfo[level].number++;
937 }
938 else
939 {
940 m_t << getStyle("ListBullet") << "\n";
941 }
944 visitChildren(l);
946 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlListItem)}\n");
947}
948
950{
951 if (m_hide) return;
952 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescList &)}\n");
953 //m_t << "{\n";
954 //m_t << rtf_Style_Reset << getStyle("ListContinue");
955 //m_lastIsPara=FALSE;
956 visitChildren(dl);
957 //m_t << "}\n";
958 //m_t << "\\par\n";
959 //m_lastIsPara=TRUE;
960}
961
963{
964 if (m_hide) return;
965 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescTitle &)}\n");
966 //m_t << "\\par\n";
967 //m_t << "{\\b ";
968 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
970 visitChildren(dt);
971 m_t << "\\par\n";
972 m_t << "}\n";
974}
975
977{
978 if (m_hide) return;
979 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescData &)}\n");
981 m_t << "{" << rtf_Style_Reset << getStyle("DescContinue");
982 visitChildren(dd);
983 m_t << "\\par";
984 m_t << "}\n";
987}
988
990{
991 if (m_hide) return;
992 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlTable &)}\n");
993 if (!m_lastIsPara) m_t << "\\par\n";
995 if (t.caption())
996 {
997 const DocHtmlCaption &c = std::get<DocHtmlCaption>(*t.caption());
998 m_t << "\\pard \\qc \\b";
999 if (!c.file().isEmpty())
1000 {
1001 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1002 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1003 }
1004 m_t << "{Table \\field\\flddirty{\\*\\fldinst { SEQ Table \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1005 std::visit(*this,*t.caption());
1006 }
1007 visitChildren(t);
1008 m_t << "\\pard\\plain\n";
1009 m_t << "\\par\n";
1011}
1012
1014{
1015 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCaption &)}\n");
1016 visitChildren(c);
1017 m_t << "}\n\\par\n";
1018}
1019
1021{
1022 if (m_hide) return;
1023 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlRow &)}\n");
1024 size_t columnWidth=r.numCells()>0 ? rtf_pageWidth/r.numCells() : 10;
1025 m_t << "\\trowd \\trgaph108\\trleft-108"
1026 "\\trbrdrt\\brdrs\\brdrw10 "
1027 "\\trbrdrl\\brdrs\\brdrw10 "
1028 "\\trbrdrb\\brdrs\\brdrw10 "
1029 "\\trbrdrr\\brdrs\\brdrw10 "
1030 "\\trbrdrh\\brdrs\\brdrw10 "
1031 "\\trbrdrv\\brdrs\\brdrw10 \n";
1032 for (size_t i=0;i<r.numCells();i++)
1033 {
1034 if (r.isHeading())
1035 {
1036 m_t << "\\clcbpat16"; // set cell shading to light grey (color 16 in the clut)
1037 }
1038 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10 "
1039 "\\clbrdrl\\brdrs\\brdrw10 "
1040 "\\clbrdrb\\brdrs\\brdrw10 "
1041 "\\clbrdrr \\brdrs\\brdrw10 "
1042 "\\cltxlrtb "
1043 "\\cellx" << ((i+1)*columnWidth) << "\n";
1044 }
1045 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1047 visitChildren(r);
1048 m_t << "\n";
1049 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1050 m_t << "{\\row }\n";
1052}
1053
1055{
1056 if (m_hide) return;
1057 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCell &)}\n");
1058 m_t << "{" << align(c);
1060 visitChildren(c);
1061 m_t << "\\cell }";
1063}
1064
1066{
1067 if (m_hide) return;
1068 visitChildren(i);
1069}
1070
1072{
1073 if (m_hide) return;
1074 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHRef &)}\n");
1075 if (Config_getBool(RTF_HYPERLINKS))
1076 {
1077 if (href.url().startsWith("#"))
1078 {
1079 // when starting with # so a local link
1080 QCString cite;
1081 cite = href.file() + "_" + href.url().right(href.url().length()-1);
1082 m_t << "{\\field "
1083 "{\\*\\fldinst "
1084 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(cite) << "\" "
1085 "}{}"
1086 "}"
1087 "{\\fldrslt "
1088 "{\\cs37\\ul\\cf2 ";
1089 }
1090 else
1091 {
1092 m_t << "{\\field "
1093 "{\\*\\fldinst "
1094 "{ HYPERLINK \"" << href.url() << "\" "
1095 "}{}"
1096 "}"
1097 "{\\fldrslt "
1098 "{\\cs37\\ul\\cf2 ";
1099 }
1100 }
1101 else
1102 {
1103 m_t << "{\\f2 ";
1104 }
1106 visitChildren(href);
1107 if (Config_getBool(RTF_HYPERLINKS))
1108 {
1109 m_t << "}"
1110 "}"
1111 "}";
1112 }
1113 else
1114 {
1115 m_t << "}";
1116 }
1118}
1119
1121{
1122 if (m_hide) return;
1123 m_t << "{\\b ";
1124 visitChildren(s);
1125 m_t << "}\\par ";
1126}
1127
1129{
1130 if (m_hide) return;
1131 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDetails &)}\n");
1132 if (!m_lastIsPara) m_t << "\\par\n";
1133 auto summary = d.summary();
1134 if (summary)
1135 {
1136 std::visit(*this,*summary);
1137 m_t << "{"; // start desc
1139 m_t << rtf_Style_Reset << getStyle("DescContinue");
1140 }
1141 visitChildren(d);
1142 if (!m_lastIsPara) m_t << "\\par\n";
1143 if (summary)
1144 {
1146 m_t << "}"; // end desc
1147 }
1149}
1150
1152{
1153 if (m_hide) return;
1154 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlHeader &)}\n");
1155 m_t << "{" // start section
1156 << rtf_Style_Reset;
1157 QCString heading;
1158 int level = std::clamp(header.level()+m_hierarchyLevel,SectionType::MinLevel,SectionType::MaxLevel);
1159 heading.sprintf("Heading%d",level);
1160 // set style
1161 m_t << rtf_Style[heading.str()].reference();
1162 // make open table of contents entry that will be closed in visitPost method
1163 m_t << "{\\tc\\tcl" << level << " ";
1165 visitChildren(header);
1166 // close open table of contents entry
1167 m_t << "} \\par";
1168 m_t << "}\n"; // end section
1170}
1171
1172void RTFDocVisitor::includePicturePreRTF(const QCString &name, bool isTypeRTF, bool hasCaption, bool inlineImage)
1173{
1174 if (isTypeRTF)
1175 {
1176 if (!inlineImage)
1177 {
1178 m_t << "\\par\n";
1179 m_t << "{\n";
1180 m_t << rtf_Style_Reset << "\n";
1181 if (hasCaption || m_lastIsPara) m_t << "\\par\n";
1182 m_t << "\\pard \\qc ";
1183 }
1184 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"";
1185 m_t << name;
1186 m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}\n";
1187 if (!inlineImage)
1188 {
1189 m_t << "\\par\n";
1190 if (hasCaption)
1191 {
1192 m_t << "\\pard \\qc \\b";
1193 m_t << "{Image \\field\\flddirty{\\*\\fldinst { SEQ Image \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1194 }
1196 }
1197 else
1198 {
1199 if (hasCaption) m_t << "{\\comment "; // to prevent caption to be shown
1200 }
1201 }
1202 else // other format -> skip
1203 {
1205 m_hide=TRUE;
1206 }
1207}
1208
1209void RTFDocVisitor::includePicturePostRTF(bool isTypeRTF, bool hasCaption, bool inlineImage)
1210{
1211 if (isTypeRTF)
1212 {
1213 if (m_hide) return;
1214 if (inlineImage)
1215 {
1216 if (hasCaption) m_t << " }";
1217 }
1218 else
1219 {
1220 if (hasCaption)
1221 {
1222 m_t << "}\n";
1223 m_t << "\\par}\n";
1224 }
1225 else
1226 {
1227 m_t << "}\n";
1228 }
1229 }
1230 }
1231 else
1232 {
1233 m_hide = popHidden();
1234 }
1235}
1236
1238{
1239 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocImage &)}\n");
1241 visitChildren(img);
1243}
1244
1245
1247{
1248 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDotFile &)}\n");
1249 bool exists = false;
1250 std::string inBuf;
1251 if (readInputFile(df.file(),inBuf))
1252 {
1253 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1254 ".dot", // extension
1255 inBuf, // contents
1256 exists);
1257 if (!fileName.isEmpty())
1258 {
1259 writeDotFile(fileName, df.hasCaption(), df.srcFile(), df.srcLine(), !exists);
1260 visitChildren(df);
1262 }
1263 }
1264}
1266{
1267 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocMscFile &)}\n");
1268 bool exists = false;
1269 std::string inBuf;
1270 if (readInputFile(df.file(),inBuf))
1271 {
1272 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1273 ".msc", // extension
1274 inBuf, // contents
1275 exists);
1276 if (!fileName.isEmpty())
1277 {
1278 writeMscFile(fileName, df.hasCaption(), df.srcFile(), df.srcLine(), !exists);
1279 visitChildren(df);
1281 }
1282 }
1283}
1284
1286{
1287 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDiaFile &)}\n");
1288 bool exists = false;
1289 std::string inBuf;
1290 if (readInputFile(df.file(),inBuf))
1291 {
1292 auto fileName = writeFileContents(Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file())+"_", // baseName
1293 ".dia", // extension
1294 inBuf, // contents
1295 exists);
1296 if (!fileName.isEmpty())
1297 {
1298 writeDiaFile(fileName, df.hasCaption(), df.srcFile(), df.srcLine(), !exists);
1299 visitChildren(df);
1301 }
1302 }
1303}
1304
1306{
1307 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPlantUmlFile &)}\n");
1308 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1309 QCString rtfOutput = Config_getString(RTF_OUTPUT);
1310 std::string inBuf;
1311 readInputFile(df.file(),inBuf);
1312 auto baseNameVector = PlantumlManager::instance().writePlantUMLSource(
1313 rtfOutput,QCString(),inBuf,PlantumlManager::PUML_BITMAP,
1314 QCString(),df.srcFile(),df.srcLine(),false);
1315 for(const auto &baseName: baseNameVector)
1316 {
1317 writePlantUMLFile(baseName, df.hasCaption());
1318 visitChildren(df);
1320 }
1321}
1322
1324{
1325 if (m_hide) return;
1326 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocLink &)}\n");
1327 startLink(lnk.ref(),lnk.file(),lnk.anchor());
1328 visitChildren(lnk);
1329 endLink(lnk.ref());
1330}
1331
1333{
1334 if (m_hide) return;
1335 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRef &)}\n");
1336 // when ref.isSubPage()==TRUE we use ref.file() for HTML and
1337 // ref.anchor() for LaTeX/RTF
1338 if (ref.isSubPage())
1339 {
1340 startLink(ref.ref(),QCString(),ref.anchor());
1341 }
1342 else
1343 {
1344 if (!ref.file().isEmpty()) startLink(ref.ref(),ref.file(),ref.anchor());
1345 }
1346 if (!ref.hasLinkText()) filter(ref.targetTitle());
1347 visitChildren(ref);
1348 if (!ref.file().isEmpty()) endLink(ref.ref());
1349 //m_t << " ";
1350}
1351
1352
1354{
1355 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefItem &)}\n");
1356 visitChildren(ref);
1357}
1358
1360{
1361 if (m_hide) return;
1362 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefList &)}\n");
1363 m_t << "{\n";
1365 m_t << rtf_Style_Reset << getStyle("LatexTOC") << "\n";
1366 m_t << "\\par\n";
1368 visitChildren(l);
1370 m_t << "\\par";
1371 m_t << "}\n";
1373}
1374
1376{
1377 if (m_hide) return;
1378 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamSect &)}\n");
1379 m_t << "{"; // start param list
1380 if (!m_lastIsPara) m_t << "\\par\n";
1381 //m_t << "{\\b "; // start bold
1382 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1383 switch(s.type())
1384 {
1386 m_t << theTranslator->trParameters(); break;
1388 m_t << theTranslator->trReturnValues(); break;
1390 m_t << theTranslator->trExceptions(); break;
1392 m_t << theTranslator->trTemplateParameters(); break;
1393 default:
1394 ASSERT(0);
1395 }
1396 m_t << "\\par";
1397 m_t << "}\n";
1398 bool useTable = s.type()==DocParamSect::Param ||
1402 if (!useTable)
1403 {
1405 }
1406 m_t << rtf_Style_Reset << getStyle("DescContinue");
1408 visitChildren(s);
1409 //m_t << "\\par\n";
1410 if (!useTable)
1411 {
1413 }
1414 m_t << "}\n";
1415}
1416
1418{
1419 m_t << " " << sep.chars() << " ";
1420}
1421
1423{
1424 static int columnPos[4][5] =
1425 { { 2, 25, 100, 100, 100 }, // no inout, no type
1426 { 3, 14, 35, 100, 100 }, // inout, no type
1427 { 3, 25, 50, 100, 100 }, // no inout, type
1428 { 4, 14, 35, 55, 100 }, // inout, type
1429 };
1430 int config=0;
1431 if (m_hide) return;
1432 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamList &)}\n");
1433
1435 const DocParamSect *sect = std::get_if<DocParamSect>(pl.parent());
1436 if (sect)
1437 {
1438 parentType = sect->type();
1439 }
1440 bool useTable = parentType==DocParamSect::Param ||
1441 parentType==DocParamSect::RetVal ||
1442 parentType==DocParamSect::Exception ||
1443 parentType==DocParamSect::TemplateParam;
1444 if (sect && sect->hasInOutSpecifier()) config+=1;
1445 if (sect && sect->hasTypeSpecifier()) config+=2;
1446 if (useTable)
1447 {
1448 m_t << "\\trowd \\trgaph108\\trleft426\\tblind426"
1449 "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1450 "\\trbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1451 "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1452 "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 "
1453 "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 "
1454 "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< "\n";
1455 for (int i=0;i<columnPos[config][0];i++)
1456 {
1457 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1458 "\\clbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1459 "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1460 "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 "
1461 "\\cltxlrtb "
1462 "\\cellx" << (rtf_pageWidth*columnPos[config][i+1]/100) << "\n";
1463 }
1464 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1465 }
1466
1467 if (sect && sect->hasInOutSpecifier())
1468 {
1469 if (useTable)
1470 {
1471 m_t << "{";
1472 }
1473
1474 // Put in the direction: in/out/in,out if specified.
1476 {
1477 if (pl.direction()==DocParamSect::In)
1478 {
1479 m_t << "in";
1480 }
1481 else if (pl.direction()==DocParamSect::Out)
1482 {
1483 m_t << "out";
1484 }
1485 else if (pl.direction()==DocParamSect::InOut)
1486 {
1487 m_t << "in,out";
1488 }
1489 }
1490
1491 if (useTable)
1492 {
1493 m_t << "\\cell }";
1494 }
1495 }
1496
1497 if (sect && sect->hasTypeSpecifier())
1498 {
1499 if (useTable)
1500 {
1501 m_t << "{";
1502 }
1503 for (const auto &type : pl.paramTypes())
1504 {
1505 std::visit(*this,type);
1506 }
1507 if (useTable)
1508 {
1509 m_t << "\\cell }";
1510 }
1511 }
1512
1513
1514 if (useTable)
1515 {
1516 m_t << "{";
1517 }
1518
1519 m_t << "{\\i ";
1520 bool first=TRUE;
1521 for (const auto &param : pl.parameters())
1522 {
1523 if (!first) m_t << ","; else first=FALSE;
1524 std::visit(*this,param);
1525 }
1526 m_t << "} ";
1527
1528 if (useTable)
1529 {
1530 m_t << "\\cell }{";
1531 }
1533
1534 for (const auto &par : pl.paragraphs())
1535 {
1536 std::visit(*this,par);
1537 }
1538
1539 if (useTable)
1540 {
1541 m_t << "\\cell }\n";
1542 //m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1543 m_t << "{\\row }\n";
1544 }
1545 else
1546 {
1547 m_t << "\\par\n";
1548 }
1549
1551}
1552
1554{
1555 if (m_hide) return;
1556 if (x.title().isEmpty()) return;
1557 bool anonymousEnum = x.file()=="@";
1558 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocXRefItem &)}\n");
1559 if (!m_lastIsPara)
1560 {
1561 m_t << "\\par\n";
1563 }
1564 m_t << "{"; // start param list
1565 //m_t << "{\\b "; // start bold
1566 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1567 if (Config_getBool(RTF_HYPERLINKS) && !anonymousEnum)
1568 {
1569 QCString refName;
1570 if (!x.file().isEmpty())
1571 {
1572 refName+=stripPath(x.file());
1573 }
1574 if (!x.file().isEmpty() && !x.anchor().isEmpty())
1575 {
1576 refName+="_";
1577 }
1578 if (!x.anchor().isEmpty())
1579 {
1580 refName+=x.anchor();
1581 }
1582
1583 m_t << "{\\field "
1584 "{\\*\\fldinst "
1585 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(refName) << "\" "
1586 "}{}"
1587 "}"
1588 "{\\fldrslt "
1589 "{\\cs37\\ul\\cf2 ";
1590 filter(x.title());
1591 m_t << "}"
1592 "}"
1593 "}";
1594 }
1595 else
1596 {
1597 filter(x.title());
1598 }
1599 m_t << ":";
1600 m_t << "\\par";
1601 m_t << "}"; // end bold
1603 m_t << rtf_Style_Reset << getStyle("DescContinue");
1605 visitChildren(x);
1606 if (x.title().isEmpty()) return;
1607 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocXRefItem)}\n");
1608 m_t << "\\par\n";
1610 m_t << "}\n"; // end xref item
1612}
1613
1615{
1616 if (m_hide) return;
1617 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocInternalRef &)}\n");
1618 startLink("",ref.file(),ref.anchor());
1619 visitChildren(ref);
1620 endLink("");
1621 m_t << " ";
1622}
1623
1625{
1626 if (m_hide) return;
1627 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocText &)}\n");
1628 visitChildren(t);
1629}
1630
1632{
1633 if (m_hide) return;
1634 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlBlockQuote &)}\n");
1635 if (!m_lastIsPara) m_t << "\\par\n";
1636 m_t << "{"; // start desc
1638 m_t << rtf_Style_Reset << getStyle("DescContinue");
1639 visitChildren(q);
1640 if (!m_lastIsPara) m_t << "\\par\n";
1642 m_t << "}"; // end desc
1644}
1645
1647{
1648}
1649
1651{
1652 if (m_hide) return;
1653 visitChildren(pb);
1654}
1655
1656
1657//static char* getMultiByte(int c)
1658//{
1659// static char s[10];
1660// sprintf(s,"\\'%X",c);
1661// return s;
1662//}
1663
1664void RTFDocVisitor::filter(const QCString &str,bool verbatim)
1665{
1666 if (!str.isEmpty())
1667 {
1668 const char *p=str.data();
1669 while (*p)
1670 {
1671 char c=*p++;
1672 switch (c)
1673 {
1674 case '{': m_t << "\\{"; break;
1675 case '}': m_t << "\\}"; break;
1676 case '\\': m_t << "\\\\"; break;
1677 case '\n': if (verbatim)
1678 {
1679 m_t << "\\par\n";
1680 }
1681 else
1682 {
1683 m_t << '\n';
1684 }
1685 break;
1686 default: m_t << c;
1687 }
1688 }
1689 }
1690}
1691
1692void RTFDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)
1693{
1694 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1695 {
1696 QCString refName;
1697 if (!file.isEmpty())
1698 {
1699 refName+=stripPath(file);
1700 }
1701 if (!file.isEmpty() && !anchor.isEmpty())
1702 {
1703 refName+='_';
1704 }
1705 if (!anchor.isEmpty())
1706 {
1707 refName+=anchor;
1708 }
1709
1710 m_t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \"";
1711 m_t << rtfFormatBmkStr(refName);
1712 m_t << "\" }{}";
1713 m_t << "}{\\fldrslt {\\cs37\\ul\\cf2 ";
1714 }
1715 else
1716 {
1717 m_t << "{\\b ";
1718 }
1720}
1721
1723{
1724 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1725 {
1726 m_t << "}}}";
1727 }
1728 else
1729 {
1730 m_t << "}";
1731 }
1733}
1734
1735void RTFDocVisitor::writeDotFile(const QCString &filename, bool hasCaption,
1736 const QCString &srcFile, int srcLine, bool newFile)
1737{
1738 QCString baseName=makeBaseName(filename,".dot");
1739 QCString outDir = Config_getString(RTF_OUTPUT);
1740 if (newFile) writeDotGraphFromFile(filename,outDir,baseName,GraphOutputFormat::BITMAP,srcFile,srcLine);
1741 QCString imgExt = getDotImageExtension();
1742 includePicturePreRTF(baseName + "." + imgExt, true, hasCaption);
1743}
1744
1745void RTFDocVisitor::writeMscFile(const QCString &fileName, bool hasCaption,
1746 const QCString &srcFile, int srcLine, bool newFile)
1747{
1748 QCString baseName=makeBaseName(fileName,".msc");
1749 QCString outDir = Config_getString(RTF_OUTPUT);
1750 if (newFile) writeMscGraphFromFile(fileName,outDir,baseName,MscOutputFormat::BITMAP,srcFile,srcLine);
1751 includePicturePreRTF(baseName + ".png", true, hasCaption);
1752}
1753
1754void RTFDocVisitor::writeDiaFile(const QCString &fileName, bool hasCaption,
1755 const QCString &srcFile, int srcLine, bool newFile)
1756{
1757 QCString baseName=makeBaseName(fileName,".dia");
1758 QCString outDir = Config_getString(RTF_OUTPUT);
1759 if (newFile) writeDiaGraphFromFile(fileName,outDir,baseName,DiaOutputFormat::BITMAP,srcFile,srcLine);
1760 includePicturePreRTF(baseName + ".png", true, hasCaption);
1761}
1762
1763void RTFDocVisitor::writePlantUMLFile(const QCString &fileName, bool hasCaption)
1764{
1765 QCString baseName=makeBaseName(fileName,".pu");
1766 QCString outDir = Config_getString(RTF_OUTPUT);
1768 includePicturePreRTF(baseName + ".png", true, hasCaption);
1769}
void parseCodeFragment(OutputCodeList &codeOutList, const QCString &fileName, const QCString &blockId, const QCString &scopeName, bool showLineNumbers, bool trimLeft, bool stripCodeComments)
static CodeFragmentManager & instance()
virtual void parseCode(OutputCodeList &codeOutList, const QCString &scopeName, const QCString &input, SrcLangExt lang, bool stripCodeComments, const CodeParserOptions &options)=0
Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
Node representing an anchor.
Definition docnode.h:229
QCString anchor() const
Definition docnode.h:232
QCString file() const
Definition docnode.h:233
Node representing an auto List.
Definition docnode.h:571
bool isCheckedList() const
Definition docnode.h:582
bool isEnumList() const
Definition docnode.h:580
Node representing an item of a auto list.
Definition docnode.h:595
int itemNumber() const
Definition docnode.h:598
Node representing a citation of some bibliographic reference.
Definition docnode.h:245
QCString getText() const
Definition docnode.cpp:972
CiteInfoOption option() const
Definition docnode.h:253
QCString target() const
Definition docnode.h:252
QCString anchor() const
Definition docnode.h:251
QCString ref() const
Definition docnode.h:250
QCString file() const
Definition docnode.h:248
Node representing a dia file.
Definition docnode.h:731
QCString srcFile() const
Definition docnode.h:691
QCString file() const
Definition docnode.h:685
int srcLine() const
Definition docnode.h:692
bool hasCaption() const
Definition docnode.h:687
Node representing a dot file.
Definition docnode.h:713
Node representing an emoji.
Definition docnode.h:341
int index() const
Definition docnode.h:345
QCString name() const
Definition docnode.h:344
Node representing an item of a cross-referenced list.
Definition docnode.h:529
QCString name() const
Definition docnode.h:532
bool isInline() const
Definition docnode.h:536
QCString relPath() const
Definition docnode.h:534
Node representing a Hypertext reference.
Definition docnode.h:823
QCString url() const
Definition docnode.h:830
QCString file() const
Definition docnode.h:831
Node representing a horizontal ruler.
Definition docnode.h:216
Node representing an HTML blockquote.
Definition docnode.h:1289
Node representing a HTML table caption.
Definition docnode.h:1226
QCString anchor() const
Definition docnode.h:1233
QCString file() const
Definition docnode.h:1232
Node representing a HTML table cell.
Definition docnode.h:1191
const HtmlAttribList & attribs() const
Definition docnode.h:1203
Node representing a HTML description data.
Definition docnode.h:1179
Node representing a Html description list.
Definition docnode.h:901
Node representing a Html description item.
Definition docnode.h:888
Node Html details.
Definition docnode.h:857
const DocNodeVariant * summary() const
Definition docnode.h:864
Node Html heading.
Definition docnode.h:873
int level() const
Definition docnode.h:877
Node representing a Html list.
Definition docnode.h:1000
const HtmlAttribList & attribs() const
Definition docnode.h:1006
Type type() const
Definition docnode.h:1005
Node representing a HTML list item.
Definition docnode.h:1163
const HtmlAttribList & attribs() const
Definition docnode.h:1168
Node representing a HTML table row.
Definition docnode.h:1244
bool isHeading() const
Definition docnode.cpp:1954
size_t numCells() const
Definition docnode.h:1249
Node Html summary.
Definition docnode.h:844
Node representing a HTML table.
Definition docnode.h:1267
const DocNodeVariant * caption() const
Definition docnode.cpp:2202
Node representing an image.
Definition docnode.h:642
QCString name() const
Definition docnode.h:648
Type type() const
Definition docnode.h:647
bool isInlineImage() const
Definition docnode.h:654
bool hasCaption() const
Definition docnode.h:649
Node representing a include/dontinclude operator block.
Definition docnode.h:477
bool stripCodeComments() const
Definition docnode.h:506
bool isLast() const
Definition docnode.h:503
QCString includeFileName() const
Definition docnode.h:509
QCString text() const
Definition docnode.h:499
QCString context() const
Definition docnode.h:501
QCString exampleFile() const
Definition docnode.h:508
int line() const
Definition docnode.h:497
Type type() const
Definition docnode.h:485
bool isFirst() const
Definition docnode.h:502
bool showLineNo() const
Definition docnode.h:498
bool isExample() const
Definition docnode.h:507
Node representing an included text block from file.
Definition docnode.h:435
QCString blockId() const
Definition docnode.h:454
QCString extension() const
Definition docnode.h:450
bool stripCodeComments() const
Definition docnode.h:455
@ LatexInclude
Definition docnode.h:437
@ SnippetWithLines
Definition docnode.h:438
@ DontIncWithLines
Definition docnode.h:439
@ IncWithLines
Definition docnode.h:438
@ HtmlInclude
Definition docnode.h:437
@ VerbInclude
Definition docnode.h:437
@ DontInclude
Definition docnode.h:437
@ DocbookInclude
Definition docnode.h:439
Type type() const
Definition docnode.h:451
QCString exampleFile() const
Definition docnode.h:457
QCString text() const
Definition docnode.h:452
QCString file() const
Definition docnode.h:449
bool trimLeft() const
Definition docnode.h:459
bool isExample() const
Definition docnode.h:456
QCString context() const
Definition docnode.h:453
Node representing an entry in the index.
Definition docnode.h:552
QCString entry() const
Definition docnode.h:559
Node representing an internal section of documentation.
Definition docnode.h:969
Node representing an internal reference to some item.
Definition docnode.h:807
QCString file() const
Definition docnode.h:811
QCString anchor() const
Definition docnode.h:813
Node representing a line break.
Definition docnode.h:202
Node representing a word that can be linked to something.
Definition docnode.h:165
QCString file() const
Definition docnode.h:171
QCString ref() const
Definition docnode.h:173
QCString word() const
Definition docnode.h:170
QCString anchor() const
Definition docnode.h:174
Node representing a msc file.
Definition docnode.h:722
DocNodeVariant * parent()
Definition docnode.h:90
Node representing an block of paragraphs.
Definition docnode.h:979
Node representing a paragraph in the documentation tree.
Definition docnode.h:1080
bool isLast() const
Definition docnode.h:1088
Node representing a parameter list.
Definition docnode.h:1123
const DocNodeList & parameters() const
Definition docnode.h:1127
const DocNodeList & paramTypes() const
Definition docnode.h:1128
DocParamSect::Direction direction() const
Definition docnode.h:1131
const DocNodeList & paragraphs() const
Definition docnode.h:1129
Node representing a parameter section.
Definition docnode.h:1053
bool hasInOutSpecifier() const
Definition docnode.h:1069
bool hasTypeSpecifier() const
Definition docnode.h:1070
Type type() const
Definition docnode.h:1068
Node representing a uml file.
Definition docnode.h:740
Node representing a reference to some item.
Definition docnode.h:778
QCString anchor() const
Definition docnode.h:785
QCString targetTitle() const
Definition docnode.h:786
bool isSubPage() const
Definition docnode.h:792
QCString file() const
Definition docnode.h:782
QCString ref() const
Definition docnode.h:784
bool hasLinkText() const
Definition docnode.h:788
Root node of documentation tree.
Definition docnode.h:1311
bool singleLine() const
Definition docnode.h:1317
bool indent() const
Definition docnode.h:1316
Node representing a reference to a section.
Definition docnode.h:935
Node representing a list of section references.
Definition docnode.h:959
Node representing a normal section.
Definition docnode.h:914
QCString file() const
Definition docnode.h:922
int level() const
Definition docnode.h:918
QCString anchor() const
Definition docnode.h:920
const DocNodeVariant * title() const
Definition docnode.h:919
Node representing a separator.
Definition docnode.h:365
QCString chars() const
Definition docnode.h:369
Node representing a simple list.
Definition docnode.h:990
Node representing a simple list item.
Definition docnode.h:1151
const DocNodeVariant * paragraph() const
Definition docnode.h:1155
Node representing a simple section.
Definition docnode.h:1017
Type type() const
Definition docnode.h:1026
const DocNodeVariant * title() const
Definition docnode.h:1033
Node representing a separator between two simple sections of the same type.
Definition docnode.h:1044
Node representing a style change.
Definition docnode.h:268
Style style() const
Definition docnode.h:307
bool enable() const
Definition docnode.h:309
Node representing a special symbol.
Definition docnode.h:328
HtmlEntityMapper::SymType symbol() const
Definition docnode.h:332
Root node of a text fragment.
Definition docnode.h:1302
Node representing a simple section title.
Definition docnode.h:608
Node representing a URL (or email address).
Definition docnode.h:188
QCString url() const
Definition docnode.h:192
bool isEmail() const
Definition docnode.h:193
Node representing a verbatim, unparsed text fragment.
Definition docnode.h:376
QCString srcFile() const
Definition docnode.h:397
int srcLine() const
Definition docnode.h:398
bool hasCaption() const
Definition docnode.h:390
QCString language() const
Definition docnode.h:388
bool isExample() const
Definition docnode.h:385
QCString context() const
Definition docnode.h:384
Type type() const
Definition docnode.h:382
QCString text() const
Definition docnode.h:383
QCString exampleFile() const
Definition docnode.h:386
QCString engine() const
Definition docnode.h:393
@ JavaDocLiteral
Definition docnode.h:378
Node representing a VHDL flow chart.
Definition docnode.h:749
CodeParserInterface & getCodeParser(const QCString &langExt)
void pushHidden(bool hide)
bool popHidden()
Node representing some amount of white space.
Definition docnode.h:354
QCString chars() const
Definition docnode.h:358
Node representing a word.
Definition docnode.h:153
QCString word() const
Definition docnode.h:156
Node representing an item of a cross-referenced list.
Definition docnode.h:621
QCString anchor() const
Definition docnode.h:625
QCString file() const
Definition docnode.h:624
QCString title() const
Definition docnode.h:626
const char * unicode(int index) const
Access routine to the unicode sequence for the Emoji entity.
Definition emoji.cpp:2016
static EmojiEntityMapper & instance()
Returns the one and only instance of the Emoji entity mapper.
Definition emoji.cpp:1978
Minimal replacement for QFileInfo.
Definition fileinfo.h:23
std::string fileName() const
Definition fileinfo.cpp:118
std::string dirPath(bool absPath=true) const
Definition fileinfo.cpp:137
static HtmlEntityMapper & instance()
Returns the one and only instance of the HTML entity mapper.
const char * rtf(SymType symb) const
Access routine to the RTF code of the HTML entity.
Class representing a list of different code generators.
Definition outputlist.h:165
StringVector writePlantUMLSource(const QCString &outDirArg, const QCString &fileName, const QCString &content, OutputFormat format, const QCString &engine, const QCString &srcFile, int srcLine, bool inlineCode)
Write a PlantUML compatible file.
Definition plantuml.cpp:31
static PlantumlManager & instance()
Definition plantuml.cpp:231
void generatePlantUMLOutput(const QCString &baseName, const QCString &outDir, OutputFormat format)
Convert a PlantUML file to an image.
Definition plantuml.cpp:202
This is an alternative implementation of QCString.
Definition qcstring.h:101
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
bool startsWith(const char *s) const
Definition qcstring.h:507
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
const std::string & str() const
Definition qcstring.h:552
QCString & setNum(short n)
Definition qcstring.h:459
QCString right(size_t len) const
Definition qcstring.h:234
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:172
void startLink(const QCString &ref, const QCString &file, const QCString &anchor)
void filter(const QCString &str, bool verbatim=FALSE)
int indentLevel() const
void visitChildren(const T &t)
void includePicturePreRTF(const QCString &name, bool isTypeRTF, bool hasCaption, bool inlineImage=FALSE)
QCString m_langExt
void writeDotFile(const QCString &fileName, bool hasCaption, const QCString &srcFile, int srcLine, bool newFile=true)
void includePicturePostRTF(bool isTypeRTF, bool hasCaption, bool inlineImage=FALSE)
OutputCodeList & m_ci
RTFDocVisitor(TextStream &t, OutputCodeList &ci, const QCString &langExt, int hierarchyLevel=0)
QCString getStyle(const QCString &name)
void writePlantUMLFile(const QCString &fileName, bool hasCaption)
static const int maxIndentLevels
TextStream & m_t
QCString getListTable(const int id)
void writeMscFile(const QCString &fileName, bool hasCaption, const QCString &srcFile, int srcLine, bool newFile=true)
void endLink(const QCString &ref)
RTFListItemInfo m_listItemInfo[maxIndentLevels]
void operator()(const DocWord &)
void writeDiaFile(const QCString &fileName, bool hasCaption, const QCString &srcFile, int srcLine, bool newFile=true)
static constexpr int MaxLevel
Definition section.h:39
static constexpr int MinLevel
Definition section.h:32
Text streaming class that buffers data.
Definition textstream.h:36
#define Config_getBool(name)
Definition config.h:33
#define Config_getString(name)
Definition config.h:32
void writeDiaGraphFromFile(const QCString &inFile, const QCString &outDir, const QCString &outFile, DiaOutputFormat format, const QCString &srcFile, int srcLine)
Definition dia.cpp:26
void writeDotGraphFromFile(const QCString &inFile, const QCString &outDir, const QCString &outFile, GraphOutputFormat format, const QCString &srcFile, int srcLine)
Definition dot.cpp:230
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
Definition filedef.cpp:269
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:6959
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5191
QCString integerToRoman(int n, bool upper)
Definition util.cpp:6698
QCString stripPath(const QCString &s)
Definition util.cpp:4929
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:5530
SrcLangExt getLanguageFromCodeLang(QCString &fileName)
Routine to handle the language attribute of the \code command.
Definition util.cpp:5209
QCString integerToAlpha(int n, bool upper)
Definition util.cpp:6682
QCString getDotImageExtension()
Definition util.cpp:6289
QCString makeBaseName(const QCString &name, const QCString &ext)
Definition util.cpp:4945
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:5857
QCString getFileNameExtension(const QCString &fn)
Definition util.cpp:5233
A bunch of utility functions.