summaryrefslogtreecommitdiffstats
path: root/src/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp384
1 files changed, 377 insertions, 7 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 5be38ca..9afb8ac 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -2286,7 +2286,7 @@ bool resolveRef(/* in */ const char *scName,
/* out */ MemberDef **resMember
)
{
- //printf("resolveRef(scName=%s,name=%s,inSeeBlock=%d,rt=%s)\n",scName,name,inSeeBlock,rt);
+ //printf("resolveRef(scName=%s,name=%s,inSeeBlock=%d)\n",scName,name,inSeeBlock);
QCString tsName = name;
bool memberScopeFirst = tsName.find('#')!=-1;
@@ -2473,7 +2473,7 @@ bool resolveLink(/* in */ const char *scName,
/* out */ QCString &resAnchor
)
{
- //printf("resolveLink clName=`%s' lr=`%s' lt=`%s'\n",clName,lr,lt);
+ //printf("resolveLink clName=`%s' lr=`%s'\n",scName,lr);
*resContext=0;
*resPageInfo=0;
@@ -2542,6 +2542,15 @@ bool generateLink(OutputDocInterface &od,const char *clName,
Definition *compound;
PageInfo *pageInfo;
QCString anchor,linkText=lt;
+ if (linkText.isEmpty())
+ {
+ linkText=substitute(lr,"#","::");
+ // strip :: prefix if present
+ if (linkText.at(0)==':' && linkText.at(1)==':')
+ {
+ linkText=linkText.right(linkText.length()-2);
+ }
+ }
if (resolveLink(clName,lr,inSeeBlock,&compound,&pageInfo,anchor))
{
if (pageInfo) // link to page
@@ -3386,10 +3395,12 @@ void addRelatedPage(const char *name,const QCString &ptitle,
)
{
PageInfo *pi=0;
+ //printf("addRelatedPage(name=%s gd=%p)\n",name,gd);
if ((pi=Doxygen::pageSDict->find(name)) && !tagInfo)
{
// append documentation block to the page.
pi->doc+="\n\n"+doc;
+ //printf("Adding page docs `%s' pi=%p name=%s\n",doc.data(),pi,name);
}
else // new page
{
@@ -3431,6 +3442,7 @@ void addRelatedPage(const char *name,const QCString &ptitle,
pi->fileName = pageName;
pi->addSections(anchors);
+ //printf("Appending page `%s'\n",baseName.data());
Doxygen::pageSDict->append(baseName,pi);
if (gd) gd->addPage(pi);
@@ -3458,7 +3470,7 @@ void addRelatedPage(const char *name,const QCString &ptitle,
// si->label.data(),si->definition?si->definition->name().data():"<none>",
// si->fileName.data());
//printf(" SectionInfo: sec=%p sec->fileName=%s\n",si,si->fileName.data());
- //printf("Adding section info %s\n",pi->name.data());
+ //printf("Adding section key=%s si->fileName=%s\n",pageName.data(),si->fileName.data());
Doxygen::sectionDict.insert(pageName,si);
}
}
@@ -3470,6 +3482,7 @@ void addRefItem(const QList<ListItemInfo> *sli,
const char *prefix,
const char *name,const char *title,const char *args)
{
+ //printf("addRefItem(%s,%s,%s,%s)\n",prefix,name,title,args);
if (sli)
{
QListIterator<ListItemInfo> slii(*sli);
@@ -3478,18 +3491,18 @@ void addRefItem(const QList<ListItemInfo> *sli,
{
RefList *refList = Doxygen::specialLists->find(lii->type);
ASSERT(refList!=0);
- //printf("addRefItem(%s) todoId=%d testId=%d bugId=%d\n",name,todoId,testId,bugId);
if (Config_getBool(refList->optionName()))
{
RefItem *item = refList->getRefItem(lii->itemId);
ASSERT(item!=0);
if (item->written) return;
+ //printf("anchor=%s\n",item->listAnchor.data());
QCString doc(1000);
- doc += "<dl><dt>\\anchor ";
+ doc = "\\anchor ";
doc += item->listAnchor;
- doc += " ";
+ doc += " <dl><dt>";
doc += prefix;
doc += " \\_internalref ";
doc += name;
@@ -3500,7 +3513,6 @@ void addRefItem(const QList<ListItemInfo> *sli,
doc += "</dt>\n<dd>";
doc += item->text;
doc += "</dd></dl>\n";
- //printf("Todo page: %s\n",doc.data());
addRelatedPage(refList->listName(),refList->pageTitle(),doc,0,"generated",1,0,0,0);
item->written=TRUE;
}
@@ -3532,3 +3544,361 @@ void addGroupListToTitle(OutputList &ol,Definition *d)
}
}
+/*!
+ * Function converts Latin1 character to latex string representin the same
+ * character.
+ */
+static void latin1ToLatex(QTextStream &t,unsigned char c)
+{
+ switch (c)
+ {
+ // the Latin-1 characters
+ case 161: t << "!`"; break;
+ case 181: t << "$\\mu$"; break;
+ case 191: t << "?`"; break;
+ case 192: t << "\\`{A}"; break;
+ case 193: t << "\\'{A}"; break;
+ case 194: t << "\\^{A}"; break;
+ case 195: t << "\\~{A}"; break;
+ case 196: t << "\\\"{A}"; break;
+ case 197: t << "\\AA{}"; break;
+ case 198: t << "\\AE{}"; break;
+ case 199: t << "\\c{C}"; break;
+ case 200: t << "\\`{E}"; break;
+ case 201: t << "\\'{E}"; break;
+ case 202: t << "\\^{E}"; break;
+ case 203: t << "\\\"{E}"; break;
+ case 204: t << "\\`{I}"; break;
+ case 205: t << "\\'{I}"; break;
+ case 206: t << "\\^{I}"; break;
+ case 207: t << "\\\"{I}"; break;
+ case 208: t << "D "; break; // anyone know the real code?
+ case 209: t << "\\~{N}"; break;
+ case 210: t << "\\`{O}"; break;
+ case 211: t << "\\'{O}"; break;
+ case 212: t << "\\^{O}"; break;
+ case 213: t << "\\~{O}"; break;
+ case 214: t << "\\\"{O}"; break;
+ case 215: t << "$\\times$"; break;
+ case 216: t << "\\O"; break;
+ case 217: t << "\\`{U}"; break;
+ case 218: t << "\\'{U}"; break;
+ case 219: t << "\\^{U}"; break;
+ case 220: t << "\\\"{U}"; break;
+ case 221: t << "\\'{Y}"; break;
+ case 223: t << "\\ss{}"; break;
+ case 224: t << "\\`{a}"; break;
+ case 225: t << "\\'{a}"; break;
+ case 226: t << "\\^{a}"; break;
+ case 227: t << "\\~{a}"; break;
+ case 228: t << "\\\"{a}"; break;
+ case 229: t << "\\aa{}"; break;
+ case 230: t << "\\ae{}"; break;
+ case 231: t << "\\c{c}"; break;
+ case 232: t << "\\`{e}"; break;
+ case 233: t << "\\'{e}"; break;
+ case 234: t << "\\^{e}"; break;
+ case 235: t << "\\\"{e}"; break;
+ case 236: t << "\\`{\\i}"; break;
+ case 237: t << "\\'{\\i}"; break;
+ case 238: t << "\\^{\\i}"; break;
+ case 239: t << "\\\"{\\i}"; break;
+ case 241: t << "\\~{n}"; break;
+ case 242: t << "\\`{o}"; break;
+ case 243: t << "\\'{o}"; break;
+ case 244: t << "\\^{o}"; break;
+ case 245: t << "\\~{o}"; break;
+ case 246: t << "\\\"{o}"; break;
+ case 248: t << "\\o{}"; break;
+ case 249: t << "\\`{u}"; break;
+ case 250: t << "\\'{u}"; break;
+ case 251: t << "\\^{u}"; break;
+ case 252: t << "\\\"{u}"; break;
+ case 253: t << "\\'{y}"; break;
+ case 255: t << "\\\"{y}"; break;
+ default: t << c;
+ }
+}
+
+/*!
+ * Function converts Latin2 character to latex string representin the same
+ * character.
+ */
+static void latin2ToLatex(QTextStream &t,unsigned char c)
+{
+ switch (c)
+ {
+ case 0xA1: t << c; break;
+ case 0xA2: t << c; break;
+ case 0xA3: t << c; break;
+ case 0xA4: t << c; break;
+ case 0xA5: t << c; break;
+ case 0xA6: t << "\\'{S}"; break;
+ case 0xA7: t << c; break;
+ case 0xA8: t << c; break;
+ case 0xA9: t << "\\v{S}"; break;
+ case 0xAA: t << "\\c{S}"; break;
+ case 0xAB: t << "\\v{T}"; break;
+ case 0xAC: t << "\\'{Z}"; break;
+ case 0xAD: t << c; break;
+ case 0xAE: t << "\\v{Z}"; break;
+ case 0xAF: t << "\\.{Z}"; break;
+
+ case 0xB0: t << c; break;
+ case 0xB1: t << c; break;
+ case 0xB2: t << c; break;
+ case 0xB3: t << c; break;
+ case 0xB4: t << c; break;
+ case 0xB5: t << c; break;
+ case 0xB6: t << "\\'{s}"; break;
+ case 0xB7: t << c; break;
+ case 0xB8: t << c; break;
+ case 0xB9: t << "\\v{s}"; break;
+ case 0xBA: t << "\\c{s}"; break;
+ case 0xBB: t << "\\v{t}"; break;
+ case 0xBC: t << "\\'{z}"; break;
+ case 0xBD: t << c; break;
+ case 0xBE: t << "\\v{z}"; break;
+ case 0xBF: t << "\\.{z}"; break;
+
+ case 0xC0: t << "\\'{R}"; break;
+ case 0xC1: t << "\\'{A}"; break;
+ case 0xC2: t << "\\^{A}"; break;
+ case 0xC3: t << "\\u{A}"; break;
+ case 0xC4: t << "\\\"{A}"; break;
+ case 0xC5: t << "\\'{L}"; break;
+ case 0xC6: t << "\\'{C}"; break;
+ case 0xC7: t << "\\c{C}"; break;
+ case 0xC8: t << "\\v{C}"; break;
+ case 0xC9: t << "\\'{E}"; break;
+ case 0xCA: t << "\\c{E}"; break;
+ case 0xCB: t << "\\\"{E}"; break;
+ case 0xCC: t << "\\v{E}"; break;
+ case 0xCD: t << "\\'{I}"; break;
+ case 0xCE: t << "\\^{I}"; break;
+ case 0xCF: t << "\\v{D}"; break;
+
+ case 0xD0: t << "\\bar{D}"; break;
+ case 0xD1: t << "\\'{N}"; break;
+ case 0xD2: t << "\\v{N}"; break;
+ case 0xD3: t << "\\'{O}"; break;
+ case 0xD4: t << "\\^{O}"; break;
+ case 0xD5: t << "\\H{O}"; break;
+ case 0xD6: t << "\\\"{O}"; break;
+ case 0xD7: t << c; break;
+ case 0xD8: t << "\\v{R}"; break;
+ case 0xD9: t << c; break;
+ case 0xDA: t << "\\'{U}"; break;
+ case 0xDB: t << "\\H{U}"; break;
+ case 0xDC: t << "\\\"{U}"; break;
+ case 0xDD: t << "\\'{Y}"; break;
+ case 0xDE: t << "\\c{T}"; break;
+ case 0xDF: t << "\\ss"; break;
+
+ case 0xE0: t << "\\'{r}"; break;
+ case 0xE1: t << "\\'{a}"; break;
+ case 0xE2: t << "\\^{a}"; break;
+ case 0xE3: t << c; break;
+ case 0xE4: t << "\\\"{a}"; break;
+ case 0xE5: t << "\\'{l}"; break;
+ case 0xE6: t << "\\'{c}"; break;
+ case 0xE7: t << "\\c{c}"; break;
+ case 0xE8: t << "\\v{c}"; break;
+ case 0xE9: t << "\\'{e}"; break;
+ case 0xEA: t << c; break;
+ case 0xEB: t << "\\\"{e}"; break;
+ case 0xEC: t << "\\v{e}"; break;
+ case 0xED: t << "\\'{\\i}"; break;
+ case 0xEE: t << "\\^{\\i}"; break;
+ case 0xEF: t << "\\v{d}"; break;
+
+ case 0xF0: t << "\\bar{d}"; break;
+ case 0xF1: t << "\\'{n}"; break;
+ case 0xF2: t << "\\v{n}"; break;
+ case 0xF3: t << "\\'{o}"; break;
+ case 0xF4: t << "\\^{o}"; break;
+ case 0xF5: t << "\\H{o}"; break;
+ case 0xF6: t << "\\\"{o}"; break;
+ case 0xF7: t << c; break;
+ case 0xF8: t << "\\v{r}"; break;
+ case 0xF9: t << c; break;
+ case 0xFA: t << "\\'{u}"; break;
+ case 0xFB: t << "\\H{u}"; break;
+ case 0xFC: t << "\\\"{u}"; break;
+ case 0xFD: t << "\\'{y}"; break;
+ case 0xFE: t << c; break;
+ case 0xFF: t << c; break;
+
+ default: t << c;
+ }
+}
+
+void filterLatexString(QTextStream &t,const char *str,
+ bool insideTabbing,bool insidePre)
+{
+ static bool isCzech = theTranslator->idLanguage()=="czech";
+ static bool isJapanese = theTranslator->idLanguage()=="japanese";
+ static bool isKorean = theTranslator->idLanguage()=="korean";
+ static bool isRussian = theTranslator->idLanguage()=="russian";
+ static bool isUkrainian = theTranslator->idLanguage()=="ukrainian";
+ static bool isChinese = theTranslator->idLanguage()=="chinese" ||
+ theTranslator->idLanguage()=="chinese-traditional";
+ static bool isLatin2 = theTranslator->idLanguageCharset()=="iso-8859-2";
+ static bool isGreek = theTranslator->idLanguage()=="greek";
+ if (str)
+ {
+ const unsigned char *p=(const unsigned char *)str;
+ unsigned char c;
+ unsigned char pc='\0';
+ while (*p)
+ {
+ c=*p++;
+
+ if (insidePre)
+ {
+ switch(c)
+ {
+ case '\\': t << "\\(\\backslash\\)"; break;
+ case '{': t << "\\{"; break;
+ case '}': t << "\\}"; break;
+ default:
+ {
+ // Some languages use wide characters
+ if (c>=128 && (isJapanese || isKorean || isChinese))
+ {
+ t << (char)c;
+ if (*p)
+ {
+ c = *p++;
+ t << (char)c;
+ }
+ }
+ else
+ {
+ t << (char)c;
+ }
+ break;
+ }
+ }
+ }
+ else
+ {
+ switch(c)
+ {
+ case '#': t << "\\#"; break;
+ case '$': t << "\\$"; break;
+ case '%': t << "\\%"; break;
+ case '^': t << "$^\\wedge$"; break;
+ case '&': t << "\\&"; break;
+ case '*': t << "$\\ast$"; break;
+ case '_': t << "\\_";
+ if (!insideTabbing) t << "\\-";
+ break;
+ case '{': t << "\\{"; break;
+ case '}': t << "\\}"; break;
+ case '<': t << "$<$"; break;
+ case '>': t << "$>$"; break;
+ case '|': t << "$|$"; break;
+ case '~': t << "$\\sim$"; break;
+ case '[': if (Config_getBool("PDF_HYPERLINKS"))
+ t << "\\mbox{[}";
+ else
+ t << "[";
+ break;
+ case ']': if (pc=='[') t << "$\\,$";
+ if (Config_getBool("PDF_HYPERLINKS"))
+ t << "\\mbox{]}";
+ else
+ t << "]";
+ break;
+ case '-': if (*p=='>')
+ { t << " $\\rightarrow$ "; p++; }
+ else
+ { t << (char)c; }
+ break;
+ case '\\': if (*p=='<')
+ { t << "$<$"; p++; }
+ else if (*p=='>')
+ { t << "$>$"; p++; }
+ else
+ { t << "$\\backslash$"; }
+ break;
+ case '"': { t << "\\char`\\\"{}"; }
+ break;
+
+ default:
+ {
+ // Some languages use wide characters
+ if (isJapanese || isKorean || isChinese)
+ {
+ if (c>=128)
+ {
+ t << (char)c;
+ if (*p)
+ {
+ c = *p++;
+ t << (char)c;
+ }
+ }
+ else // ascii char => see if we can insert a hypenation hint
+ {
+ if (isupper(c) && islower(pc) && !insideTabbing) t << "\\-";
+ t << (char)c;
+ }
+ }
+ else if (isCzech || isRussian || isUkrainian)
+ {
+ if (c>=128)
+ {
+ t << (char)c;
+ }
+ else // ascii char => see if we can insert a hypenation hint
+ {
+ if (isupper(c) && islower(pc) && !insideTabbing) t << "\\-";
+ t << (char)c;
+ }
+ }
+ else if (isGreek)
+ {
+ if (c<128)
+ {
+ t << "\\textlatin{" << (char)c << "}";
+ }
+ else
+ {
+ t << (char)c;
+ }
+ }
+ else if (isLatin2)
+ {
+ if (c>=128)
+ {
+ latin2ToLatex(t,c);
+ }
+ else
+ {
+ // see if we can insert an hyphenation hint
+ if (isupper(c) && islower(pc) && !insideTabbing) t << "\\-";
+ t << (char)c;
+ }
+ }
+ else // another language => assume latin1 charset
+ {
+ if (c>=128)
+ {
+ latin1ToLatex(t,c);
+ }
+ else
+ {
+ // see if we can insert an hyphenation hint
+ if (isupper(c) && islower(pc) && !insideTabbing) t << "\\-";
+ t << (char)c;
+ }
+ }
+ }
+ }
+ }
+ pc = c;
+ }
+ }
+}