mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Refactored to use strictly locals
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
require "cache"
|
||||
require "ui/geometry"
|
||||
require "ui/reader/readerconfig"
|
||||
require "ui/data/koptoptions"
|
||||
require "document/koptinterface"
|
||||
local Geom = require("ui/geometry")
|
||||
local Cache = require("cache")
|
||||
local CacheItem = require("cacheitem")
|
||||
local KoptOptions = require("ui/data/koptoptions")
|
||||
local KoptInterface = require("document/koptinterface")
|
||||
local Document = require("document/document")
|
||||
local Configurable = require("ui/reader/configurable")
|
||||
-- TBD: DrawContext
|
||||
|
||||
DjvuDocument = Document:new{
|
||||
local DjvuDocument = Document:new{
|
||||
_document = false,
|
||||
-- libdjvulibre manages its own additional cache, default value is hard written in c module.
|
||||
djvulibre_cache_size = nil,
|
||||
@@ -14,6 +17,16 @@ DjvuDocument = Document:new{
|
||||
koptinterface = KoptInterface,
|
||||
}
|
||||
|
||||
-- check DjVu magic string to validate
|
||||
local function validDjvuFile(filename)
|
||||
f = io.open(filename, "r")
|
||||
if not f then return false end
|
||||
local magic = f:read(8)
|
||||
f:close()
|
||||
if not magic or magic ~= "AT&TFORM" then return false end
|
||||
return true
|
||||
end
|
||||
|
||||
function DjvuDocument:init()
|
||||
self.configurable:loadDefaults(self.options)
|
||||
if not validDjvuFile(self.file) then
|
||||
@@ -33,16 +46,6 @@ function DjvuDocument:init()
|
||||
self:_readMetadata()
|
||||
end
|
||||
|
||||
-- check DjVu magic string to validate
|
||||
function validDjvuFile(filename)
|
||||
f = io.open(filename, "r")
|
||||
if not f then return false end
|
||||
local magic = f:read(8)
|
||||
f:close()
|
||||
if not magic or magic ~= "AT&TFORM" then return false end
|
||||
return true
|
||||
end
|
||||
|
||||
function DjvuDocument:invertTextYAxel(pageno, text_table)
|
||||
local _, height = self.doc:getOriginalPageSize(pageno)
|
||||
for _,text in pairs(text_table) do
|
||||
@@ -105,4 +108,8 @@ function DjvuDocument:drawPage(target, x, y, rect, pageno, zoom, rotation, gamma
|
||||
return self.koptinterface:drawPage(self, target, x, y, rect, pageno, zoom, rotation, gamma, render_mode)
|
||||
end
|
||||
|
||||
DocumentRegistry:addProvider("djvu", "application/djvu", DjvuDocument)
|
||||
function DjvuDocument:register(registry)
|
||||
registry:addProvider("djvu", "application/djvu", self)
|
||||
end
|
||||
|
||||
return DjvuDocument
|
||||
|
||||
Reference in New Issue
Block a user