mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-28 19:28:38 +00:00
treat special characters in bookmarks correctly
svn path=/trunk/KDE/kdegraphics/kdvi/; revision=428839
This commit is contained in:
parent
4854529853
commit
8192e730c2
3 changed files with 37 additions and 24 deletions
|
@ -548,14 +548,10 @@ bool dviRenderer::setFile(const QString &fname)
|
|||
|
||||
|
||||
// Generate the list of bookmarks
|
||||
kdError() << "========================================================" << endl;
|
||||
|
||||
QPtrStack<Bookmark> stack;
|
||||
stack.setAutoDelete (false);
|
||||
|
||||
QValueVector<PreBookmark>::iterator it;
|
||||
for( it = prebookmarks.begin(); it != prebookmarks.end(); ++it ) {
|
||||
kdError() << (*it).title << " has an count " << (*it).noOfChildren << endl;
|
||||
Bookmark *bmk = new Bookmark((*it).title, findAnchor((*it).anchorName));
|
||||
if (stack.isEmpty())
|
||||
bookmarks.append(bmk);
|
||||
|
@ -565,7 +561,6 @@ bool dviRenderer::setFile(const QString &fname)
|
|||
}
|
||||
for(int i=0; i<(*it).noOfChildren; i++)
|
||||
stack.push(bmk);
|
||||
|
||||
}
|
||||
prebookmarks.clear();
|
||||
|
||||
|
@ -720,24 +715,6 @@ void dviRenderer::handleSRCLink(const QString &linkText, QMouseEvent *e, Documen
|
|||
kdDebug(4300) << "Source hyperlink to " << currentDVIPage->sourceHyperLinkList[i].linkText << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
// QString cp = linkText;
|
||||
// int max = cp.length();
|
||||
// int i;
|
||||
// for(i=0; i<max; i++)
|
||||
// if (cp[i].isDigit() == false)
|
||||
// break;
|
||||
//
|
||||
// // The macro-package srcltx gives a special like "src:99 test.tex"
|
||||
// // while MikTeX gives "src:99test.tex". KDVI tries
|
||||
// // to understand both.
|
||||
// QFileInfo fi1(dviFile->filename);
|
||||
// QFileInfo fi2(fi1.dir(),cp.mid(i+1));
|
||||
//
|
||||
// //Sometimes the filename is passed without the .tex extension,
|
||||
// //better add it when necessary.
|
||||
// if ( !fi2.exists() )
|
||||
// fi2.setFile(fi2.absFilePath() + ".tex");
|
||||
|
||||
DVI_SourceFileSplitter splitter(linkText, dviFile->filename);
|
||||
QString TeXfile = splitter.filePath();
|
||||
|
@ -814,4 +791,35 @@ void dviRenderer::handleSRCLink(const QString &linkText, QMouseEvent *e, Documen
|
|||
}
|
||||
|
||||
|
||||
QString dviRenderer::PDFencodingToQString(QString pdfstring)
|
||||
{
|
||||
// This method locates special PDF characters in a string and
|
||||
// replaces them by UTF8. See Section 3.2.3 of the PDF reference
|
||||
// guide for information.
|
||||
pdfstring = pdfstring.replace("\\n", "\n");
|
||||
pdfstring = pdfstring.replace("\\r", "\n");
|
||||
pdfstring = pdfstring.replace("\\t", "\t");
|
||||
pdfstring = pdfstring.replace("\\f", "\f");
|
||||
pdfstring = pdfstring.replace("\\(", "(");
|
||||
pdfstring = pdfstring.replace("\\)", ")");
|
||||
pdfstring = pdfstring.replace("\\\\", "\\");
|
||||
|
||||
// Now replace octal character codes with the characters they encode
|
||||
int pos;
|
||||
QRegExp rx( "(\\\\)(\\d\\d\\d)" ); // matches "\xyz" where x,y,z are numbers
|
||||
while((pos = rx.search( pdfstring )) != -1) {
|
||||
pdfstring = pdfstring.replace(pos, 4, QChar(rx.cap(2).toInt(0,8)));
|
||||
}
|
||||
rx.setPattern( "(\\\\)(\\d\\d)" ); // matches "\xy" where x,y are numbers
|
||||
while((pos = rx.search( pdfstring )) != -1) {
|
||||
pdfstring = pdfstring.replace(pos, 3, QChar(rx.cap(2).toInt(0,8)));
|
||||
}
|
||||
rx.setPattern( "(\\\\)(\\d)" ); // matches "\x" where x is a number
|
||||
while((pos = rx.search( pdfstring )) != -1) {
|
||||
pdfstring = pdfstring.replace(pos, 4, QChar(rx.cap(2).toInt(0,8)));
|
||||
}
|
||||
return pdfstring;
|
||||
}
|
||||
|
||||
|
||||
#include "dviRenderer.moc"
|
||||
|
|
|
@ -167,6 +167,11 @@ private slots:
|
|||
void showThatSourceInformationIsPresent(void);
|
||||
|
||||
private:
|
||||
/* This method locates special PDF characters in a string and
|
||||
replaces them by UTF8. See Section 3.2.3 of the PDF reference
|
||||
guide for information */
|
||||
QString PDFencodingToQString(QString pdfstring);
|
||||
|
||||
void setResolution(double resolution_in_DPI);
|
||||
|
||||
fontPool font_pool;
|
||||
|
|
|
@ -341,7 +341,7 @@ void dviRenderer::prescan_ParsePSSpecial(QString cp)
|
|||
}
|
||||
// The PostScript code defines a bookmark
|
||||
if (cp.contains("/Dest") && cp.contains("/Title"))
|
||||
prebookmarks.append(PreBookmark(cp.section('(', 2, 2).section(')', 0, 0),
|
||||
prebookmarks.append(PreBookmark(PDFencodingToQString(cp.section('(', 2, 2).section(')', 0, 0)),
|
||||
cp.section('(', 1, 1).section(')', 0, 0),
|
||||
cp.section('-', 1, 1).section(' ', 0, 0).toUInt()
|
||||
));
|
||||
|
|
Loading…
Reference in a new issue