promote user to save PDF document after highlighting

This is a wordaround for #791.
This commit is contained in:
chrox
2014-08-24 15:16:01 +08:00
parent bd2fa87c85
commit 092522b89d
3 changed files with 48 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ local KoptOptions = require("ui/data/koptoptions")
local Document = require("document/document")
local Configurable = require("configurable")
local DrawContext = require("ffi/drawcontext")
local DEBUG = require("dbg")
local ffi = require("ffi")
ffi.cdef[[
typedef struct fz_point_s fz_point;
@@ -46,7 +47,6 @@ local PdfDocument = Document:new{
dc_null = DrawContext.new(),
options = KoptOptions,
koptinterface = nil,
annot_revision = 0,
}
function PdfDocument:init()
@@ -152,7 +152,7 @@ function PdfDocument:getPageLinks(pageno)
end
function PdfDocument:saveHighlight(pageno, item)
self.annot_revision = self.annot_revision + 1
self.is_edited = true
local n = #item.pboxes
local quadpoints = ffi.new("fz_point[?]", 4*n)
for i=1, n do
@@ -179,11 +179,12 @@ function PdfDocument:saveHighlight(pageno, item)
end
function PdfDocument:writeDocument()
DEBUG("writing document to", self.file)
self._document:writeDocument(self.file)
end
function PdfDocument:close()
if self.annot_revision ~= 0 then
if self.is_edited then
self:writeDocument()
end
Document.close(self)