diff options
author | Hans Hagen <pragma@wxs.nl> | 2009-12-31 14:12:00 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2009-12-31 14:12:00 +0100 |
commit | 793246447f12d17a8ff2fe46e8f54ce28fdf3168 (patch) | |
tree | 25442e3991828176bc59003b890d6107d8be880a | |
parent | 3162ffe9a685e6a5f0d882681a03056eea9775c8 (diff) | |
download | context-793246447f12d17a8ff2fe46e8f54ce28fdf3168.tar.gz |
beta 2009.12.31 14:12
-rw-r--r-- | tex/context/base/back-ini.lua | 1 | ||||
-rw-r--r-- | tex/context/base/cont-new.tex | 2 | ||||
-rw-r--r-- | tex/context/base/context.tex | 2 | ||||
-rw-r--r-- | tex/context/base/grph-inc.mkiv | 1 | ||||
-rw-r--r-- | tex/context/base/grph-swf.lua | 42 | ||||
-rw-r--r-- | tex/context/base/lpdf-ini.lua | 15 | ||||
-rw-r--r-- | tex/context/base/lpdf-ini.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/lpdf-swf.lua | 109 | ||||
-rw-r--r-- | tex/context/base/lpdf-wid.lua | 43 | ||||
-rw-r--r-- | tex/generic/context/luatex-fonts-merged.lua | 2 |
10 files changed, 196 insertions, 23 deletions
diff --git a/tex/context/base/back-ini.lua b/tex/context/base/back-ini.lua index 171b40c97..7d1754150 100644 --- a/tex/context/base/back-ini.lua +++ b/tex/context/base/back-ini.lua @@ -46,6 +46,7 @@ backends.codeinjections = { registeredsymbol = nothing, registercomment = nothing, + embedfile = nothing, attachfile = nothing, adddocumentinfo = nothing, setupidentity = nothing, diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex index 4a7212d0e..0a9052b8e 100644 --- a/tex/context/base/cont-new.tex +++ b/tex/context/base/cont-new.tex @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2009.12.30 23:52} +\newcontextversion{2009.12.31 14:12} %D This file is loaded at runtime, thereby providing an %D excellent place for hacks, patches, extensions and new diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex index 11dc9a1c7..46cce45a3 100644 --- a/tex/context/base/context.tex +++ b/tex/context/base/context.tex @@ -20,7 +20,7 @@ %D your styles an modules. \edef\contextformat {\jobname} -\edef\contextversion{2009.12.30 23:52} +\edef\contextversion{2009.12.31 14:12} %D For those who want to use this: diff --git a/tex/context/base/grph-inc.mkiv b/tex/context/base/grph-inc.mkiv index d71a03462..c2576ef30 100644 --- a/tex/context/base/grph-inc.mkiv +++ b/tex/context/base/grph-inc.mkiv @@ -22,6 +22,7 @@ \registerctxluafile{grph-inc}{1.001} \registerctxluafile{grph-fil}{1.001} \registerctxluafile{grph-u3d}{1.001} % this will change +\registerctxluafile{grph-swf}{1.001} % this will change \unprotect diff --git a/tex/context/base/grph-swf.lua b/tex/context/base/grph-swf.lua new file mode 100644 index 000000000..f9f3c5b2d --- /dev/null +++ b/tex/context/base/grph-swf.lua @@ -0,0 +1,42 @@ +if not modules then modules = { } end modules ['grph-swf'] = { + version = 1.001, + comment = "companion to grph-inc.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local format = string.format + +local texsprint = tex.sprint +local ctxcatcodes = tex.ctxcatcodes + +function figures.checkers.swf(data) + local dr, du, ds = data.request, data.used, data.status + local width = (dr.width or figures.defaultwidth):todimen() + local height = (dr.height or figures.defaultheight):todimen() + local foundname = du.fullname + dr.width, dr.height = width, height + du.width, du.height, du.foundname = width, height, foundname + texsprint(ctxcatcodes,format("\\startfoundexternalfigure{%ssp}{%ssp}",width,height)) + local annot, preview, ref = backends.pdf.helpers.insertswf { + foundname = foundname, + width = width, + height = height, + -- factor = number.dimenfactors.bp, + -- display = dr.display, + -- controls = dr.controls, + -- label = dr.label, + } + -- node.write(nodes.pdfannot(width,-height,0,annot())) + texsprint(ctxcatcodes,format("\\pdfannot width %ssp height %ssp {%s}",width,height,annot())) -- brrrr +--~ if ref then -- wrong ! a direct ref should work +--~ texsprint(ctxcatcodes,format("\\smash{\\pdfrefximage%s\\relax}",ref)) -- brrrr +--~ end + texsprint(ctxcatcodes,"\\stopfoundexternalfigure") + return data +end + +figures.includers.swf = figures.includers.nongeneric + +figures.registersuffix("swf","swf") diff --git a/tex/context/base/lpdf-ini.lua b/tex/context/base/lpdf-ini.lua index d71bfc6d7..02f65e3ff 100644 --- a/tex/context/base/lpdf-ini.lua +++ b/tex/context/base/lpdf-ini.lua @@ -142,7 +142,9 @@ tostring_a = function(t,contentonly,key) r[#r+1] = tosixteen(v) elseif tv == "table" then local mv = getmetatable(v) - if mv and mv.__lpdftype then + local mt = mv.__lpdftype + if mv and mt then +--~ print(mv,mt,v) r[#r+1] = tostring(v) elseif v[1] then r[#r+1] = tostring_a(v) @@ -224,7 +226,7 @@ function lpdf.dictionary(t) end function lpdf.array(t) - if type(t) == "string"then + if type(t) == "string" then return setmetatable({ t },mt_a) else return setmetatable(t or { },mt_a) @@ -290,9 +292,12 @@ function lpdf.verbose(t) -- maybe check for type end --~ local d = lpdf.dictionary() ---~ local e = lpdf.dictionary { ["e"] = "abc" } +--~ local e = lpdf.dictionary { ["e"] = "abc", x = lpdf.dictionary { ["f"] = "ABC" } } --~ local f = lpdf.dictionary { ["f"] = "ABC" } ---~ local a = lpdf.array() +--~ local a = lpdf.array { lpdf.array { lpdf.string("xxx") } } + +--~ print(a) +--~ os.exit() --~ d["test"] = lpdf.string ("test") --~ d["more"] = "more" @@ -306,7 +311,7 @@ end --~ d.what = a ---~ print(d) +--~ print(e) --~ local d = lpdf.dictionary() --~ d["abcd"] = { 1, 2, 3, "test" } diff --git a/tex/context/base/lpdf-ini.mkiv b/tex/context/base/lpdf-ini.mkiv index bea9a5404..d71206584 100644 --- a/tex/context/base/lpdf-ini.mkiv +++ b/tex/context/base/lpdf-ini.mkiv @@ -24,7 +24,7 @@ \registerctxluafile{lpdf-wid}{1.001} \registerctxluafile{lpdf-fld}{1.001} \registerctxluafile{lpdf-u3d}{1.001} - +\registerctxluafile{lpdf-swf}{1.001} \unprotect diff --git a/tex/context/base/lpdf-swf.lua b/tex/context/base/lpdf-swf.lua new file mode 100644 index 000000000..9fe0cd09f --- /dev/null +++ b/tex/context/base/lpdf-swf.lua @@ -0,0 +1,109 @@ +if not modules then modules = { } end modules ['lpdf-swf'] = { + version = 1.001, + comment = "companion to lpdf-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- The following code is based on tests by Luigi Scarso. His prototype +-- was using tex code. This is the official implementation. + +local format = string.format + +local pdfconstant = lpdf.constant +local pdfboolean = lpdf.boolean +local pdfstring = lpdf.string +local pdfunicode = lpdf.unicode +local pdfdictionary = lpdf.dictionary +local pdfarray = lpdf.array +local pdfnull = lpdf.null +local pdfreference = lpdf.reference + +function backends.pdf.helpers.insertswf(spec) + + local width, height, filename = spec.width, spec.height, spec.foundname + + local eref = backends.codeinjections.embedfile(filename) + + local flash = pdfdictionary { + Subtype = pdfconstant("Flash"), + Instances = pdfarray { + pdfdictionary { + Asset = eref, + Params = pdfdictionary { + Binding = pdfconstant("Foreground") + } + }, + }, + } + + local fref = pdfreference(pdf.immediateobj(tostring(flash))) + + local configuration = pdfdictionary { + Configurations = pdfarray { fref }, + Assets = pdfdictionary { + Names = pdfarray { + pdfstring(filename), + eref, + } + }, + } + + local cref = pdfreference(pdf.immediateobj(tostring(configuration))) + + local activation = pdfdictionary { + Activation = pdfdictionary { + Type = pdfconstant("RichMediaActivation"), + Condition = pdfconstant("PO"), + Configuration = fref, + Animation = pdfdictionary { + Subtype = pdfconstant("Linear"), + Speed = 1, + Playcount = 1, + }, + Deactivation = pdfdictionary { + Type = pdfconstant("RichMediaDeactivation"), + Condition = pdfconstant("XD"), + }, + Presentation = pdfdictionary { + PassContextClick = false, + Style = pdfconstant("Embedded"), + Toolbar = false, + NavigationPane = false, + Transparent = true, + Window = pdfdictionary { + Type = pdfconstant("RichMediaWindow"), + Width = pdfdictionary { + Default = 100, + Min = 100, + Max = 100, + }, + Height = pdfdictionary { + Default = 100, + Min = 100, + Max = 100, + }, + Position = pdfdictionary { + Type = pdfconstant("RichMediaPosition"), + HAlign = pdfconstant("Near"), + VAlign = pdfconstant("Near"), + HOffset = 0, + VOffset = 0, + } + } + } + } + } + + local aref = pdfreference(pdf.immediateobj(tostring(activation))) + + local annotation = pdfdictionary { + Subtype = pdfconstant("RichMedia"), + RichMediaContent = cref, + RichMediaSettings = aref, + } + + return annotation, nil, nil + +end diff --git a/tex/context/base/lpdf-wid.lua b/tex/context/base/lpdf-wid.lua index 89116d87b..f4eccd173 100644 --- a/tex/context/base/lpdf-wid.lua +++ b/tex/context/base/lpdf-wid.lua @@ -21,6 +21,7 @@ local pdfdictionary = lpdf.dictionary local pdfarray = lpdf.array local pdfreference = lpdf.reference local pdfunicode = lpdf.unicode +local pdfstring = lpdf.string local pdfcolorspec = lpdf.colorspec local pdfreserveobj = pdf.reserveobj @@ -136,6 +137,32 @@ end local nofattachments, attachments, filestreams = 0, { }, { } +function codeinjections.embedfile(filename) + local r = filestreams[filename] + if r == false then + return nil + elseif r then + return r + elseif not lfs.isfile(filename) then + interfaces.showmessage("interactions",5,filename) + filestreams[filename] = false + return nil + else + local basename = file.basename(filename) + local a = pdfdictionary { Type = pdfconstant("EmbeddedFile") } + local f = pdfimmediateobj("streamfile",filename,a()) + local d = pdfdictionary { + Type = pdfconstant("Filespec"), + F = pdfstring(newname or basename), + UF = pdfstring(newname or basename), + EF = pdfdictionary { F = pdfreference(f) }, + } + local r = pdfreference(pdfimmediateobj(tostring(d))) + filestreams[filename] = r + return r + end +end + function codeinjections.attachfile(specification) local attachment = interactions.attachment(specification.label) if not attachment then @@ -156,20 +183,8 @@ function codeinjections.attachfile(specification) if newname == "" then newname = filename end local aref = attachments[label] if not aref then - if not lfs.isfile(filename) then - interfaces.showmessage("interactions",5,filename) - return -- todo: message - else - local f = pdf.immediateobj("streamfile",filename) - filestreams[filename] = f - local d = pdfdictionary { - Type = pdfconstant("Filespec"), - F = newname, - EF = pdfdictionary { F = pdfreference(d) }, - } - aref = pdfreference(pdfimmediateobj(tostring(d))) - attachments[label] = aref - end + aref = codeinjections.embedfile(filename,newname) + attachments[label] = aref end local name, appearance = analyzesymbol(specification.symbol) local d = pdfdictionary { diff --git a/tex/generic/context/luatex-fonts-merged.lua b/tex/generic/context/luatex-fonts-merged.lua index bb7efccb1..9938caedd 100644 --- a/tex/generic/context/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts-merged.lua -- parent file : c:/data/develop/context/texmf/tex/generic/context/luatex-fonts.lua --- merge date : 12/30/09 23:55:40 +-- merge date : 12/31/09 14:23:09 do -- begin closure to overcome local limits and interference |