diff options
author | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
---|---|---|
committer | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
commit | 15995e10bfc68edf79970c4ea4fbb6678566c46e (patch) | |
tree | 2de7ca2a83f2d37ef043ad7429a5cb945bb79ddb /Master/texmf-dist/tex/context/base/lpdf-wid.lua | |
parent | c9a39f716f1e5ec820ed3aab2c9aef25c5a9d730 (diff) |
ConTeXt 2012.05.14 16:00
git-svn-id: svn://tug.org/texlive/trunk@26371 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lpdf-wid.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/lpdf-wid.lua | 114 |
1 files changed, 62 insertions, 52 deletions
diff --git a/Master/texmf-dist/tex/context/base/lpdf-wid.lua b/Master/texmf-dist/tex/context/base/lpdf-wid.lua index d0247f49a73..13940be9c86 100644 --- a/Master/texmf-dist/tex/context/base/lpdf-wid.lua +++ b/Master/texmf-dist/tex/context/base/lpdf-wid.lua @@ -7,6 +7,7 @@ if not modules then modules = { } end modules ['lpdf-wid'] = { } local gmatch, gsub, find, lower, format = string.gmatch, string.gsub, string.find, string.lower, string.format +local stripstring = string.strip local texbox, texcount = tex.box, tex.count local settings_to_array = utilities.parsers.settings_to_array local settings_to_hash = utilities.parsers.settings_to_hash @@ -16,43 +17,44 @@ local report_attachment = logs.reporter("backend","attachment") local backends, lpdf, nodes = backends, lpdf, nodes -local nodeinjections = backends.pdf.nodeinjections -local codeinjections = backends.pdf.codeinjections -local registrations = backends.pdf.registrations - -local executers = structures.references.executers -local variables = interfaces.variables - -local v_hidden = variables.hidden -local v_normal = variables.normal -local v_auto = variables.auto -local v_embed = variables.embed -local v_unknown = variables.unknown -local v_max = variables.max - -local pdfconstant = lpdf.constant -local pdfdictionary = lpdf.dictionary -local pdfarray = lpdf.array -local pdfreference = lpdf.reference -local pdfunicode = lpdf.unicode -local pdfstring = lpdf.string -local pdfboolean = lpdf.boolean -local pdfcolorspec = lpdf.colorspec -local pdfflushobject = lpdf.flushobject -local pdfreserveannotation = lpdf.reserveannotation -local pdfreserveobject = lpdf.reserveobject -local pdfimmediateobject = lpdf.immediateobject -local pdfpagereference = lpdf.pagereference -local pdfshareobjectreference = lpdf.shareobjectreference - -local nodepool = nodes.pool - -local pdfannotation_node = nodepool.pdfannotation - -local hpack_node = node.hpack -local write_node = node.write - -local pdf_border = pdfarray { 0, 0, 0 } -- can be shared +local nodeinjections = backends.pdf.nodeinjections +local codeinjections = backends.pdf.codeinjections +local registrations = backends.pdf.registrations + +local executers = structures.references.executers +local variables = interfaces.variables + +local v_hidden = variables.hidden +local v_normal = variables.normal +local v_auto = variables.auto +local v_embed = variables.embed +local v_unknown = variables.unknown +local v_max = variables.max + +local pdfconstant = lpdf.constant +local pdfdictionary = lpdf.dictionary +local pdfarray = lpdf.array +local pdfreference = lpdf.reference +local pdfunicode = lpdf.unicode +local pdfstring = lpdf.string +local pdfboolean = lpdf.boolean +local pdfcolorspec = lpdf.colorspec +local pdfflushobject = lpdf.flushobject +local pdfflushstreamobject = lpdf.flushstreamobject +local pdfflushstreamfileobject = lpdf.flushstreamfileobject +local pdfreserveannotation = lpdf.reserveannotation +local pdfreserveobject = lpdf.reserveobject +local pdfpagereference = lpdf.pagereference +local pdfshareobjectreference = lpdf.shareobjectreference + +local nodepool = nodes.pool + +local pdfannotation_node = nodepool.pdfannotation + +local hpack_node = node.hpack +local write_node = node.write -- test context(...) instead + +local pdf_border = pdfarray { 0, 0, 0 } -- can be shared -- symbols @@ -198,12 +200,13 @@ end lpdf.registerdocumentfinalizer(flushembeddedfiles,"embeddedfiles") function codeinjections.embedfile(specification) - local data = specification.data - local filename = specification.file - local name = specification.name or "" - local title = specification.title or "" - local hash = specification.hash or filename - local keepdir = specification.keepdir -- can change + local data = specification.data + local filename = specification.file + local name = specification.name or "" + local title = specification.title or "" + local hash = specification.hash or filename + local keepdir = specification.keepdir -- can change + local usedname = specification.usedname if filename == "" then filename = nil end @@ -241,17 +244,18 @@ function codeinjections.embedfile(specification) end end end - local basename = keepdir == true and filename or file.basename(filename) -local basename = string.gsub(basename,"%./","") + usedname = usedname ~= "" and usedname or filename + local basename = keepdir == true and usedname or file.basename(usedname) +local basename = gsub(basename,"%./","") local savename = file.addsuffix(name ~= "" and name or basename,"txt") -- else no valid file local a = pdfdictionary { Type = pdfconstant("EmbeddedFile") } local f if data then - f = pdfimmediateobject("stream",data,a()) + f = pdfflushstreamobject(data,a) specification.data = true -- signal that still data but already flushed else local foundname = specification.foundname or filename - f = pdfimmediateobject("streamfile",foundname,a()) + f = pdfflushstreamfileobject(foundname,a) end local d = pdfdictionary { Type = pdfconstant("Filespec"), @@ -269,10 +273,11 @@ function nodeinjections.attachfile(specification) local registered = specification.registered or "<unset>" local data = specification.data local hash + local filename if data then hash = md5.HEX(data) else - local filename = specification.file + filename = specification.file if not filename or filename == "" then report_attachment("missing file specification: registered '%s', using registered instead",registered) filename = registered @@ -301,7 +306,7 @@ function nodeinjections.attachfile(specification) title = "" end if author == "" then - author = v_unknown + author = filename or "<unknown>" end if title == "" then title = registered @@ -377,7 +382,7 @@ end function nodeinjections.comment(specification) -- brrr: seems to be done twice nofcomments = nofcomments + 1 - local text = string.strip(specification.data or "") + local text = stripstring(specification.data or "") if stripleading then text = gsub(text,"[\n\r] *","\n") end @@ -442,7 +447,7 @@ end -- object_2 -> <</Type /Rendition /S /MR /C << /Type /MediaClip ... >> >> -- rendering -> <</Type /Rendition /S /MS [objref_1 objref_2]>> -- --- we only work foreward here +-- we only work foreward here (currently) -- annotation is to be packed at the tex end -- aiff audio/aiff @@ -514,7 +519,12 @@ local function insertrenderingwindow(specification) Border = pdf_border, AA = actions, } - write_node(pdfannotation_node(specification.width or 0,specification.height or 0,0,d(),r)) -- save ref + local width = specification.width or 0 + local height = specification.height or 0 + if height == 0 or width == 0 then + -- todo: sound needs no window + end + write_node(pdfannotation_node(width,height,0,d(),r)) -- save ref return pdfreference(r) end |