Skip to content

Commit

Permalink
Fixed problem with latex and PDF bookmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri van Heesch committed Nov 22, 2015
1 parent c5a7911 commit 499ecae
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 73 deletions.
83 changes: 10 additions & 73 deletions src/latexgen.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ static void writeDefaultHeaderPart1(FTextStream &t)
// To avoid duplicate page anchors due to reuse of same numbers for // To avoid duplicate page anchors due to reuse of same numbers for
// the index (be it as roman numbers) // the index (be it as roman numbers)
t << "\\hypersetup{pageanchor=false,\n" t << "\\hypersetup{pageanchor=false,\n"
<< " bookmarks=true,\n" // << " bookmarks=true,\n" // commented out to prevent warning
<< " bookmarksnumbered=true,\n" << " bookmarksnumbered=true,\n"
<< " pdfencoding=unicode\n" << " pdfencoding=unicode\n"
<< " }\n"; << " }\n";
Expand Down Expand Up @@ -1569,13 +1569,22 @@ void LatexGenerator::startMemberDoc(const char *clname,
} }
static const char *levelLab[] = { "subsubsection","paragraph","subparagraph", "subparagraph" }; static const char *levelLab[] = { "subsubsection","paragraph","subparagraph", "subparagraph" };
static bool compactLatex = Config_getBool("COMPACT_LATEX"); static bool compactLatex = Config_getBool("COMPACT_LATEX");
static bool pdfHyperlinks = Config_getBool("PDF_HYPERLINKS");
int level=0; int level=0;
if (showInline) level+=2; if (showInline) level+=2;
if (compactLatex) level++; if (compactLatex) level++;
t << "\\" << levelLab[level]; t << "\\" << levelLab[level];


t << "[{"; t << "[{";
if (pdfHyperlinks)
{
t << "\\texorpdfstring{";
}
t << latexEscapeIndexChars(title,insideTabbing); t << latexEscapeIndexChars(title,insideTabbing);
if (pdfHyperlinks)
{
t << "}{" << latexEscapePDFString(title) << "}";
}
t << "}]"; t << "}]";
t << "{\\setlength{\\rightskip}{0pt plus 5cm}"; t << "{\\setlength{\\rightskip}{0pt plus 5cm}";
disableLinks=TRUE; disableLinks=TRUE;
Expand Down Expand Up @@ -2088,78 +2097,6 @@ void LatexGenerator::endConstraintList()
t << "\\end{Desc}" << endl; t << "\\end{Desc}" << endl;
} }


#if 0
void LatexGenerator::escapeLabelName(const char *s)
{
if (s==0) return;
const char *p=s;
char c;
QCString result(qstrlen(s)+1); // worst case allocation
int i;
while ((c=*p++))
{
switch (c)
{
case '|': t << "\\texttt{\"|}"; break;
case '!': t << "\"!"; break;
case '%': t << "\\%"; break;
case '{': t << "\\lcurly{}"; break;
case '}': t << "\\rcurly{}"; break;
case '~': t << "````~"; break; // to get it a bit better in index together with other special characters
// NOTE: adding a case here, means adding it to while below as well!
default:
i=0;
// collect as long string as possible, before handing it to docify
result[i++]=c;
while ((c=*p) && c!='|' && c!='!' && c!='%' && c!='{' && c!='}' && c!='~')
{
result[i++]=c;
p++;
}
result[i]=0;
docify(result);
break;
}
}
}

void LatexGenerator::escapeMakeIndexChars(const char *s)
{
if (s==0) return;
const char *p=s;
char c;
QCString result(qstrlen(s)+1); // worst case allocation
int i;
while ((c=*p++))
{
switch (c)
{
case '!': t << "\"!"; break;
case '"': t << "\"\""; break;
case '@': t << "\"@"; break;
case '|': t << "\\texttt{\"|}"; break;
case '[': t << "["; break;
case ']': t << "]"; break;
case '{': t << "\\lcurly{}"; break;
case '}': t << "\\rcurly{}"; break;
// NOTE: adding a case here, means adding it to while below as well!
default:
i=0;
// collect as long string as possible, before handing it to docify
result[i++]=c;
while ((c=*p) && c!='"' && c!='@' && c!='[' && c!=']' && c!='!' && c!='{' && c!='}' && c!='|')
{
result[i++]=c;
p++;
}
result[i]=0;
docify(result);
break;
}
}
}
#endif

void LatexGenerator::startCodeFragment() void LatexGenerator::startCodeFragment()
{ {
t << "\n\\begin{DoxyCode}\n"; t << "\n\\begin{DoxyCode}\n";
Expand Down
23 changes: 23 additions & 0 deletions src/util.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6713,6 +6713,29 @@ QCString latexEscapeIndexChars(const char *s,bool insideTabbing)
return result.data(); return result.data();
} }


QCString latexEscapePDFString(const char *s)
{
QGString result;
FTextStream t(&result);
const char *p=s;
char c;
int i;
while ((c=*p++))
{
switch (c)
{
case '\\': t << "\\textbackslash{}"; break;
case '{': t << "\\{"; break;
case '}': t << "\\}"; break;
default:
t << c;
break;
}
}
return result.data();
}


QCString rtfFormatBmkStr(const char *name) QCString rtfFormatBmkStr(const char *name)
{ {
static QCString g_nextTag( "AAAAAAAAAA" ); static QCString g_nextTag( "AAAAAAAAAA" );
Expand Down
1 change: 1 addition & 0 deletions src/util.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ void filterLatexString(FTextStream &t,const char *str,


QCString latexEscapeLabelName(const char *s,bool insideTabbing); QCString latexEscapeLabelName(const char *s,bool insideTabbing);
QCString latexEscapeIndexChars(const char *s,bool insideTabbing); QCString latexEscapeIndexChars(const char *s,bool insideTabbing);
QCString latexEscapePDFString(const char *s);


QCString rtfFormatBmkStr(const char *name); QCString rtfFormatBmkStr(const char *name);


Expand Down

0 comments on commit 499ecae

Please sign in to comment.