diff options
Diffstat (limited to 'src/definition.cpp')
-rw-r--r-- | src/definition.cpp | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/src/definition.cpp b/src/definition.cpp index 5cde4ce..b55eed5 100644 --- a/src/definition.cpp +++ b/src/definition.cpp @@ -867,24 +867,53 @@ bool readCodeFragment(const char *fileName, return found; } +QCString Definition::getSourceFileBase() const +{ + ASSERT(definitionType()!=Definition::TypeFile); // file overloads this method + QCString fn; + static bool sourceBrowser = Config_getBool("SOURCE_BROWSER"); + if (sourceBrowser && + m_impl->body && m_impl->body->startLine!=-1 && m_impl->body->fileDef) + { + fn = m_impl->body->fileDef->getSourceFileBase(); + } + return fn; +} + +QCString Definition::getSourceAnchor() const +{ + QCString anchorStr; + if (m_impl->body && m_impl->body->startLine!=-1) + { + if (Htags::useHtags) + { + anchorStr.sprintf("L%d",m_impl->body->startLine); + } + else + { + anchorStr.sprintf("l%05d",m_impl->body->startLine); + } + } + return anchorStr; +} + /*! Write a reference to the source code defining this definition */ void Definition::writeSourceDef(OutputList &ol,const char *) { - static bool sourceBrowser = Config_getBool("SOURCE_BROWSER"); static bool latexSourceCode = Config_getBool("LATEX_SOURCE_CODE"); ol.pushGeneratorState(); //printf("Definition::writeSourceRef %d %p\n",bodyLine,bodyDef); - if (sourceBrowser && - m_impl->body && m_impl->body->startLine!=-1 && m_impl->body->fileDef) + QCString fn = getSourceFileBase(); + if (!fn.isEmpty()) { QCString refText = theTranslator->trDefinedAtLineInSourceFile(); int lineMarkerPos = refText.find("@0"); int fileMarkerPos = refText.find("@1"); if (lineMarkerPos!=-1 && fileMarkerPos!=-1) // should always pass this. { - QCString lineStr,anchorStr; + QCString lineStr; lineStr.sprintf("%d",m_impl->body->startLine); - anchorStr.sprintf(Htags::useHtags ? "L%d" : "l%05d",m_impl->body->startLine); + QCString anchorStr = getSourceAnchor(); ol.startParagraph(); if (lineMarkerPos<fileMarkerPos) // line marker before file marker { @@ -898,8 +927,7 @@ void Definition::writeSourceDef(OutputList &ol,const char *) ol.disable(OutputGenerator::Latex); } // write line link (HTML, LaTeX optionally) - ol.writeObjectLink(0,m_impl->body->fileDef->getSourceFileBase(), - anchorStr,lineStr); + ol.writeObjectLink(0,fn,anchorStr,lineStr); ol.enableAll(); ol.disable(OutputGenerator::Html); if (latexSourceCode) @@ -922,8 +950,7 @@ void Definition::writeSourceDef(OutputList &ol,const char *) ol.disable(OutputGenerator::Latex); } // write line link (HTML, LaTeX optionally) - ol.writeObjectLink(0,m_impl->body->fileDef->getSourceFileBase(), - 0,m_impl->body->fileDef->name()); + ol.writeObjectLink(0,fn,0,m_impl->body->fileDef->name()); ol.enableAll(); ol.disable(OutputGenerator::Html); if (latexSourceCode) @@ -950,8 +977,7 @@ void Definition::writeSourceDef(OutputList &ol,const char *) ol.disable(OutputGenerator::Latex); } // write file link (HTML only) - ol.writeObjectLink(0,m_impl->body->fileDef->getSourceFileBase(), - 0,m_impl->body->fileDef->name()); + ol.writeObjectLink(0,fn,0,m_impl->body->fileDef->name()); ol.enableAll(); ol.disable(OutputGenerator::Html); if (latexSourceCode) @@ -975,8 +1001,7 @@ void Definition::writeSourceDef(OutputList &ol,const char *) } ol.disableAllBut(OutputGenerator::Html); // write line link (HTML only) - ol.writeObjectLink(0,m_impl->body->fileDef->getSourceFileBase(), - anchorStr,lineStr); + ol.writeObjectLink(0,fn,anchorStr,lineStr); ol.enableAll(); ol.disable(OutputGenerator::Html); if (latexSourceCode) |