ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Michail Vidiassov <master@iaas.msu.ru>
To: Hans Hagen <pragma@wxs.nl>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: attachment attaches twice - more research
Date: Wed, 23 Feb 2011 13:21:51 +0300 (MSK)	[thread overview]
Message-ID: <alpine.OSX.2.00.1102231308130.65648@macbook.local> (raw)
In-Reply-To: <4D61AD94.8020601@wxs.nl>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1389 bytes --]

Dear Hans,

On Mon, 21 Feb 2011, Hans Hagen wrote:

> i'll patch lpdf-wid but somehow I get the impression that it's more a viewer 
> issue (the list shown seems to be a merge of filename as well as symbolic 
> names while a clever list builder should look at the referred objects) ... 
> but maybe no one else usesvdifferent symbolic names (we had similar issues 
> with fields in the past and even now advanced field support is somewhat 
> bugged one or the other way, depending on the viewer version, esp chained 
> ones)

to say the truth I do not understand what are you talking about :(
The issues I have in mind - separating global attachments and attachments 
linked to icons on pages, additional descriptions for attached files -
are addressed in the attached patches.
I am not sure about using attachment lebel as "T" key, that is indended for 
following:
The text label that shall be displayed in the title bar of the annotation’s 
pop-up window when open and active. This entry shall identify the user who 
added the annotation.
and shows as the upper line when mouse pointer is above attachment icon.
Did not try to have file size and time information added to file stream -
but it'd be nice to have.

         Sincerely, Michail
PS. Patches show what I want done, not how it is to be done.
Just hope that my lua may be more clear than my English.

[-- Attachment #2: Type: TEXT/PLAIN, Size: 337 bytes --]

--- back-ini.lua.org	2011-02-16 01:53:17.000000000 +0300
+++ back-ini.lua	2011-02-23 09:17:50.000000000 +0300
@@ -67,6 +67,7 @@
     registercomment        = nothing,
 
     embedfile              = nothing,
+    globattachfile         = nothing,
     attachfile             = nothing,
     attachmentid           = nothing,
 

[-- Attachment #3: Type: TEXT/PLAIN, Size: 939 bytes --]

--- scrn-int.mkiv.org	2011-01-31 13:26:23.000000000 +0300
+++ scrn-int.mkiv	2011-02-23 12:34:22.000000000 +0300
@@ -405,6 +405,25 @@
 % % \setupattachments[\c!symbol={symbol-normal,symbol-down}]
 %
 % \starttext \attachment[whatever] \stoptext
+%
+% \globattachment[test.tex]
+% \globattachment[description][test.tex]
+% \globattachment[description][newname.tex][test.tex]
+
+\def\globattachment
+  {\dotripleempty\doglobattachment}
+
+\def\doglobattachment[#1][#2][#3]% description newfilename filename
+  {\ifthirdargument
+     \dodoglobattachment{#1}{#2}{#3}%
+   \else\ifsecondargument
+     \dodoglobattachment{#1}{}{#2}%
+   \else
+     \dodoglobattachment{}{}{#1}%
+   \fi\fi}
+
+\def\dodoglobattachment#1#2#3% description newfilename filename
+  {\ctxlua{backends.codeinjections.globattachfile{description="#1",newname="#2",filename="#3"}}}
 
 \def\useattachment
   {\doquadrupleempty\douseattachment}

[-- Attachment #4: Type: TEXT/PLAIN, Size: 2381 bytes --]

--- lpdf-wid.lua.org	2011-02-08 22:41:44.000000000 +0300
+++ lpdf-wid.lua	2011-02-23 12:27:53.000000000 +0300
@@ -160,14 +160,14 @@
 
 --
 
-local nofattachments, attachments, filestreams = 0, { }, { }
+local nofattachments, attachments, filestreams, globfilestreams = 0, { }, { }, { }
 
 -- todo: hash and embed once
 
 local function flushembeddedfiles()
-    if next(filestreams) then
+    if next(globfilestreams) then
         local e = pdfarray()
-        for name, reference in next, filestreams do
+        for name, reference in next, globfilestreams do
             if reference then
                 e[#e+1] = pdfstring(name)
                 e[#e+1] = reference -- already a reference
@@ -181,7 +181,7 @@
 
 lpdf.registerdocumentfinalizer(flushembeddedfiles,"embeddedfiles")
 
-function codeinjections.embedfile(filename)
+function codeinjections.embedfile(filename,newname,description)
     local r = filestreams[filename]
     if r == false then
         return nil
@@ -201,12 +201,28 @@
             UF   = pdfstring(newname or basename),
             EF   = pdfdictionary { F = pdfreference(f) },
         }
+        if description then
+            d["Desc"] = pdfstring(description)
+        end
         local r = pdfreference(pdfflushobject(d))
         filestreams[filename] = r
         return r
     end
 end
 
+function codeinjections.globattachfile(specification)
+    local filename = specification.filename
+    if not filename or filename == "" then
+        -- todo: message
+        return
+    end
+    local description = specification.description or ""
+    local newname = specification.newname or ""
+    if description == "" then description = nil end
+    if newname == "" then newname = nil end
+    globfilestreams[filename] = codeinjections.embedfile(filename,newname,description)
+end
+
 function codeinjections.attachfile(specification)
     local attachment = interactions.attachments.attachment(specification.label)
     if not attachment then
@@ -239,6 +255,7 @@
         AP       = appearance,
         OC       = analyzelayer(specification.layer),
         C        = pdfcolorspec(specification.colormodel,specification.colorvalue),
+        T        = pdfstring(label),
     }
     -- as soon as we can ask for the dimensions of an xform we can
     -- use them here

[-- Attachment #5: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  parent reply	other threads:[~2011-02-23 10:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-20  7:54 attachment attaches twice Reviczky, Adam
2011-02-20  9:40 ` Michail Vidiassov
2011-02-20 22:21   ` attachment attaches twice - more research Michail Vidiassov
2011-02-21  0:11     ` Hans Hagen
2011-02-21  5:49       ` attachment attaches twice - please, do not fix by trimming Michail Vidiassov
2011-02-22  5:25       ` \useattachment: Embedding files in PDFs - was "attachment attaches twice - more research" Michail Vidiassov
2011-02-23 10:21       ` Michail Vidiassov [this message]
2011-02-23 10:46         ` attachment attaches twice - more research Hans Hagen
2011-02-23 11:35           ` Michail Vidiassov
2011-02-26 23:22             ` Hans Hagen
2011-02-28  7:52       ` attachment attaches twice - the fix was minimal Michail Vidiassov
2011-02-28  8:46         ` Hans Hagen
2011-02-28  9:24           ` attachment attaches twice - the fix was minimal (?) Michail Vidiassov
2011-02-28  9:57             ` Hans Hagen
2011-04-29  7:24           ` attachment attaches twice - the fix was minimal Michail Vidiassov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.OSX.2.00.1102231308130.65648@macbook.local \
    --to=master@iaas.msu.ru \
    --cc=ntg-context@ntg.nl \
    --cc=pragma@wxs.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).