summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/lpdf-ano.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lpdf-ano.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/lpdf-ano.lua144
1 files changed, 94 insertions, 50 deletions
diff --git a/Master/texmf-dist/tex/context/base/lpdf-ano.lua b/Master/texmf-dist/tex/context/base/lpdf-ano.lua
index 9f452c34d12..4d0a55f806b 100644
--- a/Master/texmf-dist/tex/context/base/lpdf-ano.lua
+++ b/Master/texmf-dist/tex/context/base/lpdf-ano.lua
@@ -6,9 +6,14 @@ if not modules then modules = { } end modules ['lpdf-ano'] = {
license = "see context related readme files"
}
+-- when using rotation: \disabledirectives[refences.sharelinks] (maybe flag links)
+
+-- todo: /AA << WC << ... >> >> : WillClose actions etc
+
local next, tostring = next, tostring
local rep, format = string.rep, string.format
local texcount = tex.count
+local lpegmatch = lpeg.match
local backends, lpdf = backends, lpdf
@@ -20,30 +25,31 @@ local report_reference = logs.reporter("backend","references")
local report_destination = logs.reporter("backend","destinations")
local report_bookmark = logs.reporter("backend","bookmarks")
-local variables = interfaces.variables
-local constants = interfaces.constants
+local variables = interfaces.variables
+local constants = interfaces.constants
-local settings_to_array = utilities.parsers.settings_to_array
+local settings_to_array = utilities.parsers.settings_to_array
-local nodeinjections = backends.pdf.nodeinjections
-local codeinjections = backends.pdf.codeinjections
-local registrations = backends.pdf.registrations
+local nodeinjections = backends.pdf.nodeinjections
+local codeinjections = backends.pdf.codeinjections
+local registrations = backends.pdf.registrations
-local javascriptcode = interactions.javascripts.code
+local javascriptcode = interactions.javascripts.code
-local references = structures.references
-local bookmarks = structures.bookmarks
+local references = structures.references
+local bookmarks = structures.bookmarks
-local runners = references.runners
-local specials = references.specials
-local handlers = references.handlers
-local executers = references.executers
+local runners = references.runners
+local specials = references.specials
+local handlers = references.handlers
+local executers = references.executers
+local getinnermethod = references.getinnermethod
-local nodepool = nodes.pool
+local nodepool = nodes.pool
-local pdfannotation_node = nodepool.pdfannotation
-local pdfdestination_node = nodepool.pdfdestination
-local latelua_node = nodepool.latelua
+local pdfannotation_node = nodepool.pdfannotation
+local pdfdestination_node = nodepool.pdfdestination
+local latelua_node = nodepool.latelua
local pdfdictionary = lpdf.dictionary
local pdfarray = lpdf.array
@@ -52,29 +58,26 @@ local pdfunicode = lpdf.unicode
local pdfconstant = lpdf.constant
local pdfflushobject = lpdf.flushobject
local pdfshareobjectreference = lpdf.shareobjectreference
-local pdfimmediateobject = lpdf.immediateobject
local pdfreserveobject = lpdf.reserveobject
local pdfpagereference = lpdf.pagereference
local pdfdelayedobject = lpdf.delayedobject
local pdfregisterannotation = lpdf.registerannotation
-local pdf_annot = pdfconstant("Annot")
-local pdf_uri = pdfconstant("URI")
-local pdf_gotor = pdfconstant("GoToR")
-local pdf_goto = pdfconstant("GoTo")
-local pdf_launch = pdfconstant("Launch")
-local pdf_javascript = pdfconstant("JavaScript")
-local pdf_link = pdfconstant("Link")
-local pdf_n = pdfconstant("N")
-local pdf_t = pdfconstant("T")
-local pdf_fit = pdfconstant("Fit")
-local pdf_named = pdfconstant("Named")
-
-- todo: 3dview
-local pdf_border = pdfarray { 0, 0, 0 }
+local pdf_annot = pdfconstant("Annot")
+local pdf_uri = pdfconstant("URI")
+local pdf_gotor = pdfconstant("GoToR")
+local pdf_goto = pdfconstant("GoTo")
+local pdf_launch = pdfconstant("Launch")
+local pdf_javascript = pdfconstant("JavaScript")
+local pdf_link = pdfconstant("Link")
+local pdf_n = pdfconstant("N")
+local pdf_t = pdfconstant("T")
+local pdf_fit = pdfconstant("Fit")
+local pdf_named = pdfconstant("Named")
-local getinnermethod = references.getinnermethod
+local pdf_border = pdfarray { 0, 0, 0 }
local cache = { }
@@ -146,7 +149,7 @@ local function link(url,filename,destination,page,actions)
pdf_fit,
}
}
- else
+ elseif trace_references then
report_reference("invalid page reference: %s",tostring(page))
end
end
@@ -181,7 +184,6 @@ end
local function pdfaction(actions)
local nofactions = #actions
- texcount.referencepagestate = 0 -- goodie, as we do all in the backend, we need to set it here too
if nofactions > 0 then
local a = actions[1]
local action = runners[a.kind]
@@ -245,7 +247,7 @@ local function use_normal_annotations()
end
--- evenrually we can do this for special refs only
+-- eventually we can do this for special refs only
local hashed, nofunique, nofused = { }, 0, 0
@@ -257,7 +259,7 @@ local function use_shared_annotations()
local h, v = pdf.h, pdf.v
local llx, lly = h*factor, (v - depth)*factor
local urx, ury = (h + width)*factor, (v + height)*factor
- local annot = format("<< /Type /Annot %s /Rect [%0.2f %0.2f %0.2f %0.2f] >>",prerolled,llx,lly,urx,ury)
+ local annot = format("<< /Type /Annot %s /Rect [%0.3f %0.3f %0.3f %0.3f] >>",prerolled,llx,lly,urx,ury)
local n = hashed[annot]
if not n then
n = pdfdelayedobject(annot)
@@ -283,7 +285,7 @@ local function use_shared_annotations()
statistics.register("pdf annotations", function()
if nofused > 0 then
-- table.print(hashed,"hashed_annotations")
- return string.format("%s embedded, %s unique",nofused,nofunique)
+ return format("%s embedded, %s unique",nofused,nofunique)
else
return nil
end
@@ -326,10 +328,15 @@ end
runners["inner"] = function(var,actions)
if getinnermethod() == "names" then
- local vir = var.i.references
- local internal = vir and vir.internal
- if internal then
- var.inner = "aut:" .. internal
+ local vi = var.i
+ if vi then
+ local vir = vi.references
+ if vir then
+ local internal = vir.internal
+ if internal then
+ var.inner = "aut:" .. internal
+ end
+ end
end
else
var.inner = nil
@@ -348,7 +355,7 @@ runners["outer"] = function(var,actions)
end
runners["outer with inner"] = function(var,actions)
- local file = references.checkedfile(var.f)
+ local file = references.checkedfile(var.outer) -- was var.f but fails ... why
return link(nil,file,var.inner,var.r,actions)
end
@@ -392,10 +399,12 @@ runners["special operation with arguments"] = runners["special"]
function specials.internal(var,actions) -- better resolve in strc-ref
local i = tonumber(var.operation)
- local v = references.internals[i]
+ local v = i and references.internals[i]
+--~ print(">>>>>>>",i)
+--~ inspect(v)
if not v then
-- error
- report_reference("no internal reference '%s'",var.operation)
+ report_reference("no internal reference '%s'",i or "?")
elseif getinnermethod() == "names" then
-- named
return link(nil,nil,"aut:"..i,v.references.realpage,actions)
@@ -423,8 +432,11 @@ function specials.page(var,actions)
if type(p) == "function" then -- double
p = p()
else
- p = tonumber(references.realpageofpage(tonumber(o)))
+ p = references.realpageofpage(tonumber(p))
end
+ -- if p then
+ -- var.r = p
+ -- end
end
return link(nil,nil,nil,p or var.operation,actions)
end
@@ -448,12 +460,42 @@ function specials.userpage(var,actions)
else
local p = var.r
if not p then -- todo: call special from reference code
- p = tonumber(references.realpageofpage(var.operation))
+ p = var.operation
+ if p then -- no function and special check here. only numbers
+ p = references.realpageofpage(tonumber(p))
+ end
+ -- if p then
+ -- var.r = p
+ -- end
end
+ return link(nil,nil,nil,p or var.operation,actions)
+ end
+end
+
+function specials.deltapage(var,actions)
+ local p = tonumber(var.operation)
+ if p then
+ p = references.checkedrealpage(p + texcount.realpageno)
return link(nil,nil,nil,p,actions)
end
end
+-- sections
+
+--~ function specials.section(var,actions)
+--~ local sectionname = var.operation
+--~ local destination = var.arguments
+--~ local internal = structures.sections.internalreference(sectionname,destination)
+--~ if internal then
+--~ var.special = "internal"
+--~ var.operation = internal
+--~ var.arguments = nil
+--~ specials.internal(var,actions)
+--~ end
+--~ end
+
+specials.section = specials.internal -- specials.section just need to have a value as it's checked
+
-- todo, do this in references namespace ordered instead (this is an experiment)
local splitter = lpeg.splitat(":")
@@ -462,7 +504,7 @@ function specials.order(var,actions) -- references.specials !
local operation = var.operation
if operation then
local kind, name, n = lpegmatch(splitter,operation)
- local order = lists.ordered[kind]
+ local order = structures.lists.ordered[kind]
order = order and order[name]
local v = order[tonumber(n)]
local r = v and v.references.realpage
@@ -563,9 +605,11 @@ function executers.submitform(arguments)
}
end
+local pdf_hide = pdfconstant("Hide")
+
function executers.hide(arguments)
return pdfdictionary {
- S = pdfconstant("Hide"),
+ S = pdf_hide,
H = true,
T = arguments,
}
@@ -573,7 +617,7 @@ end
function executers.show(arguments)
return pdfdictionary {
- S = pdfconstant("Hide"),
+ S = pdf_hide,
H = false,
T = arguments,
}
@@ -617,7 +661,7 @@ function specials.action(var)
end
--~ entry.A = pdfdictionary {
---~ S = pdfconstant("GoTo"),
+--~ S = pdf_goto,
--~ D = ....
--~ }