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 CodeParserOptions().setExample(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(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(),
486 .setExample(inc.isExample(),inc.exampleFile())
487 .setFileDef(fd.get())
488 .setInlineFragment(true)
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(),
502 .setExample(inc.isExample(),inc.exampleFile())
503 .setInlineFragment(true)
504 .setShowLineNumbers(false)
505 );
506 m_t << "\\par";
507 m_t << "}\n";
508 break;
516 break;
518 m_t << inc.text();
519 break;
521 m_t << "{\n";
522 m_t << "\\par\n";
523 m_t << rtf_Style_Reset << getStyle("CodeExample");
524 filter(inc.text());
525 m_t << "\\par";
526 m_t << "}\n";
527 break;
530 m_t << "{\n";
531 if (!m_lastIsPara) m_t << "\\par\n";
532 m_t << rtf_Style_Reset << getStyle("CodeExample");
534 inc.file(),
535 inc.blockId(),
536 inc.context(),
538 inc.trimLeft(),
540 );
541 m_t << "}";
542 break;
543 }
545}
546
548{
549 //printf("DocIncOperator: type=%d first=%d, last=%d text='%s'\n",
550 // op.type(),op.isFirst(),op.isLast(),qPrint(op.text()));
551 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIncOperator)}\n");
553 if (locLangExt.isEmpty()) locLangExt = m_langExt;
554 SrcLangExt langExt = getLanguageFromFileName(locLangExt);
555 if (op.isFirst())
556 {
557 if (!m_hide)
558 {
559 m_t << "{\n";
560 m_t << "\\par\n";
561 m_t << rtf_Style_Reset << getStyle("CodeExample");
562 }
564 m_hide = TRUE;
565 }
566 if (op.type()!=DocIncOperator::Skip)
567 {
568 m_hide = popHidden();
569 if (!m_hide)
570 {
571 std::unique_ptr<FileDef> fd = nullptr;
572 if (!op.includeFileName().isEmpty())
573 {
574 FileInfo cfi( op.includeFileName().str() );
575 fd = createFileDef( cfi.dirPath(), cfi.fileName() );
576 }
577
578 getCodeParser(locLangExt).parseCode(m_ci,op.context(),op.text(),langExt,
581 .setExample(op.isExample(),op.exampleFile())
582 .setFileDef(fd.get())
583 .setStartLine(op.line())
585 );
586 }
588 m_hide=TRUE;
589 }
590 if (op.isLast())
591 {
592 m_hide = popHidden();
593 if (!m_hide)
594 {
595 m_t << "\\par";
596 m_t << "}\n";
597 }
599 }
600 else
601 {
602 if (!m_hide) m_t << "\n";
604 }
605}
606
608{
609 if (m_hide) return;
610 DBG_RTF("{\\comment RTFDocVisitor::visit(DocFormula)}\n");
611 bool bDisplay = !f.isInline();
612 if (bDisplay)
613 {
614 m_t << "\\par";
615 m_t << "{";
616 m_t << "\\pard\\plain";
617 m_t << "\\pard";
618 m_t << "\\qc";
619 }
620 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"" << f.relPath() << f.name() << ".png\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}";
621 if (bDisplay)
622 {
623 m_t << "\\par}";
624 }
626}
627
629{
630 if (m_hide) return;
631 DBG_RTF("{\\comment RTFDocVisitor::visit(DocIndexEntry)}\n");
632 m_t << "{\\xe \\v " << i.entry() << "}\n";
634}
635
639
641{
642 if (m_hide) return;
643 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocCite &)}\n");
644 auto opt = cite.option();
645 if (!cite.file().isEmpty())
646 {
647 if (!opt.noCite()) startLink(cite.ref(),cite.file(),cite.anchor());
648
649 filter(cite.getText());
650
651 if (!opt.noCite()) endLink(cite.ref());
652 }
653 else
654 {
655 m_t << "{\\b";
656 if (!opt.noPar()) filter("[");
657 filter(cite.target());
658 if (!opt.noPar()) filter("]");
659 m_t << "}";
660 }
661}
662
663
664//--------------------------------------
665// visitor functions for compound nodes
666//--------------------------------------
667
669{
670 if (m_hide) return;
671 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoList &)}\n");
672 m_t << "{\n";
673 int level = indentLevel();
674 m_listItemInfo[level].isEnum = l.isEnumList();
675 m_listItemInfo[level].isCheck = l.isCheckedList();
676 m_listItemInfo[level].type = '1';
677 m_listItemInfo[level].number = 1;
679 visitChildren(l);
680 if (!m_lastIsPara) m_t << "\\par";
681 m_t << "}\n";
683 if (!l.isCheckedList() && indentLevel()==0) m_t << "\\par\n";
684}
685
687{
688 static int prevLevel = -1;
689 if (m_hide) return;
690 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocAutoListItem &)}\n");
691 int level = indentLevel();
692 if ((level != prevLevel-1) &&
693 (!(level==prevLevel && level != 0 && m_listItemInfo[level].isCheck)) &&
694 (!m_lastIsPara))
695 m_t << "\\par\n";
696 prevLevel= level;
698 if (m_listItemInfo[level].isEnum)
699 {
700 m_t << getStyle("ListEnum") << "\n";
701 m_t << m_listItemInfo[level].number << ".\\tab ";
702 m_listItemInfo[level].number++;
703 }
704 else
705 {
706 switch (li.itemNumber())
707 {
708 case DocAutoList::Unchecked: // unchecked
709 m_t << getListTable(2) << "\n";
710 break;
711 case DocAutoList::Checked_x: // checked with x
712 case DocAutoList::Checked_X: // checked with X
713 m_t << getListTable(3) << "\n";
714 break;
715 default:
716 m_t << getListTable(1) << "\n";
717 break;
718 }
719 }
721 m_lastIsPara=false;
722 visitChildren(li);
724}
725
727{
728 if (m_hide) return;
729 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPara &)}\n");
730 visitChildren(p);
731 if (!m_lastIsPara &&
732 !p.isLast() && // omit <p> for last paragraph
733 !(p.parent() && // and for parameters & sections
734 std::get_if<DocParamSect>(p.parent())
735 )
736 )
737 {
738 m_t << "\\par\n";
740 }
741}
742
744{
745 if (m_hide) return;
746 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRoot &)}\n");
747 if (r.indent()) incIndentLevel();
748 m_t << "{" << rtf_Style["BodyText"].reference() << "\n";
749 visitChildren(r);
750 if (!m_lastIsPara && !r.singleLine()) m_t << "\\par\n";
751 m_t << "}";
753 if (r.indent()) decIndentLevel();
754}
755
757{
758 if (m_hide) return;
759 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
760 if (!m_lastIsPara) m_t << "\\par\n";
761 m_t << "{"; // start desc
762 //m_t << "{\\b "; // start bold
763 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
764 switch(s.type())
765 {
767 m_t << theTranslator->trSeeAlso(); break;
769 m_t << theTranslator->trReturns(); break;
771 m_t << theTranslator->trAuthor(TRUE,TRUE); break;
773 m_t << theTranslator->trAuthor(TRUE,FALSE); break;
775 m_t << theTranslator->trVersion(); break;
777 m_t << theTranslator->trSince(); break;
779 m_t << theTranslator->trDate(); break;
781 m_t << theTranslator->trNote(); break;
783 m_t << theTranslator->trWarning(); break;
785 m_t << theTranslator->trPrecondition(); break;
787 m_t << theTranslator->trPostcondition(); break;
789 m_t << theTranslator->trCopyright(); break;
791 m_t << theTranslator->trInvariant(); break;
793 m_t << theTranslator->trRemarks(); break;
795 m_t << theTranslator->trAttention(); break;
797 m_t << theTranslator->trImportant(); break;
798 case DocSimpleSect::User: break;
799 case DocSimpleSect::Rcs: break;
800 case DocSimpleSect::Unknown: break;
801 }
802
805 {
806 m_t << "\\par";
807 m_t << "}"; // end bold
808 m_t << rtf_Style_Reset << getStyle("DescContinue");
809 m_t << "{\\s17 \\sa60 \\sb30\n";
810 }
811 else
812 {
813 if (s.title())
814 {
815 std::visit(*this,*s.title());
816 }
817 m_t << "\\par\n";
818 m_t << "}"; // end bold
819 m_t << rtf_Style_Reset << getStyle("DescContinue");
820 }
822 visitChildren(s);
823 if (!m_lastIsPara) m_t << "\\par\n";
826 {
827 m_t << "}"; // end DescContinue
828 }
829 m_t << "}"; // end desc
831}
832
834{
835 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocTitle &)}\n");
836 if (m_hide) return;
837 visitChildren(t);
838}
839
841{
842 if (m_hide) return;
843 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleSect &)}\n");
844 m_t << "{\n";
845 m_listItemInfo[indentLevel()].isEnum = false;
846 m_listItemInfo[indentLevel()].isCheck = false;
848 visitChildren(l);
849 if (!m_lastIsPara) m_t << "\\par\n";
850 m_t << "}\n";
852}
853
855{
856 if (m_hide) return;
857 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSimpleListItem &)}\n");
858 m_t << "\\par" << rtf_Style_Reset << getStyle("ListBullet") << "\n";
861 if (li.paragraph())
862 {
863 std::visit(*this,*li.paragraph());
864 }
866 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSimpleListItem)}\n");
867}
868
870{
871 if (m_hide) return;
872 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSection &)}\n");
873 if (!m_lastIsPara) m_t << "\\par\n";
874 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
875 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(s.file())+"_"+s.anchor()) << "}\n";
876 m_t << "{{" // start section
878 QCString heading;
879 int level = std::min(s.level()+2+m_hierarchyLevel,4);
880 if (level <= 0)
881 level = 1;
882 heading.sprintf("Heading%d",level);
883 // set style
884 m_t << rtf_Style[heading.str()].reference() << "\n";
885 // make table of contents entry
886 if (s.title())
887 {
888 std::visit(*this,*s.title());
889 }
890 m_t << "\n\\par" << "}\n";
891 m_t << "{\\tc\\tcl" << level << " \\v ";
892 if (s.title())
893 {
894 std::visit(*this,*s.title());
895 }
896 m_t << "}\n";
898 visitChildren(s);
899 m_t << "\\par}\n"; // end section
901}
902
904{
905 if (m_hide) return;
906 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlList &)}\n");
907 m_t << "{\n";
908 int level = indentLevel();
909 m_listItemInfo[level].isEnum = l.type()==DocHtmlList::Ordered;
910 m_listItemInfo[level].isCheck = false;
911 m_listItemInfo[level].number = 1;
912 m_listItemInfo[level].type = '1';
913 for (const auto &opt : l.attribs())
914 {
915 if (opt.name=="type")
916 {
917 m_listItemInfo[level].type = opt.value[0];
918 }
919 if (opt.name=="start")
920 {
921 bool ok = false;
922 int val = opt.value.toInt(&ok);
923 if (ok) m_listItemInfo[level].number = val;
924 }
925 }
927 visitChildren(l);
928 m_t << "\\par" << "}\n";
930}
931
933{
934 if (m_hide) return;
935 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlListItem &)}\n");
936 m_t << "\\par\n";
938 int level = indentLevel();
939 if (m_listItemInfo[level].isEnum)
940 {
941 for (const auto &opt : l.attribs())
942 {
943 if (opt.name=="value")
944 {
945 bool ok = false;
946 int val = opt.value.toInt(&ok);
947 if (ok) m_listItemInfo[level].number = val;
948 }
949 }
950 m_t << getStyle("ListEnum") << "\n";
951 switch (m_listItemInfo[level].type)
952 {
953 case '1':
954 m_t << m_listItemInfo[level].number;
955 break;
956 case 'a':
957 m_t << integerToAlpha(m_listItemInfo[level].number,false);
958 break;
959 case 'A':
960 m_t << integerToAlpha(m_listItemInfo[level].number);
961 break;
962 case 'i':
963 m_t << integerToRoman(m_listItemInfo[level].number,false);
964 break;
965 case 'I':
966 m_t << integerToRoman(m_listItemInfo[level].number);
967 break;
968 default:
969 m_t << m_listItemInfo[level].number;
970 break;
971 }
972 m_t << ".\\tab ";
973 m_listItemInfo[level].number++;
974 }
975 else
976 {
977 m_t << getStyle("ListBullet") << "\n";
978 }
981 visitChildren(l);
983 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlListItem)}\n");
984}
985
987{
988 if (m_hide) return;
989 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescList &)}\n");
990 //m_t << "{\n";
991 //m_t << rtf_Style_Reset << getStyle("ListContinue");
992 //m_lastIsPara=FALSE;
993 visitChildren(dl);
994 //m_t << "}\n";
995 //m_t << "\\par\n";
996 //m_lastIsPara=TRUE;
997}
998
1000{
1001 if (m_hide) return;
1002 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescTitle &)}\n");
1003 //m_t << "\\par\n";
1004 //m_t << "{\\b ";
1005 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1007 visitChildren(dt);
1008 m_t << "\\par\n";
1009 m_t << "}\n";
1011}
1012
1014{
1015 if (m_hide) return;
1016 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDescData &)}\n");
1018 m_t << "{" << rtf_Style_Reset << getStyle("DescContinue");
1019 visitChildren(dd);
1020 m_t << "\\par";
1021 m_t << "}\n";
1024}
1025
1027{
1028 if (m_hide) return;
1029 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlTable &)}\n");
1030 if (!m_lastIsPara) m_t << "\\par\n";
1032 if (t.caption())
1033 {
1034 const DocHtmlCaption &c = std::get<DocHtmlCaption>(*t.caption());
1035 m_t << "\\pard \\qc \\b";
1036 if (!c.file().isEmpty())
1037 {
1038 m_t << "{\\bkmkstart " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1039 m_t << "{\\bkmkend " << rtfFormatBmkStr(stripPath(c.file())+"_"+c.anchor()) << "}\n";
1040 }
1041 m_t << "{Table \\field\\flddirty{\\*\\fldinst { SEQ Table \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1042 std::visit(*this,*t.caption());
1043 }
1044 visitChildren(t);
1045 m_t << "\\pard\\plain\n";
1046 m_t << "\\par\n";
1048}
1049
1051{
1052 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCaption &)}\n");
1053 visitChildren(c);
1054 m_t << "}\n\\par\n";
1055}
1056
1058{
1059 if (m_hide) return;
1060 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlRow &)}\n");
1061 size_t columnWidth=r.numCells()>0 ? rtf_pageWidth/r.numCells() : 10;
1062 m_t << "\\trowd \\trgaph108\\trleft-108"
1063 "\\trbrdrt\\brdrs\\brdrw10 "
1064 "\\trbrdrl\\brdrs\\brdrw10 "
1065 "\\trbrdrb\\brdrs\\brdrw10 "
1066 "\\trbrdrr\\brdrs\\brdrw10 "
1067 "\\trbrdrh\\brdrs\\brdrw10 "
1068 "\\trbrdrv\\brdrs\\brdrw10 \n";
1069 for (size_t i=0;i<r.numCells();i++)
1070 {
1071 if (r.isHeading())
1072 {
1073 m_t << "\\clcbpat16"; // set cell shading to light grey (color 16 in the clut)
1074 }
1075 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10 "
1076 "\\clbrdrl\\brdrs\\brdrw10 "
1077 "\\clbrdrb\\brdrs\\brdrw10 "
1078 "\\clbrdrr \\brdrs\\brdrw10 "
1079 "\\cltxlrtb "
1080 "\\cellx" << ((i+1)*columnWidth) << "\n";
1081 }
1082 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1084 visitChildren(r);
1085 m_t << "\n";
1086 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1087 m_t << "{\\row }\n";
1089}
1090
1092{
1093 if (m_hide) return;
1094 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlCell &)}\n");
1095 m_t << "{" << align(c);
1097 visitChildren(c);
1098 m_t << "\\cell }";
1100}
1101
1103{
1104 if (m_hide) return;
1105 visitChildren(i);
1106}
1107
1109{
1110 if (m_hide) return;
1111 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHRef &)}\n");
1112 if (Config_getBool(RTF_HYPERLINKS))
1113 {
1114 if (href.url().startsWith("#"))
1115 {
1116 // when starting with # so a local link
1117 QCString cite;
1118 cite = href.file() + "_" + href.url().right(href.url().length()-1);
1119 m_t << "{\\field "
1120 "{\\*\\fldinst "
1121 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(cite) << "\" "
1122 "}{}"
1123 "}"
1124 "{\\fldrslt "
1125 "{\\cs37\\ul\\cf2 ";
1126 }
1127 else
1128 {
1129 m_t << "{\\field "
1130 "{\\*\\fldinst "
1131 "{ HYPERLINK \"" << href.url() << "\" "
1132 "}{}"
1133 "}"
1134 "{\\fldrslt "
1135 "{\\cs37\\ul\\cf2 ";
1136 }
1137 }
1138 else
1139 {
1140 m_t << "{\\f2 ";
1141 }
1143 visitChildren(href);
1144 if (Config_getBool(RTF_HYPERLINKS))
1145 {
1146 m_t << "}"
1147 "}"
1148 "}";
1149 }
1150 else
1151 {
1152 m_t << "}";
1153 }
1155}
1156
1158{
1159 if (m_hide) return;
1160 m_t << "{\\b ";
1161 visitChildren(s);
1162 m_t << "}\\par ";
1163}
1164
1166{
1167 if (m_hide) return;
1168 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlDetails &)}\n");
1169 if (!m_lastIsPara) m_t << "\\par\n";
1170 auto summary = d.summary();
1171 if (summary)
1172 {
1173 std::visit(*this,*summary);
1174 m_t << "{"; // start desc
1176 m_t << rtf_Style_Reset << getStyle("DescContinue");
1177 }
1178 visitChildren(d);
1179 if (!m_lastIsPara) m_t << "\\par\n";
1180 if (summary)
1181 {
1183 m_t << "}"; // end desc
1184 }
1186}
1187
1189{
1190 if (m_hide) return;
1191 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlHeader &)}\n");
1192 m_t << "{" // start section
1193 << rtf_Style_Reset;
1194 QCString heading;
1195 int level = std::clamp(header.level()+m_hierarchyLevel,SectionType::MinLevel,SectionType::MaxLevel);
1196 heading.sprintf("Heading%d",level);
1197 // set style
1198 m_t << rtf_Style[heading.str()].reference();
1199 // make open table of contents entry that will be closed in visitPost method
1200 m_t << "{\\tc\\tcl" << level << " ";
1202 visitChildren(header);
1203 // close open table of contents entry
1204 m_t << "} \\par";
1205 m_t << "}\n"; // end section
1207}
1208
1209void RTFDocVisitor::includePicturePreRTF(const QCString &name, bool isTypeRTF, bool hasCaption, bool inlineImage)
1210{
1211 if (isTypeRTF)
1212 {
1213 if (!inlineImage)
1214 {
1215 m_t << "\\par\n";
1216 m_t << "{\n";
1217 m_t << rtf_Style_Reset << "\n";
1218 if (hasCaption || m_lastIsPara) m_t << "\\par\n";
1219 m_t << "\\pard \\qc ";
1220 }
1221 m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \"";
1222 m_t << name;
1223 m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}\n";
1224 if (!inlineImage)
1225 {
1226 m_t << "\\par\n";
1227 if (hasCaption)
1228 {
1229 m_t << "\\pard \\qc \\b";
1230 m_t << "{Image \\field\\flddirty{\\*\\fldinst { SEQ Image \\\\*Arabic }}{\\fldrslt {\\noproof 1}} ";
1231 }
1233 }
1234 else
1235 {
1236 if (hasCaption) m_t << "{\\comment "; // to prevent caption to be shown
1237 }
1238 }
1239 else // other format -> skip
1240 {
1242 m_hide=TRUE;
1243 }
1244}
1245
1246void RTFDocVisitor::includePicturePostRTF(bool isTypeRTF, bool hasCaption, bool inlineImage)
1247{
1248 if (isTypeRTF)
1249 {
1250 if (m_hide) return;
1251 if (inlineImage)
1252 {
1253 if (hasCaption) m_t << " }";
1254 }
1255 else
1256 {
1257 if (hasCaption)
1258 {
1259 m_t << "}\n";
1260 m_t << "\\par}\n";
1261 }
1262 else
1263 {
1264 m_t << "}\n";
1265 }
1266 }
1267 }
1268 else
1269 {
1270 m_hide = popHidden();
1271 }
1272}
1273
1275{
1276 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocImage &)}\n");
1278 visitChildren(img);
1280}
1281
1282
1284{
1285 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDotFile &)}\n");
1286 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1287 writeDotFile(df);
1288 visitChildren(df);
1290}
1292{
1293 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocMscFile &)}\n");
1294 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1295 writeMscFile(df);
1296 visitChildren(df);
1298}
1299
1301{
1302 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocDiaFile &)}\n");
1303 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1304 writeDiaFile(df);
1305 visitChildren(df);
1307}
1308
1310{
1311 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocPlantUmlFile &)}\n");
1312 if (!Config_getBool(DOT_CLEANUP)) copyFile(df.file(),Config_getString(RTF_OUTPUT)+"/"+stripPath(df.file()));
1313 QCString rtfOutput = Config_getString(RTF_OUTPUT);
1314 std::string inBuf;
1315 readInputFile(df.file(),inBuf);
1316 auto baseNameVector = PlantumlManager::instance().writePlantUMLSource(
1317 rtfOutput,QCString(),inBuf,PlantumlManager::PUML_BITMAP,
1318 QCString(),df.srcFile(),df.srcLine(),false);
1319 for(const auto &baseName: baseNameVector)
1320 {
1321 writePlantUMLFile(baseName, df.hasCaption());
1322 visitChildren(df);
1324 }
1325}
1326
1328{
1329 if (m_hide) return;
1330 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocLink &)}\n");
1331 startLink(lnk.ref(),lnk.file(),lnk.anchor());
1332 visitChildren(lnk);
1333 endLink(lnk.ref());
1334}
1335
1337{
1338 if (m_hide) return;
1339 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocRef &)}\n");
1340 // when ref.isSubPage()==TRUE we use ref.file() for HTML and
1341 // ref.anchor() for LaTeX/RTF
1342 if (ref.isSubPage())
1343 {
1344 startLink(ref.ref(),QCString(),ref.anchor());
1345 }
1346 else
1347 {
1348 if (!ref.file().isEmpty()) startLink(ref.ref(),ref.file(),ref.anchor());
1349 }
1350 if (!ref.hasLinkText()) filter(ref.targetTitle());
1351 visitChildren(ref);
1352 if (!ref.file().isEmpty()) endLink(ref.ref());
1353 //m_t << " ";
1354}
1355
1356
1358{
1359 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefItem &)}\n");
1360 visitChildren(ref);
1361}
1362
1364{
1365 if (m_hide) return;
1366 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocSecRefList &)}\n");
1367 m_t << "{\n";
1369 m_t << rtf_Style_Reset << getStyle("LatexTOC") << "\n";
1370 m_t << "\\par\n";
1372 visitChildren(l);
1374 m_t << "\\par";
1375 m_t << "}\n";
1377}
1378
1380{
1381 if (m_hide) return;
1382 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamSect &)}\n");
1383 m_t << "{"; // start param list
1384 if (!m_lastIsPara) m_t << "\\par\n";
1385 //m_t << "{\\b "; // start bold
1386 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1387 switch(s.type())
1388 {
1390 m_t << theTranslator->trParameters(); break;
1392 m_t << theTranslator->trReturnValues(); break;
1394 m_t << theTranslator->trExceptions(); break;
1396 m_t << theTranslator->trTemplateParameters(); break;
1397 default:
1398 ASSERT(0);
1399 }
1400 m_t << "\\par";
1401 m_t << "}\n";
1402 bool useTable = s.type()==DocParamSect::Param ||
1406 if (!useTable)
1407 {
1409 }
1410 m_t << rtf_Style_Reset << getStyle("DescContinue");
1412 visitChildren(s);
1413 //m_t << "\\par\n";
1414 if (!useTable)
1415 {
1417 }
1418 m_t << "}\n";
1419}
1420
1422{
1423 m_t << " " << sep.chars() << " ";
1424}
1425
1427{
1428 static int columnPos[4][5] =
1429 { { 2, 25, 100, 100, 100 }, // no inout, no type
1430 { 3, 14, 35, 100, 100 }, // inout, no type
1431 { 3, 25, 50, 100, 100 }, // no inout, type
1432 { 4, 14, 35, 55, 100 }, // inout, type
1433 };
1434 int config=0;
1435 if (m_hide) return;
1436 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocParamList &)}\n");
1437
1439 const DocParamSect *sect = std::get_if<DocParamSect>(pl.parent());
1440 if (sect)
1441 {
1442 parentType = sect->type();
1443 }
1444 bool useTable = parentType==DocParamSect::Param ||
1445 parentType==DocParamSect::RetVal ||
1446 parentType==DocParamSect::Exception ||
1447 parentType==DocParamSect::TemplateParam;
1448 if (sect && sect->hasInOutSpecifier()) config+=1;
1449 if (sect && sect->hasTypeSpecifier()) config+=2;
1450 if (useTable)
1451 {
1452 m_t << "\\trowd \\trgaph108\\trleft426\\tblind426"
1453 "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1454 "\\trbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1455 "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1456 "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 "
1457 "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 "
1458 "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< "\n";
1459 for (int i=0;i<columnPos[config][0];i++)
1460 {
1461 m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10\\brdrcf15 "
1462 "\\clbrdrl\\brdrs\\brdrw10\\brdrcf15 "
1463 "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 "
1464 "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 "
1465 "\\cltxlrtb "
1466 "\\cellx" << (rtf_pageWidth*columnPos[config][i+1]/100) << "\n";
1467 }
1468 m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1469 }
1470
1471 if (sect && sect->hasInOutSpecifier())
1472 {
1473 if (useTable)
1474 {
1475 m_t << "{";
1476 }
1477
1478 // Put in the direction: in/out/in,out if specified.
1480 {
1481 if (pl.direction()==DocParamSect::In)
1482 {
1483 m_t << "in";
1484 }
1485 else if (pl.direction()==DocParamSect::Out)
1486 {
1487 m_t << "out";
1488 }
1489 else if (pl.direction()==DocParamSect::InOut)
1490 {
1491 m_t << "in,out";
1492 }
1493 }
1494
1495 if (useTable)
1496 {
1497 m_t << "\\cell }";
1498 }
1499 }
1500
1501 if (sect && sect->hasTypeSpecifier())
1502 {
1503 if (useTable)
1504 {
1505 m_t << "{";
1506 }
1507 for (const auto &type : pl.paramTypes())
1508 {
1509 std::visit(*this,type);
1510 }
1511 if (useTable)
1512 {
1513 m_t << "\\cell }";
1514 }
1515 }
1516
1517
1518 if (useTable)
1519 {
1520 m_t << "{";
1521 }
1522
1523 m_t << "{\\i ";
1524 bool first=TRUE;
1525 for (const auto &param : pl.parameters())
1526 {
1527 if (!first) m_t << ","; else first=FALSE;
1528 std::visit(*this,param);
1529 }
1530 m_t << "} ";
1531
1532 if (useTable)
1533 {
1534 m_t << "\\cell }{";
1535 }
1537
1538 for (const auto &par : pl.paragraphs())
1539 {
1540 std::visit(*this,par);
1541 }
1542
1543 if (useTable)
1544 {
1545 m_t << "\\cell }\n";
1546 //m_t << "\\pard \\widctlpar\\intbl\\adjustright\n";
1547 m_t << "{\\row }\n";
1548 }
1549 else
1550 {
1551 m_t << "\\par\n";
1552 }
1553
1555}
1556
1558{
1559 if (m_hide) return;
1560 if (x.title().isEmpty()) return;
1561 bool anonymousEnum = x.file()=="@";
1562 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocXRefItem &)}\n");
1563 if (!m_lastIsPara)
1564 {
1565 m_t << "\\par\n";
1567 }
1568 m_t << "{"; // start param list
1569 //m_t << "{\\b "; // start bold
1570 m_t << "{" << rtf_Style["Heading5"].reference() << "\n";
1571 if (Config_getBool(RTF_HYPERLINKS) && !anonymousEnum)
1572 {
1573 QCString refName;
1574 if (!x.file().isEmpty())
1575 {
1576 refName+=stripPath(x.file());
1577 }
1578 if (!x.file().isEmpty() && !x.anchor().isEmpty())
1579 {
1580 refName+="_";
1581 }
1582 if (!x.anchor().isEmpty())
1583 {
1584 refName+=x.anchor();
1585 }
1586
1587 m_t << "{\\field "
1588 "{\\*\\fldinst "
1589 "{ HYPERLINK \\\\l \"" << rtfFormatBmkStr(refName) << "\" "
1590 "}{}"
1591 "}"
1592 "{\\fldrslt "
1593 "{\\cs37\\ul\\cf2 ";
1594 filter(x.title());
1595 m_t << "}"
1596 "}"
1597 "}";
1598 }
1599 else
1600 {
1601 filter(x.title());
1602 }
1603 m_t << ":";
1604 m_t << "\\par";
1605 m_t << "}"; // end bold
1607 m_t << rtf_Style_Reset << getStyle("DescContinue");
1609 visitChildren(x);
1610 if (x.title().isEmpty()) return;
1611 DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocXRefItem)}\n");
1612 m_t << "\\par\n";
1614 m_t << "}\n"; // end xref item
1616}
1617
1619{
1620 if (m_hide) return;
1621 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocInternalRef &)}\n");
1622 startLink("",ref.file(),ref.anchor());
1623 visitChildren(ref);
1624 endLink("");
1625 m_t << " ";
1626}
1627
1629{
1630 if (m_hide) return;
1631 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocText &)}\n");
1632 visitChildren(t);
1633}
1634
1636{
1637 if (m_hide) return;
1638 DBG_RTF("{\\comment RTFDocVisitor::operator()(const DocHtmlBlockQuote &)}\n");
1639 if (!m_lastIsPara) m_t << "\\par\n";
1640 m_t << "{"; // start desc
1642 m_t << rtf_Style_Reset << getStyle("DescContinue");
1643 visitChildren(q);
1644 if (!m_lastIsPara) m_t << "\\par\n";
1646 m_t << "}"; // end desc
1648}
1649
1651{
1652}
1653
1655{
1656 if (m_hide) return;
1657 visitChildren(pb);
1658}
1659
1660
1661//static char* getMultiByte(int c)
1662//{
1663// static char s[10];
1664// sprintf(s,"\\'%X",c);
1665// return s;
1666//}
1667
1668void RTFDocVisitor::filter(const QCString &str,bool verbatim)
1669{
1670 if (!str.isEmpty())
1671 {
1672 const char *p=str.data();
1673 while (*p)
1674 {
1675 char c=*p++;
1676 switch (c)
1677 {
1678 case '{': m_t << "\\{"; break;
1679 case '}': m_t << "\\}"; break;
1680 case '\\': m_t << "\\\\"; break;
1681 case '\n': if (verbatim)
1682 {
1683 m_t << "\\par\n";
1684 }
1685 else
1686 {
1687 m_t << '\n';
1688 }
1689 break;
1690 default: m_t << c;
1691 }
1692 }
1693 }
1694}
1695
1696void RTFDocVisitor::startLink(const QCString &ref,const QCString &file,const QCString &anchor)
1697{
1698 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1699 {
1700 QCString refName;
1701 if (!file.isEmpty())
1702 {
1703 refName+=stripPath(file);
1704 }
1705 if (!file.isEmpty() && !anchor.isEmpty())
1706 {
1707 refName+='_';
1708 }
1709 if (!anchor.isEmpty())
1710 {
1711 refName+=anchor;
1712 }
1713
1714 m_t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \"";
1715 m_t << rtfFormatBmkStr(refName);
1716 m_t << "\" }{}";
1717 m_t << "}{\\fldrslt {\\cs37\\ul\\cf2 ";
1718 }
1719 else
1720 {
1721 m_t << "{\\b ";
1722 }
1724}
1725
1727{
1728 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
1729 {
1730 m_t << "}}}";
1731 }
1732 else
1733 {
1734 m_t << "}";
1735 }
1737}
1738
1740{
1741 writeDotFile(df.file(), df.hasCaption(), df.srcFile(), df.srcLine());
1742}
1743void RTFDocVisitor::writeDotFile(const QCString &filename, bool hasCaption,
1744 const QCString &srcFile, int srcLine)
1745{
1746 QCString baseName=makeBaseName(filename);
1747 QCString outDir = Config_getString(RTF_OUTPUT);
1748 writeDotGraphFromFile(filename,outDir,baseName,GraphOutputFormat::BITMAP,srcFile,srcLine);
1749 QCString imgExt = getDotImageExtension();
1750 includePicturePreRTF(baseName + "." + imgExt, true, hasCaption);
1751}
1752
1754{
1755 writeMscFile(df.file(), df.hasCaption(), df.srcFile(), df.srcLine());
1756}
1757void RTFDocVisitor::writeMscFile(const QCString &fileName, bool hasCaption,
1758 const QCString &srcFile, int srcLine)
1759{
1760 QCString baseName=makeBaseName(fileName);
1761 QCString outDir = Config_getString(RTF_OUTPUT);
1762 writeMscGraphFromFile(fileName,outDir,baseName,MscOutputFormat::BITMAP,srcFile,srcLine);
1763 includePicturePreRTF(baseName + ".png", true, hasCaption);
1764}
1765
1767{
1768 QCString baseName=makeBaseName(df.file());
1769 QCString outDir = Config_getString(RTF_OUTPUT);
1770 writeDiaGraphFromFile(df.file(),outDir,baseName,DiaOutputFormat::BITMAP,df.srcFile(),df.srcLine());
1771 includePicturePreRTF(baseName + ".png", true, df.hasCaption());
1772}
1773
1774void RTFDocVisitor::writePlantUMLFile(const QCString &fileName, bool hasCaption)
1775{
1776 QCString baseName=makeBaseName(fileName);
1777 QCString outDir = Config_getString(RTF_OUTPUT);
1779 includePicturePreRTF(baseName + ".png", true, hasCaption);
1780}
void parseCodeFragment(OutputCodeList &codeOutList, const QCString &fileName, const QCString &blockId, const QCString &scopeName, bool showLineNumbers, bool trimLeft, bool stripCodeComments)
static CodeFragmentManager & instance()
virtual void parseCode(OutputCodeList &codeOutList, const QCString &scopeName, const QCString &input, SrcLangExt lang, bool stripCodeComments, const CodeParserOptions &options)=0
Parses a source file or fragment with the goal to produce highlighted and cross-referenced output.
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:959
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:1941
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:2189
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:165
StringVector writePlantUMLSource(const QCString &outDirArg, const QCString &fileName, const QCString &content, OutputFormat format, const QCString &engine, const QCString &srcFile, int srcLine, bool inlineCode)
Write a PlantUML compatible file.
Definition plantuml.cpp:31
static PlantumlManager & instance()
Definition plantuml.cpp:231
void generatePlantUMLOutput(const QCString &baseName, const QCString &outDir, OutputFormat format)
Convert a PlantUML file to an image.
Definition plantuml.cpp:202
This is an alternative implementation of QCString.
Definition qcstring.h:101
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
bool startsWith(const char *s) const
Definition qcstring.h:507
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:241
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
const std::string & str() const
Definition qcstring.h:552
QCString & setNum(short n)
Definition qcstring.h:459
QCString right(size_t len) const
Definition qcstring.h:234
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
@ ExplicitSize
Definition qcstring.h:146
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:96
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:172
void startLink(const QCString &ref, const QCString &file, const QCString &anchor)
void filter(const QCString &str, bool verbatim=FALSE)
int indentLevel() const
void visitChildren(const T &t)
void 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:649
Portable versions of functions that are platform dependent.
const char * qPrint(const char *s)
Definition qcstring.h:687
#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
Options to configure the code parser.
Definition parserintf.h:78
CodeParserOptions & setStartLine(int lineNr)
Definition parserintf.h:101
CodeParserOptions & setInlineFragment(bool enable)
Definition parserintf.h:107
CodeParserOptions & setShowLineNumbers(bool enable)
Definition parserintf.h:113
CodeParserOptions & setFileDef(const FileDef *fd)
Definition parserintf.h:98
QCString reference() const
Definition rtfstyle.h:69
SrcLangExt
Definition types.h:207
SrcLangExt getLanguageFromFileName(const QCString &fileName, SrcLangExt defLang)
Definition util.cpp:5159
QCString integerToRoman(int n, bool upper)
Definition util.cpp:6662
QCString stripPath(const QCString &s)
Definition util.cpp:4902
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:5498
SrcLangExt getLanguageFromCodeLang(QCString &fileName)
Routine to handle the language attribute of the \code command.
Definition util.cpp:5177
QCString integerToAlpha(int n, bool upper)
Definition util.cpp:6646
QCString getDotImageExtension()
Definition util.cpp:6253
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:5821
QCString getFileNameExtension(const QCString &fn)
Definition util.cpp:5201
A bunch of utility functions.