Skip to content

Commit b318ca0

Browse files
committed
mod: merge djvu branch with master
1 parent 145d700 commit b318ca0

File tree

5 files changed

+698
-580
lines changed

5 files changed

+698
-580
lines changed

djvureader.lua

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
require "unireader"
2+
3+
DJVUReader = UniReader:new{
4+
newDC = function()
5+
print("djvu.newDC")
6+
return djvu.newDC()
7+
end,
8+
}
9+
10+
function DJVUReader:init()
11+
self.nulldc = self.newDC()
12+
end
13+
14+
-- open a DJVU file and its settings store
15+
function DJVUReader:open(filename)
16+
self.doc = djvu.openDocument(filename)
17+
if self.doc ~= nil then
18+
self.settings = DocSettings:open(filename)
19+
local gamma = self.settings:readsetting("gamma")
20+
if gamma then
21+
self.globalgamma = gamma
22+
end
23+
return true
24+
end
25+
return false
26+
end
27+
28+
--set viewer state according to zoom state
29+
function DJVUReader:setzoom(page)
30+
local dc = self.newDC()
31+
local pwidth, pheight = page:getSize(self.nulldc)
32+
33+
if self.globalzoommode == self.ZOOM_FIT_TO_PAGE then
34+
self.globalzoom = width / pwidth
35+
self.offset_x = 0
36+
self.offset_y = (height - (self.globalzoom * pheight)) / 2
37+
if height / pheight < self.globalzoom then
38+
self.globalzoom = height / pheight
39+
print(width, (self.globalzoom * pwidth))
40+
self.offset_x = (width - (self.globalzoom * pwidth)) / 2
41+
self.offset_y = 0
42+
end
43+
elseif self.globalzoommode == self.ZOOM_FIT_TO_PAGE_WIDTH then
44+
self.globalzoom = width / pwidth
45+
self.offset_x = 0
46+
self.offset_y = (height - (self.globalzoom * pheight)) / 2
47+
elseif self.globalzoommode == self.ZOOM_FIT_TO_PAGE_HEIGHT then
48+
self.globalzoom = height / pheight
49+
self.offset_x = (width - (self.globalzoom * pwidth)) / 2
50+
self.offset_y = 0
51+
end
52+
53+
dc:setZoom(self.globalzoom)
54+
-- record globalzoom for manual zoom in/out
55+
self.globalzoom_orig = self.globalzoom
56+
57+
dc:setRotate(self.globalrotate);
58+
dc:setOffset(self.offset_x, self.offset_y)
59+
self.fullwidth, self.fullheight = page:getSize(dc)
60+
self.min_offset_x = fb.bb:getWidth() - self.fullwidth
61+
self.min_offset_y = fb.bb:getHeight() - self.fullheight
62+
if(self.min_offset_x > 0) then
63+
self.min_offset_x = 0
64+
end
65+
if(self.min_offset_y > 0) then
66+
self.min_offset_y = 0
67+
end
68+
69+
-- set gamma here, we don't have any other good place for this right now:
70+
if self.globalgamma ~= self.GAMMA_NO_GAMMA then
71+
print("gamma correction: "..self.globalgamma)
72+
dc:setGamma(self.globalgamma)
73+
end
74+
return dc
75+
end

filesearcher.lua

+2-6
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,8 @@ function FileSearcher:choose(ypos, height, keywords)
261261
pagedirty = true
262262
elseif ev.code == KEY_ENTER or ev.code == KEY_FW_PRESS then
263263
file_entry = self.result[perpage*(self.page-1)+self.current]
264-
file_path = file_entry.dir .. "/" .. file_entry.name
265-
266-
if PDFReader:open(file_path,"") then -- TODO: query for password
267-
PDFReader:goto(tonumber(PDFReader.settings:readsetting("last_page") or 1))
268-
PDFReader:inputloop()
269-
end
264+
file_full_path = file_entry.dir .. "/" .. file_entry.name
265+
openFile(file_full_path)
270266

271267
pagedirty = true
272268
elseif ev.code == KEY_BACK then

0 commit comments

Comments
 (0)