Skip to main content

The RTFCodeGenerator Class Reference

Generator for RTF code fragments. More...

Declaration

class RTFCodeGenerator { ... }

Included Headers

#include <src/rtfgen.h>

Base class

classOutputCodeIntf

Base class for code generators. More...

Friends Index

classRTFGenerator

Public Constructors Index

RTFCodeGenerator (TextStream *t)

Public Member Functions Index

voidsetTextStream (TextStream *t)
OutputTypetype () const override
voidcodify (const QCString &text) override
voidstripCodeComments (bool b) override
voidstartSpecialComment () override
voidendSpecialComment () override
voidsetStripIndentAmount (size_t amount) override
std::unique_ptr< OutputCodeIntf >clone () override
voidwriteCodeLink (CodeSymbolType type, const QCString &ref, const QCString &file, const QCString &anchor, const QCString &name, const QCString &tooltip) override
voidwriteTooltip (const QCString &, const DocLinkInfo &, const QCString &, const QCString &, const SourceLinkInfo &, const SourceLinkInfo &) override
voidwriteLineNumber (const QCString &, const QCString &, const QCString &, int l, bool) override
voidstartCodeLine (int) override
voidendCodeLine () override
voidstartFontClass (const QCString &) override
voidendFontClass () override
voidwriteCodeAnchor (const QCString &) override
voidstartCodeFragment (const QCString &style) override
voidendCodeFragment (const QCString &) override
voidstartFold (int, const QCString &, const QCString &) override
voidendFold () override

Private Member Functions Index

voidsetSourceFileName (const QCString &name)
voidsetIndentLevel (int level)
QCStringrtf_Code_DepthStyle ()

Private Member Attributes Index

size_tm_col = 0
TextStream *m_t
boolm_doxyCodeLineOpen = false
QCStringm_sourceFileName
intm_indentLevel = 0
boolm_stripCodeComments = false
boolm_hide = false
size_tm_stripIndentAmount = 0

Description

Generator for RTF code fragments.

Definition at line 27 of file rtfgen.h.

Friends

RTFGenerator

friend class RTFGenerator

Definition at line 63 of file rtfgen.h.

63 friend class RTFGenerator;

Reference RTFGenerator.

Referenced by RTFGenerator.

Public Constructors

RTFCodeGenerator()

RTFCodeGenerator::RTFCodeGenerator (TextStream * t)

Declaration at line 30 of file rtfgen.h, definition at line 114 of file rtfgen.cpp.

Reference m_t.

Public Member Functions

clone()

std::unique_ptr< OutputCodeIntf > RTFCodeGenerator::clone ()
inline virtual

Definition at line 39 of file rtfgen.h.

39 std::unique_ptr<OutputCodeIntf> clone() override { return std::make_unique<RTFCodeGenerator>(*this); }

codify()

void RTFCodeGenerator::codify (const QCString & text)
virtual

Declaration at line 34 of file rtfgen.h, definition at line 153 of file rtfgen.cpp.

154{
155 // note that RTF does not have a "verbatim", so "\n" means
156 // nothing... add a "newParagraph()";
157 const int tabSize = Config_getInt(TAB_SIZE);
158 if (!str.isEmpty())
159 {
160 char c;
161 const char *p=str.data();
162 if (m_hide)
163 {
165 }
166 else
167 {
168 while ((c=*p++))
169 {
170 switch(c)
171 {
172 case '\t': {
173 int spacesToNextTabStop = tabSize - (m_col%tabSize);
174 while (spacesToNextTabStop--)
175 {
176 if (m_col>=m_stripIndentAmount) *m_t << " ";
177 m_col++;
178 }
179 }
180 break;
181 case ' ': if (m_col>=m_stripIndentAmount) *m_t << " ";
182 m_col++;
183 break;
184 case '\n': *m_t << "\\par\n";
185 m_col=0;
186 break;
187 case '{': *m_t << "\\{"; m_col++; break;
188 case '}': *m_t << "\\}"; m_col++; break;
189 case '\\': *m_t << "\\\\"; m_col++; break;
190 default: p=writeUTF8Char(*m_t,p-1); m_col++; break;
191 }
192 }
193 }
194 }
195}

References Config_getInt, QCString::data, QCString::isEmpty, m_col, m_hide, m_stripIndentAmount, m_t, updateColumnCount and writeUTF8Char.

Referenced by writeCodeLink.

endCodeFragment()

void RTFCodeGenerator::endCodeFragment (const QCString &)
virtual

Declaration at line 58 of file rtfgen.h, definition at line 225 of file rtfgen.cpp.

226{
228
229 DBG_RTF(*m_t << "{\\comment (endCodeFragment) }\n")
230 *m_t << "}\n";
231 //m_omitParagraph = TRUE;
232}

References DBG_RTF, endCodeLine and m_t.

endCodeLine()

void RTFCodeGenerator::endCodeLine ()
virtual

Declaration at line 53 of file rtfgen.h, definition at line 285 of file rtfgen.cpp.

286{
287 if (m_hide) return;
288 if (m_doxyCodeLineOpen) *m_t << "\\par\n";
289 m_doxyCodeLineOpen = false;
290}

References m_doxyCodeLineOpen, m_hide and m_t.

Referenced by endCodeFragment.

endFold()

void RTFCodeGenerator::endFold ()
inline virtual

Definition at line 60 of file rtfgen.h.

60 void endFold() override {}

endFontClass()

void RTFCodeGenerator::endFontClass ()
virtual

Declaration at line 55 of file rtfgen.h, definition at line 317 of file rtfgen.cpp.

318{
319 if (m_hide) return;
320 *m_t << "}";
321}

References m_hide and m_t.

endSpecialComment()

void RTFCodeGenerator::endSpecialComment ()
virtual

Declaration at line 37 of file rtfgen.h, definition at line 207 of file rtfgen.cpp.

208{
209 m_hide = false;
210}

Reference m_hide.

setStripIndentAmount()

void RTFCodeGenerator::setStripIndentAmount (size_t amount)
virtual

Declaration at line 38 of file rtfgen.h, definition at line 212 of file rtfgen.cpp.

213{
214 m_stripIndentAmount = amount;
215}

Reference m_stripIndentAmount.

setTextStream()

void RTFCodeGenerator::setTextStream (TextStream * t)
inline

Definition at line 31 of file rtfgen.h.

31 void setTextStream(TextStream *t) { m_t = t; }

Reference m_t.

startCodeFragment()

void RTFCodeGenerator::startCodeFragment (const QCString & style)
virtual

Declaration at line 57 of file rtfgen.h, definition at line 217 of file rtfgen.cpp.

218{
219 DBG_RTF(*m_t << "{\\comment (startCodeFragment) }\n")
220 *m_t << "{\n";
221 *m_t << "\\par\n";
223}

References DBG_RTF, m_t, rtf_Code_DepthStyle and rtf_Style_Reset.

startCodeLine()

void RTFCodeGenerator::startCodeLine (int)
virtual

Declaration at line 52 of file rtfgen.h, definition at line 278 of file rtfgen.cpp.

279{
280 if (m_hide) return;
281 m_doxyCodeLineOpen = true;
282 m_col=0;
283}

References m_col, m_doxyCodeLineOpen and m_hide.

startFold()

void RTFCodeGenerator::startFold (int, const QCString &, const QCString &)
inline virtual

Definition at line 59 of file rtfgen.h.

59 void startFold(int,const QCString &,const QCString &) override {}

startFontClass()

void RTFCodeGenerator::startFontClass (const QCString & name)
virtual

Declaration at line 54 of file rtfgen.h, definition at line 292 of file rtfgen.cpp.

293{
294 if (m_hide) return;
295 int cod = 2;
296 static const std::unordered_map<std::string,int> map {
297 { "keyword", 17 },
298 { "keywordtype", 18 },
299 { "keywordflow", 19 },
300 { "comment", 20 },
301 { "preprocessor", 21 },
302 { "stringliteral", 22 },
303 { "charliteral", 23 },
304 { "vhdldigit", 24 },
305 { "vhdlchar", 25 },
306 { "vhdlkeyword", 26 },
307 { "vhdllogic", 27 }
308 };
309 auto it = map.find(name.str());
310 if (it != map.end())
311 {
312 cod = it->second;
313 }
314 *m_t << "{\\cf" << cod << " ";
315}

References m_hide, m_t and QCString::str.

startSpecialComment()

void RTFCodeGenerator::startSpecialComment ()
virtual

Declaration at line 36 of file rtfgen.h, definition at line 202 of file rtfgen.cpp.

References m_hide and m_stripCodeComments.

stripCodeComments()

void RTFCodeGenerator::stripCodeComments (bool b)
virtual

Declaration at line 35 of file rtfgen.h, definition at line 197 of file rtfgen.cpp.

Reference m_stripCodeComments.

type()

OutputType RTFCodeGenerator::type ()
inline virtual

Definition at line 33 of file rtfgen.h.

33 OutputType type() const override { return OutputType::RTF; }

Reference RTF.

writeCodeAnchor()

void RTFCodeGenerator::writeCodeAnchor (const QCString &)
inline virtual

Definition at line 56 of file rtfgen.h.

56 void writeCodeAnchor(const QCString &) override {}

writeCodeLink()

void RTFCodeGenerator::writeCodeLink (CodeSymbolType type, const QCString & ref, const QCString & file, const QCString & anchor, const QCString & name, const QCString & tooltip)
virtual

Declaration at line 40 of file rtfgen.h, definition at line 118 of file rtfgen.cpp.

119 const QCString &ref,const QCString &f,
120 const QCString &anchor,const QCString &name,
121 const QCString &)
122{
123 m_col+=name.length();
124 if (m_hide) return;
125 if (ref.isEmpty() && Config_getBool(RTF_HYPERLINKS))
126 {
127 QCString refName;
128 if (!f.isEmpty())
129 {
130 refName+=stripPath(f);
131 }
132 if (!anchor.isEmpty())
133 {
134 refName+='_';
135 refName+=anchor;
136 }
137
138 *m_t << "{\\field {\\*\\fldinst { HYPERLINK \\\\l \"";
139 *m_t << rtfFormatBmkStr(refName);
140 *m_t << "\" }{}";
141 *m_t << "}{\\fldrslt {\\cs37\\ul\\cf2 ";
142
143 codify(name);
144
145 *m_t << "}}}\n";
146 }
147 else
148 {
149 codify(name);
150 }
151}

References codify, Config_getBool, QCString::isEmpty, QCString::length, m_col, m_hide, m_t, rtfFormatBmkStr and stripPath.

Referenced by writeLineNumber.

writeLineNumber()

void RTFCodeGenerator::writeLineNumber (const QCString & ref, const QCString & fileName, const QCString & anchor, int l, bool writeLineAnchor)
virtual

Declaration at line 51 of file rtfgen.h, definition at line 234 of file rtfgen.cpp.

234void RTFCodeGenerator::writeLineNumber(const QCString &ref,const QCString &fileName,const QCString &anchor,int l,bool writeLineAnchor)
235{
236 if (m_hide) return;
237 bool rtfHyperlinks = Config_getBool(RTF_HYPERLINKS);
238
239 m_doxyCodeLineOpen = true;
240 if (Config_getBool(SOURCE_BROWSER))
241 {
242 QCString lineNumber;
243 lineNumber.sprintf("%05d",l);
244
245 QCString lineAnchor;
246 if (!m_sourceFileName.isEmpty())
247 {
248 lineAnchor.sprintf("_l%05d",l);
250 }
251 bool showTarget = rtfHyperlinks && !lineAnchor.isEmpty() && writeLineAnchor;
252 if (showTarget)
253 {
254 *m_t << "{\\bkmkstart ";
255 *m_t << rtfFormatBmkStr(lineAnchor);
256 *m_t << "}";
257 *m_t << "{\\bkmkend ";
258 *m_t << rtfFormatBmkStr(lineAnchor);
259 *m_t << "}\n";
260 }
261 if (!fileName.isEmpty())
262 {
263 writeCodeLink(CodeSymbolType::Default,ref,fileName,anchor,lineNumber,QCString());
264 }
265 else
266 {
267 *m_t << lineNumber;
268 }
269 *m_t << " ";
270 }
271 else
272 {
273 *m_t << l << " ";
274 }
275 m_col=0;
276}

References Config_getBool, Default, QCString::isEmpty, m_col, m_doxyCodeLineOpen, m_hide, m_sourceFileName, m_t, QCString::prepend, rtfFormatBmkStr, QCString::sprintf, stripExtensionGeneral, stripPath and writeCodeLink.

writeTooltip()

void RTFCodeGenerator::writeTooltip (const QCString &, const DocLinkInfo &, const QCString &, const QCString &, const SourceLinkInfo &, const SourceLinkInfo &)
inline virtual

Definition at line 44 of file rtfgen.h.

44 void writeTooltip(const QCString &,
45 const DocLinkInfo &,
46 const QCString &,
47 const QCString &,
48 const SourceLinkInfo &,
49 const SourceLinkInfo &
50 ) override {}

Private Member Functions

rtf_Code_DepthStyle()

QCString RTFCodeGenerator::rtf_Code_DepthStyle ()

Declaration at line 66 of file rtfgen.h, definition at line 323 of file rtfgen.cpp.

324{
325 QCString n=makeIndexName("CodeExample",m_indentLevel);
326 return rtf_Style[n.str()].reference();
327}

References m_indentLevel, makeIndexName, rtf_Style and QCString::str.

Referenced by startCodeFragment.

setIndentLevel()

void RTFCodeGenerator::setIndentLevel (int level)
inline

Definition at line 65 of file rtfgen.h.

65 void setIndentLevel(int level) { m_indentLevel=level; }

Reference m_indentLevel.

setSourceFileName()

void RTFCodeGenerator::setSourceFileName (const QCString & name)

Declaration at line 64 of file rtfgen.h, definition at line 329 of file rtfgen.cpp.

330{
331 m_sourceFileName = name;
332}

Reference m_sourceFileName.

Private Member Attributes

m_col

size_t RTFCodeGenerator::m_col = 0

Definition at line 67 of file rtfgen.h.

67 size_t m_col = 0;

Referenced by codify, startCodeLine, writeCodeLink and writeLineNumber.

m_doxyCodeLineOpen

bool RTFCodeGenerator::m_doxyCodeLineOpen = false

Definition at line 69 of file rtfgen.h.

69 bool m_doxyCodeLineOpen = false;

Referenced by endCodeLine, startCodeLine and writeLineNumber.

m_hide

bool RTFCodeGenerator::m_hide = false

m_indentLevel

int RTFCodeGenerator::m_indentLevel = 0

Definition at line 71 of file rtfgen.h.

71 int m_indentLevel = 0;

Referenced by rtf_Code_DepthStyle and setIndentLevel.

m_sourceFileName

QCString RTFCodeGenerator::m_sourceFileName

Definition at line 70 of file rtfgen.h.

Referenced by setSourceFileName and writeLineNumber.

m_stripCodeComments

bool RTFCodeGenerator::m_stripCodeComments = false

Definition at line 72 of file rtfgen.h.

72 bool m_stripCodeComments = false;

Referenced by startSpecialComment and stripCodeComments.

m_stripIndentAmount

size_t RTFCodeGenerator::m_stripIndentAmount = 0

Definition at line 74 of file rtfgen.h.

Referenced by codify and setStripIndentAmount.

m_t

TextStream* RTFCodeGenerator::m_t

The documentation for this class was generated from the following files:


Generated via doxygen2docusaurus by Doxygen 1.14.0.