From c8f87d5661208896a0529b020dae3448b53b85a9 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Fri, 16 Mar 2012 12:27:27 +0800 Subject: [PATCH] fix: remove page number checking in displaying TOC Former showTOC() method checks the page number in each entry and only display entry whose page number is greater than the previous one. However, I think this is too "clever", we should better leave the TOC untouched to keep consistent with other pdf readers. --- pdf.c | 5 +++-- unireader.lua | 10 +++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pdf.c b/pdf.c index e079c54b..1091ecc6 100644 --- a/pdf.c +++ b/pdf.c @@ -101,16 +101,17 @@ static int walkTableOfContent(lua_State *L, fz_outline* ol, int *count, int dept lua_pushstring(L, "page"); lua_pushnumber(L, ol->dest.ld.gotor.page + 1); lua_settable(L, -3); + lua_pushstring(L, "depth"); lua_pushnumber(L, depth); lua_settable(L, -3); - lua_pushstring(L, "title"); + lua_pushstring(L, "title"); lua_pushstring(L, ol->title); lua_settable(L, -3); - lua_settable(L, -3); + lua_settable(L, -3); (*count)++; if (ol->down) { walkTableOfContent(L, ol->down, count, depth); diff --git a/unireader.lua b/unireader.lua index 61fd3e26..c81262b8 100644 --- a/unireader.lua +++ b/unireader.lua @@ -678,15 +678,11 @@ function UniReader:showTOC() end local menu_items = {} local filtered_toc = {} - local curr_page = -1 -- build menu items for _k,_v in ipairs(self.toc) do - if(_v.page >= curr_page) then - table.insert(menu_items, - (" "):rep(_v.depth-1)..self:cleanUpTOCTitle(_v.title)) - table.insert(filtered_toc,_v.page) - curr_page = _v.page - end + table.insert(menu_items, + (" "):rep(_v.depth-1)..self:cleanUpTOCTitle(_v.title)) + table.insert(filtered_toc,_v.page) end toc_menu = SelectMenu:new{ menu_title = "Table of Contents",