Fix creation of the TOC tree for dvi files

The old code assumed the number of children would be
"-NUMBER "
while this file has
"-NUMBER/"
so what we do now is looping after the - until we find a non digit
All this code would better be done using a regexp and not that many section calls
but i did not want to touch it more than needed
BUGS: 283447
FIXED-IN: 4.7.3
(cherry picked from commit 83df127ac0)
remotes/origin/textfind-and-transparency
Albert Astals Cid 15 years ago
parent 5647ad5647
commit 9d6926f9b8
  1. 11
      generators/dvi/dviRenderer_prescan.cpp

@ -361,11 +361,18 @@ void dviRenderer::prescan_ParsePSSpecial(const QString& cp)
anchorList[anchorName] = Anchor(current_page+1, l);
}
// The PostScript code defines a bookmark
if (cp.contains("/Dest") && cp.contains("/Title"))
if (cp.contains("/Dest") && cp.contains("/Title")) {
const QString childrenNumberAndMoreStuff = cp.section('-', 1, 1); // Contains from the - symbol to the end of cp, effectively containing the number of children and some stuff after it
int indexOfFirstNonDigit = 0;
foreach(const QChar &c, childrenNumberAndMoreStuff) {
if (c.isDigit()) ++indexOfFirstNonDigit;
else break;
}
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()
childrenNumberAndMoreStuff.left(indexOfFirstNonDigit).toUInt()
));
}
return;
}
}

Loading…
Cancel
Save