summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/lpdf-ano.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/lpdf-ano.lua')
-rw-r--r--tex/context/base/mkiv/lpdf-ano.lua129
1 files changed, 101 insertions, 28 deletions
diff --git a/tex/context/base/mkiv/lpdf-ano.lua b/tex/context/base/mkiv/lpdf-ano.lua
index 94cc41412..21bc1e076 100644
--- a/tex/context/base/mkiv/lpdf-ano.lua
+++ b/tex/context/base/mkiv/lpdf-ano.lua
@@ -34,6 +34,7 @@ local report_bookmark = logs.reporter("backend","bookmarks")
local variables = interfaces.variables
local v_auto = variables.auto
local v_page = variables.page
+local v_name = variables.name
local factor = number.dimenfactors.bp
@@ -368,6 +369,7 @@ local destinationactions = {
-- [v_minheight] = function(r,w,h,d) return f_fitbv(r,(getvpos()+h)*factor) end, -- left coordinate, fit height of content in window
[v_minheight] = function(r,w,h,d) return f_fitbv(r,gethpos()*factor) end, -- left coordinate, fit height of content in window [v_fit] = f_fit, -- fit page in window
[v_tight] = f_fitb, -- fit content in window
+ [v_fit] = f_fit,
}
local mapping = {
@@ -386,11 +388,9 @@ local defaultaction = destinationactions[defaultview]
-- A complication is that we need to use named destinations when we have views so we
-- end up with a mix. A previous versions just output multiple destinations but not
--- that we noved all to here we can be more sparse.
+-- that we moved all to here we can be more sparse.
-local pagedestinations = { }
-
-table.setmetatableindex(pagedestinations,function(t,k)
+local pagedestinations = table.setmetatableindex(function(t,k)
local v = pdfdelayedobject(f_fit(k))
t[k] = v
return v
@@ -398,7 +398,7 @@ end)
local function flushdestination(width,height,depth,names,view)
local r = pdfpagereference(texgetcount("realpageno"))
- if view == defaultview or not view or view == "" then
+ if (references.innermethod ~= v_name) and (view == defaultview or not view or view == "") then
r = pagedestinations[r]
else
local action = view and destinationactions[view] or defaultaction
@@ -424,33 +424,92 @@ function nodeinjections.destination(width,height,depth,names,view)
-- we could save some aut's by using a name when given but it doesn't pay off apart
-- from making the code messy and tracing hard .. we only save some destinations
-- which we already share anyway
- for n=1,#names do
- local name = names[n]
- if usedviews[name] then
- -- already done, maybe a warning
- elseif type(name) == "number" then
- if noview then
+ -- for n=1,#names do
+ -- local name = names[n]
+ -- if usedviews[name] then
+ -- -- already done, maybe a warning
+ -- elseif type(name) == "number" then
+ -- if noview then
+ -- usedviews[name] = view
+ -- names[n] = false
+ -- elseif method == v_page then
+ -- usedviews[name] = view
+ -- names[n] = false
+ -- else
+ -- local used = usedinternals[name]
+ -- if used and used ~= defaultview then
+ -- usedviews[name] = view
+ -- names[n] = autoprefix .. name
+ -- doview = true
+ -- else
+ -- -- names[n] = autoprefix .. name
+ -- names[n] = false
+ -- end
+ -- end
+ -- elseif method == v_page then
+ -- usedviews[name] = view
+ -- else
+ -- usedviews[name] = view
+ -- doview = true
+ -- end
+ -- end
+
+ if method == v_page then
+ for n=1,#names do
+ local name = names[n]
+ if usedviews[name] then
+ -- already done, maybe a warning
+ elseif type(name) == "number" then
+ if noview then
+ usedviews[name] = view
+ names[n] = false
+ else
+ usedviews[name] = view
+ names[n] = false
+ end
+ else
usedviews[name] = view
- names[n] = false
- elseif method == v_page then
+ end
+ end
+ elseif method == v_name then
+ for n=1,#names do
+ local name = names[n]
+ if usedviews[name] then
+ -- already done, maybe a warning
+ elseif type(name) == "number" then
+ local used = usedinternals[name]
usedviews[name] = view
- names[n] = false
+ names[n] = autoprefix .. name
+ doview = true
else
- local used = usedinternals[name]
- if used and used ~= defaultview then
+ usedviews[name] = view
+ doview = true
+ end
+ end
+ else
+ for n=1,#names do
+ local name = names[n]
+ if usedviews[name] then
+ -- already done, maybe a warning
+ elseif type(name) == "number" then
+ if noview then
usedviews[name] = view
- names[n] = autoprefix .. name
- doview = true
- else
- -- names[n] = autoprefix .. name
names[n] = false
+ else
+ local used = usedinternals[name]
+ if used and used ~= defaultview then
+ usedviews[name] = view
+ names[n] = autoprefix .. name
+ doview = true
+ else
+ -- names[n] = autoprefix .. name
+ names[n] = false
+ end
end
+ else
+ usedviews[name] = view
+ doview = true
end
- elseif method == v_page then
- usedviews[name] = view
- else
- usedviews[name] = view
- doview = true
end
end
if doview then
@@ -461,7 +520,8 @@ end
-- we could share dictionaries ... todo
local function somedestination(destination,internal,page) -- no view anyway
- if references.innermethod ~= v_page then
+ local method = references.innermethod
+ if method == v_auto then
if type(destination) == "number" then
if not internal then
internal = destination
@@ -481,9 +541,21 @@ local function somedestination(destination,internal,page) -- no view anyway
S = pdf_goto,
D = destination,
}
+ elseif destination then
+ -- hopefully this one is flushed
+ return pdfdictionary {
+ S = pdf_goto,
+ D = destination,
+ }
+ end
+ elseif method == v_name then
+ if not destination and internal then
+ flaginternals[internal] = true -- for bookmarks and so
+ if type(destination) ~= "string" then
+ destination = autoprefix .. internal
+ end
end
if destination then
- -- hopefully this one is flushed
return pdfdictionary {
S = pdf_goto,
D = destination,
@@ -712,7 +784,8 @@ end)
runners["inner"] = function(var,actions)
local internal = false
local inner = nil
- if references.innermethod == v_auto then
+ local method = references.innermethod
+ if method == v_auto or method == v_name then
local vi = var.i
if vi then
local vir = vi.references