diff options
Diffstat (limited to 'src/definition.cpp')
-rw-r--r-- | src/definition.cpp | 114 |
1 files changed, 79 insertions, 35 deletions
diff --git a/src/definition.cpp b/src/definition.cpp index d2e3e01..6cb26de 100644 --- a/src/definition.cpp +++ b/src/definition.cpp @@ -58,10 +58,10 @@ class DefinitionImpl SectionDict *sectionDict; // dictionary of all sections, not accessible - MemberSDict *sourceRefByDict; - MemberSDict *sourceRefsDict; - QList<ListItemInfo> *xrefListItems; - GroupList *partOfGroups; + MemberSDict *sourceRefByDict; + MemberSDict *sourceRefsDict; + QList<ListItemInfo> *xrefListItems; + GroupList *partOfGroups; DocInfo *details; // not exported DocInfo *inbodyDocs; // not exported @@ -89,11 +89,11 @@ class DefinitionImpl QCString id; // clang unique id }; -DefinitionImpl::DefinitionImpl() - : sectionDict(0), sourceRefByDict(0), sourceRefsDict(0), +DefinitionImpl::DefinitionImpl() + : sectionDict(0), sourceRefByDict(0), sourceRefsDict(0), xrefListItems(0), partOfGroups(0), - details(0), inbodyDocs(0), brief(0), body(0), - outerScope(0) + details(0), inbodyDocs(0), brief(0), body(0), hidden(FALSE), isArtificial(FALSE), + outerScope(0), lang(SrcLangExt_Unknown) { } @@ -755,6 +755,7 @@ bool readCodeFragment(const char *fileName, { while ((c=fgetc(f))!='\n' && c!=EOF) /* skip */; lineNr++; + if (found && c == '\n') c = '\0'; } if (!feof(f)) { @@ -763,7 +764,7 @@ bool readCodeFragment(const char *fileName, while (lineNr<=endLine && !feof(f) && !found) { int pc=0; - while ((c=fgetc(f))!='{' && c!=':' && c!=EOF) + while ((c=fgetc(f))!='{' && c!=':' && c!=EOF) // } so vi matching brackets has no problem { //printf("parsing char `%c'\n",c); if (c=='\n') @@ -816,7 +817,7 @@ bool readCodeFragment(const char *fileName, result+=spaces; } // copy until end of line - result+=c; + if (c) result+=c; startLine=lineNr; if (c==':') { @@ -890,16 +891,17 @@ QCString Definition::getSourceFileBase() const QCString Definition::getSourceAnchor() const { - QCString anchorStr; + const int maxAnchorStrLen = 20; + char anchorStr[maxAnchorStrLen]; if (m_impl->body && m_impl->body->startLine!=-1) { if (Htags::useHtags) { - anchorStr.sprintf("L%d",m_impl->body->startLine); + qsnprintf(anchorStr,maxAnchorStrLen,"L%d",m_impl->body->startLine); } else { - anchorStr.sprintf("l%05d",m_impl->body->startLine); + qsnprintf(anchorStr,maxAnchorStrLen,"l%05d",m_impl->body->startLine); } } return anchorStr; @@ -909,6 +911,7 @@ QCString Definition::getSourceAnchor() const void Definition::writeSourceDef(OutputList &ol,const char *) { static bool latexSourceCode = Config_getBool("LATEX_SOURCE_CODE"); + static bool rtfSourceCode = Config_getBool("RTF_SOURCE_CODE"); ol.pushGeneratorState(); //printf("Definition::writeSourceRef %d %p\n",bodyLine,bodyDef); QCString fn = getSourceFileBase(); @@ -928,13 +931,16 @@ void Definition::writeSourceDef(OutputList &ol,const char *) // write text left from linePos marker ol.parseText(refText.left(lineMarkerPos)); ol.pushGeneratorState(); - ol.disable(OutputGenerator::RTF); ol.disable(OutputGenerator::Man); if (!latexSourceCode) { ol.disable(OutputGenerator::Latex); } - // write line link (HTML, LaTeX optionally) + if (!rtfSourceCode) + { + ol.disable(OutputGenerator::RTF); + } + // write line link (HTML, LaTeX optionally, RTF optionally) ol.writeObjectLink(0,fn,anchorStr,lineStr); ol.enableAll(); ol.disable(OutputGenerator::Html); @@ -942,7 +948,11 @@ void Definition::writeSourceDef(OutputList &ol,const char *) { ol.disable(OutputGenerator::Latex); } - // write normal text (Man/RTF, Latex optionally) + if (rtfSourceCode) + { + ol.disable(OutputGenerator::RTF); + } + // write normal text (Man, Latex optionally, RTF optionally) ol.docify(lineStr); ol.popGeneratorState(); @@ -951,13 +961,16 @@ void Definition::writeSourceDef(OutputList &ol,const char *) fileMarkerPos-lineMarkerPos-2)); ol.pushGeneratorState(); - ol.disable(OutputGenerator::RTF); ol.disable(OutputGenerator::Man); if (!latexSourceCode) { ol.disable(OutputGenerator::Latex); } - // write file link (HTML, LaTeX optionally) + if (!rtfSourceCode) + { + ol.disable(OutputGenerator::RTF); + } + // write file link (HTML, LaTeX optionally, RTF optionally) ol.writeObjectLink(0,fn,0,m_impl->body->fileDef->name()); ol.enableAll(); ol.disable(OutputGenerator::Html); @@ -965,7 +978,11 @@ void Definition::writeSourceDef(OutputList &ol,const char *) { ol.disable(OutputGenerator::Latex); } - // write normal text (Man/RTF, Latex optionally) + if (rtfSourceCode) + { + ol.disable(OutputGenerator::RTF); + } + // write normal text (Man, Latex optionally, RTF optionally) ol.docify(m_impl->body->fileDef->name()); ol.popGeneratorState(); @@ -978,12 +995,15 @@ void Definition::writeSourceDef(OutputList &ol,const char *) // write text left from file marker ol.parseText(refText.left(fileMarkerPos)); ol.pushGeneratorState(); - ol.disable(OutputGenerator::RTF); ol.disable(OutputGenerator::Man); if (!latexSourceCode) { ol.disable(OutputGenerator::Latex); } + if (!rtfSourceCode) + { + ol.disable(OutputGenerator::RTF); + } // write file link (HTML only) ol.writeObjectLink(0,fn,0,m_impl->body->fileDef->name()); ol.enableAll(); @@ -992,7 +1012,11 @@ void Definition::writeSourceDef(OutputList &ol,const char *) { ol.disable(OutputGenerator::Latex); } - // write normal text (Latex/Man only) + if (rtfSourceCode) + { + ol.disable(OutputGenerator::RTF); + } + // write normal text (RTF/Latex/Man only) ol.docify(m_impl->body->fileDef->name()); ol.popGeneratorState(); @@ -1001,12 +1025,15 @@ void Definition::writeSourceDef(OutputList &ol,const char *) lineMarkerPos-fileMarkerPos-2)); ol.pushGeneratorState(); - ol.disable(OutputGenerator::RTF); ol.disable(OutputGenerator::Man); if (!latexSourceCode) { ol.disable(OutputGenerator::Latex); } + if (!rtfSourceCode) + { + ol.disable(OutputGenerator::RTF); + } ol.disableAllBut(OutputGenerator::Html); // write line link (HTML only) ol.writeObjectLink(0,fn,anchorStr,lineStr); @@ -1016,6 +1043,10 @@ void Definition::writeSourceDef(OutputList &ol,const char *) { ol.disable(OutputGenerator::Latex); } + if (rtfSourceCode) + { + ol.disable(OutputGenerator::RTF); + } // write normal text (Latex/Man only) ol.docify(lineStr); ol.popGeneratorState(); @@ -1105,6 +1136,7 @@ void Definition::_writeSourceRefList(OutputList &ol,const char *scopeName, const QCString &text,MemberSDict *members,bool /*funcOnly*/) { static bool latexSourceCode = Config_getBool("LATEX_SOURCE_CODE"); + static bool rtfSourceCode = Config_getBool("RTF_SOURCE_CODE"); static bool sourceBrowser = Config_getBool("SOURCE_BROWSER"); static bool refLinkSource = Config_getBool("REFERENCES_LINK_SOURCE"); ol.pushGeneratorState(); @@ -1157,14 +1189,18 @@ void Definition::_writeSourceRefList(OutputList &ol,const char *scopeName, ol.pushGeneratorState(); //ol.disableAllBut(OutputGenerator::Html); - ol.disable(OutputGenerator::RTF); ol.disable(OutputGenerator::Man); if (!latexSourceCode) { ol.disable(OutputGenerator::Latex); } - QCString lineStr,anchorStr; - anchorStr.sprintf("l%05d",md->getStartBodyLine()); + if (!rtfSourceCode) + { + ol.disable(OutputGenerator::RTF); + } + const int maxLineNrStr = 10; + char anchorStr[maxLineNrStr]; + qsnprintf(anchorStr,maxLineNrStr,"l%05d",md->getStartBodyLine()); //printf("Write object link to %s\n",md->getBodyDef()->getSourceFileBase().data()); ol.writeObjectLink(0,md->getBodyDef()->getSourceFileBase(),anchorStr,name); ol.popGeneratorState(); @@ -1176,6 +1212,10 @@ void Definition::_writeSourceRefList(OutputList &ol,const char *scopeName, { ol.disable(OutputGenerator::Latex); } + if (!rtfSourceCode) + { + ol.disable(OutputGenerator::RTF); + } ol.docify(name); ol.popGeneratorState(); } @@ -1184,12 +1224,15 @@ void Definition::_writeSourceRefList(OutputList &ol,const char *scopeName, // for HTML write a real link ol.pushGeneratorState(); //ol.disableAllBut(OutputGenerator::Html); - ol.disable(OutputGenerator::RTF); ol.disable(OutputGenerator::Man); if (!latexSourceCode) { ol.disable(OutputGenerator::Latex); } + if (!rtfSourceCode) + { + ol.disable(OutputGenerator::RTF); + } ol.writeObjectLink(md->getReference(), md->getOutputFileBase(), @@ -1203,6 +1246,10 @@ void Definition::_writeSourceRefList(OutputList &ol,const char *scopeName, { ol.disable(OutputGenerator::Latex); } + if (rtfSourceCode) + { + ol.disable(OutputGenerator::RTF); + } ol.docify(name); ol.popGeneratorState(); } @@ -1286,9 +1333,6 @@ void Definition::addSourceReferencedBy(MemberDef *md) void Definition::addSourceReferences(MemberDef *md) { - QCString name = md->name(); - QCString scope = md->getScopeString(); - if (md) { QCString name = md->name(); @@ -1524,12 +1568,12 @@ QCString Definition::navigationPathAsString() const if (definitionType()==Definition::TypeGroup && ((const GroupDef*)this)->groupTitle()) { result+="<a class=\"el\" href=\"$relpath^"+getOutputFileBase()+Doxygen::htmlFileExtension+"\">"+ - ((const GroupDef*)this)->groupTitle()+"</a>"; + convertToHtml(((const GroupDef*)this)->groupTitle())+"</a>"; } else if (definitionType()==Definition::TypePage && !((const PageDef*)this)->title().isEmpty()) { result+="<a class=\"el\" href=\"$relpath^"+getOutputFileBase()+Doxygen::htmlFileExtension+"\">"+ - ((const PageDef*)this)->title()+"</a>"; + convertToHtml(((const PageDef*)this)->title())+"</a>"; } else if (definitionType()==Definition::TypeClass) { @@ -1540,17 +1584,17 @@ QCString Definition::navigationPathAsString() const } result+="<a class=\"el\" href=\"$relpath^"+getOutputFileBase()+Doxygen::htmlFileExtension; if (!anchor().isEmpty()) result+="#"+anchor(); - result+="\">"+name+"</a>"; + result+="\">"+convertToHtml(name)+"</a>"; } else { result+="<a class=\"el\" href=\"$relpath^"+getOutputFileBase()+Doxygen::htmlFileExtension+"\">"+ - locName+"</a>"; + convertToHtml(locName)+"</a>"; } } else { - result+="<b>"+locName+"</b>"; + result+="<b>"+convertToHtml(locName)+"</b>"; } result+="</li>"; return result; @@ -1618,7 +1662,7 @@ void Definition::writeToc(OutputList &ol) } cs[0]='0'+nextLevel; if (inLi[nextLevel]) ol.writeString("</li>\n"); - ol.writeString("<li class=\"level"+QCString(cs)+"\"><a href=\"#"+si->label+"\">"+si->title+"</a>"); + ol.writeString("<li class=\"level"+QCString(cs)+"\"><a href=\"#"+si->label+"\">"+(si->title.isEmpty()?si->label:si->title)+"</a>"); inLi[nextLevel]=TRUE; level = nextLevel; } |