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
42//#define DBG_RTF(x) m_t << x
43#define DBG_RTF(x) do {} while(0)
44
45static QCString align(const DocHtmlCell &cell)
46{
47 for (const auto &attr : cell.attribs())
48 {
49 if (attr.name.lower()=="align")
50 {
51 if (attr.value.lower()=="center") return "\\qc ";
52 else if (attr.value.lower()=="right") return "\\qr ";
53 else return "";
54 }
55 }
56 return "";
57}
58
59static QCString makeBaseName(const QCString &name)
60{
61 QCString baseName = name;
62 int i = baseName.findRev('/');
63 if (i!=-1)
64 {
65 baseName=baseName.mid(i+1);
66 }
67 return baseName;
68}
69
71 const QCString &langExt, int hierarchyLevel)
72 : m_t(t), m_ci(ci), m_langExt(langExt), m_hierarchyLevel(hierarchyLevel)
73{
74}
75
77{
78 QCString n = name + QCString().setNum(indentLevel());
79 StyleData &sd = rtf_Style[n.str()];
80 return sd.reference();
81}
82
84{
85 for (int i=0 ; rtf_Table_Default[i].definition ; i++ )
86 {
87 if ((id == rtf_Table_Default[i].id) && (m_indentLevel == rtf_Table_Default[i].lvl))
88 {
89 return rtf_Table_Default[i].place;
90 }
91 }
92 ASSERT(0);
93 return "";
94}
95
97{
98 return std::min(m_indentLevel,maxIndentLevels-1);
99}
100
102{
105 {
106 err("Maximum indent level ({}) exceeded while generating RTF output!\n",maxIndentLevels-1);
107 }
108}
109
114
115 //------------------------------------
116 // visitor functions for leaf nodes
117 //--------------------------------------
118
120{
121 if (m_hide) return;
122 DBG_RTF("{\\comment RTFDocVisitor::visit(DocWord)}\n");
123 filter(w.word());
125}
126
128{
129 if (m_hide) return;
130 DBG_RTF("{\\comment RTFDocVisitor::visit(DocLinkedWord)}\n");
131 startLink(w.ref(),w.file(),w.anchor());
132 filter(w.word());
133 endLink(w.ref());
135}
136
138{
139 if (m_hide) return;
140 DBG_RTF("{\\comment RTFDocVisitor::visit(DocWhiteSpace)}\n");
141 if (m_insidePre)
142 {
143 m_t << w.chars();
144 }
145 else
146 {
147 m_t << " ";
148 }
150}
151
153{
154 if (m_hide) return;
155 DBG_RTF("{\\comment RTFDocVisitor::visit(DocSymbol)}\n");
156 const char *res = HtmlEntityMapper::instance().rtf(s.symbol());
157 if (res)
158 {
159 m_t << res;
160 }
161 else
162 {
163 err("RTF: non supported HTML-entity found: {}\n",HtmlEntityMapper::instance().html(s.symbol(),TRUE));
164 }
166}
167
169{
170 if (m_hide) return;
171 DBG_RTF("{\\comment RTFDocVisitor::visit(DocEmoji)}\n");
172 const char *res = EmojiEntityMapper::instance().unicode(s.index());
173 if (res)
174 {
175 const char *p = res;
176 int val = 0;
177 int val1 = 0;
178 while (*p)
179 {
180 switch(*p)
181 {
182 case '&': case '#': case 'x':
183 break;
184 case ';':
185 val1 = val;
186 val = 0xd800 + ( ( val1 - 0x10000 ) & 0xffc00 ) / 0x400 - 0x10000;
187 m_t << "\\u" << val << "?";
188 val = 0xdC00 + ( ( val1 - 0x10000 ) & 0x3ff ) - 0x10000 ;
189 m_t << "\\u" << val << "?";
190 val = 0;
191 break;
192 case '0': case '1': case '2': case '3': case '4':
193 case '5': case '6': case '7': case '8': case '9':
194 val = val * 16 + *p - '0';
195 break;
196 case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
197 val = val * 16 + *p - 'a' + 10;
198 break;
199 }
200 p++;
201 }
202 }
203 else
204 {
205 m_t << s.name();
206 }
208}
209
211{
212 if (m_hide) return;
213 DBG_RTF("{\\comment RTFDocVisitor::visit(DocURL)}\n");
214 if (Config_getBool(RTF_HYPERLINKS))
215 {
216 m_t << "{\\field "
217 "{\\*\\fldinst "
218 "{ HYPERLINK \"";
219 if (u.isEmail()) m_t << "mailto:";
220 m_t << u.url();
221 m_t << "\" }"
222 "{}";
223 m_t << "}"
224 "{\\fldrslt "
225 "{\\cs37\\ul\\cf2 ";
226 filter(u.url());
227 m_t << "}"
228 "}"
229 "}\n";
230 }
231 else
232 {
233 m_t << "{\\f2 ";
234 filter(u.url());
235 m_t << "}";
236 }
238}
239
241{
242 if (m_hide) return;
243 DBG_RTF("{\\comment RTFDocVisitor::visit(DocLineBreak)}\n");
244 m_t << "\\par\n";
246}
247
249{
250 if (m_hide) return;
251 DBG_RTF("{\\comment RTFDocVisitor::visit(DocHorRuler)}\n");
252 m_t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}\n";
254}
255
257{
258 if (m_hide) return;
260 DBG_RTF("{\\comment RTFDocVisitor::visit(DocStyleChange)}\n");
261 switch (s.style())
262 {
264 if (s.enable()) m_t << "{\\b "; else m_t << "} ";
265 break;
269 if (s.enable()) m_t << "{\\strike "; else m_t << "} ";
270 break;
273 if (s.enable()) m_t << "{\\ul "; else m_t << "} ";
274 break;
276 if (s.enable()) m_t << "{\\i "; else m_t << "} ";
277 break;
281 if (s.enable()) m_t << "{\\f2 "; else m_t << "} ";
282 break;
284 if (s.enable()) m_t << "{\\sub "; else m_t << "} ";
285 break;
287 if (s.enable()) m_t << "{\\super "; else m_t << "} ";
288 break;
290 if (s.enable()) m_t << "{\\qc "; else m_t << "} ";
291 break;
293 if (s.enable()) m_t << "{\\sub "; else m_t << "} ";
294 break;
296 if (s.enable()) m_t << "{\\i "; else m_t << "} ";
297 break;
299 if (s.enable())
300 {
301 m_t << "{\n";
302 m_t << "\\par\n";
303 m_t << rtf_Style_Reset << getStyle("CodeExample");
305 }
306 else
307 {
309 m_t << "\\par";
310 m_t << "}\n";
311 }
313 break;
314 case DocStyleChange::Div: /* HTML only */ break;
315 case DocStyleChange::Span: /* HTML only */ break;
316 }
317}
318
320{
321 if (m_hide) return;
322 DBG_RTF("{\\comment RTFDocVisitor::visit(DocVerbatim)}\n");
323 QCString lang = m_langExt;
324 if (!s.language().isEmpty()) // explicit language setting
325 {
326 lang = s.language();
327 }
328 SrcLangExt langExt = getLanguageFromCodeLang(lang);
329 switch(s.type())
330 {
332 m_t << "{\n";
333 m_t << "\\par\n";
334 m_t << rtf_Style_Reset << getStyle("CodeExample");
335 getCodeParser(lang).parseCode(m_ci,s.context(),s.text(),langExt,
336 Config_getBool(STRIP_CODE_COMMENTS),
337 s.isExample(),s.exampleFile());
338 //m_t << "\\par\n";
339 m_t << "}\n";
340 break;
342 filter(s.text(),TRUE);
343 break;
345 m_t << "{\n";
346 m_t << "{\\f2 ";
347 filter(s.text(),TRUE);
348 m_t << "}";
349 m_t << "}\n";
350 break;
352 m_t << "{\n";
353 m_t << "\\par\n";
354 m_t << rtf_Style_Reset << getStyle("CodeExample");
355 filter(s.text(),TRUE);
356 //m_t << "\\par\n";
357 m_t << "}\n";
358 break;
360 m_t << s.text();
361 break;
367 /* nothing */
368 break;
369 case DocVerbatim::Dot:
370 {
371 static int dotindex = 1;
372 QCString fileName(4096, QCString::ExplicitSize);
373
374 fileName.sprintf("%s%d%s",
375 qPrint(Config_getString(RTF_OUTPUT)+"/inline_dotgraph_"),
376 dotindex++,
377 ".dot"
378 );
379 std::ofstream file = Portable::openOutputStream(fileName);
380 if (!file.is_open())
381 {
382 err("Could not open file {} for writing\n",qPrint(fileName));
383 }
384 else
385 {
386 QCString stext = s.text();
387 file.write( stext.data(), stext.length() );
388 file.close();
389 }
390
391 writeDotFile(fileName, s.hasCaption(), s.srcFile(), s.srcLine());
392 visitChildren(s);
394
395 if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName.str());
396 }
397 break;
398 case DocVerbatim::Msc:
399 {
400 static int mscindex = 1;
401 QCString baseName(4096, QCString::ExplicitSize);
402
403 baseName.sprintf("%s%d%s",
404 qPrint(Config_getString(RTF_OUTPUT)+"/inline_mscgraph_"),
405 mscindex++,
406 ".msc"
407 );
408 std::ofstream file = Portable::openOutputStream(baseName);
409 if (!file.is_open())
410 {
411 err("Could not open file {} for writing\n",qPrint(baseName));
412 }
413 QCString text = "msc {";
414 text+=s.text();
415 text+="}";
416 file.write( text.data(), text.length() );
417 file.close();
418
419 writeMscFile(baseName, s.hasCaption(), s.srcFile(), s.srcLine());
420 visitChildren(s);
422
423 if (Config_getBool(DOT_CLEANUP)) Dir().remove(baseName.str());
424 }
425 break;
427 {
428 QCString rtfOutput = Config_getString(RTF_OUTPUT);
429 auto baseNameVector = PlantumlManager::instance().writePlantUMLSource(
431 s.engine(),s.srcFile(),s.srcLine(),true);
432
433 for (const auto &baseName: baseNameVector)
434 {
435 writePlantUMLFile(QCString(baseName), s.hasCaption());
436 visitChildren(s);
438 }
439 }
440 break;
441 }
443}
444
446{
447 if (m_hide) return;
448 DBG_RTF("{\\comment RTFDocVisitor::visit(DocAnchor)}\n");
449 QCString anchor;
450 if (!anc.file().isEmpty())
451 {
452 anchor+=stripPath(anc.file());
453 }
454 if (!anc.file().isEmpty() && !anc.anchor().isEmpty())
455 {
456 anchor+="_";
457 }
458 if (!anc.anchor().isEmpty())
459 {
460 anchor+=anc.anchor();
461 }
462 m_t << "{\\bkmkstart " << rtfFormatBmkStr(anchor) << "}\n";
463 m_t << "{\\bkmkend " << rtfFormatBmkStr(anchor) << "}\n";
465}
466
468{
469 if (m_hide) return;
471 DBG_RTF("{\\comment RTFDocVisitor::visit(DocInclude)}\n");
472 switch(inc.type())
473 {
475 {
476 m_t << "{\n";
477 m_t << "\\par\n";
478 m_t << rtf_Style_Reset << getStyle("CodeExample");
479 FileInfo cfi( inc.file().str() );
480 auto fd = createFileDef( cfi.dirPath(), cfi.fileName() );
482 inc.text(),
483 langExt,
484 inc.stripCodeComments(),
485 inc.isExample(),
486 inc.exampleFile(),
487 fd.get(), // fileDef,
488 -1, // start line
489 -1, // end line
490 FALSE, // inline fragment
491 nullptr, // memberDef
492 TRUE // show line numbers
493 );
494 m_t << "\\par";
495 m_t << "}\n";
496 }
497 break;
499 m_t << "{\n";
500 m_t << "\\par\n";
501 m_t << rtf_Style_Reset << getStyle("CodeExample");
503 inc.text(),langExt,
504 inc.stripCodeComments(),
505 inc.isExample(),
506 inc.exampleFile(),
507 nullptr, // fileDef
508 -1, // startLine
509 -1, // endLine
510 TRUE, // inlineFragment
511 nullptr, // memberDef
512 FALSE // show line numbers
513 );
514 m_t << "\\par";
515 m_t << "}\n";
516 break;
524 break;
526 m_t << inc.text();
527 break;
529 m_t << "{\n";
530 m_t << "\\par\n";
531 m_t << rtf_Style_Reset << getStyle("CodeExample");
532 filter(inc.text());
533 m_t << "\\par";
534 m_t << "}\n";
535 break;
538 m_t << "{\n";
539 if (!m_lastIsPara) m_t << "\\par\n";
540 m_t << rtf_Style_Reset << getStyle("CodeExample");
542 inc.file(),
543 inc.blockId(),
544 inc.context(),
546 inc.trimLeft(),
548 );
549 m_t << "}";
550 break;
551 }
553}
554
556{
557 //printf("DocIncOperator: type=%d first=%d, last=%d text='%s'\n",
558 // op.type(),op.isFirst(),op.isLast(),qPrint(op.text()));
559 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIncOperator)}\n");
561 if (locLangExt.isEmpty()) locLangExt = m_langExt;
562 SrcLangExt langExt = getLanguageFromFileName(locLangExt);
563 if (op.isFirst())
564 {
565 if (!m_hide)
566 {
567 m_t << "{\n";
568 m_t << "\\par\n";
569 m_t << rtf_Style_Reset << getStyle("CodeExample");
570 }
572 m_hide = TRUE;
573 }
574 if (op.type()!=DocIncOperator::Skip)
575 {
576 m_hide = popHidden();
577 if (!m_hide)
578 {
579 std::unique_ptr<FileDef> fd = nullptr;
580 if (!op.includeFileName().isEmpty())
581 {
582 FileInfo cfi( op.includeFileName().str() );
583 fd = createFileDef( cfi.dirPath(), cfi.fileName() );
584 }
585
586 getCodeParser(locLangExt).parseCode(m_ci,op.context(),op.text(),langExt,
588 op.isExample(),op.exampleFile(),
589 fd.get(), // fileDef
590 op.line(), // startLine
591 -1, // endLine
592 FALSE, // inline fragment
593 nullptr, // memberDef
594 op.showLineNo() // show line numbers
595 );
596 }
598 m_hide=TRUE;
599 }
600 if (op.isLast())
601 {
602 m_hide = popHidden();
603 if (!m_hide)
604 {
605 m_t << "\\par";
606 m_t << "}\n";
607 }
609 }
610 else
611 {
612 if (!m_hide) m_t << "\n";
614 }
615}
616
618{
619 if (m_hide) return;
620 DBG_RTF("{\\comment RTFDocVisitor::visit(DocFormula)}\n");
621 bool bDisplay = !f.isInline();
622 if (bDisplay)
623 {
624 m_t << "\\par";
625 m_t << "{";
626 m_t << "\\pard\\plain";
627 m_t << "\\pard";
628 m_t << "\\qc";
629 }
630 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"" << f.relPath() << f.name() << ".png\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}";
631 if (bDisplay)
632 {
633 m_t << "\\par}";
634 }
636}
637
639{
640 if (m_hide) return;
641 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIndexEntry)}\n");
642 m_t << "{\\xe \\v " << i.entry() << "}\n";
644}
645
649
651{
652 if (m_hide) return;
653 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocCite &)}\n");
654 auto opt = cite.option();
655 if (!cite.file().isEmpty())
656 {
657 if (!opt.noCite()) startLink(cite.ref(),cite.file(),cite.anchor());
658
659 filter(cite.getText());
660
661 if (!opt.noCite()) endLink(cite.ref());
662 }
663 else
664 {
665 m_t << "{\\b";
666 if (!opt.noPar()) filter("[");
667 filter(cite.target());
668 if (!opt.noPar()) filter("]");
669 m_t << "}";
670 }
671}
672
673
674//--------------------------------------
675// visitor functions for compound nodes
676//--------------------------------------
677
679{
680 if (m_hide) return;
681 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoList &)}\n");
682 m_t << "{\n";
683 int level = indentLevel();
684 m_listItemInfo[level].isEnum = l.isEnumList();
685 m_listItemInfo[level].isCheck = l.isCheckedList();
686 m_listItemInfo[level].type = '1';
687 m_listItemInfo[level].number = 1;
689 visitChildren(l);
690 if (!m_lastIsPara) m_t << "\\par";
691 m_t << "}\n";
693 if (!l.isCheckedList() && indentLevel()==0) m_t << "\\par\n";
694}
695
697{
698 static int prevLevel = -1;
699 if (m_hide) return;
700 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoListItem &)}\n");
701 int level = indentLevel();
702 if ((level != prevLevel-1) &&
703 (!(level==prevLevel && level != 0 && m_listItemInfo[level].isCheck)) &&
704 (!m_lastIsPara))
705 m_t << "\\par\n";
706 prevLevel= level;
708 if (m_listItemInfo[level].isEnum)
709 {
710 m_t << getStyle("ListEnum") << "\n";
711 m_t << m_listItemInfo[level].number << ".\\tab ";
712 m_listItemInfo[level].number++;
713 }
714 else
715 {
716 switch (li.itemNumber())
717 {
718 case DocAutoList::Unchecked: // unchecked
719 m_t << getListTable(2) << "\n";
720 break;
721 case DocAutoList::Checked_x: // checked with x
722 case DocAutoList::Checked_X: // checked with X
723 m_t << getListTable(3) << "\n";
724 break;
725 default:
726 m_t << getListTable(1) << "\n";
727 break;
728 }
729 }
731 m_lastIsPara=false;
732 visitChildren(li);
734}
735
737{
738 if (m_hide) return;
739 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPara &)}\n");
740 visitChildren(p);
741 if (!m_lastIsPara &&
742 !p.isLast() && // omit <p> for last paragraph
743 !(p.parent() && // and for parameters & sections
744 std::get_if<DocParamSect>(p.parent())
745 )
746 )
747 {
748 m_t << "\\par\n";
750 }
751}
752
754{
755 if (m_hide) return;
756 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRoot &)}\n");
757 if (r.indent()) incIndentLevel();
758 m_t << "{" << rtf_Style["BodyText"].reference() << "\n";
759 visitChildren(r);
760 if (!m_lastIsPara && !r.singleLine()) m_t << "\\par\n";
761 m_t << "}";
763 if (r.indent()) decIndentLevel();
764}
765
767{
768 if (m_hide) return;
769 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
770 if (!m_lastIsPara) m_t << "\\par\n";
771 m_t << "{"; // start desc
772 //m_t << "{\\b "; // start bold
773 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
774 switch(s.type())
775 {
777 m_t << theTranslator->trSeeAlso(); break;
779 m_t << theTranslator->trReturns(); break;
781 m_t << theTranslator->trAuthor(TRUE,TRUE); break;
783 m_t << theTranslator->trAuthor(TRUE,FALSE); break;
785 m_t << theTranslator->trVersion(); break;
787 m_t << theTranslator->trSince(); break;
789 m_t << theTranslator->trDate(); break;
791 m_t << theTranslator->trNote(); break;
793 m_t << theTranslator->trWarning(); break;
795 m_t << theTranslator->trPrecondition(); break;
797 m_t << theTranslator->trPostcondition(); break;
799 m_t << theTranslator->trCopyright(); break;
801 m_t << theTranslator->trInvariant(); break;
803 m_t << theTranslator->trRemarks(); break;
805 m_t << theTranslator->trAttention(); break;
807 m_t << theTranslator->trImportant(); break;
808 case DocSimpleSect::User: break;
809 case DocSimpleSect::Rcs: break;
810 case DocSimpleSect::Unknown: break;
811 }
812
815 {
816 m_t << "\\par";
817 m_t << "}"; // end bold
818 m_t << rtf_Style_Reset << getStyle("DescContinue");
819 m_t << "{\\s17 \\sa60 \\sb30\n";
820 }
821 else
822 {
823 if (s.title())
824 {
825 std::visit(*this,*s.title());
826 }
827 m_t << "\\par\n";
828 m_t << "}"; // end bold
829 m_t << rtf_Style_Reset << getStyle("DescContinue");
830 }
832 visitChildren(s);
833 if (!m_lastIsPara) m_t << "\\par\n";
836 {
837 m_t << "}"; // end DescContinue
838 }
839 m_t << "}"; // end desc
841}
842
844{
845 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocTitle &)}\n");
846 if (m_hide) return;
847 visitChildren(t);
848}
849
851{
852 if (m_hide) return;
853 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
854 m_t << "{\n";
855 m_listItemInfo[indentLevel()].isEnum = false;
856 m_listItemInfo[indentLevel()].isCheck = false;
858 visitChildren(l);
859 if (!m_lastIsPara) m_t << "\\par\n";
860 m_t << "}\n";
862}
863
865{
866 if (m_hide) return;
867 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleListItem &)}\n");
868 m_t << "\\par" << rtf_Style_Reset << getStyle("ListBullet") << "\n";
871 if (li.paragraph())
872 {
873 std::visit(*this,*li.paragraph());
874 }
876 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSimpleListItem)}\n");
877}
878
880{
881 if (m_hide) return;
882 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSection &)}\n");
883 if (!m_lastIsPara) m_t << "\\par\n";
884 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
885 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
886 m_t << "{{" // start section
888 QCString heading;
889 int level = std::min(s.level()+2+m_hierarchyLevel,4);
890 if (level <= 0)
891 level = 1;
892 heading.sprintf("Heading%d",level);
893 // set style
894 m_t << rtf_Style[heading.str()].reference() << "\n";
895 // make table of contents entry
896 if (s.title())
897 {
898 std::visit(*this,*s.title());
899 }
900 m_t << "\n\\par" << "}\n";
901 m_t << "{\\tc\\tcl" << level << " \\v ";
902 if (s.title())
903 {
904 std::visit(*this,*s.title());
905 }
906 m_t << "}\n";
908 visitChildren(s);
909 m_t << "\\par}\n"; // end section
911}
912
914{
915 if (m_hide) return;
916 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlList &)}\n");
917 m_t << "{\n";
918 int level = indentLevel();
919 m_listItemInfo[level].isEnum = l.type()==DocHtmlList::Ordered;
920 m_listItemInfo[level].isCheck = false;
921 m_listItemInfo[level].number = 1;
922 m_listItemInfo[level].type = '1';
923 for (const auto &opt : l.attribs())
924 {
925 if (opt.name=="type")
926 {
927 m_listItemInfo[level].type = opt.value[0];
928 }
929 if (opt.name=="start")
930 {
931 bool ok = false;
932 int val = opt.value.toInt(&ok);
933 if (ok) m_listItemInfo[level].number = val;
934 }
935 }
937 visitChildren(l);
938 m_t << "\\par" << "}\n";
940}
941
943{
944 if (m_hide) return;
945 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlListItem &)}\n");
946 m_t << "\\par\n";
948 int level = indentLevel();
949 if (m_listItemInfo[level].isEnum)
950 {
951 for (const auto &opt : l.attribs())
952 {
953 if (opt.name=="value")
954 {
955 bool ok = false;
956 int val = opt.value.toInt(&ok);
957 if (ok) m_listItemInfo[level].number = val;
958 }
959 }
960 m_t << getStyle("ListEnum") << "\n";
961 switch (m_listItemInfo[level].type)
962 {
963 case '1':
964 m_t << m_listItemInfo[level].number;
965 break;
966 case 'a':
967 m_t << integerToAlpha(m_listItemInfo[level].number,false);
968 break;
969 case 'A':
970 m_t << integerToAlpha(m_listItemInfo[level].number);
971 break;
972 case 'i':
973 m_t << integerToRoman(m_listItemInfo[level].number,false);
974 break;
975 case 'I':
976 m_t << integerToRoman(m_listItemInfo[level].number);
977 break;
978 default:
979 m_t << m_listItemInfo[level].number;
980 break;
981 }
982 m_t << ".\\tab ";
983 m_listItemInfo[level].number++;
984 }
985 else
986 {
987 m_t << getStyle("ListBullet") << "\n";
988 }
991 visitChildren(l);
993 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlListItem)}\n");
994}
995
997{
998 if (m_hide) return;
999 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescList &)}\n");
1000 //m_t << "{\n";
1001 //m_t << rtf_Style_Reset << getStyle("ListContinue");
1002 //m_lastIsPara=FALSE;
1003 visitChildren(dl);
1004 //m_t << "}\n";
1005 //m_t << "\\par\n";
1006 //m_lastIsPara=TRUE;
1007}
1008
1010{
1011 if (m_hide) return;
1012 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescTitle &)}\n");
1013 //m_t << "\\par\n";
1014 //m_t << "{\\b ";
1015 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1017 visitChildren(dt);
1018 m_t << "\\par\n";
1019 m_t << "}\n";
1021}
1022
1024{
1025 if (m_hide) return;
1026 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescData &)}\n");
1028 m_t << "{" << rtf_Style_Reset << getStyle("DescContinue");
1029 visitChildren(dd);
1030 m_t << "\\par";
1031 m_t << "}\n";
1034}
1035
1037{
1038 if (m_hide) return;
1039 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlTable &)}\n");
1040 if (!m_lastIsPara) m_t << "\\par\n";
1042 if (t.caption())
1043 {
1044 const DocHtmlCaption &c = std::get<DocHtmlCaption>(*t.caption());
1045 m_t << "\\pard \\qc \\b";
1046 if (!c.file().isEmpty())
1047 {
1048 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1049 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1050 }
1051 m_t << "{Table \\field\\flddirty{\\*\\fldinst { SEQ Table \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1052 std::visit(*this,*t.caption());
1053 }
1054 visitChildren(t);
1055 m_t << "\\pard\\plain\n";
1056 m_t << "\\par\n";
1058}
1059
1061{
1062 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCaption &)}\n");
1063 visitChildren(c);
1064 m_t << "}\n\\par\n";
1065}
1066
1068{
1069 if (m_hide) return;
1070 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlRow &)}\n");
1071 size_t columnWidth=r.numCells()>0 ? rtf_pageWidth/r.numCells() : 10;
1072 m_t << "\\trowd \\trgaph108\\trleft-108"
1073 "\\trbrdrt\\brdrs\\brdrw10 "
1074 "\\trbrdrl\\brdrs\\brdrw10 "
1075 "\\trbrdrb\\brdrs\\brdrw10 "
1076 "\\trbrdrr\\brdrs\\brdrw10 "
1077 "\\trbrdrh\\brdrs\\brdrw10 "
1078 "\\trbrdrv\\brdrs\\brdrw10 \n";
1079 for (size_t i=0;i<r.numCells();i++)
1080 {
1081 if (r.isHeading())
1082 {
1083 m_t << "\\clcbpat16"; // set cell shading to light grey (color 16 in the clut)
1084 }
1085 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10 "
1086 "\\clbrdrl\\brdrs\\brdrw10 "
1087 "\\clbrdrb\\brdrs\\brdrw10 "
1088 "\\clbrdrr \\brdrs\\brdrw10 "
1089 "\\cltxlrtb "
1090 "\\cellx" << ((i+1)*columnWidth) << "\n";
1091 }
1092 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1094 visitChildren(r);
1095 m_t << "\n";
1096 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1097 m_t << "{\\row }\n";
1099}
1100
1102{
1103 if (m_hide) return;
1104 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCell &)}\n");
1105 m_t << "{" << align(c);
1107 visitChildren(c);
1108 m_t << "\\cell }";
1110}
1111
1113{
1114 if (m_hide) return;
1115 visitChildren(i);
1116}
1117
1119{
1120 if (m_hide) return;
1121 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHRef &)}\n");
1122 if (Config_getBool(RTF_HYPERLINKS))
1123 {
1124 if (href.url().startsWith("#"))
1125 {
1126 // when starting with # so a local link
1127 QCString cite;
1128 cite = href.file() + "_" + href.url().right(href.url().length()-1);
1129 m_t << "{\\field "
1130 "{\\*\\fldinst "
1131 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(cite) << "\" "
1132 "}{}"
1133 "}"
1134 "{\\fldrslt "
1135 "{\\cs37\\ul\\cf2 ";
1136 }
1137 else
1138 {
1139 m_t << "{\\field "
1140 "{\\*\\fldinst "
1141 "{ HYPERLINK \"" << href.url() << "\" "
1142 "}{}"
1143 "}"
1144 "{\\fldrslt "
1145 "{\\cs37\\ul\\cf2 ";
1146 }
1147 }
1148 else
1149 {
1150 m_t << "{\\f2 ";
1151 }
1153 visitChildren(href);
1154 if (Config_getBool(RTF_HYPERLINKS))
1155 {
1156 m_t << "}"
1157 "}"
1158 "}";
1159 }
1160 else
1161 {
1162 m_t << "}";
1163 }
1165}
1166
1168{
1169 if (m_hide) return;
1170 m_t << "{\\b ";
1171 visitChildren(s);
1172 m_t << "}\\par ";
1173}
1174
1176{
1177 if (m_hide) return;
1178 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDetails &)}\n");
1179 if (!m_lastIsPara) m_t << "\\par\n";
1180 auto summary = d.summary();
1181 if (summary)
1182 {
1183 std::visit(*this,*summary);
1184 m_t << "{"; // start desc
1186 m_t << rtf_Style_Reset << getStyle("DescContinue");
1187 }
1188 visitChildren(d);
1189 if (!m_lastIsPara) m_t << "\\par\n";
1190 if (summary)
1191 {
1193 m_t << "}"; // end desc
1194 }
1196}
1197
1199{
1200 if (m_hide) return;
1201 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlHeader &)}\n");
1202 m_t << "{" // start section
1203 << rtf_Style_Reset;
1204 QCString heading;
1205 int level = std::clamp(header.level()+m_hierarchyLevel,SectionType::MinLevel,SectionType::MaxLevel);
1206 heading.sprintf("Heading%d",level);
1207 // set style
1208 m_t << rtf_Style[heading.str()].reference();
1209 // make open table of contents entry that will be closed in visitPost method
1210 m_t << "{\\tc\\tcl" << level << " ";
1212 visitChildren(header);
1213 // close open table of contents entry
1214 m_t << "} \\par";
1215 m_t << "}\n"; // end section
1217}
1218
1219void RTFDocVisitor::includePicturePreRTF(const QCString &name, bool isTypeRTF, bool hasCaption, bool inlineImage)
1220{
1221 if (isTypeRTF)
1222 {
1223 if (!inlineImage)
1224 {
1225 m_t << "\\par\n";
1226 m_t << "{\n";
1227 m_t << rtf_Style_Reset << "\n";
1228 if (hasCaption || m_lastIsPara) m_t << "\\par\n";
1229 m_t << "\\pard \\qc ";
1230 }
1231 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"";
1232 m_t << name;
1233 m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}\n";
1234 if (!inlineImage)
1235 {
1236 m_t << "\\par\n";
1237 if (hasCaption)
1238 {
1239 m_t << "\\pard \\qc \\b";
1240 m_t << "{Image \\field\\flddirty{\\*\\fldinst { SEQ Image \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1241 }
1243 }
1244 else
1245 {
1246 if (hasCaption) m_t << "{\\comment "; // to prevent caption to be shown
1247 }
1248 }
1249 else // other format -> skip
1250 {
1252 m_hide=TRUE;
1253 }
1254}
1255
1256void RTFDocVisitor::includePicturePostRTF(bool isTypeRTF, bool hasCaption, bool inlineImage)
1257{
1258 if (isTypeRTF)
1259 {
1260 if (m_hide) return;
1261 if (inlineImage)
1262 {
1263 if (hasCaption) m_t << " }";
1264 }
1265 else
1266 {
1267 if (hasCaption)
1268 {
1269 m_t << "}\n";
1270 m_t << "\\par}\n";
1271 }
1272 else
1273 {
1274 m_t << "}\n";
1275 }
1276 }
1277 }
1278 else
1279 {
1280 m_hide = popHidden();
1281 }
1282}
1283
1285{
1286 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocImage &)}\n");
1288 visitChildren(img);
1290}
1291
1292
1294{
1295 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDotFile &)}\n");
1296 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1297 writeDotFile(df);
1298 visitChildren(df);
1300}
1302{
1303 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocMscFile &)}\n");
1304 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1305 writeMscFile(df);
1306 visitChildren(df);
1308}
1309
1311{
1312 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDiaFile &)}\n");
1313 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1314 writeDiaFile(df);
1315 visitChildren(df);
1317}
1318
1320{
1321 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPlantUmlFile &)}\n");
1322 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1323 QCString rtfOutput = Config_getString(RTF_OUTPUT);
1324 std::string inBuf;
1325 readInputFile(df.file(),inBuf);
1326 auto baseNameVector = PlantumlManager::instance().writePlantUMLSource(
1327 rtfOutput,QCString(),inBuf.c_str(),PlantumlManager::PUML_BITMAP,
1328 QCString(),df.srcFile(),df.srcLine(),false);
1329 for(const auto &baseName: baseNameVector)
1330 {
1331 writePlantUMLFile(QCString(baseName), df.hasCaption());
1332 visitChildren(df);
1334 }
1335}
1336
1338{
1339 if (m_hide) return;
1340 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocLink &)}\n");
1341 startLink(lnk.ref(),lnk.file(),lnk.anchor());
1342 visitChildren(lnk);
1343 endLink(lnk.ref());
1344}
1345
1347{
1348 if (m_hide) return;
1349 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRef &)}\n");
1350 // when ref.isSubPage()==TRUE we use ref.file() for HTML and
1351 // ref.anchor() for LaTeX/RTF
1352 if (ref.isSubPage())
1353 {
1354 startLink(ref.ref(),QCString(),ref.anchor());
1355 }
1356 else
1357 {
1358 if (!ref.file().isEmpty()) startLink(ref.ref(),ref.file(),ref.anchor());
1359 }
1360 if (!ref.hasLinkText()) filter(ref.targetTitle());
1361 visitChildren(ref);
1362 if (!ref.file().isEmpty()) endLink(ref.ref());
1363 //m_t << " ";
1364}
1365
1366
1368{
1369 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefItem &)}\n");
1370 visitChildren(ref);
1371}
1372
1374{
1375 if (m_hide) return;
1376 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefList &)}\n");
1377 m_t << "{\n";
1379 m_t << rtf_Style_Reset << getStyle("LatexTOC") << "\n";
1380 m_t << "\\par\n";
1382 visitChildren(l);
1384 m_t << "\\par";
1385 m_t << "}\n";
1387}
1388
1390{
1391 if (m_hide) return;
1392 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamSect &)}\n");
1393 m_t << "{"; // start param list
1394 if (!m_lastIsPara) m_t << "\\par\n";
1395 //m_t << "{\\b "; // start bold
1396 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1397 switch(s.type())
1398 {
1400 m_t << theTranslator->trParameters(); break;
1402 m_t << theTranslator->trReturnValues(); break;
1404 m_t << theTranslator->trExceptions(); break;
1406 m_t << theTranslator->trTemplateParameters(); break;
1407 default:
1408 ASSERT(0);
1409 }
1410 m_t << "\\par";
1411 m_t << "}\n";
1412 bool useTable = s.type()==DocParamSect::Param ||
1416 if (!useTable)
1417 {
1419 }
1420 m_t << rtf_Style_Reset << getStyle("DescContinue");
1422 visitChildren(s);
1423 //m_t << "\\par\n";
1424 if (!useTable)
1425 {
1427 }
1428 m_t << "}\n";
1429}
1430
1432{
1433 m_t << " " << sep.chars() << " ";
1434}
1435
1437{
1438 static int columnPos[4][5] =
1439 { { 2, 25, 100, 100, 100 }, // no inout, no type
1440 { 3, 14, 35, 100, 100 }, // inout, no type
1441 { 3, 25, 50, 100, 100 }, // no inout, type
1442 { 4, 14, 35, 55, 100 }, // inout, type
1443 };
1444 int config=0;
1445 if (m_hide) return;
1446 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamList &)}\n");
1447
1449 const DocParamSect *sect = std::get_if<DocParamSect>(pl.parent());
1450 if (sect)
1451 {
1452 parentType = sect->type();
1453 }
1454 bool useTable = parentType==DocParamSect::Param ||
1455 parentType==DocParamSect::RetVal ||
1456 parentType==DocParamSect::Exception ||
1457 parentType==DocParamSect::TemplateParam;
1458 if (sect && sect->hasInOutSpecifier()) config+=1;
1459 if (sect && sect->hasTypeSpecifier()) config+=2;
1460 if (useTable)
1461 {
1462 m_t << "\\trowd \\trgaph108\\trleft426\\tblind426"
1463 "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1464 "\\trbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1465 "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1466 "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 "
1467 "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 "
1468 "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< "\n";
1469 for (int i=0;i<columnPos[config][0];i++)
1470 {
1471 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1472 "\\clbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1473 "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1474 "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 "
1475 "\\cltxlrtb "
1476 "\\cellx" << (rtf_pageWidth*columnPos[config][i+1]/100) << "\n";
1477 }
1478 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1479 }
1480
1481 if (sect && sect->hasInOutSpecifier())
1482 {
1483 if (useTable)
1484 {
1485 m_t << "{";
1486 }
1487
1488 // Put in the direction: in/out/in,out if specified.
1490 {
1491 if (pl.direction()==DocParamSect::In)
1492 {
1493 m_t << "in";
1494 }
1495 else if (pl.direction()==DocParamSect::Out)
1496 {
1497 m_t << "out";
1498 }
1499 else if (pl.direction()==DocParamSect::InOut)
1500 {
1501 m_t << "in,out";
1502 }
1503 }
1504
1505 if (useTable)
1506 {
1507 m_t << "\\cell }";
1508 }
1509 }
1510
1511 if (sect && sect->hasTypeSpecifier())
1512 {
1513 if (useTable)
1514 {
1515 m_t << "{";
1516 }
1517 for (const auto &type : pl.paramTypes())
1518 {
1519 std::visit(*this,type);
1520 }
1521 if (useTable)
1522 {
1523 m_t << "\\cell }";
1524 }
1525 }
1526
1527
1528 if (useTable)
1529 {
1530 m_t << "{";
1531 }
1532
1533 m_t << "{\\i ";
1534 bool first=TRUE;
1535 for (const auto &param : pl.parameters())
1536 {
1537 if (!first) m_t << ","; else first=FALSE;
1538 std::visit(*this,param);
1539 }
1540 m_t << "} ";
1541
1542 if (useTable)
1543 {
1544 m_t << "\\cell }{";
1545 }
1547
1548 for (const auto &par : pl.paragraphs())
1549 {
1550 std::visit(*this,par);
1551 }
1552
1553 if (useTable)
1554 {
1555 m_t << "\\cell }\n";
1556 //m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1557 m_t << "{\\row }\n";
1558 }
1559 else
1560 {
1561 m_t << "\\par\n";
1562 }
1563
1565}
1566
1568{
1569 if (m_hide) return;
1570 if (x.title().isEmpty()) return;
1571 bool anonymousEnum = x.file()=="@";
1572 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocXRefItem &)}\n");
1573 if (!m_lastIsPara)
1574 {
1575 m_t << "\\par\n";
1577 }
1578 m_t << "{"; // start param list
1579 //m_t << "{\\b "; // start bold
1580 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1581 if (Config_getBool(RTF_HYPERLINKS) && !anonymousEnum)
1582 {
1583 QCString refName;
1584 if (!x.file().isEmpty())
1585 {
1586 refName+=stripPath(x.file());
1587 }
1588 if (!x.file().isEmpty() && !x.anchor().isEmpty())
1589 {
1590 refName+="_";
1591 }
1592 if (!x.anchor().isEmpty())
1593 {
1594 refName+=x.anchor();
1595 }
1596
1597 m_t << "{\\field "
1598 "{\\*\\fldinst "
1599 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(refName) << "\" "
1600 "}{}"
1601 "}"
1602 "{\\fldrslt "
1603 "{\\cs37\\ul\\cf2 ";
1604 filter(x.title());
1605 m_t << "}"
1606 "}"
1607 "}";
1608 }
1609 else
1610 {
1611 filter(x.title());
1612 }
1613 m_t << ":";
1614 m_t << "\\par";
1615 m_t << "}"; // end bold
1617 m_t << rtf_Style_Reset << getStyle("DescContinue");
1619 visitChildren(x);
1620 if (x.title().isEmpty()) return;
1621 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocXRefItem)}\n");
1622 m_t << "\\par\n";
1624 m_t << "}\n"; // end xref item
1626}
1627
1629{
1630 if (m_hide) return;
1631 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocInternalRef &)}\n");
1632 startLink("",ref.file(),ref.anchor());
1633 visitChildren(ref);
1634 endLink("");
1635 m_t << " ";
1636}
1637
1639{
1640 if (m_hide) return;
1641 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocText &)}\n");
1642 visitChildren(t);
1643}
1644
1646{
1647 if (m_hide) return;
1648 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlBlockQuote &)}\n");
1649 if (!m_lastIsPara) m_t << "\\par\n";
1650 m_t << "{"; // start desc
1652 m_t << rtf_Style_Reset << getStyle("DescContinue");
1653 visitChildren(q);
1654 if (!m_lastIsPara) m_t << "\\par\n";
1656 m_t << "}"; // end desc
1658}
1659
1661{
1662}
1663
1665{
1666 if (m_hide) return;
1667 visitChildren(pb);
1668}
1669
1670
1671//static char* getMultiByte(int c)
1672//{
1673// static char s[10];
1674// sprintf(s,"\\'%X",c);
1675// return s;
1676//}
1677
1678void RTFDocVisitor::filter(const QCString &str,bool verbatim)
1679{
1680 if (!str.isEmpty())
1681 {
1682 const char *p=str.data();
1683 while (*p)
1684 {
1685 char c=*p++;
1686 switch (c)
1687 {
1688 case '{': m_t << "\\{"; break;
1689 case '}': m_t << "\\}"; break;
1690 case '\\': m_t << "\\\\"; break;
1691 case '\n': if (verbatim)
1692 {
1693 m_t << "\\par\n";
1694 }
1695 else
1696 {
1697 m_t << '\n';
1698 }
1699 break;
1700 default: m_t << c;
1701 }
1702 }
1703 }
1704}
1705
1706void RTFDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)
1707{
1708 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1709 {
1710 QCString refName;
1711 if (!file.isEmpty())
1712 {
1713 refName+=stripPath(file);
1714 }
1715 if (!file.isEmpty() && !anchor.isEmpty())
1716 {
1717 refName+='_';
1718 }
1719 if (!anchor.isEmpty())
1720 {
1721 refName+=anchor;
1722 }
1723
1724 m_t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \"";
1725 m_t << rtfFormatBmkStr(refName);
1726 m_t << "\" }{}";
1727 m_t << "}{\\fldrslt {\\cs37\\ul\\cf2 ";
1728 }
1729 else
1730 {
1731 m_t << "{\\b ";
1732 }
1734}
1735
1737{
1738 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1739 {
1740 m_t << "}}}";
1741 }
1742 else
1743 {
1744 m_t << "}";
1745 }
1747}
1748
1750{
1751 writeDotFile(df.file(), df.hasCaption(), df.srcFile(), df.srcLine());
1752}
1753void RTFDocVisitor::writeDotFile(const QCString &filename, bool hasCaption,
1754 const QCString &srcFile, int srcLine)
1755{
1756 QCString baseName=makeBaseName(filename);
1757 QCString outDir = Config_getString(RTF_OUTPUT);
1758 writeDotGraphFromFile(filename,outDir,baseName,GraphOutputFormat::BITMAP,srcFile,srcLine);
1759 QCString imgExt = getDotImageExtension();
1760 includePicturePreRTF(baseName + "." + imgExt, true, hasCaption);
1761}
1762
1764{
1765 writeMscFile(df.file(), df.hasCaption(), df.srcFile(), df.srcLine());
1766}
1767void RTFDocVisitor::writeMscFile(const QCString &fileName, bool hasCaption,
1768 const QCString &srcFile, int srcLine)
1769{
1770 QCString baseName=makeBaseName(fileName);
1771 QCString outDir = Config_getString(RTF_OUTPUT);
1772 writeMscGraphFromFile(fileName,outDir,baseName,MscOutputFormat::BITMAP,srcFile,srcLine);
1773 includePicturePreRTF(baseName + ".png", true, hasCaption);
1774}
1775
1777{
1778 QCString baseName=makeBaseName(df.file());
1779 QCString outDir = Config_getString(RTF_OUTPUT);
1780 writeDiaGraphFromFile(df.file(),outDir,baseName,DiaOutputFormat::BITMAP,df.srcFile(),df.srcLine());
1781 includePicturePreRTF(baseName + ".png", true, df.hasCaption());
1782}
1783
1784void RTFDocVisitor::writePlantUMLFile(const QCString &fileName, bool hasCaption)
1785{
1786 QCString baseName=makeBaseName(fileName);
1787 QCString outDir = Config_getString(RTF_OUTPUT);
1789 includePicturePreRTF(baseName + ".png", true, hasCaption);
1790}
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: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:939
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:1291
Node representing a HTML table caption.
Definition docnode.h:1228
QCString anchor() const
Definition docnode.h:1235
QCString file() const
Definition docnode.h:1234
Node representing a HTML table cell.
Definition docnode.h:1193
const HtmlAttribList & attribs() const
Definition docnode.h:1205
Node representing a HTML description data.
Definition docnode.h:1181
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:1165
const HtmlAttribList & attribs() const
Definition docnode.h:1170
Node representing a HTML table row.
Definition docnode.h:1246
bool isHeading() const
Definition docnode.cpp:1922
size_t numCells() const
Definition docnode.h:1251
Node Html summary.
Definition docnode.h:844
Node representing a HTML table.
Definition docnode.h:1269
const DocNodeVariant * caption() const
Definition docnode.cpp:2141
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:1125
const DocNodeList & parameters() const
Definition docnode.h:1129
const DocNodeList & paramTypes() const
Definition docnode.h:1130
DocParamSect::Direction direction() const
Definition docnode.h:1133
const DocNodeList & paragraphs() const
Definition docnode.h:1131
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:1313
bool singleLine() const
Definition docnode.h:1319
bool indent() const
Definition docnode.h:1318
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:1153
const DocNodeVariant * paragraph() const
Definition docnode.h:1157
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:1304
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:164
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: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: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
const char * reference() const
Definition rtfstyle.h:69
SrcLangExt
Definition types.h:207
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5718
QCString integerToRoman(int n, bool upper)
Definition util.cpp:7209
QCString stripPath(const QCString &s)
Definition util.cpp:5461
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:6047
SrcLangExt getLanguageFromCodeLang(QCString &fileName)
Routine to handle the language attribute of the \code command.
Definition util.cpp:5736
QCString integerToAlpha(int n, bool upper)
Definition util.cpp:7193
QCString getDotImageExtension()
Definition util.cpp:6800
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:6370
QCString getFileNameExtension(const QCString &fn)
Definition util.cpp:5760
A bunch of utility functions.