Hi,
while testing some new okular feature, I discovered that scan(int) actually
scans one page more than what was specified as argument.
This is my explanation (of course correct me if I'm wrong):
- FontScanner uses 1..n indeces for the pages, so in the constructor
currentPage is initialized to 1
line 41: lastPage = currentPage + nPages;
init the "last" page (or upper bound) of the scanning
line 46: for (pg = currentPage; pg <= lastPage; ++pg) {
this scans either the current page, the pages between currentPage and
lastPage, but lastPage as well!
Example: currentPage = 3, and we request nPages = 2 (scan 2 pages),
it should scan the pages 3,4, while this for() would scan pages 3,4,5.
line 66: currentPage = lastPage + 1;
the current page becomes the pages after the "last" page
I propose two patches :)
A: makes sure lastPage is always the page after the last page in every
scanning
B: lastPage is the past page to be actually scanned in each scanning
What do you think?
If possible, I'd like to have it fixed before the final release.
Thanks,
--
Pino Toscano
Index: FontInfo.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/FontInfo.cc,v
retrieving revision 1.12
diff -u -p -r1.12 FontInfo.cc
--- FontInfo.cc 25 Apr 2007 19:59:10 -0000 1.12
+++ FontInfo.cc 9 Jul 2007 10:13:10 -0000
@@ -39,11 +39,11 @@ GooList *FontInfoScanner::scan(int nPage
result = new GooList();
lastPage = currentPage + nPages;
- if (lastPage > doc->getNumPages()) {
- lastPage = doc->getNumPages();
+ if (lastPage > doc->getNumPages() + 1) {
+ lastPage = doc->getNumPages() + 1;
}
- for (pg = currentPage; pg <= lastPage; ++pg) {
+ for (pg = currentPage; pg < lastPage; ++pg) {
page = doc->getCatalog()->getPage(pg);
if ((resDict = page->getResourceDict())) {
scanFonts(resDict, result);
@@ -63,7 +63,7 @@ GooList *FontInfoScanner::scan(int nPage
delete annots;
}
- currentPage = lastPage + 1;
+ currentPage = lastPage;
return result;
}
Index: FontInfo.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/FontInfo.cc,v
retrieving revision 1.12
diff -u -p -r1.12 FontInfo.cc
--- FontInfo.cc 25 Apr 2007 19:59:10 -0000 1.12
+++ FontInfo.cc 9 Jul 2007 09:50:08 -0000
@@ -38,7 +38,7 @@ GooList *FontInfoScanner::scan(int nPage
result = new GooList();
- lastPage = currentPage + nPages;
+ lastPage = currentPage + nPages - 1;
if (lastPage > doc->getNumPages()) {
lastPage = doc->getNumPages();
}
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler