doxygen
rtfgen.h
1 /******************************************************************************
2  *
3  * Copyright (C) 1997-2023 by Parker Waechter & 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 #ifndef RTFGEN_H
17 #define RTFGEN_H
18 
19 #include <array>
20 
21 #include "config.h"
22 #include "outputgen.h"
23 
24 class OutputCodeList;
25 
28 {
29  public:
31  void setTextStream(TextStream *t) { m_t = t; }
32 
33  OutputType type() const { return OutputType::RTF; }
34  void codify(const QCString &text);
35  void writeCodeLink(CodeSymbolType type,
36  const QCString &ref,const QCString &file,
37  const QCString &anchor,const QCString &name,
38  const QCString &tooltip);
39  void writeTooltip(const QCString &,
40  const DocLinkInfo &,
41  const QCString &,
42  const QCString &,
43  const SourceLinkInfo &,
44  const SourceLinkInfo &
45  ) {}
46  void writeLineNumber(const QCString &,const QCString &,const QCString &,int l, bool);
47  void startCodeLine(int);
48  void endCodeLine();
49  void startFontClass(const QCString &);
50  void endFontClass();
51  void writeCodeAnchor(const QCString &) {}
52  void startCodeFragment(const QCString &style);
53  void endCodeFragment(const QCString &);
54  void startFold(int,const QCString &,const QCString &) {}
55  void endFold() {}
56 
57  private:
58  friend class RTFGenerator;
59  void setSourceFileName(const QCString &name);
60  void setIndentLevel(int level) { m_indentLevel=level; }
61  QCString rtf_Code_DepthStyle();
62  int m_col = 0;
63  TextStream *m_t;
64  bool m_doxyCodeLineOpen = false;
65  QCString m_sourceFileName;
66  int m_indentLevel = 0;
67 };
68 
69 
72 {
73  public:
74  RTFGenerator();
75  RTFGenerator(const RTFGenerator &);
76  RTFGenerator &operator=(const RTFGenerator &);
78  RTFGenerator &operator=(RTFGenerator &&) = delete;
79  ~RTFGenerator();
80 
81  static void init();
82  void cleanup();
83  static void writeStyleSheetFile(TextStream &t);
84  static void writeExtensionsFile(TextStream &t);
85  OutputType type() const { return OutputType::RTF; }
86 
87  void setRelativePath(const QCString &path);
88  void setSourceFileName(const QCString &sourceFileName);
89 
90  void writeDoc(const IDocNodeAST *ast,const Definition *,const MemberDef *,int);
91 
92  void startFile(const QCString &name,const QCString &manName,const QCString &title,int id,int hierarchyLevel);
93  void writeSearchInfo() {}
94  void writeFooter(const QCString &) {}
95  void endFile();
96  void clearBuffer();
97 
98  void startPageDoc(const QCString &) {}
99  void endPageDoc() {}
100  void startIndexSection(IndexSection);
101  void endIndexSection(IndexSection);
102  void writePageLink(const QCString &,bool);
103  void startProjectNumber();
104  void endProjectNumber();
105  void writeStyleInfo(int part);
106  void startTitleHead(const QCString &);
107  void endTitleHead(const QCString &,const QCString &name);
108 
109  void startParagraph(const QCString &classDef);
110  void endParagraph();
111  void writeString(const QCString &text);
112  void startIndexListItem();
113  void endIndexListItem();
114  void startIndexList();
115  void endIndexList();
116  void startIndexKey();
117  void endIndexKey();
118  void startIndexValue(bool);
119  void endIndexValue(const QCString &,bool);
120  void startItemList();
121  void endItemList();
122  void startIndexItem(const QCString &ref,const QCString &file);
123  void endIndexItem(const QCString &ref,const QCString &file);
124  void docify(const QCString &text);
125  void writeObjectLink(const QCString &ref,const QCString &file,
126  const QCString &anchor,const QCString &name);
127  void startTextLink(const QCString &f,const QCString &anchor);
128  void endTextLink();
129  void startTypewriter() { m_t << "{\\f2 "; }
130  void endTypewriter() { m_t << "}"; }
131  void startGroupHeader(int);
132  void endGroupHeader(int);
133  void startItemListItem();
134  void endItemListItem();
135 
136  void startMemberSections() {}
137  void endMemberSections() {}
138  void startHeaderSection() {}
139  void endHeaderSection() {}
140  void startMemberHeader(const QCString &,int) { startGroupHeader(0); }
141  void endMemberHeader() { endGroupHeader(FALSE); }
142  void startMemberSubtitle();
143  void endMemberSubtitle();
144  void startMemberDocList() {}
145  void endMemberDocList() {}
146  void startMemberList();
147  void endMemberList();
148  void startInlineHeader();
149  void endInlineHeader();
150  void startAnonTypeScope(int) {}
151  void endAnonTypeScope(int) {}
152  void startMemberItem(const QCString &,MemberItemType,const QCString &);
153  void endMemberItem(MemberItemType);
154  void startMemberTemplateParams() {}
155  void endMemberTemplateParams(const QCString &,const QCString &) {}
156  void startCompoundTemplateParams();
157  void endCompoundTemplateParams();
158  void insertMemberAlign(bool) {}
159  void insertMemberAlignLeft(MemberItemType,bool){}
160 
161  void writeRuler() { rtfwriteRuler_thin(); }
162 
163  void writeAnchor(const QCString &fileName,const QCString &name);
164  void startEmphasis() { m_t << "{\\i "; }
165  void endEmphasis() { m_t << "}"; }
166  void startBold() { m_t << "{\\b "; }
167  void endBold() { m_t << "}"; }
168  void lineBreak(const QCString &style=QCString());
169  void startMemberDoc(const QCString &,const QCString &,const QCString &,const QCString &,int,int,bool);
170  void endMemberDoc(bool);
171  void startDoxyAnchor(const QCString &,const QCString &,const QCString &,const QCString &,const QCString &);
172  void endDoxyAnchor(const QCString &,const QCString &);
173  void addLabel(const QCString &,const QCString &);
174  void writeChar(char c);
175  void writeLatexSpacing() {};//{ m_t << "\\hspace{0.3cm}"; }
176  void writeStartAnnoItem(const QCString &type,const QCString &file,
177  const QCString &path,const QCString &name);
178  void startCenter() { m_t << "{\\qc\n"; }
179  void endCenter() { m_t << "}"; }
180  void startSmall() { m_t << "{\\sub "; }
181  void endSmall() { m_t << "}"; }
182 
183  void startMemberDescription(const QCString &,const QCString &,bool);
184  void endMemberDescription();
185  void startMemberDeclaration() {}
186  void endMemberDeclaration(const QCString &,const QCString &) {}
187  void writeInheritedSectionTitle(const QCString &,const QCString &,const QCString &,
188  const QCString &,const QCString &,const QCString &);
189  void startExamples();
190  void endExamples();
191  void startDescForItem();
192  void endDescForItem();
193  void startSection(const QCString &,const QCString &,SectionType);
194  void endSection(const QCString &,SectionType);
195  void addIndexItem(const QCString &,const QCString &);
196  void startIndent();
197  void endIndent();
198  void writeSynopsis() {}
199  void startClassDiagram();
200  void endClassDiagram(const ClassDiagram &,const QCString &filename,const QCString &name);
201  void startPageRef();
202  void endPageRef(const QCString &,const QCString &);
203  void startQuickIndices() {}
204  void endQuickIndices() {}
205  void writeSplitBar(const QCString &) {}
206  void writeNavigationPath(const QCString &) {}
207  void writeLogo() {}
208  void writeQuickLinks(HighlightedItem,const QCString &) {}
209  void writeSummaryLink(const QCString &,const QCString &,const QCString &,bool) {}
210  void startContents() {}
211  void endContents() {}
212  void writeNonBreakableSpace(int);
213 
214  void startDescTable(const QCString &title);
215  void endDescTable();
216  void startDescTableRow();
217  void endDescTableRow();
218  void startDescTableTitle();
219  void endDescTableTitle();
220  void startDescTableData();
221  void endDescTableData();
222 
223  void startDotGraph();
224  void endDotGraph(DotClassGraph &);
225  void startInclDepGraph();
226  void endInclDepGraph(DotInclDepGraph &);
227  void startGroupCollaboration();
228  void endGroupCollaboration(DotGroupCollaboration &g);
229  void startCallGraph();
230  void endCallGraph(DotCallGraph &);
231  void startDirDepGraph();
232  void endDirDepGraph(DotDirDeps &g);
233  void writeGraphicalHierarchy(DotGfxHierarchyTable &) {}
234 
235  void startMemberGroupHeader(bool);
236  void endMemberGroupHeader();
237  void startMemberGroupDocs();
238  void endMemberGroupDocs();
239  void startMemberGroup();
240  void endMemberGroup(bool);
241 
242  void startTextBlock(bool dense);
243  void endTextBlock(bool);
244  void lastIndexPage();
245 
246  void startMemberDocPrefixItem() {}
247  void endMemberDocPrefixItem() {}
248  void startMemberDocName(bool) {}
249  void endMemberDocName() {}
250  void startParameterType(bool,const QCString &);
251  void endParameterType();
252  void startParameterName(bool) {}
253  void endParameterName() {}
254  void startParameterExtra() {}
255  void endParameterExtra(bool,bool,bool);
256  void startParameterDefVal(const char *s) { docify(s); startTypewriter(); }
257  void endParameterDefVal() { endTypewriter(); }
258  void startParameterList(bool);
259  void endParameterList() {}
260  void exceptionEntry(const QCString &,bool);
261 
262  void startConstraintList(const QCString &);
263  void startConstraintParam();
264  void endConstraintParam();
265  void startConstraintType();
266  void endConstraintType();
267  void startConstraintDocs();
268  void endConstraintDocs();
269  void endConstraintList();
270 
271  void startMemberDocSimple(bool);
272  void endMemberDocSimple(bool);
273  void startInlineMemberType();
274  void endInlineMemberType();
275  void startInlineMemberName();
276  void endInlineMemberName();
277  void startInlineMemberDoc();
278  void endInlineMemberDoc();
279 
280  void startLabels();
281  void writeLabel(const QCString &l,bool isLast);
282  void endLabels();
283 
284  void writeLocalToc(const SectionRefs &,const LocalToc &) {}
285 
286  static bool preProcessFileInplace(const QCString &path,const QCString &name);
287 
288  void addCodeGen(OutputCodeList &list);
289 
290  private:
291  QCString rtf_BList_DepthStyle();
292  QCString rtf_CList_DepthStyle();
293  QCString rtf_EList_DepthStyle();
294  QCString rtf_LCList_DepthStyle();
295  QCString rtf_DList_DepthStyle();
296  void beginRTFDocument();
297  void beginRTFChapter();
298  void beginRTFSection();
299  void rtfwriteRuler_doubleline();
300  void rtfwriteRuler_emboss();
301  void rtfwriteRuler_thick();
302  void rtfwriteRuler_thin();
303  void writeRTFReference(const QCString &label);
304  void newParagraph();
305 
306  int indentLevel() const;
307  void incIndentLevel();
308  void decIndentLevel();
309 
310  bool m_bstartedBody = false; // has startbody been called yet?
311  bool m_omitParagraph = false; // should a the next paragraph command be ignored?
312  int m_numCols = 0; // number of columns in a table
313  QCString m_relPath;
314  int m_hierarchyLevel = 0;
315 
316  // RTF does not really have a additive indent...manually set list level.
317  static const int maxIndentLevels = 13;
318  int m_indentLevel = 0;
319  struct RTFListItemInfo
320  {
321  bool isEnum = false;
322  int number = 1;
323  char type = '1';
324  };
325  std::array<RTFListItemInfo,maxIndentLevels> m_listItemInfo;
326  std::unique_ptr<OutputCodeList> m_codeList;
327  RTFCodeGenerator *m_codeGen;
328 };
329 
330 QCString rtfFormatBmkStr(const QCString &name);
331 
332 
333 #endif
The common base class of all entity definitions found in the sources.
Definition: definition.h:74
A model of a class/file/namespace member symbol.
Definition: memberdef.h:47
Text streaming class that buffers data.
Definition: textstream.h:34
Generator for RTF code fragments.
Definition: rtfgen.h:27
class that represents a list of constant references to sections.
Definition: section.h:104
Generator for RTF output.
Definition: rtfgen.h:71
Represents a graphical class hierarchy.
Definition: dotgfxhierarchytable.h:31
Definition: types.h:308
Representation of a group collaboration graph.
Definition: dotgroupcollaboration.h:28
opaque representation of the abstract syntax tree (AST)
Definition: docparser.h:46
Class representing a list of different code generators.
Definition: outputlist.h:199
Class representing a built-in class diagram.
Definition: diagram.h:29
Definition: section.h:27
Representation of an call graph.
Definition: dotcallgraph.h:26
Representation of a class inheritance or dependency graph.
Definition: dotclassgraph.h:28
Base class for specific output generators.
Definition: outputgen.h:64
Representation of an include dependency graph.
Definition: dotincldepgraph.h:30
Representation of an directory dependency graph.
Definition: dotdirdeps.h:25
This is an alternative implementation of QCString.
Definition: qcstring.h:93
Definition: outputgen.h:49
Definition: outputgen.h:41