diff options
author | albert-github <albert.tests@gmail.com> | 2020-03-21 15:16:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-21 15:16:50 (GMT) |
commit | f788f684f055c5470d624f3c27c6e236f18c2c31 (patch) | |
tree | 5a7d04854e0606058096c6b984dee652ce89616d /src | |
parent | d165a89863eab073702afb0e19b44cf2e85f7db5 (diff) | |
download | Doxygen-f788f684f055c5470d624f3c27c6e236f18c2c31.zip Doxygen-f788f684f055c5470d624f3c27c6e236f18c2c31.tar.gz Doxygen-f788f684f055c5470d624f3c27c6e236f18c2c31.tar.bz2 |
Missing anchors in RTF code output (#7647)
When having the RTF_SOURCE_CODE and RTF_HYPERLINKS set the links to the code are generated (e.g. in "Definition at line") but the corresponding anchor is missing.
The corresponding anchors are created (in a similar way as it is done for LaTeX).
Diffstat (limited to 'src')
-rw-r--r-- | src/rtfgen.cpp | 38 | ||||
-rw-r--r-- | src/rtfgen.h | 3 |
2 files changed, 39 insertions, 2 deletions
diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp index ae1a77e..1a11989 100644 --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -79,6 +79,16 @@ RTFGenerator::~RTFGenerator() { } +void RTFGenerator::setRelativePath(const QCString &path) +{ + m_relPath = path; +} + +void RTFGenerator::setSourceFileName(const QCString &name) +{ + m_sourceFileName = name; +} + void RTFGenerator::writeStyleSheetFile(QFile &file) { FTextStream t(&file); @@ -358,6 +368,8 @@ void RTFGenerator::startFile(const char *name,const char *,const char *) if (fileName.right(4)!=".rtf" ) fileName+=".rtf"; startPlainFile(fileName); + setRelativePath(m_relPath); + setSourceFileName(stripPath(fileName)); beginRTFDocument(); } @@ -367,6 +379,7 @@ void RTFGenerator::endFile() t << "}"; endPlainFile(); + setSourceFileName(""); } void RTFGenerator::startProjectNumber() @@ -3024,12 +3037,33 @@ void RTFGenerator::endInlineMemberDoc() t << "\\cell }{\\row }" << endl; } -void RTFGenerator::writeLineNumber(const char *,const char *,const char *,int l) +void RTFGenerator::writeLineNumber(const char *ref,const char *fileName,const char *anchor,int l) { + static bool rtfHyperlinks = Config_getBool(RTF_HYPERLINKS); + DoxyCodeLineOpen = TRUE; QCString lineNumber; lineNumber.sprintf("%05d",l); - t << lineNumber << " "; + if (m_prettyCode) + { + if (fileName && !m_sourceFileName.isEmpty() && rtfHyperlinks) + { + QCString lineAnchor; + lineAnchor.sprintf("_l%05d",l); + lineAnchor.prepend(stripExtensionGeneral(m_sourceFileName, ".rtf")); + t << "{\\bkmkstart "; + t << rtfFormatBmkStr(lineAnchor); + t << "}"; + t << "{\\bkmkend "; + t << rtfFormatBmkStr(lineAnchor); + t << "}" << endl; + } + t << lineNumber << " "; + } + else + { + t << l << " "; + } m_col=0; } void RTFGenerator::startCodeLine(bool) diff --git a/src/rtfgen.h b/src/rtfgen.h index 1750a7b..9330b13 100644 --- a/src/rtfgen.h +++ b/src/rtfgen.h @@ -32,6 +32,8 @@ class RTFGenerator : public OutputGenerator static void writeStyleSheetFile(QFile &f); static void writeExtensionsFile(QFile &file); + void setRelativePath(const QCString &path); + void setSourceFileName(const QCString &sourceFileName); void enable() { if (m_genStack->top()) m_active=*m_genStack->top(); else m_active=TRUE; } void disable() { m_active=FALSE; } @@ -279,6 +281,7 @@ class RTFGenerator : public OutputGenerator const char *rtf_Code_DepthStyle(); void incrementIndentLevel(); void decrementIndentLevel(); + QCString m_sourceFileName; int m_col; bool m_prettyCode; |