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
41//#define DBG_RTF(x) m_t << x
42#define DBG_RTF(x) do {} while(0)
43
44static QCString align(const DocHtmlCell &cell)
45{
46 for (const auto &attr : cell.attribs())
47 {
48 if (attr.name.lower()=="align")
49 {
50 if (attr.value.lower()=="center") return "\\qc ";
51 else if (attr.value.lower()=="right") return "\\qr ";
52 else return "";
53 }
54 }
55 return "";
56}
57
58static QCString makeBaseName(const QCString &name)
59{
60 QCString baseName = name;
61 int i = baseName.findRev('/');
62 if (i!=-1)
63 {
64 baseName=baseName.mid(i+1);
65 }
66 return baseName;
67}
68
70 const QCString &langExt, int hierarchyLevel)
71 : m_t(t), m_ci(ci), m_langExt(langExt), m_hierarchyLevel(hierarchyLevel)
72{
73}
74
76{
77 QCString n = name + QCString().setNum(indentLevel());
78 StyleData &sd = rtf_Style[n.str()];
79 return sd.reference();
80}
81
83{
84 for (int i=0 ; rtf_Table_Default[i].definition ; i++ )
85 {
86 if ((id == rtf_Table_Default[i].id) && (m_indentLevel == rtf_Table_Default[i].lvl))
87 {
88 return rtf_Table_Default[i].place;
89 }
90 }
91 ASSERT(0);
92 return "";
93}
94
96{
97 return std::min(m_indentLevel,maxIndentLevels-1);
98}
99
101{
104 {
105 err("Maximum indent level ({}) exceeded while generating RTF output!\n",maxIndentLevels-1);
106 }
107}
108
113
114 //------------------------------------
115 // visitor functions for leaf nodes
116 //--------------------------------------
117
119{
120 if (m_hide) return;
121 DBG_RTF("{\\comment RTFDocVisitor::visit(DocWord)}\n");
122 filter(w.word());
124}
125
127{
128 if (m_hide) return;
129 DBG_RTF("{\\comment RTFDocVisitor::visit(DocLinkedWord)}\n");
130 startLink(w.ref(),w.file(),w.anchor());
131 filter(w.word());
132 endLink(w.ref());
134}
135
137{
138 if (m_hide) return;
139 DBG_RTF("{\\comment RTFDocVisitor::visit(DocWhiteSpace)}\n");
140 if (m_insidePre)
141 {
142 m_t << w.chars();
143 }
144 else
145 {
146 m_t << " ";
147 }
149}
150
152{
153 if (m_hide) return;
154 DBG_RTF("{\\comment RTFDocVisitor::visit(DocSymbol)}\n");
155 const char *res = HtmlEntityMapper::instance().rtf(s.symbol());
156 if (res)
157 {
158 m_t << res;
159 }
160 else
161 {
162 err("RTF: non supported HTML-entity found: {}\n",HtmlEntityMapper::instance().html(s.symbol(),TRUE));
163 }
165}
166
168{
169 if (m_hide) return;
170 DBG_RTF("{\\comment RTFDocVisitor::visit(DocEmoji)}\n");
171 const char *res = EmojiEntityMapper::instance().unicode(s.index());
172 if (res)
173 {
174 const char *p = res;
175 int val = 0;
176 int val1 = 0;
177 while (*p)
178 {
179 switch(*p)
180 {
181 case '&': case '#': case 'x':
182 break;
183 case ';':
184 val1 = val;
185 val = 0xd800 + ( ( val1 - 0x10000 ) & 0xffc00 ) / 0x400 - 0x10000;
186 m_t << "\\u" << val << "?";
187 val = 0xdC00 + ( ( val1 - 0x10000 ) & 0x3ff ) - 0x10000 ;
188 m_t << "\\u" << val << "?";
189 val = 0;
190 break;
191 case '0': case '1': case '2': case '3': case '4':
192 case '5': case '6': case '7': case '8': case '9':
193 val = val * 16 + *p - '0';
194 break;
195 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
196 val = val * 16 + *p - 'a' + 10;
197 break;
198 }
199 p++;
200 }
201 }
202 else
203 {
204 m_t << s.name();
205 }
207}
208
210{
211 if (m_hide) return;
212 DBG_RTF("{\\comment RTFDocVisitor::visit(DocURL)}\n");
213 if (Config_getBool(RTF_HYPERLINKS))
214 {
215 m_t << "{\\field "
216 "{\\*\\fldinst "
217 "{ HYPERLINK \"";
218 if (u.isEmail()) m_t << "mailto:";
219 m_t << u.url();
220 m_t << "\" }"
221 "{}";
222 m_t << "}"
223 "{\\fldrslt "
224 "{\\cs37\\ul\\cf2 ";
225 filter(u.url());
226 m_t << "}"
227 "}"
228 "}\n";
229 }
230 else
231 {
232 m_t << "{\\f2 ";
233 filter(u.url());
234 m_t << "}";
235 }
237}
238
240{
241 if (m_hide) return;
242 DBG_RTF("{\\comment RTFDocVisitor::visit(DocLineBreak)}\n");
243 m_t << "\\par\n";
245}
246
248{
249 if (m_hide) return;
250 DBG_RTF("{\\comment RTFDocVisitor::visit(DocHorRuler)}\n");
251 m_t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}\n";
253}
254
256{
257 if (m_hide) return;
259 DBG_RTF("{\\comment RTFDocVisitor::visit(DocStyleChange)}\n");
260 switch (s.style())
261 {
263 if (s.enable()) m_t << "{\\b "; else m_t << "} ";
264 break;
268 if (s.enable()) m_t << "{\\strike "; else m_t << "} ";
269 break;
272 if (s.enable()) m_t << "{\\ul "; else m_t << "} ";
273 break;
275 if (s.enable()) m_t << "{\\i "; else m_t << "} ";
276 break;
280 if (s.enable()) m_t << "{\\f2 "; else m_t << "} ";
281 break;
283 if (s.enable()) m_t << "{\\sub "; else m_t << "} ";
284 break;
286 if (s.enable()) m_t << "{\\super "; else m_t << "} ";
287 break;
289 if (s.enable()) m_t << "{\\qc "; else m_t << "} ";
290 break;
292 if (s.enable()) m_t << "{\\sub "; else m_t << "} ";
293 break;
295 if (s.enable()) m_t << "{\\i "; else m_t << "} ";
296 break;
298 if (s.enable())
299 {
300 m_t << "{\n";
301 m_t << "\\par\n";
302 m_t << rtf_Style_Reset << getStyle("CodeExample");
304 }
305 else
306 {
308 m_t << "\\par";
309 m_t << "}\n";
310 }
312 break;
313 case DocStyleChange::Div: /* HTML only */ break;
314 case DocStyleChange::Span: /* HTML only */ break;
315 }
316}
317
319{
320 if (m_hide) return;
321 DBG_RTF("{\\comment RTFDocVisitor::visit(DocVerbatim)}\n");
322 QCString lang = m_langExt;
323 if (!s.language().isEmpty()) // explicit language setting
324 {
325 lang = s.language();
326 }
327 SrcLangExt langExt = getLanguageFromCodeLang(lang);
328 switch(s.type())
329 {
331 m_t << "{\n";
332 m_t << "\\par\n";
333 m_t << rtf_Style_Reset << getStyle("CodeExample");
334 getCodeParser(lang).parseCode(m_ci,s.context(),s.text(),langExt,
335 Config_getBool(STRIP_CODE_COMMENTS),
336 s.isExample(),s.exampleFile());
337 //m_t << "\\par\n";
338 m_t << "}\n";
339 break;
341 filter(s.text(),TRUE);
342 break;
344 m_t << "{\n";
345 m_t << "{\\f2 ";
346 filter(s.text(),TRUE);
347 m_t << "}";
348 m_t << "}\n";
349 break;
351 m_t << "{\n";
352 m_t << "\\par\n";
353 m_t << rtf_Style_Reset << getStyle("CodeExample");
354 filter(s.text(),TRUE);
355 //m_t << "\\par\n";
356 m_t << "}\n";
357 break;
359 m_t << s.text();
360 break;
366 /* nothing */
367 break;
368 case DocVerbatim::Dot:
369 {
370 static int dotindex = 1;
371 QCString fileName(4096, QCString::ExplicitSize);
372
373 fileName.sprintf("%s%d%s",
374 qPrint(Config_getString(RTF_OUTPUT)+"/inline_dotgraph_"),
375 dotindex++,
376 ".dot"
377 );
378 std::ofstream file = Portable::openOutputStream(fileName);
379 if (!file.is_open())
380 {
381 err("Could not open file {} for writing\n",qPrint(fileName));
382 }
383 else
384 {
385 QCString stext = s.text();
386 file.write( stext.data(), stext.length() );
387 file.close();
388 }
389
390 writeDotFile(fileName, s.hasCaption(), s.srcFile(), s.srcLine());
391 visitChildren(s);
393
394 if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName.str());
395 }
396 break;
397 case DocVerbatim::Msc:
398 {
399 static int mscindex = 1;
400 QCString baseName(4096, QCString::ExplicitSize);
401
402 baseName.sprintf("%s%d%s",
403 qPrint(Config_getString(RTF_OUTPUT)+"/inline_mscgraph_"),
404 mscindex++,
405 ".msc"
406 );
407 std::ofstream file = Portable::openOutputStream(baseName);
408 if (!file.is_open())
409 {
410 err("Could not open file {} for writing\n",qPrint(baseName));
411 }
412 QCString text = "msc {";
413 text+=s.text();
414 text+="}";
415 file.write( text.data(), text.length() );
416 file.close();
417
418 writeMscFile(baseName, s.hasCaption(), s.srcFile(), s.srcLine());
419 visitChildren(s);
421
422 if (Config_getBool(DOT_CLEANUP)) Dir().remove(baseName.str());
423 }
424 break;
426 {
427 QCString rtfOutput = Config_getString(RTF_OUTPUT);
430 s.engine(),s.srcFile(),s.srcLine(),true);
431
432 writePlantUMLFile(baseName, s.hasCaption());
433 visitChildren(s);
435 }
436 break;
437 }
439}
440
442{
443 if (m_hide) return;
444 DBG_RTF("{\\comment RTFDocVisitor::visit(DocAnchor)}\n");
445 QCString anchor;
446 if (!anc.file().isEmpty())
447 {
448 anchor+=stripPath(anc.file());
449 }
450 if (!anc.file().isEmpty() && !anc.anchor().isEmpty())
451 {
452 anchor+="_";
453 }
454 if (!anc.anchor().isEmpty())
455 {
456 anchor+=anc.anchor();
457 }
458 m_t << "{\\bkmkstart " << rtfFormatBmkStr(anchor) << "}\n";
459 m_t << "{\\bkmkend " << rtfFormatBmkStr(anchor) << "}\n";
461}
462
464{
465 if (m_hide) return;
467 DBG_RTF("{\\comment RTFDocVisitor::visit(DocInclude)}\n");
468 switch(inc.type())
469 {
471 {
472 m_t << "{\n";
473 m_t << "\\par\n";
474 m_t << rtf_Style_Reset << getStyle("CodeExample");
475 FileInfo cfi( inc.file().str() );
476 auto fd = createFileDef( cfi.dirPath(), cfi.fileName() );
478 inc.text(),
479 langExt,
480 inc.stripCodeComments(),
481 inc.isExample(),
482 inc.exampleFile(),
483 fd.get(), // fileDef,
484 -1, // start line
485 -1, // end line
486 FALSE, // inline fragment
487 nullptr, // memberDef
488 TRUE // show line numbers
489 );
490 m_t << "\\par";
491 m_t << "}\n";
492 }
493 break;
495 m_t << "{\n";
496 m_t << "\\par\n";
497 m_t << rtf_Style_Reset << getStyle("CodeExample");
499 inc.text(),langExt,
500 inc.stripCodeComments(),
501 inc.isExample(),
502 inc.exampleFile(),
503 nullptr, // fileDef
504 -1, // startLine
505 -1, // endLine
506 TRUE, // inlineFragment
507 nullptr, // memberDef
508 FALSE // show line numbers
509 );
510 m_t << "\\par";
511 m_t << "}\n";
512 break;
520 break;
522 m_t << inc.text();
523 break;
525 m_t << "{\n";
526 m_t << "\\par\n";
527 m_t << rtf_Style_Reset << getStyle("CodeExample");
528 filter(inc.text());
529 m_t << "\\par";
530 m_t << "}\n";
531 break;
534 m_t << "{\n";
535 if (!m_lastIsPara) m_t << "\\par\n";
536 m_t << rtf_Style_Reset << getStyle("CodeExample");
538 inc.file(),
539 inc.blockId(),
540 inc.context(),
542 inc.trimLeft(),
544 );
545 m_t << "}";
546 break;
547 }
549}
550
552{
553 //printf("DocIncOperator: type=%d first=%d, last=%d text='%s'\n",
554 // op.type(),op.isFirst(),op.isLast(),qPrint(op.text()));
555 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIncOperator)}\n");
557 if (locLangExt.isEmpty()) locLangExt = m_langExt;
558 SrcLangExt langExt = getLanguageFromFileName(locLangExt);
559 if (op.isFirst())
560 {
561 if (!m_hide)
562 {
563 m_t << "{\n";
564 m_t << "\\par\n";
565 m_t << rtf_Style_Reset << getStyle("CodeExample");
566 }
568 m_hide = TRUE;
569 }
570 if (op.type()!=DocIncOperator::Skip)
571 {
572 m_hide = popHidden();
573 if (!m_hide)
574 {
575 std::unique_ptr<FileDef> fd = nullptr;
576 if (!op.includeFileName().isEmpty())
577 {
578 FileInfo cfi( op.includeFileName().str() );
579 fd = createFileDef( cfi.dirPath(), cfi.fileName() );
580 }
581
582 getCodeParser(locLangExt).parseCode(m_ci,op.context(),op.text(),langExt,
584 op.isExample(),op.exampleFile(),
585 fd.get(), // fileDef
586 op.line(), // startLine
587 -1, // endLine
588 FALSE, // inline fragment
589 nullptr, // memberDef
590 op.showLineNo() // show line numbers
591 );
592 }
594 m_hide=TRUE;
595 }
596 if (op.isLast())
597 {
598 m_hide = popHidden();
599 if (!m_hide)
600 {
601 m_t << "\\par";
602 m_t << "}\n";
603 }
605 }
606 else
607 {
608 if (!m_hide) m_t << "\n";
610 }
611}
612
614{
615 if (m_hide) return;
616 DBG_RTF("{\\comment RTFDocVisitor::visit(DocFormula)}\n");
617 bool bDisplay = !f.isInline();
618 if (bDisplay)
619 {
620 m_t << "\\par";
621 m_t << "{";
622 m_t << "\\pard\\plain";
623 m_t << "\\pard";
624 m_t << "\\qc";
625 }
626 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"" << f.relPath() << f.name() << ".png\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}";
627 if (bDisplay)
628 {
629 m_t << "\\par}";
630 }
632}
633
635{
636 if (m_hide) return;
637 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIndexEntry)}\n");
638 m_t << "{\\xe \\v " << i.entry() << "}\n";
640}
641
645
647{
648 if (m_hide) return;
649 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocCite &)}\n");
650 if (!cite.file().isEmpty())
651 {
652 startLink(cite.ref(),cite.file(),cite.anchor());
653 }
654 else
655 {
656 m_t << "{\\b ";
657 }
658 filter(cite.text());
659 if (!cite.file().isEmpty())
660 {
661 endLink(cite.ref());
662 }
663 else
664 {
665 m_t << "}";
666 }
667}
668
669
670//--------------------------------------
671// visitor functions for compound nodes
672//--------------------------------------
673
675{
676 if (m_hide) return;
677 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoList &)}\n");
678 m_t << "{\n";
679 int level = indentLevel();
680 m_listItemInfo[level].isEnum = l.isEnumList();
681 m_listItemInfo[level].isCheck = l.isCheckedList();
682 m_listItemInfo[level].type = '1';
683 m_listItemInfo[level].number = 1;
685 visitChildren(l);
686 if (!m_lastIsPara) m_t << "\\par";
687 m_t << "}\n";
689 if (!l.isCheckedList() && indentLevel()==0) m_t << "\\par\n";
690}
691
693{
694 static int prevLevel = -1;
695 if (m_hide) return;
696 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoListItem &)}\n");
697 int level = indentLevel();
698 if ((level != prevLevel-1) &&
699 (!(level==prevLevel && level != 0 && m_listItemInfo[level].isCheck)) &&
700 (!m_lastIsPara))
701 m_t << "\\par\n";
702 prevLevel= level;
704 if (m_listItemInfo[level].isEnum)
705 {
706 m_t << getStyle("ListEnum") << "\n";
707 m_t << m_listItemInfo[level].number << ".\\tab ";
708 m_listItemInfo[level].number++;
709 }
710 else
711 {
712 switch (li.itemNumber())
713 {
714 case DocAutoList::Unchecked: // unchecked
715 m_t << getListTable(2) << "\n";
716 break;
717 case DocAutoList::Checked_x: // checked with x
718 case DocAutoList::Checked_X: // checked with X
719 m_t << getListTable(3) << "\n";
720 break;
721 default:
722 m_t << getListTable(1) << "\n";
723 break;
724 }
725 }
727 m_lastIsPara=false;
728 visitChildren(li);
730}
731
733{
734 if (m_hide) return;
735 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPara &)}\n");
736 visitChildren(p);
737 if (!m_lastIsPara &&
738 !p.isLast() && // omit <p> for last paragraph
739 !(p.parent() && // and for parameters & sections
740 std::get_if<DocParamSect>(p.parent())
741 )
742 )
743 {
744 m_t << "\\par\n";
746 }
747}
748
750{
751 if (m_hide) return;
752 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRoot &)}\n");
753 if (r.indent()) incIndentLevel();
754 m_t << "{" << rtf_Style["BodyText"].reference() << "\n";
755 visitChildren(r);
756 if (!m_lastIsPara && !r.singleLine()) m_t << "\\par\n";
757 m_t << "}";
759 if (r.indent()) decIndentLevel();
760}
761
763{
764 if (m_hide) return;
765 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
766 if (!m_lastIsPara) m_t << "\\par\n";
767 m_t << "{"; // start desc
768 //m_t << "{\\b "; // start bold
769 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
770 switch(s.type())
771 {
773 m_t << theTranslator->trSeeAlso(); break;
775 m_t << theTranslator->trReturns(); break;
777 m_t << theTranslator->trAuthor(TRUE,TRUE); break;
779 m_t << theTranslator->trAuthor(TRUE,FALSE); break;
781 m_t << theTranslator->trVersion(); break;
783 m_t << theTranslator->trSince(); break;
785 m_t << theTranslator->trDate(); break;
787 m_t << theTranslator->trNote(); break;
789 m_t << theTranslator->trWarning(); break;
791 m_t << theTranslator->trPrecondition(); break;
793 m_t << theTranslator->trPostcondition(); break;
795 m_t << theTranslator->trCopyright(); break;
797 m_t << theTranslator->trInvariant(); break;
799 m_t << theTranslator->trRemarks(); break;
801 m_t << theTranslator->trAttention(); break;
803 m_t << theTranslator->trImportant(); break;
804 case DocSimpleSect::User: break;
805 case DocSimpleSect::Rcs: break;
806 case DocSimpleSect::Unknown: break;
807 }
808
811 {
812 m_t << "\\par";
813 m_t << "}"; // end bold
814 m_t << rtf_Style_Reset << getStyle("DescContinue");
815 m_t << "{\\s17 \\sa60 \\sb30\n";
816 }
817 else
818 {
819 if (s.title())
820 {
821 std::visit(*this,*s.title());
822 }
823 m_t << "\\par\n";
824 m_t << "}"; // end bold
825 m_t << rtf_Style_Reset << getStyle("DescContinue");
826 }
828 visitChildren(s);
829 if (!m_lastIsPara) m_t << "\\par\n";
832 {
833 m_t << "}"; // end DescContinue
834 }
835 m_t << "}"; // end desc
837}
838
840{
841 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocTitle &)}\n");
842 if (m_hide) return;
843 visitChildren(t);
844}
845
847{
848 if (m_hide) return;
849 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
850 m_t << "{\n";
851 m_listItemInfo[indentLevel()].isEnum = false;
852 m_listItemInfo[indentLevel()].isCheck = false;
854 visitChildren(l);
855 if (!m_lastIsPara) m_t << "\\par\n";
856 m_t << "}\n";
858}
859
861{
862 if (m_hide) return;
863 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleListItem &)}\n");
864 m_t << "\\par" << rtf_Style_Reset << getStyle("ListBullet") << "\n";
867 if (li.paragraph())
868 {
869 std::visit(*this,*li.paragraph());
870 }
872 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSimpleListItem)}\n");
873}
874
876{
877 if (m_hide) return;
878 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSection &)}\n");
879 if (!m_lastIsPara) m_t << "\\par\n";
880 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
881 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
882 m_t << "{{" // start section
884 QCString heading;
885 int level = std::min(s.level()+2+m_hierarchyLevel,4);
886 if (level <= 0)
887 level = 1;
888 heading.sprintf("Heading%d",level);
889 // set style
890 m_t << rtf_Style[heading.str()].reference() << "\n";
891 // make table of contents entry
892 if (s.title())
893 {
894 std::visit(*this,*s.title());
895 }
896 m_t << "\n\\par" << "}\n";
897 m_t << "{\\tc\\tcl" << level << " \\v ";
898 if (s.title())
899 {
900 std::visit(*this,*s.title());
901 }
902 m_t << "}\n";
904 visitChildren(s);
905 m_t << "\\par}\n"; // end section
907}
908
910{
911 if (m_hide) return;
912 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlList &)}\n");
913 m_t << "{\n";
914 int level = indentLevel();
915 m_listItemInfo[level].isEnum = l.type()==DocHtmlList::Ordered;
916 m_listItemInfo[level].isCheck = false;
917 m_listItemInfo[level].number = 1;
918 m_listItemInfo[level].type = '1';
919 for (const auto &opt : l.attribs())
920 {
921 if (opt.name=="type")
922 {
923 m_listItemInfo[level].type = opt.value[0];
924 }
925 if (opt.name=="start")
926 {
927 bool ok = false;
928 int val = opt.value.toInt(&ok);
929 if (ok) m_listItemInfo[level].number = val;
930 }
931 }
933 visitChildren(l);
934 m_t << "\\par" << "}\n";
936}
937
939{
940 if (m_hide) return;
941 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlListItem &)}\n");
942 m_t << "\\par\n";
944 int level = indentLevel();
945 if (m_listItemInfo[level].isEnum)
946 {
947 for (const auto &opt : l.attribs())
948 {
949 if (opt.name=="value")
950 {
951 bool ok = false;
952 int val = opt.value.toInt(&ok);
953 if (ok) m_listItemInfo[level].number = val;
954 }
955 }
956 m_t << getStyle("ListEnum") << "\n";
957 switch (m_listItemInfo[level].type)
958 {
959 case '1':
960 m_t << m_listItemInfo[level].number;
961 break;
962 case 'a':
963 m_t << integerToAlpha(m_listItemInfo[level].number,false);
964 break;
965 case 'A':
966 m_t << integerToAlpha(m_listItemInfo[level].number);
967 break;
968 case 'i':
969 m_t << integerToRoman(m_listItemInfo[level].number,false);
970 break;
971 case 'I':
972 m_t << integerToRoman(m_listItemInfo[level].number);
973 break;
974 default:
975 m_t << m_listItemInfo[level].number;
976 break;
977 }
978 m_t << ".\\tab ";
979 m_listItemInfo[level].number++;
980 }
981 else
982 {
983 m_t << getStyle("ListBullet") << "\n";
984 }
987 visitChildren(l);
989 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlListItem)}\n");
990}
991
993{
994 if (m_hide) return;
995 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescList &)}\n");
996 //m_t << "{\n";
997 //m_t << rtf_Style_Reset << getStyle("ListContinue");
998 //m_lastIsPara=FALSE;
999 visitChildren(dl);
1000 //m_t << "}\n";
1001 //m_t << "\\par\n";
1002 //m_lastIsPara=TRUE;
1003}
1004
1006{
1007 if (m_hide) return;
1008 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescTitle &)}\n");
1009 //m_t << "\\par\n";
1010 //m_t << "{\\b ";
1011 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1013 visitChildren(dt);
1014 m_t << "\\par\n";
1015 m_t << "}\n";
1017}
1018
1020{
1021 if (m_hide) return;
1022 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescData &)}\n");
1024 m_t << "{" << rtf_Style_Reset << getStyle("DescContinue");
1025 visitChildren(dd);
1026 m_t << "\\par";
1027 m_t << "}\n";
1030}
1031
1033{
1034 if (m_hide) return;
1035 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlTable &)}\n");
1036 if (!m_lastIsPara) m_t << "\\par\n";
1038 if (t.caption())
1039 {
1040 const DocHtmlCaption &c = std::get<DocHtmlCaption>(*t.caption());
1041 m_t << "\\pard \\qc \\b";
1042 if (!c.file().isEmpty())
1043 {
1044 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1045 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1046 }
1047 m_t << "{Table \\field\\flddirty{\\*\\fldinst { SEQ Table \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1048 std::visit(*this,*t.caption());
1049 }
1050 visitChildren(t);
1051 m_t << "\\pard\\plain\n";
1052 m_t << "\\par\n";
1054}
1055
1057{
1058 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCaption &)}\n");
1059 visitChildren(c);
1060 m_t << "}\n\\par\n";
1061}
1062
1064{
1065 if (m_hide) return;
1066 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlRow &)}\n");
1067 size_t columnWidth=r.numCells()>0 ? rtf_pageWidth/r.numCells() : 10;
1068 m_t << "\\trowd \\trgaph108\\trleft-108"
1069 "\\trbrdrt\\brdrs\\brdrw10 "
1070 "\\trbrdrl\\brdrs\\brdrw10 "
1071 "\\trbrdrb\\brdrs\\brdrw10 "
1072 "\\trbrdrr\\brdrs\\brdrw10 "
1073 "\\trbrdrh\\brdrs\\brdrw10 "
1074 "\\trbrdrv\\brdrs\\brdrw10 \n";
1075 for (size_t i=0;i<r.numCells();i++)
1076 {
1077 if (r.isHeading())
1078 {
1079 m_t << "\\clcbpat16"; // set cell shading to light grey (color 16 in the clut)
1080 }
1081 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10 "
1082 "\\clbrdrl\\brdrs\\brdrw10 "
1083 "\\clbrdrb\\brdrs\\brdrw10 "
1084 "\\clbrdrr \\brdrs\\brdrw10 "
1085 "\\cltxlrtb "
1086 "\\cellx" << ((i+1)*columnWidth) << "\n";
1087 }
1088 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1090 visitChildren(r);
1091 m_t << "\n";
1092 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1093 m_t << "{\\row }\n";
1095}
1096
1098{
1099 if (m_hide) return;
1100 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCell &)}\n");
1101 m_t << "{" << align(c);
1103 visitChildren(c);
1104 m_t << "\\cell }";
1106}
1107
1109{
1110 if (m_hide) return;
1111 visitChildren(i);
1112}
1113
1115{
1116 if (m_hide) return;
1117 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHRef &)}\n");
1118 if (Config_getBool(RTF_HYPERLINKS))
1119 {
1120 if (href.url().startsWith("#"))
1121 {
1122 // when starting with # so a local link
1123 QCString cite;
1124 cite = href.file() + "_" + href.url().right(href.url().length()-1);
1125 m_t << "{\\field "
1126 "{\\*\\fldinst "
1127 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(cite) << "\" "
1128 "}{}"
1129 "}"
1130 "{\\fldrslt "
1131 "{\\cs37\\ul\\cf2 ";
1132 }
1133 else
1134 {
1135 m_t << "{\\field "
1136 "{\\*\\fldinst "
1137 "{ HYPERLINK \"" << href.url() << "\" "
1138 "}{}"
1139 "}"
1140 "{\\fldrslt "
1141 "{\\cs37\\ul\\cf2 ";
1142 }
1143 }
1144 else
1145 {
1146 m_t << "{\\f2 ";
1147 }
1149 visitChildren(href);
1150 if (Config_getBool(RTF_HYPERLINKS))
1151 {
1152 m_t << "}"
1153 "}"
1154 "}";
1155 }
1156 else
1157 {
1158 m_t << "}";
1159 }
1161}
1162
1164{
1165 if (m_hide) return;
1166 m_t << "{\\b ";
1167 visitChildren(s);
1168 m_t << "}\\par ";
1169}
1170
1172{
1173 if (m_hide) return;
1174 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDetails &)}\n");
1175 if (!m_lastIsPara) m_t << "\\par\n";
1176 auto summary = d.summary();
1177 if (summary)
1178 {
1179 std::visit(*this,*summary);
1180 m_t << "{"; // start desc
1182 m_t << rtf_Style_Reset << getStyle("DescContinue");
1183 }
1184 visitChildren(d);
1185 if (!m_lastIsPara) m_t << "\\par\n";
1186 if (summary)
1187 {
1189 m_t << "}"; // end desc
1190 }
1192}
1193
1195{
1196 if (m_hide) return;
1197 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlHeader &)}\n");
1198 m_t << "{" // start section
1199 << rtf_Style_Reset;
1200 QCString heading;
1201 int level = std::clamp(header.level()+m_hierarchyLevel,SectionType::MinLevel,SectionType::MaxLevel);
1202 heading.sprintf("Heading%d",level);
1203 // set style
1204 m_t << rtf_Style[heading.str()].reference();
1205 // make open table of contents entry that will be closed in visitPost method
1206 m_t << "{\\tc\\tcl" << level << " ";
1208 visitChildren(header);
1209 // close open table of contents entry
1210 m_t << "} \\par";
1211 m_t << "}\n"; // end section
1213}
1214
1215void RTFDocVisitor::includePicturePreRTF(const QCString &name, bool isTypeRTF, bool hasCaption, bool inlineImage)
1216{
1217 if (isTypeRTF)
1218 {
1219 if (!inlineImage)
1220 {
1221 m_t << "\\par\n";
1222 m_t << "{\n";
1223 m_t << rtf_Style_Reset << "\n";
1224 if (hasCaption || m_lastIsPara) m_t << "\\par\n";
1225 m_t << "\\pard \\qc ";
1226 }
1227 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"";
1228 m_t << name;
1229 m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}\n";
1230 if (!inlineImage)
1231 {
1232 m_t << "\\par\n";
1233 if (hasCaption)
1234 {
1235 m_t << "\\pard \\qc \\b";
1236 m_t << "{Image \\field\\flddirty{\\*\\fldinst { SEQ Image \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1237 }
1239 }
1240 else
1241 {
1242 if (hasCaption) m_t << "{\\comment "; // to prevent caption to be shown
1243 }
1244 }
1245 else // other format -> skip
1246 {
1248 m_hide=TRUE;
1249 }
1250}
1251
1252void RTFDocVisitor::includePicturePostRTF(bool isTypeRTF, bool hasCaption, bool inlineImage)
1253{
1254 if (isTypeRTF)
1255 {
1256 if (m_hide) return;
1257 if (inlineImage)
1258 {
1259 if (hasCaption) m_t << " }";
1260 }
1261 else
1262 {
1263 if (hasCaption)
1264 {
1265 m_t << "}\n";
1266 m_t << "\\par}\n";
1267 }
1268 else
1269 {
1270 m_t << "}\n";
1271 }
1272 }
1273 }
1274 else
1275 {
1276 m_hide = popHidden();
1277 }
1278}
1279
1281{
1282 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocImage &)}\n");
1284 visitChildren(img);
1286}
1287
1288
1290{
1291 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDotFile &)}\n");
1292 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1293 writeDotFile(df);
1294 visitChildren(df);
1296}
1298{
1299 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocMscFile &)}\n");
1300 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1301 writeMscFile(df);
1302 visitChildren(df);
1304}
1305
1307{
1308 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDiaFile &)}\n");
1309 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1310 writeDiaFile(df);
1311 visitChildren(df);
1313}
1314
1316{
1317 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPlantUmlFile &)}\n");
1318 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1319 QCString rtfOutput = Config_getString(RTF_OUTPUT);
1320 std::string inBuf;
1321 readInputFile(df.file(),inBuf);
1323 rtfOutput,QCString(),inBuf.c_str(),PlantumlManager::PUML_BITMAP,
1324 QCString(),df.srcFile(),df.srcLine(),false);
1325 writePlantUMLFile(baseName, df.hasCaption());
1326 visitChildren(df);
1328}
1329
1331{
1332 if (m_hide) return;
1333 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocLink &)}\n");
1334 startLink(lnk.ref(),lnk.file(),lnk.anchor());
1335 visitChildren(lnk);
1336 endLink(lnk.ref());
1337}
1338
1340{
1341 if (m_hide) return;
1342 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRef &)}\n");
1343 // when ref.isSubPage()==TRUE we use ref.file() for HTML and
1344 // ref.anchor() for LaTeX/RTF
1345 if (ref.isSubPage())
1346 {
1347 startLink(ref.ref(),QCString(),ref.anchor());
1348 }
1349 else
1350 {
1351 if (!ref.file().isEmpty()) startLink(ref.ref(),ref.file(),ref.anchor());
1352 }
1353 if (!ref.hasLinkText()) filter(ref.targetTitle());
1354 visitChildren(ref);
1355 if (!ref.file().isEmpty()) endLink(ref.ref());
1356 //m_t << " ";
1357}
1358
1359
1361{
1362 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefItem &)}\n");
1363 visitChildren(ref);
1364}
1365
1367{
1368 if (m_hide) return;
1369 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefList &)}\n");
1370 m_t << "{\n";
1372 m_t << rtf_Style_Reset << getStyle("LatexTOC") << "\n";
1373 m_t << "\\par\n";
1375 visitChildren(l);
1377 m_t << "\\par";
1378 m_t << "}\n";
1380}
1381
1383{
1384 if (m_hide) return;
1385 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamSect &)}\n");
1386 m_t << "{"; // start param list
1387 if (!m_lastIsPara) m_t << "\\par\n";
1388 //m_t << "{\\b "; // start bold
1389 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1390 switch(s.type())
1391 {
1393 m_t << theTranslator->trParameters(); break;
1395 m_t << theTranslator->trReturnValues(); break;
1397 m_t << theTranslator->trExceptions(); break;
1399 m_t << theTranslator->trTemplateParameters(); break;
1400 default:
1401 ASSERT(0);
1402 }
1403 m_t << "\\par";
1404 m_t << "}\n";
1405 bool useTable = s.type()==DocParamSect::Param ||
1409 if (!useTable)
1410 {
1412 }
1413 m_t << rtf_Style_Reset << getStyle("DescContinue");
1415 visitChildren(s);
1416 //m_t << "\\par\n";
1417 if (!useTable)
1418 {
1420 }
1421 m_t << "}\n";
1422}
1423
1425{
1426 m_t << " " << sep.chars() << " ";
1427}
1428
1430{
1431 static int columnPos[4][5] =
1432 { { 2, 25, 100, 100, 100 }, // no inout, no type
1433 { 3, 14, 35, 100, 100 }, // inout, no type
1434 { 3, 25, 50, 100, 100 }, // no inout, type
1435 { 4, 14, 35, 55, 100 }, // inout, type
1436 };
1437 int config=0;
1438 if (m_hide) return;
1439 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamList &)}\n");
1440
1442 const DocParamSect *sect = std::get_if<DocParamSect>(pl.parent());
1443 if (sect)
1444 {
1445 parentType = sect->type();
1446 }
1447 bool useTable = parentType==DocParamSect::Param ||
1448 parentType==DocParamSect::RetVal ||
1449 parentType==DocParamSect::Exception ||
1450 parentType==DocParamSect::TemplateParam;
1451 if (sect && sect->hasInOutSpecifier()) config+=1;
1452 if (sect && sect->hasTypeSpecifier()) config+=2;
1453 if (useTable)
1454 {
1455 m_t << "\\trowd \\trgaph108\\trleft426\\tblind426"
1456 "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1457 "\\trbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1458 "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1459 "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 "
1460 "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 "
1461 "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< "\n";
1462 for (int i=0;i<columnPos[config][0];i++)
1463 {
1464 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1465 "\\clbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1466 "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1467 "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 "
1468 "\\cltxlrtb "
1469 "\\cellx" << (rtf_pageWidth*columnPos[config][i+1]/100) << "\n";
1470 }
1471 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1472 }
1473
1474 if (sect && sect->hasInOutSpecifier())
1475 {
1476 if (useTable)
1477 {
1478 m_t << "{";
1479 }
1480
1481 // Put in the direction: in/out/in,out if specified.
1483 {
1484 if (pl.direction()==DocParamSect::In)
1485 {
1486 m_t << "in";
1487 }
1488 else if (pl.direction()==DocParamSect::Out)
1489 {
1490 m_t << "out";
1491 }
1492 else if (pl.direction()==DocParamSect::InOut)
1493 {
1494 m_t << "in,out";
1495 }
1496 }
1497
1498 if (useTable)
1499 {
1500 m_t << "\\cell }";
1501 }
1502 }
1503
1504 if (sect && sect->hasTypeSpecifier())
1505 {
1506 if (useTable)
1507 {
1508 m_t << "{";
1509 }
1510 for (const auto &type : pl.paramTypes())
1511 {
1512 std::visit(*this,type);
1513 }
1514 if (useTable)
1515 {
1516 m_t << "\\cell }";
1517 }
1518 }
1519
1520
1521 if (useTable)
1522 {
1523 m_t << "{";
1524 }
1525
1526 m_t << "{\\i ";
1527 bool first=TRUE;
1528 for (const auto &param : pl.parameters())
1529 {
1530 if (!first) m_t << ","; else first=FALSE;
1531 std::visit(*this,param);
1532 }
1533 m_t << "} ";
1534
1535 if (useTable)
1536 {
1537 m_t << "\\cell }{";
1538 }
1540
1541 for (const auto &par : pl.paragraphs())
1542 {
1543 std::visit(*this,par);
1544 }
1545
1546 if (useTable)
1547 {
1548 m_t << "\\cell }\n";
1549 //m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1550 m_t << "{\\row }\n";
1551 }
1552 else
1553 {
1554 m_t << "\\par\n";
1555 }
1556
1558}
1559
1561{
1562 if (m_hide) return;
1563 if (x.title().isEmpty()) return;
1564 bool anonymousEnum = x.file()=="@";
1565 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocXRefItem &)}\n");
1566 if (!m_lastIsPara)
1567 {
1568 m_t << "\\par\n";
1570 }
1571 m_t << "{"; // start param list
1572 //m_t << "{\\b "; // start bold
1573 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1574 if (Config_getBool(RTF_HYPERLINKS) && !anonymousEnum)
1575 {
1576 QCString refName;
1577 if (!x.file().isEmpty())
1578 {
1579 refName+=stripPath(x.file());
1580 }
1581 if (!x.file().isEmpty() && !x.anchor().isEmpty())
1582 {
1583 refName+="_";
1584 }
1585 if (!x.anchor().isEmpty())
1586 {
1587 refName+=x.anchor();
1588 }
1589
1590 m_t << "{\\field "
1591 "{\\*\\fldinst "
1592 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(refName) << "\" "
1593 "}{}"
1594 "}"
1595 "{\\fldrslt "
1596 "{\\cs37\\ul\\cf2 ";
1597 filter(x.title());
1598 m_t << "}"
1599 "}"
1600 "}";
1601 }
1602 else
1603 {
1604 filter(x.title());
1605 }
1606 m_t << ":";
1607 m_t << "\\par";
1608 m_t << "}"; // end bold
1610 m_t << rtf_Style_Reset << getStyle("DescContinue");
1612 visitChildren(x);
1613 if (x.title().isEmpty()) return;
1614 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocXRefItem)}\n");
1615 m_t << "\\par\n";
1617 m_t << "}\n"; // end xref item
1619}
1620
1622{
1623 if (m_hide) return;
1624 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocInternalRef &)}\n");
1625 startLink("",ref.file(),ref.anchor());
1626 visitChildren(ref);
1627 endLink("");
1628 m_t << " ";
1629}
1630
1632{
1633 if (m_hide) return;
1634 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocText &)}\n");
1635 visitChildren(t);
1636}
1637
1639{
1640 if (m_hide) return;
1641 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlBlockQuote &)}\n");
1642 if (!m_lastIsPara) m_t << "\\par\n";
1643 m_t << "{"; // start desc
1645 m_t << rtf_Style_Reset << getStyle("DescContinue");
1646 visitChildren(q);
1647 if (!m_lastIsPara) m_t << "\\par\n";
1649 m_t << "}"; // end desc
1651}
1652
1654{
1655}
1656
1658{
1659 if (m_hide) return;
1660 visitChildren(pb);
1661}
1662
1663
1664//static char* getMultiByte(int c)
1665//{
1666// static char s[10];
1667// sprintf(s,"\\'%X",c);
1668// return s;
1669//}
1670
1671void RTFDocVisitor::filter(const QCString &str,bool verbatim)
1672{
1673 if (!str.isEmpty())
1674 {
1675 const char *p=str.data();
1676 while (*p)
1677 {
1678 char c=*p++;
1679 switch (c)
1680 {
1681 case '{': m_t << "\\{"; break;
1682 case '}': m_t << "\\}"; break;
1683 case '\\': m_t << "\\\\"; break;
1684 case '\n': if (verbatim)
1685 {
1686 m_t << "\\par\n";
1687 }
1688 else
1689 {
1690 m_t << '\n';
1691 }
1692 break;
1693 default: m_t << c;
1694 }
1695 }
1696 }
1697}
1698
1699void RTFDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)
1700{
1701 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1702 {
1703 QCString refName;
1704 if (!file.isEmpty())
1705 {
1706 refName+=stripPath(file);
1707 }
1708 if (!file.isEmpty() && !anchor.isEmpty())
1709 {
1710 refName+='_';
1711 }
1712 if (!anchor.isEmpty())
1713 {
1714 refName+=anchor;
1715 }
1716
1717 m_t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \"";
1718 m_t << rtfFormatBmkStr(refName);
1719 m_t << "\" }{}";
1720 m_t << "}{\\fldrslt {\\cs37\\ul\\cf2 ";
1721 }
1722 else
1723 {
1724 m_t << "{\\b ";
1725 }
1727}
1728
1730{
1731 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1732 {
1733 m_t << "}}}";
1734 }
1735 else
1736 {
1737 m_t << "}";
1738 }
1740}
1741
1743{
1744 writeDotFile(df.file(), df.hasCaption(), df.srcFile(), df.srcLine());
1745}
1746void RTFDocVisitor::writeDotFile(const QCString &filename, bool hasCaption,
1747 const QCString &srcFile, int srcLine)
1748{
1749 QCString baseName=makeBaseName(filename);
1750 QCString outDir = Config_getString(RTF_OUTPUT);
1751 writeDotGraphFromFile(filename,outDir,baseName,GraphOutputFormat::BITMAP,srcFile,srcLine);
1752 QCString imgExt = getDotImageExtension();
1753 includePicturePreRTF(baseName + "." + imgExt, true, hasCaption);
1754}
1755
1757{
1758 writeMscFile(df.file(), df.hasCaption(), df.srcFile(), df.srcLine());
1759}
1760void RTFDocVisitor::writeMscFile(const QCString &fileName, bool hasCaption,
1761 const QCString &srcFile, int srcLine)
1762{
1763 QCString baseName=makeBaseName(fileName);
1764 QCString outDir = Config_getString(RTF_OUTPUT);
1765 writeMscGraphFromFile(fileName,outDir,baseName,MscOutputFormat::BITMAP,srcFile,srcLine);
1766 includePicturePreRTF(baseName + ".png", true, hasCaption);
1767}
1768
1770{
1771 QCString baseName=makeBaseName(df.file());
1772 QCString outDir = Config_getString(RTF_OUTPUT);
1773 writeDiaGraphFromFile(df.file(),outDir,baseName,DiaOutputFormat::BITMAP,df.srcFile(),df.srcLine());
1774 includePicturePreRTF(baseName + ".png", true, df.hasCaption());
1775}
1776
1777void RTFDocVisitor::writePlantUMLFile(const QCString &fileName, bool hasCaption)
1778{
1779 QCString baseName=makeBaseName(fileName);
1780 QCString outDir = Config_getString(RTF_OUTPUT);
1782 includePicturePreRTF(baseName + ".png", true, hasCaption);
1783}
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, bool isExampleBlock, const QCString &exampleName=QCString(), const FileDef *fileDef=nullptr, int startLine=-1, int endLine=-1, bool inlineFragment=FALSE, const MemberDef *memberDef=nullptr, bool showLineNumbers=TRUE, const Definition *searchCtx=nullptr, bool collectXRefs=TRUE)=0
Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
Class representing a directory in the file system.
Definition dir.h:75
bool remove(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:314
Node representing an anchor.
Definition docnode.h:228
QCString anchor() const
Definition docnode.h:231
QCString file() const
Definition docnode.h:232
Node representing an auto List.
Definition docnode.h:567
bool isCheckedList() const
Definition docnode.h:578
bool isEnumList() const
Definition docnode.h:576
Node representing an item of a auto list.
Definition docnode.h:591
int itemNumber() const
Definition docnode.h:594
Node representing a citation of some bibliographic reference.
Definition docnode.h:244
QCString text() const
Definition docnode.h:251
QCString anchor() const
Definition docnode.h:250
QCString ref() const
Definition docnode.h:249
QCString file() const
Definition docnode.h:247
Node representing a dia file.
Definition docnode.h:726
QCString srcFile() const
Definition docnode.h:686
QCString file() const
Definition docnode.h:680
int srcLine() const
Definition docnode.h:687
bool hasCaption() const
Definition docnode.h:682
Node representing a dot file.
Definition docnode.h:708
Node representing an emoji.
Definition docnode.h:337
int index() const
Definition docnode.h:341
QCString name() const
Definition docnode.h:340
Node representing an item of a cross-referenced list.
Definition docnode.h:525
QCString name() const
Definition docnode.h:528
bool isInline() const
Definition docnode.h:532
QCString relPath() const
Definition docnode.h:530
Node representing a Hypertext reference.
Definition docnode.h:818
QCString url() const
Definition docnode.h:825
QCString file() const
Definition docnode.h:826
Node representing a horizontal ruler.
Definition docnode.h:215
Node representing an HTML blockquote.
Definition docnode.h:1286
Node representing a HTML table caption.
Definition docnode.h:1223
QCString anchor() const
Definition docnode.h:1230
QCString file() const
Definition docnode.h:1229
Node representing a HTML table cell.
Definition docnode.h:1188
const HtmlAttribList & attribs() const
Definition docnode.h:1200
Node representing a HTML description data.
Definition docnode.h:1176
Node representing a Html description list.
Definition docnode.h:896
Node representing a Html description item.
Definition docnode.h:883
Node Html details.
Definition docnode.h:852
const DocNodeVariant * summary() const
Definition docnode.h:859
Node Html heading.
Definition docnode.h:868
int level() const
Definition docnode.h:872
Node representing a Html list.
Definition docnode.h:995
const HtmlAttribList & attribs() const
Definition docnode.h:1001
Type type() const
Definition docnode.h:1000
Node representing a HTML list item.
Definition docnode.h:1160
const HtmlAttribList & attribs() const
Definition docnode.h:1165
Node representing a HTML table row.
Definition docnode.h:1241
bool isHeading() const
Definition docnode.cpp:1898
size_t numCells() const
Definition docnode.h:1246
Node Html summary.
Definition docnode.h:839
Node representing a HTML table.
Definition docnode.h:1264
const DocNodeVariant * caption() const
Definition docnode.cpp:2044
Node representing an image.
Definition docnode.h:637
QCString name() const
Definition docnode.h:643
Type type() const
Definition docnode.h:642
bool isInlineImage() const
Definition docnode.h:649
bool hasCaption() const
Definition docnode.h:644
Node representing a include/dontinclude operator block.
Definition docnode.h:473
bool stripCodeComments() const
Definition docnode.h:502
bool isLast() const
Definition docnode.h:499
QCString includeFileName() const
Definition docnode.h:505
QCString text() const
Definition docnode.h:495
QCString context() const
Definition docnode.h:497
QCString exampleFile() const
Definition docnode.h:504
int line() const
Definition docnode.h:493
Type type() const
Definition docnode.h:481
bool isFirst() const
Definition docnode.h:498
bool showLineNo() const
Definition docnode.h:494
bool isExample() const
Definition docnode.h:503
Node representing an included text block from file.
Definition docnode.h:431
QCString blockId() const
Definition docnode.h:450
QCString extension() const
Definition docnode.h:446
bool stripCodeComments() const
Definition docnode.h:451
@ LatexInclude
Definition docnode.h:433
@ SnippetWithLines
Definition docnode.h:434
@ DontIncWithLines
Definition docnode.h:435
@ IncWithLines
Definition docnode.h:434
@ HtmlInclude
Definition docnode.h:433
@ VerbInclude
Definition docnode.h:433
@ DontInclude
Definition docnode.h:433
@ DocbookInclude
Definition docnode.h:435
Type type() const
Definition docnode.h:447
QCString exampleFile() const
Definition docnode.h:453
QCString text() const
Definition docnode.h:448
QCString file() const
Definition docnode.h:445
bool trimLeft() const
Definition docnode.h:455
bool isExample() const
Definition docnode.h:452
QCString context() const
Definition docnode.h:449
Node representing an entry in the index.
Definition docnode.h:548
QCString entry() const
Definition docnode.h:555
Node representing an internal section of documentation.
Definition docnode.h:964
Node representing an internal reference to some item.
Definition docnode.h:802
QCString file() const
Definition docnode.h:806
QCString anchor() const
Definition docnode.h:808
Node representing a line break.
Definition docnode.h:201
Node representing a word that can be linked to something.
Definition docnode.h:164
QCString file() const
Definition docnode.h:170
QCString ref() const
Definition docnode.h:172
QCString word() const
Definition docnode.h:169
QCString anchor() const
Definition docnode.h:173
Node representing a msc file.
Definition docnode.h:717
DocNodeVariant * parent()
Definition docnode.h:89
Node representing an block of paragraphs.
Definition docnode.h:974
Node representing a paragraph in the documentation tree.
Definition docnode.h:1075
bool isLast() const
Definition docnode.h:1083
Node representing a parameter list.
Definition docnode.h:1120
const DocNodeList & parameters() const
Definition docnode.h:1124
const DocNodeList & paramTypes() const
Definition docnode.h:1125
DocParamSect::Direction direction() const
Definition docnode.h:1128
const DocNodeList & paragraphs() const
Definition docnode.h:1126
Node representing a parameter section.
Definition docnode.h:1048
bool hasInOutSpecifier() const
Definition docnode.h:1064
bool hasTypeSpecifier() const
Definition docnode.h:1065
Type type() const
Definition docnode.h:1063
Node representing a uml file.
Definition docnode.h:735
Node representing a reference to some item.
Definition docnode.h:773
QCString anchor() const
Definition docnode.h:780
QCString targetTitle() const
Definition docnode.h:781
bool isSubPage() const
Definition docnode.h:787
QCString file() const
Definition docnode.h:777
QCString ref() const
Definition docnode.h:779
bool hasLinkText() const
Definition docnode.h:783
Root node of documentation tree.
Definition docnode.h:1308
bool singleLine() const
Definition docnode.h:1314
bool indent() const
Definition docnode.h:1313
Node representing a reference to a section.
Definition docnode.h:930
Node representing a list of section references.
Definition docnode.h:954
Node representing a normal section.
Definition docnode.h:909
QCString file() const
Definition docnode.h:917
int level() const
Definition docnode.h:913
QCString anchor() const
Definition docnode.h:915
const DocNodeVariant * title() const
Definition docnode.h:914
Node representing a separator.
Definition docnode.h:361
QCString chars() const
Definition docnode.h:365
Node representing a simple list.
Definition docnode.h:985
Node representing a simple list item.
Definition docnode.h:1148
const DocNodeVariant * paragraph() const
Definition docnode.h:1152
Node representing a simple section.
Definition docnode.h:1012
Type type() const
Definition docnode.h:1021
const DocNodeVariant * title() const
Definition docnode.h:1028
Node representing a separator between two simple sections of the same type.
Definition docnode.h:1039
Node representing a style change.
Definition docnode.h:264
Style style() const
Definition docnode.h:303
bool enable() const
Definition docnode.h:305
Node representing a special symbol.
Definition docnode.h:324
HtmlEntityMapper::SymType symbol() const
Definition docnode.h:328
Root node of a text fragment.
Definition docnode.h:1299
Node representing a simple section title.
Definition docnode.h:604
Node representing a URL (or email address)
Definition docnode.h:187
QCString url() const
Definition docnode.h:191
bool isEmail() const
Definition docnode.h:192
Node representing a verbatim, unparsed text fragment.
Definition docnode.h:372
QCString srcFile() const
Definition docnode.h:393
int srcLine() const
Definition docnode.h:394
bool hasCaption() const
Definition docnode.h:386
QCString language() const
Definition docnode.h:384
bool isExample() const
Definition docnode.h:381
QCString context() const
Definition docnode.h:380
Type type() const
Definition docnode.h:378
QCString text() const
Definition docnode.h:379
QCString exampleFile() const
Definition docnode.h:382
QCString engine() const
Definition docnode.h:389
@ JavaDocLiteral
Definition docnode.h:374
Node representing a VHDL flow chart.
Definition docnode.h:744
CodeParserInterface & getCodeParser(const QCString &langExt)
void pushHidden(bool hide)
bool popHidden()
Node representing some amount of white space.
Definition docnode.h:350
QCString chars() const
Definition docnode.h:354
Node representing a word.
Definition docnode.h:152
QCString word() const
Definition docnode.h:155
Node representing an item of a cross-referenced list.
Definition docnode.h:616
QCString anchor() const
Definition docnode.h:620
QCString file() const
Definition docnode.h:619
QCString title() const
Definition docnode.h:621
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:164
QCString 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:28
static PlantumlManager & instance()
Definition plantuml.cpp:157
void generatePlantUMLOutput(const QCString &baseName, const QCString &outDir, OutputFormat format)
Convert a PlantUML file to an image.
Definition plantuml.cpp:128
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:153
bool startsWith(const char *s) const
Definition qcstring.h:492
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:226
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
const std::string & str() const
Definition qcstring.h:537
QCString & setNum(short n)
Definition qcstring.h:444
QCString right(size_t len) const
Definition qcstring.h:219
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
@ ExplicitSize
Definition qcstring.h:133
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:91
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:159
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 writeDotFile(const QCString &fileName, bool hasCaption, const QCString &srcFile, int srcLine)
void includePicturePreRTF(const QCString &name, bool isTypeRTF, bool hasCaption, bool inlineImage=FALSE)
QCString m_langExt
void writeDiaFile(const DocDiaFile &)
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 writeMscFile(const QCString &fileName, bool hasCaption, const QCString &srcFile, int srcLine)
TextStream & m_t
QCString getListTable(const int id)
void endLink(const QCString &ref)
RTFListItemInfo m_listItemInfo[maxIndentLevels]
void operator()(const DocWord &)
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
static QCString makeBaseName(const QCString &name)
void writeDotGraphFromFile(const QCString &inFile, const QCString &outDir, const QCString &outFile, GraphOutputFormat format, const QCString &srcFile, int srcLine)
Definition dot.cpp:230
std::unique_ptr< FileDef > createFileDef(const QCString &p, const QCString &n, const QCString &ref, const QCString &dn)
Definition filedef.cpp:268
Translator * theTranslator
Definition language.cpp:71
#define err(fmt,...)
Definition message.h:127
void writeMscGraphFromFile(const QCString &inFile, const QCString &outDir, const QCString &outFile, MscOutputFormat format, const QCString &srcFile, int srcLine)
Definition msc.cpp:157
std::ofstream openOutputStream(const QCString &name, bool append=false)
Definition portable.cpp:665
Portable versions of functions that are platform dependent.
const char * qPrint(const char *s)
Definition qcstring.h:672
#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)
static QCString makeBaseName(const QCString &name)
#define DBG_RTF(x)
QCString rtfFormatBmkStr(const QCString &name)
Definition rtfgen.cpp:2870
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
const char * reference() const
Definition rtfstyle.h:69
SrcLangExt
Definition types.h:207
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5721
QCString integerToRoman(int n, bool upper)
Definition util.cpp:7175
QCString stripPath(const QCString &s)
Definition util.cpp:5464
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:6013
SrcLangExt getLanguageFromCodeLang(QCString &fileName)
Routine to handle the language attribute of the \code command.
Definition util.cpp:5739
QCString integerToAlpha(int n, bool upper)
Definition util.cpp:7159
QCString getDotImageExtension()
Definition util.cpp:6766
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:6336
QCString getFileNameExtension(const QCString &fn)
Definition util.cpp:5763
A bunch of utility functions.