Debian Codegraph @

reports/ll2visio.ll

raw
1 /*
2 * @progname ll2visio.ll
3 * @version 1 of 1999-04-02
4 * @author Rafal T. Prinke ([email protected])
5 * @category
6 * @output VISIO 5 diagram
7 * @description
8 *
9 * This program generates a text file with male line descendants
10 * which can be imported by VISIO 5 and converted to a diagram.
11 *
12 * The main procedure is based on Tom Wetmore's _pdesc2_ report.
13 * The procedures "longvitals" and "spousevitals" were originally
14 * based on the same in Tom Wetmore's _register1_ report but
15 * have been changed beyond recognition.
16 *
17 * The included procedures "upl2.ll" were written by Paul McBride.
18 *
19 * The text file describing a diagram to be constructed in VISIO 5
20 * consists of records (lines) and data fields separated with a comma (.csv)
21 * or a tab (.txt). It can also use an arbitrary delimiter but this report
22 * uses a comma so the output file should be given a .CSV extension.
23 * The CR (hard return) character is not treated as end of record if
24 * enclosed in quotation marks. Comment lines are escaped with a semicolon.
25 * All measurements are in inches.
26 *
27 * Here is a quick reference to record types. For one field records
28 * I have added possible values [with explanations in brackets].
29 *
30 * <record type,> <field,field,field...>
31 *
32 * Master,MasterID,StencilName
33 *
34 * PlacementStyle,Style (0|1|2) [Radial|TopToBottom|LeftToRight]
35 * RoutingStyle,Style (1|2|3|4|5|) [RightAngle||||Flowchart]
36 *
37 * NodeToLineClearance,Horizontal,Vertical
38 * LineToLineClearance,Horizontal,Vertical
39 *
40 * Gridding,UseGrid (0|1) [no|yes]
41 * BlockSize,Width,Length
42 * AvenueSize,Width,Height
43 *
44 * Template,FileName
45 * Property,Master,RowName,Label,Prompt,Type,Format,Value,Hidden,Ask
46 *
47 * Shape,ID,Master,Text,X,Y,Width,Height,Property
48 * Link,ID,Master,Text,From,To
49 *
50 */
51
52 include("upl2.ll")
53
54 global(persons)
55 global(mens)
56 global(ind1)
57 global(first)
58 global(maxgen)
59 global(upl_tag_list)
60 global(upl_before_list)
61 global(upl_after_list)
62 global(upl_level_list)
63 global(upl_process_list)
64 global(upl_out_type) /* 0 = both, 1 = screen, 2 = file */
65
66 proc main () {
67
68 list(persons)
69 table(mens)
70 call upl_build()
71 set(upl_out_type, 2) /* output to file */
72
73 while(not(indi)) {
74 getindi(indi)
75 }
76 getintmsg(maxgen,"How many generations? ")
77
78 call head(indi)
79 call mensae(indi)
80 call pout(0, indi)
81 set(first,key(indi))
82
83 while(not(empty(persons))) {
84 set(p,pop(persons))
85 call longvitals(p)
86 }
87 }
88
89 /* This procedure produces a list of individuals which is then
90 * popped for final output. The reason is that VISIO 5 seems to
91 * lay out the shapes from top to bottom and from right to left,
92 * so the older children would be on the right and younger on the left,
93 * while in traditional genealogical tables the older children are
94 * on the left.
95 */
96
97 proc pout(gen, indi)
98 {
99 push(persons, indi)
100 set(next, add(1, gen))
101 families(indi,fam,sp,num) {
102 if (lt(next,maxgen)) {
103
104 /*
105 remove the condition below to include all descendants
106 (this may not work well yet - father/mother functions need modification)
107 */
108
109 if(eqstr(sex(indi),"M")) {
110 children(fam, child, no) {
111 call pout(next, child)
112 }
113 }
114 }
115 }
116 }
117
118 /*
119 * The following is the procedure outputting the header of the .csv
120 * file for import to VISIO 5. The records field and allowed values
121 * can be altered to give intended results.
122 */
123
124 proc head(u)
125 {
126
127 "Master,AUTO,Auto-height Box,Basic Flowchart Shapes.VSS\n"
128 "Master,CON,Bottom to top variable,Connectors and Callouts.VSS\n"
129 "PlacementStyle,1\n"
130 "RoutingStyle,1\n"
131 ";RoutingStyle,7\n"
132 "AvenueSize,0.15,0.15\n"
133 "LineToLineClearance,0.1,0.1\n"
134 "NodeToLineClearance,0.1,0.1\n"
135 "BlockSize,0.2,0.2\n"
136 "Gridding,0\n"
137 ";Property,AUTO,,,,\n"
138 ";Template,\n"
139 "\n"
140 }
141
142 /*
143 * The remaining procedures define what information goes into
144 * one person box. This is rather specific to my files and uses
145 * Polish terms so should be adapted to one's needs.
146 */
147
148
149 proc longvitals(i)
150 {
151 set(ikey,key(i))
152 set(ind1,i)
153
154 /*
155 * The following line is the beginning of an individual shape (or box)
156 * definition, and then the text inside it is constructed.
157 * NOTE: if there are quotation marks in the data, there may be problems.
158 */
159
160 "Shape," ikey ",AUTO," "\""
161
162 /* The following fragment is intended to overcome the "unknown mother"
163 * problem when numbering marriages. It is assumed that a dummy FAM record
164 * (a) has no WIFE, (b) has the word "ANY" as the wife's name, or (c) has two
165 * or more numbers separated with the bar character as her name (e.g. "2|3")
166 * when only some wives are possible mothers.
167 */
168
169
170 if(nestr(ikey,first)) {
171 if (ne(nfamilies(father(i)),1)) {
172 if (eqstr(name(mother),"ANY")) {
173 "(n) "
174 }
175 elsif (index(name(mother(i)),"|",1)) {
176 "(" name(mother) ") "
177 }
178 else {
179 set(wnm,0)
180 families(father(i),a,b,c) {
181 if (wife(parents(i))) {
182 set(wnm,add(wnm,1))
183 }
184 if (eqstr(key(a),key(parents(i)))) {
185 if (wife(parents(i))) {
186 "(" d(wnm) ") " }
187 else { "(n) " }
188 }
189 }
190 }
191 }
192 }
193
194 /* biographical data report on person is called */
195
196 call upl_report(i)
197
198 if (eq(1,nspouses(i))) {
199 spouses(i,s,f,n) {
200 "; x "
201 call spousevitals(s,f)
202 }
203 } else {
204 spouses(i,s,f,n) {
205 "; x (" d(n) ") "
206 call spousevitals(s,f)
207 }
208 }
209
210 "\"\n"
211
212 /*
213 * The following line is the definition of a link between two boxes.
214 * The condition excludes up-link from the first person.
215 */
216
217 if(nestr(ikey,first)) { "Link,,CON,," key(father(i)) "," key(i) "\n" }
218
219 }
220
221 proc spousevitals (spouse,fam)
222 {
223 set(e,marriage(fam))
224 if (and(e,long(e))) { mylong(e) ", " }
225 roz(fam)
226
227 /* biographical data report on spouse is called */
228
229 call upl_report(spouse)
230
231 set(dad,father(spouse))
232 set(mom,mother(spouse))
233 if (or(dad,mom)) {
234 ", "
235 if (male(spouse)) { "s. " }
236 elsif (female(spouse)) { "dau. " }
237 else { "ch. " }
238 }
239
240 if (dad) { givens(dad) /* "==a" */
241 fornodes(inode(dad), ok) {
242 if (eqstr(tag(ok),"OCCU")) {
243 ", " value(ok)
244 }
245 }
246 }
247
248 /* Other marriages of the spouse. */
249
250 set(srd,0)
251 if (gt(nspouses(spouse),1)) { " ["
252 spouses(spouse,ind2,fm,nsp) {
253 if (ne(ind2,ind1)) {
254 if (srd) { "; " }
255 " x (" d(nsp) ") "
256 set (es,marriage(fm))
257 if (and(es,long(es))) { mylong(es) " " }
258 roz(fm)
259 name(ind2,0)
260 set(srd,1)
261 }
262 }
263 "]"
264 }
265 }
266
267 func mylong(ev)
268 {
269 list(datum)
270 extracttokens(date(ev),datum,n," ")
271 forlist(datum,q,n) {
272 if (lookup(mens,q)) { lookup(mens,q) }
273 else { q }
274 }
275 if(place(ev)) {
276 " (" place(ev) ")"
277 }
278 }
279
280
281 func roz(fx)
282 {
283 fornodes(root(fx), ok) {
284 if (eqstr(tag(ok),"DIV")) {
285 ", div."
286 fornodes(ok, dt) {
287 if (eqstr(tag(dt),"DATE")) {
288 " " mylong(dt)
289 }
290 }
291 }
292 }
293 }
294
295
296 /* Table of date tokens follows. */
297
298 proc mensae(w)
299 {
300 insert(mens,"JAN",".I.")
301 insert(mens,"FEB",".II.")
302 insert(mens,"MAR",".III.")
303 insert(mens,"APR",".IV.")
304 insert(mens,"MAY",".V.")
305 insert(mens,"JUN",".VI.")
306 insert(mens,"JUL",".VII.")
307 insert(mens,"AUG",".VIII.")
308 insert(mens,"SEP",".IX.")
309 insert(mens,"OCT",".X.")
310 insert(mens,"NOV",".XI.")
311 insert(mens,"DEC",".XII.")
312 insert(mens,"BEF","a")
313 insert(mens,"AFT","p")
314 insert(mens,"ABT","c")
315 insert(mens,"CIR","c")
316 insert(mens,"BET","")
317 insert(mens,"AND","/")
318 }
319